/// <summary> /// Process a timer event /// </summary> async private void onTimer(object sender, System.Timers.ElapsedEventArgs e) { string hostname = Workflow.State.HostName; List <Project> enabledProjects = Workflow.GetProjectsToUpdate(); IWorkflowDetails oldDetails = Cache.Details.Clone(); try { await Cache.UpdateAsync(); } catch (OperatorException ex) { ExceptionHandlers.Handle(ex, "Auto-update failed"); return; } MergeRequestUpdates updates = WorkflowDetailsChecker.CheckForUpdates(hostname, enabledProjects, oldDetails, Cache.Details); ProjectWatcher.ProcessUpdates(updates, Workflow.State.HostName, Cache.Details); Trace.TraceInformation( String.Format("[UpdateManager] Merge Request Updates: New {0}, Updated {1}, Closed {2}", updates.NewMergeRequests.Count, updates.UpdatedMergeRequests.Count, updates.ClosedMergeRequests.Count)); OnUpdate?.Invoke(updates); }
public UpdateManager(Workflow.Workflow workflow, ISynchronizeInvoke synchronizeInvoke, UserDefinedSettings settings) { Settings = settings; Workflow = workflow; WorkflowDetailsChecker = new WorkflowDetailsChecker(); ProjectWatcher = new ProjectWatcher(); Cache = new WorkflowDetailsCache(settings, workflow); Timer.Elapsed += onTimer; Timer.SynchronizingObject = synchronizeInvoke; Timer.Start(); }