// TODO: should not start if stopping (ie. not stopped)
        /// <summary>
        /// Starts this instance.
        /// </summary>
        /// <remarks></remarks>
        public void Start()
        {
            lock (this)
            {
                if (IsRunning)
                {
                    return;
                }

                //if stopping or currently within a restart, allow this run to occur, but then stop project when finished
                //this is to allow the server to restart when config has been update

                if (isRestarting || state == ProjectIntegratorState.Stopping)
                {
                    runAndStop   = true;
                    isRestarting = false;
                }
                state = ProjectIntegratorState.Running;
            }

            // multiple thread instances cannot be created
            if (thread == null || thread.ThreadState == ThreadState.Stopped)
            {
                thread      = new Thread(Run);
                thread.Name = project.Name;
            }

            // start thread if it's not running yet
            if (thread.ThreadState != ThreadState.Running)
            {
                thread.Start();
            }
        }
 /// <summary>
 /// Main integration loop, intended to be run in its own thread.
 /// </summary>
 private void Run()
 {
     Log.Info("Starting integrator for project: " + project.Name);
     try
     {
         // loop, until the integrator is stopped
         while (IsRunning)
         {
             try
             {
                 bool ran = Integrate();
                 if (ran && runAndStop)
                 {
                     state      = ProjectIntegratorState.Stopping;
                     runAndStop = false;
                 }
             }
             catch (Exception ex)
             {
                 Log.Error(ex);
             }
             // sleep for a short while, to avoid hammering CPU
             Thread.Sleep(100);
         }
     }
     catch (ThreadAbortException)
     {
         // suppress logging of ThreadAbortException
         Thread.ResetAbort();
     }
     finally
     {
         Stopped();
     }
 }
 /// <summary>
 /// Sets the state to <see cref="ProjectIntegratorState.Stopping"/>, telling the project to
 /// stop at the next possible point in time.
 /// </summary>
 public void Stop(bool restarting)
 {
     if (IsRunning || state == ProjectIntegratorState.Unknown)
     {
         this.isRestarting = restarting;
         Log.Info("Stopping integrator for project: " + project.Name);
         state = ProjectIntegratorState.Stopping;
     }
 }
示例#4
0
 private void Stopped()
 {
     // the state was set to 'Stopping', so set it to 'Stopped'
     state  = ProjectIntegratorState.Stopped;
     thread = null;
     // Ensure that any queued integrations are cleared for this project.
     integrationQueue.RemoveProject(project);
     Log.Info("Integrator for project: " + project.Name + " is now stopped.");
 }
示例#5
0
 public ProjectStatus(ProjectIntegratorState status, IntegrationStatus buildStatus, ProjectActivity activity, string name, string webURL, DateTime lastBuildDate, string lastBuildLabel, string lastSuccessfulBuildLabel, DateTime nextBuildTime)
 {
     this.status                   = status;
     this.buildStatus              = buildStatus;
     this.activity                 = activity;
     this.name                     = name;
     this.webURL                   = webURL;
     this.lastBuildDate            = lastBuildDate;
     this.lastBuildLabel           = lastBuildLabel;
     this.lastSuccessfulBuildLabel = lastSuccessfulBuildLabel;
     this.nextBuildTime            = nextBuildTime;
 }
示例#6
0
 public ProjectStatus(ProjectIntegratorState status, IntegrationStatus buildStatus, ProjectActivity activity, string name, string webURL, DateTime lastBuildDate, string lastBuildLabel, string lastSuccessfulBuildLabel, DateTime nextBuildTime)
 {
     this.status = status;
     this.buildStatus = buildStatus;
     this.activity = activity;
     this.name = name;
     this.webURL = webURL;
     this.lastBuildDate = lastBuildDate;
     this.lastBuildLabel = lastBuildLabel;
     this.lastSuccessfulBuildLabel = lastSuccessfulBuildLabel;
     this.nextBuildTime = nextBuildTime;
 }
