async Task OnWorkstationLock(int sessionId, WorkstationEventType eventType) { if (eventType != WorkstationEventType.ComputerLock && eventType != WorkstationEventType.ComputerLogoff) { return; } var we = _eventSaver.GetPrevSessionWorkstationEvent(); we.EventId = eventType; lock (_lpLock) { if (_lockProcedure != null && (DateTime.UtcNow - _lockProcedure.Time).TotalSeconds <= LOCK_EVENT_TIMEOUT) { we.Note = _lockProcedure.Reason.ToString(); we.DeviceId = _bleDeviceManager.Find(_lockProcedure.Mac, 1)?.SerialNo; // Todo: Replace channel magic number with const } else { we.Note = WorkstationLockingReason.NonHideez.ToString(); } _lockProcedure = null; } await _eventSaver.AddNewAsync(we, true); }
void GenerateSessionEndEvent(SessionTimestamp timestamp) { Task.Run(async() => { var baseEvent = _eventSaver.GetWorkstationEvent(); baseEvent.WorkstationSessionId = timestamp.SessionId; baseEvent.UserSession = timestamp.SessionName; baseEvent.Date = timestamp.Time; baseEvent.Note = "Unexpected Shutdown"; baseEvent.EventId = WorkstationEventType.ComputerLock; // TODO: Maybe, add another event for Unexpected Shutdown await _eventSaver.AddNewAsync(baseEvent, true); }); }