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

Diff of /trunk/TSAdminTool/ImageRuntimeConfig.cs

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

--- trunk/TSAdminTool/ImageRuntimeConfig.cs	2012/07/12 14:17:14	46
+++ trunk/TSAdminTool/ImageRuntimeConfig.cs	2012/07/14 02:35:50	93
@@ -5,7 +5,8 @@
 using System.IO;
 using System.Net;
 using System.Windows.Forms;
-
+using log4net;
+using System.Linq;
 namespace AnywhereTS
 {
     // An image config set for an ATSImage, AnywhereTS Image
@@ -142,7 +143,15 @@
                     ReadFromDatabase(row);
                 }
                 else
-                    throw new Exception("Error: Default record not written (27773).");
+                {
+                    string error = "Error: Default record not written (27773)";
+                    using (log4net.NDC.Push(string.Format("recordname={0}", ProSupport.DEFAULT_RECORD_MAC)))
+                    {
+                        Logging.ATSAdminLog.Error(error);
+                    }
+                    MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("recordname={0}", ProSupport.DEFAULT_RECORD_MAC)));
+                    return;
+                }
             }
         }
 
@@ -159,7 +168,13 @@
                     ScreenColorDepth = ATSScreenColorDepth.ATS24Bit;
                     break;
                 default:
-                    throw new Exception("Error: Invalid color depth: " + row["ScreenColorDepth"].ToString());
+                    string error = "Error: Invalid color depth";
+                    using (log4net.NDC.Push(string.Format("ScreenColorDepth={0}", row["ScreenColorDepth"].ToString())))
+                    {
+                        Logging.ATSAdminLog.Error(error);
+                    }
+                    MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("ScreenColorDepth={0}", row["ScreenColorDepth"].ToString())));
+                    return;
             }
 
             ServerName = row["ServerName"].ToString();
@@ -176,7 +191,16 @@
                 SessionType = ATSSessionType.ATSICA;
             else if (row["SessionType"].ToString() == "PNA")
                 SessionType = ATSSessionType.ATSPNA;
-            else throw new Exception("Data conversion error 44539");
+            else
+            {
+                string error = "Error: Data conversion error (44539)";
+                using (log4net.NDC.Push(string.Format("RawSessionType={0}", row["SessionType"].ToString())))
+                {
+                    Logging.ATSAdminLog.Error(error);
+                }
+                MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("RawSessionType={0}", row["SessionType"].ToString())));
+                return;
+            }
 
             ReconnectPrompt = (bool)row["ReconnectPrompt"];
             RedirectFloppy = (bool)row["RedirectFloppy"];
@@ -198,7 +222,15 @@
             else if (row["IcaProtocol"].ToString() == "HTTPonTCP")
                 ICAProtocol = ATSIcaProtocol.ATSHTTPOnTCP;
             else
-                throw new Exception("Unknown ICA protocol. Error 19732");
+            {
+                string error = "Error: Unknown ICA protocol. Error (19732)";
+                using (log4net.NDC.Push(string.Format("RawIcaProtocol={0}", row["IcaProtocol"].ToString())))
+                {
+                    Logging.ATSAdminLog.Error(error);
+                }
+                MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("RawIcaProtocol={0}", row["IcaProtocol"].ToString())));
+                return;
+            }
             ICAEncryption = row["IcaEncryption"].ToString();
 
             ICACompression = (bool)row["IcaCompression"];
@@ -210,7 +242,15 @@
             else if (row["IcaAudioQuality"].ToString() == "High")
                 IcaAudioQuality = ATSIcaAudioQuality.High;
             else
-                throw new Exception("Unknown ICA audio quality. Error 34732");
+            {
+                string error = "Error: Unknown ICA audio quality. Error (34732)";
+                using (log4net.NDC.Push(string.Format("RawIcaAudioQuality={0}", row["IcaAudioQuality"].ToString())))
+                {
+                    Logging.ATSAdminLog.Error(error);
+                }
+                MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("RawIcaAudioQuality={0}", row["IcaAudioQuality"].ToString())));
+                return;
+            }
 
             ICAServer = row["IcaServer"].ToString();
             ICAApplicationSet = row["IcaApplicationSet"].ToString();