示例#7
0
        public void StreamToXMLFullConstructorTest()
        {
            string                 projectName              = "full test";
            string                 category                 = "categ1";
            ProjectActivity        activity                 = ProjectActivity.Building;
            IntegrationStatus      buildStatus              = IntegrationStatus.Failure;
            ProjectIntegratorState status                   = ProjectIntegratorState.Stopped;
            string                 webURL                   = "someurl";
            DateTime               lastBuildDate            = DateTime.Now;
            string                 lastBuildLabel           = "lastLabel";
            string                 lastSuccessfulBuildLabel = "lastSuccess";
            DateTime               nextBuildTime            = DateTime.Now.AddDays(2);
            string                 buildStage               = "some stage";
            string                 queue    = "someQueue";
            int queuePriority               = 25;
            List <ParameterBase> parameters = new List <ParameterBase>();

            ProjectStatus projectStatus = new ProjectStatus(projectName, category, activity, buildStatus,
                                                            status, webURL, lastBuildDate, lastBuildLabel,
                                                            lastSuccessfulBuildLabel, nextBuildTime, buildStage,
                                                            queue, queuePriority, parameters);

            XmlSerializer           serializer = new XmlSerializer(typeof(ProjectStatus));
            TextWriter              writer     = new StringWriter();
            XmlSerializerNamespaces nmsp       = new XmlSerializerNamespaces();

            nmsp.Add("", "");

            serializer.Serialize(writer, projectStatus, nmsp);

            Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-16\"?>" + Environment.NewLine +
                            "<projectStatus " +
                            "stage=\"" + buildStage + "\" " +
                            "showForceBuildButton=\"true\" " +
                            "showStartStopButton=\"true\" " +
                            "serverName=\"" + Environment.MachineName + "\" " +
                            "status=\"" + status.ToString() + "\" " +
                            "buildStatus=\"" + buildStatus.ToString() + "\" " +
                            "name=\"" + projectName + "\" " +
                            "category=\"" + category + "\" " +
                            "queueName=\"" + queue + "\" " +
                            "queuePriority=\"" + queuePriority.ToString() + "\" " +
                            "url=\"" + webURL + "\" " +
                            "lastBuildDate=\"" + lastBuildDate.ToString("yyyy-MM-ddTHH:mm:ss.FFFFFFF") + "\" " +
                            "lastBuildLabel=\"" + lastBuildLabel + "\" " +
                            "lastSuccessfulBuildLabel=\"" + lastSuccessfulBuildLabel + "\" " +
                            "nextBuildTime=\"" + nextBuildTime.ToString("yyyy-MM-ddTHH:mm:ss.FFFFFFF") + "\"" +
                            ">" + Environment.NewLine +
                            "  <activity type=\"" + activity.ToString() + "\" />" + Environment.NewLine +
                            "  <parameters />" + Environment.NewLine +
                            "</projectStatus>",
                            writer.ToString());
        }
