/[AnywhereTS-MSSQL]/trunk/TSAdminTool/frmAdmin.cs
ViewVC logotype

Diff of /trunk/TSAdminTool/frmAdmin.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/TSAdminTool/frmAdmin.cs	2012/07/11 14:19:13	4
+++ trunk/TSAdminTool/frmAdmin.cs	2012/07/12 16:47:17	57
@@ -8,7 +8,8 @@
     using System.Text;
     using System.Windows.Forms;
     using System.Runtime.InteropServices;
-    using System.IO; // For File operations
+    using System.IO;
+    using System.Data.SqlClient; // For File operations
     
 
     public partial class frmAdmin : Form
@@ -23,8 +24,33 @@
         public frmAdmin()
         {
             InitializeComponent();
+            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
         }
 
+        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
+        {
+            Exception ex = (e.ExceptionObject as Exception);
+            if (ex == null)
+            {
+                Logging.ATSAdminLog.Error("Encountered unhandled Exception, but the exception was null");
+                return;
+            }
+            if (ex.GetType() == typeof(SqlException))
+            {
+                SqlException sql_ex = (ex as SqlException);
+                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())))
+                {
+                    Logging.ATSAdminLog.Error("Encountered unhandled SqlException");
+                }
+            }
+            else
+            {
+                using (log4net.NDC.Push(string.Format("Exception: MESSAGE={0}{1}Diagnostics:{1}{2}", ex.Message, System.Environment.NewLine, ex.ToString())))
+                {
+                    Logging.ATSAdminLog.Error("Encountered unhandled Exception");
+                }
+            }
+        }
 
         private void frmAdmin_Load(object sender, EventArgs e)
         {
@@ -407,6 +433,10 @@
                 else
                 {   // Unhandled node
                     MessageBox.Show("Error: unhandled node (28843)");
+                    using (log4net.NDC.Push(string.Format("unhandled node={0}", node.Parent.Name)))
+                    {
+                        Logging.ATSAdminLog.Error("rror: unhandled node (28843)");
+                    }
                 }
             }
             else
@@ -755,6 +785,10 @@
             {
                 this.Cursor = Cursors.Default;
                 MessageBox.Show("Could not create directory '" + dataDir + "'. Error: " + ex.Message);
+                using (log4net.NDC.Push(string.Format("directory={0}", dataDir)))
+                {
+                    Logging.ATSAdminLog.Error("Could not create directory.");
+                }
                 return false;
             }
 
@@ -869,9 +903,13 @@
                 {
                     ProSupport.clientTableAdapter.FillClients(datasetAllClients.Client);
                 }
-                catch (Exception ex)
+                catch (SqlException ex)
                 {
                     MessageBox.Show("Unhandled SQL error, please restart AnywhereTS. Details: " + ex.Message);
+                    using (log4net.NDC.Push(string.Format("SqlException: ID={0} MESSAGE={1}{2}Diagnostics:{2}{3}", ex.Number.ToString(), ex.Message, System.Environment.NewLine, ex.ToString())))
+                    {
+                        Logging.ATSAdminLog.Error("Encountered Unhandled or Unexcepected SQL error");
+                    }
                     Application.Exit();
                     return;
                 }
@@ -911,6 +949,10 @@
             else
             {
                 MessageBox.Show("Error, no mode selected (56541)");
+                using (log4net.NDC.Push(string.Format("ATSGlobals.managedMode={0}", ATSGlobals.managedMode)))
+                {
+                    Logging.ATSAdminLog.Error("Error, no mode selected (56541)");
+                }
             }
         }
 

 

  ViewVC Help
Powered by ViewVC 1.1.22