public void Poll() { try { ProjectStatus newProjectStatus = serverMonitor.GetProjectStatus(ProjectName); if (lastProjectStatus != null && newProjectStatus != null) { PollIntervalReporter duringInterval = new PollIntervalReporter(lastProjectStatus, newProjectStatus); if (duringInterval.IsAnotherBuildComplete && duringInterval.WasLatestBuildSuccessful) { buildDurationTracker.OnSuccessfulBuild(); } if (duringInterval.IsAnotherBuildComplete) { OnBuildOccurred(new MonitorBuildOccurredEventArgs(this, duringInterval.BuildTransition)); } if (duringInterval.HasNewBuildStarted) { buildDurationTracker.OnBuildStart(); } if (duringInterval.WasNewStatusMessagesReceived) { OnMessageReceived(newProjectStatus.Name, duringInterval.AllStatusMessages); } } lastProjectStatus = newProjectStatus; } catch (Exception ex) { Debug.WriteLine("Exception during poll: " + ex); lastProjectStatus = null; connectException = ex; } OnPolled(new MonitorPolledEventArgs(this)); }
private BuildTransition CalculateBuildTransition(ProjectStatus oldStatus, ProjectStatus newStatus) { bool wasOk = oldStatus.BuildStatus == IntegrationStatus.Success; bool isOk = newStatus.BuildStatus == IntegrationStatus.Success; if (wasOk && isOk) { return(BuildTransition.StillSuccessful); } else if (!wasOk && !isOk) { return(BuildTransition.StillFailing); } else if (wasOk && !isOk) { return(BuildTransition.Broken); } else if (!wasOk && isOk) { return(BuildTransition.Fixed); } throw new Exception("The universe has gone crazy."); }
public PollIntervalReporter(ProjectStatus lastProjectStatus, ProjectStatus newProjectStatus) { this.lastProjectStatus = lastProjectStatus; this.newProjectStatus = newProjectStatus; }