示例#8
0
 /// <summary>
 /// Initialise a new populated <see cref="ProjectStatus"/>.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="category"></param>
 /// <param name="activity"></param>
 /// <param name="buildStatus"></param>
 /// <param name="status"></param>
 /// <param name="webURL"></param>
 /// <param name="lastBuildDate"></param>
 /// <param name="lastBuildLabel"></param>
 /// <param name="lastSuccessfulBuildLabel"></param>
 /// <param name="nextBuildTime"></param>
 /// <param name="buildStage"></param>
 /// <param name="queue"></param>
 /// <param name="queuePriority"></param>
 public ProjectStatus(string name, string category, ProjectActivity activity, IntegrationStatus buildStatus, ProjectIntegratorState status, string webURL, DateTime lastBuildDate, string lastBuildLabel, string lastSuccessfulBuildLabel, DateTime nextBuildTime, string buildStage, string queue, int queuePriority)
 {
     this.status = status;
     this.buildStatus = buildStatus;
     this.activity = activity;
     this.name = name;
     this.category = category;
     this.webURL = webURL;
     this.lastBuildDate = new SerializableDateTime(lastBuildDate);
     this.lastBuildLabel = lastBuildLabel;
     this.lastSuccessfulBuildLabel = lastSuccessfulBuildLabel;
     this.nextBuildTime = new SerializableDateTime(nextBuildTime);
     this.currentBuildStage = buildStage;
     this.queue = queue;
     this.queuePriority = queuePriority;
 }
 /// <summary>
 /// Initialise a new populated <see cref="ProjectStatus"/>.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="category"></param>
 /// <param name="activity"></param>
 /// <param name="buildStatus"></param>
 /// <param name="status"></param>
 /// <param name="webURL"></param>
 /// <param name="lastBuildDate"></param>
 /// <param name="lastBuildLabel"></param>
 /// <param name="lastSuccessfulBuildLabel"></param>
 /// <param name="nextBuildTime"></param>
 /// <param name="buildStage"></param>
 /// <param name="queue"></param>
 /// <param name="queuePriority"></param>
 public ProjectStatus(string name, string category, ProjectActivity activity, IntegrationStatus buildStatus, ProjectIntegratorState status, string webURL, DateTime lastBuildDate, string lastBuildLabel, string lastSuccessfulBuildLabel, DateTime nextBuildTime, string buildStage, string queue, int queuePriority)
 {
     this.status                   = status;
     this.buildStatus              = buildStatus;
     this.activity                 = activity;
     this.name                     = name;
     this.category                 = category;
     this.webURL                   = webURL;
     this.lastBuildDate            = new SerializableDateTime(lastBuildDate);
     this.lastBuildLabel           = lastBuildLabel;
     this.lastSuccessfulBuildLabel = lastSuccessfulBuildLabel;
     this.nextBuildTime            = new SerializableDateTime(nextBuildTime);
     this.currentBuildStage        = buildStage;
     this.queue                    = queue;
     this.queuePriority            = queuePriority;
 }
示例#10
0
 public ProjectStatus(string name, string category, ProjectActivity activity, IntegrationStatus buildStatus, ProjectIntegratorState status, string webURL, DateTime lastBuildDate, string lastBuildLabel, string lastSuccessfulBuildLabel, DateTime nextBuildTime, string buildStage, string queue, int queuePriority, List<ParameterBase> parameters)
 {
     this.status = status;
     this.buildStatus = buildStatus;
     this.activity = activity;
     this.name = name;
     this.category = category;
     this.webURL = webURL;
     this.lastBuildDate = lastBuildDate;
     this.lastBuildLabel = lastBuildLabel;
     this.lastSuccessfulBuildLabel = lastSuccessfulBuildLabel;
     this.nextBuildTime = nextBuildTime;
     this.currentBuildStage = buildStage;
     this.queue = queue;
     this.queuePriority = queuePriority;
     this.parameters = parameters;
 }
示例#11
0
        string GetStatus(ProjectIntegratorState projectIntegratorState)
        {
            switch (projectIntegratorState)
            {
            case ProjectIntegratorState.Running:
                return("Running");

            case ProjectIntegratorState.Stopped:
                return("Stopped");

            case ProjectIntegratorState.Stopping:
                return("Stopping");

            default:
                return(projectIntegratorState.ToString());
            }
        }
示例#12
0
        /// <summary>
        /// Converts a <see cref="ProjectIntegratorState"/> to a <see cref="ProjectSummaryStatus"/>.
        /// </summary>
        /// <param name="status">The <see cref="ProjectIntegratorState"/>.</param>
        /// <returns>
        /// The <see cref="ProjectSummaryStatus"/>.
        /// </returns>
        private static ProjectSummaryStatus Convert(ProjectIntegratorState status)
        {
            switch (status)
            {
            case ProjectIntegratorState.Running:
                return(ProjectSummaryStatus.Running);

            case ProjectIntegratorState.Stopped:
                return(ProjectSummaryStatus.Stopped);

            case ProjectIntegratorState.Stopping:
                return(ProjectSummaryStatus.Stopping);

            case ProjectIntegratorState.Unknown:
                // Project has not started
                return(ProjectSummaryStatus.Stopped);
            }

            return(ProjectSummaryStatus.Unknown);
        }
