public SessionTimestampLogger(string timestampFilePath, SessionInfoProvider sessionInfoProvider, EventSaver eventSaver, ILog log)
            : base(nameof(SessionTimestampLogger), log)
        {
            _timestampFilePath   = timestampFilePath;
            _sessionInfoProvider = sessionInfoProvider;
            _eventSaver          = eventSaver;

            _timestampSaveTimer.Elapsed += TimestampSaveTimer_Elapsed;

            var savedTimestamp = GetSavedTimestamp();

            if (savedTimestamp != null)
            {
                GenerateSessionEndEvent(savedTimestamp);
                ClearSavedTimestamp();
            }

            SessionSwitchMonitor.SessionSwitch += SessionSwitchMonitor_SessionSwitch;

            var state = WorkstationHelper.GetSessionLockState(WorkstationHelper.GetSessionId());

            if (state == WorkstationHelper.LockState.Unlocked)
            {
                SaveOrUpdateTimestamp(CreateNewTimestamp());
                _timestampSaveTimer.Start();
            }
        }
示例#2
0
        void GenerateNewSessionId()
        {
            PreviousSession = CurrentSession;
            var virtualSessionId = Guid.NewGuid().ToString();
            var sessionName      = WorkstationHelper.GetSessionName(WorkstationHelper.GetSessionId());

            CurrentSession = new SessionInfo(virtualSessionId, sessionName);
            WriteLine($"Generated new session id: (current: {CurrentSession?.SessionId}), (prev: {PreviousSession?.SessionId})");
        }
示例#3
0
        void GenerateNewIdIfUnlocked()
        {
            var sid   = WorkstationHelper.GetSessionId();
            var state = WorkstationHelper.GetSessionLockState(sid);
            var name  = WorkstationHelper.GetSessionName(sid);

            WriteLine($"Startup sid:{sid}, state:{state}, name:{name}");

            if (state == WorkstationHelper.LockState.Unlocked && name != "SYSTEM")
            {
                GenerateNewSessionId();
            }
        }