/[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 09:15:41	148
+++ trunk/TSAdminTool/ATSAmdin.Installer.cs	2012/07/15 11:21:36	149
@@ -4,6 +4,7 @@
 using System.ComponentModel;
 using System.Configuration.Install;
 using System.Linq;
+using System.Reflection;
 
 
 namespace AnywhereTS
@@ -15,5 +16,65 @@
         {
             InitializeComponent();
         }
+
+        public override void Install(IDictionary stateSaver)
+        {
+            base.Install(stateSaver);
+            string path = this.Context.Parameters["targetdir"];
+            Logging.SetLogPath(path);
+            //// load files into app domain
+            //AssemblyName asm_log4net = Assembly.LoadFile(string.Format(@"{0}\log4net.dll", path)).GetName();
+            //AssemblyName asm_logging = Assembly.LoadFile(string.Format(@"{0}\AnywhereTS.Logging.dll", path)).GetName();
+            //AppDomain.CurrentDomain.Load(asm_log4net);
+            //AppDomain.CurrentDomain.Load(asm_logging);
+
+            using (log4net.NDC.Push("Logged from ATSAdmin.Installer"))
+            {                
+                // setup database
+                string DBServer = this.Context.Parameters["DBSERVER"];
+                string DBInstance = this.Context.Parameters["DBINSTANCE"];
+                // Log the entered data
+                Logging.ATSAdminLog.DebugFormat("Server={0} Instance={1}", DBServer, DBInstance);
+                CreateRegistryConfigKeys();               
+                ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseServer, DBServer);
+                ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseInstance, DBInstance);
+                // install the database 
+                try
+                {
+                    AnywhereTS.DatabaseSupport dbsup = new DatabaseSupport();
+                    dbsup.SetupDatabase();
+                }
+                catch (Exception ex)
+                {
+                    // database install failed
+                    throw ex;
+                }
+            }
+        }
+
+        private void CreateRegistryConfigKeys()
+        {
+            Microsoft.Win32.RegistryKey key =null;
+            if (IntPtr.Size == 8)
+            {   // 64 bit OS
+                //string t = @"SOFTWARE\Wow6432Node\" + ATSGlobals.ApplicationName + @"\ts-config";
+                key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\", true);
+                key.CreateSubKey("TFTPD32").CreateSubKey("DHCP");
+                key = key.CreateSubKey(ATSGlobals.ApplicationName).CreateSubKey("ts-config");             
+            }
+            else
+            {   // 32 bit OS
+                //strATSregRoot = @"SOFTWARE\" + ATSGlobals.ApplicationName + @"\ts-config";
+                key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software",true);
+                key.CreateSubKey("TFTPD32").CreateSubKey("DHCP");
+                key = key.CreateSubKey(ATSGlobals.ApplicationName).CreateSubKey("ts-config");
+            }
+
+            // AdminVersion = 2
+            key.SetValue("AdminVersion", 2);
+            // RunFirstTime = 1
+            key.SetValue("RunFirstTime", 1);
+            ATSGlobals.CreateRegistryValues();
+        }
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22