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

Diff of /trunk/TSAdminTool/ProSupport.cs

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

revision 16 by william, Wed Jul 11 16:36:27 2012 UTC revision 91 by william, Sat Jul 14 00:36:23 2012 UTC
# Line 11  using System.Security.Principal; Line 11  using System.Security.Principal;
11  using System.IO;  using System.IO;
12  using System.Management;  using System.Management;
13  using System.Net;  using System.Net;
14    using log4net;
15    
16  // Support class for the AnywhereTS version. This file should only be included in the Pro version.  // Support class for the AnywhereTS version. This file should only be included in the Pro version.
17  namespace AnywhereTS  namespace AnywhereTS
# Line 26  namespace AnywhereTS Line 27  namespace AnywhereTS
27          // Registry keys          // Registry keys
28          public const string strRegTFTP_root = "TFTP_root"; // Reg key for TFTP root directory in database          public const string strRegTFTP_root = "TFTP_root"; // Reg key for TFTP root directory in database
29          public const string strRegDatabaseDir = "DatabaseDir"; // Reg key for database directory          public const string strRegDatabaseDir = "DatabaseDir"; // Reg key for database directory
30          public const string strRegDatabaseServer = "DatabaseServer"; // Reg key for database server          public const string strRegDatabaseServer = "AnywhereTSServer"; // Reg key for database server
31          public const string strRegDestDir = "DestDir"; // Reg key for Destination directory, used in unmanged mode..          public const string strRegDestDir = "DestDir"; // Reg key for Destination directory, used in unmanged mode..
32                    
33          // Database constants          // Database constants
# Line 38  namespace AnywhereTS Line 39  namespace AnywhereTS
39          public static atsDataSetTableAdapters.TerminalServerTableAdapter terminalServerTableAdapter; // The AnywhereTS application data adapter for the terminal servers table. Only this adapter should be used.          public static atsDataSetTableAdapters.TerminalServerTableAdapter terminalServerTableAdapter; // The AnywhereTS application data adapter for the terminal servers table. Only this adapter should be used.
40          public static atsDataSetTableAdapters.AppInfoTableAdapter appInfoTableAdapter; // The AnywhereTS application data adapter for the AppInfo table. Only this adapter should be used.          public static atsDataSetTableAdapters.AppInfoTableAdapter appInfoTableAdapter; // The AnywhereTS application data adapter for the AppInfo table. Only this adapter should be used.
41    
42          public static string strDatabaseServer; // If this computer does not contain the database server, this is the name of the database server that contains the ATS database. Used by the Control Panel          public static string strAnywhereTSServer; // If this computer does not contain the database server, this is the name of the database server that contains the ATS database. Used by the Control Panel
43                    
44          // Directories          // Directories
45          public static string strDatabasePath; // The directory where the database file is located.          public static string strDatabasePath; // The directory where the database file is located.
# Line 50  namespace AnywhereTS Line 51  namespace AnywhereTS
51              // Initiate variables from registry              // Initiate variables from registry
52              strDatabasePath = ATSGlobals.GetATSRegValueString(strRegDatabaseDir);              strDatabasePath = ATSGlobals.GetATSRegValueString(strRegDatabaseDir);
53              strDestDir = ATSGlobals.GetATSRegValueString(strRegDestDir);              strDestDir = ATSGlobals.GetATSRegValueString(strRegDestDir);
54              strDatabaseServer = ATSGlobals.GetATSRegValueString(strRegDatabaseServer);              strAnywhereTSServer = ATSGlobals.GetATSRegValueString(strRegDatabaseServer);
55          }          }
56    
57          // Loook up local IP for computer          // Loook up local IP for computer
# Line 148  namespace AnywhereTS Line 149  namespace AnywhereTS
149          }          }
150    
151          // Adds an ACL entry for RW access on the specified file for Remote desktop users.          // Adds an ACL entry for RW access on the specified file for Remote desktop users.
152            [Obsolete("GrantRWaccessForRemoteDesktopUsers has been deprecated - define user access rights via SQL Server")]
153          public static void GrantRWaccessForRemoteDesktopUsers(string fileName)          public static void GrantRWaccessForRemoteDesktopUsers(string fileName)
154          {          {
155              // Get a FileSecurity object that represents the current security settings.              // Get a FileSecurity object that represents the current security settings.
# Line 163  namespace AnywhereTS Line 165  namespace AnywhereTS
165          }          }
166    
167          // Adds an ACL entry for ReadWriteModify access on the specified file for Remote desktop users.          // Adds an ACL entry for ReadWriteModify access on the specified file for Remote desktop users.
168            [Obsolete("GrantRWMaccessForRemoteDesktopUsers has been deprecated - define user access rights via SQL Server")]
169          public static void GrantRWMaccessForRemoteDesktopUsers(string fileName)          public static void GrantRWMaccessForRemoteDesktopUsers(string fileName)
170          {          {
171              // Get a FileSecurity object that represents the current security settings.              // Get a FileSecurity object that represents the current security settings.
# Line 180  namespace AnywhereTS Line 183  namespace AnywhereTS
183    
184          // (obsolete)          // (obsolete)
185          // Adds an ACL entry for to deny modify access on the specified file for all users.          // Adds an ACL entry for to deny modify access on the specified file for all users.
186            [Obsolete("DenyAccessRightModifyForUsers has been deprecated - define user access rights via SQL Server")]
187          public static void DenyAccessRightModifyForUsers(string fileName)          public static void DenyAccessRightModifyForUsers(string fileName)
188          {          {
189              // Get a FileSecurity object that represents the current security settings.              // Get a FileSecurity object that represents the current security settings.
# Line 223  namespace AnywhereTS Line 227  namespace AnywhereTS
227                  }                  }
228              }              }
229              else              else
230                  throw new Exception("Unknown TFTP mode 28158");              {
231                    string error = "Error: Unknown TFTP Config mode (28158)";
232                    using (log4net.NDC.Push(string.Format("tftpConfig={0}", ATSGlobals.tftpConfig)))
233                    {
234                        Logging.ATSAdminLog.Error(error);
235                    }
236                    MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("tftpConfig={0}", ATSGlobals.tftpConfig)));
237                    return;
238                }
239          }          }
240    
241          // Copy image file to all external tftp directories/servers          // Copy image file to all external tftp directories/servers
# Line 245  namespace AnywhereTS Line 257  namespace AnywhereTS
257                  catch (Exception e)                  catch (Exception e)
258                  {                  {
259                      MessageBox.Show("Could not update TFTP server '" + GetTftpPath(row) + "' (22181). Error: " + e.Message);                      MessageBox.Show("Could not update TFTP server '" + GetTftpPath(row) + "' (22181). Error: " + e.Message);
260                        using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
261                        {
262                            using (log4net.NDC.Push(string.Format("tftpPath={0}", GetTftpPath(row))))
263                            {
264                                Logging.ATSAdminLog.Error("Could not update TFTP server");
265                            }
266                        }
267                  }                  }
268                            
269                  // Try to set rights for image the image file                  // Try to set rights for image the image file
# Line 280  namespace AnywhereTS Line 299  namespace AnywhereTS
299                  catch (Exception e)                  catch (Exception e)
300                  {                  {
301                      MessageBox.Show("Could not update TFTP server '" + GetTftpPath(row) + "' (22381). Error: " + e.Message);                      MessageBox.Show("Could not update TFTP server '" + GetTftpPath(row) + "' (22381). Error: " + e.Message);
302                        using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
303                        {
304                            using (log4net.NDC.Push(string.Format("tftpPath={0}", GetTftpPath(row))))
305                            {
306                                Logging.ATSAdminLog.Error("Could not update TFTP server");
307                            }
308                        }
309                  }                  }
310              }              }
311          }          }
# Line 299  namespace AnywhereTS Line 325  namespace AnywhereTS
325                  catch (Exception ex)                  catch (Exception ex)
326                  {                  {
327                      MessageBox.Show("Cannot set access rights for client configuration. Application will abort. Error: " + ex.Message);                      MessageBox.Show("Cannot set access rights for client configuration. Application will abort. Error: " + ex.Message);
328                        using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", ex.Message, System.Environment.NewLine, ex.ToString())))
329                        {
330                            Logging.ATSAdminLog.Error("Cannot set access rights for client configuration");
331                        }
332                      Application.Exit();                      Application.Exit();
333                      return;                      return;
334                  }                  }
# Line 325  namespace AnywhereTS Line 355  namespace AnywhereTS
355                  }                  }
356              }              }
357              else              else
358                  throw new Exception("Unknown TFTP mode 48158");              {
359                    string error = "Error: Unknown TFTP Config mode (48158)";
360                    using (log4net.NDC.Push(string.Format("tftpConfig={0}", ATSGlobals.tftpConfig)))
361                    {
362                        Logging.ATSAdminLog.Error(error);
363                    }
364                    MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("tftpConfig={0}", ATSGlobals.tftpConfig)));
365                    return;
366                }
367          }          }
368    
369    
# Line 361  namespace AnywhereTS Line 399  namespace AnywhereTS
399              {              {
400                  //improve autoretry                  //improve autoretry
401                  MessageBox.Show("Error: Could not write configuration data to disk. Possibly the data is being accessed by another component right now or you do not have the sufficient rights. Please retry this operation later (52044). Error details: " + e.Message);                  MessageBox.Show("Error: Could not write configuration data to disk. Possibly the data is being accessed by another component right now or you do not have the sufficient rights. Please retry this operation later (52044). Error details: " + e.Message);
402                    using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
403                    {
404                        using (log4net.NDC.Push(string.Format("path={0}", path)))
405                        {
406                            Logging.ATSAdminLog.Error("Could not write configuration data to disk");
407                        }
408                    }
409              }              }
410    
411              finally              finally
# Line 436  namespace AnywhereTS Line 481  namespace AnywhereTS
481                  }                  }
482              }              }
483              else              else
484                  throw new Exception("Unknown TFTP mode 88158");              {
485                    string error = "Error: Unknown TFTP Config mode (88158)";
486                    using (log4net.NDC.Push(string.Format("tftpConfig={0}", ATSGlobals.tftpConfig)))
487                    {
488                        Logging.ATSAdminLog.Error(error);
489                    }
490                    MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("tftpConfig={0}", ATSGlobals.tftpConfig)));
491                    return;
492                }
493    
494              WriteHostsFiles();              WriteHostsFiles();
495              ATSImageRuntimeConfig currentConfig = new ATSImageRuntimeConfig();              ATSImageRuntimeConfig currentConfig = new ATSImageRuntimeConfig();

Legend:
Removed from v.16  
changed lines
  Added in v.91

  ViewVC Help
Powered by ViewVC 1.1.22