示例#13
0
 public ProjectStatus(ProjectIntegratorState status, IntegrationStatus buildStatus,
                      ProjectActivity activity, string name, string webURL, DateTime lastBuildDate, TimeSpan lastBuildDuration,
                      string lastBuildLabel, string lastSuccessfulBuildLabel, DateTime nextBuildTime,
                      string forcee, Modification[] modifications, DateTime currentBuildStartTime, BuildCondition buildCondition)
 {
     this.status                   = status;
     this.buildStatus              = buildStatus;
     this.activity                 = activity;
     this.name                     = name;
     this.webURL                   = webURL;
     this.lastBuildDate            = lastBuildDate;
     this.lastBuildLabel           = lastBuildLabel;
     this.lastSuccessfulBuildLabel = lastSuccessfulBuildLabel;
     this.nextBuildTime            = nextBuildTime;
     this._Forcee                  = forcee;
     this._Modifications           = modifications;
     this.currentBuildStartTime    = currentBuildStartTime;
     this.buildCondition           = buildCondition;
     this.lastBuildDuration        = lastBuildDuration;
 }
示例#14
0
 public ProjectStatus(ProjectIntegratorState status, IntegrationStatus buildStatus, 
     ProjectActivity activity, string name, string webURL, DateTime lastBuildDate, TimeSpan lastBuildDuration,
     string lastBuildLabel, string lastSuccessfulBuildLabel, DateTime nextBuildTime,
     string forcee, Modification[] modifications, DateTime currentBuildStartTime, BuildCondition buildCondition)
 {
     this.status = status;
     this.buildStatus = buildStatus;
     this.activity = activity;
     this.name = name;
     this.webURL = webURL;
     this.lastBuildDate = lastBuildDate;
     this.lastBuildLabel = lastBuildLabel;
     this.lastSuccessfulBuildLabel = lastSuccessfulBuildLabel;
     this.nextBuildTime = nextBuildTime;
     this._Forcee = forcee;
     this._Modifications = modifications;
     this.currentBuildStartTime = currentBuildStartTime;
     this.buildCondition = buildCondition;
     this.lastBuildDuration = lastBuildDuration;
 }
示例#15
0
 public ProjectStatus(string name, string category, ProjectActivity activity, IntegrationStatus buildStatus, ProjectIntegratorState status, string webURL, DateTime lastBuildDate, string lastBuildLabel, string lastSuccessfulBuildLabel, DateTime nextBuildTime, string buildStage, string queue, int queuePriority, ParameterBase[] parameters) : this(name, category, activity, buildStatus, status, webURL, lastBuildDate, lastBuildLabel, lastSuccessfulBuildLabel, nextBuildTime, buildStage, queue, queuePriority, (parameters == null) ? new List<ParameterBase>() : new List<ParameterBase>(parameters)) { }
 private void Stopped()
 {
     // the state was set to 'Stopping', so set it to 'Stopped'
     state = ProjectIntegratorState.Stopped;
     thread = null;
     // Ensure that any queued integrations are cleared for this project.
     integrationQueue.RemoveProject(project);
     Log.Info("Integrator for project: " + project.Name + " is now stopped.");
 }
 /// <summary>
 /// Sets the state to <see cref="ProjectIntegratorState.Stopping"/>, telling the project to
 /// stop at the next possible point in time.
 /// </summary>
 public void Stop()
 {
     if (IsRunning)
     {
         Log.Info("Stopping integrator for project: " + project.Name);
         state = ProjectIntegratorState.Stopping;
     }
 }
        // TODO: should not start if stopping (ie. not stopped)
        public void Start()
        {
            lock (this)
            {
                if (IsRunning)
                    return;

                state = ProjectIntegratorState.Running;
            }

            // multiple thread instances cannot be created
            if (thread == null || thread.ThreadState == ThreadState.Stopped)
            {
                thread = new Thread(Run);
                thread.Name = project.Name;
            }

            // start thread if it's not running yet
            if (thread.ThreadState != ThreadState.Running)
            {
                thread.Start();
            }
        }
