Example #1
0
        //Summarize information about user and environment
        private string GetBrowserInfo()
        {
            var browser          = this.Request.Browser;
            var userName         = this.User.Identity.Name;
            var totalOnlineUsers = (int)AppStateHelper.Get(AppStateKeys.ONLINE, 0);

            var result = String.Format(
                @"Browser: {0} {1},<br />EcmaScript: {2},<br />JavaScript: {3},<br />Platform: {4}," +
                "<br />Cookies: {5},<br />ActiveXControls: {6},<br />JavaApplets {7},<br />Frames: {8}," +
                "<br />IsMobile: {9},<br />Manufacture: {10},<br />Model: {11}," +
                "<br />User Name: {12}{13},<br />Online: {14},<br />Framework: {15}, <br /> OS: {16}",
                browser.Browser,
                browser.Version,
                browser.EcmaScriptVersion,
                browser["JavaScriptVersion"],
                browser.Platform,
                browser.Cookies,
                browser.ActiveXControls,
                browser.JavaApplets,
                browser.Frames,
                browser.IsMobileDevice,
                browser.MobileDeviceManufacturer,
                browser.MobileDeviceModel,
                string.Format("{0} ({1})", this.CurrentADUser.Name, this.CurrentADUser.EmailAddress),
                userName.Length == 0 ? "" : string.Format("({0})", userName.Replace(@"\", "&#92;")),
                totalOnlineUsers,
                Environment.Version.ToString(),
                Environment.OSVersion.ToString()
                );

            return(result);
        }
Example #2
0
        protected void Session_End(object sender, EventArgs e)
        {
            // event is raised when a session is abandoned or expires
            int currentValue = (int)AppStateHelper.Get(AppStateKeys.ONLINE, 0);

            AppStateHelper.Set(AppStateKeys.ONLINE, currentValue - 1);
            AppStateHelper.SetMultiple(new Dictionary <AppStateKeys, object> {
                { AppStateKeys.LAST_REQUEST_TIME, HttpContext.Current.Timestamp },
                { AppStateKeys.LAST_REQUEST_URL, this.Request.RawUrl }
            });
        }
Example #3
0
        protected void Session_Start(object sender, EventArgs e)
        {
            // event is raised each time a new session is created
            int currentValue = (int)AppStateHelper.Get(AppStateKeys.ONLINE, 0);

            AppStateHelper.Set(AppStateKeys.ONLINE, currentValue + 1);
            AppStateHelper.SetMultiple(new Dictionary <AppStateKeys, object> {
                { AppStateKeys.LAST_REQUEST_TIME, HttpContext.Current.Timestamp },
                { AppStateKeys.LAST_REQUEST_URL, this.Request.RawUrl }
            });
        }
        public ActionResult Increment()
        {
            int currentValue = (int)AppStateHelper.Get(AppStateKeys.COUNTER, 0);

            AppStateHelper.Set(AppStateKeys.COUNTER, currentValue + 1);
            AppStateHelper.SetMultiple(new Dictionary <AppStateKeys, object> {
                { AppStateKeys.LAST_REQUEST_TIME, HttpContext.Timestamp },
                { AppStateKeys.LAST_REQUEST_URL, Request.RawUrl }
            });
            return(RedirectToAction("Index"));
        }
        public ActionResult Index()
        {
            Dictionary <string, object> data = new Dictionary <string, object>();

            data.Add("Counter", AppStateHelper.Get(AppStateKeys.COUNTER, 0));
            IDictionary <AppStateKeys, object> stateData
                = AppStateHelper.GetMultiple(AppStateKeys.LAST_REQUEST_TIME,
                                             AppStateKeys.LAST_REQUEST_URL);

            foreach (AppStateKeys key in stateData.Keys)
            {
                data.Add(Enum.GetName(typeof(AppStateKeys), key), stateData[key]);
            }
            return(View(data));
        }