CSLA - E & F

This commit is contained in:
2026-09-09 14:08:28 -04:00
parent a69a2270a6
commit f2b064f459
25 changed files with 1535 additions and 3501 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 EntryInfo : ReadOnlyBase<EntryInfo>, IDisposable
{
public event EntryInfoEvent 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<EntryInfo> _CacheList = new List<EntryInfo>();
protected static void AddToCache(EntryInfo entryInfo)
{
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
{
while (_CacheList.Contains(entryInfo)) _CacheList.Remove(entryInfo); // In RemoveFromCache
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, List<EntryInfo>> _CacheByPrimaryKey = new Dictionary<string, List<EntryInfo>>();
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 Entry _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ContentID;
[System.ComponentModel.DataObjectField(true, true)]
public int ContentID
@@ -149,32 +133,19 @@ namespace VEPROMS.CSLA.Library
return _UserID;
}
}
// CSLATODO: Replace base EntryInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current EntryInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check EntryInfo.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 EntryInfo</returns>
protected override object GetIdValue()
{
return MyEntryInfoUnique; // Absolutely Unique ID
}
protected override object GetIdValue() => MyEntryInfoUnique; // Absolutely Unique ID
#endregion
#region Factory Methods
private static int _EntryInfoUnique = 0;
private static int EntryInfoUnique
{ get { return ++_EntryInfoUnique; } }
private int _MyEntryInfoUnique = EntryInfoUnique;
public int MyEntryInfoUnique // Absolutely Unique ID - Info
{ get { return _MyEntryInfoUnique; } }
private static int EntryInfoUnique => ++_EntryInfoUnique;
private readonly int _MyEntryInfoUnique = EntryInfoUnique;
// Absolutely Unique ID - Info
public int MyEntryInfoUnique => _MyEntryInfoUnique;
protected EntryInfo()
{/* require use of factory methods */
AddToCache(this);
@@ -183,15 +154,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;
~EntryInfo()
{
_CountFinalized++;
@@ -208,10 +175,7 @@ namespace VEPROMS.CSLA.Library
if (listEntryInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
}
public virtual Entry Get()
{
return _Editable = Entry.Get(_ContentID);
}
public virtual Entry Get() => _Editable = Entry.Get(_ContentID);
public static void Refresh(Entry tmp)
{
string key = tmp.ContentID.ToString();
@@ -224,11 +188,11 @@ namespace VEPROMS.CSLA.Library
{
if (_DocID != tmp.DocID)
{
if (MyDocument != null) MyDocument.RefreshDocumentEntries(); // Update List for old value
MyDocument?.RefreshDocumentEntries(); // 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.RefreshDocumentEntries(); // Update List for new value
MyDocument?.RefreshDocumentEntries(); // Update List for new value
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_EntryInfoExtension.Refresh(this);
@@ -251,8 +215,6 @@ namespace VEPROMS.CSLA.Library
}
public static EntryInfo Get(int contentID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Entry");
try
{
EntryInfo tmp = GetCachedByPrimaryKey(contentID);
@@ -291,13 +253,9 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteria
{
private int _ContentID;
public int ContentID
{ get { return _ContentID; } }
public PKCriteria(int contentID)
{
_ContentID = contentID;
}
private readonly int _ContentID;
public int ContentID => _ContentID;
public PKCriteria(int contentID) => _ContentID = contentID;
}
private void ReadData(SafeDataReader dr)
{
@@ -355,7 +313,7 @@ namespace VEPROMS.CSLA.Library
#endregion
// Standard Refresh
#region extension
EntryInfoExtension _EntryInfoExtension = new EntryInfoExtension();
readonly EntryInfoExtension _EntryInfoExtension = new EntryInfoExtension();
[Serializable()]
partial class EntryInfoExtension : extensionBase { }
[Serializable()]
@@ -371,10 +329,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 EntryInfo)
if (destType == typeof(string) && value is EntryInfo info)
{
// Return the ToString value
return ((EntryInfo)value).ToString();
return info.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}