public void RebuildSince(DateTime? since, Action<string> reportProgress) { try { var buildStatuses = _sosDb.ReadAll(); var sortedBuildStatuses = buildStatuses .Where(buildStatus => since == null || buildStatus.StartedTime > since) .OrderByDescending(buildStatus => buildStatus.LocalStartTime) .ToList(); var totalBuilds = sortedBuildStatuses.Count; var rulesEngine = new RulesEngine(_settings) { DisableSosOnline = true, DisableWritingToSosDb = true }; int i = 0; foreach (var buildStatus in sortedBuildStatuses) { rulesEngine.ExecuteNewBuilds(new List<BuildStatus> {buildStatus}); if (i%10 == 0) { reportProgress(string.Format("Processing {0}/{1}", i, totalBuilds)); } i++; } _settings.Save(); reportProgress("Completed reset successfully"); } catch (Exception ex) { _log.Error("Error in sync", ex); reportProgress("Error, check the logs. " + ex.Message); } }
private void OpenConfigureServerDialog() { bool anyChanges = ConfigureServers.Show(_settings); if (anyChanges) { _settings.ClearDuplicateNameCache(); StopWatchingBuild(); _rulesEngine = null; // reset the rules engine in case it changed (e.g. from TFS to Team City) StartWatchingBuild(); } Activate(); Focus(); _viewBuilds.ReinitializeGettingStarted(); }
private RulesEngine GetRulesEngine() { var rulesEngine = new RulesEngine(_settings); rulesEngine.PlayWindowsAudio += RulesEnginePlayWindowsAudio; rulesEngine.UpdateStatusBar += RulesEngineUpdateStatusBar; rulesEngine.RefreshStatus += RulesEngineRefreshRefreshStatus; rulesEngine.TrayNotify += RulesEngineTrayNotify; rulesEngine.ModalDialog += RulesEngineModalDialog; rulesEngine.SetAudio += RulesEngineSetAudio; rulesEngine.SetLights += RulesEngineSetLights; rulesEngine.SetTrayIcon += RulesEngineSetTrayIcon; rulesEngine.StatsChanged += RulesEngineStatsChanged; rulesEngine.NewAlert += RulesEngineNewAlert; rulesEngine.NewAchievement += RulesEngineNewAchievement; rulesEngine.NewNewsItem += RulesEngineNewNewsItem; rulesEngine.NewUser += RulesEngineNewUser; return rulesEngine; }
public void FireApplicableRulesEngineEvents(BuildStatusEnum?previousWorkingOrBrokenStatus, BuildStatusEnum?previousStatus, RulesEngine rulesEngine, List <Rule> rules) { var rule = rules .Where(r => r.IsMatch(this, previousWorkingOrBrokenStatus)) .OrderByDescending(r => r.PriorityId) .FirstOrDefault(); if (rule != null) { rule.FireEvent(rulesEngine, previousWorkingOrBrokenStatus, this); } rules.ForEach(r => r.FireAnyUntilBuildPassesEvents(rulesEngine, this, previousStatus)); }
public void FireApplicableRulesEngineEvents(BuildStatusEnum? previousWorkingOrBrokenStatus, BuildStatusEnum? previousStatus, RulesEngine rulesEngine, List<Rule> rules) { var rule = rules .Where(r => r.IsMatch(this, previousWorkingOrBrokenStatus)) .OrderByDescending(r => r.PriorityId) .FirstOrDefault(); if (rule != null) rule.FireEvent(rulesEngine, previousWorkingOrBrokenStatus, this); rules.ForEach(r => r.FireAnyUntilBuildPassesEvents(rulesEngine, this, previousStatus)); }
public void FireEvent(RulesEngine rulesEngine, BuildStatusEnum? previousStatus, BuildStatus buildStatus) { var newlyBroken = buildStatus.IsNewlyBroken(previousStatus); var newlyFixed = buildStatus.IsNewlyFixed(previousStatus); string message = null; string okText = null; if (newlyBroken) { message = "Build newly broken by " + buildStatus.RequestedBy; okText = "Rats"; } if (newlyFixed) { message = "Build is passing again"; okText = "Yayy!"; } if (buildStatus.BuildStatusEnum == BuildStatusEnum.InProgress) { message = "Build triggered by " + buildStatus.RequestedBy; okText = "Ok, whatever"; } if (buildStatus.BuildStatusEnum == BuildStatusEnum.Broken && !newlyBroken) { message = "Build still broken"; okText = "Rats"; } if (buildStatus.BuildStatusEnum == BuildStatusEnum.Working && !newlyFixed) { message = "Build passed"; okText = "Yayy!"; } message += " for " + buildStatus.Name; if (buildStatus.BuildStatusEnum == BuildStatusEnum.InProgress && !string.IsNullOrEmpty(buildStatus.Comment)) { message += "\r\n" + buildStatus.Comment; } if (AlertType == AlertType.TrayAlert && !(previousStatus == null && buildStatus.BuildStatusEnum == BuildStatusEnum.Working)) { rulesEngine.InvokeTrayNotify(buildStatus.BuildStatusEnum == BuildStatusEnum.Broken ? ToolTipIcon.Error : ToolTipIcon.Info, string.Format("Build {0}", buildStatus.BuildStatusDescription), message); } if (LedPattern != null) { rulesEngine.InvokeSetLights(LedPattern, LightsDuration); } if (AudioPattern != null) { rulesEngine.InvokeSetAudio(AudioPattern, AudioDuration); } if (AlertType == AlertType.ModalDialog) { rulesEngine.InvokeModalDialog(message, okText); } if (!string.IsNullOrEmpty(WindowsAudioLocation) && previousStatus != null) { rulesEngine.InvokePlayWindowsAudio(WindowsAudioLocation); } }
public void FireAnyUntilBuildPassesEvents(RulesEngine rulesEngine, BuildStatus buildStatus, BuildStatusEnum? previousStatus) { bool newlyFixed = buildStatus.BuildStatusEnum == BuildStatusEnum.Working && previousStatus != null && previousStatus != BuildStatusEnum.Working; if (PlayAudio && PlayAudioUntilBuildPasses && newlyFixed) { rulesEngine.InvokeSetAudio(null, null); } if (PlayLights && PlayLightsUntilBuildPasses && newlyFixed) { rulesEngine.InvokeSetLights(null, null); } }