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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 william 145 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 william 149 using System.Reflection;
8 william 145
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 william 149
20     public override void Install(IDictionary stateSaver)
21     {
22     base.Install(stateSaver);
23 william 150 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 william 149
39     AnywhereTS.DatabaseSupport dbsup = new DatabaseSupport();
40     dbsup.SetupDatabase();
41 william 150
42 william 149 }
43 william 150 }
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 william 149 {
49 william 150 Logging.ATSAdminInstallerLog.Error("Install() failed.");
50 william 149 }
51 william 150 throw ex;
52 william 149 }
53     }
54    
55     private void CreateRegistryConfigKeys()
56     {
57 william 150 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 william 149 }
81 william 150 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 william 149 }
88     }
89 william 145 }
90     }

  ViewVC Help
Powered by ViewVC 1.1.22