/// <summary> /// Adds the newly created case to the system and adds the ID to the class /// </summary> /// <returns>The case with the id populated</returns> public FogBugzCase Add(FogBugzCase fogBugzCase) { //Make sure we have a token if (this.token == "") { throw new FogBugzApiException("You need to logon to the API before calling this method"); } //Now construct the various parameters Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("token", this.token); parameters.Add("sTitle", fogBugzCase.Title); parameters.Add("ixProject", fogBugzCase.Project); parameters.Add("ixArea", fogBugzCase.Area); parameters.Add("ixFixFor", fogBugzCase.FixFor); parameters.Add("ixCategory", fogBugzCase.Category); parameters.Add("ixPersonAssignedTo", fogBugzCase.PersonAssignedTo); parameters.Add("ixPriority", fogBugzCase.Priority); parameters.Add("dtDue", fogBugzCase.Due); parameters.Add("hrsCurrEst", fogBugzCase.HrsCurrEst); parameters.Add("sVersion", fogBugzCase.Version); parameters.Add("sComputer", fogBugzCase.Computer); parameters.Add("sEvent", fogBugzCase.Description); //Finally call the method and get the id back XmlElement response = CallMethod("new", parameters); //Extract the bug/case id and populate XmlElement xmlNewCase = (XmlElement)response.SelectSingleNode("case"); fogBugzCase.Id = Int32.Parse(xmlNewCase.Attributes["ixBug"].Value); return(fogBugzCase); }
/// <summary> /// Gets an existing case in the system /// </summary> /// <param name="id">The id of the case to retrieve</param> /// <returns>The case object</returns> protected List <FogBugzCase> Search(string searchString) { //First create the list of items List <FogBugzCase> fogBugzCases = new List <FogBugzCase>(); //Make sure we have a token if (this.token == "") { throw new FogBugzApiException("You need to logon to the API before calling this method"); } //Now construct the various parameters Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("token", this.token); parameters.Add("q", searchString); parameters.Add("cols", "ixBug,fOpen,sTitle,sLatestTextSummary,ixProject,ixArea,ixPersonOpenedBy,ixPersonAssignedTo,ixStatus,ixPriority,ixFixFor,sVersion,sComputer,hrsCurrEst,ixCategory,dtClosed,dtDue,dtLastUpdated"); //Finally call the method and get the response xml XmlElement response = CallMethod("search", parameters); //Extract the bug/case id and populate XmlNodeList xmlCases = (XmlNodeList)response.ChildNodes[0].ChildNodes; foreach (XmlElement xmlCase in xmlCases) { FogBugzCase fogBugzCase = new FogBugzCase(); fogBugzCase.Id = Int32.Parse(xmlCase.Attributes["ixBug"].Value); fogBugzCase.Title = xmlCase.SelectSingleNode("sTitle").InnerText; fogBugzCase.Project = GetIntValue(xmlCase, "ixProject"); fogBugzCase.Area = GetIntValue(xmlCase, "ixArea"); fogBugzCase.FixFor = GetIntValue(xmlCase, "ixFixFor"); fogBugzCase.Status = GetIntValue(xmlCase, "ixStatus"); fogBugzCase.Category = GetIntValue(xmlCase, "ixCategory"); fogBugzCase.PersonOpenedBy = GetIntValue(xmlCase, "ixPersonOpenedBy"); fogBugzCase.PersonAssignedTo = GetIntValue(xmlCase, "ixPersonAssignedTo"); fogBugzCase.Priority = GetIntValue(xmlCase, "ixPriority"); fogBugzCase.Due = GetDateTimeValue(xmlCase, "dtDue"); fogBugzCase.HrsCurrEst = GetIntValue(xmlCase, "hrsCurrEst"); fogBugzCase.Version = xmlCase.SelectSingleNode("sVersion").InnerText; fogBugzCase.Computer = xmlCase.SelectSingleNode("sComputer").InnerText; fogBugzCase.Description = xmlCase.SelectSingleNode("sLatestTextSummary").InnerText; fogBugzCase.Closed = GetDateTimeValue(xmlCase, "dtClosed"); fogBugzCase.LastUpdated = GetDateTimeValue(xmlCase, "dtLastUpdated"); fogBugzCases.Add(fogBugzCase); } //Return the case return(fogBugzCases); }