B2022-026 RO Memory reduction coding

This commit is contained in:
2022-05-26 19:55:07 +00:00
parent 61febac1a0
commit 27993553cb
21 changed files with 6827 additions and 5160 deletions

View File

@@ -39,7 +39,11 @@ namespace VEPROMS.CSLA.Library
private static List<ROFstInfo> _CacheList = new List<ROFstInfo>();
protected static void AddToCache(ROFstInfo rOFstInfo)
{
if (!_CacheList.Contains(rOFstInfo)) _CacheList.Add(rOFstInfo); // In AddToCache
if (!_CacheList.Contains(rOFstInfo))
{
rOFstInfo.ClearROLookupBytes(); // B2022-026 RO Memory reduction
_CacheList.Add(rOFstInfo); // In AddToCache
}
}
protected static void RemoveFromCache(ROFstInfo rOFstInfo)
{
@@ -56,6 +60,7 @@ namespace VEPROMS.CSLA.Library
{
_CacheByPrimaryKey[pKey] = new List<ROFstInfo>(); // Add new list for PrimaryKey
}
tmp.ClearROLookupBytes(); // B2022-026 RO Memory reduction
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first ROFstInfo
}
@@ -122,6 +127,7 @@ namespace VEPROMS.CSLA.Library
return _MyRODb;
}
}
private byte[] _ROLookup;
public byte[] ROLookup
{
@@ -129,9 +135,17 @@ namespace VEPROMS.CSLA.Library
get
{
CanReadProperty("ROLookup", true);
return _ROLookup;
//if (_ROLookup == null)
//{
// _ROLookup = ROFSTLookup.GetRofstLookupBytes(_ROFstID);
//}
//return _ROLookup;
// B2022-026 RO Memory reduction
return null;
}
}
private string _Config = string.Empty;
public string Config
{
@@ -238,16 +252,7 @@ namespace VEPROMS.CSLA.Library
foreach (ROFstInfo tmp in _CacheByPrimaryKey[_ROFstID.ToString()])
tmp._ROFstFigureCount = -1; // This will cause the data to be requeried
}
// CSLATODO: Replace base ROFstInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROFstInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check ROFstInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
@@ -256,8 +261,11 @@ namespace VEPROMS.CSLA.Library
{
return MyROFstInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _ROFstInfoUnique = 0;
private static int ROFstInfoUnique
{ get { return ++_ROFstInfoUnique; } }
@@ -272,6 +280,7 @@ namespace VEPROMS.CSLA.Library
private static int _CountCreated = 0;
private static int _CountDisposed = 0;
private static int _CountFinalized = 0;
private static int IncrementCountCreated
{ get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated;
@@ -309,6 +318,12 @@ namespace VEPROMS.CSLA.Library
foreach (ROFstInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
// B2022-026 RO Memory reduction
public void ClearROLookupBytes()
{
_ROLookup = null;
}
protected virtual void RefreshFields(ROFst tmp)
{
if (_RODbID != tmp.RODbID)
@@ -318,7 +333,8 @@ namespace VEPROMS.CSLA.Library
}
_MyRODb = null; // Reset list so that the next line gets a new list
if (MyRODb != null) MyRODb.RefreshRODbROFsts(); // Update List for new value
_ROLookup = tmp.ROLookup;
//_ROLookup = tmp.ROLookup;
_ROLookup = null; // B2022-026 RO Memory reduction
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
@@ -335,7 +351,8 @@ namespace VEPROMS.CSLA.Library
}
protected virtual void RefreshFields(RODbROFst tmp)
{
_ROLookup = tmp.ROLookup;
//_ROLookup = tmp.ROLookup;
_ROLookup = null; // B2022-026 RO Memory reduction
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
@@ -344,8 +361,6 @@ namespace VEPROMS.CSLA.Library
}
public static ROFstInfo Get(int rOFstID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ROFst");
try
{
ROFstInfo tmp = GetCachedByPrimaryKey(rOFstID);
@@ -354,11 +369,18 @@ namespace VEPROMS.CSLA.Library
tmp = DataPortal.Fetch<ROFstInfo>(new PKCriteria(rOFstID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ROFstInfo
tmp = null;
}
if (tmp != null)
{
tmp.ClearROLookupBytes(); // B2022-026 RO Memory reduction
}
return tmp;
}
catch (Exception ex)
@@ -366,8 +388,11 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Error on ROFstInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ROFstInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfo.Constructor", GetHashCode());
@@ -381,6 +406,7 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("ROFstInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
@@ -392,6 +418,7 @@ namespace VEPROMS.CSLA.Library
_ROFstID = rOFstID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfo.ReadData", GetHashCode());
@@ -399,7 +426,8 @@ namespace VEPROMS.CSLA.Library
{
_ROFstID = dr.GetInt32("ROFstID");
_RODbID = dr.GetInt32("RODbID");
_ROLookup = (byte[])dr.GetValue("ROLookup");
//_ROLookup = (byte[])dr.GetValue("ROLookup");
_ROLookup = null; // B2022-026 RO Memory reduction
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
@@ -413,6 +441,7 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("ROFstInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfo.DataPortal_Fetch", GetHashCode());
@@ -449,7 +478,9 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("ROFstInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ROFstInfoExtension _ROFstInfoExtension = new ROFstInfoExtension();
@@ -463,7 +494,9 @@ namespace VEPROMS.CSLA.Library
}
#endregion
} // Class
#region Converter
internal class ROFstInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
@@ -476,5 +509,6 @@ namespace VEPROMS.CSLA.Library
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace