diff --git a/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs b/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs index 9666486d..601d069b 100644 --- a/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs +++ b/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs @@ -569,7 +569,7 @@ namespace VEPROMS // RHM 20120925 Overlay the bottom of the dialog so that cancel button is covered. frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, pw.ToString(), cbxDebug.Checked, cbxOrPgBrk.Checked, cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked, myPDFPath, cbd, txbPDFName.Text, new Point(Left, Bottom - 50), - swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value);//C2018-009 print PROMS version + swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, true);//C2018-009 print PROMS version frmStatus.CloseWhenDone = true; Application.DoEvents(); frmStatus.CancelStop = true; @@ -595,7 +595,7 @@ namespace VEPROMS // B2016-249 Output Procedure to folder associated with Parent Child frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, pw.ToString(), cbxDebug.Checked, cbxOrPgBrk.Checked, cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked, GetMultiunitPDFPath(), cbd, txbPDFName.Text, new Point(Left, Bottom - 50), - swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value);//C2018-009 print PROMS version + swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, true);//C2018-009 print PROMS version frmStatus.CloseWhenDone = true; Application.DoEvents(); frmStatus.CancelStop = true; @@ -624,7 +624,7 @@ namespace VEPROMS // B2016-249 Output Procedure to folder associated with Parent Child frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, pw.ToString(), cbxDebug.Checked, cbxOrPgBrk.Checked, cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked, GetMultiunitPDFPath(), cbd, txbPDFName.Text, - new Point(Left, Bottom - 50), swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value);//C2018-009 print PROMS version + new Point(Left, Bottom - 50), swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, true);//C2018-009 print PROMS version frmStatus.CloseWhenDone = true; Application.DoEvents(); frmStatus.CancelStop = true; @@ -721,7 +721,7 @@ namespace VEPROMS // B2016-249 Output Procedure to folder associated with Parent Child frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, pw.ToString(), cbxDebug.Checked, cbxOrPgBrk.Checked, cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked, GetMultiunitPDFPath(), cbd, txbPDFName.Text, new Point(Left, Bottom - 50), - swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic,Prefix,SaveLinks,RemoveTrailingHardReturnsAndManualPageBreaks,swtbtnPROMSVersion.Value); //C2018-009 print PROMS version + swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic,Prefix,SaveLinks,RemoveTrailingHardReturnsAndManualPageBreaks,swtbtnPROMSVersion.Value, false); //C2018-009 print PROMS version frmStatus.MakePlaceKeeper = swtbtnGeneratePlacekeeper.Value; frmStatus.MakeContinuousActionSummary = cbxGenerateConActSum.Checked; if (Automatic && cbxGenerateConActSum.Checked) diff --git a/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs b/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs index 872d6c6e..bc05cd67 100644 --- a/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs +++ b/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs @@ -1134,7 +1134,7 @@ namespace VEPROMS //ProcedureInfo myproc = pi; //frmPDFStatusForm frm = new frmPDFStatusForm(myproc, ap.RevNumber, /* revdate change: ap.RevDate.ToString("MM/dd/yyyy") ,*/ waterMark, false, false, ViewPDF, true, VlnSettings.TemporaryFolder, new ChangeBarDefinition(pi.MyDocVersion.MyConfig as DocVersionConfig, pi.ActiveFormat), pdfTmp, location); //myproc.ChangeBarDate = myDTS; - frmPDFStatusForm frm = new frmPDFStatusForm(pi, ap.RevNumAndDate, /* revdate change: ap.RevDate.ToString("MM/dd/yyyy") ,*/ waterMark, false, false, ViewPDF, true, VlnSettings.TemporaryFolder, new ChangeBarDefinition(pi.MyDocVersion.MyConfig as DocVersionConfig, pi.ActiveFormat), pdfTmp, location, pi.MyDocVersion.DocVersionConfig.Print_AddBlankPagesWhenUsingDuplexFoldouts, true,"",false,false,false); + frmPDFStatusForm frm = new frmPDFStatusForm(pi, ap.RevNumAndDate, /* revdate change: ap.RevDate.ToString("MM/dd/yyyy") ,*/ waterMark, false, false, ViewPDF, true, VlnSettings.TemporaryFolder, new ChangeBarDefinition(pi.MyDocVersion.MyConfig as DocVersionConfig, pi.ActiveFormat), pdfTmp, location, pi.MyDocVersion.DocVersionConfig.Print_AddBlankPagesWhenUsingDuplexFoldouts, true,"",false,false,false,MyProcedures.Count > (MyProcedures[0].ProcInfo.MyDocVersion.Procedures.Count/4)); frm.AllowAllWatermarks = true; frm.CloseWhenDone = !ViewPDF; frm.DocReplace = new Dictionary(); // will hold the Word Attachments with resolved ROs diff --git a/PROMS/VEPROMS User Interface/frmPDFStatusForm.cs b/PROMS/VEPROMS User Interface/frmPDFStatusForm.cs index 0fc95fe9..da35d707 100644 --- a/PROMS/VEPROMS User Interface/frmPDFStatusForm.cs +++ b/PROMS/VEPROMS User Interface/frmPDFStatusForm.cs @@ -75,10 +75,17 @@ namespace VEPROMS get { return _OnlyShowContinuousActionSummary; } set { _OnlyShowContinuousActionSummary = value; } } - public frmPDFStatusForm(ItemInfo myItem, string rev, string watermark, bool debugOutput, bool origPgBrk, bool openPDF, bool overWrite, string pdfPath, ChangeBarDefinition cbd,string pdfFile, Point newLocation,bool insertBlankPages, bool allOrAuto, string prefix, bool saveLinks, bool removeTrailingHardReturnsAndManualPageBreaks, bool showPROMSVer) + private bool _DidAll = false; + public bool DidAll + { + get { return _DidAll; } + set { _DidAll = value; } + } + public frmPDFStatusForm(ItemInfo myItem, string rev, string watermark, bool debugOutput, bool origPgBrk, bool openPDF, bool overWrite, string pdfPath, ChangeBarDefinition cbd,string pdfFile, Point newLocation,bool insertBlankPages, bool allOrAuto, string prefix, bool saveLinks, bool removeTrailingHardReturnsAndManualPageBreaks, bool showPROMSVer, bool didAll) { Prefix = prefix; OpenPDF = openPDF; + DidAll = didAll; InitializeComponent(); // if the version number of PROMS is 1.0, then we are running a Demo version. // When running a Demo version, force a "Sample" watermark when printing. @@ -166,8 +173,25 @@ namespace VEPROMS do { int profileDepth = ProfileTimer.Push(">>>> MyPromsPrinter.Print"); + // B2018-099: remove cache items for contents, items and parts to prevent out of memory errors when + // doing print all or automated print testing or approval of some or all procedures, i.e. HashSet and use of them below. + HashSet cacheContentInfo = null; + HashSet cacheItemInfo = null; + HashSet cachePartInfo = null; + if (DidAll) + { + cacheContentInfo = ContentInfo.CacheList; + cacheItemInfo = ItemInfo.CacheList; + cachePartInfo = PartInfo.CacheList; + } _PdfFile = MyPromsPrinter.Print(PDFPath, MakePlaceKeeper, MakeContinuousActionSummary); ProfileTimer.Pop(profileDepth); + if (DidAll) + { + ContentInfo.RestoreCacheList(cacheContentInfo); + ItemInfo.RestoreCacheList(cacheItemInfo); + PartInfo.RestoreCacheList(cachePartInfo); + } } while (_PdfFile == null && MessageBox.Show("Try Again?", "PDF Creation Failed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes); if (_PdfFile == null) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/CacheUsage.cs b/PROMS/VEPROMS.CSLA.Library/Extension/CacheUsage.cs index 6add287d..a8fc9de6 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/CacheUsage.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/CacheUsage.cs @@ -631,20 +631,20 @@ namespace VEPROMS.CSLA.Library } public partial class PartInfo { - public static List CacheList + public static HashSet CacheList { get { if (!CSLACache.RestoreCache) return null; ConvertListToDictionary(); - List lst = new List(); + HashSet lst = new HashSet(); foreach (string key in _CacheByPrimaryKey.Keys) foreach (PartInfo pi in _CacheByPrimaryKey[key]) lst.Add(pi.MyPartInfoUnique); return lst; } } - public static void RestoreCacheList(List cacheList) + public static void RestoreCacheList(HashSet cacheList) { if (cacheList == null) return; ConvertListToDictionary(); @@ -667,28 +667,31 @@ namespace VEPROMS.CSLA.Library #region Restore Cache public partial class ContentInfo { - public static List CacheList + // B2018-099: CacheLists where changed from List to HashSet because use for preventing out of memory errors + // was very slow when using List (HashSets are faster for large lists). The ContentInfo, ItemInfo and PartInfo + // CacheLists were changed. + public static HashSet CacheList { get { if (!CSLACache.RestoreCache) return null; ConvertListToDictionary(); - List lst = new List(); + HashSet lst = new HashSet(); foreach (string key in _CacheByPrimaryKey.Keys) foreach (ContentInfo ci in _CacheByPrimaryKey[key]) lst.Add(ci.MyContentInfoUnique); return lst; } } - public static void RestoreCacheList(List cacheList) + public static void RestoreCacheList(HashSet cacheList) { - if (cacheList == null) return; + if (cacheList == null) return; // if 'initialized' through CacheList above, it won't be null. ConvertListToDictionary(); List ciList = new List(); - foreach (string key in _CacheByPrimaryKey.Keys) + foreach (string key in _CacheByPrimaryKey.Keys) // KBR THIS is what takes so long for contents! foreach (ContentInfo ci in _CacheByPrimaryKey[key]) { - if (!cacheList.Contains(ci.MyContentInfoUnique)) + if (!cacheList.Contains(ci.MyContentInfoUnique)) ciList.Add(ci); } while (ciList.Count > 0) @@ -769,20 +772,20 @@ namespace VEPROMS.CSLA.Library } public partial class ItemInfo { - public static List CacheList + public static HashSet CacheList { get { if (!CSLACache.RestoreCache) return null; ConvertListToDictionary(); - List lst = new List(); + HashSet lst = new HashSet(); foreach (string key in _CacheByPrimaryKey.Keys) foreach (ItemInfo ii in _CacheByPrimaryKey[key]) lst.Add(ii.MyItemInfoUnique); return lst; } } - public static void RestoreCacheList(List cacheList) + public static void RestoreCacheList(HashSet cacheList) { if (cacheList == null) return; ConvertListToDictionary();