public Backend(InstanceType instanceType, AppType appType) { settingsCollection = SettingsCollectionSerializer.DeSerialize(); trackUsage = new TrackUsage(settingsCollection.AppSettings, settingsCollection.InternalSettings, instanceType, appType); versionControl = new VersionControl(instanceType, appType, trackUsage); jiraTimerCollection = new JiraTimerCollection(settingsCollection.ExportSettings); jiraTimerCollection.exportPrompt += OnExportPromptEvent; jiraConnection = new JiraConnection(trackUsage); idleTimerCollection = new IdleTimerCollection(); ActivityChecker = new ActivityChecker(jiraTimerCollection, settingsCollection.AppSettings); ActivityChecker.NoActivityEvent += OnNoActivityEvent; hearbeat = new Timer(1800000); hearbeat.Elapsed += HearbeatOnElapsed; hearbeat.Start(); if (Settings.AppSettings.TimerRunningOnShutdown.HasValue) { var timer = jiraTimerCollection.GetTimer(Settings.AppSettings.TimerRunningOnShutdown.Value); if (timer != null && timer.DateStarted.Date == DateTime.Now.Date) { JiraTimerCollection.StartTimer(Settings.AppSettings.TimerRunningOnShutdown.Value); } Settings.AppSettings.TimerRunningOnShutdown = null; SaveSettings(false); } HearbeatOnElapsed(this, null); }
public bool StartIdleTimer() { ActivityChecker.StopActivityCheck(); runningTimerWhenIdle = JiraTimerCollection.GetRunningTimerId(); if (runningTimerWhenIdle.HasValue) { jiraTimerCollection.StopTimer(runningTimerWhenIdle.Value); } return(idleTimerCollection.NewLockTimer()); }
public Backend() { appSettings = AppSettingsSerializer.DeSerialize(); jiraConnectionSettings = JiraConnectionSettingsSerializer.DeSerialize(); jiraTimerCollection = new JiraTimerCollection(); idleTimerCollection = new IdleTimerCollection(); ActivityChecker = new ActivityChecker(jiraTimerCollection, appSettings); ActivityChecker.NoActivityEvent += OnNoActivityEvent; hearbeat = new Timer(3600000); hearbeat.Elapsed += HearbeatOnElapsed; hearbeat.Start(); }
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())); }
public void Initialise() { settingsCollection.Initialise(); idleTimerCollection.Initialise(); jiraTimerCollection.Initialise(); recentJiraCollection.Initialise(); if (settingsCollection.InternalSettings.LastChangeLogVersion == new Version(0, 0, 0, 0) && settingsCollection.InternalSettings.NewUser) { throw new MissingConfigException("New User"); } jiraConnection.ReConnect(settingsCollection.JiraConnectionSettings, settingsCollection.ExportSettings); cleanUpAndTrackingHeartbeat.Start(); jiraExportHeartbeat.Start(); BackendModifiedTimers?.Invoke(this, null); if (Settings.AppSettings.TimerRunningOnShutdown.HasValue) { var timer = jiraTimerCollection.GetTimer(Settings.AppSettings.TimerRunningOnShutdown.Value); if (timer != null && timer.DateStarted.Date == DateTime.Now.Date) { JiraTimerCollection.StartTimer(Settings.AppSettings.TimerRunningOnShutdown.Value); } Settings.AppSettings.TimerRunningOnShutdown = null; SaveSettings(false, false); } if (Settings.AppSettings.NoTimerRunningOnShutdown.HasValue) { ActivityChecker.SetValue(Settings.AppSettings.NoTimerRunningOnShutdown.Value); Settings.AppSettings.NoTimerRunningOnShutdown = null; SaveSettings(false, false); } CleanUpAndTrackingHeartbeatOnElapsed(this, null); IsInitialised = true; Task.Run(() => { JiraExportHeartbeatHeartbeatOnElapsed(this, null); }); }
public Backend(InstanceType instanceType) { settingsCollection = SettingsCollectionSerializer.DeSerialize(); versionControl = new VersionControl(instanceType); trackUsage = new TrackUsage(versionControl, settingsCollection, instanceType); versionControl.UpdateCheckOccured += (sender, b) => trackUsage.TrackAppUsage(b ? TrackingType.UpdateCheckManual : TrackingType.UpdateCheck); jiraTimerCollection = new JiraTimerCollection(settingsCollection, trackUsage); jiraTimerCollection.exportPrompt += OnExportPromptEvent; jiraConnection = new JiraConnection(trackUsage); idleTimerCollection = new IdleTimerCollection(); ActivityChecker = new ActivityChecker(jiraTimerCollection, settingsCollection); withThanksCreator = new WithThanksCreator(); premiumChecker = new PremiumChecker(); ActivityChecker.NoActivityEvent += OnNoActivityEvent; var cleanUpAndTrackingHeartbeat = new Timer(TimeSpan.FromMinutes(15).TotalMilliseconds); cleanUpAndTrackingHeartbeat.Elapsed += CleanUpAndTrackingHearbeatOnElapsed; cleanUpAndTrackingHeartbeat.Start(); exportedHeartbeatMutex = new Mutex(false); var jiraExportHearbeat = new Timer(TimeSpan.FromMinutes(10).TotalMilliseconds); jiraExportHearbeat.Elapsed += JiraExportHearbeatHearbeatOnElapsed; jiraExportHearbeat.Start(); if (Settings.AppSettings.TimerRunningOnShutdown.HasValue) { var timer = jiraTimerCollection.GetTimer(Settings.AppSettings.TimerRunningOnShutdown.Value); if (timer != null && timer.DateStarted.Date == DateTime.Now.Date) { JiraTimerCollection.StartTimer(Settings.AppSettings.TimerRunningOnShutdown.Value); } Settings.AppSettings.TimerRunningOnShutdown = null; SaveSettings(false, false); } }
public Backend(InstanceType instanceType) { settingsCollection = new SettingsCollection(SettingsCollectionSerializer.DeSerialize()); versionControl = new VersionControl(instanceType); trackUsage = new TrackUsage(versionControl, settingsCollection, instanceType); jiraTimerCollection = new JiraTimerCollection(settingsCollection, trackUsage); recentJiraCollection = new RecentJiraCollection(); jiraConnection = new JiraConnection(trackUsage, recentJiraCollection); idleTimerCollection = new IdleTimerCollection(); ActivityChecker = new ActivityChecker(jiraTimerCollection, settingsCollection); withThanksCreator = new WithThanksCreator(); versionControl.UpdateCheckOccured += (sender, b) => trackUsage.TrackAppUsage(b ? TrackingType.UpdateCheckManual : TrackingType.UpdateCheck); jiraTimerCollection.ExportPrompt += OnExportPromptEvent; ActivityChecker.NoActivityEvent += OnNoActivityEvent; cleanUpAndTrackingHeartbeat = new Timer(TimeSpan.FromMinutes(15).TotalMilliseconds); cleanUpAndTrackingHeartbeat.Elapsed += CleanUpAndTrackingHeartbeatOnElapsed; exportedHeartbeatMutex = new Mutex(false); jiraExportHeartbeat = new Timer(TimeSpan.FromMinutes(10).TotalMilliseconds); jiraExportHeartbeat.Elapsed += JiraExportHeartbeatHeartbeatOnElapsed; }
public Backend(InstanceType instanceType, AppType appType) { settingsCollection = SettingsCollectionSerializer.DeSerialize(); trackUsage = new TrackUsage(settingsCollection.AppSettings, settingsCollection.InternalSettings, instanceType, appType); versionControl = new VersionControl(instanceType, appType, trackUsage); jiraTimerCollection = new JiraTimerCollection(settingsCollection.ExportSettings, trackUsage); jiraTimerCollection.exportPrompt += OnExportPromptEvent; jiraConnection = new JiraConnection(trackUsage); idleTimerCollection = new IdleTimerCollection(); ActivityChecker = new ActivityChecker(jiraTimerCollection, settingsCollection.AppSettings); withThanksCreator = new WithThanksCreator(); ActivityChecker.NoActivityEvent += OnNoActivityEvent; var cleanUpAndTrackingHearbeat = new Timer(1800000); // 30 minutes cleanUpAndTrackingHearbeat.Elapsed += CleanUpAndTrackingHearbeatOnElapsed; cleanUpAndTrackingHearbeat.Start(); exportedHeartbeatMutex = new Mutex(false); var jiraExportHearbeat = new Timer(600000); //10 minutes jiraExportHearbeat.Elapsed += JiraExportHearbeatHearbeatOnElapsed; jiraExportHearbeat.Start(); if (Settings.AppSettings.TimerRunningOnShutdown.HasValue) { var timer = jiraTimerCollection.GetTimer(Settings.AppSettings.TimerRunningOnShutdown.Value); if (timer != null && timer.DateStarted.Date == DateTime.Now.Date) { JiraTimerCollection.StartTimer(Settings.AppSettings.TimerRunningOnShutdown.Value); } Settings.AppSettings.TimerRunningOnShutdown = null; SaveSettings(false); } }