Themelia Pro A powerful new development platform built on ASP.NET.
 
Accessing User Count and Application Lifetime
 
 

In addition to this startup and shutdown functionality, the Themelia.Web.Application class keeps track of when your application started and how many users are currently active on the system. You can access this information via the following static objects:

  • Themelia.Web.Application.AppStartDateTime (DateTime value)
  • Themelia.Web.Application.TimeRunning (Int32 value is seconds)
  • Themelia.Web.Application.TotalUserCount (Int32 value)

Full Example

Below is an example of a complete session application processor:

using System;
//+
using Themelia.Web;
//+
namespace Sample.Web
{
    public class SessionApplicationProcessor : Themelia.Web.SessionApplicationProcessorBase
    {
        //- @Info -//
        public class Info
        {
            public const String User = "User";
            public const String Number = "Number";
            public const String TimeArrived = "TimeArrived";
        }
 
        //+
        //- @OnStartup -//
        public override void OnStartup()
        {
            HttpData.SetScopedSessionItem<DateTime>(Info.User, Info.TimeArrived, DateTime.Now);
            HttpData.SetScopedSessionItem<Int32>(Info.User, Info.Number, Themelia.Web.Application.TotalUserCount);
        }
    }
}

This example saves the user�s arrival time and their sequential user number into session state using Themelia�s HTTP data manager.

Than at any time before session times out, this information can be accessed on any web page like this:

using System;
//+
using Themelia.Web;
//+
using Info = Sample.Web.SessionApplicationProcessor.Info;
//+
namespace Sequence.Home
{
    public partial class StepB : Themelia.Web.Controls.SequenceUserControl
    {
        //- #OnInit -//
        protected override void OnInit(System.EventArgs e)
        {
            Int32 userNumber = HttpData.GetScopedSessionItem<Int32>(Info.User, Info.Number);
            DateTime timeArrived = HttpData.GetScopedSessionItem<DateTime>(Info.User, Info.TimeArrived);
            //+
            Response.Write("You arrived at  " + timeArrived.ToString() + ".");
            Response.Write("You are user number " + userNumber.ToString() + ".");
            //+
            base.OnInit(e);
        }
    }
}

This will show information like this:

You arrived at 3/21/2009 10:26:12 PM.
You are user number 1.

When a second user arrives, it may say this:

You arrived at 3/21/2009 10:28:33 PM.
You are user number 2.