Ejemplo n.º 1
0
        private void HearbeatOnElapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                jiraTimerCollection.RemoveTimersOlderThanDays(settingsCollection.AppSettings.KeepTimersForDays);
                idleTimerCollection.RemoveOldTimers();
                jiraConnection.UpdateCache();

                var runningTimerId = jiraTimerCollection.GetRunningTimerId();
                if (runningTimerId.HasValue)
                {
                    var runningTimer = jiraTimerCollection.GetTimer(runningTimerId.Value);
                    if (runningTimer.DateStarted.Date != DateTime.Now.Date)
                    {
                        jiraTimerCollection.StopTimer(runningTimerId.Value);
                        jiraTimerCollection.StartTimer(runningTimerId.Value);
                    }
                }

                if (settingsCollection.InternalSettings.LastHeartbeatTracked.Date < DateTime.UtcNow.Date)
                {
                    trackUsage.TrackAppUsage(TrackingType.DailyHearbeat);
                    settingsCollection.InternalSettings.LastHeartbeatTracked = DateTime.UtcNow;
                    settingsCollection.SaveSettings();
                }
            }
            catch { /*Surpress Errors, if this fails timers won't be removed*/ }
        }
Ejemplo n.º 2
0
        private void CleanUpAndTrackingHeartbeatOnElapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                jiraTimerCollection.RemoveTimersOlderThanDays(settingsCollection.AppSettings.KeepTimersForDays);
                idleTimerCollection.RemoveOldTimers();
                jiraConnection.UpdateCache();

                var runningTimerId = jiraTimerCollection.GetRunningTimerId();
                if (runningTimerId.HasValue)
                {
                    var runningTimer = jiraTimerCollection.GetTimer(runningTimerId.Value);
                    if (runningTimer.DateStarted.Date != DateTime.Now.Date)
                    {
                        jiraTimerCollection.StopTimer(runningTimerId.Value, true);
                        jiraTimerCollection.StartTimer(runningTimerId.Value);
                    }
                }
                BackendModifiedTimers?.Invoke(this, null);

                if (settingsCollection.InternalSettings.LastHeartbeatTracked.Date < DateTime.UtcNow.Date)
                {
                    if (versionControl.IsAutomatedDeploy && jiraConnection.IsConnected)
                    {
                        DailyTrackingEvent?.Invoke(this, null);
                        trackUsage.TrackAppUsage(TrackingType.DailyHeartbeat);
                        settingsCollection.InternalSettings.SetLastHeartbeatTracked(DateTime.UtcNow);
                        settingsCollection.SaveSettings();
                    }
                }
            }
            catch { /*Suppress Errors, if this fails timers won't be removed*/ }
        }
Ejemplo n.º 3
0
        public bool StartIdleTimer()
        {
            ActivityChecker.StopActivityCheck();

            runningTimerWhenIdle = JiraTimerCollection.GetRunningTimerId();
            if (runningTimerWhenIdle.HasValue)
            {
                jiraTimerCollection.StopTimer(runningTimerWhenIdle.Value);
            }
            return(idleTimerCollection.NewLockTimer());
        }
Ejemplo n.º 4
0
        public void StartLockTimer(TimeSpan?initalTimeSpan = null)
        {
            ActivityChecker.PauseForLockTimer(initalTimeSpan);

            if (!runningTimerWhenIdle.HasValue)
            {
                runningTimerWhenIdle = JiraTimerCollection.GetRunningTimerId();
                if (runningTimerWhenIdle.HasValue)
                {
                    jiraTimerCollection.StopTimer(runningTimerWhenIdle.Value, true);
                    if (initalTimeSpan.HasValue)
                    {
                        jiraTimerCollection.AdjustTime(runningTimerWhenIdle.Value, initalTimeSpan.Value.Hours, initalTimeSpan.Value.Minutes, false);
                    }
                }
            }

            idleTimerCollection.NewLockTimer(initalTimeSpan.GetValueOrDefault(new TimeSpan()));
        }