Пример #1
0
 private void FireDashboardStatusChanged(DashboardStatus status)
 {
     if (DashboardStatusChanged != null)
     {
         DashboardStatusChanged(this, new DashboardStatusChangedEventArgs(status));
     }
 }
Пример #2
0
 public DashboardStatusChangedEventArgs(DashboardStatus status)
 {
     this.status = status;
 }
Пример #3
0
        private void DetectStateChanges(XmlNode doc)
        {
            XmlNodeList projects = doc.SelectNodes("/projects/project");
            DateTime newestUpdate = DateTime.MinValue;

            bool failuresPresent = false;
            bool currentlyBuilding = false;

            foreach (XmlNode project in projects)
            {
                string status = project.SelectSingleNode("status").InnerText;

                if ("BUILDING".Equals(status))
                {
                    currentlyBuilding = true;
                    XmlNode previousStatusNode = project.SelectSingleNode("previous-status");
                    string previousStatusText = "";

                    if (previousStatusNode != null)
                    {
                        previousStatusText = previousStatusNode.InnerText;
                    }
                    ParseFailure(previousStatusText, ref failuresPresent);
                }
                else
                {
                    ParseFailure(status, ref failuresPresent);
                }

                XmlNode timestampNode = project.SelectSingleNode("timestamp");

                if (timestampNode == null)
                {
                    continue;
                }

                string dtStr = timestampNode.InnerText;

                if (string.IsNullOrEmpty(dtStr))
                {
                    continue;
                }

                DateTime dt = DateTime.ParseExact(dtStr, "yyyy-MM-dd HH:mm:ss", null);

                if (dt > this.lastUpdate)
                {
                    FireNewBuildAvailable(project);
                }

                if (dt > newestUpdate)
                {
                    newestUpdate = dt;
                }
            }

            this.lastUpdate = newestUpdate;

            DashboardStatus newStatus = new DashboardStatus(failuresPresent, currentlyBuilding);
            if (!newStatus.Equals(lastStatus))
            {
                FireDashboardStatusChanged(newStatus);
            }

            lastStatus = newStatus;
        }