/[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/12 16:47:17	57
+++ trunk/TSAdminTool/frmAdmin.cs	2012/07/14 04:50:27	99
@@ -9,7 +9,8 @@
     using System.Windows.Forms;
     using System.Runtime.InteropServices;
     using System.IO;
-    using System.Data.SqlClient; // For File operations
+    using System.Data.SqlClient;
+    using System.Security.Permissions; // For File operations
     
 
     public partial class frmAdmin : Form
@@ -23,38 +24,15 @@
         private string selectedClientMacAddress; // The MAC address of the currently selected client.
         public frmAdmin()
         {
+            Logging.ATSAdminLog.Debug("Entering frmAdmin .ctor()");
             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");
-                }
-            }
+            Logging.ATSAdminLog.Debug("Leaving frmAdmin .ctor()");
         }
 
         private void frmAdmin_Load(object sender, EventArgs e)
         {
-            this.Cursor = Cursors.WaitCursor;
+            //this.Cursor = Cursors.WaitCursor;
+            Logging.ATSAdminLog.Debug("Entering frmAdmin_Load()");
 
             UpdateControlsToReflectProgramVersion();
 
@@ -83,10 +61,12 @@
             ATSImageDesigntimeConfig newConfig = new ATSImageDesigntimeConfig();
             newConfig.ReadDefaultFromDatabase();
             newConfig.WriteDefaultsToDatabase();
+            Logging.ATSAdminLog.Debug("Leaving frmAdmin_Load()");
         } // form load
 
         private void UpdateControlsToReflectProgramVersion()
         {
+            Logging.ATSAdminLog.Debug("Entering UpdateControlsToReflectProgramVersion()");
             // Update the application to reflect the type of license and release
             ATSGlobals.isPro = true;
             Globals.isPro = ATSGlobals.isPro; // Update program status for the VB part of the application.
@@ -95,6 +75,7 @@
 
             this.Text = ATSGlobals.ApplicationTitle; // Set name in window title
             aboutToolStripMenuItem.Text = "About " + ATSGlobals.ApplicationTitle;
+            Logging.ATSAdminLog.Debug("Leaving UpdateControlsToReflectProgramVersion()");
         }
 
         // Update database from terminal server sessions
@@ -634,7 +615,13 @@
                 }
                 else
                 {
-                    throw new Exception("Error: Cannot find record to delete (43556)");
+                    string error = string.Format("Error: Cannot find record to delete (43556) for mac address: {0}", selectedClientMacAddress);
+                    using (log4net.NDC.Push(string.Format("MacAddress={0}", selectedClientMacAddress)))
+                    {
+                        Logging.ATSAdminLog.Error(error);
+                    }
+                    MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("MacAddress={0}", selectedClientMacAddress)));
+                    return;
                 }
             }
         }
@@ -763,9 +750,10 @@
 
 
         // Configure AnywhereTS
-        // Run first time starting ATS and can also be invoked from the Tools menu.
+        // Run first time starting ATS and can also be invoked from the Tools menu.        
         private bool ConfigureATS()
         {
+            Logging.ATSAdminLog.Debug("Entering ConfigureATS()");
             DialogResult result;
 
             if (!ProSupport.IsAnAdministrator())
@@ -858,11 +846,13 @@
             // Configuration completed
             ATSGlobals.configured = 1; // Indicate that configuration process is completed
             ATSGlobals.SetATSRegValue(ATSGlobals.strRegConfigured, ATSGlobals.configured); // Save to registry
+            Logging.ATSAdminLog.Debug("Leaving ConfigureATS()");
             return true;
         }
 
         void SetMode()
         {
+            Logging.ATSAdminLog.Debug("Entering SetMode()");
             if (ATSGlobals.managedMode == 1)
             { // We are running in managed mode, enable all controls related to client administration. 
                 lblClientProperties.Enabled = true;
@@ -954,6 +944,7 @@
                     Logging.ATSAdminLog.Error("Error, no mode selected (56541)");
                 }
             }
+            Logging.ATSAdminLog.Debug("Leaving SetMode()");
         }
 
         private void frmAdmin_Resize(object sender, EventArgs e)
@@ -990,6 +981,7 @@
         // Saves the computer name of the current computer, being the one running the admin tool into the database
         private void SaveMachineNameToDatabase()
         {
+            Logging.ATSAdminLog.Debug("Entering SaveMachineNameToDatabase()");
             string machineName = Environment.MachineName;
             atsDataSet datasetAppInfo;
             DataRow row;
@@ -1015,6 +1007,7 @@
             }
             // Save changes
             ProSupport.appInfoTableAdapter.Update(datasetAppInfo.AppInfo);
+            Logging.ATSAdminLog.Debug("Leaving SaveMachineNameToDatabase()");
         }
 
     } // FrmAdmin

 

  ViewVC Help
Powered by ViewVC 1.1.22