ResetSessionAttributes() private méthode

private ResetSessionAttributes ( System.DateTime now ) : void
now System.DateTime
Résultat void
Exemple #1
0
        private void ProcessSession()
        {
            var now = DateTime.Now;

            // very firsts Session
            if (ActivityState == null)
            {
                // create fresh activity state
                ActivityState = new ActivityState();
                ActivityState.SessionCount = 1; // first session

                TransferSessionPackage();

                ActivityState.ResetSessionAttributes(now);
                ActivityState.Enabled = Enabled;
                WriteActivityStateInternal();

                return;
            }

            var lastInterval = now - ActivityState.LastActivity.Value;

            if (lastInterval.Ticks < 0)
            {
                Logger.Error("Time Travel!");
                ActivityState.LastActivity = now;
                WriteActivityStateInternal();
                return;
            }

            // new session
            if (lastInterval > SessionInterval)
            {
                ActivityState.SessionCount++;
                ActivityState.LastInterval = lastInterval;

                TransferSessionPackage();

                ActivityState.ResetSessionAttributes(now);
                WriteActivityStateInternal();

                return;
            }

            // new subsession
            if (lastInterval > SubsessionInterval)
            {
                ActivityState.SubSessionCount++;
                ActivityState.SessionLenght += lastInterval;
                ActivityState.LastActivity   = now;

                WriteActivityStateInternal();
                Logger.Info("Started subsession {0} of session {1}",
                            ActivityState.SubSessionCount, ActivityState.SessionCount);
                return;
            }
        }
        private void ProcessSession()
        {
            var now = DateTime.Now;

            // very firsts Session
            if (ActivityState == null)
            {
                // create fresh activity state
                ActivityState = new ActivityState();
                ActivityState.SessionCount = 1; // first session

                TransferSessionPackage();

                ActivityState.ResetSessionAttributes(now);
                ActivityState.Enabled = Enabled;
                WriteActivityStateInternal();

                return;
            }

            var lastInterval = now - ActivityState.LastActivity.Value;

            if (lastInterval.Ticks < 0)
            {
                Logger.Error("Time Travel!");
                ActivityState.LastActivity = now;
                WriteActivityStateInternal();
                return;
            }

            // new session
            if (lastInterval > SessionInterval)
            {
                ActivityState.SessionCount++;
                ActivityState.LastInterval = lastInterval;

                TransferSessionPackage();

                ActivityState.ResetSessionAttributes(now);
                WriteActivityStateInternal();

                return;
            }

            // new subsession
            if (lastInterval > SubsessionInterval)
            {
                ActivityState.SubSessionCount++;
                ActivityState.SessionLenght += lastInterval;
                ActivityState.LastActivity = now;

                WriteActivityStateInternal();
                Logger.Info("Started subsession {0} of session {1}",
                    ActivityState.SubSessionCount, ActivityState.SessionCount);
                return;
            }
        }