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

Diff of /trunk/TSAdminTool/Globals.cs

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

--- trunk/TSAdminTool/Globals.cs	2012/07/11 14:19:13	4
+++ trunk/TSAdminTool/Globals.cs	2012/07/12 14:17:14	46
@@ -160,21 +160,42 @@
             {
                 objRegkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regKey);
             }
-            catch (ArgumentNullException)
+            catch (ArgumentNullException ex)
             {
                 MessageBox.Show("Error when reading from registry. Installation info missing, please run the " + ATSGlobals.ApplicationName + " installation program. (22411)");
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", ex.Message, System.Environment.NewLine, ex.ToString())))
+                {
+                    using (log4net.NDC.Push("Installation info missing."))
+                    {
+                        Logging.ATSAdminLog.Error("Error when reading from registry.");
+                    }
+                }
                 Application.Exit();
                 return "";
             }
-            catch (SecurityException e)
+            catch (SecurityException ex)
             {
-                MessageBox.Show("Error when reading from registry. You do not have the necessary permission (22412). Key: "+ regKey + " Value: " + regValue + " Error details:" + e.Message);
+                MessageBox.Show("Error when reading from registry. You do not have the necessary permission (22412). Key: "+ regKey + " Value: " + regValue + " Error details:" + ex.Message);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", ex.Message, System.Environment.NewLine, ex.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                        using (log4net.NDC.Push("Invalid users rights."))
+                        {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");
+                        }
+                    }
+                }
                 Application.Exit();
                 return "";
             }
-            catch (Exception e)
+            catch (Exception ex)
             {
-                MessageBox.Show("Error when reading from registry (22413). Key: " + regKey + " Value: " + regValue + " Error details:" + e.Message);
+                MessageBox.Show("Error when reading from registry (22413). Key: " + regKey + " Value: " + regValue + " Error details:" + ex.Message);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", ex.Message, System.Environment.NewLine, ex.ToString())))
+                {
+                    Logging.ATSAdminLog.Error("Error when reading from registry.");                   
+                }
                 Application.Exit();
                 return "";
             }
@@ -190,6 +211,10 @@
                     catch (Exception e)
                     {
                         MessageBox.Show("Error when reading from registry (22414). Key: " + regKey + " Value: " + regValue + " Error details:" + e.Message);
+                        using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                        {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");
+                        }
                         Application.Exit();
                         return "";
                     }
@@ -197,6 +222,13 @@
                 else
                 {
                     MessageBox.Show("Error when reading from registry (55222). Value missing. Key: " + regKey + " Value: " + regValue);
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                        using (log4net.NDC.Push("Value is missing"))
+                        {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");
+                        }
+                    }
                     Application.Exit();
                     return "";
                 }
@@ -204,6 +236,13 @@
             else
             {
                 MessageBox.Show("Error when reading from registry (55221). Key missing. Key: " + regKey + " Value: " + strRegTFTP_root);
+                using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                {
+                    using (log4net.NDC.Push("Key is missing"))
+                    {
+                        Logging.ATSAdminLog.Error("Error when reading from registry.");
+                    }
+                }
                 Application.Exit();
             }
             return ""; // No value could be retrieved from registry
@@ -218,21 +257,42 @@
             {
                 objRegkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regKey);
             }
-            catch (ArgumentNullException)
+            catch (ArgumentNullException ex)
             {
                 MessageBox.Show("Error when reading from registry. Installation info missing, please run the " + ATSGlobals.ApplicationName + " installation program. (22411)");
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", ex.Message, System.Environment.NewLine, ex.ToString())))
+                {
+                    using (log4net.NDC.Push("Installation info missing."))
+                    {
+                        Logging.ATSAdminLog.Error("Error when reading from registry.");
+                    }
+                }
                 Application.Exit();
                 return 0;
             }
             catch (SecurityException e)
             {
                 MessageBox.Show("Error when reading from registry. You do not have the necessary permission (22412). Key: " + regKey + " Value: " + regValue + " Error details:" + e.Message);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                        using (log4net.NDC.Push("Invalid user rights."))
+                        {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");
+                        }
+                    }
+                }
                 Application.Exit();
                 return 0;
             }
             catch (Exception e)
             {
                 MessageBox.Show("Error when reading from registry (22413). Key: " + regKey + " Value: " + regValue + " Error details:" + e.Message);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                        Logging.ATSAdminLog.Error("Error when reading from registry.");                  
+                }
                 Application.Exit();
                 return 0;
             }
@@ -248,6 +308,13 @@
                     catch (Exception e)
                     {
                         MessageBox.Show("Error when reading from registry (22414). Key: " + regKey + " Value: " + regValue + " Error details:" + e.Message);
+                        using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                        {
+                            using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                            {
+                                    Logging.ATSAdminLog.Error("Error when reading from registry.");                                
+                            }
+                        }
                         Application.Exit();
                         return 0;
                     }
