Esempio n. 1
0
        public LabelResult[] UnlabelItem(Workspace workspace, string labelName,
                                         string labelScope, ItemSpec[] itemSpecs,
                                         VersionSpec version)
        {
            Message msg = new Message(GetWebRequest(new Uri(Url)), "UnlabelItem");

            msg.Body.WriteElementString("workspaceName", workspace.Name);
            msg.Body.WriteElementString("workspaceOwner", workspace.OwnerName);
            msg.Body.WriteElementString("labelName", labelName);

            if (!String.IsNullOrEmpty(labelScope))
            {
                msg.Body.WriteElementString("labelScope", labelScope);
            }

            msg.Body.WriteStartElement("items");
            foreach (ItemSpec itemSpec in itemSpecs)
            {
                itemSpec.ToXml(msg.Body, "ItemSpec");
            }
            msg.Body.WriteEndElement();

            version.ToXml(msg.Body, "version");

            List <LabelResult> labelResults = new List <LabelResult>();
            List <Failure>     faillist     = new List <Failure>();

            using (HttpWebResponse response = Invoke(msg))
            {
                XmlReader results = msg.ResponseReader(response);

                while (results.Read())
                {
                    if (results.NodeType == XmlNodeType.Element)
                    {
                        switch (results.Name)
                        {
                        case "LabelResult":
                            labelResults.Add(LabelResult.FromXml(this, results));
                            break;

                        case "Failure":
                            faillist.Add(Failure.FromXml(this, results));
                            break;
                        }
                    }
                }
            }

            foreach (Failure failure in faillist)
            {
                versionControlServer.OnNonFatalError(workspace, failure);
            }

            return(labelResults.ToArray());
        }
        private List <Failure> FailuresExtractor(XElement response)
        {
            var failures = response.Element(MessageNs + "failures");

            if (failures != null)
            {
                return(failures.Elements(MessageNs + "Failure").Select(x => Failure.FromXml(x)).ToList());
            }
            return(new List <Failure>());
        }
Esempio n. 3
0
        public PendingChange[] QueryPendingSets(string localWorkspaceName, string localWorkspaceOwner,
                                                string queryWorkspaceName, string ownerName,
                                                ItemSpec[] itemSpecs, bool generateDownloadUrls,
                                                out Failure[] failures)
        {
            Message msg = new Message(GetWebRequest(new Uri(Url)), "QueryPendingSets");

            msg.Body.WriteElementString("localWorkspaceName", localWorkspaceName);
            msg.Body.WriteElementString("localWorkspaceOwner", localWorkspaceOwner);
            msg.Body.WriteElementString("queryWorkspaceName", queryWorkspaceName);
            msg.Body.WriteElementString("ownerName", ownerName);

            msg.Body.WriteStartElement("itemSpecs");
            foreach (ItemSpec item in itemSpecs)
            {
                item.ToXml(msg.Body, "ItemSpec");
            }
            msg.Body.WriteEndElement();

            msg.Body.WriteElementString("generateDownloadUrls",
                                        generateDownloadUrls.ToString().ToLower());

            List <PendingChange> changes  = new List <PendingChange>();
            List <Failure>       faillist = new List <Failure>();

            using (HttpWebResponse response = Invoke(msg))
            {
                XmlReader results = msg.ResponseReader(response);

                while (results.Read())
                {
                    if (results.NodeType == XmlNodeType.Element)
                    {
                        switch (results.Name)
                        {
                        case "PendingChange":
                            changes.Add(PendingChange.FromXml(this, results));
                            break;

                        case "Failure":
                            faillist.Add(Failure.FromXml(this, results));
                            break;
                        }
                    }
                }
            }

            failures = faillist.ToArray();
            return(changes.ToArray());
        }
