B2018-099: Print all & Approve all of large set crashes with out of memory error

This commit is contained in:
Kathy Ruffing 2018-06-29 13:24:15 +00:00
parent 8b431d2fe4
commit 03f07f3aeb
4 changed files with 45 additions and 18 deletions

View File

@ -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)

View File

@ -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<int, byte[]>(); // will hold the Word Attachments with resolved ROs

View File

@ -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<int> cacheContentInfo = null;
HashSet<int> cacheItemInfo = null;
HashSet<int> 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)

View File

@ -631,20 +631,20 @@ namespace VEPROMS.CSLA.Library
}
public partial class PartInfo
{
public static List<int> CacheList
public static HashSet<int> CacheList
{
get
{
if (!CSLACache.RestoreCache) return null;
ConvertListToDictionary();
List<int> lst = new List<int>();
HashSet<int> lst = new HashSet<int>();
foreach (string key in _CacheByPrimaryKey.Keys)
foreach (PartInfo pi in _CacheByPrimaryKey[key])
lst.Add(pi.MyPartInfoUnique);
return lst;
}
}
public static void RestoreCacheList(List<int> cacheList)
public static void RestoreCacheList(HashSet<int> cacheList)
{
if (cacheList == null) return;
ConvertListToDictionary();
@ -667,28 +667,31 @@ namespace VEPROMS.CSLA.Library
#region Restore Cache
public partial class ContentInfo
{
public static List<int> CacheList
// B2018-099: CacheLists where changed from List<int> to HashSet<int> 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<int> CacheList
{
get
{
if (!CSLACache.RestoreCache) return null;
ConvertListToDictionary();
List<int> lst = new List<int>();
HashSet<int> lst = new HashSet<int>();
foreach (string key in _CacheByPrimaryKey.Keys)
foreach (ContentInfo ci in _CacheByPrimaryKey[key])
lst.Add(ci.MyContentInfoUnique);
return lst;
}
}
public static void RestoreCacheList(List<int> cacheList)
public static void RestoreCacheList(HashSet<int> cacheList)
{
if (cacheList == null) return;
if (cacheList == null) return; // if 'initialized' through CacheList above, it won't be null.
ConvertListToDictionary();
List<ContentInfo> ciList = new List<ContentInfo>();
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<int> CacheList
public static HashSet<int> CacheList
{
get
{
if (!CSLACache.RestoreCache) return null;
ConvertListToDictionary();
List<int> lst = new List<int>();
HashSet<int> lst = new HashSet<int>();
foreach (string key in _CacheByPrimaryKey.Keys)
foreach (ItemInfo ii in _CacheByPrimaryKey[key])
lst.Add(ii.MyItemInfoUnique);
return lst;
}
}
public static void RestoreCacheList(List<int> cacheList)
public static void RestoreCacheList(HashSet<int> cacheList)
{
if (cacheList == null) return;
ConvertListToDictionary();