static void send(MainForm frm) { Uri URL = new Uri(Program.url + "/insert_bug.aspx"); ExtendedWebClient extendedWebClient = new ExtendedWebClient(); CredentialCache myCredCache = new CredentialCache(); myCredCache.Add(URL, "Basic", new NetworkCredential(Program.username, Program.password)); myCredCache.Add(URL, "NTLM", new NetworkCredential(Program.username, Program.password, Program.domain)); extendedWebClient.Credentials = myCredCache; System.IO.MemoryStream ms = new System.IO.MemoryStream(); frm.getBitmap().Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); string base64 = System.Convert.ToBase64String(ms.ToArray()); ms.Close(); ms.Dispose(); try { // Anmelden per POST; anonymer Typ als Parameterobjekt WebRequest req = extendedWebClient.Post(URL, new { username = Program.username, password = Program.password, bugid = frm.textBoxBugId.Text, short_desc = frm.textBoxShortDescription.Text, projectid = Convert.ToString(Program.project_id), attachment_content_type = "image/jpg", attachment_filename = "screenshot.jpg", attachment = base64 }); WebResponse res = (WebResponse)req.GetResponse(); frm.BeginInvoke(new MainForm.ResponseDelegate(frm.handleResponse), res); } catch (Exception e2) { frm.BeginInvoke(new MainForm.ResponseDelegate(frm.handleResponse), e2); } }
static void send(MainForm frm) { Uri URL = new Uri(Program.url + "/insert_bug.aspx"); ExtendedWebClient extendedWebClient = new ExtendedWebClient(); CredentialCache myCredCache = new CredentialCache(); myCredCache.Add(URL, "Basic", new NetworkCredential(Program.username, Program.password)); myCredCache.Add(URL, "NTLM", new NetworkCredential(Program.username, Program.password, Program.domain)); extendedWebClient.Credentials = myCredCache; System.IO.MemoryStream ms = new System.IO.MemoryStream(); frm.getBitmap().Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); string base64 = System.Convert.ToBase64String(ms.ToArray()); ms.Close(); ms.Dispose(); try { // Anmelden per POST; anonymer Typ als Parameterobjekt WebRequest req = extendedWebClient.Post(URL, new { username = Program.username, password = Program.password, bugid = frm.textBoxBugId.Text, short_desc = frm.textBoxShortDescription.Text, projectid = Convert.ToString(Program.project_id), attachment_content_type = "image/jpg", attachment_filename = String.Format("screenshot_{0}.jpg", DateTime.Now.ToString("yyyyMMdd'_'HHmmss")), attachment = base64 }); WebResponse res = (WebResponse)req.GetResponse(); frm.BeginInvoke(new MainForm.ResponseDelegate(frm.handleResponse), res); } catch (Exception e2) { frm.BeginInvoke(new MainForm.ResponseDelegate(frm.handleResponse), e2); } }