Exemplo n.º 1
0
        /// <summary>
        /// Maps the specified XML.
        /// </summary>
        /// <param name="xml">The XML.</param>
        /// <returns></returns>
        public Job Map(XmlDocument xml)
        {
            Job job = null;

            if (xml != null)
            {
                job = new Job
                {
                    Name = xml.Find("//name"),
                    Description = xml.Find("//description"),
                    DisplayName = xml.Find("//displayName"),
                    Url = xml.FindUri("//url"),
                    Buildable = bool.Parse(xml.Find("//buildable")),
                    BuildStatus = BuildStatusParser.Parse(xml.Find("//color")),
                    HealthReport = xml.Find("//healthReport/description"),
                    IconUrl = xml.Find("//healthReport/iconUrl"),
                    Score = xml.FindInteger("//healthReport/score"),
                    InQueue = bool.Parse(xml.Find("//inQueue")),
                    KeepDependencies = bool.Parse(xml.Find("//keepDependencies")),
                    NextBuildNumber = xml.FindInteger("//nextBuildNumber")
                };
            }

            return job;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the model specified job.
        /// </summary>
        /// <param name="job">The job.</param>
        /// <returns></returns>
        public bool Update(Job job)
        {
            var updated = false;

            if (job.LastBuild.Number > Number)
            {
                updated = true;
            }
            else if (job.LastBuild.Number == Number)
            {
                if (job.BuildStatus != BuildStatus)
                {
                    BuildStatus = job.BuildStatus;

                    updated = true;
                }
            }

            if (updated)
            {
                Number = job.LastBuild.Number;
                BuildStatus = job.BuildStatus;
                Comment = job.LastBuild.Comments;
                User = job.LastBuild.User;
                Created = job.LastBuild.Created;
                Name = job.Name;
                Url = job.Url;
                LastStableBuildTime = job.LastStableBuild.Duration / 1000;
            }

            if (string.IsNullOrEmpty(Comment)) Comment = job.Description;

            if (string.IsNullOrEmpty(Comment)) Comment = "No comments for this build.";

            return updated;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JobModel"/> class.
 /// </summary>
 /// <param name="job">The job.</param>
 public JobModel(Job job)
 {
     Update(job);
 }