/[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 94 by william, Sat Jul 14 02:52:23 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()");
30          }          }  
   
         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");  
                 }  
             }  
         }  
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              UpdateControlsToReflectProgramVersion();              UpdateControlsToReflectProgramVersion();
37    
38              // Check if AnywhereTS is configured              // Check if AnywhereTS is configured
# Line 83  namespace AnywhereTS Line 60  namespace AnywhereTS
60              ATSImageDesigntimeConfig newConfig = new ATSImageDesigntimeConfig();              ATSImageDesigntimeConfig newConfig = new ATSImageDesigntimeConfig();
61              newConfig.ReadDefaultFromDatabase();              newConfig.ReadDefaultFromDatabase();
62              newConfig.WriteDefaultsToDatabase();              newConfig.WriteDefaultsToDatabase();
63                Logging.ATSAdminLog.Debug("Leaving frmAdmin_Load()");
64          } // form load          } // form load
65    
66          private void UpdateControlsToReflectProgramVersion()          private void UpdateControlsToReflectProgramVersion()
67          {          {
68                Logging.ATSAdminLog.Debug("Entering UpdateControlsToReflectProgramVersion()");
69              // Update the application to reflect the type of license and release              // Update the application to reflect the type of license and release
70              ATSGlobals.isPro = true;              ATSGlobals.isPro = true;
71              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 74  namespace AnywhereTS
74    
75              this.Text = ATSGlobals.ApplicationTitle; // Set name in window title              this.Text = ATSGlobals.ApplicationTitle; // Set name in window title
76              aboutToolStripMenuItem.Text = "About " + ATSGlobals.ApplicationTitle;              aboutToolStripMenuItem.Text = "About " + ATSGlobals.ApplicationTitle;
77                Logging.ATSAdminLog.Debug("Leaving UpdateControlsToReflectProgramVersion()");
78          }          }
79    
80          // Update database from terminal server sessions          // Update database from terminal server sessions
# Line 634  namespace AnywhereTS Line 614  namespace AnywhereTS
614                  }                  }
615                  else                  else
616                  {                  {
617                      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);
618                        using (log4net.NDC.Push(string.Format("MacAddress={0}", selectedClientMacAddress)))
619                        {
620                            Logging.ATSAdminLog.Error(error);
621                        }
622                        MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("MacAddress={0}", selectedClientMacAddress)));
623                        return;
624                  }                  }
625              }              }
626          }          }
# Line 763  namespace AnywhereTS Line 749  namespace AnywhereTS
749    
750    
751          // Configure AnywhereTS          // Configure AnywhereTS
752          // 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.        
753          private bool ConfigureATS()          private bool ConfigureATS()
754          {          {
755                Logging.ATSAdminLog.Debug("Entering ConfigureATS()");
756              DialogResult result;              DialogResult result;
757    
758              if (!ProSupport.IsAnAdministrator())              if (!ProSupport.IsAnAdministrator())
# Line 858  DisplayConfig: // Config services Line 845  DisplayConfig: // Config services
845              // Configuration completed              // Configuration completed
846              ATSGlobals.configured = 1; // Indicate that configuration process is completed              ATSGlobals.configured = 1; // Indicate that configuration process is completed
847              ATSGlobals.SetATSRegValue(ATSGlobals.strRegConfigured, ATSGlobals.configured); // Save to registry              ATSGlobals.SetATSRegValue(ATSGlobals.strRegConfigured, ATSGlobals.configured); // Save to registry
848                Logging.ATSAdminLog.Debug("Leaving ConfigureATS()");
849              return true;              return true;
850          }          }
851    
852          void SetMode()          void SetMode()
853          {          {
854                Logging.ATSAdminLog.Debug("Entering SetMode()");
855              if (ATSGlobals.managedMode == 1)              if (ATSGlobals.managedMode == 1)
856              { // 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.
857                  lblClientProperties.Enabled = true;                  lblClientProperties.Enabled = true;
# Line 954  If you want to register more terminal se Line 943  If you want to register more terminal se
943                      Logging.ATSAdminLog.Error("Error, no mode selected (56541)");                      Logging.ATSAdminLog.Error("Error, no mode selected (56541)");
944                  }                  }
945              }              }
946                Logging.ATSAdminLog.Debug("Leaving SetMode()");
947          }          }
948    
949          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 980  If you want to register more terminal se
980          // 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
981          private void SaveMachineNameToDatabase()          private void SaveMachineNameToDatabase()
982          {          {
983                Logging.ATSAdminLog.Debug("Entering SaveMachineNameToDatabase()");
984              string machineName = Environment.MachineName;              string machineName = Environment.MachineName;
985              atsDataSet datasetAppInfo;              atsDataSet datasetAppInfo;
986              DataRow row;              DataRow row;
# Line 1015  If you want to register more terminal se Line 1006  If you want to register more terminal se
1006              }              }
1007              // Save changes              // Save changes
1008              ProSupport.appInfoTableAdapter.Update(datasetAppInfo.AppInfo);              ProSupport.appInfoTableAdapter.Update(datasetAppInfo.AppInfo);
1009                Logging.ATSAdminLog.Debug("Leaving SaveMachineNameToDatabase()");
1010          }          }
1011    
1012      } // FrmAdmin      } // FrmAdmin

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

  ViewVC Help
Powered by ViewVC 1.1.22