1 |
using System; |
2 |
using System.Collections.Generic; |
3 |
using System.Windows.Forms; |
4 |
using System.Data.SqlClient; |
5 |
|
6 |
namespace AnywhereTS |
7 |
{ |
8 |
static class Program |
9 |
{ |
10 |
/// <summary> |
11 |
/// The main entry point for the application. |
12 |
/// </summary> |
13 |
[STAThread] |
14 |
static void Main() |
15 |
{ |
16 |
AppDomain currentDomain = AppDomain.CurrentDomain; |
17 |
currentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); |
18 |
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException, true); |
19 |
|
20 |
Application.EnableVisualStyles(); |
21 |
Application.SetCompatibleTextRenderingDefault(false); |
22 |
|
23 |
frmClientProperties objCustomDialogBox = new frmClientProperties(); |
24 |
objCustomDialogBox.dialogMode = frmClientProperties.ATSClientMode.CONTROL_PANEL; // Select the mode to run the form in. |
25 |
Application.Run(objCustomDialogBox); |
26 |
} |
27 |
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs args) |
28 |
{ |
29 |
Exception e = (Exception)args.ExceptionObject; |
30 |
if (e == null) |
31 |
{ |
32 |
Logging.ATSAdminLog.Error("Encountered unhandled Exception, but the exception was null"); |
33 |
return; |
34 |
} |
35 |
if (e.GetType() == typeof(SqlException)) |
36 |
{ |
37 |
SqlException sql_ex = (e as SqlException); |
38 |
using (log4net.NDC.Push(string.Format("SqlException: ID={0} MESSAGE={1}{2}Diagnostics:{2}{3}", sql_ex.Number.ToString(), sql_ex.Message, System.Environment.NewLine, sql_ex.ToString()))) |
39 |
{ |
40 |
Logging.ATSAdminLog.Error("Encountered unhandled SqlException"); |
41 |
} |
42 |
} |
43 |
else |
44 |
{ |
45 |
using (log4net.NDC.Push(string.Format("Exception: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString()))) |
46 |
{ |
47 |
Logging.ATSAdminLog.Error("Encountered unhandled Exception"); |
48 |
} |
49 |
} |
50 |
} |
51 |
} |
52 |
} |