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 void setUp() { probeMock = Mock.Create <LastActivityProbe>(); activityListenerMock = Mock.Create <ActivityPeriodsListener>(); clockMock = Mock.Create <Clock>(); activityCheckerSut = new ActivityChecker(probeMock, clockMock); activityCheckerSut.SetActivityListner(activityListenerMock); SetCurrentTime(DateTime.Now); }
public void setUp() { policies = new TimeTablePolicies(); var timeTable = new TimeTable(policies); activityChecker = new ActivityChecker(GetLastActivityProbeStub(), GetClockStub()); activityChecker.SetActivityListner(timeTable); statsReporter = new StatsReporterImpl(timeTable, policies, GetClockStub()); }
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 CheckOutPutNotFromStructuredLG() { var diagnostics = ActivityChecker.Check("Not a valid json"); Assert.AreEqual(diagnostics.Count, 1); Assert.IsTrue(diagnostics[0].Severity == DiagnosticSeverity.Warning); Assert.AreEqual(diagnostics[0].Message, "LG output is not a json object, and will fallback to string format."); diagnostics = ActivityChecker.Check("{}"); Assert.AreEqual(diagnostics.Count, 1); Assert.IsTrue(diagnostics[0].Severity == DiagnosticSeverity.Error); Assert.AreEqual(diagnostics[0].Message, "'type' or '$type' is not exist in lg output json object."); }
static async Task Main(string[] args) { var http = new HttpClient(); var activityChecker = new ActivityChecker(http); var stopwatch = new Stopwatch(); stopwatch.Start(); var activityTime = await activityChecker.GetLastActivityTime(20777669); stopwatch.Stop(); Console.WriteLine(activityTime.ToLongDateString()); Console.WriteLine($"Took {stopwatch.ElapsedMilliseconds}ms"); }
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 async Task CheckStructuredLGDiagnostics() { var context = await GetTurnContext("DignosticStructuredLG.lg"); var languageGenerator = context.TurnState.Get <ILanguageGenerator>(); var lgStringResult = await languageGenerator.Generate(context, "@{ErrorStructuredType()}", null); var diagnostics = ActivityChecker.Check(lgStringResult); Assert.AreEqual(diagnostics.Count, 1); Assert.IsTrue(diagnostics[0].Severity == DiagnosticSeverity.Error); Assert.AreEqual(diagnostics[0].Message, "Type 'mystruct' is not support currently."); lgStringResult = await languageGenerator.Generate(context, "@{ErrorActivityType()}", null); diagnostics = ActivityChecker.Check(lgStringResult); Assert.AreEqual(diagnostics.Count, 2); Assert.IsTrue(diagnostics[0].Severity == DiagnosticSeverity.Error); Assert.AreEqual(diagnostics[0].Message, "'xxx' is not a valid activity type."); Assert.IsTrue(diagnostics[1].Severity == DiagnosticSeverity.Warning); Assert.AreEqual(diagnostics[1].Message, "'invalidproperty' not support in Activity."); lgStringResult = await languageGenerator.Generate(context, "@{ErrorMessage()}", null); diagnostics = ActivityChecker.Check(lgStringResult); Assert.AreEqual(diagnostics.Count, 5); Assert.IsTrue(diagnostics[0].Severity == DiagnosticSeverity.Warning); Assert.AreEqual(diagnostics[0].Message, "'attachment,suggestedaction' not support in Activity."); Assert.IsTrue(diagnostics[1].Severity == DiagnosticSeverity.Warning); Assert.AreEqual(diagnostics[1].Message, "'mystruct' is not card action type."); Assert.IsTrue(diagnostics[2].Severity == DiagnosticSeverity.Error); Assert.AreEqual(diagnostics[2].Message, "'yyy' is not a valid card action type."); Assert.IsTrue(diagnostics[3].Severity == DiagnosticSeverity.Error); Assert.AreEqual(diagnostics[3].Message, "'notsure' is not a boolean value."); Assert.IsTrue(diagnostics[4].Severity == DiagnosticSeverity.Warning); Assert.AreEqual(diagnostics[4].Message, "'mystruct' is not an attachment type."); }
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); } }