Added info messages for Trace

This commit is contained in:
S T Chan 2013-12-30 21:49:37 -05:00
parent 8a7606a7c3
commit d4b652a22e

View File

@ -72,6 +72,7 @@ namespace PdfScribeCore
const string FILENOTDELETED_UNAUTHORIZED = "{0} is read-only, or its file permissions do not allow for deletion."; const string FILENOTDELETED_UNAUTHORIZED = "{0} is read-only, or its file permissions do not allow for deletion.";
const string FILENOTCOPIED_PRINTERDRIVER = "Printer driver file was not copied. Exception message: {0}"; const string FILENOTCOPIED_PRINTERDRIVER = "Printer driver file was not copied. Exception message: {0}";
const string FILENOTCOPIED_ALREADYEXISTS = "Destination file {0} was not copied/created - it already exists.";
const string WIN32ERROR = "Win32 error code {0}."; const string WIN32ERROR = "Win32 error code {0}.";
@ -83,6 +84,13 @@ namespace PdfScribeCore
const string REGISTRYCONFIG_NOT_ADDED = "Could not add port configuration to registry. Exception message: {0}"; const string REGISTRYCONFIG_NOT_ADDED = "Could not add port configuration to registry. Exception message: {0}";
const string REGISTRYCONFIG_NOT_DELETED = "Could not delete port configuration from registry. Exception message: {0}"; const string REGISTRYCONFIG_NOT_DELETED = "Could not delete port configuration from registry. Exception message: {0}";
const String INFO_INSTALLPORTMONITOR_FAILED = "Port monitor installation failed.";
const String INFO_INSTALLCOPYDRIVER_FAILED = "Could not copy printer driver files.";
const String INFO_INSTALLPORT_FAILED = "Could not add redirected port.";
const String INFO_INSTALLPRINTERDRIVER_FAILED = "Printer driver installation failed.";
const String INFO_INSTALLPRINTER_FAILED = "Could not add printer.";
const String INFO_INSTALLCONFIGPORT_FAILED = "Port configuration failed.";
#endregion #endregion
@ -490,6 +498,7 @@ namespace PdfScribeCore
bool printerInstalled = false; bool printerInstalled = false;
Stack<undoInstall> undoInstallActions = new Stack<undoInstall>(); Stack<undoInstall> undoInstallActions = new Stack<undoInstall>();
String driverDirectory = RetrievePrinterDriverDirectory(); String driverDirectory = RetrievePrinterDriverDirectory();
@ -512,34 +521,40 @@ namespace PdfScribeCore
if (ConfigurePdfScribePort()) if (ConfigurePdfScribePort())
printerInstalled = true; printerInstalled = true;
else else
{
// Failed to configure port // Failed to configure port
} this.logEventSource.TraceEvent(TraceEventType.Error,
(int)TraceEventType.Error,
INFO_INSTALLCONFIGPORT_FAILED);
} }
else else
{
// Failed to install printer // Failed to install printer
} this.logEventSource.TraceEvent(TraceEventType.Error,
(int)TraceEventType.Error,
INFO_INSTALLPRINTER_FAILED);
} }
else else
{
// Failed to install printer driver // Failed to install printer driver
} this.logEventSource.TraceEvent(TraceEventType.Error,
(int)TraceEventType.Error,
INFO_INSTALLPRINTERDRIVER_FAILED);
} }
else else
{
// Failed to add printer port // Failed to add printer port
} this.logEventSource.TraceEvent(TraceEventType.Error,
(int)TraceEventType.Error,
INFO_INSTALLPORT_FAILED);
} }
else else
{
//Failed to copy printer driver files //Failed to copy printer driver files
} this.logEventSource.TraceEvent(TraceEventType.Error,
(int)TraceEventType.Error,
INFO_INSTALLCOPYDRIVER_FAILED);
} }
else else
{
//Failed to add port monitor //Failed to add port monitor
} this.logEventSource.TraceEvent(TraceEventType.Error,
(int)TraceEventType.Error,
INFO_INSTALLPORTMONITOR_FAILED);
if (printerInstalled == false) if (printerInstalled == false)
{ {
// Printer installation failed - // Printer installation failed -
@ -575,20 +590,20 @@ namespace PdfScribeCore
/// <returns></returns> /// <returns></returns>
public bool UninstallPdfScribePrinter() public bool UninstallPdfScribePrinter()
{ {
bool printerUninstalled = true; bool printerUninstalledCleanly = true;
if (!DeletePdfScribePrinter()) if (!DeletePdfScribePrinter())
printerUninstalled = false; printerUninstalledCleanly = false;
if (!RemovePDFScribePrinterDriver()) if (!RemovePDFScribePrinterDriver())
printerUninstalled = false; printerUninstalledCleanly = false;
if (!DeletePdfScribePort()) if (!DeletePdfScribePort())
printerUninstalled = false; printerUninstalledCleanly = false;
if (!RemovePdfScribePortMonitor()) if (!RemovePdfScribePortMonitor())
printerUninstalled = false; printerUninstalledCleanly = false;
if (!RemovePdfScribePortConfig()) if (!RemovePdfScribePortConfig())
printerUninstalled = false; printerUninstalledCleanly = false;
DeletePdfScribePortMonitorDll(); DeletePdfScribePortMonitorDll();
return printerUninstalled; return printerUninstalledCleanly;
} }
private bool CopyPrinterDriverFiles(String driverSourceDirectory, private bool CopyPrinterDriverFiles(String driverSourceDirectory,
@ -628,6 +643,9 @@ namespace PdfScribeCore
{ {
// Just keep going - file was already there // Just keep going - file was already there
// Not really a problem // Not really a problem
logEventSource.TraceEvent(TraceEventType.Verbose,
(int)TraceEventType.Verbose,
String.Format(FILENOTCOPIED_ALREADYEXISTS, fileDestinationPath));
continue; continue;
} }
} }