示例#19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CCProject"/> class from being created.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="name">The name.</param>
 /// <param name="category">The category.</param>
 /// <param name="activity">The activity.</param>
 /// <param name="buildStatus">The build status.</param>
 /// <param name="status">The status.</param>
 /// <param name="webURL">The web URL.</param>
 /// <param name="lastBuildDate">The last build date.</param>
 /// <param name="lastBuildLabel">The last build label.</param>
 /// <param name="lastSuccessfulBuildLabel">The last successful build label.</param>
 /// <param name="nextBuildTime">The next build time.</param>
 /// <param name="buildStage">The build stage.</param>
 /// <param name="queue">The queue.</param>
 /// <param name="queuePriority">The queue priority.</param>
 /// <param name="parameters">The project parameters</param>
 private CCProject(CruiseServerClientBase client, string name, string category, ProjectActivity activity, IntegrationStatus buildStatus, ProjectIntegratorState status, string webURL, DateTime lastBuildDate, string lastBuildLabel, string lastSuccessfulBuildLabel, DateTime nextBuildTime, string buildStage, string queue, int queuePriority, List<ParameterBase> parameters)
     : base(name, category, activity, buildStatus, status, webURL, lastBuildDate, lastBuildLabel, lastSuccessfulBuildLabel, nextBuildTime, buildStage, queue, queuePriority, parameters)
 {
     this.client = client;
 }
		public static ProjectStatus New(string project, string category, ProjectActivity activity, IntegrationStatus integrationStatus, ProjectIntegratorState integratorState, string label, DateTime lastBuildDate)
		{
            return new ProjectStatus(project, category, activity, integrationStatus, integratorState, DefaultUrl, lastBuildDate, label, label, DefaultLastBuildDate,string.Empty,string.Empty, 0);
		}
