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

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

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();