C2025-011 PROMS – RO Update Admin Tool Memory Enhancements

The purpose of this upgrade is to improve the user experience when using the Admin tool to Update ROs. Currently for larger RO dbs (like Barakah) we can run up against memory constraints that do not allow all the ROs to be updated at one time. This is based upon some initial resource where some places were identified where we could improve memory usage.  Some of these should benefit PROMS as a whole while others will be specific to the RO Update option in Admin Tools.
This commit is contained in:
2025-02-04 13:23:21 -05:00
parent f2d330bd0e
commit 378653c536
254 changed files with 159727 additions and 163222 deletions

View File

@@ -49,29 +49,35 @@ namespace VEPROMS.CSLA.Library
{
if (DocVersionAssociations == null || DocVersionAssociations.Count == 0) return false;
ROFstInfo roFstInfo = ROFstInfo.GetJustROFst(DocVersionAssociations[0].ROFstID);
using (ROFstInfo roFstInfo = ROFstInfo.GetJustROFst(DocVersionAssociations[0].ROFstID))
{
using (RODbInfo rdi = RODbInfo.GetJustRODB(roFstInfo.RODbID))
{
string rofstPath = rdi.FolderPath + @"\ro.fst";
if (!File.Exists(rofstPath)) return false;
RODbInfo rdi = RODbInfo.GetJustRODB(roFstInfo.RODbID);
string rofstPath = rdi.FolderPath + @"\ro.fst";
if (!File.Exists(rofstPath)) return false;
FileInfo fiRofst = new FileInfo(rofstPath);
FileInfo fiRofst = new FileInfo(rofstPath);
// if the database Ro.Fst is newer or if the files have identical DTS,
// assume that they are the same file.
if (roFstInfo.DTS >= fiRofst.LastWriteTimeUtc) return false;
// if the database Ro.Fst is newer or if the files have identical DTS,
// assume that they are the same file.
if (roFstInfo.DTS >= fiRofst.LastWriteTimeUtc) return false;
// next see if the data is the same size, i.e. byte count of record and byte count
// of file. If different sizes, the date/time stamp check will hold.
// B2022-026 RO Memory reduction - new logic
var bytes = ROFSTLookup.GetRofstLookupBytes(roFstInfo.ROFstID);
// next see if the data is the same size, i.e. byte count of record and byte count
// of file. If different sizes, the date/time stamp check will hold.
// B2022-026 RO Memory reduction - new logic
var bytes = ROFSTLookup.GetRofstLookupBytes(roFstInfo.ROFstID);
if (bytes != null && fiRofst.Length != bytes.Length)
return fiRofst.LastWriteTimeUtc > roFstInfo.DTS;
// if we can't tell by the DTS or size, compare the contents. Get all of the rodb's
// rofsts of the size of the file & compare bytes.
return ROFstInfoList.ROFstDiffBySize(rofstPath, rdi.RODbID, (int)fiRofst.Length);
}
}
if (bytes != null && fiRofst.Length != bytes.Length)
return fiRofst.LastWriteTimeUtc > roFstInfo.DTS;
// if we can't tell by the DTS or size, compare the contents. Get all of the rodb's
// rofsts of the size of the file & compare bytes.
return ROFstInfoList.ROFstDiffBySize(rofstPath, rdi.RODbID, (int)fiRofst.Length);
}
}
public bool ROfstLastCompleted

View File

