CSLA - R to Z

This commit is contained in:
2026-09-14 15:30:10 -04:00
parent d238d6aed2
commit 1c6f3e3e3c
32 changed files with 1978 additions and 4455 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 VersionInfo : ReadOnlyBase<VersionInfo>, IDisposable
{
public event VersionInfoEvent 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<VersionInfo> _CacheList = new List<VersionInfo>();
protected static void AddToCache(VersionInfo versionInfo)
{
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
{
while (_CacheList.Contains(versionInfo)) _CacheList.Remove(versionInfo); // In RemoveFromCache
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, List<VersionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<VersionInfo>>();
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 Version _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _VersionID;
[System.ComponentModel.DataObjectField(true, true)]
public int VersionID
@@ -196,32 +180,19 @@ namespace VEPROMS.CSLA.Library
return _UserID;
}
}
// CSLATODO: Replace base VersionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current VersionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check VersionInfo.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 VersionInfo</returns>
protected override object GetIdValue()
{
return MyVersionInfoUnique; // Absolutely Unique ID
}
protected override object GetIdValue() => MyVersionInfoUnique; // Absolutely Unique ID
#endregion
#region Factory Methods
private static int _VersionInfoUnique = 0;
private static int VersionInfoUnique
{ get { return ++_VersionInfoUnique; } }
private int _MyVersionInfoUnique = VersionInfoUnique;
public int MyVersionInfoUnique // Absolutely Unique ID - Info
{ get { return _MyVersionInfoUnique; } }
private static int VersionInfoUnique => ++_VersionInfoUnique;
private readonly int _MyVersionInfoUnique = VersionInfoUnique;
// Absolutely Unique ID - Info
public int MyVersionInfoUnique => _MyVersionInfoUnique;
protected VersionInfo()
{/* require use of factory methods */
AddToCache(this);
@@ -230,15 +201,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;
~VersionInfo()
{
_CountFinalized++;
@@ -255,10 +222,7 @@ namespace VEPROMS.CSLA.Library
if (listVersionInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(VersionID.ToString()); // remove the list
}
public virtual Version Get()
{
return _Editable = Version.Get(_VersionID);
}
public virtual Version Get() => _Editable = Version.Get(_VersionID);
public static void Refresh(Version tmp)
{
string key = tmp.VersionID.ToString();
@@ -271,18 +235,18 @@ namespace VEPROMS.CSLA.Library
{
if (_RevisionID != tmp.RevisionID)
{
if (MyRevision != null) MyRevision.RefreshRevisionVersions(); // Update List for old value
MyRevision?.RefreshRevisionVersions(); // Update List for old value
_RevisionID = tmp.RevisionID; // Update the value
}
_MyRevision = null; // Reset list so that the next line gets a new list
if (MyRevision != null) MyRevision.RefreshRevisionVersions(); // Update List for new value
MyRevision?.RefreshRevisionVersions(); // Update List for new value
if (_StageID != tmp.StageID)
{
if (MyStage != null) MyStage.RefreshStageVersions(); // Update List for old value
MyStage?.RefreshStageVersions(); // Update List for old value
_StageID = tmp.StageID; // Update the value
}
_MyStage = null; // Reset list so that the next line gets a new list
if (MyStage != null) MyStage.RefreshStageVersions(); // Update List for new value
MyStage?.RefreshStageVersions(); // Update List for new value
_PDF = tmp.PDF;
_SummaryPDF = tmp.SummaryPDF;
_DTS = tmp.DTS;
@@ -302,11 +266,11 @@ namespace VEPROMS.CSLA.Library
{
if (_StageID != tmp.StageID)
{
if (MyStage != null) MyStage.RefreshStageVersions(); // Update List for old value
MyStage?.RefreshStageVersions(); // Update List for old value
_StageID = tmp.StageID; // Update the value
}
_MyStage = null; // Reset list so that the next line gets a new list
if (MyStage != null) MyStage.RefreshStageVersions(); // Update List for new value
MyStage?.RefreshStageVersions(); // Update List for new value
_PDF = tmp.PDF;
_SummaryPDF = tmp.SummaryPDF;
_DTS = tmp.DTS;
@@ -326,11 +290,11 @@ namespace VEPROMS.CSLA.Library
{
if (_RevisionID != tmp.RevisionID)
{
if (MyRevision != null) MyRevision.RefreshRevisionVersions(); // Update List for old value
MyRevision?.RefreshRevisionVersions(); // Update List for old value
_RevisionID = tmp.RevisionID; // Update the value
}
_MyRevision = null; // Reset list so that the next line gets a new list
if (MyRevision != null) MyRevision.RefreshRevisionVersions(); // Update List for new value
MyRevision?.RefreshRevisionVersions(); // Update List for new value
_PDF = tmp.PDF;
_SummaryPDF = tmp.SummaryPDF;
_DTS = tmp.DTS;
@@ -340,8 +304,6 @@ namespace VEPROMS.CSLA.Library
}
public static VersionInfo Get(int versionID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Version");
try
{
VersionInfo tmp = GetCachedByPrimaryKey(versionID);
@@ -380,13 +342,9 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteria
{
private int _VersionID;
public int VersionID
{ get { return _VersionID; } }
public PKCriteria(int versionID)
{
_VersionID = versionID;
}
private readonly int _VersionID;
public int VersionID => _VersionID;
public PKCriteria(int versionID) => _VersionID = versionID;
}
private void ReadData(SafeDataReader dr)
{
@@ -448,7 +406,7 @@ namespace VEPROMS.CSLA.Library
#endregion
// Standard Refresh
#region extension
VersionInfoExtension _VersionInfoExtension = new VersionInfoExtension();
readonly VersionInfoExtension _VersionInfoExtension = new VersionInfoExtension();
[Serializable()]
partial class VersionInfoExtension : extensionBase { }
[Serializable()]
@@ -464,10 +422,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 VersionInfo)
if (destType == typeof(string) && value is VersionInfo info)
{
// Return the ToString value
return ((VersionInfo)value).ToString();
return info.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}