moel@86: /* moel@86: moel@86: Version: MPL 1.1/GPL 2.0/LGPL 2.1 moel@86: moel@86: The contents of this file are subject to the Mozilla Public License Version moel@86: 1.1 (the "License"); you may not use this file except in compliance with moel@86: the License. You may obtain a copy of the License at moel@86: moel@86: http://www.mozilla.org/MPL/ moel@86: moel@86: Software distributed under the License is distributed on an "AS IS" basis, moel@86: WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License moel@86: for the specific language governing rights and limitations under the License. moel@86: moel@86: The Original Code is the Open Hardware Monitor code. moel@86: moel@86: The Initial Developer of the Original Code is moel@86: Michael Möller . moel@86: Portions created by the Initial Developer are Copyright (C) 2009-2010 moel@86: the Initial Developer. All Rights Reserved. moel@86: moel@86: Contributor(s): moel@86: moel@86: Alternatively, the contents of this file may be used under the terms of moel@86: either the GNU General Public License Version 2 or later (the "GPL"), or moel@86: the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), moel@86: in which case the provisions of the GPL or the LGPL are applicable instead moel@86: of those above. If you wish to allow use of your version of this file only moel@86: under the terms of either the GPL or the LGPL, and not to allow others to moel@86: use your version of this file under the terms of the MPL, indicate your moel@86: decision by deleting the provisions above and replace them with the notice moel@86: and other provisions required by the GPL or the LGPL. If you do not delete moel@86: the provisions above, a recipient may use your version of this file under moel@86: the terms of any one of the MPL, the GPL or the LGPL. moel@86: moel@86: */ moel@86: moel@86: using System; moel@86: using System.Collections.Generic; moel@86: using System.ComponentModel; moel@86: using System.Data; moel@86: using System.Drawing; moel@86: using System.IO; moel@86: using System.Net; moel@86: using System.Text; moel@86: using System.Web; moel@86: using System.Windows.Forms; moel@86: moel@86: namespace OpenHardwareMonitor.GUI { moel@86: public partial class CrashReportForm : Form { moel@86: moel@86: private Exception exception; moel@86: moel@86: public CrashReportForm() { moel@86: InitializeComponent(); moel@86: } moel@86: moel@86: public Exception Exception { moel@86: get { return exception; } moel@86: set { moel@86: exception = value; moel@86: StringBuilder s = new StringBuilder(); moel@86: Version version = typeof(CrashReportForm).Assembly.GetName().Version; moel@86: s.Append("Version: "); s.AppendLine(version.ToString()); moel@86: s.AppendLine(); moel@86: s.AppendLine(exception.ToString()); moel@86: s.AppendLine(); moel@86: if (exception.InnerException != null) { moel@86: s.AppendLine(exception.InnerException.ToString()); moel@86: s.AppendLine(); moel@86: } moel@86: reportTextBox.Text = s.ToString(); moel@86: } moel@86: } moel@86: moel@86: private void sendButton_Click(object sender, EventArgs e) { moel@87: try { moel@87: Version version = typeof(CrashReportForm).Assembly.GetName().Version; moel@87: WebRequest request = WebRequest.Create( moel@87: "http://openhardwaremonitor.org/report.php"); moel@87: request.Method = "POST"; moel@87: request.Timeout = 3000; moel@87: request.ContentType = "application/x-www-form-urlencoded"; moel@86: moel@87: string report = moel@87: "version=" + HttpUtility.UrlEncode(version.ToString()) + "&" + moel@87: "report=" + HttpUtility.UrlEncode(reportTextBox.Text + moel@87: commentTextBox.Text); moel@87: byte[] byteArray = Encoding.UTF8.GetBytes(report); moel@87: request.ContentLength = byteArray.Length; moel@87: moel@87: Stream dataStream = request.GetRequestStream(); moel@87: dataStream.Write(byteArray, 0, byteArray.Length); moel@86: dataStream.Close(); moel@87: try { moel@87: WebResponse response = request.GetResponse(); moel@87: dataStream = response.GetResponseStream(); moel@87: StreamReader reader = new StreamReader(dataStream); moel@87: string responseFromServer = reader.ReadToEnd(); moel@87: reader.Close(); moel@87: dataStream.Close(); moel@87: response.Close(); moel@87: } catch (WebException) { moel@87: } moel@87: } finally { moel@87: Close(); moel@86: } moel@86: } moel@86: } moel@86: }