示例#21
0
        public void StreamToXMLFullConstructorWithParametersTest()
        {
            string                 projectName              = "full test";
            string                 category                 = "categ1";
            ProjectActivity        activity                 = ProjectActivity.Building;
            IntegrationStatus      buildStatus              = IntegrationStatus.Failure;
            ProjectIntegratorState status                   = ProjectIntegratorState.Stopped;
            string                 webURL                   = "someurl";
            DateTime               lastBuildDate            = DateTime.Now;
            string                 lastBuildLabel           = "lastLabel";
            string                 lastSuccessfulBuildLabel = "lastSuccess";
            DateTime               nextBuildTime            = DateTime.Now.AddDays(2);
            string                 buildStage               = "some stage";
            string                 queue    = "someQueue";
            int queuePriority               = 25;
            List <ParameterBase> parameters = new List <ParameterBase> {
                new TextParameter("textParam"), new BooleanParameter("boolParam")
            };

            ProjectStatus projectStatus = new ProjectStatus(projectName, category, activity, buildStatus,
                                                            status, webURL, lastBuildDate, lastBuildLabel,
                                                            lastSuccessfulBuildLabel, nextBuildTime, buildStage,
                                                            queue, queuePriority, parameters);

            string streamedParameters = String.Empty;

            foreach (ParameterBase parameter in parameters)
            {
                XmlSerializerNamespaces parameternmsp = new XmlSerializerNamespaces();
                parameternmsp.Add("", "");

                XmlSerializer parameterSerializer = new XmlSerializer(parameter.GetType());
                TextWriter    parameterWriter     = new StringWriter();

                XmlWriterSettings writerSettings = new XmlWriterSettings();
                writerSettings.OmitXmlDeclaration = true;
                using (XmlWriter xmlWriter = XmlWriter.Create(parameterWriter, writerSettings))
                {
                    parameterSerializer.Serialize(xmlWriter, parameter, parameternmsp);
                }
                string streamedParameter = parameterWriter.ToString();
                streamedParameter   = Regex.Replace(streamedParameter, parameter.GetType().Name, "parameter d3p1:type=\"" + parameter.GetType().Name + "\"", RegexOptions.IgnoreCase);
                streamedParameter   = Regex.Replace(streamedParameter, "/>", "xmlns:d3p1=\"http://www.w3.org/2001/XMLSchema-instance\" />", RegexOptions.IgnoreCase);
                streamedParameters += "    " + streamedParameter + "" + Environment.NewLine;
            }

            XmlSerializerNamespaces nmsp = new XmlSerializerNamespaces();

            nmsp.Add("", "");

            XmlSerializer serializer = new XmlSerializer(typeof(ProjectStatus));
            TextWriter    writer     = new StringWriter();

            serializer.Serialize(writer, projectStatus, nmsp);

            Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-16\"?>" + Environment.NewLine +
                            "<projectStatus " +
                            "stage=\"" + buildStage + "\" " +
                            "showForceBuildButton=\"true\" " +
                            "showStartStopButton=\"true\" " +
                            "serverName=\"" + Environment.MachineName + "\" " +
                            "status=\"" + status.ToString() + "\" " +
                            "buildStatus=\"" + buildStatus.ToString() + "\" " +
                            "name=\"" + projectName + "\" " +
                            "category=\"" + category + "\" " +
                            "queueName=\"" + queue + "\" " +
                            "queuePriority=\"" + queuePriority.ToString() + "\" " +
                            "url=\"" + webURL + "\" " +
                            "lastBuildDate=\"" + lastBuildDate.ToString("yyyy-MM-ddTHH:mm:ss.FFFFFFF") + "\" " +
                            "lastBuildLabel=\"" + lastBuildLabel + "\" " +
                            "lastSuccessfulBuildLabel=\"" + lastSuccessfulBuildLabel + "\" " +
                            "nextBuildTime=\"" + nextBuildTime.ToString("yyyy-MM-ddTHH:mm:ss.FFFFFFF") + "\"" +
                            ">" + Environment.NewLine +
                            "  <activity type=\"" + activity.ToString() + "\" />" + Environment.NewLine +
                            "  <parameters>" + Environment.NewLine +
                            streamedParameters +
                            "  </parameters>" + Environment.NewLine +
                            "</projectStatus>",
                            writer.ToString());
        }
 /// <summary>
 /// Main integration loop, intended to be run in its own thread.
 /// </summary>
 private void Run()
 {
     Log.Info("Starting integrator for project: " + project.Name);
     try
     {
         // loop, until the integrator is stopped
         while (IsRunning)
         {
             try
             {
                 bool ran = Integrate();
                 if (ran && runAndStop)
                 {
                     state = ProjectIntegratorState.Stopping;
                     runAndStop = false;
                 }
             }
             catch (Exception ex)
             {
                 Log.Error(ex);
             }
             // sleep for a short while, to avoid hammering CPU
             Thread.Sleep(100);
         }
     }
     catch (ThreadAbortException)
     {
         // suppress logging of ThreadAbortException
         Thread.ResetAbort();
     }
     finally
     {
         Stopped();
     }
 }
示例#23
0
 public static ProjectStatus New(string project, string category, ProjectActivity activity, IntegrationStatus integrationStatus, ProjectIntegratorState integratorState, string label, DateTime lastBuildDate, string buildStage)
 {
     return(new ProjectStatus(project, category, activity, integrationStatus, integratorState, DefaultUrl, lastBuildDate, label, label, DefaultLastBuildDate, buildStage, string.Empty, 0));
 }
示例#24
0
 public ProjectStatus(string name, string category, ProjectActivity activity, IntegrationStatus buildStatus, ProjectIntegratorState status, string webURL, DateTime lastBuildDate, string lastBuildLabel, string lastSuccessfulBuildLabel, DateTime nextBuildTime, string buildStage, string queue, int queuePriority, ParameterBase[] parameters) : this(name, category, activity, buildStatus, status, webURL, lastBuildDate, lastBuildLabel, lastSuccessfulBuildLabel, nextBuildTime, buildStage, queue, queuePriority, (parameters == null) ? new List <ParameterBase>() : new List <ParameterBase>(parameters))
 {
 }
