From ff7ccc7dab8f2db1bf1313d082711cde82aa7dde Mon Sep 17 00:00:00 2001 From: McMak Date: Fri, 8 May 2015 20:50:54 +0300 Subject: [PATCH] Added file logger and default values for usernames, passwords. --- .../Sources/Setup.WIXInstaller/Product.wxs | 14 +++-- .../Common/WiXLogFileListener.cs | 55 +++++++++++++++++++ .../WebsitePanel.WIXInstaller/CustomAction.cs | 28 ++++++++++ .../WebsitePanel.WIXInstaller.csproj | 1 + 4 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/WiXLogFileListener.cs diff --git a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs index 82eef886..866e0a79 100644 --- a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs +++ b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs @@ -452,6 +452,7 @@ 1 1 + Please wait while [ProductName] Installer configures IIS & ASP.NET, this may take a few minutes. Thanks! @@ -476,7 +477,7 @@ - + @@ -503,7 +504,7 @@ - + @@ -512,7 +513,7 @@ - + @@ -522,7 +523,7 @@ - + @@ -590,9 +591,10 @@ WSP_ROOT + - + @@ -610,8 +612,10 @@ + 1 + diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/WiXLogFileListener.cs b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/WiXLogFileListener.cs new file mode 100644 index 00000000..623505fa --- /dev/null +++ b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/WiXLogFileListener.cs @@ -0,0 +1,55 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Text; +using Microsoft.Deployment.WindowsInstaller; + +namespace WebsitePanel.WIXInstaller.Common +{ + public class WiXLogFileListener : TraceListener + { + public const uint FileFlushSize = 4096; + public const string DefaultLogFile = "WSPInstallation.log.txt"; + public static string LogFile { get; private set; } + private StringBuilder m_Ctx; + static WiXLogFileListener() + { + LogFile = Path.Combine(Path.GetTempPath() + DefaultLogFile); + } + public WiXLogFileListener(string LogFileName = DefaultLogFile) + : base("WiXLogFileListener") + { + m_Ctx = new StringBuilder(); + } + ~WiXLogFileListener() + { + Dispose(false); + } + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + Flush(true); + } + public override void Write(string Value) + { + m_Ctx.Append(Value); + Flush(); + } + public override void WriteLine(string Value) + { + m_Ctx.AppendLine(Value); + Flush(); + } + private void Flush(bool Force = false) + { + if(m_Ctx.Length >= FileFlushSize || Force) + { + using (var FileCtx = new StreamWriter(LogFile, true)) + { + FileCtx.Write(m_Ctx.ToString()); + } + m_Ctx.Clear(); + } + } + } +} diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs index 2f652068..726ded67 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs @@ -54,6 +54,32 @@ namespace WebsitePanel.WIXInstaller #region CustomActions [CustomAction] + public static ActionResult PreFillSettings(Session session) + { + PopUpDebugger(); + var Ctx = session; + Ctx.AttachToSetupLog(); + Log.WriteStart("PreFillSettings"); + TryApllyNewPassword(Ctx, "PI_SERVER_PASSWORD"); + TryApllyNewPassword(Ctx, "PI_ESERVER_PASSWORD"); + TryApllyNewPassword(Ctx, "PI_PORTAL_PASSWORD"); + TryApllyNewPassword(Ctx, "SERVER_ACCESS_PASSWORD"); + TryApllyNewPassword(Ctx, "SERVERADMIN_PASSWORD"); + Log.WriteEnd("PreFillSettings"); + return ActionResult.Success; + } + private static void TryApllyNewPassword(Session Ctx, string Id) + { + var Pass = Ctx[Id]; + if(string.IsNullOrWhiteSpace(Pass)) + { + Pass = Guid.NewGuid().ToString(); + Ctx[Id] = Pass; + Ctx[Id + "_CONFIRM"] = Pass; + Log.WriteInfo("New password was applied to " + Id); + } + } + [CustomAction] public static ActionResult InstallWebFeatures(Session session) { var Msg = string.Empty; @@ -406,6 +432,7 @@ namespace WebsitePanel.WIXInstaller [CustomAction] public static ActionResult FillIpListUI(Session session) { + PopUpDebugger(); var Ctrls = new[]{ new ComboBoxCtrl(session, "PI_SERVER_IP"), new ComboBoxCtrl(session, "PI_ESERVER_IP"), new ComboBoxCtrl(session, "PI_PORTAL_IP") }; @@ -758,6 +785,7 @@ namespace WebsitePanel.WIXInstaller { WiXSetup.InstallLogListener(new WiXLogListener(Ctx)); WiXSetup.InstallLogListener(new InMemoryStringLogListener("WIX CA IN MEMORY")); + WiXSetup.InstallLogListener(new WiXLogFileListener()); } } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/WebsitePanel.WIXInstaller.csproj b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/WebsitePanel.WIXInstaller.csproj index 59ae4596..1a4b44b7 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/WebsitePanel.WIXInstaller.csproj +++ b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/WebsitePanel.WIXInstaller.csproj @@ -63,6 +63,7 @@ +