@@ -244,7 +284,13 @@
                         UsbDrive = ATSUsbDrive.Many;
                         break;
                     default:
-                        throw new Exception("Error: Invalid USB Drive config:" + row["UsbDrive"].ToString());
+                        string error = "Error: Invalid USB Drive config";
+                        using (log4net.NDC.Push(string.Format("UsbDrive={0}", row["UsbDrive"].ToString())))
+                        {
+                            Logging.ATSAdminLog.Error(error);
+                        }
+                        MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("UsbDrive={0}", row["UsbDrive"].ToString())));
+                        return;
                 }
             }
             else
@@ -311,7 +357,13 @@
                     row["ScreenColorDepth"] = "24";
                     break;
                 default:
-                    throw new Exception("Data conversion error 76532");
+                    string error = "Error: Data conversion error (76532)";
+                    using (log4net.NDC.Push(string.Format("ScreenColorDepth={0}", ScreenColorDepth)))
+                    {
+                        Logging.ATSAdminLog.Error(error);
+                    }
+                    MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("ScreenColorDepth={0}", ScreenColorDepth)));
+                    return;
             }
             row["ServerName"] = ServerName;
             row["ServerDomain"] = ServerDomain;
@@ -333,7 +385,13 @@
                     row["SessionType"] = "PNA";
                     break;
                 default:
-                    throw new Exception("Data conversion error 44532");
+                    string error = "Error: Data conversion error (44532)";
+                    using (log4net.NDC.Push(string.Format("SessionType={0}", SessionType)))
+                    {
+                        Logging.ATSAdminLog.Error(error);
+                    }
+                    MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("SessionType={0}", SessionType)));
+                    return;
             }
             row["ReconnectPrompt"] = ReconnectPrompt;
             row["RedirectFloppy"] = RedirectFloppy;
@@ -356,7 +414,15 @@
             else if (ICAProtocol == ATSIcaProtocol.ATSHTTPOnTCP)
                 row["IcaProtocol"] = "HTTPonTCP";
             else
-                throw new Exception("Unknown ICA protocol. Error 19732");
+            {
+                string error = "Error: Unknown ICA protocol. Error (19732)";
+                using (log4net.NDC.Push(string.Format("IcaProtocol={0}", ICAProtocol)))
+                {
+                    Logging.ATSAdminLog.Error(error);
+                }
+                MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("IcaProtocol={0}", ICAProtocol)));
+                return;
+            }
 
             row["IcaEncryption"] = ICAEncryption;
             row["IcaCompression"] = ICACompression;
@@ -366,9 +432,17 @@
             else if (IcaAudioQuality == ATSIcaAudioQuality.Medium)
                 row["IcaAudioQuality"]= "Medium";
             else if (IcaAudioQuality == ATSIcaAudioQuality.High)
-                row["IcaAudioQuality"]= "High";
+                row["IcaAudioQuality"] = "High";
             else
-                throw new Exception("Unknown ICA audio quality. Error 39702");
+            {
+                string error = "Error: Unknown ICA audio quality. Error (39702)";
+                using (log4net.NDC.Push(string.Format("IcaAudioQuality={0}", IcaAudioQuality)))
+                {
+                    Logging.ATSAdminLog.Error(error);
+                }
+                MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("IcaAudioQuality={0}", IcaAudioQuality)));
+                return;
+            }
 
             row["IcaServer"] = ICAServer;
             row["IcaApplicationSet"] = ICAApplicationSet;
@@ -393,7 +467,13 @@
                     row["UsbDrive"] = 2;
                     break;
                 default:
-                    throw new Exception("Data conversion error 32244");
+                    string error = "Error: Data conversion error (32244)";
+                    using (log4net.NDC.Push(string.Format("UsbDrive={0}", UsbDrive)))
+                    {
+                        Logging.ATSAdminLog.Error(error);
+                    }
+                    MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("UsbDrive={0}", UsbDrive)));
+                    return;
             }
             row["UsbDrivename"] = UsbDriveName;
 
@@ -426,7 +506,15 @@
             else if (ScreenColorDepth == ATSScreenColorDepth.ATS24Bit)
                 writer.WriteLine("24");
             else
