diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FormatDocVersion.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FormatDocVersion.cs index aa2c1b74..97127734 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FormatDocVersion.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FormatDocVersion.cs @@ -181,7 +181,7 @@ namespace VEPROMS.CSLA.Library set { CanWriteProperty("MyItem", true); - if (_MyItem != value) + if ((_MyItem == null ? _ItemID : (int?)_MyItem.ItemID) != (value == null ? null : (int?)value.ItemID)) { _MyItem = value; _ItemID = (value == null ? null : (int?)value.ItemID); @@ -312,6 +312,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 { @@ -551,6 +561,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"); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FormatFolder.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FormatFolder.cs index 02d183b0..601bcd93 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FormatFolder.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FormatFolder.cs @@ -186,6 +186,26 @@ namespace VEPROMS.CSLA.Library } } } + private double? _ManualOrder; + public double? ManualOrder + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("ManualOrder", true); + return _ManualOrder; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty("ManualOrder", true); + if (_ManualOrder != value) + { + _ManualOrder = value; + PropertyHasChanged(); + } + } + } private string _Config = string.Empty; public string Config { @@ -453,6 +473,8 @@ namespace VEPROMS.CSLA.Library //AuthorizationRules.AllowWrite(Title, ""); //AuthorizationRules.AllowRead(ShortName, ""); //AuthorizationRules.AllowWrite(ShortName, ""); + //AuthorizationRules.AllowRead(ManualOrder, ""); + //AuthorizationRules.AllowWrite(ManualOrder, ""); //AuthorizationRules.AllowRead(Config, ""); //AuthorizationRules.AllowWrite(Config, ""); //AuthorizationRules.AllowRead(DTS, ""); @@ -539,6 +561,7 @@ namespace VEPROMS.CSLA.Library _Name = dr.GetString("Name"); _Title = dr.GetString("Title"); _ShortName = dr.GetString("ShortName"); + _ManualOrder = (double?)dr.GetValue("ManualOrder"); _Config = dr.GetString("Config"); _DTS = dr.GetDateTime("DTS"); _UsrID = dr.GetString("UsrID"); @@ -563,7 +586,7 @@ namespace VEPROMS.CSLA.Library // if we're not dirty then don't update the database if (!this.IsDirty) return; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; - _LastChanged = Folder.Add(cn, ref _FolderID, Folder.Get(_ParentID), _MyConnection, _Name, _Title, _ShortName, myFormat, _Config, _DTS, _UsrID); + _LastChanged = Folder.Add(cn, ref _FolderID, Folder.Get(_ParentID), _MyConnection, _Name, _Title, _ShortName, myFormat, _ManualOrder, _Config, _DTS, _UsrID); MarkOld(); } internal void Update(Format myFormat) @@ -571,7 +594,7 @@ namespace VEPROMS.CSLA.Library // if we're not dirty then don't update the database if (!this.IsDirty) return; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; - _LastChanged = Folder.Update(cn, ref _FolderID, Folder.Get(_ParentID), _MyConnection, _Name, _Title, _ShortName, myFormat, _Config, _DTS, _UsrID, ref _LastChanged); + _LastChanged = Folder.Update(cn, ref _FolderID, Folder.Get(_ParentID), _MyConnection, _Name, _Title, _ShortName, myFormat, _ManualOrder, _Config, _DTS, _UsrID, ref _LastChanged); MarkOld(); } internal void DeleteSelf(Format myFormat) diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfo.cs index 81531686..4077b06c 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfo.cs @@ -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 _AllList = new List(); - private static Dictionary> _AllByPrimaryKey = new Dictionary>(); + private static List _CacheList = new List(); + protected static void AddToCache(FormatInfo formatInfo) + { + if (!_CacheList.Contains(formatInfo)) _CacheList.Add(formatInfo); // In AddToCache + } + protected static void RemoveFromCache(FormatInfo formatInfo) + { + while (_CacheList.Contains(formatInfo)) _CacheList.Remove(formatInfo); // In RemoveFromCache + } + private static Dictionary> _CacheByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); - foreach (FormatInfo tmp in _AllList) + foreach (FormatInfo tmp in _CacheList) { - if (!_AllByPrimaryKey.ContainsKey(tmp.FormatID.ToString())) + if (!_CacheByPrimaryKey.ContainsKey(tmp.FormatID.ToString())) { - _AllByPrimaryKey[tmp.FormatID.ToString()] = new List(); // Add new list for PrimaryKey + _CacheByPrimaryKey[tmp.FormatID.ToString()] = new List(); // Add new list for PrimaryKey } - _AllByPrimaryKey[tmp.FormatID.ToString()].Add(tmp); // Add to Primary Key list + _CacheByPrimaryKey[tmp.FormatID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (FormatInfo tmp in remove) - _AllList.Remove(tmp); + RemoveFromCache(tmp); } internal static void AddList(FormatInfoList lst) { - foreach (FormatInfo item in lst) _AllList.Add(item); + foreach (FormatInfo item in lst) AddToCache(item); } - public static FormatInfo GetExistingByPrimaryKey(int formatID) + protected static FormatInfo GetCachedByPrimaryKey(int formatID) { ConvertListToDictionary(); string key = formatID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; + if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; return null; } #endregion @@ -203,11 +211,11 @@ namespace VEPROMS.CSLA.Library return _FormatContents; } } - internal void RefreshFormatContents() + public void RefreshFormatContents() { ConvertListToDictionary(); - if (_AllByPrimaryKey.ContainsKey(_FormatID.ToString())) - foreach (FormatInfo tmp in _AllByPrimaryKey[_FormatID.ToString()]) + if (_CacheByPrimaryKey.ContainsKey(_FormatID.ToString())) + foreach (FormatInfo tmp in _CacheByPrimaryKey[_FormatID.ToString()]) tmp._FormatContentCount = -1; // This will cause the data to be requeried } private int _FormatDocVersionCount = 0; @@ -238,11 +246,11 @@ namespace VEPROMS.CSLA.Library return _FormatDocVersions; } } - internal void RefreshFormatDocVersions() + public void RefreshFormatDocVersions() { ConvertListToDictionary(); - if (_AllByPrimaryKey.ContainsKey(_FormatID.ToString())) - foreach (FormatInfo tmp in _AllByPrimaryKey[_FormatID.ToString()]) + if (_CacheByPrimaryKey.ContainsKey(_FormatID.ToString())) + foreach (FormatInfo tmp in _CacheByPrimaryKey[_FormatID.ToString()]) tmp._FormatDocVersionCount = -1; // This will cause the data to be requeried } private int _FormatFolderCount = 0; @@ -273,11 +281,11 @@ namespace VEPROMS.CSLA.Library return _FormatFolders; } } - internal void RefreshFormatFolders() + public void RefreshFormatFolders() { ConvertListToDictionary(); - if (_AllByPrimaryKey.ContainsKey(_FormatID.ToString())) - foreach (FormatInfo tmp in _AllByPrimaryKey[_FormatID.ToString()]) + if (_CacheByPrimaryKey.ContainsKey(_FormatID.ToString())) + foreach (FormatInfo tmp in _CacheByPrimaryKey[_FormatID.ToString()]) tmp._FormatFolderCount = -1; // This will cause the data to be requeried } private int _ChildFormatCount = 0; @@ -308,11 +316,11 @@ namespace VEPROMS.CSLA.Library return _ChildFormats; } } - internal void RefreshChildFormats() + public void RefreshChildFormats() { ConvertListToDictionary(); - if (_AllByPrimaryKey.ContainsKey(_FormatID.ToString())) - foreach (FormatInfo tmp in _AllByPrimaryKey[_FormatID.ToString()]) + if (_CacheByPrimaryKey.ContainsKey(_FormatID.ToString())) + foreach (FormatInfo tmp in _CacheByPrimaryKey[_FormatID.ToString()]) tmp._ChildFormatCount = -1; // This will cause the data to be requeried } // TODO: Replace base FormatInfo.ToString function as necessary @@ -336,24 +344,23 @@ namespace VEPROMS.CSLA.Library #endregion #region Factory Methods private static int _FormatInfoUnique = 0; - private int _MyFormatInfoUnique; + private static int FormatInfoUnique + { get { return ++_FormatInfoUnique; } } + private int _MyFormatInfoUnique = FormatInfoUnique; public int MyFormatInfoUnique - { - get { return _MyFormatInfoUnique; } - } - private FormatInfo() + { get { return _MyFormatInfoUnique; } } + protected FormatInfo() {/* require use of factory methods */ - _MyFormatInfoUnique = ++_FormatInfoUnique; - _AllList.Add(this); + AddToCache(this); } public void Dispose() { - _AllList.Remove(this); - if (!_AllByPrimaryKey.ContainsKey(FormatID.ToString())) return; - List listFormatInfo = _AllByPrimaryKey[FormatID.ToString()]; // Get the list of items - listFormatInfo.Remove(this); // Remove the item from the list + RemoveFromCache(this); + if (!_CacheByPrimaryKey.ContainsKey(FormatID.ToString())) return; + List listFormatInfo = _CacheByPrimaryKey[FormatID.ToString()]; // Get the list of items + while (listFormatInfo.Contains(this)) listFormatInfo.Remove(this); // Remove the item from the list if (listFormatInfo.Count == 0) // If there are no items left in the list - _AllByPrimaryKey.Remove(FormatID.ToString()); // remove the list + _CacheByPrimaryKey.Remove(FormatID.ToString()); // remove the list } public virtual Format Get() { @@ -363,15 +370,15 @@ namespace VEPROMS.CSLA.Library { string key = tmp.FormatID.ToString(); ConvertListToDictionary(); - if (_AllByPrimaryKey.ContainsKey(key)) - foreach (FormatInfo tmpInfo in _AllByPrimaryKey[key]) + if (_CacheByPrimaryKey.ContainsKey(key)) + foreach (FormatInfo tmpInfo in _CacheByPrimaryKey[key]) tmpInfo.RefreshFields(tmp); } - private void RefreshFields(Format tmp) + protected virtual void RefreshFields(Format tmp) { if (_ParentID != tmp.ParentID) { - MyParent.RefreshChildFormats(); // Update List for old value + if (MyParent != null) MyParent.RefreshChildFormats(); // Update List for old value _ParentID = tmp.ParentID; // Update the value } _MyParent = null; // Reset list so that the next line gets a new list @@ -392,13 +399,17 @@ namespace VEPROMS.CSLA.Library // throw new System.Security.SecurityException("User not authorized to view a Format"); try { - FormatInfo tmp = GetExistingByPrimaryKey(formatID); + FormatInfo tmp = GetCachedByPrimaryKey(formatID); if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(formatID)); - if (!_AllList.Contains(tmp)) _AllList.Add(tmp); + AddToCache(tmp); + } + if (tmp.ErrorMessage == "No Record Found") + { + tmp.Dispose(); // Clean-up FormatInfo + tmp = null; } - if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; } catch (Exception ex) @@ -410,7 +421,6 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal internal FormatInfo(SafeDataReader dr) { - _MyFormatInfoUnique = ++_FormatInfoUnique; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfo.Constructor", GetHashCode()); try { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Group.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Group.cs index 9b2e6df6..e17a73fb 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Group.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Group.cs @@ -77,38 +77,46 @@ namespace VEPROMS.CSLA.Library } #endregion #region Collection - protected static List _AllList = new List(); - private static Dictionary> _AllByPrimaryKey = new Dictionary>(); - private static Dictionary> _AllByGroupName = new Dictionary>(); + private static List _CacheList = new List(); + protected static void AddToCache(Group group) + { + if (!_CacheList.Contains(group)) _CacheList.Add(group); // In AddToCache + } + protected static void RemoveFromCache(Group group) + { + while (_CacheList.Contains(group)) _CacheList.Remove(group); // In RemoveFromCache + } + private static Dictionary> _CacheByPrimaryKey = new Dictionary>(); + private static Dictionary> _CacheByGroupName = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); - foreach (Group tmp in _AllList) + foreach (Group tmp in _CacheList) { - if (!_AllByPrimaryKey.ContainsKey(tmp.GID.ToString())) + if (!_CacheByPrimaryKey.ContainsKey(tmp.GID.ToString())) { - _AllByPrimaryKey[tmp.GID.ToString()] = new List(); // Add new list for PrimaryKey - _AllByGroupName[tmp.GroupName.ToString()] = new List(); // Add new list for GroupName + _CacheByPrimaryKey[tmp.GID.ToString()] = new List(); // Add new list for PrimaryKey + _CacheByGroupName[tmp.GroupName.ToString()] = new List(); // Add new list for GroupName } - _AllByPrimaryKey[tmp.GID.ToString()].Add(tmp); // Add to Primary Key list - _AllByGroupName[tmp.GroupName.ToString()].Add(tmp); // Unique Index + _CacheByPrimaryKey[tmp.GID.ToString()].Add(tmp); // Add to Primary Key list + _CacheByGroupName[tmp.GroupName.ToString()].Add(tmp); // Unique Index remove.Add(tmp); } foreach (Group tmp in remove) - _AllList.Remove(tmp); + RemoveFromCache(tmp); } - public static Group GetExistingByPrimaryKey(int gid) + protected static Group GetCachedByPrimaryKey(int gid) { ConvertListToDictionary(); string key = gid.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; + if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; return null; } - public static Group GetExistingByGroupName(string groupName) + protected static Group GetCachedByGroupName(string groupName) { ConvertListToDictionary(); string key = groupName.ToString(); - if (_AllByGroupName.ContainsKey(key)) return _AllByGroupName[key][0]; + if (_CacheByGroupName.ContainsKey(key)) return _CacheByGroupName[key][0]; return null; } #endregion @@ -462,28 +470,41 @@ namespace VEPROMS.CSLA.Library public int CurrentEditLevel { get { return EditLevel; } } private static int _GroupUnique = 0; - private int _MyGroupUnique; + protected static int GroupUnique + { get { return ++_GroupUnique; } } + private int _MyGroupUnique = GroupUnique; public int MyGroupUnique - { - get { return _MyGroupUnique; } - } + { get { return _MyGroupUnique; } } protected Group() {/* require use of factory methods */ - _MyGroupUnique = ++_GroupUnique; - _AllList.Add(this); + AddToCache(this); } public void Dispose() { - _AllList.Remove(this); - if (!_AllByPrimaryKey.ContainsKey(GID.ToString())) return; - List listGroup = _AllByPrimaryKey[GID.ToString()]; // Get the list of items - listGroup.Remove(this); // Remove the item from the list - if (listGroup.Count == 0) //If there are no items left in the list - _AllByPrimaryKey.Remove(GID.ToString()); // remove the list - listGroup = _AllByGroupName[GID.ToString()]; // Get the list of items - listGroup.Remove(this); // Remove the item from the list - if (listGroup.Count == 0) //If there are no items left in the list - _AllByGroupName.Remove(GID.ToString()); // remove the list + RemoveFromDictionaries(); + } + private void RemoveFromDictionaries() + { + RemoveFromCache(this); + if (_CacheByPrimaryKey.ContainsKey(GID.ToString())) + { + List listGroup = _CacheByPrimaryKey[GID.ToString()]; // Get the list of items + while (listGroup.Contains(this)) listGroup.Remove(this); // Remove the item from the list + if (listGroup.Count == 0) //If there are no items left in the list + _CacheByPrimaryKey.Remove(GID.ToString()); // remove the list + } + string myKey; + myKey = null; + foreach (string key in _CacheByGroupName.Keys) + if (_CacheByGroupName[key].Contains(this)) + myKey = key; + if (myKey != null) + { + List listGroup = _CacheByGroupName[myKey]; // Get the list of items + listGroup.Remove(this); // Remove the item from the list + if (listGroup.Count == 0) //If there are no items left in the list + _CacheByGroupName.Remove(myKey); // remove the list + } } public static Group New() { @@ -518,7 +539,11 @@ namespace VEPROMS.CSLA.Library { Group tmp = Group.New(groupName, groupType, config, dts, usrID); if (tmp.IsSavable) - tmp = tmp.Save(); + { + Group tmp2 = tmp; + tmp = tmp2.Save(); + tmp2.Dispose(); + } else { Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules(); @@ -542,7 +567,11 @@ namespace VEPROMS.CSLA.Library { Group tmp = Group.New(groupName, groupType, config); if (tmp.IsSavable) - tmp = tmp.Save(); + { + Group tmp2 = tmp; + tmp = tmp2.Save(); + tmp2.Dispose(); + } else { Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules(); @@ -560,13 +589,17 @@ namespace VEPROMS.CSLA.Library throw new System.Security.SecurityException("User not authorized to view a Group"); try { - Group tmp = GetExistingByPrimaryKey(gid); + Group tmp = GetCachedByPrimaryKey(gid); if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(gid)); - if (!_AllList.Contains(tmp)) _AllList.Add(tmp); + AddToCache(tmp); + } + if (tmp.ErrorMessage == "No Record Found") + { + tmp.Dispose(); // Clean-up Group + tmp = null; } - if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; } catch (Exception ex) @@ -574,19 +607,23 @@ namespace VEPROMS.CSLA.Library throw new DbCslaException("Error on Group.Get", ex); } } - private static Group GetByGroupName(string groupName) + public static Group GetByGroupName(string groupName) { if (!CanGetObject()) throw new System.Security.SecurityException("User not authorized to view a Group"); try { - Group tmp = GetExistingByGroupName(groupName); + Group tmp = GetCachedByGroupName(groupName); if (tmp == null) { tmp = DataPortal.Fetch(new GroupNameCriteria(groupName)); - if (!_AllList.Contains(tmp)) _AllList.Add(tmp); + AddToCache(tmp); + } + if (tmp.ErrorMessage == "No Record Found") + { + tmp.Dispose(); // Clean-up Group + tmp = null; } - if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; } catch (Exception ex) @@ -628,7 +665,8 @@ namespace VEPROMS.CSLA.Library { BuildRefreshList(); Group group = base.Save(); - _AllList.Add(group);//Refresh the item in AllList + RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache + AddToCache(group);//Refresh the item in AllList ProcessRefreshList(); return group; } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/GroupAssignment.cs b/PROMS/VEPROMS.CSLA.Library/Generated/GroupAssignment.cs index 5cf4f607..d85321ec 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/GroupAssignment.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/GroupAssignment.cs @@ -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 { @@ -587,6 +597,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"); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/GroupInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/GroupInfo.cs index c9572e79..4b00a128 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/GroupInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/GroupInfo.cs @@ -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 _AllList = new List(); - private static Dictionary> _AllByPrimaryKey = new Dictionary>(); + private static List _CacheList = new List(); + protected static void AddToCache(GroupInfo groupInfo) + { + if (!_CacheList.Contains(groupInfo)) _CacheList.Add(groupInfo); // In AddToCache + } + protected static void RemoveFromCache(GroupInfo groupInfo) + { + while (_CacheList.Contains(groupInfo)) _CacheList.Remove(groupInfo); // In RemoveFromCache + } + private static Dictionary> _CacheByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); - foreach (GroupInfo tmp in _AllList) + foreach (GroupInfo tmp in _CacheList) { - if (!_AllByPrimaryKey.ContainsKey(tmp.GID.ToString())) + if (!_CacheByPrimaryKey.ContainsKey(tmp.GID.ToString())) { - _AllByPrimaryKey[tmp.GID.ToString()] = new List(); // Add new list for PrimaryKey + _CacheByPrimaryKey[tmp.GID.ToString()] = new List(); // Add new list for PrimaryKey } - _AllByPrimaryKey[tmp.GID.ToString()].Add(tmp); // Add to Primary Key list + _CacheByPrimaryKey[tmp.GID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (GroupInfo tmp in remove) - _AllList.Remove(tmp); + RemoveFromCache(tmp); } internal static void AddList(GroupInfoList lst) { - foreach (GroupInfo item in lst) _AllList.Add(item); + foreach (GroupInfo item in lst) AddToCache(item); } - public static GroupInfo GetExistingByPrimaryKey(int gid) + protected static GroupInfo GetCachedByPrimaryKey(int gid) { ConvertListToDictionary(); string key = gid.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; + if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; return null; } #endregion @@ -171,11 +179,11 @@ namespace VEPROMS.CSLA.Library return _GroupAssignments; } } - internal void RefreshGroupAssignments() + public void RefreshGroupAssignments() { ConvertListToDictionary(); - if (_AllByPrimaryKey.ContainsKey(_GID.ToString())) - foreach (GroupInfo tmp in _AllByPrimaryKey[_GID.ToString()]) + if (_CacheByPrimaryKey.ContainsKey(_GID.ToString())) + foreach (GroupInfo tmp in _CacheByPrimaryKey[_GID.ToString()]) tmp._GroupAssignmentCount = -1; // This will cause the data to be requeried } private int _GroupMembershipCount = 0; @@ -206,11 +214,11 @@ namespace VEPROMS.CSLA.Library return _GroupMemberships; } } - internal void RefreshGroupMemberships() + public void RefreshGroupMemberships() { ConvertListToDictionary(); - if (_AllByPrimaryKey.ContainsKey(_GID.ToString())) - foreach (GroupInfo tmp in _AllByPrimaryKey[_GID.ToString()]) + if (_CacheByPrimaryKey.ContainsKey(_GID.ToString())) + foreach (GroupInfo tmp in _CacheByPrimaryKey[_GID.ToString()]) tmp._GroupMembershipCount = -1; // This will cause the data to be requeried } // TODO: Replace base GroupInfo.ToString function as necessary @@ -234,24 +242,23 @@ namespace VEPROMS.CSLA.Library #endregion #region Factory Methods private static int _GroupInfoUnique = 0; - private int _MyGroupInfoUnique; + private static int GroupInfoUnique + { get { return ++_GroupInfoUnique; } } + private int _MyGroupInfoUnique = GroupInfoUnique; public int MyGroupInfoUnique - { - get { return _MyGroupInfoUnique; } - } - private GroupInfo() + { get { return _MyGroupInfoUnique; } } + protected GroupInfo() {/* require use of factory methods */ - _MyGroupInfoUnique = ++_GroupInfoUnique; - _AllList.Add(this); + AddToCache(this); } public void Dispose() { - _AllList.Remove(this); - if (!_AllByPrimaryKey.ContainsKey(GID.ToString())) return; - List listGroupInfo = _AllByPrimaryKey[GID.ToString()]; // Get the list of items - listGroupInfo.Remove(this); // Remove the item from the list + RemoveFromCache(this); + if (!_CacheByPrimaryKey.ContainsKey(GID.ToString())) return; + List listGroupInfo = _CacheByPrimaryKey[GID.ToString()]; // Get the list of items + while (listGroupInfo.Contains(this)) listGroupInfo.Remove(this); // Remove the item from the list if (listGroupInfo.Count == 0) // If there are no items left in the list - _AllByPrimaryKey.Remove(GID.ToString()); // remove the list + _CacheByPrimaryKey.Remove(GID.ToString()); // remove the list } public virtual Group Get() { @@ -261,11 +268,11 @@ namespace VEPROMS.CSLA.Library { string key = tmp.GID.ToString(); ConvertListToDictionary(); - if (_AllByPrimaryKey.ContainsKey(key)) - foreach (GroupInfo tmpInfo in _AllByPrimaryKey[key]) + if (_CacheByPrimaryKey.ContainsKey(key)) + foreach (GroupInfo tmpInfo in _CacheByPrimaryKey[key]) tmpInfo.RefreshFields(tmp); } - private void RefreshFields(Group tmp) + protected virtual void RefreshFields(Group tmp) { _GroupName = tmp.GroupName; _GroupType = tmp.GroupType; @@ -281,13 +288,17 @@ namespace VEPROMS.CSLA.Library // throw new System.Security.SecurityException("User not authorized to view a Group"); try { - GroupInfo tmp = GetExistingByPrimaryKey(gid); + GroupInfo tmp = GetCachedByPrimaryKey(gid); if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(gid)); - if (!_AllList.Contains(tmp)) _AllList.Add(tmp); + AddToCache(tmp); + } + if (tmp.ErrorMessage == "No Record Found") + { + tmp.Dispose(); // Clean-up GroupInfo + tmp = null; } - if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; } catch (Exception ex) @@ -299,7 +310,6 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal internal GroupInfo(SafeDataReader dr) { - _MyGroupInfoUnique = ++_GroupInfoUnique; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfo.Constructor", GetHashCode()); try { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Item.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Item.cs index 6251646d..743c337d 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Item.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Item.cs @@ -124,28 +124,36 @@ namespace VEPROMS.CSLA.Library } #endregion #region Collection - protected static List _AllList = new List(); - private static Dictionary> _AllByPrimaryKey = new Dictionary>(); + private static List _CacheList = new List(); + protected static void AddToCache(Item item) + { + if (!_CacheList.Contains(item)) _CacheList.Add(item); // In AddToCache + } + protected static void RemoveFromCache(Item item) + { + while (_CacheList.Contains(item)) _CacheList.Remove(item); // In RemoveFromCache + } + private static Dictionary> _CacheByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); - foreach (Item tmp in _AllList) + foreach (Item tmp in _CacheList) { - if (!_AllByPrimaryKey.ContainsKey(tmp.ItemID.ToString())) + if (!_CacheByPrimaryKey.ContainsKey(tmp.ItemID.ToString())) { - _AllByPrimaryKey[tmp.ItemID.ToString()] = new List(); // Add new list for PrimaryKey + _CacheByPrimaryKey[tmp.ItemID.ToString()] = new List(); // Add new list for PrimaryKey } - _AllByPrimaryKey[tmp.ItemID.ToString()].Add(tmp); // Add to Primary Key list + _CacheByPrimaryKey[tmp.ItemID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (Item tmp in remove) - _AllList.Remove(tmp); + RemoveFromCache(tmp); } - public static Item GetExistingByPrimaryKey(int itemID) + protected static Item GetCachedByPrimaryKey(int itemID) { ConvertListToDictionary(); string key = itemID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; + if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; return null; } #endregion @@ -196,7 +204,7 @@ namespace VEPROMS.CSLA.Library set { CanWriteProperty("MyPrevious", true); - if (_MyPrevious != value) + if ((_MyPrevious == null ? _PreviousID : (int?)_MyPrevious.ItemID) != (value == null ? null : (int?)value.ItemID)) { _MyPrevious = value; _PreviousID = (value == null ? null : (int?)value.ItemID); @@ -635,24 +643,29 @@ namespace VEPROMS.CSLA.Library public int CurrentEditLevel { get { return EditLevel; } } private static int _ItemUnique = 0; - private int _MyItemUnique; + protected static int ItemUnique + { get { return ++_ItemUnique; } } + private int _MyItemUnique = ItemUnique; public int MyItemUnique - { - get { return _MyItemUnique; } - } + { get { return _MyItemUnique; } } protected Item() {/* require use of factory methods */ - _MyItemUnique = ++_ItemUnique; - _AllList.Add(this); + AddToCache(this); } public void Dispose() { - _AllList.Remove(this); - if (!_AllByPrimaryKey.ContainsKey(ItemID.ToString())) return; - List listItem = _AllByPrimaryKey[ItemID.ToString()]; // Get the list of items - listItem.Remove(this); // Remove the item from the list - if (listItem.Count == 0) //If there are no items left in the list - _AllByPrimaryKey.Remove(ItemID.ToString()); // remove the list + RemoveFromDictionaries(); + } + private void RemoveFromDictionaries() + { + RemoveFromCache(this); + if (_CacheByPrimaryKey.ContainsKey(ItemID.ToString())) + { + List listItem = _CacheByPrimaryKey[ItemID.ToString()]; // Get the list of items + while (listItem.Contains(this)) listItem.Remove(this); // Remove the item from the list + if (listItem.Count == 0) //If there are no items left in the list + _CacheByPrimaryKey.Remove(ItemID.ToString()); // remove the list + } } public static Item New() { @@ -686,7 +699,11 @@ namespace VEPROMS.CSLA.Library { Item tmp = Item.New(myPrevious, myContent, dts, userID); if (tmp.IsSavable) - tmp = tmp.Save(); + { + Item tmp2 = tmp; + tmp = tmp2.Save(); + tmp2.Dispose(); + } else { Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules(); @@ -709,7 +726,11 @@ namespace VEPROMS.CSLA.Library { Item tmp = Item.New(myPrevious, myContent); if (tmp.IsSavable) - tmp = tmp.Save(); + { + Item tmp2 = tmp; + tmp = tmp2.Save(); + tmp2.Dispose(); + } else { Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules(); @@ -727,13 +748,17 @@ namespace VEPROMS.CSLA.Library throw new System.Security.SecurityException("User not authorized to view a Item"); try { - Item tmp = GetExistingByPrimaryKey(itemID); + Item tmp = GetCachedByPrimaryKey(itemID); if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(itemID)); - if (!_AllList.Contains(tmp)) _AllList.Add(tmp); + AddToCache(tmp); + } + if (tmp.ErrorMessage == "No Record Found") + { + tmp.Dispose(); // Clean-up Item + tmp = null; } - if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; } catch (Exception ex) @@ -785,7 +810,8 @@ namespace VEPROMS.CSLA.Library { BuildRefreshList(); Item item = base.Save(); - _AllList.Add(item);//Refresh the item in AllList + RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache + AddToCache(item);//Refresh the item in AllList ProcessRefreshList(); return item; } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ItemDocVersion.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ItemDocVersion.cs index d6e40d34..8cca4ccf 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ItemDocVersion.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ItemDocVersion.cs @@ -181,7 +181,7 @@ namespace VEPROMS.CSLA.Library set { CanWriteProperty("MyFormat", true); - if (_MyFormat != value) + if ((_MyFormat == null ? _FormatID : (int?)_MyFormat.FormatID) != (value == null ? null : (int?)value.FormatID)) { _MyFormat = value; _FormatID = (value == null ? null : (int?)value.FormatID); @@ -312,6 +312,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 { @@ -551,6 +561,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"); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfo.cs index 9c48585d..f1b7b11a 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfo.cs @@ -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 _AllList = new List(); - private static Dictionary> _AllByPrimaryKey = new Dictionary>(); + private static List _CacheList = new List(); + protected static void AddToCache(ItemInfo itemInfo) + { + if (!_CacheList.Contains(itemInfo)) _CacheList.Add(itemInfo); // In AddToCache + } + protected static void RemoveFromCache(ItemInfo itemInfo) + { + while (_CacheList.Contains(itemInfo)) _CacheList.Remove(itemInfo); // In RemoveFromCache + } + private static Dictionary> _CacheByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); - foreach (ItemInfo tmp in _AllList) + foreach (ItemInfo tmp in _CacheList) { - if (!_AllByPrimaryKey.ContainsKey(tmp.ItemID.ToString())) + if (!_CacheByPrimaryKey.ContainsKey(tmp.ItemID.ToString())) { - _AllByPrimaryKey[tmp.ItemID.ToString()] = new List(); // Add new list for PrimaryKey + _CacheByPrimaryKey[tmp.ItemID.ToString()] = new List(); // Add new list for PrimaryKey } - _AllByPrimaryKey[tmp.ItemID.ToString()].Add(tmp); // Add to Primary Key list + _CacheByPrimaryKey[tmp.ItemID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (ItemInfo tmp in remove) - _AllList.Remove(tmp); + RemoveFromCache(tmp); } internal static void AddList(ItemInfoList lst) { - foreach (ItemInfo item in lst) _AllList.Add(item); + foreach (ItemInfo item in lst) AddToCache(item); } - public static ItemInfo GetExistingByPrimaryKey(int itemID) + protected static ItemInfo GetCachedByPrimaryKey(int itemID) { ConvertListToDictionary(); string key = itemID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; + if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; return null; } #endregion @@ -185,11 +193,11 @@ namespace VEPROMS.CSLA.Library return _ItemAnnotations; } } - internal void RefreshItemAnnotations() + public void RefreshItemAnnotations() { ConvertListToDictionary(); - if (_AllByPrimaryKey.ContainsKey(_ItemID.ToString())) - foreach (ItemInfo tmp in _AllByPrimaryKey[_ItemID.ToString()]) + if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString())) + foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()]) tmp._ItemAnnotationCount = -1; // This will cause the data to be requeried } private int _ItemDocVersionCount = 0; @@ -220,11 +228,11 @@ namespace VEPROMS.CSLA.Library return _ItemDocVersions; } } - internal void RefreshItemDocVersions() + public void RefreshItemDocVersions() { ConvertListToDictionary(); - if (_AllByPrimaryKey.ContainsKey(_ItemID.ToString())) - foreach (ItemInfo tmp in _AllByPrimaryKey[_ItemID.ToString()]) + if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString())) + foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()]) tmp._ItemDocVersionCount = -1; // This will cause the data to be requeried } private int _NextItemCount = 0; @@ -255,11 +263,11 @@ namespace VEPROMS.CSLA.Library return _NextItems; } } - internal void RefreshNextItems() + public void RefreshNextItems() { ConvertListToDictionary(); - if (_AllByPrimaryKey.ContainsKey(_ItemID.ToString())) - foreach (ItemInfo tmp in _AllByPrimaryKey[_ItemID.ToString()]) + if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString())) + foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()]) tmp._NextItemCount = -1; // This will cause the data to be requeried } private int _ItemPartCount = 0; @@ -290,11 +298,11 @@ namespace VEPROMS.CSLA.Library return _ItemParts; } } - internal void RefreshItemParts() + public void RefreshItemParts() { ConvertListToDictionary(); - if (_AllByPrimaryKey.ContainsKey(_ItemID.ToString())) - foreach (ItemInfo tmp in _AllByPrimaryKey[_ItemID.ToString()]) + if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString())) + foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()]) tmp._ItemPartCount = -1; // This will cause the data to be requeried } private int _ItemTransition_RangeIDCount = 0; @@ -325,11 +333,11 @@ namespace VEPROMS.CSLA.Library return _ItemTransitions_RangeID; } } - internal void RefreshItemTransitions_RangeID() + public void RefreshItemTransitions_RangeID() { ConvertListToDictionary(); - if (_AllByPrimaryKey.ContainsKey(_ItemID.ToString())) - foreach (ItemInfo tmp in _AllByPrimaryKey[_ItemID.ToString()]) + if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString())) + foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()]) tmp._ItemTransition_RangeIDCount = -1; // This will cause the data to be requeried } private int _ItemTransition_ToIDCount = 0; @@ -360,11 +368,11 @@ namespace VEPROMS.CSLA.Library return _ItemTransitions_ToID; } } - internal void RefreshItemTransitions_ToID() + public void RefreshItemTransitions_ToID() { ConvertListToDictionary(); - if (_AllByPrimaryKey.ContainsKey(_ItemID.ToString())) - foreach (ItemInfo tmp in _AllByPrimaryKey[_ItemID.ToString()]) + if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString())) + foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()]) tmp._ItemTransition_ToIDCount = -1; // This will cause the data to be requeried } // TODO: Replace base ItemInfo.ToString function as necessary @@ -388,24 +396,23 @@ namespace VEPROMS.CSLA.Library #endregion #region Factory Methods private static int _ItemInfoUnique = 0; - private int _MyItemInfoUnique; + private static int ItemInfoUnique + { get { return ++_ItemInfoUnique; } } + private int _MyItemInfoUnique = ItemInfoUnique; public int MyItemInfoUnique - { - get { return _MyItemInfoUnique; } - } - private ItemInfo() + { get { return _MyItemInfoUnique; } } + protected ItemInfo() {/* require use of factory methods */ - _MyItemInfoUnique = ++_ItemInfoUnique; - _AllList.Add(this); + AddToCache(this); } public void Dispose() { - _AllList.Remove(this); - if (!_AllByPrimaryKey.ContainsKey(ItemID.ToString())) return; - List listItemInfo = _AllByPrimaryKey[ItemID.ToString()]; // Get the list of items - listItemInfo.Remove(this); // Remove the item from the list + RemoveFromCache(this); + if (!_CacheByPrimaryKey.ContainsKey(ItemID.ToString())) return; + List listItemInfo = _CacheByPrimaryKey[ItemID.ToString()]; // Get the list of items + while (listItemInfo.Contains(this)) listItemInfo.Remove(this); // Remove the item from the list if (listItemInfo.Count == 0) // If there are no items left in the list - _AllByPrimaryKey.Remove(ItemID.ToString()); // remove the list + _CacheByPrimaryKey.Remove(ItemID.ToString()); // remove the list } public virtual Item Get() { @@ -415,22 +422,22 @@ namespace VEPROMS.CSLA.Library { string key = tmp.ItemID.ToString(); ConvertListToDictionary(); - if (_AllByPrimaryKey.ContainsKey(key)) - foreach (ItemInfo tmpInfo in _AllByPrimaryKey[key]) + if (_CacheByPrimaryKey.ContainsKey(key)) + foreach (ItemInfo tmpInfo in _CacheByPrimaryKey[key]) tmpInfo.RefreshFields(tmp); } - private void RefreshFields(Item tmp) + protected virtual void RefreshFields(Item tmp) { if (_PreviousID != tmp.PreviousID) { - MyPrevious.RefreshNextItems(); // Update List for old value + if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for old value _PreviousID = tmp.PreviousID; // Update the value } _MyPrevious = null; // Reset list so that the next line gets a new list if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for new value if (_ContentID != tmp.ContentID) { - MyContent.RefreshContentItems(); // Update List for old value + if (MyContent != null) MyContent.RefreshContentItems(); // Update List for old value _ContentID = tmp.ContentID; // Update the value } _MyContent = null; // Reset list so that the next line gets a new list @@ -446,15 +453,15 @@ namespace VEPROMS.CSLA.Library { string key = tmp.ItemID.ToString(); ConvertListToDictionary(); - if (_AllByPrimaryKey.ContainsKey(key)) - foreach (ItemInfo tmpInfo in _AllByPrimaryKey[key]) + if (_CacheByPrimaryKey.ContainsKey(key)) + foreach (ItemInfo tmpInfo in _CacheByPrimaryKey[key]) tmpInfo.RefreshFields(tmp); } - private void RefreshFields(ContentItem tmp) + protected virtual void RefreshFields(ContentItem tmp) { if (_PreviousID != tmp.PreviousID) { - MyPrevious.RefreshNextItems(); // Update List for old value + if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for old value _PreviousID = tmp.PreviousID; // Update the value } _MyPrevious = null; // Reset list so that the next line gets a new list @@ -472,13 +479,17 @@ namespace VEPROMS.CSLA.Library // throw new System.Security.SecurityException("User not authorized to view a Item"); try { - ItemInfo tmp = GetExistingByPrimaryKey(itemID); + ItemInfo tmp = GetCachedByPrimaryKey(itemID); if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(itemID)); - if (!_AllList.Contains(tmp)) _AllList.Add(tmp); + AddToCache(tmp); + } + if (tmp.ErrorMessage == "No Record Found") + { + tmp.Dispose(); // Clean-up ItemInfo + tmp = null; } - if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; } catch (Exception ex) @@ -490,7 +501,6 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal internal ItemInfo(SafeDataReader dr) { - _MyItemInfoUnique = ++_ItemInfoUnique; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.Constructor", GetHashCode()); try {