using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Configuration.Install; using System.Linq; using System.Reflection; namespace AnywhereTS { [RunInstaller(true)] public partial class ATSAmdin : System.Configuration.Install.Installer { public ATSAmdin() { InitializeComponent(); } 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"]; // Log the entered data Logging.ATSAdminInstallerLog.DebugFormat("Server={0} Instance={1}", DBServer, DBInstance); CreateRegistryConfigKeys(); ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseServer, DBServer); ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseInstance, DBInstance); // install the database AnywhereTS.DatabaseSupport dbsup = new DatabaseSupport(); dbsup.SetupDatabase(); } } catch (Exception ex) { // 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()))) { Logging.ATSAdminInstallerLog.Error("Install() failed."); } throw ex; } } private void CreateRegistryConfigKeys() { try { 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(); } 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()))) { Logging.ATSAdminInstallerLog.Error("CreateRegistryConfigKeys() failed."); } } } } }