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 FigureInfo : ReadOnlyBase<FigureInfo>, IDisposable
{
public event FigureInfoEvent 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<FigureInfo> _CacheList = new List<FigureInfo>();
protected static void AddToCache(FigureInfo figureInfo)
{
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
{
while (_CacheList.Contains(figureInfo)) _CacheList.Remove(figureInfo); // In RemoveFromCache
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, List<FigureInfo>> _CacheByPrimaryKey = new Dictionary<string, List<FigureInfo>>();
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 Figure _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _FigureID;
[System.ComponentModel.DataObjectField(true, true)]
public int FigureID
@@ -166,32 +150,19 @@ namespace VEPROMS.CSLA.Library
return _UserID;
}
}
// CSLATODO: Replace base FigureInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current FigureInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check FigureInfo.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 FigureInfo</returns>
protected override object GetIdValue()
{
return MyFigureInfoUnique; // Absolutely Unique ID
}
protected override object GetIdValue() => MyFigureInfoUnique; // Absolutely Unique ID
#endregion
#region Factory Methods
private static int _FigureInfoUnique = 0;
private static int FigureInfoUnique
{ get { return ++_FigureInfoUnique; } }
private int _MyFigureInfoUnique = FigureInfoUnique;
public int MyFigureInfoUnique // Absolutely Unique ID - Info
{ get { return _MyFigureInfoUnique; } }
private static int FigureInfoUnique => ++_FigureInfoUnique;
private readonly int _MyFigureInfoUnique = FigureInfoUnique;
// Absolutely Unique ID - Info
public int MyFigureInfoUnique => _MyFigureInfoUnique;
protected FigureInfo()
{/* require use of factory methods */
AddToCache(this);
@@ -200,15 +171,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;
~FigureInfo()
{
_CountFinalized++;
@@ -225,10 +192,7 @@ namespace VEPROMS.CSLA.Library
if (listFigureInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(FigureID.ToString()); // remove the list
}
public virtual Figure Get()
{
return _Editable = Figure.Get(_FigureID);
}
public virtual Figure Get() => _Editable = Figure.Get(_FigureID);
public static void Refresh(Figure tmp)
{
string key = tmp.FigureID.ToString();
@@ -241,18 +205,18 @@ namespace VEPROMS.CSLA.Library
{
if (_ROFstID != tmp.ROFstID)
{
if (MyROFst != null) MyROFst.RefreshROFstFigures(); // Update List for old value
MyROFst?.RefreshROFstFigures(); // Update List for old value
_ROFstID = tmp.ROFstID; // Update the value
}
_MyROFst = null; // Reset list so that the next line gets a new list
if (MyROFst != null) MyROFst.RefreshROFstFigures(); // Update List for new value
MyROFst?.RefreshROFstFigures(); // Update List for new value
if (_ImageID != tmp.ImageID)
{
if (MyROImage != null) MyROImage.RefreshROImageFigures(); // Update List for old value
MyROImage?.RefreshROImageFigures(); // Update List for old value
_ImageID = tmp.ImageID; // Update the value
}
_MyROImage = null; // Reset list so that the next line gets a new list
if (MyROImage != null) MyROImage.RefreshROImageFigures(); // Update List for new value
MyROImage?.RefreshROImageFigures(); // Update List for new value
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
@@ -271,11 +235,11 @@ namespace VEPROMS.CSLA.Library
{
if (_ImageID != tmp.ImageID)
{
if (MyROImage != null) MyROImage.RefreshROImageFigures(); // Update List for old value
MyROImage?.RefreshROImageFigures(); // Update List for old value
_ImageID = tmp.ImageID; // Update the value
}
_MyROImage = null; // Reset list so that the next line gets a new list
if (MyROImage != null) MyROImage.RefreshROImageFigures(); // Update List for new value
MyROImage?.RefreshROImageFigures(); // Update List for new value
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
@@ -294,11 +258,11 @@ namespace VEPROMS.CSLA.Library
{
if (_ROFstID != tmp.ROFstID)
{
if (MyROFst != null) MyROFst.RefreshROFstFigures(); // Update List for old value
MyROFst?.RefreshROFstFigures(); // Update List for old value
_ROFstID = tmp.ROFstID; // Update the value
}
_MyROFst = null; // Reset list so that the next line gets a new list
if (MyROFst != null) MyROFst.RefreshROFstFigures(); // Update List for new value
MyROFst?.RefreshROFstFigures(); // Update List for new value
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
@@ -307,8 +271,6 @@ namespace VEPROMS.CSLA.Library
}
public static FigureInfo Get(int figureID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Figure");
try
{
FigureInfo tmp = GetCachedByPrimaryKey(figureID);
@@ -347,13 +309,9 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteria
{
private int _FigureID;
public int FigureID
{ get { return _FigureID; } }
public PKCriteria(int figureID)
{
_FigureID = figureID;
}
private readonly int _FigureID;
public int FigureID => _FigureID;
public PKCriteria(int figureID) => _FigureID = figureID;
}
private string _ROImage_FileName = string.Empty;
public string ROImage_FileName
@@ -427,7 +385,7 @@ namespace VEPROMS.CSLA.Library
#endregion
// Standard Refresh
#region extension
FigureInfoExtension _FigureInfoExtension = new FigureInfoExtension();
readonly FigureInfoExtension _FigureInfoExtension = new FigureInfoExtension();
[Serializable()]
partial class FigureInfoExtension : extensionBase { }
[Serializable()]
@@ -443,10 +401,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 FigureInfo)
if (destType == typeof(string) && value is FigureInfo info)
{
// Return the ToString value
return ((FigureInfo)value).ToString();
return info.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}