コード例 #1
0
        //---------------------------------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        ///     Using the OnUnload method for performance benchmarking of pages
        /// </summary>
        protected override void OnUnload(EventArgs e)
        {
            // Performance benchmarking ...
            DateTime dt2 = DateTime.Now;
            TimeSpan t1  = dt2.Subtract(dt1);

            string currentPageName = HttpContext.Current.Request.Url.AbsoluteUri;

            int currentUserID = (Authorisation.CurrentUser != null) ? Authorisation.CurrentUser.ID : 0;

            // 14-Jan-2015 - Get the IP Address
            string srcIPAddress = IPAddressHelper.GetIP4OrAnyAddressFromHTTPRequest();

            // 11-Mar-2016 - Sanity check - when pages crash, dt1 is not always set so is the null date, so if the difference between dt1 and dt2 is more than one day (!!), use dt2
            // 16-Mar-2016 - And reset the timespan so it is sensible, otherwise the average response time queries in view page performance do not work!
            // you can find the crashed pages in the db with this query: SELECT * FROM Log_PageRequests WHERE Server_Render_Speed > 63593600000000;
            DateTime logTime = dt1;

            if (t1.TotalMilliseconds > 86400000)
            {
                logTime = dt2;
                t1      = new TimeSpan(0, 0, 0, 0, 50);
            }

            LoggerDB.LogPageRequestInDatabase(MGLSessionInterface.Instance().Config, MGLApplicationInterface.Instance().ApplicationName,
                                              Session.SessionID, MGLSessionInterface.Instance().SessionID, currentPageName, dt2, t1.TotalMilliseconds, currentUserID, srcIPAddress);
//            Logger.LogError(currentPageName + "Time to build page: " + t1.TotalMilliseconds);

            base.OnUnload(e);
        }
コード例 #2
0
        //---------------------------------------------------------------------------------------------------------------------------------------------------------------
        public bool LogLogin(int userID, bool successful)
        {
            ////////////////////////////////////////
            // increment the total logins, clear the number of incorrect logins ....
            // add todays date, IP address etc ....

            if (successful)
            {
                dbInfo.ExecuteSQL("UPDATE " + tnUsers + " SET TotalLogins=TotalLogins+1, NumberOfIncorrectLogins=0 WHERE ID=" + userID + ";", ref successful);

                //Update other bits of info in the user table
                StringBuilder builder = new StringBuilder();

                builder.Append("UPDATE " + tnUsers + " SET LastLoginDate = '");
                builder.Append(DateTimeInformation.GetUniversalDateTime(DateTime.Now).ToString());
                builder.Append("' WHERE ID = ");
                builder.Append(userID);
                builder.Append(";");

                // Last IP
                builder.Append("UPDATE " + tnUsers + " SET LastIP = ");
                builder.Append("'");
                // 27-Nov-2015 - Converted to use this v4IPAddress method.
                builder.Append(IPAddressHelper.GetIP4OrAnyAddressFromHTTPRequest());
//                builder.Append(HttpContext.Current.Request.UserHostAddress);
                builder.Append("' ");
                builder.Append(" WHERE ID = ");
                builder.Append(userID);
                builder.Append(";");

                // Last browser
                builder.Append("UPDATE " + tnUsers + " SET LastBrowser = ");
                builder.Append("'");
                builder.Append(HttpContext.Current.Request.Browser.Browser);
                builder.Append(" ");
                builder.Append(HttpContext.Current.Request.Browser.Version);
                builder.Append("'");
                builder.Append(" WHERE ID = ");
                builder.Append(userID);
                builder.Append(";");

                dbInfo.ExecuteSQL(builder.ToString(), ref successful);
            }
            else
            {
                dbInfo.ExecuteSQL("UPDATE " + tnUsers + " SET NumberOfIncorrectLogins=NumberOfIncorrectLogins+1 WHERE ID=" + userID + ";", ref successful);
            }
            //            return ! Logger.LogList(dbInfo.GetErrors(), "UserOperations", "LogLogin");
            return(successful);
        }
コード例 #3
0
ファイル: Global.asax.cs プロジェクト: DataNirvana/HSPAdmin
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------
        protected void Session_Start(Object sender, EventArgs e)
        {
            //_____ Add the Config Info to the address seshion interface
            MGL.Web.WebUtilities.MGLSessionInterface.Instance().Config = MGL.Web.WebUtilities.MGLApplicationInterface.Instance().ConfigDefault;

            //____ Generate a new Unique SessionID ...  Use for logging specific sessions ...
            MGLSessionInterface.Instance().GenerateNewSessionID();
            // 8-Jan-2015 - Code that runs when a new session is started - this stops the following error from occurring intermittently:
            // "Session state has created a session id, but cannot save it because the response was already flushed by the application"
            string sessionId = Session.SessionID;

            //_____ Update the number of users in the database ...
            bool success = DataNirvanaWebProcessing.LogNewSiteVisitor(MGLSessionInterface.Instance().Config);

            MGLSessionInterface.Instance().NumberOfUsers = DataNirvanaWebProcessing.GetNumberOfVisitors(MGLSessionInterface.Instance().Config);

            //_____ LEGACY - Increment the number of users ....
            MGLApplicationInterface.Instance().NumberOfUsers++;

            //_____ Set the Users Host Address at the startup of the session ...
            // 27-Nov-2015 - Converted to use this v4IPAddress method.
            //MGLSessionSecurityInterface.Instance().UserIPAddress = Request.UserHostAddress;
            MGLSessionSecurityInterface.Instance().UserIPAddress = IPAddressHelper.GetIP4OrAnyAddressFromHTTPRequest();

            // 7-Dec-2015 - set the default session timeout in minutes in the case locker object.
            //            if (CaseLocker.SessionTimeoutMins == 0) {
            //                CaseLocker.SessionTimeoutMins = Session.Timeout;
            //            }

            // 17-Dec-2015 - align the session UseHTTPS variable with the global variable and always set the session requires HTTPS if HTTPS is true
            MGLSessionInterface.Instance().UseHTTPS = MGLApplicationSecurityInterface.Instance().AppLoginConfig.UseHTTPS;
            if (MGLSessionInterface.Instance().UseHTTPS == true)
            {
                MGLSessionInterface.Instance().SetSessionRequiresHTTPs(Request.Cookies["AnonID"], sessionId, HttpContext.Current.Request.IsLocal);
            }
        }