示例#1
0
        public override bool Equals(object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return(false);
            }

            // If parameter cannot be cast to Point return false.
            YouTrackBug p = obj as YouTrackBug;

            if ((System.Object)p == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return(ID == p.ID);
        }
        //Wildcard char doesn't seem to work in version 3
        //http://youtrack.jetbrains.com/issue/JT-13494#
        public List<IBug> GetFilteredBugsForProject(IProject project, int page, int pageSize, string filterBy, string filterValue)
        {
            string url;
            if(String.IsNullOrEmpty(filterBy) || String.IsNullOrEmpty(filterValue))
                url = String.Format(BUGLISTURL, project.ID, pageSize * page, pageSize);
            else
                url = String.Format(BUGLISTWITHFILTERURL, project.ID, pageSize * page, pageSize, filterBy, filterValue);

            List<IBug> bugs = new List<IBug>();
            string bugsAsXML = GETResponseFrom(url);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(bugsAsXML);

            XmlNodeList bugNodes = doc.SelectNodes("/issues/issue");
            foreach (XmlNode bugNode in bugNodes)
            {
                IBug bug = new YouTrackBug() { ID = bugNode.Attributes["id"].Value, IsResolved = false };

                //Get description node
                XmlNode desNode = bugNode.SelectSingleNode("field[@name='description']/value");
                if (desNode != null)
                    bug.Description = desNode.InnerText;

                //Get summary node
                XmlNode sumNode = bugNode.SelectSingleNode("field[@name='summary']/value");
                if (sumNode != null)
                    bug.Summary = sumNode.InnerText;

                //Find out if resolved
                XmlNode resolvedNode = bugNode.SelectSingleNode("field[@name='resolved']/value");
                if (resolvedNode != null)
                    bug.IsResolved = true;
                else
                    bug.IsResolved = false;

                bugs.Add(bug);
            }//end foreach

            return bugs;
        }