GUI/CrashReportForm.cs
changeset 150 522da3b8cb1a
parent 149 de70c4468b36
child 151 76e18684713d
     1.1 --- a/GUI/CrashReportForm.cs	Sat Jul 03 12:08:51 2010 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,120 +0,0 @@
     1.4 -/*
     1.5 -  
     1.6 -  Version: MPL 1.1/GPL 2.0/LGPL 2.1
     1.7 -
     1.8 -  The contents of this file are subject to the Mozilla Public License Version
     1.9 -  1.1 (the "License"); you may not use this file except in compliance with
    1.10 -  the License. You may obtain a copy of the License at
    1.11 - 
    1.12 -  http://www.mozilla.org/MPL/
    1.13 -
    1.14 -  Software distributed under the License is distributed on an "AS IS" basis,
    1.15 -  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
    1.16 -  for the specific language governing rights and limitations under the License.
    1.17 -
    1.18 -  The Original Code is the Open Hardware Monitor code.
    1.19 -
    1.20 -  The Initial Developer of the Original Code is 
    1.21 -  Michael Möller <m.moeller@gmx.ch>.
    1.22 -  Portions created by the Initial Developer are Copyright (C) 2009-2010
    1.23 -  the Initial Developer. All Rights Reserved.
    1.24 -
    1.25 -  Contributor(s):
    1.26 -
    1.27 -  Alternatively, the contents of this file may be used under the terms of
    1.28 -  either the GNU General Public License Version 2 or later (the "GPL"), or
    1.29 -  the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
    1.30 -  in which case the provisions of the GPL or the LGPL are applicable instead
    1.31 -  of those above. If you wish to allow use of your version of this file only
    1.32 -  under the terms of either the GPL or the LGPL, and not to allow others to
    1.33 -  use your version of this file under the terms of the MPL, indicate your
    1.34 -  decision by deleting the provisions above and replace them with the notice
    1.35 -  and other provisions required by the GPL or the LGPL. If you do not delete
    1.36 -  the provisions above, a recipient may use your version of this file under
    1.37 -  the terms of any one of the MPL, the GPL or the LGPL.
    1.38 - 
    1.39 -*/
    1.40 -
    1.41 -using System;
    1.42 -using System.Collections.Generic;
    1.43 -using System.ComponentModel;
    1.44 -using System.Drawing;
    1.45 -using System.IO;
    1.46 -using System.Net;
    1.47 -using System.Text;
    1.48 -using System.Web;
    1.49 -using System.Windows.Forms;
    1.50 -
    1.51 -namespace OpenHardwareMonitor.GUI {
    1.52 -  public partial class CrashReportForm : Form {
    1.53 -
    1.54 -    private Exception exception;
    1.55 -
    1.56 -    public CrashReportForm() {
    1.57 -      InitializeComponent();
    1.58 -    }
    1.59 -
    1.60 -    public Exception Exception {
    1.61 -      get { return exception; }
    1.62 -      set {
    1.63 -        exception = value;
    1.64 -        StringBuilder s = new StringBuilder();
    1.65 -        Version version = typeof(CrashReportForm).Assembly.GetName().Version;
    1.66 -        s.Append("Version: "); s.AppendLine(version.ToString());        
    1.67 -        s.AppendLine();
    1.68 -        s.AppendLine(exception.ToString());
    1.69 -        s.AppendLine();
    1.70 -        if (exception.InnerException != null) {
    1.71 -          s.AppendLine(exception.InnerException.ToString());
    1.72 -          s.AppendLine();
    1.73 -        }
    1.74 -        s.Append("Common Language Runtime: "); 
    1.75 -        s.AppendLine(Environment.Version.ToString());
    1.76 -        s.Append("Operating System: ");
    1.77 -        s.AppendLine(Environment.OSVersion.ToString());
    1.78 -        s.Append("Process Type: ");
    1.79 -        s.AppendLine(IntPtr.Size == 4 ? "32-Bit" : "64-Bit");
    1.80 -        reportTextBox.Text = s.ToString();        
    1.81 -      }
    1.82 -    }
    1.83 -
    1.84 -    private void sendButton_Click(object sender, EventArgs e) {
    1.85 -      try {
    1.86 -        Version version = typeof(CrashReportForm).Assembly.GetName().Version;
    1.87 -        WebRequest request = WebRequest.Create(
    1.88 -          "http://openhardwaremonitor.org/report.php");
    1.89 -        request.Method = "POST";
    1.90 -        request.Timeout = 5000;
    1.91 -        request.ContentType = "application/x-www-form-urlencoded";
    1.92 -
    1.93 -        string report =
    1.94 -          "version=" + HttpUtility.UrlEncode(version.ToString()) + "&" +
    1.95 -          "report=" + HttpUtility.UrlEncode(reportTextBox.Text) + "&" +
    1.96 -          "comment=" + HttpUtility.UrlEncode(commentTextBox.Text) + "&" +
    1.97 -          "email=" + HttpUtility.UrlEncode(emailTextBox.Text);
    1.98 -        byte[] byteArray = Encoding.UTF8.GetBytes(report);
    1.99 -        request.ContentLength = byteArray.Length;
   1.100 -
   1.101 -        try {
   1.102 -          Stream dataStream = request.GetRequestStream();
   1.103 -          dataStream.Write(byteArray, 0, byteArray.Length);
   1.104 -          dataStream.Close();
   1.105 -
   1.106 -          WebResponse response = request.GetResponse();
   1.107 -          dataStream = response.GetResponseStream();
   1.108 -          StreamReader reader = new StreamReader(dataStream);
   1.109 -          string responseFromServer = reader.ReadToEnd();
   1.110 -          reader.Close();
   1.111 -          dataStream.Close();
   1.112 -          response.Close();
   1.113 -
   1.114 -          Close();
   1.115 -        } catch (WebException) {
   1.116 -          MessageBox.Show("Sending the crash report failed.", "Error", 
   1.117 -            MessageBoxButtons.OK, MessageBoxIcon.Error);
   1.118 -        }
   1.119 -      } catch {
   1.120 -      }
   1.121 -    }
   1.122 -  }  
   1.123 -}