CLSA - Ds

This commit is contained in:
2026-09-08 08:55:36 -04:00
parent c21f366bb9
commit a69a2270a6
24 changed files with 1609 additions and 3414 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,14 +26,12 @@ namespace VEPROMS.CSLA.Library
public partial class DROUsageInfo : ReadOnlyBase<DROUsageInfo>, IDisposable
{
public event DROUsageInfoEvent 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<DROUsageInfo> _CacheList = new List<DROUsageInfo>();
protected static void AddToCache(DROUsageInfo dROUsageInfo)
{
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
{
while (_CacheList.Contains(dROUsageInfo)) _CacheList.Remove(dROUsageInfo); // In RemoveFromCache
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, List<DROUsageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DROUsageInfo>>();
private static void ConvertListToDictionary()
{
@@ -74,21 +71,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 DROUsage _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _DROUsageID;
[System.ComponentModel.DataObjectField(true, true)]
public int DROUsageID
@@ -175,32 +159,19 @@ namespace VEPROMS.CSLA.Library
return _MyRODb;
}
}
// CSLATODO: Replace base DROUsageInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DROUsageInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check DROUsageInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current DROUsageInfo</returns>
protected override object GetIdValue()
{
return MyDROUsageInfoUnique; // Absolutely Unique ID
}
protected override object GetIdValue() => MyDROUsageInfoUnique; // Absolutely Unique ID
#endregion
#region Factory Methods
private static int _DROUsageInfoUnique = 0;
private static int DROUsageInfoUnique
{ get { return ++_DROUsageInfoUnique; } }
private int _MyDROUsageInfoUnique = DROUsageInfoUnique;
public int MyDROUsageInfoUnique // Absolutely Unique ID - Info
{ get { return _MyDROUsageInfoUnique; } }
private static int DROUsageInfoUnique => ++_DROUsageInfoUnique;
private readonly int _MyDROUsageInfoUnique = DROUsageInfoUnique;
// Absolutely Unique ID - Info
public int MyDROUsageInfoUnique => _MyDROUsageInfoUnique;
protected DROUsageInfo()
{/* require use of factory methods */
AddToCache(this);
@@ -209,15 +180,11 @@ 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;
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;
~DROUsageInfo()
{
_CountFinalized++;
@@ -234,10 +201,7 @@ namespace VEPROMS.CSLA.Library
if (listDROUsageInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(DROUsageID.ToString()); // remove the list
}
public virtual DROUsage Get()
{
return _Editable = DROUsage.Get(_DROUsageID);
}
public virtual DROUsage Get() => _Editable = DROUsage.Get(_DROUsageID);
public static void Refresh(DROUsage tmp)
{
string key = tmp.DROUsageID.ToString();
@@ -250,22 +214,22 @@ namespace VEPROMS.CSLA.Library
{
if (_DocID != tmp.DocID)
{
if (MyDocument != null) MyDocument.RefreshDocumentDROUsages(); // Update List for old value
MyDocument?.RefreshDocumentDROUsages(); // Update List for old value
_DocID = tmp.DocID; // Update the value
}
_MyDocument = null; // Reset list so that the next line gets a new list
if (MyDocument != null) MyDocument.RefreshDocumentDROUsages(); // Update List for new value
MyDocument?.RefreshDocumentDROUsages(); // Update List for new value
_ROID = tmp.ROID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
if (_RODbID != tmp.RODbID)
{
if (MyRODb != null) MyRODb.RefreshRODbDROUsages(); // Update List for old value
MyRODb?.RefreshRODbDROUsages(); // 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.RefreshRODbDROUsages(); // Update List for new value
MyRODb?.RefreshRODbDROUsages(); // Update List for new value
_DROUsageInfoExtension.Refresh(this);
OnChange();// raise an event
}
@@ -285,11 +249,11 @@ namespace VEPROMS.CSLA.Library
_UserID = tmp.UserID;
if (_RODbID != tmp.RODbID)
{
if (MyRODb != null) MyRODb.RefreshRODbDROUsages(); // Update List for old value
MyRODb?.RefreshRODbDROUsages(); // 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.RefreshRODbDROUsages(); // Update List for new value
MyRODb?.RefreshRODbDROUsages(); // Update List for new value
_DROUsageInfoExtension.Refresh(this);
OnChange();// raise an event
}
@@ -305,11 +269,11 @@ namespace VEPROMS.CSLA.Library
{
if (_DocID != tmp.DocID)
{
if (MyDocument != null) MyDocument.RefreshDocumentDROUsages(); // Update List for old value
MyDocument?.RefreshDocumentDROUsages(); // Update List for old value
_DocID = tmp.DocID; // Update the value
}
_MyDocument = null; // Reset list so that the next line gets a new list
if (MyDocument != null) MyDocument.RefreshDocumentDROUsages(); // Update List for new value
MyDocument?.RefreshDocumentDROUsages(); // Update List for new value
_ROID = tmp.ROID;
_Config = tmp.Config;
_DTS = tmp.DTS;
@@ -319,8 +283,6 @@ namespace VEPROMS.CSLA.Library
}
public static DROUsageInfo Get(int dROUsageID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a DROUsage");
try
{
DROUsageInfo tmp = GetCachedByPrimaryKey(dROUsageID);
@@ -359,13 +321,9 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteria
{
private int _DROUsageID;
public int DROUsageID
{ get { return _DROUsageID; } }
public PKCriteria(int dROUsageID)
{
_DROUsageID = dROUsageID;
}
private readonly int _DROUsageID;
public int DROUsageID => _DROUsageID;
public PKCriteria(int dROUsageID) => _DROUsageID = dROUsageID;
}
private void ReadData(SafeDataReader dr)
{
@@ -426,7 +384,7 @@ namespace VEPROMS.CSLA.Library
#endregion
// Standard Refresh
#region extension
DROUsageInfoExtension _DROUsageInfoExtension = new DROUsageInfoExtension();
readonly DROUsageInfoExtension _DROUsageInfoExtension = new DROUsageInfoExtension();
[Serializable()]
partial class DROUsageInfoExtension : extensionBase { }
[Serializable()]
@@ -442,10 +400,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 DROUsageInfo)
if (destType == typeof(string) && value is DROUsageInfo info)
{
// Return the ToString value
return ((DROUsageInfo)value).ToString();
return info.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}