public string Transition(BuildStatus status) { // Find the Primary State that matches the Input State // ------------------------------------------------------ var activeState = _transition.States.FirstOrDefault(state => state.Name.ToUpper().Equals(status.Status.ToString().ToUpper())); if (activeState == null) return null; // Look for a SubState which matches the conditions // ------------------------------------------------------ var activeSubState = activeState.SubState.FirstOrDefault(subState => subState.Evaluate(_lastChange)); FileLogger.Logger.LogInformation("{3}: State='{0}' and SubState='{1}' and Change='{2}' and LastDate='{4}'", activeState.Name, activeSubState == null ? "None" : activeSubState.Name, activeState != _priState || activeSubState != _subState ? "YES" : "NO", _visualiser, _lastChange); if (activeState != _priState || activeSubState != _subState) { if (activeState != _priState) _lastChange = DateTime.Now; _priState = activeState; _subState = activeSubState; if (activeSubState != null) return activeSubState.Action; return activeState.Action; } return null; }
/// <summary> /// Works out the state of the Monitored Builds. /// </summary> /// <returns>A BuildStatus object that respresents the overall Status of this group of Projects</returns> private BuildStatus DetermineMonitorState() { // The default result is a Positive OK // --------------------------------------------------------------------- var result = new BuildStatus(Name, Name, Status.Success, DateTime.Now, null); foreach (var buildStatus in _builds) { if (buildStatus.Status == Status.Error) { result.Status = Status.Error; break; } if (buildStatus.Status != Status.Success) { result.Status = buildStatus.Status; result.ID = buildStatus.ID; result.Name = buildStatus.Name; result.DateTime = buildStatus.DateTime; result.User = buildStatus.User; break; } } FileLogger.Logger.LogVerbose("Polled: {0} = {1}", result.ID, result.Status); return result; }
private void UpdateWithoutTransition(BuildStatus status) { if (_lastStatus == null || _lastStatus != status.Status) { FileLogger.Logger.LogInformation("{0}\t {1}\tStatus = '{2}'", DateTime.Now.ToString(CultureInfo.InvariantCulture), status.Name, status.Status); _traceFile.WriteLine("{0}\t {1}\tStatus = '{2}'", DateTime.Now.ToString(CultureInfo.InvariantCulture), status.Name, status.Status); _traceFile.Flush(); _lastStatus = status.Status; } }
public void Update(BuildStatus status) { if (_transitionController != null) UpdateWithTransition(status); else UpdateWithoutTransition(status); }
private void UpdateWithTransition(BuildStatus status) { var actions = _transitionController.Transition(status); if (actions != null) { _traceFile.WriteLine("{0}\t {1}\tStatus = '{2}'\tAction='{3}'", DateTime.Now.ToString(CultureInfo.InvariantCulture), status.Name, status.Status, actions); _traceFile.Flush(); } }
private void UpdateWithoutTransition(BuildStatus status) { if (_lastStatus == null || _lastStatus != status.Status) { FileLogger.Logger.LogInformation("Publishing to Visualiser: {0} with a status of {1}", Name, status.Status); switch (status.Status) { case Status.Success: _controller.SetColor(new DelcomLight(Colors.Green, Modes.On)); break; case Status.Unknown: _controller.SetColor(new DelcomLight(Colors.Yellow, Modes.Flash)); break; case Status.InProgress: _controller.SetColor(new DelcomLight(Colors.Yellow, Modes.On)); break; case Status.Error: _controller.SetColor(new DelcomLight(Colors.Red, Modes.Flash)); break; case Status.Failed: _controller.SetColor(new DelcomLight(Colors.Red, Modes.On)); break; case Status.FailedInProgress: _controller.SetColor(new DelcomLight(Colors.Red, Modes.On), new DelcomLight(Colors.Yellow, Modes.Flash)); break; case Status.SuccessInProgress: _controller.SetColor(new DelcomLight(Colors.Green, Modes.On), new DelcomLight(Colors.Yellow, Modes.Flash)); break; } _lastStatus = status.Status; } }
private void UpdateWithTransition(BuildStatus status) { var actions = _transitionController.Transition(status); if (actions != null) { _controller.Off(); foreach (var action in actions.Split(';')) { var light = DetermineLight(action); if (light !=null) _controller.SetColor(light); } } }