예제 #1
0
 private static void WriteQueuedRequestSnapshot(XmlWriter xmlWriter, QueuedRequestSnapshot queuedRequest)
 {
     xmlWriter.WriteStartElement("Request");
     xmlWriter.WriteAttributeString("projectName", queuedRequest.ProjectName);
     xmlWriter.WriteAttributeString("activity", queuedRequest.Activity.ToString());
     xmlWriter.WriteEndElement();
 }
 public void LastBuildDateGetSetTest()
 {
     DateTime timeNow = DateTime.Now;
     QueuedRequestSnapshot activity = new QueuedRequestSnapshot();
     activity.RequestTime = timeNow;
     Assert.AreEqual(timeNow, activity.RequestTime);
 }
		public IntegrationQueueTreeNodeTag(IntegrationQueueTreeNodeAdaptor adaptor, QueueSnapshot queueSnapshot, 
			QueuedRequestSnapshot queuedRequestSnapshot, int queueIndex)
		{
			this.Adaptor = adaptor;
			this.QueueSnapshot = queueSnapshot;
			this.QueuedRequestSnapshot = queuedRequestSnapshot;
			this.QueueIndex = queueIndex;
		}
예제 #4
0
        /// <summary>
        /// Checks if a snapshot has changed.
        /// </summary>
        /// <param name="queueSetSnapshotToCompare"></param>
        /// <returns></returns>
        public bool IsQueueSetSnapshotChanged(QueueSetSnapshot queueSetSnapshotToCompare)
        {
            if (queueSetSnapshotToCompare == null)
            {
                if (queueSetSnapshot == null)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            if (queueSetSnapshot == null)
            {
                return(true);
            }
            if (queueSetSnapshotToCompare.Queues.Count != queueSetSnapshot.Queues.Count)
            {
                return(true);
            }

            for (int queueIndex = 0; queueIndex < queueSetSnapshot.Queues.Count; queueIndex++)
            {
                QueueSnapshot queueSnapshot          = queueSetSnapshot.Queues[queueIndex];
                QueueSnapshot queueSnapshotToCompare = queueSetSnapshotToCompare.Queues[queueIndex];
                if (queueSnapshotToCompare.QueueName != queueSnapshot.QueueName)
                {
                    return(true);
                }
                if (queueSnapshotToCompare.Requests.Count != queueSnapshot.Requests.Count)
                {
                    return(true);
                }

                for (int requestIndex = 0; requestIndex < queueSnapshot.Requests.Count; requestIndex++)
                {
                    QueuedRequestSnapshot request          = queueSnapshot.Requests[requestIndex];
                    QueuedRequestSnapshot requestToCompare = queueSnapshotToCompare.Requests[requestIndex];
                    if (requestToCompare.ProjectName != request.ProjectName)
                    {
                        return(true);
                    }
                    if (requestToCompare.Activity != request.Activity)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #5
0
        /// <summary>
        /// Parse the queue information.
        /// </summary>
        /// <param name="document"></param>
        /// <param name="snapshot"></param>
        private void ParseQueues(XmlDocument document, CruiseServerSnapshot snapshot)
        {
            foreach (XmlElement queueSnapshotEl in document.SelectNodes("/CruiseControl/Queues/Queue"))
            {
                // Retrieve the queue details
                var queueSnapshot = new QueueSnapshot
                {
                    QueueName = RetrieveAttributeValue(queueSnapshotEl, "name", string.Empty)
                };
                snapshot.QueueSetSnapshot.Queues.Add(queueSnapshot);

                // Retrieve the requests
                foreach (XmlElement requestEl in queueSnapshotEl.SelectNodes("Request"))
                {
                    var request = new QueuedRequestSnapshot
                    {
                        Activity    = new ProjectActivity(RetrieveAttributeValue(requestEl, "activity", "Unknown")),
                        ProjectName = RetrieveAttributeValue(requestEl, "projectName", string.Empty)
                    };
                    queueSnapshot.Requests.Add(request);
                }
            }
        }
	    private QueueSetSnapshot ConvertDashboardQueues(DashboardQueue[] dashboardQueues)
        {
            QueueSetSnapshot queueSetSnapshot = new QueueSetSnapshot();
            if (dashboardQueues != null)
            {
                foreach (DashboardQueue dashboardQueue in dashboardQueues)
                {
                    QueueSnapshot queueSnapshot = new QueueSnapshot(dashboardQueue.Name);
                    if (dashboardQueue.Requests != null)
                    {
                        foreach (DashboardQueuedRequest dashboardQueuedRequest in dashboardQueue.Requests)
                        {
                            QueuedRequestSnapshot queuedRequestSnapshot = new QueuedRequestSnapshot(
                                dashboardQueuedRequest.ProjectName,
                                new ProjectActivity(dashboardQueuedRequest.Activity));
                            queueSnapshot.Requests.Add(queuedRequestSnapshot);
                        }
                    }
                    queueSetSnapshot.Queues.Add(queueSnapshot);
                }
            }
            return queueSetSnapshot;
        }
 public void ActivityGetSetTest()
 {
     QueuedRequestSnapshot activity = new QueuedRequestSnapshot();
     activity.Activity = ProjectActivity.Building;
     Assert.AreEqual(ProjectActivity.Building, activity.Activity);
 }
 public void ProjectNameGetSetTest()
 {
     QueuedRequestSnapshot activity = new QueuedRequestSnapshot();
     activity.ProjectName = "testing";
     Assert.AreEqual("testing", activity.ProjectName);
 }
        private CruiseServerSnapshot CreatePopulatedQueuesSnapshot()
		{
            CruiseServerSnapshot cruiseServerSnapshot = CreateEmptyQueuesSnapshot();
            QueueSetSnapshot queueSetSnapshot = cruiseServerSnapshot.QueueSetSnapshot;

			QueueSnapshot queueSnapshot1 = queueSetSnapshot.Queues[0];

            QueuedRequestSnapshot queuedRequestSnapshot1 = new QueuedRequestSnapshot("Project1", ProjectActivity.CheckingModifications);
			queueSnapshot1.Requests.Add(queuedRequestSnapshot1);

            QueuedRequestSnapshot queuedRequestSnapshot2 = new QueuedRequestSnapshot("Project2", ProjectActivity.Pending);
			queueSnapshot1.Requests.Add(queuedRequestSnapshot2);

            return cruiseServerSnapshot;
        }
예제 #10
0
 /// <summary>
 /// Cancels a pending request request.
 /// </summary>
 /// <param name="request">The request.</param>
 public void CancelRequest(QueuedRequestSnapshot request)
 {
     if (request.Activity.IsPending())
     {
         this.client.CancelPendingRequest(request.ProjectName);
     }
 }
예제 #11
0
        private static QueueSnapshot BuildQueueSnapshot(IIntegrationQueue queue)
        {
            QueueSnapshot queueSnapshot = new QueueSnapshot(queue.Name);

            for (int index = 0; index < queue.Count; index++)
            {
                IIntegrationQueueItem integrationQueueItem = (IIntegrationQueueItem)queue[index];
                // The first request in the queue shows it's real activity of CheckingModifications or Building
                // Everything else is in a pending state.
                ProjectActivity projectActivity = ProjectActivity.Pending;
                if (index == 0)
                {
                    projectActivity = integrationQueueItem.Project.CurrentActivity;
                }
                QueuedRequestSnapshot queuedRequestSnapshot = new QueuedRequestSnapshot(
                    integrationQueueItem.Project.Name,
                    projectActivity,
                    integrationQueueItem.IntegrationRequest.RequestTime);
                queueSnapshot.Requests.Add(queuedRequestSnapshot);
            }
            return queueSnapshot;
        }