From 5a5502d8fc10418dac3bf34c5d940bbdb46cdcd2 Mon Sep 17 00:00:00 2001 From: Rich Date: Mon, 16 Feb 2015 20:51:34 +0000 Subject: [PATCH] Added somecode so that profile errors will be recordedd to the Error Log Added a reference to Log4Net Fixed Profile Logic when PDF cannot be created because it is already open. --- PROMS/Volian.Base.Library/VlnTimer.cs | 3 ++- PROMS/Volian.Print.Library/PromsPrinter.cs | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/PROMS/Volian.Base.Library/VlnTimer.cs b/PROMS/Volian.Base.Library/VlnTimer.cs index 4a42afa8..bfdd5e19 100644 --- a/PROMS/Volian.Base.Library/VlnTimer.cs +++ b/PROMS/Volian.Base.Library/VlnTimer.cs @@ -54,6 +54,7 @@ namespace Volian.Base.Library } public static class ProfileTimer { + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static Stack _MyStack = new Stack(); public static Stack MyStack @@ -93,7 +94,7 @@ namespace Volian.Base.Library private static int DoPop(int depth) { if (MyStack.Count != depth) - Console.WriteLine("Profile Stack Issues {0}", Start); + _MyLog.WarnFormat("Profile Stack Issues\r\n {0}, Depth is {1}, Depth should be {2}", Start,MyStack.Count,depth); Start = MyStack.Pop(); return MyStack.Count; } diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index 2e204ae9..cbd6b151 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -438,7 +438,11 @@ namespace Volian.Print.Library // Setup a pdf Document for printing OnStatusChanged("Before OpenDoc", PromsPrinterStatusType.Before); PdfContentByte cb = OpenDoc(outputFileName); - if (cb == null) return null; + if (cb == null) + { + ProfileTimer.Pop(profileDepth); + return null; + } OnStatusChanged("Before NewPage", PromsPrinterStatusType.Before); cb.PdfDocument.NewPage(); // Start of print //_MyLog.InfoFormat("NewPage 1 {0}", cb.PdfWriter.CurrentPageNumber); @@ -446,6 +450,7 @@ namespace Volian.Print.Library if (myProcedure.Sections == null) { MessageBox.Show("This procedure has no content and will not be printed.", "Empty Procedure", MessageBoxButtons.OK, MessageBoxIcon.Information); + ProfileTimer.Pop(profileDepth); return null; } OnStatusChanged(myProcedure.DisplayNumber, PromsPrinterStatusType.ProgressSetup, myProcedure.Sections.Count);