Fix Logic to properly cleanup data when the processing of a foldout is complete

Removed Debug Output
This commit is contained in:
Rich 2015-03-26 18:11:23 +00:00
parent a367581307
commit 0b3ce5147b

View File

@ -235,7 +235,6 @@ namespace Volian.Print.Library
if (retstr == null) return null; if (retstr == null) return null;
BeforePageNumberPdf = retstr; BeforePageNumberPdf = retstr;
ProcedureInfo.RefreshPageNumTransitions(_MyItem as ProcedureInfo); ProcedureInfo.RefreshPageNumTransitions(_MyItem as ProcedureInfo);
MyContentByte = null;
_MyReaderHelper = new ReaderHelper(this); _MyReaderHelper = new ReaderHelper(this);
return Print(_MyItem as ProcedureInfo, pdfFolder, makePlacekeeper); return Print(_MyItem as ProcedureInfo, pdfFolder, makePlacekeeper);
} }
@ -289,13 +288,13 @@ namespace Volian.Print.Library
_WatermarkLayer.SetPrint("Watermark", true); _WatermarkLayer.SetPrint("Watermark", true);
} }
} }
private void CloseDocument(string fileName)
private void CloseDocument(PdfContentByte cb, string fileName)
{ {
int profileDepth = ProfileTimer.Push(">>>> CloseDocument"); int profileDepth = ProfileTimer.Push(">>>> CloseDocument");
try try
{ {
cb.PdfDocument.Close(); MyContentByte.PdfDocument.Close();
MyContentByte = null;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -314,7 +313,7 @@ namespace Volian.Print.Library
set set
{ {
_MyContentByte = value; _MyContentByte = value;
MyReaderHelper.LoadTree(MyItem); if(value != null)MyReaderHelper.LoadTree(MyItem);
} }
} }
public void NewPage() public void NewPage()
@ -328,11 +327,7 @@ namespace Volian.Print.Library
if (_MyHelper != null) if (_MyHelper != null)
{ {
SectionInfo currentSection = _MyHelper.MySection; SectionInfo currentSection = _MyHelper.MySection;
//if (currentSection.InList(79359)) Console.WriteLine("Here");
//currentSection = currentSection.ActiveParent as SectionInfo;
SectionInfo nextSection = GetNextSection(currentSection); // _MyHelper.MySection.NextItem as SectionInfo; SectionInfo nextSection = GetNextSection(currentSection); // _MyHelper.MySection.NextItem as SectionInfo;
//if (nextSection == null) Console.WriteLine("Here");
//if (nextSection != null && nextSection.InList(79359)) Console.WriteLine("Here");
SectionConfig sc = (nextSection ?? currentSection).MyConfig as SectionConfig; SectionConfig sc = (nextSection ?? currentSection).MyConfig as SectionConfig;
bool wordMargins = (sc != null && sc.Section_WordMargin == "Y"); bool wordMargins = (sc != null && sc.Section_WordMargin == "Y");
if (wordMargins) if (wordMargins)
@ -342,7 +337,7 @@ namespace Volian.Print.Library
LastWordSection = nextSection; LastWordSection = nextSection;
_PageCountOfWordSection = 1; _PageCountOfWordSection = 1;
MyReaderHelper.MySectionInfo = LastWordSection; MyReaderHelper.MySectionInfo = LastWordSection;
ShowNeedForPageSize(); //ShowNeedForPageSize();
rct = MyReaderHelper.GetSize(LastWordSection, 1); rct = MyReaderHelper.GetSize(LastWordSection, 1);
} }
else if (!currentSection.IsStepSection) //current section is a word section else if (!currentSection.IsStepSection) //current section is a word section
@ -355,7 +350,7 @@ namespace Volian.Print.Library
else else
_PageCountOfWordSection++; _PageCountOfWordSection++;
MyReaderHelper.MySectionInfo = LastWordSection; MyReaderHelper.MySectionInfo = LastWordSection;
ShowNeedForPageSize(); //ShowNeedForPageSize();
rct = MyReaderHelper.GetSize(LastWordSection, _PageCountOfWordSection); rct = MyReaderHelper.GetSize(LastWordSection, _PageCountOfWordSection);
} }
} }
@ -363,10 +358,10 @@ namespace Volian.Print.Library
{ {
rct = PageSize.LETTER; rct = PageSize.LETTER;
} }
Console.WriteLine("\"{0}\"\t\"{1}\"\t\"{2}\"\t\"{3}\"\t{4}" //Console.WriteLine("\"{0}\"\t\"{1}\"\t\"{2}\"\t\"{3}\"\t{4}"
, currentSection == null ? "" : currentSection.DisplayNumber + " " + currentSection.DisplayText // , currentSection == null ? "" : currentSection.DisplayNumber + " " + currentSection.DisplayText
, nextSection == null ? "" : nextSection.DisplayNumber + " " + nextSection.DisplayText // , nextSection == null ? "" : nextSection.DisplayNumber + " " + nextSection.DisplayText
, sectionChange, wordMargins,_PageCountOfWordSection); // , sectionChange, wordMargins,_PageCountOfWordSection);
} }
MyContentByte.PdfDocument.SetPageSize(rct); MyContentByte.PdfDocument.SetPageSize(rct);
MyContentByte.PdfDocument.NewPage(); MyContentByte.PdfDocument.NewPage();
@ -400,13 +395,13 @@ namespace Volian.Print.Library
} }
} }
private int _PageCountOfWordSection = 0; private int _PageCountOfWordSection = 0;
private void ShowNeedForPageSize() //private void ShowNeedForPageSize()
{ //{
if(PreviousWordSection != null && PreviousWordSection != LastWordSection) // if(PreviousWordSection != null && PreviousWordSection != LastWordSection)
Console.WriteLine("Switch From {0}.{1} ",PreviousWordSection.DisplayNumber,PreviousWordSection.DisplayText); // Console.WriteLine("Switch From {0}.{1} ",PreviousWordSection.DisplayNumber,PreviousWordSection.DisplayText);
Console.WriteLine("To {0}.{1} Page: {2}",LastWordSection.DisplayNumber,LastWordSection.DisplayText,_PageCountOfWordSection); // Console.WriteLine("To {0}.{1} Page: {2}",LastWordSection.DisplayNumber,LastWordSection.DisplayText,_PageCountOfWordSection);
PreviousWordSection = LastWordSection; // PreviousWordSection = LastWordSection;
} //}
private PdfContentByte OpenDoc(string outputFileName, iTextSharp.text.Rectangle rect) private PdfContentByte OpenDoc(string outputFileName, iTextSharp.text.Rectangle rect)
{ {
PdfWriter writer=null; PdfWriter writer=null;
@ -428,7 +423,7 @@ namespace Volian.Print.Library
sb.AppendLine("If it is open, close and retry."); sb.AppendLine("If it is open, close and retry.");
MessageBox.Show(sb.ToString(), "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show(sb.ToString(), "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning);
//MessageBox.Show("Could not create " + outputFileName + ". If it is open, close and retry.", "Error on CreatePdf"); //MessageBox.Show("Could not create " + outputFileName + ". If it is open, close and retry.", "Error on CreatePdf");
return null; return MyContentByte = null;
} }
document.Open(); document.Open();
// Create Layers // Create Layers
@ -443,7 +438,8 @@ namespace Volian.Print.Library
PrintOverride.ChangeBarColor = System.Drawing.Color.Red; PrintOverride.ChangeBarColor = System.Drawing.Color.Red;
PrintOverride.DebugColor = System.Drawing.Color.CadetBlue; PrintOverride.DebugColor = System.Drawing.Color.CadetBlue;
} }
return MyContentByte = writer.DirectContent; MyContentByte = writer.DirectContent;
return MyContentByte;
} }
//private string CreateFileName(string procNumber, string sectNumber, string sectTitle) //private string CreateFileName(string procNumber, string sectNumber, string sectTitle)
//{ //{
@ -771,7 +767,7 @@ namespace Volian.Print.Library
} }
OnStatusChanged(myProcedure.DisplayNumber + " PDF Creation Completed", PromsPrinterStatusType.Progress, progress); OnStatusChanged(myProcedure.DisplayNumber + " PDF Creation Completed", PromsPrinterStatusType.Progress, progress);
if (DebugPagination.IsOpen) DebugPagination.TotalPages += cb.PdfWriter.CurrentPageNumber; if (DebugPagination.IsOpen) DebugPagination.TotalPages += cb.PdfWriter.CurrentPageNumber;
CloseDocument(cb, outputFileName); CloseDocument(outputFileName);
if (_MyHelper != null && makePlacekeeper) if (_MyHelper != null && makePlacekeeper)
{ {
// Setting the default font to Arial since that is what Calvert is currently using for their Placekeeper pages // Setting the default font to Arial since that is what Calvert is currently using for their Placekeeper pages
@ -1608,7 +1604,8 @@ namespace Volian.Print.Library
} }
public void LoadTree(ItemInfo ii) public void LoadTree(ItemInfo ii)
{ {
if (dicPage.Count == 0) dicPage = new Dictionary<string, PdfImportedPage>();
dicSize = new Dictionary<string, iTextSharp.text.Rectangle>();
LoadSectionTree(ii); LoadSectionTree(ii);
} }
private void LoadSectionTree(ItemInfo ii) private void LoadSectionTree(ItemInfo ii)