public bool IsMatch(BuildStatus buildStatus, BuildStatusEnum?previousStatus) { bool isBuildDefinitionMatch = BuildDefinitionId == null || BuildDefinitionId == buildStatus.BuildDefinitionId; if (!isBuildDefinitionMatch) { return(false); } bool isPersonMatch = string.IsNullOrEmpty(TriggerPerson) || TriggerPerson == buildStatus.RequestedBy; if (!isPersonMatch) { return(false); } var newlyBroken = buildStatus.IsNewlyBroken(previousStatus); var newlyFixed = buildStatus.IsNewlyFixed(previousStatus); bool isTriggerTypeMatch = IsTriggerTypeMatch(buildStatus, newlyBroken, newlyFixed); return(isTriggerTypeMatch); }
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); } }