@@ -255,6 +322,16 @@
                 else
                 {
                     MessageBox.Show("Error when reading from registry (55222). Value missing. Key: " + regKey + " Value: " + regValue);
+                    using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                    {
+                        using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                        {
+                            using (log4net.NDC.Push("Value is missing"))
+                            {
+                                Logging.ATSAdminLog.Error("Error when reading from registry.");
+                            }
+                        }
+                    }
                     Application.Exit();
                     return 0;
                 }
@@ -262,6 +339,16 @@
             else
             {
                 MessageBox.Show("Error when reading from registry (55221). Key missing. Key: " + regKey + " Value: " + regValue);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                        using (log4net.NDC.Push("Key is missing"))
+                        {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");
+                        }
+                    }
+                }
                 Application.Exit();
             }
             return 0; // No value could be retrieved from registry
@@ -276,21 +363,45 @@
             {
                 objRegkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regKey,true);
             }
-            catch (ArgumentNullException)
+            catch (ArgumentNullException e)
             {
                 MessageBox.Show("Error when writing to registry. Installation info missing, please run the " + ATSGlobals.ApplicationName + " installation program. (62411)");
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                        using (log4net.NDC.Push("Installation info missing"))
+                        {
+                            Logging.ATSAdminLog.Error("Error when writing to registry.");
+                        }                    
+                }
                 Application.Exit();
                 return;
             }
             catch (SecurityException e)
             {
                 MessageBox.Show("Error when writing to registry. You do not have the necessary permission (62412). Key: " + regKey + " Value: " + regValue + " Error details:" + e.Message);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                        using (log4net.NDC.Push("Invalid user rights"))
+                        {
+                            Logging.ATSAdminLog.Error("Error when writing to registry.");
+                        }
+                    }
+                }
                 Application.Exit();
                 return;
             }
             catch (Exception e)
             {
                 MessageBox.Show("Error when reading from registry (62413). Key: " + regKey + " Value: " + regValue + " Error details:" + e.Message);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");                        
+                    }
+                }
                 Application.Exit();
                 return;
             }
@@ -304,12 +415,28 @@
                 catch (Exception e)
                 {
                     MessageBox.Show("Error when writing to registry (62414). Key: " + regKey + " Value: " + regValue + " Error details:" + e.Message);
+                    using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                    {
+                        using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                        {
+                                Logging.ATSAdminLog.Error("Error when writing to registry.");                            
+                        }
+                    }
                     Application.Exit();
                 }
             }
             else
             {
                 MessageBox.Show("Error when writing to registry (65222). Key missing. Key: " + regKey + " Value: " + regValue);
+                
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                        using (log4net.NDC.Push("Key is missing"))
+                        {
+                            Logging.ATSAdminLog.Error("Error when writing to registry.");
+                        }                        
+                    }
+                
                 Application.Exit();
             }
         }
@@ -323,21 +450,45 @@
             {
                 objRegkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regKey, true);
             }
-            catch (ArgumentNullException)
+            catch (ArgumentNullException e)
             {
                 MessageBox.Show("Error when writing to registry. Installation info missing, please run the " + ATSGlobals.ApplicationName + " installation program. (62411)");
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                        Logging.ATSAdminLog.Error("Error when writing to registry.");
+                    }
+                }
                 Application.Exit();
                 return;
             }
             catch (SecurityException e)
             {
                 MessageBox.Show("Error when writing to registry. You do not have the necessary permission (62412). Key: " + regKey + " Value: " + regValue + " Error details:" + e.Message);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                        using (log4net.NDC.Push("Invalid user rights"))
+                        {
+                            Logging.ATSAdminLog.Error("Error when writing to registry.");
+                        }
+                    }
+                }
                 Application.Exit();
                 return;
             }
             catch (Exception e)
             {
                 MessageBox.Show("Error when reading from registry (62413). Key: " + regKey + " Value: " + regValue + " Error details:" + e.Message);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                        {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");
+                        }                   
+                }
                 Application.Exit();
                 return;
             }
@@ -351,12 +502,29 @@
                 catch (Exception e)
                 {
                     MessageBox.Show("Error when writing to registry (62414). Key: " + regKey + " Value: " + regValue + " Error details:" + e.Message);
+                    using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                    {
+                        using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                        {
+                                Logging.ATSAdminLog.Error("Error when writing to registry.");                           
+                        }
+                    }
                     Application.Exit();
                 }
             }
             else
             {
                 MessageBox.Show("Error when writing to registry (65222). Key missing. Key: " + regKey + " Value: " + regValue);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                        using (log4net.NDC.Push("Key is missing"))
+                        {
+                            Logging.ATSAdminLog.Error("Error when writing to registry.");
+                        }
+                    }
+                }
                 Application.Exit();
             }
         }
