This commit is contained in:
Kathy Ruffing 2008-08-12 11:42:50 +00:00
parent dfafac5a3a
commit d81b4d8af0
19 changed files with 941 additions and 569 deletions

View File

@ -53,28 +53,36 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region Collection
protected static List<Membership> _AllList = new List<Membership>();
private static Dictionary<string, List<Membership>> _AllByPrimaryKey = new Dictionary<string, List<Membership>>();
private static List<Membership> _CacheList = new List<Membership>();
protected static void AddToCache(Membership membership)
{
if (!_CacheList.Contains(membership)) _CacheList.Add(membership); // In AddToCache
}
protected static void RemoveFromCache(Membership membership)
{
while (_CacheList.Contains(membership)) _CacheList.Remove(membership); // In RemoveFromCache
}
private static Dictionary<string, List<Membership>> _CacheByPrimaryKey = new Dictionary<string, List<Membership>>();
private static void ConvertListToDictionary()
{
List<Membership> remove = new List<Membership>();
foreach (Membership tmp in _AllList)
foreach (Membership tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.UGID.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.UGID.ToString()))
{
_AllByPrimaryKey[tmp.UGID.ToString()] = new List<Membership>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[tmp.UGID.ToString()] = new List<Membership>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.UGID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[tmp.UGID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (Membership tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
public static Membership GetExistingByPrimaryKey(int ugid)
protected static Membership GetCachedByPrimaryKey(int ugid)
{
ConvertListToDictionary();
string key = ugid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
@ -484,24 +492,29 @@ namespace VEPROMS.CSLA.Library
public int CurrentEditLevel
{ get { return EditLevel; } }
private static int _MembershipUnique = 0;
private int _MyMembershipUnique;
protected static int MembershipUnique
{ get { return ++_MembershipUnique; } }
private int _MyMembershipUnique = MembershipUnique;
public int MyMembershipUnique
{
get { return _MyMembershipUnique; }
}
{ get { return _MyMembershipUnique; } }
protected Membership()
{/* require use of factory methods */
_MyMembershipUnique = ++_MembershipUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
if (!_AllByPrimaryKey.ContainsKey(UGID.ToString())) return;
List<Membership> listMembership = _AllByPrimaryKey[UGID.ToString()]; // Get the list of items
listMembership.Remove(this); // Remove the item from the list
if (listMembership.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(UGID.ToString()); // remove the list
RemoveFromDictionaries();
}
private void RemoveFromDictionaries()
{
RemoveFromCache(this);
if (_CacheByPrimaryKey.ContainsKey(UGID.ToString()))
{
List<Membership> listMembership = _CacheByPrimaryKey[UGID.ToString()]; // Get the list of items
while (listMembership.Contains(this)) listMembership.Remove(this); // Remove the item from the list
if (listMembership.Count == 0) //If there are no items left in the list
_CacheByPrimaryKey.Remove(UGID.ToString()); // remove the list
}
}
public static Membership New()
{
@ -539,7 +552,11 @@ namespace VEPROMS.CSLA.Library
{
Membership tmp = Membership.New(myUser, myGroup, startDate, endDate, config, dts, usrID);
if (tmp.IsSavable)
tmp = tmp.Save();
{
Membership tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
@ -564,7 +581,11 @@ namespace VEPROMS.CSLA.Library
{
Membership tmp = Membership.New(myUser, myGroup, endDate, config);
if (tmp.IsSavable)
tmp = tmp.Save();
{
Membership tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
@ -582,13 +603,17 @@ namespace VEPROMS.CSLA.Library
throw new System.Security.SecurityException("User not authorized to view a Membership");
try
{
Membership tmp = GetExistingByPrimaryKey(ugid);
Membership tmp = GetCachedByPrimaryKey(ugid);
if (tmp == null)
{
tmp = DataPortal.Fetch<Membership>(new PKCriteria(ugid));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up Membership
tmp = null;
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
@ -630,7 +655,8 @@ namespace VEPROMS.CSLA.Library
{
BuildRefreshList();
Membership membership = base.Save();
_AllList.Add(membership);//Refresh the item in AllList
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(membership);//Refresh the item in AllList
ProcessRefreshList();
return membership;
}

View File

@ -36,32 +36,40 @@ namespace VEPROMS.CSLA.Library
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
protected static List<MembershipInfo> _AllList = new List<MembershipInfo>();
private static Dictionary<string, List<MembershipInfo>> _AllByPrimaryKey = new Dictionary<string, List<MembershipInfo>>();
private static List<MembershipInfo> _CacheList = new List<MembershipInfo>();
protected static void AddToCache(MembershipInfo membershipInfo)
{
if (!_CacheList.Contains(membershipInfo)) _CacheList.Add(membershipInfo); // In AddToCache
}
protected static void RemoveFromCache(MembershipInfo membershipInfo)
{
while (_CacheList.Contains(membershipInfo)) _CacheList.Remove(membershipInfo); // In RemoveFromCache
}
private static Dictionary<string, List<MembershipInfo>> _CacheByPrimaryKey = new Dictionary<string, List<MembershipInfo>>();
private static void ConvertListToDictionary()
{
List<MembershipInfo> remove = new List<MembershipInfo>();
foreach (MembershipInfo tmp in _AllList)
foreach (MembershipInfo tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.UGID.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.UGID.ToString()))
{
_AllByPrimaryKey[tmp.UGID.ToString()] = new List<MembershipInfo>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[tmp.UGID.ToString()] = new List<MembershipInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.UGID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[tmp.UGID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (MembershipInfo tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
internal static void AddList(MembershipInfoList lst)
{
foreach (MembershipInfo item in lst) _AllList.Add(item);
foreach (MembershipInfo item in lst) AddToCache(item);
}
public static MembershipInfo GetExistingByPrimaryKey(int ugid)
protected static MembershipInfo GetCachedByPrimaryKey(int ugid)
{
ConvertListToDictionary();
string key = ugid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
@ -208,24 +216,23 @@ namespace VEPROMS.CSLA.Library
#endregion
#region Factory Methods
private static int _MembershipInfoUnique = 0;
private int _MyMembershipInfoUnique;
private static int MembershipInfoUnique
{ get { return ++_MembershipInfoUnique; } }
private int _MyMembershipInfoUnique = MembershipInfoUnique;
public int MyMembershipInfoUnique
{
get { return _MyMembershipInfoUnique; }
}
private MembershipInfo()
{ get { return _MyMembershipInfoUnique; } }
protected MembershipInfo()
{/* require use of factory methods */
_MyMembershipInfoUnique = ++_MembershipInfoUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
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
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(UGID.ToString())) return;
List<MembershipInfo> listMembershipInfo = _CacheByPrimaryKey[UGID.ToString()]; // Get the list of items
while (listMembershipInfo.Contains(this)) 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
_CacheByPrimaryKey.Remove(UGID.ToString()); // remove the list
}
public virtual Membership Get()
{
@ -235,22 +242,22 @@ namespace VEPROMS.CSLA.Library
{
string key = tmp.UGID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (MembershipInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (MembershipInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Membership tmp)
protected virtual void RefreshFields(Membership tmp)
{
if (_UID != tmp.UID)
{
MyUser.RefreshUserMemberships(); // Update List for old value
if (MyUser != null) 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
if (_GID != tmp.GID)
{
MyGroup.RefreshGroupMemberships(); // Update List for old value
if (MyGroup != null) 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
@ -269,15 +276,15 @@ namespace VEPROMS.CSLA.Library
{
string key = tmp.UGID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (MembershipInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (MembershipInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(GroupMembership tmp)
protected virtual void RefreshFields(GroupMembership tmp)
{
if (_UID != tmp.UID)
{
MyUser.RefreshUserMemberships(); // Update List for old value
if (MyUser != null) 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
@ -296,15 +303,15 @@ namespace VEPROMS.CSLA.Library
{
string key = tmp.UGID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (MembershipInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (MembershipInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(UserMembership tmp)
protected virtual void RefreshFields(UserMembership tmp)
{
if (_GID != tmp.GID)
{
MyGroup.RefreshGroupMemberships(); // Update List for old value
if (MyGroup != null) 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
@ -325,13 +332,17 @@ namespace VEPROMS.CSLA.Library
// throw new System.Security.SecurityException("User not authorized to view a Membership");
try
{
MembershipInfo tmp = GetExistingByPrimaryKey(ugid);
MembershipInfo tmp = GetCachedByPrimaryKey(ugid);
if (tmp == null)
{
tmp = DataPortal.Fetch<MembershipInfo>(new PKCriteria(ugid));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up MembershipInfo
tmp = null;
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
@ -343,7 +354,6 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal
internal MembershipInfo(SafeDataReader dr)
{
_MyMembershipInfoUnique = ++_MembershipInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.Constructor", GetHashCode());
try
{

View File

@ -53,28 +53,36 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region Collection
protected static List<Part> _AllList = new List<Part>();
private static Dictionary<string, List<Part>> _AllByPrimaryKey = new Dictionary<string, List<Part>>();
private static List<Part> _CacheList = new List<Part>();
protected static void AddToCache(Part part)
{
if (!_CacheList.Contains(part)) _CacheList.Add(part); // In AddToCache
}
protected static void RemoveFromCache(Part part)
{
while (_CacheList.Contains(part)) _CacheList.Remove(part); // In RemoveFromCache
}
private static Dictionary<string, List<Part>> _CacheByPrimaryKey = new Dictionary<string, List<Part>>();
private static void ConvertListToDictionary()
{
List<Part> remove = new List<Part>();
foreach (Part tmp in _AllList)
foreach (Part tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()))
{
_AllByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()] = new List<Part>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()] = new List<Part>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (Part tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
public static Part GetExistingByPrimaryKey(int contentID, int fromType)
protected static Part GetCachedByPrimaryKey(int contentID, int fromType)
{
ConvertListToDictionary();
string key = contentID.ToString() + "_" + fromType.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
@ -339,24 +347,29 @@ namespace VEPROMS.CSLA.Library
public int CurrentEditLevel
{ get { return EditLevel; } }
private static int _PartUnique = 0;
private int _MyPartUnique;
protected static int PartUnique
{ get { return ++_PartUnique; } }
private int _MyPartUnique = PartUnique;
public int MyPartUnique
{
get { return _MyPartUnique; }
}
{ get { return _MyPartUnique; } }
protected Part()
{/* require use of factory methods */
_MyPartUnique = ++_PartUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString() + "_" + FromType.ToString())) return;
List<Part> listPart = _AllByPrimaryKey[ContentID.ToString() + "_" + FromType.ToString()]; // Get the list of items
listPart.Remove(this); // Remove the item from the list
if (listPart.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(ContentID.ToString() + "_" + FromType.ToString()); // remove the list
RemoveFromDictionaries();
}
private void RemoveFromDictionaries()
{
RemoveFromCache(this);
if (_CacheByPrimaryKey.ContainsKey(ContentID.ToString() + "_" + FromType.ToString()))
{
List<Part> listPart = _CacheByPrimaryKey[ContentID.ToString() + "_" + FromType.ToString()]; // Get the list of items
while (listPart.Contains(this)) listPart.Remove(this); // Remove the item from the list
if (listPart.Count == 0) //If there are no items left in the list
_CacheByPrimaryKey.Remove(ContentID.ToString() + "_" + FromType.ToString()); // remove the list
}
}
public static Part New()
{
@ -379,6 +392,26 @@ namespace VEPROMS.CSLA.Library
tmp.MyItem = myItem;
return tmp;
}
public static Part MakePart(Content myContent, int fromType, Item myItem)
{
Part tmp = Part.New(myContent, fromType, myItem);
if (tmp.IsSavable)
{
Part tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
tmp._ErrorMessage = "Failed Validation:";
foreach (Csla.Validation.BrokenRule br in brc)
{
tmp._ErrorMessage += "\r\n\tFailure: " + br.RuleName;
}
}
return tmp;
}
public static Part New(Content myContent, int fromType, Item myItem, DateTime dts, string userID)
{
Part tmp = Part.New();
@ -393,7 +426,11 @@ namespace VEPROMS.CSLA.Library
{
Part tmp = Part.New(myContent, fromType, myItem, dts, userID);
if (tmp.IsSavable)
tmp = tmp.Save();
{
Part tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
@ -411,13 +448,17 @@ namespace VEPROMS.CSLA.Library
throw new System.Security.SecurityException("User not authorized to view a Part");
try
{
Part tmp = GetExistingByPrimaryKey(contentID, fromType);
Part tmp = GetCachedByPrimaryKey(contentID, fromType);
if (tmp == null)
{
tmp = DataPortal.Fetch<Part>(new PKCriteria(contentID, fromType));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up Part
tmp = null;
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
@ -459,7 +500,8 @@ namespace VEPROMS.CSLA.Library
{
BuildRefreshList();
Part part = base.Save();
_AllList.Add(part);//Refresh the item in AllList
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(part);//Refresh the item in AllList
ProcessRefreshList();
return part;
}

View File

@ -36,32 +36,40 @@ namespace VEPROMS.CSLA.Library
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
protected static List<PartInfo> _AllList = new List<PartInfo>();
private static Dictionary<string, List<PartInfo>> _AllByPrimaryKey = new Dictionary<string, List<PartInfo>>();
private static List<PartInfo> _CacheList = new List<PartInfo>();
protected static void AddToCache(PartInfo partInfo)
{
if (!_CacheList.Contains(partInfo)) _CacheList.Add(partInfo); // In AddToCache
}
protected static void RemoveFromCache(PartInfo partInfo)
{
while (_CacheList.Contains(partInfo)) _CacheList.Remove(partInfo); // In RemoveFromCache
}
private static Dictionary<string, List<PartInfo>> _CacheByPrimaryKey = new Dictionary<string, List<PartInfo>>();
private static void ConvertListToDictionary()
{
List<PartInfo> remove = new List<PartInfo>();
foreach (PartInfo tmp in _AllList)
foreach (PartInfo tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()))
{
_AllByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()] = new List<PartInfo>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()] = new List<PartInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (PartInfo tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
internal static void AddList(PartInfoList lst)
{
foreach (PartInfo item in lst) _AllList.Add(item);
foreach (PartInfo item in lst) AddToCache(item);
}
public static PartInfo GetExistingByPrimaryKey(int contentID, int fromType)
protected static PartInfo GetCachedByPrimaryKey(int contentID, int fromType)
{
ConvertListToDictionary();
string key = contentID.ToString() + "_" + fromType.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
@ -180,24 +188,23 @@ namespace VEPROMS.CSLA.Library
#endregion
#region Factory Methods
private static int _PartInfoUnique = 0;
private int _MyPartInfoUnique;
private static int PartInfoUnique
{ get { return ++_PartInfoUnique; } }
private int _MyPartInfoUnique = PartInfoUnique;
public int MyPartInfoUnique
{
get { return _MyPartInfoUnique; }
}
private PartInfo()
{ get { return _MyPartInfoUnique; } }
protected PartInfo()
{/* require use of factory methods */
_MyPartInfoUnique = ++_PartInfoUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString() + "_" + FromType.ToString())) return;
List<PartInfo> listPartInfo = _AllByPrimaryKey[ContentID.ToString() + "_" + FromType.ToString()]; // Get the list of items
listPartInfo.Remove(this); // Remove the item from the list
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString() + "_" + FromType.ToString())) return;
List<PartInfo> listPartInfo = _CacheByPrimaryKey[ContentID.ToString() + "_" + FromType.ToString()]; // Get the list of items
while (listPartInfo.Contains(this)) listPartInfo.Remove(this); // Remove the item from the list
if (listPartInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(ContentID.ToString() + "_" + FromType.ToString()); // remove the list
_CacheByPrimaryKey.Remove(ContentID.ToString() + "_" + FromType.ToString()); // remove the list
}
public virtual Part Get()
{
@ -207,15 +214,15 @@ namespace VEPROMS.CSLA.Library
{
string key = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (PartInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (PartInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Part tmp)
protected virtual void RefreshFields(Part tmp)
{
if (_ItemID != tmp.ItemID)
{
MyItem.RefreshItemParts(); // Update List for old value
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value
}
_MyItem = null; // Reset list so that the next line gets a new list
@ -231,15 +238,15 @@ namespace VEPROMS.CSLA.Library
{
string key = myContent.ContentID.ToString() + "_" + tmp.FromType.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (PartInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (PartInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ContentPart tmp)
protected virtual void RefreshFields(ContentPart tmp)
{
if (_ItemID != tmp.ItemID)
{
MyItem.RefreshItemParts(); // Update List for old value
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value
}
_MyItem = null; // Reset list so that the next line gets a new list
@ -255,11 +262,11 @@ namespace VEPROMS.CSLA.Library
{
string key = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (PartInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (PartInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ItemPart tmp)
protected virtual void RefreshFields(ItemPart tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
@ -274,13 +281,17 @@ namespace VEPROMS.CSLA.Library
// throw new System.Security.SecurityException("User not authorized to view a Part");
try
{
PartInfo tmp = GetExistingByPrimaryKey(contentID, fromType);
PartInfo tmp = GetCachedByPrimaryKey(contentID, fromType);
if (tmp == null)
{
tmp = DataPortal.Fetch<PartInfo>(new PKCriteria(contentID, fromType));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up PartInfo
tmp = null;
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
@ -292,7 +303,6 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal
internal PartInfo(SafeDataReader dr)
{
_MyPartInfoUnique = ++_PartInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.Constructor", GetHashCode());
try
{

View File

@ -52,28 +52,36 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region Collection
protected static List<Permission> _AllList = new List<Permission>();
private static Dictionary<string, List<Permission>> _AllByPrimaryKey = new Dictionary<string, List<Permission>>();
private static List<Permission> _CacheList = new List<Permission>();
protected static void AddToCache(Permission permission)
{
if (!_CacheList.Contains(permission)) _CacheList.Add(permission); // In AddToCache
}
protected static void RemoveFromCache(Permission permission)
{
while (_CacheList.Contains(permission)) _CacheList.Remove(permission); // In RemoveFromCache
}
private static Dictionary<string, List<Permission>> _CacheByPrimaryKey = new Dictionary<string, List<Permission>>();
private static void ConvertListToDictionary()
{
List<Permission> remove = new List<Permission>();
foreach (Permission tmp in _AllList)
foreach (Permission tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.PID.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.PID.ToString()))
{
_AllByPrimaryKey[tmp.PID.ToString()] = new List<Permission>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[tmp.PID.ToString()] = new List<Permission>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.PID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[tmp.PID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (Permission tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
public static Permission GetExistingByPrimaryKey(int pid)
protected static Permission GetCachedByPrimaryKey(int pid)
{
ConvertListToDictionary();
string key = pid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
@ -538,24 +546,29 @@ namespace VEPROMS.CSLA.Library
public int CurrentEditLevel
{ get { return EditLevel; } }
private static int _PermissionUnique = 0;
private int _MyPermissionUnique;
protected static int PermissionUnique
{ get { return ++_PermissionUnique; } }
private int _MyPermissionUnique = PermissionUnique;
public int MyPermissionUnique
{
get { return _MyPermissionUnique; }
}
{ get { return _MyPermissionUnique; } }
protected Permission()
{/* require use of factory methods */
_MyPermissionUnique = ++_PermissionUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
if (!_AllByPrimaryKey.ContainsKey(PID.ToString())) return;
List<Permission> listPermission = _AllByPrimaryKey[PID.ToString()]; // Get the list of items
listPermission.Remove(this); // Remove the item from the list
if (listPermission.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(PID.ToString()); // remove the list
RemoveFromDictionaries();
}
private void RemoveFromDictionaries()
{
RemoveFromCache(this);
if (_CacheByPrimaryKey.ContainsKey(PID.ToString()))
{
List<Permission> listPermission = _CacheByPrimaryKey[PID.ToString()]; // Get the list of items
while (listPermission.Contains(this)) listPermission.Remove(this); // Remove the item from the list
if (listPermission.Count == 0) //If there are no items left in the list
_CacheByPrimaryKey.Remove(PID.ToString()); // remove the list
}
}
public static Permission New()
{
@ -598,7 +611,11 @@ namespace VEPROMS.CSLA.Library
{
Permission tmp = Permission.New(myRole, permLevel, versionType, permValue, permAD, startDate, endDate, config, dts, usrID);
if (tmp.IsSavable)
tmp = tmp.Save();
{
Permission tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
@ -625,7 +642,11 @@ namespace VEPROMS.CSLA.Library
{
Permission tmp = Permission.New(myRole, permLevel, versionType, permValue, endDate, config);
if (tmp.IsSavable)
tmp = tmp.Save();
{
Permission tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
@ -643,13 +664,17 @@ namespace VEPROMS.CSLA.Library
throw new System.Security.SecurityException("User not authorized to view a Permission");
try
{
Permission tmp = GetExistingByPrimaryKey(pid);
Permission tmp = GetCachedByPrimaryKey(pid);
if (tmp == null)
{
tmp = DataPortal.Fetch<Permission>(new PKCriteria(pid));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up Permission
tmp = null;
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
@ -691,7 +716,8 @@ namespace VEPROMS.CSLA.Library
{
BuildRefreshList();
Permission permission = base.Save();
_AllList.Add(permission);//Refresh the item in AllList
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(permission);//Refresh the item in AllList
ProcessRefreshList();
return permission;
}

View File

@ -36,32 +36,40 @@ namespace VEPROMS.CSLA.Library
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
protected static List<PermissionInfo> _AllList = new List<PermissionInfo>();
private static Dictionary<string, List<PermissionInfo>> _AllByPrimaryKey = new Dictionary<string, List<PermissionInfo>>();
private static List<PermissionInfo> _CacheList = new List<PermissionInfo>();
protected static void AddToCache(PermissionInfo permissionInfo)
{
if (!_CacheList.Contains(permissionInfo)) _CacheList.Add(permissionInfo); // In AddToCache
}
protected static void RemoveFromCache(PermissionInfo permissionInfo)
{
while (_CacheList.Contains(permissionInfo)) _CacheList.Remove(permissionInfo); // In RemoveFromCache
}
private static Dictionary<string, List<PermissionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<PermissionInfo>>();
private static void ConvertListToDictionary()
{
List<PermissionInfo> remove = new List<PermissionInfo>();
foreach (PermissionInfo tmp in _AllList)
foreach (PermissionInfo tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.PID.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.PID.ToString()))
{
_AllByPrimaryKey[tmp.PID.ToString()] = new List<PermissionInfo>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[tmp.PID.ToString()] = new List<PermissionInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.PID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[tmp.PID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (PermissionInfo tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
internal static void AddList(PermissionInfoList lst)
{
foreach (PermissionInfo item in lst) _AllList.Add(item);
foreach (PermissionInfo item in lst) AddToCache(item);
}
public static PermissionInfo GetExistingByPrimaryKey(int pid)
protected static PermissionInfo GetCachedByPrimaryKey(int pid)
{
ConvertListToDictionary();
string key = pid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
@ -238,24 +246,23 @@ namespace VEPROMS.CSLA.Library
#endregion
#region Factory Methods
private static int _PermissionInfoUnique = 0;
private int _MyPermissionInfoUnique;
private static int PermissionInfoUnique
{ get { return ++_PermissionInfoUnique; } }
private int _MyPermissionInfoUnique = PermissionInfoUnique;
public int MyPermissionInfoUnique
{
get { return _MyPermissionInfoUnique; }
}
private PermissionInfo()
{ get { return _MyPermissionInfoUnique; } }
protected PermissionInfo()
{/* require use of factory methods */
_MyPermissionInfoUnique = ++_PermissionInfoUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
if (!_AllByPrimaryKey.ContainsKey(PID.ToString())) return;
List<PermissionInfo> listPermissionInfo = _AllByPrimaryKey[PID.ToString()]; // Get the list of items
listPermissionInfo.Remove(this); // Remove the item from the list
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(PID.ToString())) return;
List<PermissionInfo> listPermissionInfo = _CacheByPrimaryKey[PID.ToString()]; // Get the list of items
while (listPermissionInfo.Contains(this)) listPermissionInfo.Remove(this); // Remove the item from the list
if (listPermissionInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(PID.ToString()); // remove the list
_CacheByPrimaryKey.Remove(PID.ToString()); // remove the list
}
public virtual Permission Get()
{
@ -265,15 +272,15 @@ namespace VEPROMS.CSLA.Library
{
string key = tmp.PID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (PermissionInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (PermissionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Permission tmp)
protected virtual void RefreshFields(Permission tmp)
{
if (_RID != tmp.RID)
{
MyRole.RefreshRolePermissions(); // Update List for old value
if (MyRole != null) 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
@ -295,11 +302,11 @@ namespace VEPROMS.CSLA.Library
{
string key = tmp.PID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (PermissionInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (PermissionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(RolePermission tmp)
protected virtual void RefreshFields(RolePermission tmp)
{
_PermLevel = tmp.PermLevel;
_VersionType = tmp.VersionType;
@ -320,13 +327,17 @@ namespace VEPROMS.CSLA.Library
// throw new System.Security.SecurityException("User not authorized to view a Permission");
try
{
PermissionInfo tmp = GetExistingByPrimaryKey(pid);
PermissionInfo tmp = GetCachedByPrimaryKey(pid);
if (tmp == null)
{
tmp = DataPortal.Fetch<PermissionInfo>(new PKCriteria(pid));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up PermissionInfo
tmp = null;
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
@ -338,7 +349,6 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal
internal PermissionInfo(SafeDataReader dr)
{
_MyPermissionInfoUnique = ++_PermissionInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PermissionInfo.Constructor", GetHashCode());
try
{

View File

@ -52,28 +52,36 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region Collection
protected static List<RoUsage> _AllList = new List<RoUsage>();
private static Dictionary<string, List<RoUsage>> _AllByPrimaryKey = new Dictionary<string, List<RoUsage>>();
private static List<RoUsage> _CacheList = new List<RoUsage>();
protected static void AddToCache(RoUsage roUsage)
{
if (!_CacheList.Contains(roUsage)) _CacheList.Add(roUsage); // In AddToCache
}
protected static void RemoveFromCache(RoUsage roUsage)
{
while (_CacheList.Contains(roUsage)) _CacheList.Remove(roUsage); // In RemoveFromCache
}
private static Dictionary<string, List<RoUsage>> _CacheByPrimaryKey = new Dictionary<string, List<RoUsage>>();
private static void ConvertListToDictionary()
{
List<RoUsage> remove = new List<RoUsage>();
foreach (RoUsage tmp in _AllList)
foreach (RoUsage tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.ROUsageID.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.ROUsageID.ToString()))
{
_AllByPrimaryKey[tmp.ROUsageID.ToString()] = new List<RoUsage>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[tmp.ROUsageID.ToString()] = new List<RoUsage>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.ROUsageID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[tmp.ROUsageID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (RoUsage tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
public static RoUsage GetExistingByPrimaryKey(int rOUsageID)
protected static RoUsage GetCachedByPrimaryKey(int rOUsageID)
{
ConvertListToDictionary();
string key = rOUsageID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
@ -372,24 +380,29 @@ namespace VEPROMS.CSLA.Library
public int CurrentEditLevel
{ get { return EditLevel; } }
private static int _RoUsageUnique = 0;
private int _MyRoUsageUnique;
protected static int RoUsageUnique
{ get { return ++_RoUsageUnique; } }
private int _MyRoUsageUnique = RoUsageUnique;
public int MyRoUsageUnique
{
get { return _MyRoUsageUnique; }
}
{ get { return _MyRoUsageUnique; } }
protected RoUsage()
{/* require use of factory methods */
_MyRoUsageUnique = ++_RoUsageUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
if (!_AllByPrimaryKey.ContainsKey(ROUsageID.ToString())) return;
List<RoUsage> listRoUsage = _AllByPrimaryKey[ROUsageID.ToString()]; // Get the list of items
listRoUsage.Remove(this); // Remove the item from the list
if (listRoUsage.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(ROUsageID.ToString()); // remove the list
RemoveFromDictionaries();
}
private void RemoveFromDictionaries()
{
RemoveFromCache(this);
if (_CacheByPrimaryKey.ContainsKey(ROUsageID.ToString()))
{
List<RoUsage> listRoUsage = _CacheByPrimaryKey[ROUsageID.ToString()]; // Get the list of items
while (listRoUsage.Contains(this)) listRoUsage.Remove(this); // Remove the item from the list
if (listRoUsage.Count == 0) //If there are no items left in the list
_CacheByPrimaryKey.Remove(ROUsageID.ToString()); // remove the list
}
}
public static RoUsage New()
{
@ -424,7 +437,11 @@ namespace VEPROMS.CSLA.Library
{
RoUsage tmp = RoUsage.New(myContent, roid, config, dts, userID);
if (tmp.IsSavable)
tmp = tmp.Save();
{
RoUsage tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
@ -448,7 +465,11 @@ namespace VEPROMS.CSLA.Library
{
RoUsage tmp = RoUsage.New(myContent, roid, config);
if (tmp.IsSavable)
tmp = tmp.Save();
{
RoUsage tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
@ -466,13 +487,17 @@ namespace VEPROMS.CSLA.Library
throw new System.Security.SecurityException("User not authorized to view a RoUsage");
try
{
RoUsage tmp = GetExistingByPrimaryKey(rOUsageID);
RoUsage tmp = GetCachedByPrimaryKey(rOUsageID);
if (tmp == null)
{
tmp = DataPortal.Fetch<RoUsage>(new PKCriteria(rOUsageID));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up RoUsage
tmp = null;
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
@ -514,7 +539,8 @@ namespace VEPROMS.CSLA.Library
{
BuildRefreshList();
RoUsage roUsage = base.Save();
_AllList.Add(roUsage);//Refresh the item in AllList
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(roUsage);//Refresh the item in AllList
ProcessRefreshList();
return roUsage;
}

View File

@ -36,32 +36,40 @@ namespace VEPROMS.CSLA.Library
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
protected static List<RoUsageInfo> _AllList = new List<RoUsageInfo>();
private static Dictionary<string, List<RoUsageInfo>> _AllByPrimaryKey = new Dictionary<string, List<RoUsageInfo>>();
private static List<RoUsageInfo> _CacheList = new List<RoUsageInfo>();
protected static void AddToCache(RoUsageInfo roUsageInfo)
{
if (!_CacheList.Contains(roUsageInfo)) _CacheList.Add(roUsageInfo); // In AddToCache
}
protected static void RemoveFromCache(RoUsageInfo roUsageInfo)
{
while (_CacheList.Contains(roUsageInfo)) _CacheList.Remove(roUsageInfo); // In RemoveFromCache
}
private static Dictionary<string, List<RoUsageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<RoUsageInfo>>();
private static void ConvertListToDictionary()
{
List<RoUsageInfo> remove = new List<RoUsageInfo>();
foreach (RoUsageInfo tmp in _AllList)
foreach (RoUsageInfo tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.ROUsageID.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.ROUsageID.ToString()))
{
_AllByPrimaryKey[tmp.ROUsageID.ToString()] = new List<RoUsageInfo>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[tmp.ROUsageID.ToString()] = new List<RoUsageInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.ROUsageID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[tmp.ROUsageID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (RoUsageInfo tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
internal static void AddList(RoUsageInfoList lst)
{
foreach (RoUsageInfo item in lst) _AllList.Add(item);
foreach (RoUsageInfo item in lst) AddToCache(item);
}
public static RoUsageInfo GetExistingByPrimaryKey(int rOUsageID)
protected static RoUsageInfo GetCachedByPrimaryKey(int rOUsageID)
{
ConvertListToDictionary();
string key = rOUsageID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
@ -176,24 +184,23 @@ namespace VEPROMS.CSLA.Library
#endregion
#region Factory Methods
private static int _RoUsageInfoUnique = 0;
private int _MyRoUsageInfoUnique;
private static int RoUsageInfoUnique
{ get { return ++_RoUsageInfoUnique; } }
private int _MyRoUsageInfoUnique = RoUsageInfoUnique;
public int MyRoUsageInfoUnique
{
get { return _MyRoUsageInfoUnique; }
}
private RoUsageInfo()
{ get { return _MyRoUsageInfoUnique; } }
protected RoUsageInfo()
{/* require use of factory methods */
_MyRoUsageInfoUnique = ++_RoUsageInfoUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
if (!_AllByPrimaryKey.ContainsKey(ROUsageID.ToString())) return;
List<RoUsageInfo> listRoUsageInfo = _AllByPrimaryKey[ROUsageID.ToString()]; // Get the list of items
listRoUsageInfo.Remove(this); // Remove the item from the list
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ROUsageID.ToString())) return;
List<RoUsageInfo> listRoUsageInfo = _CacheByPrimaryKey[ROUsageID.ToString()]; // Get the list of items
while (listRoUsageInfo.Contains(this)) listRoUsageInfo.Remove(this); // Remove the item from the list
if (listRoUsageInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(ROUsageID.ToString()); // remove the list
_CacheByPrimaryKey.Remove(ROUsageID.ToString()); // remove the list
}
public virtual RoUsage Get()
{
@ -203,15 +210,15 @@ namespace VEPROMS.CSLA.Library
{
string key = tmp.ROUsageID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (RoUsageInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (RoUsageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(RoUsage tmp)
protected virtual void RefreshFields(RoUsage tmp)
{
if (_ContentID != tmp.ContentID)
{
MyContent.RefreshContentRoUsages(); // Update List for old value
if (MyContent != null) MyContent.RefreshContentRoUsages(); // Update List for old value
_ContentID = tmp.ContentID; // Update the value
}
_MyContent = null; // Reset list so that the next line gets a new list
@ -228,11 +235,11 @@ namespace VEPROMS.CSLA.Library
{
string key = tmp.ROUsageID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (RoUsageInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (RoUsageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ContentRoUsage tmp)
protected virtual void RefreshFields(ContentRoUsage tmp)
{
_ROID = tmp.ROID;
_Config = tmp.Config;
@ -248,13 +255,17 @@ namespace VEPROMS.CSLA.Library
// throw new System.Security.SecurityException("User not authorized to view a RoUsage");
try
{
RoUsageInfo tmp = GetExistingByPrimaryKey(rOUsageID);
RoUsageInfo tmp = GetCachedByPrimaryKey(rOUsageID);
if (tmp == null)
{
tmp = DataPortal.Fetch<RoUsageInfo>(new PKCriteria(rOUsageID));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up RoUsageInfo
tmp = null;
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
@ -266,7 +277,6 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal
internal RoUsageInfo(SafeDataReader dr)
{
_MyRoUsageInfoUnique = ++_RoUsageInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfo.Constructor", GetHashCode());
try
{

View File

@ -77,38 +77,46 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region Collection
protected static List<Role> _AllList = new List<Role>();
private static Dictionary<string, List<Role>> _AllByPrimaryKey = new Dictionary<string, List<Role>>();
private static Dictionary<string, List<Role>> _AllByName = new Dictionary<string, List<Role>>();
private static List<Role> _CacheList = new List<Role>();
protected static void AddToCache(Role role)
{
if (!_CacheList.Contains(role)) _CacheList.Add(role); // In AddToCache
}
protected static void RemoveFromCache(Role role)
{
while (_CacheList.Contains(role)) _CacheList.Remove(role); // In RemoveFromCache
}
private static Dictionary<string, List<Role>> _CacheByPrimaryKey = new Dictionary<string, List<Role>>();
private static Dictionary<string, List<Role>> _CacheByName = new Dictionary<string, List<Role>>();
private static void ConvertListToDictionary()
{
List<Role> remove = new List<Role>();
foreach (Role tmp in _AllList)
foreach (Role tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.RID.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.RID.ToString()))
{
_AllByPrimaryKey[tmp.RID.ToString()] = new List<Role>(); // Add new list for PrimaryKey
_AllByName[tmp.Name.ToString()] = new List<Role>(); // Add new list for Name
_CacheByPrimaryKey[tmp.RID.ToString()] = new List<Role>(); // Add new list for PrimaryKey
_CacheByName[tmp.Name.ToString()] = new List<Role>(); // Add new list for Name
}
_AllByPrimaryKey[tmp.RID.ToString()].Add(tmp); // Add to Primary Key list
_AllByName[tmp.Name.ToString()].Add(tmp); // Unique Index
_CacheByPrimaryKey[tmp.RID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByName[tmp.Name.ToString()].Add(tmp); // Unique Index
remove.Add(tmp);
}
foreach (Role tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
public static Role GetExistingByPrimaryKey(int rid)
protected static Role GetCachedByPrimaryKey(int rid)
{
ConvertListToDictionary();
string key = rid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
public static Role GetExistingByName(string name)
protected static Role GetCachedByName(string name)
{
ConvertListToDictionary();
string key = name.ToString();
if (_AllByName.ContainsKey(key)) return _AllByName[key][0];
if (_CacheByName.ContainsKey(key)) return _CacheByName[key][0];
return null;
}
#endregion
@ -442,28 +450,41 @@ namespace VEPROMS.CSLA.Library
public int CurrentEditLevel
{ get { return EditLevel; } }
private static int _RoleUnique = 0;
private int _MyRoleUnique;
protected static int RoleUnique
{ get { return ++_RoleUnique; } }
private int _MyRoleUnique = RoleUnique;
public int MyRoleUnique
{
get { return _MyRoleUnique; }
}
{ get { return _MyRoleUnique; } }
protected Role()
{/* require use of factory methods */
_MyRoleUnique = ++_RoleUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
if (!_AllByPrimaryKey.ContainsKey(RID.ToString())) return;
List<Role> listRole = _AllByPrimaryKey[RID.ToString()]; // Get the list of items
listRole.Remove(this); // Remove the item from the list
if (listRole.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(RID.ToString()); // remove the list
listRole = _AllByName[RID.ToString()]; // Get the list of items
listRole.Remove(this); // Remove the item from the list
if (listRole.Count == 0) //If there are no items left in the list
_AllByName.Remove(RID.ToString()); // remove the list
RemoveFromDictionaries();
}
private void RemoveFromDictionaries()
{
RemoveFromCache(this);
if (_CacheByPrimaryKey.ContainsKey(RID.ToString()))
{
List<Role> listRole = _CacheByPrimaryKey[RID.ToString()]; // Get the list of items
while (listRole.Contains(this)) listRole.Remove(this); // Remove the item from the list
if (listRole.Count == 0) //If there are no items left in the list
_CacheByPrimaryKey.Remove(RID.ToString()); // remove the list
}
string myKey;
myKey = null;
foreach (string key in _CacheByName.Keys)
if (_CacheByName[key].Contains(this))
myKey = key;
if (myKey != null)
{
List<Role> listRole = _CacheByName[myKey]; // Get the list of items
listRole.Remove(this); // Remove the item from the list
if (listRole.Count == 0) //If there are no items left in the list
_CacheByName.Remove(myKey); // remove the list
}
}
public static Role New()
{
@ -485,6 +506,26 @@ namespace VEPROMS.CSLA.Library
tmp.Title = title;
return tmp;
}
public static Role MakeRole(string name, string title)
{
Role tmp = Role.New(name, title);
if (tmp.IsSavable)
{
Role tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
tmp._ErrorMessage = "Failed Validation:";
foreach (Csla.Validation.BrokenRule br in brc)
{
tmp._ErrorMessage += "\r\n\tFailure: " + br.RuleName;
}
}
return tmp;
}
public static Role New(string name, string title, DateTime dts, string usrID)
{
Role tmp = Role.New();
@ -498,7 +539,11 @@ namespace VEPROMS.CSLA.Library
{
Role tmp = Role.New(name, title, dts, usrID);
if (tmp.IsSavable)
tmp = tmp.Save();
{
Role tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
@ -516,13 +561,17 @@ namespace VEPROMS.CSLA.Library
throw new System.Security.SecurityException("User not authorized to view a Role");
try
{
Role tmp = GetExistingByPrimaryKey(rid);
Role tmp = GetCachedByPrimaryKey(rid);
if (tmp == null)
{
tmp = DataPortal.Fetch<Role>(new PKCriteria(rid));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up Role
tmp = null;
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
@ -530,19 +579,23 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Error on Role.Get", ex);
}
}
private static Role GetByName(string name)
public static Role GetByName(string name)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Role");
try
{
Role tmp = GetExistingByName(name);
Role tmp = GetCachedByName(name);
if (tmp == null)
{
tmp = DataPortal.Fetch<Role>(new NameCriteria(name));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up Role
tmp = null;
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
@ -584,7 +637,8 @@ namespace VEPROMS.CSLA.Library
{
BuildRefreshList();
Role role = base.Save();
_AllList.Add(role);//Refresh the item in AllList
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(role);//Refresh the item in AllList
ProcessRefreshList();
return role;
}

View File

@ -285,6 +285,16 @@ namespace VEPROMS.CSLA.Library
return _Folder_FormatID;
}
}
private double? _Folder_ManualOrder;
public double? Folder_ManualOrder
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_ManualOrder", true);
return _Folder_ManualOrder;
}
}
private string _Folder_Config = string.Empty;
public string Folder_Config
{
@ -597,6 +607,7 @@ namespace VEPROMS.CSLA.Library
_Folder_Title = dr.GetString("Folder_Title");
_Folder_ShortName = dr.GetString("Folder_ShortName");
_Folder_FormatID = (int?)dr.GetValue("Folder_FormatID");
_Folder_ManualOrder = (double?)dr.GetValue("Folder_ManualOrder");
_Folder_Config = dr.GetString("Folder_Config");
_Folder_DTS = dr.GetDateTime("Folder_DTS");
_Folder_UsrID = dr.GetString("Folder_UsrID");

View File

@ -36,32 +36,40 @@ namespace VEPROMS.CSLA.Library
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
protected static List<RoleInfo> _AllList = new List<RoleInfo>();
private static Dictionary<string, List<RoleInfo>> _AllByPrimaryKey = new Dictionary<string, List<RoleInfo>>();
private static List<RoleInfo> _CacheList = new List<RoleInfo>();
protected static void AddToCache(RoleInfo roleInfo)
{
if (!_CacheList.Contains(roleInfo)) _CacheList.Add(roleInfo); // In AddToCache
}
protected static void RemoveFromCache(RoleInfo roleInfo)
{
while (_CacheList.Contains(roleInfo)) _CacheList.Remove(roleInfo); // In RemoveFromCache
}
private static Dictionary<string, List<RoleInfo>> _CacheByPrimaryKey = new Dictionary<string, List<RoleInfo>>();
private static void ConvertListToDictionary()
{
List<RoleInfo> remove = new List<RoleInfo>();
foreach (RoleInfo tmp in _AllList)
foreach (RoleInfo tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.RID.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.RID.ToString()))
{
_AllByPrimaryKey[tmp.RID.ToString()] = new List<RoleInfo>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[tmp.RID.ToString()] = new List<RoleInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.RID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[tmp.RID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (RoleInfo tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
internal static void AddList(RoleInfoList lst)
{
foreach (RoleInfo item in lst) _AllList.Add(item);
foreach (RoleInfo item in lst) AddToCache(item);
}
public static RoleInfo GetExistingByPrimaryKey(int rid)
protected static RoleInfo GetCachedByPrimaryKey(int rid)
{
ConvertListToDictionary();
string key = rid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
@ -161,11 +169,11 @@ namespace VEPROMS.CSLA.Library
return _RoleAssignments;
}
}
internal void RefreshRoleAssignments()
public void RefreshRoleAssignments()
{
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_RID.ToString()))
foreach (RoleInfo tmp in _AllByPrimaryKey[_RID.ToString()])
if (_CacheByPrimaryKey.ContainsKey(_RID.ToString()))
foreach (RoleInfo tmp in _CacheByPrimaryKey[_RID.ToString()])
tmp._RoleAssignmentCount = -1; // This will cause the data to be requeried
}
private int _RolePermissionCount = 0;
@ -196,11 +204,11 @@ namespace VEPROMS.CSLA.Library
return _RolePermissions;
}
}
internal void RefreshRolePermissions()
public void RefreshRolePermissions()
{
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_RID.ToString()))
foreach (RoleInfo tmp in _AllByPrimaryKey[_RID.ToString()])
if (_CacheByPrimaryKey.ContainsKey(_RID.ToString()))
foreach (RoleInfo tmp in _CacheByPrimaryKey[_RID.ToString()])
tmp._RolePermissionCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base RoleInfo.ToString function as necessary
@ -224,24 +232,23 @@ namespace VEPROMS.CSLA.Library
#endregion
#region Factory Methods
private static int _RoleInfoUnique = 0;
private int _MyRoleInfoUnique;
private static int RoleInfoUnique
{ get { return ++_RoleInfoUnique; } }
private int _MyRoleInfoUnique = RoleInfoUnique;
public int MyRoleInfoUnique
{
get { return _MyRoleInfoUnique; }
}
private RoleInfo()
{ get { return _MyRoleInfoUnique; } }
protected RoleInfo()
{/* require use of factory methods */
_MyRoleInfoUnique = ++_RoleInfoUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
if (!_AllByPrimaryKey.ContainsKey(RID.ToString())) return;
List<RoleInfo> listRoleInfo = _AllByPrimaryKey[RID.ToString()]; // Get the list of items
listRoleInfo.Remove(this); // Remove the item from the list
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(RID.ToString())) return;
List<RoleInfo> listRoleInfo = _CacheByPrimaryKey[RID.ToString()]; // Get the list of items
while (listRoleInfo.Contains(this)) listRoleInfo.Remove(this); // Remove the item from the list
if (listRoleInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(RID.ToString()); // remove the list
_CacheByPrimaryKey.Remove(RID.ToString()); // remove the list
}
public virtual Role Get()
{
@ -251,11 +258,11 @@ namespace VEPROMS.CSLA.Library
{
string key = tmp.RID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (RoleInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (RoleInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Role tmp)
protected virtual void RefreshFields(Role tmp)
{
_Name = tmp.Name;
_Title = tmp.Title;
@ -270,13 +277,17 @@ namespace VEPROMS.CSLA.Library
// throw new System.Security.SecurityException("User not authorized to view a Role");
try
{
RoleInfo tmp = GetExistingByPrimaryKey(rid);
RoleInfo tmp = GetCachedByPrimaryKey(rid);
if (tmp == null)
{
tmp = DataPortal.Fetch<RoleInfo>(new PKCriteria(rid));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up RoleInfo
tmp = null;
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
@ -288,7 +299,6 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal
internal RoleInfo(SafeDataReader dr)
{
_MyRoleInfoUnique = ++_RoleInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoleInfo.Constructor", GetHashCode());
try
{

View File

@ -54,28 +54,36 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region Collection
protected static List<Transition> _AllList = new List<Transition>();
private static Dictionary<string, List<Transition>> _AllByPrimaryKey = new Dictionary<string, List<Transition>>();
private static List<Transition> _CacheList = new List<Transition>();
protected static void AddToCache(Transition transition)
{
if (!_CacheList.Contains(transition)) _CacheList.Add(transition); // In AddToCache
}
protected static void RemoveFromCache(Transition transition)
{
while (_CacheList.Contains(transition)) _CacheList.Remove(transition); // In RemoveFromCache
}
private static Dictionary<string, List<Transition>> _CacheByPrimaryKey = new Dictionary<string, List<Transition>>();
private static void ConvertListToDictionary()
{
List<Transition> remove = new List<Transition>();
foreach (Transition tmp in _AllList)
foreach (Transition tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.TransitionID.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.TransitionID.ToString()))
{
_AllByPrimaryKey[tmp.TransitionID.ToString()] = new List<Transition>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[tmp.TransitionID.ToString()] = new List<Transition>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.TransitionID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[tmp.TransitionID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (Transition tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
public static Transition GetExistingByPrimaryKey(int transitionID)
protected static Transition GetCachedByPrimaryKey(int transitionID)
{
ConvertListToDictionary();
string key = transitionID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
@ -503,24 +511,29 @@ namespace VEPROMS.CSLA.Library
public int CurrentEditLevel
{ get { return EditLevel; } }
private static int _TransitionUnique = 0;
private int _MyTransitionUnique;
protected static int TransitionUnique
{ get { return ++_TransitionUnique; } }
private int _MyTransitionUnique = TransitionUnique;
public int MyTransitionUnique
{
get { return _MyTransitionUnique; }
}
{ get { return _MyTransitionUnique; } }
protected Transition()
{/* require use of factory methods */
_MyTransitionUnique = ++_TransitionUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
if (!_AllByPrimaryKey.ContainsKey(TransitionID.ToString())) return;
List<Transition> listTransition = _AllByPrimaryKey[TransitionID.ToString()]; // Get the list of items
listTransition.Remove(this); // Remove the item from the list
if (listTransition.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(TransitionID.ToString()); // remove the list
RemoveFromDictionaries();
}
private void RemoveFromDictionaries()
{
RemoveFromCache(this);
if (_CacheByPrimaryKey.ContainsKey(TransitionID.ToString()))
{
List<Transition> listTransition = _CacheByPrimaryKey[TransitionID.ToString()]; // Get the list of items
while (listTransition.Contains(this)) listTransition.Remove(this); // Remove the item from the list
if (listTransition.Count == 0) //If there are no items left in the list
_CacheByPrimaryKey.Remove(TransitionID.ToString()); // remove the list
}
}
public static Transition New()
{
@ -559,7 +572,11 @@ namespace VEPROMS.CSLA.Library
{
Transition tmp = Transition.New(myContent, myItemToID, myItemRangeID, tranType, config, dts, userID);
if (tmp.IsSavable)
tmp = tmp.Save();
{
Transition tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
@ -584,7 +601,11 @@ namespace VEPROMS.CSLA.Library
{
Transition tmp = Transition.New(myContent, myItemToID, myItemRangeID, config);
if (tmp.IsSavable)
tmp = tmp.Save();
{
Transition tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
@ -602,13 +623,17 @@ namespace VEPROMS.CSLA.Library
throw new System.Security.SecurityException("User not authorized to view a Transition");
try
{
Transition tmp = GetExistingByPrimaryKey(transitionID);
Transition tmp = GetCachedByPrimaryKey(transitionID);
if (tmp == null)
{
tmp = DataPortal.Fetch<Transition>(new PKCriteria(transitionID));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up Transition
tmp = null;
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
@ -650,7 +675,8 @@ namespace VEPROMS.CSLA.Library
{
BuildRefreshList();
Transition transition = base.Save();
_AllList.Add(transition);//Refresh the item in AllList
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(transition);//Refresh the item in AllList
ProcessRefreshList();
return transition;
}

View File

@ -36,32 +36,40 @@ namespace VEPROMS.CSLA.Library
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
protected static List<TransitionInfo> _AllList = new List<TransitionInfo>();
private static Dictionary<string, List<TransitionInfo>> _AllByPrimaryKey = new Dictionary<string, List<TransitionInfo>>();
private static List<TransitionInfo> _CacheList = new List<TransitionInfo>();
protected static void AddToCache(TransitionInfo transitionInfo)
{
if (!_CacheList.Contains(transitionInfo)) _CacheList.Add(transitionInfo); // In AddToCache
}
protected static void RemoveFromCache(TransitionInfo transitionInfo)
{
while (_CacheList.Contains(transitionInfo)) _CacheList.Remove(transitionInfo); // In RemoveFromCache
}
private static Dictionary<string, List<TransitionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<TransitionInfo>>();
private static void ConvertListToDictionary()
{
List<TransitionInfo> remove = new List<TransitionInfo>();
foreach (TransitionInfo tmp in _AllList)
foreach (TransitionInfo tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.TransitionID.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.TransitionID.ToString()))
{
_AllByPrimaryKey[tmp.TransitionID.ToString()] = new List<TransitionInfo>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[tmp.TransitionID.ToString()] = new List<TransitionInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.TransitionID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[tmp.TransitionID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (TransitionInfo tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
internal static void AddList(TransitionInfoList lst)
{
foreach (TransitionInfo item in lst) _AllList.Add(item);
foreach (TransitionInfo item in lst) AddToCache(item);
}
public static TransitionInfo GetExistingByPrimaryKey(int transitionID)
protected static TransitionInfo GetCachedByPrimaryKey(int transitionID)
{
ConvertListToDictionary();
string key = transitionID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
@ -223,8 +231,11 @@ namespace VEPROMS.CSLA.Library
get
{
CanReadProperty("MyZTransition", true);
if (_TransitionZTransitionCount > 0 && _MyZTransition == null)
if (_TransitionZTransitionCount != 0 && _MyZTransition == null)
{
_MyZTransition = ZTransitionInfo.Get(_TransitionID);
_TransitionZTransitionCount = _MyZTransition == null ? 0 : 1;
}
return _MyZTransition;
}
}
@ -249,24 +260,23 @@ namespace VEPROMS.CSLA.Library
#endregion
#region Factory Methods
private static int _TransitionInfoUnique = 0;
private int _MyTransitionInfoUnique;
private static int TransitionInfoUnique
{ get { return ++_TransitionInfoUnique; } }
private int _MyTransitionInfoUnique = TransitionInfoUnique;
public int MyTransitionInfoUnique
{
get { return _MyTransitionInfoUnique; }
}
private TransitionInfo()
{ get { return _MyTransitionInfoUnique; } }
protected TransitionInfo()
{/* require use of factory methods */
_MyTransitionInfoUnique = ++_TransitionInfoUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
if (!_AllByPrimaryKey.ContainsKey(TransitionID.ToString())) return;
List<TransitionInfo> listTransitionInfo = _AllByPrimaryKey[TransitionID.ToString()]; // Get the list of items
listTransitionInfo.Remove(this); // Remove the item from the list
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(TransitionID.ToString())) return;
List<TransitionInfo> listTransitionInfo = _CacheByPrimaryKey[TransitionID.ToString()]; // Get the list of items
while (listTransitionInfo.Contains(this)) listTransitionInfo.Remove(this); // Remove the item from the list
if (listTransitionInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(TransitionID.ToString()); // remove the list
_CacheByPrimaryKey.Remove(TransitionID.ToString()); // remove the list
}
public virtual Transition Get()
{
@ -276,29 +286,29 @@ namespace VEPROMS.CSLA.Library
{
string key = tmp.TransitionID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (TransitionInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (TransitionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Transition tmp)
protected virtual void RefreshFields(Transition tmp)
{
if (_FromID != tmp.FromID)
{
MyContent.RefreshContentTransitions(); // Update List for old value
if (MyContent != null) MyContent.RefreshContentTransitions(); // Update List for old value
_FromID = tmp.FromID; // Update the value
}
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentTransitions(); // Update List for new value
if (_ToID != tmp.ToID)
{
MyItemToID.RefreshItemTransitions_ToID(); // Update List for old value
if (MyItemToID != null) MyItemToID.RefreshItemTransitions_ToID(); // Update List for old value
_ToID = tmp.ToID; // Update the value
}
_MyItemToID = null; // Reset list so that the next line gets a new list
if (MyItemToID != null) MyItemToID.RefreshItemTransitions_ToID(); // Update List for new value
if (_RangeID != tmp.RangeID)
{
MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for old value
if (MyItemRangeID != null) MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for old value
_RangeID = tmp.RangeID; // Update the value
}
_MyItemRangeID = null; // Reset list so that the next line gets a new list
@ -311,29 +321,30 @@ namespace VEPROMS.CSLA.Library
_MyContent = null;
_MyItemToID = null;
_MyItemRangeID = null;
_MyZTransition = null;//
_MyZTransition = null;// Reset related value
_TransitionZTransitionCount = -1;// Reset Count
OnChange();// raise an event
}
public static void Refresh(ContentTransition tmp)
{
string key = tmp.TransitionID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (TransitionInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (TransitionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ContentTransition tmp)
protected virtual void RefreshFields(ContentTransition tmp)
{
if (_ToID != tmp.ToID)
{
MyItemToID.RefreshItemTransitions_ToID(); // Update List for old value
if (MyItemToID != null) MyItemToID.RefreshItemTransitions_ToID(); // Update List for old value
_ToID = tmp.ToID; // Update the value
}
_MyItemToID = null; // Reset list so that the next line gets a new list
if (MyItemToID != null) MyItemToID.RefreshItemTransitions_ToID(); // Update List for new value
if (_RangeID != tmp.RangeID)
{
MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for old value
if (MyItemRangeID != null) MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for old value
_RangeID = tmp.RangeID; // Update the value
}
_MyItemRangeID = null; // Reset list so that the next line gets a new list
@ -346,29 +357,30 @@ namespace VEPROMS.CSLA.Library
_MyContent = null;
_MyItemToID = null;
_MyItemRangeID = null;
_MyZTransition = null;//
_MyZTransition = null;// Reset related value
_TransitionZTransitionCount = -1;// Reset Count
OnChange();// raise an event
}
public static void Refresh(ItemTransition_RangeID tmp)
{
string key = tmp.TransitionID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (TransitionInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (TransitionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ItemTransition_RangeID tmp)
protected virtual void RefreshFields(ItemTransition_RangeID tmp)
{
if (_FromID != tmp.FromID)
{
MyContent.RefreshContentTransitions(); // Update List for old value
if (MyContent != null) MyContent.RefreshContentTransitions(); // Update List for old value
_FromID = tmp.FromID; // Update the value
}
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentTransitions(); // Update List for new value
if (_ToID != tmp.ToID)
{
MyItemToID.RefreshItemTransitions_ToID(); // Update List for old value
if (MyItemToID != null) MyItemToID.RefreshItemTransitions_ToID(); // Update List for old value
_ToID = tmp.ToID; // Update the value
}
_MyItemToID = null; // Reset list so that the next line gets a new list
@ -381,29 +393,30 @@ namespace VEPROMS.CSLA.Library
_MyContent = null;
_MyItemToID = null;
_MyItemRangeID = null;
_MyZTransition = null;//
_MyZTransition = null;// Reset related value
_TransitionZTransitionCount = -1;// Reset Count
OnChange();// raise an event
}
public static void Refresh(ItemTransition_ToID tmp)
{
string key = tmp.TransitionID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (TransitionInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (TransitionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ItemTransition_ToID tmp)
protected virtual void RefreshFields(ItemTransition_ToID tmp)
{
if (_FromID != tmp.FromID)
{
MyContent.RefreshContentTransitions(); // Update List for old value
if (MyContent != null) MyContent.RefreshContentTransitions(); // Update List for old value
_FromID = tmp.FromID; // Update the value
}
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentTransitions(); // Update List for new value
if (_RangeID != tmp.RangeID)
{
MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for old value
if (MyItemRangeID != null) MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for old value
_RangeID = tmp.RangeID; // Update the value
}
_MyItemRangeID = null; // Reset list so that the next line gets a new list
@ -416,7 +429,8 @@ namespace VEPROMS.CSLA.Library
_MyContent = null;
_MyItemToID = null;
_MyItemRangeID = null;
_MyZTransition = null;//
_MyZTransition = null;// Reset related value
_TransitionZTransitionCount = -1;// Reset Count
OnChange();// raise an event
}
public static TransitionInfo Get(int transitionID)
@ -425,13 +439,17 @@ namespace VEPROMS.CSLA.Library
// throw new System.Security.SecurityException("User not authorized to view a Transition");
try
{
TransitionInfo tmp = GetExistingByPrimaryKey(transitionID);
TransitionInfo tmp = GetCachedByPrimaryKey(transitionID);
if (tmp == null)
{
tmp = DataPortal.Fetch<TransitionInfo>(new PKCriteria(transitionID));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up TransitionInfo
tmp = null;
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
@ -443,7 +461,6 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal
internal TransitionInfo(SafeDataReader dr)
{
_MyTransitionInfoUnique = ++_TransitionInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] TransitionInfo.Constructor", GetHashCode());
try
{

View File

@ -64,28 +64,36 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region Collection
protected static List<User> _AllList = new List<User>();
private static Dictionary<string, List<User>> _AllByPrimaryKey = new Dictionary<string, List<User>>();
private static List<User> _CacheList = new List<User>();
protected static void AddToCache(User user)
{
if (!_CacheList.Contains(user)) _CacheList.Add(user); // In AddToCache
}
protected static void RemoveFromCache(User user)
{
while (_CacheList.Contains(user)) _CacheList.Remove(user); // In RemoveFromCache
}
private static Dictionary<string, List<User>> _CacheByPrimaryKey = new Dictionary<string, List<User>>();
private static void ConvertListToDictionary()
{
List<User> remove = new List<User>();
foreach (User tmp in _AllList)
foreach (User tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.UID.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.UID.ToString()))
{
_AllByPrimaryKey[tmp.UID.ToString()] = new List<User>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[tmp.UID.ToString()] = new List<User>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.UID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[tmp.UID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (User tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
public static User GetExistingByPrimaryKey(int uid)
protected static User GetCachedByPrimaryKey(int uid)
{
ConvertListToDictionary();
string key = uid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
@ -618,24 +626,29 @@ namespace VEPROMS.CSLA.Library
public int CurrentEditLevel
{ get { return EditLevel; } }
private static int _UserUnique = 0;
private int _MyUserUnique;
protected static int UserUnique
{ get { return ++_UserUnique; } }
private int _MyUserUnique = UserUnique;
public int MyUserUnique
{
get { return _MyUserUnique; }
}
{ get { return _MyUserUnique; } }
protected User()
{/* require use of factory methods */
_MyUserUnique = ++_UserUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
if (!_AllByPrimaryKey.ContainsKey(UID.ToString())) return;
List<User> listUser = _AllByPrimaryKey[UID.ToString()]; // Get the list of items
listUser.Remove(this); // Remove the item from the list
if (listUser.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(UID.ToString()); // remove the list
RemoveFromDictionaries();
}
private void RemoveFromDictionaries()
{
RemoveFromCache(this);
if (_CacheByPrimaryKey.ContainsKey(UID.ToString()))
{
List<User> listUser = _CacheByPrimaryKey[UID.ToString()]; // Get the list of items
while (listUser.Contains(this)) listUser.Remove(this); // Remove the item from the list
if (listUser.Count == 0) //If there are no items left in the list
_CacheByPrimaryKey.Remove(UID.ToString()); // remove the list
}
}
public static User New()
{
@ -672,7 +685,11 @@ namespace VEPROMS.CSLA.Library
{
User tmp = User.New(userID, firstName, middleName, lastName, suffix, courtesyTitle, phoneNumber, cFGName, userLogin, userName, config, dts, usrID);
if (tmp.IsSavable)
tmp = tmp.Save();
{
User tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
@ -703,7 +720,11 @@ namespace VEPROMS.CSLA.Library
{
User tmp = User.New(firstName, middleName, lastName, suffix, courtesyTitle, phoneNumber, cFGName, userLogin, userName, config);
if (tmp.IsSavable)
tmp = tmp.Save();
{
User tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
@ -721,13 +742,17 @@ namespace VEPROMS.CSLA.Library
throw new System.Security.SecurityException("User not authorized to view a User");
try
{
User tmp = GetExistingByPrimaryKey(uid);
User tmp = GetCachedByPrimaryKey(uid);
if (tmp == null)
{
tmp = DataPortal.Fetch<User>(new PKCriteria(uid));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up User
tmp = null;
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
@ -769,7 +794,8 @@ namespace VEPROMS.CSLA.Library
{
BuildRefreshList();
User user = base.Save();
_AllList.Add(user);//Refresh the item in AllList
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(user);//Refresh the item in AllList
ProcessRefreshList();
return user;
}

View File

@ -36,32 +36,40 @@ namespace VEPROMS.CSLA.Library
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
protected static List<UserInfo> _AllList = new List<UserInfo>();
private static Dictionary<string, List<UserInfo>> _AllByPrimaryKey = new Dictionary<string, List<UserInfo>>();
private static List<UserInfo> _CacheList = new List<UserInfo>();
protected static void AddToCache(UserInfo userInfo)
{
if (!_CacheList.Contains(userInfo)) _CacheList.Add(userInfo); // In AddToCache
}
protected static void RemoveFromCache(UserInfo userInfo)
{
while (_CacheList.Contains(userInfo)) _CacheList.Remove(userInfo); // In RemoveFromCache
}
private static Dictionary<string, List<UserInfo>> _CacheByPrimaryKey = new Dictionary<string, List<UserInfo>>();
private static void ConvertListToDictionary()
{
List<UserInfo> remove = new List<UserInfo>();
foreach (UserInfo tmp in _AllList)
foreach (UserInfo tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.UID.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.UID.ToString()))
{
_AllByPrimaryKey[tmp.UID.ToString()] = new List<UserInfo>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[tmp.UID.ToString()] = new List<UserInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.UID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[tmp.UID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (UserInfo tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
internal static void AddList(UserInfoList lst)
{
foreach (UserInfo item in lst) _AllList.Add(item);
foreach (UserInfo item in lst) AddToCache(item);
}
public static UserInfo GetExistingByPrimaryKey(int uid)
protected static UserInfo GetCachedByPrimaryKey(int uid)
{
ConvertListToDictionary();
string key = uid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
@ -251,11 +259,11 @@ namespace VEPROMS.CSLA.Library
return _UserMemberships;
}
}
internal void RefreshUserMemberships()
public void RefreshUserMemberships()
{
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_UID.ToString()))
foreach (UserInfo tmp in _AllByPrimaryKey[_UID.ToString()])
if (_CacheByPrimaryKey.ContainsKey(_UID.ToString()))
foreach (UserInfo tmp in _CacheByPrimaryKey[_UID.ToString()])
tmp._UserMembershipCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base UserInfo.ToString function as necessary
@ -279,24 +287,23 @@ namespace VEPROMS.CSLA.Library
#endregion
#region Factory Methods
private static int _UserInfoUnique = 0;
private int _MyUserInfoUnique;
private static int UserInfoUnique
{ get { return ++_UserInfoUnique; } }
private int _MyUserInfoUnique = UserInfoUnique;
public int MyUserInfoUnique
{
get { return _MyUserInfoUnique; }
}
private UserInfo()
{ get { return _MyUserInfoUnique; } }
protected UserInfo()
{/* require use of factory methods */
_MyUserInfoUnique = ++_UserInfoUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
if (!_AllByPrimaryKey.ContainsKey(UID.ToString())) return;
List<UserInfo> listUserInfo = _AllByPrimaryKey[UID.ToString()]; // Get the list of items
listUserInfo.Remove(this); // Remove the item from the list
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(UID.ToString())) return;
List<UserInfo> listUserInfo = _CacheByPrimaryKey[UID.ToString()]; // Get the list of items
while (listUserInfo.Contains(this)) listUserInfo.Remove(this); // Remove the item from the list
if (listUserInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(UID.ToString()); // remove the list
_CacheByPrimaryKey.Remove(UID.ToString()); // remove the list
}
public virtual User Get()
{
@ -306,11 +313,11 @@ namespace VEPROMS.CSLA.Library
{
string key = tmp.UID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (UserInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (UserInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(User tmp)
protected virtual void RefreshFields(User tmp)
{
_UserID = tmp.UserID;
_FirstName = tmp.FirstName;
@ -334,13 +341,17 @@ namespace VEPROMS.CSLA.Library
// throw new System.Security.SecurityException("User not authorized to view a User");
try
{
UserInfo tmp = GetExistingByPrimaryKey(uid);
UserInfo tmp = GetCachedByPrimaryKey(uid);
if (tmp == null)
{
tmp = DataPortal.Fetch<UserInfo>(new PKCriteria(uid));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up UserInfo
tmp = null;
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
@ -352,7 +363,6 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal
internal UserInfo(SafeDataReader dr)
{
_MyUserInfoUnique = ++_UserInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] UserInfo.Constructor", GetHashCode());
try
{

View File

@ -51,28 +51,36 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region Collection
protected static List<ZContent> _AllList = new List<ZContent>();
private static Dictionary<string, List<ZContent>> _AllByPrimaryKey = new Dictionary<string, List<ZContent>>();
private static List<ZContent> _CacheList = new List<ZContent>();
protected static void AddToCache(ZContent zContent)
{
if (!_CacheList.Contains(zContent)) _CacheList.Add(zContent); // In AddToCache
}
protected static void RemoveFromCache(ZContent zContent)
{
while (_CacheList.Contains(zContent)) _CacheList.Remove(zContent); // In RemoveFromCache
}
private static Dictionary<string, List<ZContent>> _CacheByPrimaryKey = new Dictionary<string, List<ZContent>>();
private static void ConvertListToDictionary()
{
List<ZContent> remove = new List<ZContent>();
foreach (ZContent tmp in _AllList)
foreach (ZContent tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
{
_AllByPrimaryKey[tmp.ContentID.ToString()] = new List<ZContent>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[tmp.ContentID.ToString()] = new List<ZContent>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ZContent tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
public static ZContent GetExistingByPrimaryKey(int contentID)
protected static ZContent GetCachedByPrimaryKey(int contentID)
{
ConvertListToDictionary();
string key = contentID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
@ -254,24 +262,29 @@ namespace VEPROMS.CSLA.Library
public int CurrentEditLevel
{ get { return EditLevel; } }
private static int _ZContentUnique = 0;
private int _MyZContentUnique;
protected static int ZContentUnique
{ get { return ++_ZContentUnique; } }
private int _MyZContentUnique = ZContentUnique;
public int MyZContentUnique
{
get { return _MyZContentUnique; }
}
{ get { return _MyZContentUnique; } }
protected ZContent()
{/* require use of factory methods */
_MyZContentUnique = ++_ZContentUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString())) return;
List<ZContent> listZContent = _AllByPrimaryKey[ContentID.ToString()]; // Get the list of items
listZContent.Remove(this); // Remove the item from the list
if (listZContent.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(ContentID.ToString()); // remove the list
RemoveFromDictionaries();
}
private void RemoveFromDictionaries()
{
RemoveFromCache(this);
if (_CacheByPrimaryKey.ContainsKey(ContentID.ToString()))
{
List<ZContent> listZContent = _CacheByPrimaryKey[ContentID.ToString()]; // Get the list of items
while (listZContent.Contains(this)) listZContent.Remove(this); // Remove the item from the list
if (listZContent.Count == 0) //If there are no items left in the list
_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
}
}
public static ZContent New()
{
@ -297,7 +310,11 @@ namespace VEPROMS.CSLA.Library
{
ZContent tmp = ZContent.New(myContent, oldStepSequence);
if (tmp.IsSavable)
tmp = tmp.Save();
{
ZContent tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
@ -323,13 +340,17 @@ namespace VEPROMS.CSLA.Library
throw new System.Security.SecurityException("User not authorized to view a ZContent");
try
{
ZContent tmp = GetExistingByPrimaryKey(contentID);
ZContent tmp = GetCachedByPrimaryKey(contentID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ZContent>(new PKCriteria(contentID));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ZContent
tmp = null;
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
@ -371,7 +392,8 @@ namespace VEPROMS.CSLA.Library
{
BuildRefreshList();
ZContent zContent = base.Save();
_AllList.Add(zContent);//Refresh the item in AllList
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(zContent);//Refresh the item in AllList
ProcessRefreshList();
return zContent;
}

View File

@ -36,28 +36,36 @@ namespace VEPROMS.CSLA.Library
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
protected static List<ZContentInfo> _AllList = new List<ZContentInfo>();
private static Dictionary<string, List<ZContentInfo>> _AllByPrimaryKey = new Dictionary<string, List<ZContentInfo>>();
private static List<ZContentInfo> _CacheList = new List<ZContentInfo>();
protected static void AddToCache(ZContentInfo zContentInfo)
{
if (!_CacheList.Contains(zContentInfo)) _CacheList.Add(zContentInfo); // In AddToCache
}
protected static void RemoveFromCache(ZContentInfo zContentInfo)
{
while (_CacheList.Contains(zContentInfo)) _CacheList.Remove(zContentInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ZContentInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ZContentInfo>>();
private static void ConvertListToDictionary()
{
List<ZContentInfo> remove = new List<ZContentInfo>();
foreach (ZContentInfo tmp in _AllList)
foreach (ZContentInfo tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
{
_AllByPrimaryKey[tmp.ContentID.ToString()] = new List<ZContentInfo>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[tmp.ContentID.ToString()] = new List<ZContentInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ZContentInfo tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
public static ZContentInfo GetExistingByPrimaryKey(int contentID)
protected static ZContentInfo GetCachedByPrimaryKey(int contentID)
{
ConvertListToDictionary();
string key = contentID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
@ -133,24 +141,23 @@ namespace VEPROMS.CSLA.Library
#endregion
#region Factory Methods
private static int _ZContentInfoUnique = 0;
private int _MyZContentInfoUnique;
private static int ZContentInfoUnique
{ get { return ++_ZContentInfoUnique; } }
private int _MyZContentInfoUnique = ZContentInfoUnique;
public int MyZContentInfoUnique
{
get { return _MyZContentInfoUnique; }
}
private ZContentInfo()
{ get { return _MyZContentInfoUnique; } }
protected ZContentInfo()
{/* require use of factory methods */
_MyZContentInfoUnique = ++_ZContentInfoUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString())) return;
List<ZContentInfo> listZContentInfo = _AllByPrimaryKey[ContentID.ToString()]; // Get the list of items
listZContentInfo.Remove(this); // Remove the item from the list
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString())) return;
List<ZContentInfo> listZContentInfo = _CacheByPrimaryKey[ContentID.ToString()]; // Get the list of items
while (listZContentInfo.Contains(this)) listZContentInfo.Remove(this); // Remove the item from the list
if (listZContentInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(ContentID.ToString()); // remove the list
_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
}
public virtual ZContent Get()
{
@ -160,11 +167,11 @@ namespace VEPROMS.CSLA.Library
{
string key = tmp.ContentID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (ZContentInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ZContentInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ZContent tmp)
protected virtual void RefreshFields(ZContent tmp)
{
_OldStepSequence = tmp.OldStepSequence;
_ZContentInfoExtension.Refresh(this);
@ -177,15 +184,16 @@ namespace VEPROMS.CSLA.Library
// throw new System.Security.SecurityException("User not authorized to view a ZContent");
try
{
ZContentInfo tmp = GetExistingByPrimaryKey(contentID);
ZContentInfo tmp = GetCachedByPrimaryKey(contentID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ZContentInfo>(new PKCriteria(contentID));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp._ContentID = contentID;
tmp.Dispose(); // Clean-up ZContentInfo
tmp = null;
}
return tmp;
}
@ -198,7 +206,6 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal
internal ZContentInfo(SafeDataReader dr)
{
_MyZContentInfoUnique = ++_ZContentInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContentInfo.Constructor", GetHashCode());
try
{

View File

@ -51,28 +51,36 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region Collection
protected static List<ZTransition> _AllList = new List<ZTransition>();
private static Dictionary<string, List<ZTransition>> _AllByPrimaryKey = new Dictionary<string, List<ZTransition>>();
private static List<ZTransition> _CacheList = new List<ZTransition>();
protected static void AddToCache(ZTransition zTransition)
{
if (!_CacheList.Contains(zTransition)) _CacheList.Add(zTransition); // In AddToCache
}
protected static void RemoveFromCache(ZTransition zTransition)
{
while (_CacheList.Contains(zTransition)) _CacheList.Remove(zTransition); // In RemoveFromCache
}
private static Dictionary<string, List<ZTransition>> _CacheByPrimaryKey = new Dictionary<string, List<ZTransition>>();
private static void ConvertListToDictionary()
{
List<ZTransition> remove = new List<ZTransition>();
foreach (ZTransition tmp in _AllList)
foreach (ZTransition tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.TransitionID.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.TransitionID.ToString()))
{
_AllByPrimaryKey[tmp.TransitionID.ToString()] = new List<ZTransition>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[tmp.TransitionID.ToString()] = new List<ZTransition>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.TransitionID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[tmp.TransitionID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ZTransition tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
public static ZTransition GetExistingByPrimaryKey(int transitionID)
protected static ZTransition GetCachedByPrimaryKey(int transitionID)
{
ConvertListToDictionary();
string key = transitionID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
@ -254,24 +262,29 @@ namespace VEPROMS.CSLA.Library
public int CurrentEditLevel
{ get { return EditLevel; } }
private static int _ZTransitionUnique = 0;
private int _MyZTransitionUnique;
protected static int ZTransitionUnique
{ get { return ++_ZTransitionUnique; } }
private int _MyZTransitionUnique = ZTransitionUnique;
public int MyZTransitionUnique
{
get { return _MyZTransitionUnique; }
}
{ get { return _MyZTransitionUnique; } }
protected ZTransition()
{/* require use of factory methods */
_MyZTransitionUnique = ++_ZTransitionUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
if (!_AllByPrimaryKey.ContainsKey(TransitionID.ToString())) return;
List<ZTransition> listZTransition = _AllByPrimaryKey[TransitionID.ToString()]; // Get the list of items
listZTransition.Remove(this); // Remove the item from the list
if (listZTransition.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(TransitionID.ToString()); // remove the list
RemoveFromDictionaries();
}
private void RemoveFromDictionaries()
{
RemoveFromCache(this);
if (_CacheByPrimaryKey.ContainsKey(TransitionID.ToString()))
{
List<ZTransition> listZTransition = _CacheByPrimaryKey[TransitionID.ToString()]; // Get the list of items
while (listZTransition.Contains(this)) listZTransition.Remove(this); // Remove the item from the list
if (listZTransition.Count == 0) //If there are no items left in the list
_CacheByPrimaryKey.Remove(TransitionID.ToString()); // remove the list
}
}
public static ZTransition New()
{
@ -297,7 +310,11 @@ namespace VEPROMS.CSLA.Library
{
ZTransition tmp = ZTransition.New(myTransition, oldto);
if (tmp.IsSavable)
tmp = tmp.Save();
{
ZTransition tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
@ -323,13 +340,17 @@ namespace VEPROMS.CSLA.Library
throw new System.Security.SecurityException("User not authorized to view a ZTransition");
try
{
ZTransition tmp = GetExistingByPrimaryKey(transitionID);
ZTransition tmp = GetCachedByPrimaryKey(transitionID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ZTransition>(new PKCriteria(transitionID));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ZTransition
tmp = null;
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
@ -371,7 +392,8 @@ namespace VEPROMS.CSLA.Library
{
BuildRefreshList();
ZTransition zTransition = base.Save();
_AllList.Add(zTransition);//Refresh the item in AllList
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(zTransition);//Refresh the item in AllList
ProcessRefreshList();
return zTransition;
}

View File

@ -36,28 +36,36 @@ namespace VEPROMS.CSLA.Library
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
protected static List<ZTransitionInfo> _AllList = new List<ZTransitionInfo>();
private static Dictionary<string, List<ZTransitionInfo>> _AllByPrimaryKey = new Dictionary<string, List<ZTransitionInfo>>();
private static List<ZTransitionInfo> _CacheList = new List<ZTransitionInfo>();
protected static void AddToCache(ZTransitionInfo zTransitionInfo)
{
if (!_CacheList.Contains(zTransitionInfo)) _CacheList.Add(zTransitionInfo); // In AddToCache
}
protected static void RemoveFromCache(ZTransitionInfo zTransitionInfo)
{
while (_CacheList.Contains(zTransitionInfo)) _CacheList.Remove(zTransitionInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ZTransitionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ZTransitionInfo>>();
private static void ConvertListToDictionary()
{
List<ZTransitionInfo> remove = new List<ZTransitionInfo>();
foreach (ZTransitionInfo tmp in _AllList)
foreach (ZTransitionInfo tmp in _CacheList)
{
if (!_AllByPrimaryKey.ContainsKey(tmp.TransitionID.ToString()))
if (!_CacheByPrimaryKey.ContainsKey(tmp.TransitionID.ToString()))
{
_AllByPrimaryKey[tmp.TransitionID.ToString()] = new List<ZTransitionInfo>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[tmp.TransitionID.ToString()] = new List<ZTransitionInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.TransitionID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[tmp.TransitionID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ZTransitionInfo tmp in remove)
_AllList.Remove(tmp);
RemoveFromCache(tmp);
}
public static ZTransitionInfo GetExistingByPrimaryKey(int transitionID)
protected static ZTransitionInfo GetCachedByPrimaryKey(int transitionID)
{
ConvertListToDictionary();
string key = transitionID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
@ -133,24 +141,23 @@ namespace VEPROMS.CSLA.Library
#endregion
#region Factory Methods
private static int _ZTransitionInfoUnique = 0;
private int _MyZTransitionInfoUnique;
private static int ZTransitionInfoUnique
{ get { return ++_ZTransitionInfoUnique; } }
private int _MyZTransitionInfoUnique = ZTransitionInfoUnique;
public int MyZTransitionInfoUnique
{
get { return _MyZTransitionInfoUnique; }
}
private ZTransitionInfo()
{ get { return _MyZTransitionInfoUnique; } }
protected ZTransitionInfo()
{/* require use of factory methods */
_MyZTransitionInfoUnique = ++_ZTransitionInfoUnique;
_AllList.Add(this);
AddToCache(this);
}
public void Dispose()
{
_AllList.Remove(this);
if (!_AllByPrimaryKey.ContainsKey(TransitionID.ToString())) return;
List<ZTransitionInfo> listZTransitionInfo = _AllByPrimaryKey[TransitionID.ToString()]; // Get the list of items
listZTransitionInfo.Remove(this); // Remove the item from the list
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(TransitionID.ToString())) return;
List<ZTransitionInfo> listZTransitionInfo = _CacheByPrimaryKey[TransitionID.ToString()]; // Get the list of items
while (listZTransitionInfo.Contains(this)) listZTransitionInfo.Remove(this); // Remove the item from the list
if (listZTransitionInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(TransitionID.ToString()); // remove the list
_CacheByPrimaryKey.Remove(TransitionID.ToString()); // remove the list
}
public virtual ZTransition Get()
{
@ -160,11 +167,11 @@ namespace VEPROMS.CSLA.Library
{
string key = tmp.TransitionID.ToString();
ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(key))
foreach (ZTransitionInfo tmpInfo in _AllByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ZTransitionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ZTransition tmp)
protected virtual void RefreshFields(ZTransition tmp)
{
_Oldto = tmp.Oldto;
_ZTransitionInfoExtension.Refresh(this);
@ -177,15 +184,16 @@ namespace VEPROMS.CSLA.Library
// throw new System.Security.SecurityException("User not authorized to view a ZTransition");
try
{
ZTransitionInfo tmp = GetExistingByPrimaryKey(transitionID);
ZTransitionInfo tmp = GetCachedByPrimaryKey(transitionID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ZTransitionInfo>(new PKCriteria(transitionID));
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp._TransitionID = transitionID;
tmp.Dispose(); // Clean-up ZTransitionInfo
tmp = null;
}
return tmp;
}
@ -198,7 +206,6 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal
internal ZTransitionInfo(SafeDataReader dr)
{
_MyZTransitionInfoUnique = ++_ZTransitionInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransitionInfo.Constructor", GetHashCode());
try
{