This commit is contained in:
@@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
#region Collection
|
||||
protected static List<RoUsageInfo> _AllList = new List<RoUsageInfo>();
|
||||
private static Dictionary<string, RoUsageInfo> _AllByPrimaryKey = new Dictionary<string, RoUsageInfo>();
|
||||
private static Dictionary<string, List<RoUsageInfo>> _AllByPrimaryKey = new Dictionary<string, List<RoUsageInfo>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<RoUsageInfo> remove = new List<RoUsageInfo>();
|
||||
foreach (RoUsageInfo tmp in _AllList)
|
||||
{
|
||||
_AllByPrimaryKey[tmp.ROUsageID.ToString()]=tmp; // Primary Key
|
||||
if (!_AllByPrimaryKey.ContainsKey(tmp.ROUsageID.ToString()))
|
||||
{
|
||||
_AllByPrimaryKey[tmp.ROUsageID.ToString()] = new List<RoUsageInfo>(); // Add new list for PrimaryKey
|
||||
}
|
||||
_AllByPrimaryKey[tmp.ROUsageID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
remove.Add(tmp);
|
||||
}
|
||||
foreach (RoUsageInfo tmp in remove)
|
||||
@@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
ConvertListToDictionary();
|
||||
string key = rOUsageID.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("ROUsageID",true);
|
||||
CanReadProperty("ROUsageID", true);
|
||||
return _ROUsageID;
|
||||
}
|
||||
}
|
||||
@@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("ContentID",true);
|
||||
CanReadProperty("ContentID", true);
|
||||
if (_MyContent != null) _ContentID = _MyContent.ContentID;
|
||||
return _ContentID;
|
||||
}
|
||||
@@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("MyContent",true);
|
||||
CanReadProperty("MyContent", true);
|
||||
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
|
||||
return _MyContent;
|
||||
}
|
||||
@@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("ROID",true);
|
||||
CanReadProperty("ROID", true);
|
||||
return _ROID;
|
||||
}
|
||||
}
|
||||
@@ -127,7 +131,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("Config",true);
|
||||
CanReadProperty("Config", true);
|
||||
return _Config;
|
||||
}
|
||||
}
|
||||
@@ -137,7 +141,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("DTS",true);
|
||||
CanReadProperty("DTS", true);
|
||||
return _DTS;
|
||||
}
|
||||
}
|
||||
@@ -147,7 +151,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("UserID",true);
|
||||
CanReadProperty("UserID", true);
|
||||
return _UserID;
|
||||
}
|
||||
}
|
||||
@@ -171,14 +175,25 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _RoUsageInfoUnique = 0;
|
||||
private int _MyRoUsageInfoUnique;
|
||||
public int MyRoUsageInfoUnique
|
||||
{
|
||||
get { return _MyRoUsageInfoUnique; }
|
||||
}
|
||||
private RoUsageInfo()
|
||||
{/* require use of factory methods */
|
||||
_MyRoUsageInfoUnique = ++_RoUsageInfoUnique;
|
||||
_AllList.Add(this);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
_AllList.Remove(this);
|
||||
_AllByPrimaryKey.Remove(ROUsageID.ToString());
|
||||
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
|
||||
if (listRoUsageInfo.Count == 0) // If there are no items left in the list
|
||||
_AllByPrimaryKey.Remove(ROUsageID.ToString()); // remove the list
|
||||
}
|
||||
public virtual RoUsage Get()
|
||||
{
|
||||
@@ -186,9 +201,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(RoUsage tmp)
|
||||
{
|
||||
RoUsageInfo tmpInfo = GetExistingByPrimaryKey(tmp.ROUsageID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.ROUsageID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (RoUsageInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(RoUsage tmp)
|
||||
{
|
||||
@@ -196,9 +213,9 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
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
|
||||
MyContent.RefreshContentRoUsages(); // Update List for new value
|
||||
}
|
||||
_MyContent = null; // Reset list so that the next line gets a new list
|
||||
if (MyContent != null) MyContent.RefreshContentRoUsages(); // Update List for new value
|
||||
_ROID = tmp.ROID;
|
||||
_Config = tmp.Config;
|
||||
_DTS = tmp.DTS;
|
||||
@@ -209,9 +226,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(ContentRoUsage tmp)
|
||||
{
|
||||
RoUsageInfo tmpInfo = GetExistingByPrimaryKey(tmp.ROUsageID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.ROUsageID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (RoUsageInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(ContentRoUsage tmp)
|
||||
{
|
||||
@@ -233,7 +252,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<RoUsageInfo>(new PKCriteria(rOUsageID));
|
||||
_AllList.Add(tmp);
|
||||
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
@@ -247,14 +266,15 @@ namespace VEPROMS.CSLA.Library
|
||||
#region Data Access Portal
|
||||
internal RoUsageInfo(SafeDataReader dr)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsageInfo.Constructor", GetHashCode());
|
||||
_MyRoUsageInfoUnique = ++_RoUsageInfoUnique;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfo.Constructor", GetHashCode());
|
||||
try
|
||||
{
|
||||
ReadData(dr);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsageInfo.Constructor", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsageInfo.Constructor", ex);
|
||||
throw new DbCslaException("RoUsageInfo.Constructor", ex);
|
||||
}
|
||||
}
|
||||
@@ -271,7 +291,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsageInfo.ReadData", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfo.ReadData", GetHashCode());
|
||||
try
|
||||
{
|
||||
_ROUsageID = dr.GetInt32("ROUsageID");
|
||||
@@ -283,14 +303,14 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsageInfo.ReadData", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsageInfo.ReadData", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("RoUsageInfo.ReadData", ex);
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(PKCriteria criteria)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsageInfo.DataPortal_Fetch", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfo.DataPortal_Fetch", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
@@ -318,7 +338,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsageInfo.DataPortal_Fetch", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsageInfo.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("RoUsageInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
@@ -328,7 +348,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#region extension
|
||||
RoUsageInfoExtension _RoUsageInfoExtension = new RoUsageInfoExtension();
|
||||
[Serializable()]
|
||||
partial class RoUsageInfoExtension : extensionBase {}
|
||||
partial class RoUsageInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
class extensionBase
|
||||
{
|
||||
|
Reference in New Issue
Block a user