示例#25
0
 public static ProjectStatus New(string project, string category, ProjectActivity activity, IntegrationStatus integrationStatus, ProjectIntegratorState integratorState, string label, DateTime lastBuildDate)
 {
     return(new ProjectStatus(project, category, activity, integrationStatus, integratorState, DefaultUrl, lastBuildDate, label, label, DefaultLastBuildDate, string.Empty, string.Empty, 0, new List <ParameterBase>()));
 }
 /// <summary>
 /// Sets the state to <see cref="ProjectIntegratorState.Stopping"/>, telling the project to
 /// stop at the next possible point in time.
 /// </summary>
 public void Stop(bool restarting)
 {
     if (IsRunning || state == ProjectIntegratorState.Unknown)
     {
         this.isRestarting = restarting;
         Log.Info("Stopping integrator for project: " + project.Name);
         state = ProjectIntegratorState.Stopping;
     }
 }
示例#27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CCProject"/> class from being created.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="name">The name.</param>
 /// <param name="category">The category.</param>
 /// <param name="activity">The activity.</param>
 /// <param name="buildStatus">The build status.</param>
 /// <param name="status">The status.</param>
 /// <param name="webURL">The web URL.</param>
 /// <param name="lastBuildDate">The last build date.</param>
 /// <param name="lastBuildLabel">The last build label.</param>
 /// <param name="lastSuccessfulBuildLabel">The last successful build label.</param>
 /// <param name="nextBuildTime">The next build time.</param>
 /// <param name="buildStage">The build stage.</param>
 /// <param name="queue">The queue.</param>
 /// <param name="queuePriority">The queue priority.</param>
 private CCProject(CruiseServerClientBase client, string name, string category, ProjectActivity activity, IntegrationStatus buildStatus, ProjectIntegratorState status, string webURL, DateTime lastBuildDate, string lastBuildLabel, string lastSuccessfulBuildLabel, DateTime nextBuildTime, string buildStage, string queue, int queuePriority)
     : base(name, category, activity, buildStatus, status, webURL, lastBuildDate, lastBuildLabel, lastSuccessfulBuildLabel, nextBuildTime, buildStage, queue, queuePriority)
 {
     this.client = client;
 }
        // TODO: should not start if stopping (ie. not stopped)
        /// <summary>
        /// Starts this instance.	
        /// </summary>
        /// <remarks></remarks>
        public void Start()
        {
            lock (this)
            {
                if (IsRunning)
                    return;

                //if stopping or currently within a restart, allow this run to occur, but then stop project when finished
                //this is to allow the server to restart when config has been update

                if (isRestarting || state == ProjectIntegratorState.Stopping)
                {
                    runAndStop = true;
                    isRestarting = false;
                }
                state = ProjectIntegratorState.Running;
            }

            // multiple thread instances cannot be created
            if (thread == null || thread.ThreadState == ThreadState.Stopped)
            {
                thread = new Thread(Run);
                thread.Name = project.Name;
            }

            // start thread if it's not running yet
            if (thread.ThreadState != ThreadState.Running)
            {
                thread.Start();
            }
        }
 public static ProjectStatus New(string project, string category, ProjectActivity activity, IntegrationStatus integrationStatus, ProjectIntegratorState integratorState, string label, DateTime lastBuildDate, string buildStage)
 {
     return new ProjectStatus(project, category, activity, integrationStatus, integratorState, DefaultUrl, lastBuildDate, label, label, DefaultLastBuildDate, buildStage, string.Empty, 0, new List<ParameterBase>());
 }
        /// <summary>
        /// Converts a <see cref="ProjectIntegratorState"/> to a <see cref="ProjectSummaryStatus"/>.
        /// </summary>
        /// <param name="status">The <see cref="ProjectIntegratorState"/>.</param>
        /// <returns>
        /// The <see cref="ProjectSummaryStatus"/>.
        /// </returns>
        private static ProjectSummaryStatus Convert(ProjectIntegratorState status)
        {
            switch (status)
            {
                case ProjectIntegratorState.Running:
                    return ProjectSummaryStatus.Running;

                case ProjectIntegratorState.Stopped:
                    return ProjectSummaryStatus.Stopped;

                case ProjectIntegratorState.Stopping:
                    return ProjectSummaryStatus.Stopping;

                case ProjectIntegratorState.Unknown:
                    // Project has not started
                    return ProjectSummaryStatus.Stopped;
            }

            return ProjectSummaryStatus.Unknown;
        }