Added file logger and default values for usernames, passwords.
This commit is contained in:
parent
b35dec4356
commit
ff7ccc7dab
4 changed files with 93 additions and 5 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
<Compile Include="Common\Tool.cs" />
|
||||
<Compile Include="Common\Prop.cs" />
|
||||
<Compile Include="Common\Util\IListCtrl.cs" />
|
||||
<Compile Include="Common\WiXLogFileListener.cs" />
|
||||
<Compile Include="Common\WiXLogListener.cs" />
|
||||
<Compile Include="Common\YesNo.cs" />
|
||||
<Compile Include="CustomAction.cs" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue