-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
92 lines (79 loc) · 3.02 KB
/
Program.cs
File metadata and controls
92 lines (79 loc) · 3.02 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Threading;
namespace ZZ
{
static class Program
{
[DllImport("kernel32.dll")]
static extern bool AttachConsole(UInt32 dwProcessId = 0xffffffff);
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
MainForm baseForm = new MainForm();
if (0 < args.Length)
{
if ("auto" == args[0])
{
baseForm.LoadSettings();
string type = string.Empty;
if (args.Length > 1)
{
type = args[1];
}
baseForm.StartProcess(type);
}
else if ("?" == args[0])
{
AttachConsole();
Console.WriteLine();
Console.WriteLine("Help");
Console.WriteLine("auto - start in SQL->WEB tab");
Console.WriteLine("auto web - start in WEB tab");
Console.WriteLine("auto sql - start in SQL tab");
}
}
else
{
Application.Run(baseForm);
}
}
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
ProcessException(e.Exception, "Unhandled Thread Exception");
}
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
ProcessException((e.ExceptionObject as Exception), "Unhandled UI Exception");
}
private static void ProcessException(Exception ex, string caption)
{
if (System.Windows.Forms.Application.MessageLoop)
{
DialogResult rez = UI.ExceptionCustomForm.Instance.ShowModal(ex, caption, ex.Message,
"Retry", "Abort");
if (DialogResult.Abort == rez)
{
System.Windows.Forms.Application.Exit();
}
}
else
{
AttachConsole();
Console.WriteLine();
Console.WriteLine("Error");
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
System.Environment.Exit(1);
}
}
}
}