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();
            }
        }
Esempio n. 2
0
        public EventSaver(SessionInfoProvider sessionInfoProvider, IWorkstationIdProvider workstationIdProvider, string eventsDirectoryPath, ILog log)
            : base(nameof(EventSaver), log)
        {
            EventsDirectoryPath = eventsDirectoryPath;

            if (!Directory.Exists(EventsDirectoryPath))
            {
                Directory.CreateDirectory(EventsDirectoryPath);
            }

            _eventFactory = new EventFactory(sessionInfoProvider, workstationIdProvider, log);
        }
Esempio n. 3
0
 public EventFactory(SessionInfoProvider sessionInfoProvider, IWorkstationIdProvider workstationIdProvider, ILog log)
 {
     _sessionInfoProvider   = sessionInfoProvider;
     _workstationIdProvider = workstationIdProvider;
 }