This commit is contained in:
@@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
#region Collection
|
||||
protected static List<MembershipInfo> _AllList = new List<MembershipInfo>();
|
||||
private static Dictionary<string, MembershipInfo> _AllByPrimaryKey = new Dictionary<string, MembershipInfo>();
|
||||
private static Dictionary<string, List<MembershipInfo>> _AllByPrimaryKey = new Dictionary<string, List<MembershipInfo>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<MembershipInfo> remove = new List<MembershipInfo>();
|
||||
foreach (MembershipInfo tmp in _AllList)
|
||||
{
|
||||
_AllByPrimaryKey[tmp.UGID.ToString()]=tmp; // Primary Key
|
||||
if (!_AllByPrimaryKey.ContainsKey(tmp.UGID.ToString()))
|
||||
{
|
||||
_AllByPrimaryKey[tmp.UGID.ToString()] = new List<MembershipInfo>(); // Add new list for PrimaryKey
|
||||
}
|
||||
_AllByPrimaryKey[tmp.UGID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
remove.Add(tmp);
|
||||
}
|
||||
foreach (MembershipInfo tmp in remove)
|
||||
@@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
ConvertListToDictionary();
|
||||
string key = ugid.ToString();
|
||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
|
||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
@@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("UGID",true);
|
||||
CanReadProperty("UGID", true);
|
||||
return _UGID;
|
||||
}
|
||||
}
|
||||
@@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("UID",true);
|
||||
CanReadProperty("UID", true);
|
||||
if (_MyUser != null) _UID = _MyUser.UID;
|
||||
return _UID;
|
||||
}
|
||||
@@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("MyUser",true);
|
||||
CanReadProperty("MyUser", true);
|
||||
if (_MyUser == null && _UID != 0) _MyUser = UserInfo.Get(_UID);
|
||||
return _MyUser;
|
||||
}
|
||||
@@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("GID",true);
|
||||
CanReadProperty("GID", true);
|
||||
if (_MyGroup != null) _GID = _MyGroup.GID;
|
||||
return _GID;
|
||||
}
|
||||
@@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("MyGroup",true);
|
||||
CanReadProperty("MyGroup", true);
|
||||
if (_MyGroup == null && _GID != 0) _MyGroup = GroupInfo.Get(_GID);
|
||||
return _MyGroup;
|
||||
}
|
||||
@@ -139,7 +143,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("StartDate",true);
|
||||
CanReadProperty("StartDate", true);
|
||||
return _StartDate;
|
||||
}
|
||||
}
|
||||
@@ -149,7 +153,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("EndDate",true);
|
||||
CanReadProperty("EndDate", true);
|
||||
return _EndDate;
|
||||
}
|
||||
}
|
||||
@@ -159,7 +163,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("Config",true);
|
||||
CanReadProperty("Config", true);
|
||||
return _Config;
|
||||
}
|
||||
}
|
||||
@@ -169,7 +173,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("DTS",true);
|
||||
CanReadProperty("DTS", true);
|
||||
return _DTS;
|
||||
}
|
||||
}
|
||||
@@ -179,7 +183,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("UsrID",true);
|
||||
CanReadProperty("UsrID", true);
|
||||
return _UsrID;
|
||||
}
|
||||
}
|
||||
@@ -203,14 +207,25 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _MembershipInfoUnique = 0;
|
||||
private int _MyMembershipInfoUnique;
|
||||
public int MyMembershipInfoUnique
|
||||
{
|
||||
get { return _MyMembershipInfoUnique; }
|
||||
}
|
||||
private MembershipInfo()
|
||||
{/* require use of factory methods */
|
||||
_MyMembershipInfoUnique = ++_MembershipInfoUnique;
|
||||
_AllList.Add(this);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
_AllList.Remove(this);
|
||||
_AllByPrimaryKey.Remove(UGID.ToString());
|
||||
if (!_AllByPrimaryKey.ContainsKey(UGID.ToString())) return;
|
||||
List<MembershipInfo> listMembershipInfo = _AllByPrimaryKey[UGID.ToString()]; // Get the list of items
|
||||
listMembershipInfo.Remove(this); // Remove the item from the list
|
||||
if (listMembershipInfo.Count == 0) // If there are no items left in the list
|
||||
_AllByPrimaryKey.Remove(UGID.ToString()); // remove the list
|
||||
}
|
||||
public virtual Membership Get()
|
||||
{
|
||||
@@ -218,9 +233,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(Membership tmp)
|
||||
{
|
||||
MembershipInfo tmpInfo = GetExistingByPrimaryKey(tmp.UGID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.UGID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (MembershipInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(Membership tmp)
|
||||
{
|
||||
@@ -228,16 +245,16 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
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
|
||||
MyUser.RefreshUserMemberships(); // Update List for new value
|
||||
}
|
||||
_MyUser = null; // Reset list so that the next line gets a new list
|
||||
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for new value
|
||||
if (_GID != tmp.GID)
|
||||
{
|
||||
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
|
||||
MyGroup.RefreshGroupMemberships(); // Update List for new value
|
||||
}
|
||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for new value
|
||||
_StartDate = tmp.StartDate;
|
||||
_EndDate = tmp.EndDate;
|
||||
_Config = tmp.Config;
|
||||
@@ -250,9 +267,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(GroupMembership tmp)
|
||||
{
|
||||
MembershipInfo tmpInfo = GetExistingByPrimaryKey(tmp.UGID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.UGID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (MembershipInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(GroupMembership tmp)
|
||||
{
|
||||
@@ -260,9 +279,9 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
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
|
||||
MyUser.RefreshUserMemberships(); // Update List for new value
|
||||
}
|
||||
_MyUser = null; // Reset list so that the next line gets a new list
|
||||
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for new value
|
||||
_StartDate = tmp.StartDate;
|
||||
_EndDate = tmp.EndDate;
|
||||
_Config = tmp.Config;
|
||||
@@ -275,9 +294,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(UserMembership tmp)
|
||||
{
|
||||
MembershipInfo tmpInfo = GetExistingByPrimaryKey(tmp.UGID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.UGID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (MembershipInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(UserMembership tmp)
|
||||
{
|
||||
@@ -285,9 +306,9 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
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
|
||||
MyGroup.RefreshGroupMemberships(); // Update List for new value
|
||||
}
|
||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for new value
|
||||
_StartDate = tmp.StartDate;
|
||||
_EndDate = tmp.EndDate;
|
||||
_Config = tmp.Config;
|
||||
@@ -308,7 +329,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<MembershipInfo>(new PKCriteria(ugid));
|
||||
_AllList.Add(tmp);
|
||||
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
@@ -322,14 +343,15 @@ namespace VEPROMS.CSLA.Library
|
||||
#region Data Access Portal
|
||||
internal MembershipInfo(SafeDataReader dr)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] MembershipInfo.Constructor", GetHashCode());
|
||||
_MyMembershipInfoUnique = ++_MembershipInfoUnique;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.Constructor", GetHashCode());
|
||||
try
|
||||
{
|
||||
ReadData(dr);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("MembershipInfo.Constructor", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.Constructor", ex);
|
||||
throw new DbCslaException("MembershipInfo.Constructor", ex);
|
||||
}
|
||||
}
|
||||
@@ -346,7 +368,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] MembershipInfo.ReadData", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.ReadData", GetHashCode());
|
||||
try
|
||||
{
|
||||
_UGID = dr.GetInt32("UGID");
|
||||
@@ -360,14 +382,14 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("MembershipInfo.ReadData", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.ReadData", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("MembershipInfo.ReadData", ex);
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(PKCriteria criteria)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] MembershipInfo.DataPortal_Fetch", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.DataPortal_Fetch", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
@@ -395,7 +417,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("MembershipInfo.DataPortal_Fetch", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("MembershipInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
@@ -405,7 +427,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#region extension
|
||||
MembershipInfoExtension _MembershipInfoExtension = new MembershipInfoExtension();
|
||||
[Serializable()]
|
||||
partial class MembershipInfoExtension : extensionBase {}
|
||||
partial class MembershipInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
class extensionBase
|
||||
{
|
||||
|
Reference in New Issue
Block a user