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 TransitionInfo : ReadOnlyBase<TransitionInfo>, IDisposable
{
public event TransitionInfoEvent 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<TransitionInfo> _CacheList = new List<TransitionInfo>();
protected static void AddToCache(TransitionInfo transitionInfo)
{
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
{
while (_CacheList.Contains(transitionInfo)) _CacheList.Remove(transitionInfo); // In RemoveFromCache
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, List<TransitionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<TransitionInfo>>();
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 Transition _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _TransitionID;
[System.ComponentModel.DataObjectField(true, true)]
public int TransitionID
@@ -237,32 +221,19 @@ namespace VEPROMS.CSLA.Library
return _MyZTransition;
}
}
// CSLATODO: Replace base TransitionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current TransitionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check TransitionInfo.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 TransitionInfo</returns>
protected override object GetIdValue()
{
return MyTransitionInfoUnique; // Absolutely Unique ID
}
protected override object GetIdValue() => MyTransitionInfoUnique; // Absolutely Unique ID
#endregion
#region Factory Methods
private static int _TransitionInfoUnique = 0;
private static int TransitionInfoUnique
{ get { return ++_TransitionInfoUnique; } }
private int _MyTransitionInfoUnique = TransitionInfoUnique;
public int MyTransitionInfoUnique // Absolutely Unique ID - Info
{ get { return _MyTransitionInfoUnique; } }
private static int TransitionInfoUnique => ++_TransitionInfoUnique;
private readonly int _MyTransitionInfoUnique = TransitionInfoUnique;
// Absolutely Unique ID - Info
public int MyTransitionInfoUnique => _MyTransitionInfoUnique;
protected TransitionInfo()
{/* require use of factory methods */
AddToCache(this);
@@ -271,15 +242,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;
~TransitionInfo()
{
_CountFinalized++;
@@ -296,10 +263,7 @@ namespace VEPROMS.CSLA.Library
if (listTransitionInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(TransitionID.ToString()); // remove the list
}
public virtual Transition Get()
{
return _Editable = Transition.Get(_TransitionID);
}
public virtual Transition Get() => _Editable = Transition.Get(_TransitionID);
public static void Refresh(Transition tmp)
{
string key = tmp.TransitionID.ToString();
@@ -312,25 +276,25 @@ namespace VEPROMS.CSLA.Library
{
if (_FromID != tmp.FromID)
{
if (MyContent != null) MyContent.RefreshContentTransitions(); // Update List for old value
MyContent?.RefreshContentTransitions(); // Update List for old value
_FromID = tmp.FromID; // Update the value
}
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentTransitions(); // Update List for new value
MyContent?.RefreshContentTransitions(); // Update List for new value
if (_ToID != tmp.ToID)
{
if (MyItemToID != null) MyItemToID.RefreshItemTransitions_ToID(); // Update List for old value
MyItemToID?.RefreshItemTransitions_ToID(); // Update List for old value
_ToID = tmp.ToID; // Update the value
}
_MyItemToID = null; // Reset list so that the next line gets a new list
if (MyItemToID != null) MyItemToID.RefreshItemTransitions_ToID(); // Update List for new value
MyItemToID?.RefreshItemTransitions_ToID(); // Update List for new value
if (_RangeID != tmp.RangeID)
{
if (MyItemRangeID != null) MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for old value
MyItemRangeID?.RefreshItemTransitions_RangeID(); // Update List for old value
_RangeID = tmp.RangeID; // Update the value
}
_MyItemRangeID = null; // Reset list so that the next line gets a new list
if (MyItemRangeID != null) MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for new value
MyItemRangeID?.RefreshItemTransitions_RangeID(); // Update List for new value
_IsRange = tmp.IsRange;
_TranType = tmp.TranType;
_Config = tmp.Config;
@@ -352,18 +316,18 @@ namespace VEPROMS.CSLA.Library
{
if (_ToID != tmp.ToID)
{
if (MyItemToID != null) MyItemToID.RefreshItemTransitions_ToID(); // Update List for old value
MyItemToID?.RefreshItemTransitions_ToID(); // Update List for old value
_ToID = tmp.ToID; // Update the value
}
_MyItemToID = null; // Reset list so that the next line gets a new list
if (MyItemToID != null) MyItemToID.RefreshItemTransitions_ToID(); // Update List for new value
MyItemToID?.RefreshItemTransitions_ToID(); // Update List for new value
if (_RangeID != tmp.RangeID)
{
if (MyItemRangeID != null) MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for old value
MyItemRangeID?.RefreshItemTransitions_RangeID(); // Update List for old value
_RangeID = tmp.RangeID; // Update the value
}
_MyItemRangeID = null; // Reset list so that the next line gets a new list
if (MyItemRangeID != null) MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for new value
MyItemRangeID?.RefreshItemTransitions_RangeID(); // Update List for new value
_IsRange = tmp.IsRange;
_TranType = tmp.TranType;
_Config = tmp.Config;
@@ -385,18 +349,18 @@ namespace VEPROMS.CSLA.Library
{
if (_FromID != tmp.FromID)
{
if (MyContent != null) MyContent.RefreshContentTransitions(); // Update List for old value
MyContent?.RefreshContentTransitions(); // Update List for old value
_FromID = tmp.FromID; // Update the value
}
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentTransitions(); // Update List for new value
MyContent?.RefreshContentTransitions(); // Update List for new value
if (_ToID != tmp.ToID)
{
if (MyItemToID != null) MyItemToID.RefreshItemTransitions_ToID(); // Update List for old value
MyItemToID?.RefreshItemTransitions_ToID(); // Update List for old value
_ToID = tmp.ToID; // Update the value
}
_MyItemToID = null; // Reset list so that the next line gets a new list
if (MyItemToID != null) MyItemToID.RefreshItemTransitions_ToID(); // Update List for new value
MyItemToID?.RefreshItemTransitions_ToID(); // Update List for new value
_IsRange = tmp.IsRange;
_TranType = tmp.TranType;
_Config = tmp.Config;
@@ -418,18 +382,18 @@ namespace VEPROMS.CSLA.Library
{
if (_FromID != tmp.FromID)
{
if (MyContent != null) MyContent.RefreshContentTransitions(); // Update List for old value
MyContent?.RefreshContentTransitions(); // Update List for old value
_FromID = tmp.FromID; // Update the value
}
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentTransitions(); // Update List for new value
MyContent?.RefreshContentTransitions(); // Update List for new value
if (_RangeID != tmp.RangeID)
{
if (MyItemRangeID != null) MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for old value
MyItemRangeID?.RefreshItemTransitions_RangeID(); // Update List for old value
_RangeID = tmp.RangeID; // Update the value
}
_MyItemRangeID = null; // Reset list so that the next line gets a new list
if (MyItemRangeID != null) MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for new value
MyItemRangeID?.RefreshItemTransitions_RangeID(); // Update List for new value
_IsRange = tmp.IsRange;
_TranType = tmp.TranType;
_Config = tmp.Config;
@@ -441,8 +405,6 @@ namespace VEPROMS.CSLA.Library
}
public static TransitionInfo Get(int transitionID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Transition");
try
{
TransitionInfo tmp = GetCachedByPrimaryKey(transitionID);
@@ -481,13 +443,9 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteria
{
private int _TransitionID;
public int TransitionID
{ get { return _TransitionID; } }
public PKCriteria(int transitionID)
{
_TransitionID = transitionID;
}
private readonly int _TransitionID;
public int TransitionID => _TransitionID;
public PKCriteria(int transitionID) => _TransitionID = transitionID;
}
private void ReadData(SafeDataReader dr)
{
@@ -551,7 +509,7 @@ namespace VEPROMS.CSLA.Library
#endregion
// Standard Refresh
#region extension
TransitionInfoExtension _TransitionInfoExtension = new TransitionInfoExtension();
readonly TransitionInfoExtension _TransitionInfoExtension = new TransitionInfoExtension();
[Serializable()]
partial class TransitionInfoExtension : extensionBase { }
[Serializable()]
@@ -567,10 +525,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 TransitionInfo)
if (destType == typeof(string) && value is TransitionInfo info)
{
// Return the ToString value
return ((TransitionInfo)value).ToString();
return info.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}