5 |
using System.Configuration.Install; |
using System.Configuration.Install; |
6 |
using System.Linq; |
using System.Linq; |
7 |
using System.Reflection; |
using System.Reflection; |
8 |
|
using System.Threading; |
9 |
|
using System.Windows.Forms; |
10 |
|
using System.Drawing; |
11 |
|
|
12 |
|
|
13 |
namespace AnywhereTS |
namespace AnywhereTS |
15 |
[RunInstaller(true)] |
[RunInstaller(true)] |
16 |
public partial class ATSAmdin : System.Configuration.Install.Installer |
public partial class ATSAmdin : System.Configuration.Install.Installer |
17 |
{ |
{ |
18 |
|
string DBServer; |
19 |
|
string DBInstance; |
20 |
public ATSAmdin() |
public ATSAmdin() |
21 |
{ |
{ |
22 |
InitializeComponent(); |
InitializeComponent(); |
23 |
} |
} |
24 |
|
Exception install_ex = null; |
25 |
|
DatabaseInstallerWaitDialog dlg; |
26 |
|
public void InstallDatabaseWaitMessage() |
27 |
|
{ |
28 |
|
dlg = new DatabaseInstallerWaitDialog("", string.Format(@"Please Wait... Installing database: {2} to {0}\{1}", DBServer, DBInstance, ATSGlobals.strDatabaseName)); |
29 |
|
dlg.ForeColor = Color.Black; |
30 |
|
dlg.ShowDialog(); |
31 |
|
} |
32 |
|
|
33 |
public override void Install(IDictionary stateSaver) |
public override void Install(IDictionary stateSaver) |
34 |
{ |
{ |
35 |
base.Install(stateSaver); |
base.Install(stateSaver); |
36 |
try |
try |
37 |
{ |
{ |
38 |
|
|
39 |
string path = this.Context.Parameters["targetdir"]; |
string path = this.Context.Parameters["targetdir"]; |
40 |
Logging.UpdateLogPath(string.Format(@"{0}\logs", path)); |
Logging.UpdateLogPath(string.Format(@"{0}\logs", path)); |
41 |
using (log4net.NDC.Push("Logged from ATSAdmin.Installer")) |
using (log4net.NDC.Push("Logged from ATSAdmin.Installer")) |
42 |
{ |
{ |
43 |
// setup database |
// setup database |
44 |
string DBServer = this.Context.Parameters["DBSERVER"]; |
DBServer = this.Context.Parameters["DBSERVER"]; |
45 |
string DBInstance = this.Context.Parameters["DBINSTANCE"]; |
DBInstance = this.Context.Parameters["DBINSTANCE"]; |
46 |
// Log the entered data |
// Log the entered data |
47 |
Logging.ATSAdminInstallerLog.DebugFormat("Server={0} Instance={1}", DBServer, DBInstance); |
Logging.ATSAdminInstallerLog.DebugFormat("Server={0} Instance={1}", DBServer, DBInstance); |
48 |
CreateRegistryConfigKeys(); |
CreateRegistryConfigKeys(); |
49 |
ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseServer, DBServer); |
ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseServer, DBServer); |
50 |
ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseInstance, DBInstance); |
ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseInstance, DBInstance); |
51 |
|
ProSupport.strDatabaseServer = ATSGlobals.GetATSRegValueString(ProSupport.strRegDatabaseServer); |
52 |
|
ProSupport.strDatabaseInstance = ATSGlobals.GetATSRegValueString(ProSupport.strRegDatabaseInstance); |
53 |
// install the database |
// install the database |
54 |
|
Thread db_installer_thread = new Thread(new ThreadStart(InstallDatabaseWaitMessage)); |
55 |
|
db_installer_thread.IsBackground = true; |
56 |
|
db_installer_thread.Start(); |
57 |
|
Logging.ATSAdminInstallerLog.DebugFormat(@"Installing database: {2} to {0}\{1}", DBServer, DBInstance, ATSGlobals.strDatabaseName); |
58 |
AnywhereTS.DatabaseSupport dbsup = new DatabaseSupport(); |
AnywhereTS.DatabaseSupport dbsup = new DatabaseSupport(); |
59 |
dbsup.SetupDatabase(); |
dbsup.SetupDatabase(); |
60 |
|
dlg.Message = string.Format(@"Successfully installed the database: {2} to {0}\{1}", DBServer, DBInstance, ATSGlobals.strDatabaseName); |
61 |
|
dlg.ForeColor = Color.Green; |
62 |
|
Thread.Sleep(new TimeSpan(0,0,15)); |
63 |
|
dlg.Close(); |
64 |
|
Logging.ATSAdminInstallerLog.DebugFormat(@"Successfully Installed database: {2} to {0}\{1}", DBServer, DBInstance, ATSGlobals.strDatabaseName); |
65 |
} |
} |
66 |
} |
} |
67 |
catch (Exception ex) |
catch (Exception ex) |
68 |
{ |
{ |
69 |
|
Logging.ATSAdminInstallerLog.DebugFormat(@"Failed to Install database: {2} to {0}\{1}", DBServer, DBInstance, ATSGlobals.strDatabaseName); |
70 |
|
dlg.Message = string.Format(@"Failed to install the database: {2} to {0}\{1}", DBServer, DBInstance, ATSGlobals.strDatabaseName); |
71 |
|
dlg.ForeColor = Color.Red; |
72 |
|
Thread.Sleep(new TimeSpan(0, 0, 15)); |
73 |
|
dlg.Close(); |
74 |
// database install failed |
// database install failed |
75 |
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()))) |
76 |
{ |
{ |
108 |
} |
} |
109 |
catch (Exception ex) |
catch (Exception ex) |
110 |
{ |
{ |
111 |
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()))) |
112 |
{ |
{ |
113 |
Logging.ATSAdminInstallerLog.Error("CreateRegistryConfigKeys() failed."); |
Logging.ATSAdminInstallerLog.Error("CreateRegistryConfigKeys() failed."); |
114 |
} |
} |