Blame view

SunVoteARSPPT/Forms/FrmErrorMsg.cs 3.63 KB
20c0108c   wutaian   xx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
  /// ----------------------------------------------------------------
  ///   名:FrmErrorMsg.cs
  /// 功能描述:系统错误日志类
  /// 
  /// 创建:杨斌 2011-11-29
  /// 修改:杨斌 2013-09-02
  /// ----------------------------------------------------------------
  using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  using GeneralLib;
  using System.Diagnostics;
  using System.IO;
  using SunVoteARSPPT;
  
  namespace GeneralLib
  {
      public partial class FrmErrorMsg : Form
      {
          public FrmErrorMsg(Exception ex, string logPath, string msg = "")
          {
              try
              {
                  InitializeComponent();
  
                  string title = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name
                          + " " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
  
                  string logInfo = DateTime.Now.ToString() + "\r\n" + title + "\r\n" + ex.ToString();
                  if (!string.IsNullOrEmpty(msg))
                      logInfo += msg;
  
                  this.Text = title;
                  txtDetail.Text = logInfo;
                  LogPath = logPath;
  
                  btnShowLog.Visible = File.Exists(LogPath);
  
                  strBtnShowDetal0 = GlobalInfo.SysLanguage.LPT.ReadString("FrmErrorMsg", "btnShowDetail", "点击此处查看详细信息↓");
                  strBtnShowDetal1 = GlobalInfo.SysLanguage.LPT.ReadString("FrmErrorMsg", "btnShowDetail_1", "收起详细信息↑");
  
                  GlobalInfo.SysLanguage.SetLanguage(this.Name, this);
              }
              catch (Exception exx)
              {
                  MessageBox.Show(exx.ToString());
              }
          }
  
          private string strBtnShowDetal0 = "";
          private string strBtnShowDetal1 = "";
  
          public string LogPath = "";
  
          private void FrmErrorMsg_Load(object sender, EventArgs e)
          {
              ShowDetail = false;
              ShowDetail = true;//杨斌 2019-06-13。默认展开。之前他们评审默认隐藏,结果每次报错截图有个屁用,真™坑
  
              //杨斌 2014-06-16
              this.Text += "  " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + "  " + FrmAboutPowerVote.GetVersionInfo();
          }
  
          private void btnShowDetail_Click(object sender, EventArgs e)
          {
              ShowDetail = !ShowDetail;
          }
  
          private bool mShowDetail = false;
          private bool ShowDetail
          {
              get { return mShowDetail; }
              set
              {
                  mShowDetail = value;
                  if (value)
                  {
                      this.Height = pnlDetail.Bottom + (int)(btnShowDetail.Height*1.5f);//杨斌 2016-03-01
                      pnlDetail.Visible = true;
                      btnShowDetail.Text = strBtnShowDetal1;
                  }
                  else
                  {
                      this.Height = pnlDetail.Top + (int)(btnShowDetail.Height * 1.5f);//杨斌 2016-03-01
                      pnlDetail.Visible = false;
                      btnShowDetail.Text = strBtnShowDetal0;
                  }
              }
          }
  
          private void btnCancel_Click(object sender, EventArgs e)
          {
              this.Close();
          }
  
          private void btnShowLog_Click(object sender, EventArgs e)
          {
              if (!File.Exists(LogPath)) return;
              Process open = new Process();
              open.StartInfo.FileName = "explorer";
              open.StartInfo.Arguments = @"/select," + LogPath;
              open.Start();
  
          }
      }
  }