/[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

revision 57 by william, Thu Jul 12 16:47:17 2012 UTC revision 99 by william, Sat Jul 14 04:50:27 2012 UTC
# Line 9  namespace AnywhereTS Line 9  namespace AnywhereTS
9      using System.Windows.Forms;      using System.Windows.Forms;
10      using System.Runtime.InteropServices;      using System.Runtime.InteropServices;
11      using System.IO;      using System.IO;
12      using System.Data.SqlClient; // For File operations      using System.Data.SqlClient;
13        using System.Security.Permissions; // For File operations
14            
15    
16      public partial class frmAdmin : Form      public partial class frmAdmin : Form
# Line 23  namespace AnywhereTS Line 24  namespace AnywhereTS
24          private string selectedClientMacAddress; // The MAC address of the currently selected client.          private string selectedClientMacAddress; // The MAC address of the currently selected client.
25          public frmAdmin()          public frmAdmin()
26          {          {
27                Logging.ATSAdminLog.Debug("Entering frmAdmin .ctor()");
28              InitializeComponent();              InitializeComponent();
29              AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);              Logging.ATSAdminLog.Debug("Leaving frmAdmin .ctor()");
         }  
   
         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");  
                 }  
             }  
30          }          }
31    
32          private void frmAdmin_Load(object sender, EventArgs e)          private void frmAdmin_Load(object sender, EventArgs e)
33          {          {
34              this.Cursor = Cursors.WaitCursor;              //this.Cursor = Cursors.WaitCursor;
35                Logging.ATSAdminLog.Debug("Entering frmAdmin_Load()");
36    
37              UpdateControlsToReflectProgramVersion();              UpdateControlsToReflectProgramVersion();
38    
# Line 83  namespace AnywhereTS Line 61  namespace AnywhereTS
61              ATSImageDesigntimeConfig newConfig = new ATSImageDesigntimeConfig();              ATSImageDesigntimeConfig newConfig = new ATSImageDesigntimeConfig();
62              newConfig.ReadDefaultFromDatabase();              newConfig.ReadDefaultFromDatabase();
63              newConfig.WriteDefaultsToDatabase();              newConfig.WriteDefaultsToDatabase();
64                Logging.ATSAdminLog.Debug("Leaving frmAdmin_Load()");
65          } // form load          } // form load
66    
67          private void UpdateControlsToReflectProgramVersion()          private void UpdateControlsToReflectProgramVersion()
68          {          {
69                Logging.ATSAdminLog.Debug("Entering UpdateControlsToReflectProgramVersion()");
70              // Update the application to reflect the type of license and release              // Update the application to reflect the type of license and release
71              ATSGlobals.isPro = true;              ATSGlobals.isPro = true;
72              Globals.isPro = ATSGlobals.isPro; // Update program status for the VB part of the application.              Globals.isPro = ATSGlobals.isPro; // Update program status for the VB part of the application.
# Line 95  namespace AnywhereTS Line 75  namespace AnywhereTS
75    
76              this.Text = ATSGlobals.ApplicationTitle; // Set name in window title              this.Text = ATSGlobals.ApplicationTitle; // Set name in window title
77              aboutToolStripMenuItem.Text = "About " + ATSGlobals.ApplicationTitle;              aboutToolStripMenuItem.Text = "About " + ATSGlobals.ApplicationTitle;
78                Logging.ATSAdminLog.Debug("Leaving UpdateControlsToReflectProgramVersion()");
79          }          }
80    
81          // Update database from terminal server sessions          // Update database from terminal server sessions
# Line 634  namespace AnywhereTS Line 615  namespace AnywhereTS
615                  }                  }
616                  else                  else
617                  {                  {
618                      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);
619                        using (log4net.NDC.Push(string.Format("MacAddress={0}", selectedClientMacAddress)))
620                        {
621                            Logging.ATSAdminLog.Error(error);
622                        }
623                        MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("MacAddress={0}", selectedClientMacAddress)));
624                        return;
625                  }                  }
626              }              }
627          }          }
# Line 763  namespace AnywhereTS Line 750  namespace AnywhereTS
750    
751    
752          // Configure AnywhereTS          // Configure AnywhereTS
753          // 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.        
754          private bool ConfigureATS()          private bool ConfigureATS()
755          {          {
756                Logging.ATSAdminLog.Debug("Entering ConfigureATS()");
757              DialogResult result;              DialogResult result;
758    
759              if (!ProSupport.IsAnAdministrator())              if (!ProSupport.IsAnAdministrator())
# Line 858  DisplayConfig: // Config services Line 846  DisplayConfig: // Config services
846              // Configuration completed              // Configuration completed
847              ATSGlobals.configured = 1; // Indicate that configuration process is completed              ATSGlobals.configured = 1; // Indicate that configuration process is completed
848              ATSGlobals.SetATSRegValue(ATSGlobals.strRegConfigured, ATSGlobals.configured); // Save to registry              ATSGlobals.SetATSRegValue(ATSGlobals.strRegConfigured, ATSGlobals.configured); // Save to registry
849                Logging.ATSAdminLog.Debug("Leaving ConfigureATS()");
850              return true;              return true;
851          }          }
852    
853          void SetMode()          void SetMode()
854          {          {
855                Logging.ATSAdminLog.Debug("Entering SetMode()");
856              if (ATSGlobals.managedMode == 1)              if (ATSGlobals.managedMode == 1)
857              { // We are running in managed mode, enable all controls related to client administration.              { // We are running in managed mode, enable all controls related to client administration.
858                  lblClientProperties.Enabled = true;                  lblClientProperties.Enabled = true;
# Line 954  If you want to register more terminal se Line 944  If you want to register more terminal se
944                      Logging.ATSAdminLog.Error("Error, no mode selected (56541)");                      Logging.ATSAdminLog.Error("Error, no mode selected (56541)");
945                  }                  }
946              }              }
947                Logging.ATSAdminLog.Debug("Leaving SetMode()");
948          }          }
949    
950          private void frmAdmin_Resize(object sender, EventArgs e)          private void frmAdmin_Resize(object sender, EventArgs e)
# Line 990  If you want to register more terminal se Line 981  If you want to register more terminal se
981          // Saves the computer name of the current computer, being the one running the admin tool into the database          // Saves the computer name of the current computer, being the one running the admin tool into the database
982          private void SaveMachineNameToDatabase()          private void SaveMachineNameToDatabase()
983          {          {
984                Logging.ATSAdminLog.Debug("Entering SaveMachineNameToDatabase()");
985              string machineName = Environment.MachineName;              string machineName = Environment.MachineName;
986              atsDataSet datasetAppInfo;              atsDataSet datasetAppInfo;
987              DataRow row;              DataRow row;
# Line 1015  If you want to register more terminal se Line 1007  If you want to register more terminal se
1007              }              }
1008              // Save changes              // Save changes
1009              ProSupport.appInfoTableAdapter.Update(datasetAppInfo.AppInfo);              ProSupport.appInfoTableAdapter.Update(datasetAppInfo.AppInfo);
1010                Logging.ATSAdminLog.Debug("Leaving SaveMachineNameToDatabase()");
1011          }          }
1012    
1013      } // FrmAdmin      } // FrmAdmin

Legend:
Removed from v.57  
changed lines
  Added in v.99

  ViewVC Help
Powered by ViewVC 1.1.22