Beispiel #1
0
        private void Poll()
        {
            Console.WriteLine("Polling on project " + this.name);
            try
            {
                ProjectStatus   latestProjectStatus = GetRemoteProjectStatus();
                bool            hasBuildOccurred    = HasBuildOccurred(latestProjectStatus);
                BuildTransition transition          = GetBuildTransition(latestProjectStatus);

                _currentProjectStatus = latestProjectStatus;
                OnPolled(this, new PolledEventArgs(latestProjectStatus));

                if (hasBuildOccurred)
                {
                    Console.WriteLine("OnBuildOccurred");
                    OnBuildOccurred(this, new BuildOccurredEventArgs(latestProjectStatus, transition));
                }
            }
            catch (Exception e)
            {
                OnError(this, new PollingErrorEventArgs(e, this));
            }
        }
Beispiel #2
0
        private BuildTransition GetBuildTransition(ProjectStatus projectStatus)
        {
            bool wasOk = _currentProjectStatus.BuildStatus == BuildStatus.Successful;
            bool isOk  = projectStatus.BuildStatus == BuildStatus.Successful;

            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.");
        }
Beispiel #3
0
 public PolledEventArgs(ProjectStatus projectStatus)
 {
     _projectStatus = projectStatus;
 }
Beispiel #4
0
 public BuildOccurredEventArgs(ProjectStatus newProjectStatus, BuildTransition transition)
 {
     _projectStatus = newProjectStatus;
     _transition    = transition;
 }