-                throw new Exception("Error: Unknown color depth 63342");
+            {
+                string error = "Error: Unknown color depth (63342)";
+                using (log4net.NDC.Push(string.Format("ScreenColorDepth={0}", ScreenColorDepth)))
+                {
+                    Logging.ATSAdminLog.Error(error);
+                }
+                MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("ScreenColorDepth={0}", ScreenColorDepth)));
+                return;
+            }
             if (UsbDrive == ATSUsbDrive.One)
                 writer.WriteLine(@"USB_STORAGE_MULTI=OFF");
             if (UsbDrive == ATSUsbDrive.Many)
@@ -488,7 +576,15 @@
                 writer.WriteLine("pnabrowse");
             }
             else
-                throw new Exception("Error: Unknown color depth 61132");
+            {
+                string error = "Error: Unknown SessionType (61132)";
+                using (log4net.NDC.Push(string.Format("SessionType={0}", SessionType)))
+                {
+                    Logging.ATSAdminLog.Error(error);
+                }
+                MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("SessionType={0}", SessionType)));
+                return;
+            }
 
             // Server
             if (ServerPort == -1)
@@ -521,7 +617,15 @@
                 else if (ScreenColorDepth == ATSScreenColorDepth.ATS24Bit)
                     writer.Write(" -a 24");
                 else
-                    throw new Exception("Error: Unknown color depth 63342");
+                {
+                    string error = "Error: Unknown ScreenColorDepth depth (63342)";
+                    using (log4net.NDC.Push(string.Format("ScreenColorDepth={0}", ScreenColorDepth)))
+                    {
+                        Logging.ATSAdminLog.Error(error);
+                    }
+                    MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("ScreenColorDepth={0}", ScreenColorDepth)));
+                    return;
+                }
             }
 
             // RDP sound
@@ -611,7 +715,15 @@
                 else if (ICAProtocol == ATSIcaProtocol.ATSHTTPOnTCP)
                     writer.WriteLine("ICA_BROWSER_PROTOCOL=HTTPonTCP");
                 else
-                    throw new Exception("Unknown ICA protocol Error: 34211");
+                {
+                    string error = "Error: Unknown ICA protocol Error: (34211)";
+                    using (log4net.NDC.Push(string.Format("ICAProtocol={0}", ICAProtocol)))
+                    {
+                        Logging.ATSAdminLog.Error(error);
+                    }
+                    MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("ICAProtocol={0}", ICAProtocol)));
+                    return;
+                }
 
                 writer.WriteLine("SESSION_0_ICA_SERVER=" + ServerName);
                 writer.WriteLine(@"ICA_ENCRYPTION=""" + ICAEncryption + @"""");
@@ -633,7 +745,15 @@
                 else if (IcaAudioQuality == ATSIcaAudioQuality.High)
                     writer.WriteLine("ICA_AUDIO_QUALITY=High");
                 else
-                    throw new Exception("Unknown ICA audio quality. Error 23165");
+                {
+                    string error = "Error: ICA audio quality. Error (23165)";
+                    using (log4net.NDC.Push(string.Format("IcaAudioQuality={0}", IcaAudioQuality)))
+                    {
+                        Logging.ATSAdminLog.Error(error);
+                    }
+                    MessageBox.Show(string.Format("{0} -> {1}", error, string.Format("IcaAudioQuality={0}", IcaAudioQuality)));
+                    return;
+                }
 
                 writer.WriteLine("ICA_PRINTER=OFF"); //tabort
                 writer.WriteLine("ICA_SEAMLESS_WINDOW=OFF"); //tabort
@@ -763,10 +883,14 @@
         // twointegers: String with resolution in the format '1024X768'
         // x: (out) The x resolution from the string
         // y: (out) The y resolution from the string
-
-        private void ExtractResolution(string twointegers, out int x, out int y)
+        private void ExtractResolution(string resolution, out int x, out int y)
         {
-            ATSGlobals.ExtractIntegers(twointegers, 'x', out x, out y);
+            x = -1;
+            y = -1;
+            int[] parsed = new int[0];
+            ATSGlobals.ExtractIntegers(resolution, 'x', out parsed);
+            x = parsed.First();
+            y = parsed.Last();
         }
 
     } // class

 

  ViewVC Help
Powered by ViewVC 1.1.22