@@ -373,18 +541,45 @@
             catch (ArgumentNullException)
             {
                 MessageBox.Show("Error when reading from registry. Installation info missing, please run the " + ATSGlobals.ApplicationName + " installation program. (29411)");
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                        using (log4net.NDC.Push("Installation info missing"))
+                        {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");
+                        }
+                    }
+                }
                 Application.Exit();
                 return false;
             }
             catch (SecurityException e)
             {
                 MessageBox.Show("Error when reading from registry. You do not have the necessary permission (29412). Key: " + regKey + " Value: " + regValue + " Error details:" + e.Message);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                        using (log4net.NDC.Push("Invalid user rights"))
+                        {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");
+                        }
+                    }
+                }
                 Application.Exit();
                 return false;
             }
             catch (Exception e)
             {
                 MessageBox.Show("Error when reading from registry (29413). Key: " + regKey + " Value: " + regValue + " Error details:" + e.Message);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");                        
+                    }
+                }
                 Application.Exit();
                 return false;
             }
@@ -403,6 +598,16 @@
             else
             {
                 MessageBox.Show("Error when reading from registry (59221). Key missing. Key: " + regKey + " Value: " + strRegTFTP_root);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                        using (log4net.NDC.Push("Key is missing"))
+                        {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");
+                        }
+                    }
+                }
                 Application.Exit();
             }
             return false; // No value could be retrieved from registry
@@ -517,21 +722,49 @@
             {
                 objRegkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regKey);
             }
-            catch (ArgumentNullException)
+            catch (ArgumentNullException e)
             {
                 MessageBox.Show("Error when reading from registry. Installation info missing, please run the " + ATSGlobals.ApplicationName + " installation program. (92411)");
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                        using (log4net.NDC.Push("Installation info missing"))
+                        {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");
+                        }
+                    }
+                }
                 Application.Exit();
                 return;
             }
             catch (SecurityException e)
             {
                 MessageBox.Show("Error when reading from registry. You do not have the necessary permission (92412). Key: "+ regKey + " Value: " + regValue + " Error details:" + e.Message);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                        using (log4net.NDC.Push("Invalid user rights"))
+                        {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");
+                        }
+                    }
+                }
                 Application.Exit();
                 return;
             }
             catch (Exception e)
             {
                 MessageBox.Show("Error when reading from registry (92413). Key: " + regKey + " Value: " + regValue + " Error details:" + e.Message);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");
+                        
+                    }
+                }
                 Application.Exit();
                 return;
             }
@@ -546,6 +779,13 @@
             else
             {
                 MessageBox.Show("Error when reading from registry (95221). Key missing. Key: " + regKey + " Value: " + strRegTFTP_root);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");                        
+                    }
+                }
                 Application.Exit();
             }
         }
@@ -561,21 +801,48 @@
             {
                 objRegkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regKey);
             }
-            catch (ArgumentNullException)
+            catch (ArgumentNullException e)
             {
                 MessageBox.Show("Error when reading from registry. Installation info missing, please run the " + ATSGlobals.ApplicationName + " installation program. (92411)");
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                        using (log4net.NDC.Push("Installation info missing"))
+                        {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");
+                        }
+                    }
+                }
                 Application.Exit();
                 return;
             }
             catch (SecurityException e)
             {
                 MessageBox.Show("Error when reading from registry. You do not have the necessary permission (92412). Key: " + regKey + " Value: " + regValue + " Error details:" + e.Message);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                        using (log4net.NDC.Push("Invalid users rights"))
+                        {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");
+                        }
+                    }
+                }
                 Application.Exit();
                 return;
             }
             catch (Exception e)
             {
                 MessageBox.Show("Error when reading from registry (92413). Key: " + regKey + " Value: " + regValue + " Error details:" + e.Message);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");                        
+                    }
+                }
                 Application.Exit();
                 return;
             }
@@ -590,6 +857,13 @@
             else
             {
                 MessageBox.Show("Error when reading from registry (95221). Key missing. Key: " + regKey + " Value: " + strRegTFTP_root);
+                using (log4net.NDC.Push(string.Format("SqlException: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
+                {
+                    using (log4net.NDC.Push(string.Format("key={0} value={1}", regKey, regValue)))
+                    {
+                            Logging.ATSAdminLog.Error("Error when reading from registry.");                       
+                    }
+                }
                 Application.Exit();
             }
         }

 

  ViewVC Help
Powered by ViewVC 1.1.22