This commit is contained in:
2026-09-09 15:52:32 -04:00
parent f2b064f459
commit da8d25082f
12 changed files with 698 additions and 1660 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;
using System.Linq;
@@ -30,14 +28,12 @@ namespace VEPROMS.CSLA.Library
public partial class GridInfo : ReadOnlyBase<GridInfo>, IDisposable
{
public event GridInfoEvent 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<GridInfo> _CacheList = new List<GridInfo>();
protected static void AddToCache(GridInfo gridInfo)
{
@@ -47,6 +43,7 @@ namespace VEPROMS.CSLA.Library
{
while (_CacheList.Contains(gridInfo)) _CacheList.Remove(gridInfo); // In RemoveFromCache
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, List<GridInfo>> _CacheByPrimaryKey = new Dictionary<string, List<GridInfo>>();
private static void ConvertListToDictionary()
{
@@ -92,21 +89,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 Grid _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
@@ -165,32 +149,19 @@ namespace VEPROMS.CSLA.Library
return _UserID;
}
}
// CSLATODO: Replace base GridInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current GridInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check GridInfo.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 GridInfo</returns>
protected override object GetIdValue()
{
return MyGridInfoUnique; // Absolutely Unique ID
}
protected override object GetIdValue() => MyGridInfoUnique; // Absolutely Unique ID
#endregion
#region Factory Methods
private static int _GridInfoUnique = 0;
private static int GridInfoUnique
{ get { return ++_GridInfoUnique; } }
private int _MyGridInfoUnique = GridInfoUnique;
public int MyGridInfoUnique // Absolutely Unique ID - Info
{ get { return _MyGridInfoUnique; } }
private static int GridInfoUnique => ++_GridInfoUnique;
private readonly int _MyGridInfoUnique = GridInfoUnique;
// Absolutely Unique ID - Info
public int MyGridInfoUnique => _MyGridInfoUnique;
protected GridInfo()
{/* require use of factory methods */
AddToCache(this);
@@ -199,15 +170,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;
~GridInfo()
{
_CountFinalized++;
@@ -224,10 +191,7 @@ namespace VEPROMS.CSLA.Library
if (listGridInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
}
public virtual Grid Get()
{
return _Editable = Grid.Get(_ContentID);
}
public virtual Grid Get() => _Editable = Grid.Get(_ContentID);
public static void Refresh(Grid tmp)
{
string key = tmp.ContentID.ToString();
@@ -247,8 +211,6 @@ namespace VEPROMS.CSLA.Library
}
public static GridInfo Get(int contentID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Grid");
try
{
GridInfo tmp = GetCachedByPrimaryKey(contentID);
@@ -287,13 +249,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)
{
@@ -352,7 +310,7 @@ namespace VEPROMS.CSLA.Library
#endregion
// Standard Refresh
#region extension
GridInfoExtension _GridInfoExtension = new GridInfoExtension();
readonly GridInfoExtension _GridInfoExtension = new GridInfoExtension();
[Serializable()]
partial class GridInfoExtension : extensionBase { }
[Serializable()]
@@ -368,10 +326,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 GridInfo)
if (destType == typeof(string) && value is GridInfo info)
{
// Return the ToString value
return ((GridInfo)value).ToString();
return info.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}