public static int Create(string space, string user, string password, string summary, string description, AssemblaStatus status, AssemblaPriority priority) { int stat = (int)status; int pri = (int)priority; string url = GetTicketsUrl(space); HttpWebRequest hr = WebRequest.Create(url) as HttpWebRequest; hr.Credentials = new System.Net.NetworkCredential(user, password); hr.PreAuthenticate = true; hr.Method = "POST"; hr.ContentType = "application/xml"; StringBuilder data = new StringBuilder(); data.AppendLine("<ticket>"); data.AppendLine("<status>"+stat.ToString()+"</status>"); data.AppendLine("<priority>" + pri.ToString()+"</priority>"); data.AppendLine("<summary>"); data.AppendLine(System.Web.HttpUtility.HtmlEncode(summary)); data.AppendLine("</summary>"); data.AppendLine("<description>"); data.AppendLine(System.Web.HttpUtility.HtmlEncode(description)); data.AppendLine("</description>"); data.AppendLine("</ticket>"); // encode byte[] bytes = UTF8Encoding.UTF8.GetBytes(data.ToString()); hr.ContentLength = bytes.Length; // prepare id int id = 0; try { // write it System.IO.Stream post = hr.GetRequestStream(); post.Write(bytes, 0, bytes.Length); // get response System.IO.StreamReader response = new System.IO.StreamReader(hr.GetResponse().GetResponseStream()); // get string version string rs = response.ReadToEnd(); XmlDocument xd = new XmlDocument(); xd.LoadXml(rs); XmlNodeList xnl = xd.GetElementsByTagName("id"); string val = xnl[0].InnerText; if ((val!=null) && (val!=string.Empty)) id = Convert.ToInt32(val); // display it if (SendDebug!=null) SendDebug(DebugImpl.Create(rs)); } catch (Exception ex) { if (SendDebug != null) SendDebug(DebugImpl.Create("exception: " + ex.Message+ex.StackTrace)); return 0; } return id; }
public static int Create(string space, string user, string password, string summary, string description, AssemblaStatus status, AssemblaPriority priority) { int stat = (int)status; int pri = (int)priority; string url = GetTicketsUrl(space); HttpWebRequest hr = WebRequest.Create(url) as HttpWebRequest; hr.Credentials = new System.Net.NetworkCredential(user, password); hr.PreAuthenticate = true; hr.Method = "POST"; hr.ContentType = "application/xml"; StringBuilder data = new StringBuilder(); data.AppendLine("<ticket>"); data.AppendLine("<status>" + stat.ToString() + "</status>"); data.AppendLine("<priority>" + pri.ToString() + "</priority>"); data.AppendLine("<summary>"); data.AppendLine(System.Web.HttpUtility.HtmlEncode(summary)); data.AppendLine("</summary>"); data.AppendLine("<description>"); data.AppendLine(System.Web.HttpUtility.HtmlEncode(description)); data.AppendLine("</description>"); data.AppendLine("</ticket>"); // encode byte[] bytes = UTF8Encoding.UTF8.GetBytes(data.ToString()); hr.ContentLength = bytes.Length; // prepare id int id = 0; try { // write it System.IO.Stream post = hr.GetRequestStream(); post.Write(bytes, 0, bytes.Length); // get response System.IO.StreamReader response = new System.IO.StreamReader(hr.GetResponse().GetResponseStream()); // get string version string rs = response.ReadToEnd(); XmlDocument xd = new XmlDocument(); xd.LoadXml(rs); XmlNodeList xnl = xd.GetElementsByTagName("id"); string val = xnl[0].InnerText; if ((val != null) && (val != string.Empty)) { id = Convert.ToInt32(val); } // display it if (SendDebug != null) { SendDebug(DebugImpl.Create(rs)); } } catch (Exception ex) { if (SendDebug != null) { SendDebug(DebugImpl.Create("exception: " + ex.Message + ex.StackTrace)); } return(0); } return(id); }