This commit is contained in:
@@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
#region Collection
|
||||
protected static List<ZTransitionInfo> _AllList = new List<ZTransitionInfo>();
|
||||
private static Dictionary<string, ZTransitionInfo> _AllByPrimaryKey = new Dictionary<string, ZTransitionInfo>();
|
||||
private static Dictionary<string, List<ZTransitionInfo>> _AllByPrimaryKey = new Dictionary<string, List<ZTransitionInfo>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<ZTransitionInfo> remove = new List<ZTransitionInfo>();
|
||||
foreach (ZTransitionInfo tmp in _AllList)
|
||||
{
|
||||
_AllByPrimaryKey[tmp.TransitionID.ToString()]=tmp; // Primary Key
|
||||
if (!_AllByPrimaryKey.ContainsKey(tmp.TransitionID.ToString()))
|
||||
{
|
||||
_AllByPrimaryKey[tmp.TransitionID.ToString()] = new List<ZTransitionInfo>(); // Add new list for PrimaryKey
|
||||
}
|
||||
_AllByPrimaryKey[tmp.TransitionID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
remove.Add(tmp);
|
||||
}
|
||||
foreach (ZTransitionInfo tmp in remove)
|
||||
@@ -53,7 +57,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
ConvertListToDictionary();
|
||||
string key = transitionID.ToString();
|
||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
|
||||
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
@@ -81,7 +85,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("TransitionID",true);
|
||||
CanReadProperty("TransitionID", true);
|
||||
if (_MyTransition != null) _TransitionID = _MyTransition.TransitionID;
|
||||
return _TransitionID;
|
||||
}
|
||||
@@ -93,7 +97,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("MyTransition",true);
|
||||
CanReadProperty("MyTransition", true);
|
||||
if (_MyTransition == null && _TransitionID != 0) _MyTransition = TransitionInfo.Get(_TransitionID);
|
||||
return _MyTransition;
|
||||
}
|
||||
@@ -104,7 +108,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("Oldto",true);
|
||||
CanReadProperty("Oldto", true);
|
||||
return _Oldto;
|
||||
}
|
||||
}
|
||||
@@ -128,14 +132,25 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _ZTransitionInfoUnique = 0;
|
||||
private int _MyZTransitionInfoUnique;
|
||||
public int MyZTransitionInfoUnique
|
||||
{
|
||||
get { return _MyZTransitionInfoUnique; }
|
||||
}
|
||||
private ZTransitionInfo()
|
||||
{/* require use of factory methods */
|
||||
_MyZTransitionInfoUnique = ++_ZTransitionInfoUnique;
|
||||
_AllList.Add(this);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
_AllList.Remove(this);
|
||||
_AllByPrimaryKey.Remove(TransitionID.ToString());
|
||||
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
|
||||
if (listZTransitionInfo.Count == 0) // If there are no items left in the list
|
||||
_AllByPrimaryKey.Remove(TransitionID.ToString()); // remove the list
|
||||
}
|
||||
public virtual ZTransition Get()
|
||||
{
|
||||
@@ -143,9 +158,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(ZTransition tmp)
|
||||
{
|
||||
ZTransitionInfo tmpInfo = GetExistingByPrimaryKey(tmp.TransitionID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.TransitionID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (ZTransitionInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(ZTransition tmp)
|
||||
{
|
||||
@@ -164,7 +181,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<ZTransitionInfo>(new PKCriteria(transitionID));
|
||||
_AllList.Add(tmp);
|
||||
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
@@ -181,14 +198,15 @@ namespace VEPROMS.CSLA.Library
|
||||
#region Data Access Portal
|
||||
internal ZTransitionInfo(SafeDataReader dr)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZTransitionInfo.Constructor", GetHashCode());
|
||||
_MyZTransitionInfoUnique = ++_ZTransitionInfoUnique;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransitionInfo.Constructor", GetHashCode());
|
||||
try
|
||||
{
|
||||
ReadData(dr);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("ZTransitionInfo.Constructor", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransitionInfo.Constructor", ex);
|
||||
throw new DbCslaException("ZTransitionInfo.Constructor", ex);
|
||||
}
|
||||
}
|
||||
@@ -205,7 +223,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZTransitionInfo.ReadData", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransitionInfo.ReadData", GetHashCode());
|
||||
try
|
||||
{
|
||||
_TransitionID = dr.GetInt32("TransitionID");
|
||||
@@ -213,14 +231,14 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("ZTransitionInfo.ReadData", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransitionInfo.ReadData", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("ZTransitionInfo.ReadData", ex);
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(PKCriteria criteria)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZTransitionInfo.DataPortal_Fetch", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransitionInfo.DataPortal_Fetch", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
@@ -248,7 +266,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("ZTransitionInfo.DataPortal_Fetch", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransitionInfo.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("ZTransitionInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
@@ -258,7 +276,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#region extension
|
||||
ZTransitionInfoExtension _ZTransitionInfoExtension = new ZTransitionInfoExtension();
|
||||
[Serializable()]
|
||||
partial class ZTransitionInfoExtension : extensionBase {}
|
||||
partial class ZTransitionInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
class extensionBase
|
||||
{
|
||||
|
Reference in New Issue
Block a user