Custom action additions, slight refactoring

This commit is contained in:
S T Chan 2013-12-31 18:17:02 -05:00
parent d4b652a22e
commit 3fafd9d411
3 changed files with 48 additions and 7 deletions

View File

@ -493,7 +493,9 @@ namespace PdfScribeCore
/// <param name="driverFilesToCopy">An array containing the printer driver's filenames</param> /// <param name="driverFilesToCopy">An array containing the printer driver's filenames</param>
/// <param name="dependentFilesToCopy">An array containing dependent filenames</param> /// <param name="dependentFilesToCopy">An array containing dependent filenames</param>
/// <returns>true if installation suceeds, false if failed</returns> /// <returns>true if installation suceeds, false if failed</returns>
public bool InstallPdfScribePrinter(String driverSourceDirectory) public bool InstallPdfScribePrinter(String driverSourceDirectory,
String outputHandlerCommand,
String outputHandlerArguments)
{ {
bool printerInstalled = false; bool printerInstalled = false;
@ -518,7 +520,7 @@ namespace PdfScribeCore
if (AddPdfScribePrinter()) if (AddPdfScribePrinter())
{ {
undoInstallActions.Push(this.RemovePdfScribePortConfig); undoInstallActions.Push(this.RemovePdfScribePortConfig);
if (ConfigurePdfScribePort()) if (ConfigurePdfScribePort(outputHandlerCommand, outputHandlerArguments))
printerInstalled = true; printerInstalled = true;
else else
// Failed to configure port // Failed to configure port
@ -945,6 +947,8 @@ namespace PdfScribeCore
return ConfigurePdfScribePort(String.Empty, String.Empty); return ConfigurePdfScribePort(String.Empty, String.Empty);
} }
private bool ConfigurePdfScribePort(String commandValue, private bool ConfigurePdfScribePort(String commandValue,
String argumentsValue) String argumentsValue)
{ {

View File

@ -8,6 +8,10 @@ using PdfScribeCore;
namespace PdfScribeInstallCustomAction namespace PdfScribeInstallCustomAction
{ {
/// <summary>
/// Lotsa notes from here:
/// http://stackoverflow.com/questions/835624/how-do-i-pass-msiexec-properties-to-a-wix-c-sharp-custom-action
/// </summary>
public class CustomActions public class CustomActions
{ {
@ -18,15 +22,48 @@ namespace PdfScribeInstallCustomAction
PdfScribeInstaller installer = new PdfScribeInstaller(); PdfScribeInstaller installer = new PdfScribeInstaller();
if (installer.IsPdfScribePrinterInstalled()) if (installer.IsPdfScribePrinterInstalled())
{
resultCode = ActionResult.Success; resultCode = ActionResult.Success;
}
else else
{
resultCode = ActionResult.Failure; resultCode = ActionResult.Failure;
}
return resultCode; return resultCode;
} }
[CustomAction]
public static ActionResult InstallPdfScribePrinter(Session session)
{
ActionResult printerInstalled;
String driverSourceDirectory = session.CustomActionData["DriverSourceDirectory"];
String outputCommand = session.CustomActionData["OutputCommand"];
String outputCommandArguments = session.CustomActionData["OutputCommandArguments"];
PdfScribeInstaller installer = new PdfScribeInstaller();
if (installer.InstallPdfScribePrinter(driverSourceDirectory,
outputCommand,
outputCommandArguments))
printerInstalled = ActionResult.Success;
else
printerInstalled = ActionResult.Failure;
return printerInstalled;
}
[CustomAction]
public static ActionResult UninstallPdfScribePrinter()
{
ActionResult printerUninstalled;
PdfScribeInstaller installer = new PdfScribeInstaller();
if (installer.UninstallPdfScribePrinter())
printerUninstalled = ActionResult.Success;
else
printerUninstalled = ActionResult.Failure;
return printerUninstalled;
}
} }
} }

View File

@ -50,7 +50,7 @@ namespace PdfScribeUnitTests
public void Test_InstallPdfScribePrinter() public void Test_InstallPdfScribePrinter()
{ {
var scribeInstaller = new PdfScribeInstaller(); var scribeInstaller = new PdfScribeInstaller();
scribeInstaller.InstallPdfScribePrinter(@"C:\Code\PdfScribe\Lib\"); scribeInstaller.InstallPdfScribePrinter(@"C:\Code\PdfScribe\Lib\", String.Empty, String.Empty);
} }
//[Test] //[Test]