CSLA - M through P

This commit is contained in:
2026-09-11 09:50:40 -04:00
parent e41a4ea65d
commit d9f8f6cb37
20 changed files with 1196 additions and 2757 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 PermissionInfo : ReadOnlyBase<PermissionInfo>, IDisposable
{
public event PermissionInfoEvent 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<PermissionInfo> _CacheList = new List<PermissionInfo>();
protected static void AddToCache(PermissionInfo permissionInfo)
{
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
{
while (_CacheList.Contains(permissionInfo)) _CacheList.Remove(permissionInfo); // In RemoveFromCache
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, List<PermissionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<PermissionInfo>>();
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 Permission _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _PID;
[System.ComponentModel.DataObjectField(true, true)]
public int PID
@@ -212,32 +196,19 @@ namespace VEPROMS.CSLA.Library
return _UsrID;
}
}
// CSLATODO: Replace base PermissionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current PermissionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check PermissionInfo.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 PermissionInfo</returns>
protected override object GetIdValue()
{
return MyPermissionInfoUnique; // Absolutely Unique ID
}
protected override object GetIdValue() => MyPermissionInfoUnique; // Absolutely Unique ID
#endregion
#region Factory Methods
private static int _PermissionInfoUnique = 0;
private static int PermissionInfoUnique
{ get { return ++_PermissionInfoUnique; } }
private int _MyPermissionInfoUnique = PermissionInfoUnique;
public int MyPermissionInfoUnique // Absolutely Unique ID - Info
{ get { return _MyPermissionInfoUnique; } }
private static int PermissionInfoUnique => ++_PermissionInfoUnique;
private readonly int _MyPermissionInfoUnique = PermissionInfoUnique;
// Absolutely Unique ID - Info
public int MyPermissionInfoUnique => _MyPermissionInfoUnique;
protected PermissionInfo()
{/* require use of factory methods */
AddToCache(this);
@@ -246,15 +217,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;
~PermissionInfo()
{
_CountFinalized++;
@@ -271,10 +238,7 @@ namespace VEPROMS.CSLA.Library
if (listPermissionInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(PID.ToString()); // remove the list
}
public virtual Permission Get()
{
return _Editable = Permission.Get(_PID);
}
public virtual Permission Get() => _Editable = Permission.Get(_PID);
public static void Refresh(Permission tmp)
{
string key = tmp.PID.ToString();
@@ -287,11 +251,11 @@ namespace VEPROMS.CSLA.Library
{
if (_RID != tmp.RID)
{
if (MyRole != null) MyRole.RefreshRolePermissions(); // Update List for old value
MyRole?.RefreshRolePermissions(); // Update List for old value
_RID = tmp.RID; // Update the value
}
_MyRole = null; // Reset list so that the next line gets a new list
if (MyRole != null) MyRole.RefreshRolePermissions(); // Update List for new value
MyRole?.RefreshRolePermissions(); // Update List for new value
_PermLevel = tmp.PermLevel;
_VersionType = tmp.VersionType;
_PermValue = tmp.PermValue;
@@ -328,8 +292,6 @@ namespace VEPROMS.CSLA.Library
}
public static PermissionInfo Get(int pid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Permission");
try
{
PermissionInfo tmp = GetCachedByPrimaryKey(pid);
@@ -368,13 +330,9 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteria
{
private int _PID;
public int PID
{ get { return _PID; } }
public PKCriteria(int pid)
{
_PID = pid;
}
private readonly int _PID;
public int PID => _PID;
public PKCriteria(int pid) => _PID = pid;
}
private void ReadData(SafeDataReader dr)
{
@@ -439,7 +397,7 @@ namespace VEPROMS.CSLA.Library
#endregion
// Standard Refresh
#region extension
PermissionInfoExtension _PermissionInfoExtension = new PermissionInfoExtension();
readonly PermissionInfoExtension _PermissionInfoExtension = new PermissionInfoExtension();
[Serializable()]
partial class PermissionInfoExtension : extensionBase { }
[Serializable()]
@@ -455,10 +413,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 PermissionInfo)
if (destType == typeof(string) && value is PermissionInfo info)
{
// Return the ToString value
return ((PermissionInfo)value).ToString();
return info.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}