Example #1
0
 public void TryStartWatchingScreen()
 {
     if (_lastMkEventEnd == null)
     {
         _lastMkEventEnd = InternalTimeService.GetCurrentDateTime();
     }
 }
        public static WorkTime CreateStartedManually()
        {
            var workTime = new WorkTime(_id--, UserTestUtils.CreateTestUser(), null, InternalTimeService.GetCurrentDateTime().AddMinutes(10));

            workTime.StartManually();
            workTime.MarkPendingEventsAsHandled();
            return(workTime);
        }
Example #3
0
        public void TryAddWatchingScreen()
        {
            if (_lastMkEventEnd.HasValue)
            {
                var diff = InternalTimeService.GetCurrentDateTime() - _lastMkEventEnd.Value;
                if (diff.TotalMilliseconds > _config.WatchingScreenThreshold)
                {
                    Debug.WriteLine("Adding user watching screen diff: " + diff.TotalMilliseconds);
                    WorkTime?.AddUserWatchingScreen(_lastMkEventEnd.Value, (long)diff.TotalMilliseconds, _lastActiveWinExecutable);
                }

                _lastMkEventEnd = null;
            }
        }
Example #4
0
        public void SetResored_when_interrupted_generates_event()
        {
            var workTime = WorkTimeTestUtils.CreateManual(_user);

            workTime.StartManually();
            workTime.MarkPendingEventsAsHandled();

            workTime.SetInterrupted();

            workTime.PendingEvents.Last().Should().BeOfType <WorkTimeInterrupted>();

            InternalTimeService.GetCurrentDateTime = () => DateTime.UtcNow.AddMilliseconds(2000);

            workTime.SetRestored();

            workTime.PendingEvents.Last().Should().BeOfType <WorkTimeRestored>();

            var restoredEv = workTime.PendingEvents.Last() as WorkTimeRestored;

            restoredEv.TotalTimeMs.Should().BeInRange(2000, 2100);

            //not throwing
            workTime.AddRecognitionFailure(InternalTimeService.GetCurrentDateTime(), true, false);
        }
Example #5
0
 public void SetStart()
 {
     _lastMkEventEnd          = InternalTimeService.GetCurrentDateTime();
     _lastActiveWinExecutable = UnknownExecutableName;
 }
Example #6
0
 public void StartRecognitionFailure() => _recognitionFailureStart = InternalTimeService.GetCurrentDateTime();
 public static WorkTime CreateManual(User user)
 {
     Debug.WriteLine(_id);
     return(new WorkTime(Interlocked.Decrement(ref _id), user, null, InternalTimeService.GetCurrentDateTime().AddMinutes(10)));
 }