Esempio n. 4
0
        public LabelResult[] LabelItem(Workspace workspace, VersionControlLabel label,
                                       LabelItemSpec[] labelSpecs, LabelChildOption children)
        {
            Message msg = new Message(GetWebRequest(new Uri(Url)), "LabelItem");

            msg.Body.WriteElementString("workspaceName", workspace.Name);
            msg.Body.WriteElementString("workspaceOwner", workspace.OwnerName);
            label.ToXml(msg.Body, "label");

            msg.Body.WriteStartElement("labelSpecs");
            foreach (LabelItemSpec labelSpec in labelSpecs)
            {
                labelSpec.ToXml(msg.Body, "LabelItemSpec");
            }
            msg.Body.WriteEndElement();

            msg.Body.WriteElementString("children", children.ToString());

            List <LabelResult> labelResults = new List <LabelResult>();
            List <Failure>     faillist     = new List <Failure>();

            using (HttpWebResponse response = Invoke(msg))
            {
                XmlReader results = msg.ResponseReader(response);

                while (results.Read())
                {
                    if (results.NodeType == XmlNodeType.Element)
                    {
                        switch (results.Name)
                        {
                        case "LabelResult":
                            labelResults.Add(LabelResult.FromXml(this, results));
                            break;

                        case "Failure":
                            faillist.Add(Failure.FromXml(this, results));
                            break;
                        }
                    }
                }
            }

            foreach (Failure failure in faillist)
            {
                versionControlServer.OnNonFatalError(workspace, failure);
            }

            return(labelResults.ToArray());
        }
Esempio n. 5
0
        public GetOperation[] PendChanges(Workspace workspace, ChangeRequest[] changes)
        {
            Message msg = new Message(GetWebRequest(new Uri(Url)), "PendChanges");

            msg.Body.WriteElementString("workspaceName", workspace.Name);
            msg.Body.WriteElementString("ownerName", workspace.OwnerName);
            msg.Body.WriteStartElement("changes");
            foreach (ChangeRequest change in changes)
            {
                change.ToXml(msg.Body, "");
            }
            msg.Body.WriteEndElement();

            List <GetOperation> operations = new List <GetOperation>();
            List <Failure>      faillist   = new List <Failure>();

            using (HttpWebResponse response = Invoke(msg))
            {
                XmlReader results = msg.ResponseReader(response);

                while (results.Read())
                {
                    if (results.NodeType == XmlNodeType.Element)
                    {
                        switch (results.Name)
                        {
                        case "GetOperation":
                            operations.Add(GetOperation.FromXml(ItemUrl, results));
                            break;

                        case "Failure":
                            faillist.Add(Failure.FromXml(this, results));
                            break;
                        }
                    }
                }
            }

            foreach (Failure failure in faillist)
            {
                versionControlServer.OnNonFatalError(workspace, failure);
            }

            return(operations.ToArray());
        }
Esempio n. 6
0
        public int CheckIn(Workspace workspace, string[] serverItems, string comment,
                           ref SortedList <string, bool> undoneServerItems)
        {
            Message msg = new Message(GetWebRequest(new Uri(Url)), "CheckIn");

            msg.Body.WriteElementString("workspaceName", workspace.Name);
            msg.Body.WriteElementString("ownerName", workspace.OwnerName);

            msg.Body.WriteStartElement("serverItems");
            foreach (string serverItem in serverItems)
            {
                msg.Body.WriteElementString("string", serverItem);
            }
            msg.Body.WriteEndElement();

            // write info subtree
            msg.Body.WriteStartElement("info");

            DateTime dt = new DateTime(0);

            msg.Body.WriteAttributeString("date", dt.ToString("s"));

            msg.Body.WriteAttributeString("cset", "0");
            msg.Body.WriteAttributeString("owner", workspace.OwnerName);
            msg.Body.WriteElementString("Comment", comment);
            msg.Body.WriteElementString("CheckinNote", "");
            msg.Body.WriteElementString("PolicyOverride", "");
            msg.Body.WriteElementString("CheckinOptions", "ValidateCheckinOwner");
            msg.Body.WriteEndElement();

            int cset = 0;

            using (HttpWebResponse response = Invoke(msg))
            {
                XmlReader results = msg.ResponseReader(response);
                cset = Convert.ToInt32(results.GetAttribute("cset"));

                List <Failure> failures = new List <Failure>();

                //TODO: read <ImplicitItems />
                //<CheckInResponse xmlns="http://schemas.microsoft.com/TeamFoundation/2005/06/VersionControl/ClientServices/03"><CheckInResult cset="11486"><UndoneServerItems /><ImplicitItems /></CheckInResult><failures /></CheckInResponse>
                while (results.Read())
                {
                    if (results.NodeType == XmlNodeType.Element)
                    {
                        switch (results.Name)
                        {
                        case "Failure":
                            failures.Add(Failure.FromXml(this, results));
                            break;

                        case "string":
                            undoneServerItems.Add(results.ReadString(), true);
                            break;
                        }
                    }
                }

                foreach (Failure failure in failures)
                {
                    versionControlServer.OnNonFatalError(workspace, failure);
                }
            }

            return(cset);
        }