CSLA - M through P
This commit is contained in:
@@ -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 MembershipInfo : ReadOnlyBase<MembershipInfo>, IDisposable
|
||||
{
|
||||
public event MembershipInfoEvent 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<MembershipInfo> _CacheList = new List<MembershipInfo>();
|
||||
protected static void AddToCache(MembershipInfo membershipInfo)
|
||||
{
|
||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
while (_CacheList.Contains(membershipInfo)) _CacheList.Remove(membershipInfo); // In RemoveFromCache
|
||||
}
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static Dictionary<string, List<MembershipInfo>> _CacheByPrimaryKey = new Dictionary<string, List<MembershipInfo>>();
|
||||
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 Membership _Editable;
|
||||
private IVEHasBrokenRules HasBrokenRules
|
||||
{
|
||||
get
|
||||
{
|
||||
IVEHasBrokenRules hasBrokenRules = null;
|
||||
if (_Editable != null)
|
||||
hasBrokenRules = _Editable.HasBrokenRules;
|
||||
return hasBrokenRules;
|
||||
}
|
||||
}
|
||||
private int _UGID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public int UGID
|
||||
@@ -202,32 +186,19 @@ namespace VEPROMS.CSLA.Library
|
||||
return _UsrID;
|
||||
}
|
||||
}
|
||||
// CSLATODO: Replace base MembershipInfo.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current MembershipInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// CSLATODO: Check MembershipInfo.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 MembershipInfo</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return MyMembershipInfoUnique; // Absolutely Unique ID
|
||||
}
|
||||
protected override object GetIdValue() => MyMembershipInfoUnique; // Absolutely Unique ID
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _MembershipInfoUnique = 0;
|
||||
private static int MembershipInfoUnique
|
||||
{ get { return ++_MembershipInfoUnique; } }
|
||||
private int _MyMembershipInfoUnique = MembershipInfoUnique;
|
||||
public int MyMembershipInfoUnique // Absolutely Unique ID - Info
|
||||
{ get { return _MyMembershipInfoUnique; } }
|
||||
private static int MembershipInfoUnique => ++_MembershipInfoUnique;
|
||||
private readonly int _MyMembershipInfoUnique = MembershipInfoUnique;
|
||||
// Absolutely Unique ID - Info
|
||||
public int MyMembershipInfoUnique => _MyMembershipInfoUnique;
|
||||
protected MembershipInfo()
|
||||
{/* require use of factory methods */
|
||||
AddToCache(this);
|
||||
@@ -236,15 +207,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;
|
||||
~MembershipInfo()
|
||||
{
|
||||
_CountFinalized++;
|
||||
@@ -261,10 +228,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (listMembershipInfo.Count == 0) // If there are no items left in the list
|
||||
_CacheByPrimaryKey.Remove(UGID.ToString()); // remove the list
|
||||
}
|
||||
public virtual Membership Get()
|
||||
{
|
||||
return _Editable = Membership.Get(_UGID);
|
||||
}
|
||||
public virtual Membership Get() => _Editable = Membership.Get(_UGID);
|
||||
public static void Refresh(Membership tmp)
|
||||
{
|
||||
string key = tmp.UGID.ToString();
|
||||
@@ -277,18 +241,18 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_UID != tmp.UID)
|
||||
{
|
||||
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for old value
|
||||
MyUser?.RefreshUserMemberships(); // Update List for old value
|
||||
_UID = tmp.UID; // Update the value
|
||||
}
|
||||
_MyUser = null; // Reset list so that the next line gets a new list
|
||||
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for new value
|
||||
MyUser?.RefreshUserMemberships(); // Update List for new value
|
||||
if (_GID != tmp.GID)
|
||||
{
|
||||
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for old value
|
||||
MyGroup?.RefreshGroupMemberships(); // Update List for old value
|
||||
_GID = tmp.GID; // Update the value
|
||||
}
|
||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for new value
|
||||
MyGroup?.RefreshGroupMemberships(); // Update List for new value
|
||||
_StartDate = tmp.StartDate;
|
||||
_EndDate = tmp.EndDate;
|
||||
_Config = tmp.Config;
|
||||
@@ -309,11 +273,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_UID != tmp.UID)
|
||||
{
|
||||
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for old value
|
||||
MyUser?.RefreshUserMemberships(); // Update List for old value
|
||||
_UID = tmp.UID; // Update the value
|
||||
}
|
||||
_MyUser = null; // Reset list so that the next line gets a new list
|
||||
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for new value
|
||||
MyUser?.RefreshUserMemberships(); // Update List for new value
|
||||
_StartDate = tmp.StartDate;
|
||||
_EndDate = tmp.EndDate;
|
||||
_Config = tmp.Config;
|
||||
@@ -334,11 +298,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_GID != tmp.GID)
|
||||
{
|
||||
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for old value
|
||||
MyGroup?.RefreshGroupMemberships(); // Update List for old value
|
||||
_GID = tmp.GID; // Update the value
|
||||
}
|
||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for new value
|
||||
MyGroup?.RefreshGroupMemberships(); // Update List for new value
|
||||
_StartDate = tmp.StartDate;
|
||||
_EndDate = tmp.EndDate;
|
||||
_Config = tmp.Config;
|
||||
@@ -349,8 +313,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static MembershipInfo Get(int ugid)
|
||||
{
|
||||
//if (!CanGetObject())
|
||||
// throw new System.Security.SecurityException("User not authorized to view a Membership");
|
||||
try
|
||||
{
|
||||
MembershipInfo tmp = GetCachedByPrimaryKey(ugid);
|
||||
@@ -389,13 +351,9 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
protected class PKCriteria
|
||||
{
|
||||
private int _UGID;
|
||||
public int UGID
|
||||
{ get { return _UGID; } }
|
||||
public PKCriteria(int ugid)
|
||||
{
|
||||
_UGID = ugid;
|
||||
}
|
||||
private readonly int _UGID;
|
||||
public int UGID => _UGID;
|
||||
public PKCriteria(int ugid) => _UGID = ugid;
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
@@ -457,7 +415,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
// Standard Refresh
|
||||
#region extension
|
||||
MembershipInfoExtension _MembershipInfoExtension = new MembershipInfoExtension();
|
||||
readonly MembershipInfoExtension _MembershipInfoExtension = new MembershipInfoExtension();
|
||||
[Serializable()]
|
||||
partial class MembershipInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
@@ -473,10 +431,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 MembershipInfo)
|
||||
if (destType == typeof(string) && value is MembershipInfo info)
|
||||
{
|
||||
// Return the ToString value
|
||||
return ((MembershipInfo)value).ToString();
|
||||
return info.ToString();
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user