periodic commit

This commit is contained in:
S T Chan 2014-01-07 00:00:21 -05:00
parent 8604972520
commit ba10c1d0a6
2 changed files with 41 additions and 18 deletions

View File

@ -17,19 +17,26 @@ namespace PdfScribeInstallCustomAction
public class CustomActions
{
static readonly String traceSourceName = "PdfScribeInstaller";
[CustomAction]
public static ActionResult CheckIfPrinterNotInstalled(Session session)
{
ActionResult resultCode;
TextWriterTraceListener installTraceListener = new TextWriterTraceListener("C:\\testout.txt");
SessionLogWriterTraceListener installTraceListener = new SessionLogWriterTraceListener(session);
PdfScribeInstaller installer = new PdfScribeInstaller();
installer.AddTraceListener(installTraceListener);
if (installer.IsPdfScribePrinterInstalled())
resultCode = ActionResult.Success;
else
resultCode = ActionResult.Failure;
try
{
if (installer.IsPdfScribePrinterInstalled())
resultCode = ActionResult.Success;
else
resultCode = ActionResult.Failure;
}
finally
{
if (installTraceListener != null)
installTraceListener.Dispose();
}
return resultCode;
}
@ -64,23 +71,37 @@ namespace PdfScribeInstallCustomAction
}
finally
{
if (installTraceListener != null) installTraceListener.Dispose();
if (installTraceListener != null)
installTraceListener.Dispose();
}
return printerInstalled;
}
[CustomAction]
public static ActionResult UninstallPdfScribePrinter()
public static ActionResult UninstallPdfScribePrinter(Session session)
{
ActionResult printerUninstalled;
PdfScribeInstaller installer = new PdfScribeInstaller();
if (installer.UninstallPdfScribePrinter())
printerUninstalled = ActionResult.Success;
else
printerUninstalled = ActionResult.Failure;
SessionLogWriterTraceListener installTraceListener = new SessionLogWriterTraceListener(session);
installTraceListener.TraceOutputOptions = TraceOptions.DateTime;
PdfScribeInstaller installer = new PdfScribeInstaller();
installer.AddTraceListener(installTraceListener);
try
{
if (installer.UninstallPdfScribePrinter())
printerUninstalled = ActionResult.Success;
else
printerUninstalled = ActionResult.Failure;
installTraceListener.CloseAndWriteLog();
}
finally
{
if (installTraceListener != null)
installTraceListener.Dispose();
}
return printerUninstalled;
}
}

View File

@ -28,11 +28,12 @@ namespace PdfScribeInstallCustomAction
/// <summary>
/// Releases resources held by the listener -
/// Note will not automatically flush and write
/// trace data to the install session -
/// will not automatically flush and write
/// trace data to the install session log -
/// call CloseAndWriteLog() before disposing
/// to ensure data is written
/// </summary>
public void Dispose()
public new void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
@ -70,7 +71,7 @@ namespace PdfScribeInstallCustomAction
/// <summary>
/// Closes the listener and writes accumulated
/// trace data to the install session's log (Session.Log)
/// The listener will no longer be usable after calling
/// The listener should not be used after calling
/// this method, and should be disposed of.
/// </summary>
public void CloseAndWriteLog()
@ -79,7 +80,6 @@ namespace PdfScribeInstallCustomAction
this.installSession != null)
{
this.Flush();
this.Close();
if (this.listenerStream.Length > 0)
{
listenerStream.Position = 0;
@ -88,7 +88,9 @@ namespace PdfScribeInstallCustomAction
this.installSession.Log(listenerStreamReader.ReadToEnd());
}
}
this.Close();
this.Dispose();
this.installSession = null;
}
}
}