forked from itdos/Dos.Tool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
78 lines (69 loc) · 2.66 KB
/
Program.cs
File metadata and controls
78 lines (69 loc) · 2.66 KB
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
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;
using System.Text;
using System.Threading;
using Dos.Common;
using Dos.Tools.EntityDesign.Forms;
namespace Hxj.Tools.EntityDesign
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
#region 检查最新版
try
{
var serverVersion = HttpHelper.Get("http://123.57.75.168:8001/DosToolsEntityDesign.txt", "", 2);
string thisVersion = Application.ProductVersion;
if (Convert.ToInt32(serverVersion.Replace("v", "").Replace(".", "")) > Convert.ToInt32(thisVersion.Replace(".", "")))
{
var cv = new CheckVersion();
cv.ShowDialog();
}
}
catch (Exception)
{
}
#endregion
Application.Run(new MainForm());
}
/// <summary>
/// 记录错误
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
MessageBox.Show(e.Exception.Message + "\r\n 详情请查看日志!", "出错啦!", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (!Directory.Exists(errorpath))
{
Directory.CreateDirectory(errorpath);
}
string errorDayPath = Path.Combine(errorpath, DateTime.Now.ToString("yyyyMM") + ".txt");
StringBuilder error = new StringBuilder();
error.Append("DateTime:");
error.Append(DateTime.Now.ToString());
error.Append("\r\n");
error.Append("Message:");
error.Append(e.Exception.Message);
error.Append("\r\n");
error.Append("Source:");
error.Append(e.Exception.Source);
error.Append("\r\n");
error.Append("StackTrace:");
error.Append(e.Exception.StackTrace);
error.Append("\r\n--------------------------------------------------------------\r\n");
File.AppendAllText(errorDayPath, error.ToString());
}
public static string errorpath = Path.Combine(Application.StartupPath, "log");
}
}