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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 150 - (show annotations) (download)
Sun Jul 15 11:41:39 2012 UTC (9 years, 4 months ago) by william
File size: 3725 byte(s)
+ fix logging in installer

1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using System.ComponentModel;
5 using System.Configuration.Install;
6 using System.Linq;
7 using System.Reflection;
8
9
10 namespace AnywhereTS
11 {
12 [RunInstaller(true)]
13 public partial class ATSAmdin : System.Configuration.Install.Installer
14 {
15 public ATSAmdin()
16 {
17 InitializeComponent();
18 }
19
20 public override void Install(IDictionary stateSaver)
21 {
22 base.Install(stateSaver);
23 try
24 {
25 string path = this.Context.Parameters["targetdir"];
26 Logging.UpdateLogPath(string.Format(@"{0}\logs", path));
27 using (log4net.NDC.Push("Logged from ATSAdmin.Installer"))
28 {
29 // setup database
30 string DBServer = this.Context.Parameters["DBSERVER"];
31 string DBInstance = this.Context.Parameters["DBINSTANCE"];
32 // Log the entered data
33 Logging.ATSAdminInstallerLog.DebugFormat("Server={0} Instance={1}", DBServer, DBInstance);
34 CreateRegistryConfigKeys();
35 ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseServer, DBServer);
36 ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseInstance, DBInstance);
37 // install the database
38
39 AnywhereTS.DatabaseSupport dbsup = new DatabaseSupport();
40 dbsup.SetupDatabase();
41
42 }
43 }
44 catch (Exception ex)
45 {
46 // database install failed
47 using (log4net.NDC.Push(string.Format("{0}: MESSAGE={1}{2}Diagnostics:{2}{3}", ex.GetType().Name, ex.Message, System.Environment.NewLine, ex.ToString())))
48 {
49 Logging.ATSAdminInstallerLog.Error("Install() failed.");
50 }
51 throw ex;
52 }
53 }
54
55 private void CreateRegistryConfigKeys()
56 {
57 try
58 {
59 Microsoft.Win32.RegistryKey key = null;
60 if (IntPtr.Size == 8)
61 { // 64 bit OS
62 //string t = @"SOFTWARE\Wow6432Node\" + ATSGlobals.ApplicationName + @"\ts-config";
63 key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\", true);
64 key.CreateSubKey("TFTPD32").CreateSubKey("DHCP");
65 key = key.CreateSubKey(ATSGlobals.ApplicationName).CreateSubKey("ts-config");
66 }
67 else
68 { // 32 bit OS
69 //strATSregRoot = @"SOFTWARE\" + ATSGlobals.ApplicationName + @"\ts-config";
70 key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software", true);
71 key.CreateSubKey("TFTPD32").CreateSubKey("DHCP");
72 key = key.CreateSubKey(ATSGlobals.ApplicationName).CreateSubKey("ts-config");
73 }
74
75 // AdminVersion = 2
76 key.SetValue("AdminVersion", 2);
77 // RunFirstTime = 1
78 key.SetValue("RunFirstTime", 1);
79 ATSGlobals.CreateRegistryValues();
80 }
81 catch (Exception ex)
82 {
83 using (log4net.NDC.Push(string.Format("{0}: MESSAGE={1}{2}Diagnostics:{2}{3}",ex.GetType().Name, ex.Message, System.Environment.NewLine, ex.ToString())))
84 {
85 Logging.ATSAdminInstallerLog.Error("CreateRegistryConfigKeys() failed.");
86 }
87 }
88 }
89 }
90 }

  ViewVC Help
Powered by ViewVC 1.1.22