This commit is contained in:
@@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
#region Collection
|
||||
protected static List<AssignmentInfo> _AllList = new List<AssignmentInfo>();
|
||||
private static Dictionary<string, AssignmentInfo> _AllByPrimaryKey = new Dictionary<string, AssignmentInfo>();
|
||||
private static Dictionary<string, List<AssignmentInfo>> _AllByPrimaryKey = new Dictionary<string, List<AssignmentInfo>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<AssignmentInfo> remove = new List<AssignmentInfo>();
|
||||
foreach (AssignmentInfo tmp in _AllList)
|
||||
{
|
||||
_AllByPrimaryKey[tmp.AID.ToString()]=tmp; // Primary Key
|
||||
if (!_AllByPrimaryKey.ContainsKey(tmp.AID.ToString()))
|
||||
{
|
||||
_AllByPrimaryKey[tmp.AID.ToString()] = new List<AssignmentInfo>(); // Add new list for PrimaryKey
|
||||
}
|
||||
_AllByPrimaryKey[tmp.AID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
remove.Add(tmp);
|
||||
}
|
||||
foreach (AssignmentInfo tmp in remove)
|
||||
@@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
ConvertListToDictionary();
|
||||
string key = aid.ToString();
|
||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
|
||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
@@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("AID",true);
|
||||
CanReadProperty("AID", true);
|
||||
return _AID;
|
||||
}
|
||||
}
|
||||
@@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("GID",true);
|
||||
CanReadProperty("GID", true);
|
||||
if (_MyGroup != null) _GID = _MyGroup.GID;
|
||||
return _GID;
|
||||
}
|
||||
@@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("MyGroup",true);
|
||||
CanReadProperty("MyGroup", true);
|
||||
if (_MyGroup == null && _GID != 0) _MyGroup = GroupInfo.Get(_GID);
|
||||
return _MyGroup;
|
||||
}
|
||||
@@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("RID",true);
|
||||
CanReadProperty("RID", true);
|
||||
if (_MyRole != null) _RID = _MyRole.RID;
|
||||
return _RID;
|
||||
}
|
||||
@@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("MyRole",true);
|
||||
CanReadProperty("MyRole", true);
|
||||
if (_MyRole == null && _RID != 0) _MyRole = RoleInfo.Get(_RID);
|
||||
return _MyRole;
|
||||
}
|
||||
@@ -139,7 +143,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("FolderID",true);
|
||||
CanReadProperty("FolderID", true);
|
||||
if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
|
||||
return _FolderID;
|
||||
}
|
||||
@@ -150,7 +154,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("MyFolder",true);
|
||||
CanReadProperty("MyFolder", true);
|
||||
if (_MyFolder == null && _FolderID != 0) _MyFolder = FolderInfo.Get(_FolderID);
|
||||
return _MyFolder;
|
||||
}
|
||||
@@ -161,7 +165,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("StartDate",true);
|
||||
CanReadProperty("StartDate", true);
|
||||
return _StartDate;
|
||||
}
|
||||
}
|
||||
@@ -171,7 +175,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("EndDate",true);
|
||||
CanReadProperty("EndDate", true);
|
||||
return _EndDate;
|
||||
}
|
||||
}
|
||||
@@ -181,7 +185,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("DTS",true);
|
||||
CanReadProperty("DTS", true);
|
||||
return _DTS;
|
||||
}
|
||||
}
|
||||
@@ -191,7 +195,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("UsrID",true);
|
||||
CanReadProperty("UsrID", true);
|
||||
return _UsrID;
|
||||
}
|
||||
}
|
||||
@@ -215,14 +219,25 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _AssignmentInfoUnique = 0;
|
||||
private int _MyAssignmentInfoUnique;
|
||||
public int MyAssignmentInfoUnique
|
||||
{
|
||||
get { return _MyAssignmentInfoUnique; }
|
||||
}
|
||||
private AssignmentInfo()
|
||||
{/* require use of factory methods */
|
||||
_MyAssignmentInfoUnique = ++_AssignmentInfoUnique;
|
||||
_AllList.Add(this);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
_AllList.Remove(this);
|
||||
_AllByPrimaryKey.Remove(AID.ToString());
|
||||
if (!_AllByPrimaryKey.ContainsKey(AID.ToString())) return;
|
||||
List<AssignmentInfo> listAssignmentInfo = _AllByPrimaryKey[AID.ToString()]; // Get the list of items
|
||||
listAssignmentInfo.Remove(this); // Remove the item from the list
|
||||
if (listAssignmentInfo.Count == 0) // If there are no items left in the list
|
||||
_AllByPrimaryKey.Remove(AID.ToString()); // remove the list
|
||||
}
|
||||
public virtual Assignment Get()
|
||||
{
|
||||
@@ -230,9 +245,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(Assignment tmp)
|
||||
{
|
||||
AssignmentInfo tmpInfo = GetExistingByPrimaryKey(tmp.AID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.AID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(Assignment tmp)
|
||||
{
|
||||
@@ -240,23 +257,23 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
MyGroup.RefreshGroupAssignments(); // Update List for old value
|
||||
_GID = tmp.GID; // Update the value
|
||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||
MyGroup.RefreshGroupAssignments(); // Update List for new value
|
||||
}
|
||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
|
||||
if (_RID != tmp.RID)
|
||||
{
|
||||
MyRole.RefreshRoleAssignments(); // Update List for old value
|
||||
_RID = tmp.RID; // Update the value
|
||||
_MyRole = null; // Reset list so that the next line gets a new list
|
||||
MyRole.RefreshRoleAssignments(); // Update List for new value
|
||||
}
|
||||
_MyRole = null; // Reset list so that the next line gets a new list
|
||||
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
|
||||
if (_FolderID != tmp.FolderID)
|
||||
{
|
||||
MyFolder.RefreshFolderAssignments(); // Update List for old value
|
||||
_FolderID = tmp.FolderID; // Update the value
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
MyFolder.RefreshFolderAssignments(); // Update List for new value
|
||||
}
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for new value
|
||||
_StartDate = tmp.StartDate;
|
||||
_EndDate = tmp.EndDate;
|
||||
_DTS = tmp.DTS;
|
||||
@@ -269,9 +286,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(FolderAssignment tmp)
|
||||
{
|
||||
AssignmentInfo tmpInfo = GetExistingByPrimaryKey(tmp.AID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.AID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(FolderAssignment tmp)
|
||||
{
|
||||
@@ -279,16 +298,16 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
MyGroup.RefreshGroupAssignments(); // Update List for old value
|
||||
_GID = tmp.GID; // Update the value
|
||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||
MyGroup.RefreshGroupAssignments(); // Update List for new value
|
||||
}
|
||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
|
||||
if (_RID != tmp.RID)
|
||||
{
|
||||
MyRole.RefreshRoleAssignments(); // Update List for old value
|
||||
_RID = tmp.RID; // Update the value
|
||||
_MyRole = null; // Reset list so that the next line gets a new list
|
||||
MyRole.RefreshRoleAssignments(); // Update List for new value
|
||||
}
|
||||
_MyRole = null; // Reset list so that the next line gets a new list
|
||||
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
|
||||
_StartDate = tmp.StartDate;
|
||||
_EndDate = tmp.EndDate;
|
||||
_DTS = tmp.DTS;
|
||||
@@ -301,9 +320,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(GroupAssignment tmp)
|
||||
{
|
||||
AssignmentInfo tmpInfo = GetExistingByPrimaryKey(tmp.AID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.AID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(GroupAssignment tmp)
|
||||
{
|
||||
@@ -311,16 +332,16 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
MyRole.RefreshRoleAssignments(); // Update List for old value
|
||||
_RID = tmp.RID; // Update the value
|
||||
_MyRole = null; // Reset list so that the next line gets a new list
|
||||
MyRole.RefreshRoleAssignments(); // Update List for new value
|
||||
}
|
||||
_MyRole = null; // Reset list so that the next line gets a new list
|
||||
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
|
||||
if (_FolderID != tmp.FolderID)
|
||||
{
|
||||
MyFolder.RefreshFolderAssignments(); // Update List for old value
|
||||
_FolderID = tmp.FolderID; // Update the value
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
MyFolder.RefreshFolderAssignments(); // Update List for new value
|
||||
}
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for new value
|
||||
_StartDate = tmp.StartDate;
|
||||
_EndDate = tmp.EndDate;
|
||||
_DTS = tmp.DTS;
|
||||
@@ -333,9 +354,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(RoleAssignment tmp)
|
||||
{
|
||||
AssignmentInfo tmpInfo = GetExistingByPrimaryKey(tmp.AID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.AID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(RoleAssignment tmp)
|
||||
{
|
||||
@@ -343,16 +366,16 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
MyGroup.RefreshGroupAssignments(); // Update List for old value
|
||||
_GID = tmp.GID; // Update the value
|
||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||
MyGroup.RefreshGroupAssignments(); // Update List for new value
|
||||
}
|
||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
|
||||
if (_FolderID != tmp.FolderID)
|
||||
{
|
||||
MyFolder.RefreshFolderAssignments(); // Update List for old value
|
||||
_FolderID = tmp.FolderID; // Update the value
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
MyFolder.RefreshFolderAssignments(); // Update List for new value
|
||||
}
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for new value
|
||||
_StartDate = tmp.StartDate;
|
||||
_EndDate = tmp.EndDate;
|
||||
_DTS = tmp.DTS;
|
||||
@@ -373,7 +396,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<AssignmentInfo>(new PKCriteria(aid));
|
||||
_AllList.Add(tmp);
|
||||
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
@@ -387,14 +410,15 @@ namespace VEPROMS.CSLA.Library
|
||||
#region Data Access Portal
|
||||
internal AssignmentInfo(SafeDataReader dr)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfo.Constructor", GetHashCode());
|
||||
_MyAssignmentInfoUnique = ++_AssignmentInfoUnique;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfo.Constructor", GetHashCode());
|
||||
try
|
||||
{
|
||||
ReadData(dr);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("AssignmentInfo.Constructor", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("AssignmentInfo.Constructor", ex);
|
||||
throw new DbCslaException("AssignmentInfo.Constructor", ex);
|
||||
}
|
||||
}
|
||||
@@ -411,7 +435,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfo.ReadData", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfo.ReadData", GetHashCode());
|
||||
try
|
||||
{
|
||||
_AID = dr.GetInt32("AID");
|
||||
@@ -425,14 +449,14 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("AssignmentInfo.ReadData", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("AssignmentInfo.ReadData", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("AssignmentInfo.ReadData", ex);
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(PKCriteria criteria)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfo.DataPortal_Fetch", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfo.DataPortal_Fetch", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
@@ -460,7 +484,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("AssignmentInfo.DataPortal_Fetch", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("AssignmentInfo.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("AssignmentInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
@@ -470,7 +494,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#region extension
|
||||
AssignmentInfoExtension _AssignmentInfoExtension = new AssignmentInfoExtension();
|
||||
[Serializable()]
|
||||
partial class AssignmentInfoExtension : extensionBase {}
|
||||
partial class AssignmentInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
class extensionBase
|
||||
{
|
||||
|
Reference in New Issue
Block a user