@@ -40,6 +40,17 @@ namespace VEPROMS.CSLA.Library
Console.WriteLine("- - - - - -");
}
//C2025-011 RO Update Admin Tool Memory Enhancements
//clears everything in cache - to run between sections in the Admin Tool to reclaim memory
public static void ClearItemCache()
{
_CacheByPrimaryKey.Clear();
while (_CacheList.Count > 0)
{
_CacheList[0].DisposeOfContent = true;
_CacheList[0].Dispose();
}
}
public override string ToString()
{
return string.Format("{0} {1}", MyContent.Number, MyContent.Text).Trim();
@@ -326,6 +337,32 @@ namespace VEPROMS.CSLA.Library
#region ItemInfo
public partial class ItemInfo : IVEDrillDownReadOnly
{
//C2025-011 RO Update Admin Tool Memory Enhancements
//clears everything in cache - to run between sections in the Admin Tool to reclaim memory
public static void ClearItemInfoCache()
{
while (_CacheByPrimaryKey.Count > 0)
{
var ii = _CacheByPrimaryKey.FirstOrDefault();
while (ii.Value.Count > 0)
{
if (ii.Value[0]?.MyContent?.ContentParts != null)
{ foreach (PartInfo pi in ii.Value[0]?.MyContent?.ContentParts) pi.Dispose(); }
ii.Value[0].Dispose();
}
_CacheByPrimaryKey.Remove(ii.Key);
}
while (_CacheList.Count > 0)
{
if (_CacheList[0]?.MyContent?.ContentParts != null)
{foreach (PartInfo pi in _CacheList[0]?.MyContent?.ContentParts) pi.Dispose(); }
_CacheList[0].Dispose();
}
}
private bool _PrintAllAtOnce = false;
public bool PrintAllAtOnce
@@ -2491,15 +2528,19 @@ namespace VEPROMS.CSLA.Library
}
public ItemInfo LastChild(E_FromType partType)
{
ItemInfoList myitems = Lookup((int)partType);
if (myitems != null) return myitems[myitems.Count - 1];
return null;
using (ItemInfoList myitems = Lookup((int)partType))
{
if (myitems != null) return myitems[myitems.Count - 1];
return null;
}
}
public ItemInfo FirstChild(E_FromType partType)
{
ItemInfoList myitems = Lookup((int)partType);
if (myitems != null) return myitems[0];
return null;
using (ItemInfoList myitems = Lookup((int)partType))
{
if (myitems != null) return myitems[0];
return null;
}
}
public bool HasAncestor(ItemInfo ancestor)
{
@@ -3863,30 +3904,33 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region IVEReadOnlyItem
PartInfoList _PartInfoList;
public System.Collections.IList GetChildren()
{
_PartInfoList = this.MyContent.ContentParts;
if (_PartInfoList.Count == 1 && ((IsProcedure && _PartInfoList[0].ToString() == "Sections") || _PartInfoList[0].ToString() == "Steps"))
return _PartInfoList[0].GetChildren();
return _PartInfoList;
}
public System.Collections.IList GetChildren(bool allParts)
{
_PartInfoList = this.MyContent.ContentParts;
if (allParts)
using (PartInfoList _PartInfoList = this.MyContent.ContentParts)
{
if (_PartInfoList.Count == 1 && ((IsProcedure && _PartInfoList[0].ToString() == "Sections") || _PartInfoList[0].ToString() == "Steps"))
return _PartInfoList[0].GetChildren();
return _PartInfoList;
}
else // Steps and Sections only
{
for (int i = 0; i < _PartInfoList.Count; i++)
if (_PartInfoList[i].ToString() == "Sections" || _PartInfoList[i].ToString() == "Steps")
return _PartInfoList[i].GetChildren();
return null;
}
public System.Collections.IList GetChildren(bool allParts)
{
using (PartInfoList _PartInfoList = this.MyContent.ContentParts)
{
if (allParts)
{
if (_PartInfoList.Count == 1 && ((IsProcedure && _PartInfoList[0].ToString() == "Sections") || _PartInfoList[0].ToString() == "Steps"))
return _PartInfoList[0].GetChildren();
return _PartInfoList;
}
else // Steps and Sections only
{
for (int i = 0; i < _PartInfoList.Count; i++)
if (_PartInfoList[i].ToString() == "Sections" || _PartInfoList[i].ToString() == "Steps")
return _PartInfoList[i].GetChildren();
return null;
}
}
}
//public bool ChildrenAreLoaded
@@ -6185,8 +6229,8 @@ namespace VEPROMS.CSLA.Library
{
try
{
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new MoveItemCriteria(itemID, index));
return tmp;
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new MoveItemCriteria(itemID, index)))
{ return tmp; }
}
catch (Exception ex)
{
@@ -6198,13 +6242,15 @@ namespace VEPROMS.CSLA.Library
{
try
{
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListCriteria(itemID, type));
ItemInfo.AddList(tmp);
tmp.AddEvents();
#if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList
ContentInfoList.GetList(itemID); // Performance - Load All Content
#endif
return tmp;
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListCriteria(itemID, type)))
{
ItemInfo.AddList(tmp);
tmp.AddEvents();
#if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList
ContentInfoList.GetList(itemID); // Performance - Load All Content
#endif
return tmp;
}
}
catch (Exception ex)
{
@@ -6215,13 +6261,16 @@ namespace VEPROMS.CSLA.Library
{
try
{
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemTranToListCriteria());
ItemInfo.AddList(tmp);
tmp.AddEvents();
#if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList
ContentInfoList.GetList(itemID); // Performance - Load All Content
#endif
return tmp;
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemTranToListCriteria()))
{
ItemInfo.AddList(tmp);
tmp.AddEvents();
#if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList
ContentInfoList.GetList(itemID); // Performance - Load All Content
#endif
return tmp;
}
}
catch (Exception ex)
{
@@ -6232,13 +6281,15 @@ namespace VEPROMS.CSLA.Library
{
try
{
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemTranFromListCriteria());
ItemInfo.AddList(tmp);
tmp.AddEvents();
#if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList
ContentInfoList.GetList(itemID); // Performance - Load All Content
#endif
return tmp;
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemTranFromListCriteria()))
{
ItemInfo.AddList(tmp);
tmp.AddEvents();
#if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList
ContentInfoList.GetList(itemID); // Performance - Load All Content
#endif
return tmp;
}
}
catch (Exception ex)
{
@@ -6249,13 +6300,15 @@ namespace VEPROMS.CSLA.Library
{
try
{
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListPartTypeCriteria(fromType));
ItemInfo.AddList(tmp);
tmp.AddEvents();
#if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList
ContentInfoList.GetList(itemID); // Performance - Load All Content
#endif
return tmp;
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListPartTypeCriteria(fromType)))
{
ItemInfo.AddList(tmp);
tmp.AddEvents();
#if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList
ContentInfoList.GetList(itemID); // Performance - Load All Content
#endif
return tmp;
}
}
catch (Exception ex)
{
@@ -6740,8 +6793,8 @@ namespace VEPROMS.CSLA.Library
{
try
{
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListEnhancedTextDifferencesCriteria(procItem.ItemID));
return tmp;
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListEnhancedTextDifferencesCriteria(procItem.ItemID)))
{ return tmp; }
}
catch (Exception ex)
{
@@ -6809,8 +6862,8 @@ namespace VEPROMS.CSLA.Library
{
try
{
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListEnhancedMissingCriteria(srcItem.ItemID, enhType));
return tmp;
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListEnhancedMissingCriteria(srcItem.ItemID, enhType)))
{ return tmp; }
}
catch (Exception ex)
{
@@ -6879,11 +6932,13 @@ namespace VEPROMS.CSLA.Library
{
try
{
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListSearchCriteria(docVersionList, stepTypeList, searchString, caseSensitive, includeLinks, includeRtfFormatting, includeSpecialCharacters, unitPrefix, byWordPrefix, byWordSuffix));
tmp.SourceOfList = "Search";
ItemInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListSearchCriteria(docVersionList, stepTypeList, searchString, caseSensitive, includeLinks, includeRtfFormatting, includeSpecialCharacters, unitPrefix, byWordPrefix, byWordSuffix)))
{
tmp.SourceOfList = "Search";
ItemInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
}
catch (Exception ex)
{
@@ -7038,10 +7093,12 @@ namespace VEPROMS.CSLA.Library
{
try
{
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListROSearchCriteria(docVersionList, stepTypeList, roSearchString, unitPrefix));
ItemInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListROSearchCriteria(docVersionList, stepTypeList, roSearchString, unitPrefix)))
{
ItemInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
}
catch (Exception ex)
{
@@ -7142,10 +7199,12 @@ namespace VEPROMS.CSLA.Library
{
try
{
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListAnnotationSearchCriteria(docVersionList, stepTypeList, annotationTypeList, searchString, caseSensitive, unitPrefix));
ItemInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListAnnotationSearchCriteria(docVersionList, stepTypeList, annotationTypeList, searchString, caseSensitive, unitPrefix)))
{
ItemInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
}
catch (Exception ex)
{
@@ -7266,10 +7325,12 @@ namespace VEPROMS.CSLA.Library
{
try
{
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListTransitionSearchCriteria(docVersionList, tranType, tranCategory, stepTypeList));
ItemInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListTransitionSearchCriteria(docVersionList, tranType, tranCategory, stepTypeList)))
{
ItemInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
}
catch (Exception ex)
{
@@ -7355,10 +7416,12 @@ namespace VEPROMS.CSLA.Library
{
try
{
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListROReportCriteria(docVersionList, stepTypeList, roSearchString, unitPrefix));
ItemInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListROReportCriteria(docVersionList, stepTypeList, roSearchString, unitPrefix)))
{
ItemInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
}
catch (Exception ex)
{
@@ -7460,11 +7523,13 @@ namespace VEPROMS.CSLA.Library
{
try
{
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListApplicabilitySearchCriteria(docVersionList, stepTypeList, searchString, caseSensitive, includeLinks, includeRtfFormatting, includeSpecialCharacters, unitPrefix, applicSetting));
tmp.SourceOfList = "Search";
ItemInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListApplicabilitySearchCriteria(docVersionList, stepTypeList, searchString, caseSensitive, includeLinks, includeRtfFormatting, includeSpecialCharacters, unitPrefix, applicSetting)))
{
tmp.SourceOfList = "Search";
ItemInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
}
catch (Exception ex)
{
@@ -8114,27 +8179,30 @@ namespace VEPROMS.CSLA.Library
// get list of differences from sql. This list does not resolve links and may have other rtf commands.
// also this list is source items, not enhanced.
ItemInfoList iil = ItemInfoList.GetListEnhancedTextDifferences(this);
if (iil == null || iil.Count == 0) return null; // no differences were found.
// from sql list, get display text of source items & compare to this procedure's items. This
// will determine true 'text' differences. Then return this list.
ItemInfoList retiil = null; // new ItemInfoList(null);
foreach (ItemInfo ii in iil)
using (ItemInfoList iil = ItemInfoList.GetListEnhancedTextDifferences(this))
{
EnhancedDocuments seds = ii.GetMyEnhancedDocuments();
if (seds != null && seds.Count != 0)
if (iil == null || iil.Count == 0) return null; // no differences were found.
// from sql list, get display text of source items & compare to this procedure's items. This
// will determine true 'text' differences. Then return this list.
ItemInfoList retiil = null; // new ItemInfoList(null);
foreach (ItemInfo ii in iil)
{
EnhancedDocuments seds = ii.GetMyEnhancedDocuments();
if (seds != null && seds.Count != 0)
{
ItemInfo srcItem = ItemInfo.Get(seds[0].ItemID);
// B2022-049: Copy/paste of enhanced procedure and bad links between source and enhanced. Null reference check
if (srcItem != null && srcItem.DisplayTextKeepSpecialChars != ii.DisplayTextKeepSpecialChars)
// B2022-049: Copy/paste of enhanced procedure and bad links between source and enhanced. Null reference check
if (srcItem != null && srcItem.DisplayTextKeepSpecialChars != ii.DisplayTextKeepSpecialChars)
{
if (retiil == null) retiil = new ItemInfoList(ii);
else retiil.AddItem(ii);
}
}
}
return retiil;
}
return retiil;
}
public void EnhancedProcedureRefreshTextDifferences(ItemInfoList iil)
{

View File

@@ -84,7 +84,6 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("LastChanged", true);
return _LastChanged;
}
set { _LastChanged = value; }

View File

@@ -80,7 +80,6 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("LastChanged", true);
return _LastChanged;
}
set { _LastChanged = value; }