CSLA - R - Group 1

This commit is contained in:
2026-09-11 16:03:51 -04:00
parent d9f8f6cb37
commit d238d6aed2
33 changed files with 2101 additions and 4829 deletions
@@ -13,8 +13,6 @@ using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
@@ -28,20 +26,17 @@ namespace VEPROMS.CSLA.Library
public partial class ROFstInfo : ReadOnlyBase<ROFstInfo>, IDisposable
{
public event ROFstInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
private void OnChange() => Changed?.Invoke(this);
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static List<ROFstInfo> _CacheList = new List<ROFstInfo>();
protected static void AddToCache(ROFstInfo rOFstInfo)
{
if (!_CacheList.Contains(rOFstInfo))
{
rOFstInfo.ClearROLookupBytes(); // B2022-026 RO Memory reduction
_CacheList.Add(rOFstInfo); // In AddToCache
}
}
@@ -49,6 +44,7 @@ namespace VEPROMS.CSLA.Library
{
while (_CacheList.Contains(rOFstInfo)) _CacheList.Remove(rOFstInfo); // In RemoveFromCache
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, List<ROFstInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ROFstInfo>>();
private static void ConvertListToDictionary()
{
@@ -60,7 +56,6 @@ 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
}
@@ -79,21 +74,8 @@ namespace VEPROMS.CSLA.Library
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
public string ErrorMessage => _ErrorMessage;
protected ROFst _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ROFstID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROFstID
@@ -124,19 +106,6 @@ namespace VEPROMS.CSLA.Library
return _MyRODb;
}
}
private byte[] _ROLookup;
public byte[] ROLookup
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
// B2022-026 RO Memory reduction
return null;
}
}
private string _Config = string.Empty;
public string Config
{
@@ -241,21 +210,17 @@ namespace VEPROMS.CSLA.Library
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current ROFstInfo</returns>
protected override object GetIdValue()
{
return MyROFstInfoUnique; // Absolutely Unique ID
}
protected override object GetIdValue() => MyROFstInfoUnique; // Absolutely Unique ID
#endregion
#region Factory Methods
private static int _ROFstInfoUnique = 0;
private static int ROFstInfoUnique
{ get { return ++_ROFstInfoUnique; } }
private int _MyROFstInfoUnique = ROFstInfoUnique;
public int MyROFstInfoUnique // Absolutely Unique ID - Info
{ get { return _MyROFstInfoUnique; } }
private static int ROFstInfoUnique => ++_ROFstInfoUnique;
private readonly int _MyROFstInfoUnique = ROFstInfoUnique;
// Absolutely Unique ID - Info
public int MyROFstInfoUnique => _MyROFstInfoUnique;
protected ROFstInfo()
{/* require use of factory methods */
AddToCache(this);
@@ -265,15 +230,11 @@ namespace VEPROMS.CSLA.Library
private static int _CountDisposed = 0;
private static int _CountFinalized = 0;
private static int IncrementCountCreated
{ get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated
{ get { return _CountCreated; } }
public static int CountNotDisposed
{ get { return _CountCreated - _CountDisposed; } }
public static int CountNotFinalized
{ get { return _CountCreated - _CountFinalized; } }
private static int IncrementCountCreated => ++_CountCreated;
private readonly int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated => _CountCreated;
public static int CountNotDisposed => _CountCreated - _CountDisposed;
public static int CountNotFinalized => _CountCreated - _CountFinalized;
~ROFstInfo()
{
_CountFinalized++;
@@ -290,10 +251,7 @@ namespace VEPROMS.CSLA.Library
if (listROFstInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ROFstID.ToString()); // remove the list
}
public virtual ROFst Get()
{
return _Editable = ROFst.Get(_ROFstID);
}
public virtual ROFst Get() => _Editable = ROFst.Get(_ROFstID);
public static void Refresh(ROFst tmp)
{
string key = tmp.ROFstID.ToString();
@@ -302,23 +260,16 @@ 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)
{
if (MyRODb != null) MyRODb.RefreshRODbROFsts(); // Update List for old value
MyRODb?.RefreshRODbROFsts(); // Update List for old value
_RODbID = tmp.RODbID; // Update the value
}
_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 = null; // B2022-026 RO Memory reduction
MyRODb?.RefreshRODbROFsts(); // Update List for new value
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
@@ -335,8 +286,6 @@ namespace VEPROMS.CSLA.Library
}
protected virtual void RefreshFields(RODbROFst tmp)
{
//_ROLookup = tmp.ROLookup;
_ROLookup = null; // B2022-026 RO Memory reduction
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
@@ -360,11 +309,6 @@ namespace VEPROMS.CSLA.Library
tmp = null;
}
if (tmp != null)
{
tmp.ClearROLookupBytes(); // B2022-026 RO Memory reduction
}
return tmp;
}
catch (Exception ex)
@@ -394,13 +338,9 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteria
{
private int _ROFstID;
public int ROFstID
{ get { return _ROFstID; } }
public PKCriteria(int rOFstID)
{
_ROFstID = rOFstID;
}
private readonly int _ROFstID;
public int ROFstID => _ROFstID;
public PKCriteria(int rOFstID) => _ROFstID = rOFstID;
}
private void ReadData(SafeDataReader dr)
@@ -410,8 +350,6 @@ namespace VEPROMS.CSLA.Library
{
_ROFstID = dr.GetInt32("ROFstID");
_RODbID = dr.GetInt32("RODbID");
//_ROLookup = (byte[])dr.GetValue("ROLookup");
_ROLookup = null; // B2022-026 RO Memory reduction
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
@@ -467,7 +405,7 @@ namespace VEPROMS.CSLA.Library
// Standard Refresh
#region extension
ROFstInfoExtension _ROFstInfoExtension = new ROFstInfoExtension();
readonly ROFstInfoExtension _ROFstInfoExtension = new ROFstInfoExtension();
[Serializable()]
partial class ROFstInfoExtension : extensionBase { }
[Serializable()]
@@ -485,10 +423,10 @@ namespace VEPROMS.CSLA.Library
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROFstInfo)
if (destType == typeof(string) && value is ROFstInfo info)
{
// Return the ToString value
return ((ROFstInfo)value).ToString();
return info.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}