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

Diff of /trunk/TSAdminTool/ATSAmdin.Installer.cs

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

--- trunk/TSAdminTool/ATSAmdin.Installer.cs	2012/07/15 11:41:39	150
+++ trunk/TSAdminTool/ATSAmdin.Installer.cs	2012/07/15 13:01:23	152
@@ -5,6 +5,9 @@
 using System.Configuration.Install;
 using System.Linq;
 using System.Reflection;
+using System.Threading;
+using System.Windows.Forms;
+using System.Drawing;
 
 
 namespace AnywhereTS
@@ -12,37 +15,62 @@
     [RunInstaller(true)]
     public partial class ATSAmdin : System.Configuration.Install.Installer
     {
+        string DBServer;
+        string DBInstance;
         public ATSAmdin()
         {
             InitializeComponent();
         }
+        Exception install_ex = null;
+        DatabaseInstallerWaitDialog dlg;
+        public void InstallDatabaseWaitMessage()
+        {
+            dlg = new DatabaseInstallerWaitDialog("", string.Format(@"Please Wait... Installing database: {2} to {0}\{1}", DBServer, DBInstance, ATSGlobals.strDatabaseName));
+            dlg.ForeColor = Color.Black;
+            dlg.ShowDialog();            
+        }
 
         public override void Install(IDictionary stateSaver)
         {
             base.Install(stateSaver);
             try
             {
+                
                 string path = this.Context.Parameters["targetdir"];
                 Logging.UpdateLogPath(string.Format(@"{0}\logs", path));
                 using (log4net.NDC.Push("Logged from ATSAdmin.Installer"))
                 {
                     // setup database
-                    string DBServer = this.Context.Parameters["DBSERVER"];
-                    string DBInstance = this.Context.Parameters["DBINSTANCE"];
+                    DBServer = this.Context.Parameters["DBSERVER"];
+                    DBInstance = this.Context.Parameters["DBINSTANCE"];
                     // Log the entered data
                     Logging.ATSAdminInstallerLog.DebugFormat("Server={0} Instance={1}", DBServer, DBInstance);
                     CreateRegistryConfigKeys();
                     ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseServer, DBServer);
                     ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseInstance, DBInstance);
+                    ProSupport.strDatabaseServer = ATSGlobals.GetATSRegValueString(ProSupport.strRegDatabaseServer);
+                    ProSupport.strDatabaseInstance = ATSGlobals.GetATSRegValueString(ProSupport.strRegDatabaseInstance);
                     // install the database 
-
+                    Thread db_installer_thread = new Thread(new ThreadStart(InstallDatabaseWaitMessage));
+                    db_installer_thread.IsBackground = true;
+                    db_installer_thread.Start();
+                    Logging.ATSAdminInstallerLog.DebugFormat(@"Installing database: {2} to {0}\{1}", DBServer, DBInstance, ATSGlobals.strDatabaseName);
                     AnywhereTS.DatabaseSupport dbsup = new DatabaseSupport();
                     dbsup.SetupDatabase();
-
+                    dlg.Message = string.Format(@"Successfully installed the database: {2} to {0}\{1}", DBServer, DBInstance, ATSGlobals.strDatabaseName);
+                    dlg.ForeColor = Color.Green;
+                    Thread.Sleep(new TimeSpan(0,0,15));
+                    dlg.Close();
+                    Logging.ATSAdminInstallerLog.DebugFormat(@"Successfully Installed database: {2} to {0}\{1}", DBServer, DBInstance, ATSGlobals.strDatabaseName);
                 }
             }
             catch (Exception ex)
             {
+                Logging.ATSAdminInstallerLog.DebugFormat(@"Failed to Install database: {2} to {0}\{1}", DBServer, DBInstance, ATSGlobals.strDatabaseName);
+                dlg.Message = string.Format(@"Failed to install the database: {2} to {0}\{1}", DBServer, DBInstance, ATSGlobals.strDatabaseName);
+                dlg.ForeColor = Color.Red;
+                Thread.Sleep(new TimeSpan(0, 0, 15));
+                dlg.Close();
                 // database install failed
                 using (log4net.NDC.Push(string.Format("{0}: MESSAGE={1}{2}Diagnostics:{2}{3}", ex.GetType().Name, ex.Message, System.Environment.NewLine, ex.ToString())))
                 {
@@ -80,7 +108,7 @@
             }
             catch (Exception ex)
             {
-                using (log4net.NDC.Push(string.Format("{0}: MESSAGE={1}{2}Diagnostics:{2}{3}",ex.GetType().Name, ex.Message, System.Environment.NewLine, ex.ToString())))
+                using (log4net.NDC.Push(string.Format("{0}: MESSAGE={1}{2}Diagnostics:{2}{3}", ex.GetType().Name, ex.Message, System.Environment.NewLine, ex.ToString())))
                 {
                     Logging.ATSAdminInstallerLog.Error("CreateRegistryConfigKeys() failed.");
                 }

 

  ViewVC Help
Powered by ViewVC 1.1.22