This commit is contained in:
@@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
#region Collection
|
||||
protected static List<TransitionInfo> _AllList = new List<TransitionInfo>();
|
||||
private static Dictionary<string, TransitionInfo> _AllByPrimaryKey = new Dictionary<string, TransitionInfo>();
|
||||
private static Dictionary<string, List<TransitionInfo>> _AllByPrimaryKey = new Dictionary<string, List<TransitionInfo>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<TransitionInfo> remove = new List<TransitionInfo>();
|
||||
foreach (TransitionInfo tmp in _AllList)
|
||||
{
|
||||
_AllByPrimaryKey[tmp.TransitionID.ToString()]=tmp; // Primary Key
|
||||
if (!_AllByPrimaryKey.ContainsKey(tmp.TransitionID.ToString()))
|
||||
{
|
||||
_AllByPrimaryKey[tmp.TransitionID.ToString()] = new List<TransitionInfo>(); // Add new list for PrimaryKey
|
||||
}
|
||||
_AllByPrimaryKey[tmp.TransitionID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
remove.Add(tmp);
|
||||
}
|
||||
foreach (TransitionInfo tmp in remove)
|
||||
@@ -57,7 +61,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
|
||||
@@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("TransitionID",true);
|
||||
CanReadProperty("TransitionID", true);
|
||||
return _TransitionID;
|
||||
}
|
||||
}
|
||||
@@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("FromID",true);
|
||||
CanReadProperty("FromID", true);
|
||||
if (_MyContent != null) _FromID = _MyContent.ContentID;
|
||||
return _FromID;
|
||||
}
|
||||
@@ -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 && _FromID != 0) _MyContent = ContentInfo.Get(_FromID);
|
||||
return _MyContent;
|
||||
}
|
||||
@@ -120,7 +124,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("ToID",true);
|
||||
CanReadProperty("ToID", true);
|
||||
if (_MyItemToID != null) _ToID = _MyItemToID.ItemID;
|
||||
return _ToID;
|
||||
}
|
||||
@@ -131,7 +135,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("MyItemToID",true);
|
||||
CanReadProperty("MyItemToID", true);
|
||||
if (_MyItemToID == null && _ToID != 0) _MyItemToID = ItemInfo.Get(_ToID);
|
||||
return _MyItemToID;
|
||||
}
|
||||
@@ -142,7 +146,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("RangeID",true);
|
||||
CanReadProperty("RangeID", true);
|
||||
if (_MyItemRangeID != null) _RangeID = _MyItemRangeID.ItemID;
|
||||
return _RangeID;
|
||||
}
|
||||
@@ -153,7 +157,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("MyItemRangeID",true);
|
||||
CanReadProperty("MyItemRangeID", true);
|
||||
if (_MyItemRangeID == null && _RangeID != 0) _MyItemRangeID = ItemInfo.Get(_RangeID);
|
||||
return _MyItemRangeID;
|
||||
}
|
||||
@@ -164,7 +168,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("TranType",true);
|
||||
CanReadProperty("TranType", true);
|
||||
return _TranType;
|
||||
}
|
||||
}
|
||||
@@ -174,7 +178,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("Config",true);
|
||||
CanReadProperty("Config", true);
|
||||
return _Config;
|
||||
}
|
||||
}
|
||||
@@ -184,7 +188,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("DTS",true);
|
||||
CanReadProperty("DTS", true);
|
||||
return _DTS;
|
||||
}
|
||||
}
|
||||
@@ -194,7 +198,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("UserID",true);
|
||||
CanReadProperty("UserID", true);
|
||||
return _UserID;
|
||||
}
|
||||
}
|
||||
@@ -207,7 +211,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("TransitionZTransitionCount",true);
|
||||
CanReadProperty("TransitionZTransitionCount", true);
|
||||
return _TransitionZTransitionCount;
|
||||
}
|
||||
}
|
||||
@@ -218,7 +222,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("MyZTransition",true);
|
||||
CanReadProperty("MyZTransition", true);
|
||||
if (_TransitionZTransitionCount > 0 && _MyZTransition == null)
|
||||
_MyZTransition = ZTransitionInfo.Get(_TransitionID);
|
||||
return _MyZTransition;
|
||||
@@ -244,14 +248,25 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _TransitionInfoUnique = 0;
|
||||
private int _MyTransitionInfoUnique;
|
||||
public int MyTransitionInfoUnique
|
||||
{
|
||||
get { return _MyTransitionInfoUnique; }
|
||||
}
|
||||
private TransitionInfo()
|
||||
{/* require use of factory methods */
|
||||
_MyTransitionInfoUnique = ++_TransitionInfoUnique;
|
||||
_AllList.Add(this);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
_AllList.Remove(this);
|
||||
_AllByPrimaryKey.Remove(TransitionID.ToString());
|
||||
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
|
||||
if (listTransitionInfo.Count == 0) // If there are no items left in the list
|
||||
_AllByPrimaryKey.Remove(TransitionID.ToString()); // remove the list
|
||||
}
|
||||
public virtual Transition Get()
|
||||
{
|
||||
@@ -259,9 +274,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(Transition tmp)
|
||||
{
|
||||
TransitionInfo tmpInfo = GetExistingByPrimaryKey(tmp.TransitionID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.TransitionID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (TransitionInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(Transition tmp)
|
||||
{
|
||||
@@ -269,23 +286,23 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
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
|
||||
MyContent.RefreshContentTransitions(); // Update List for new 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
|
||||
_ToID = tmp.ToID; // Update the value
|
||||
_MyItemToID = null; // Reset list so that the next line gets a new list
|
||||
MyItemToID.RefreshItemTransitions_ToID(); // Update List for new 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
|
||||
_RangeID = tmp.RangeID; // Update the value
|
||||
_MyItemRangeID = null; // Reset list so that the next line gets a new list
|
||||
MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for new value
|
||||
}
|
||||
_MyItemRangeID = null; // Reset list so that the next line gets a new list
|
||||
if (MyItemRangeID != null) MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for new value
|
||||
_TranType = tmp.TranType;
|
||||
_Config = tmp.Config;
|
||||
_DTS = tmp.DTS;
|
||||
@@ -299,9 +316,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(ContentTransition tmp)
|
||||
{
|
||||
TransitionInfo tmpInfo = GetExistingByPrimaryKey(tmp.TransitionID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.TransitionID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (TransitionInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(ContentTransition tmp)
|
||||
{
|
||||
@@ -309,16 +328,16 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
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
|
||||
MyItemToID.RefreshItemTransitions_ToID(); // Update List for new 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
|
||||
_RangeID = tmp.RangeID; // Update the value
|
||||
_MyItemRangeID = null; // Reset list so that the next line gets a new list
|
||||
MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for new value
|
||||
}
|
||||
_MyItemRangeID = null; // Reset list so that the next line gets a new list
|
||||
if (MyItemRangeID != null) MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for new value
|
||||
_TranType = tmp.TranType;
|
||||
_Config = tmp.Config;
|
||||
_DTS = tmp.DTS;
|
||||
@@ -332,9 +351,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(ItemTransition_RangeID tmp)
|
||||
{
|
||||
TransitionInfo tmpInfo = GetExistingByPrimaryKey(tmp.TransitionID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.TransitionID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (TransitionInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(ItemTransition_RangeID tmp)
|
||||
{
|
||||
@@ -342,16 +363,16 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
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
|
||||
MyContent.RefreshContentTransitions(); // Update List for new 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
|
||||
_ToID = tmp.ToID; // Update the value
|
||||
_MyItemToID = null; // Reset list so that the next line gets a new list
|
||||
MyItemToID.RefreshItemTransitions_ToID(); // Update List for new 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
|
||||
_TranType = tmp.TranType;
|
||||
_Config = tmp.Config;
|
||||
_DTS = tmp.DTS;
|
||||
@@ -365,9 +386,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static void Refresh(ItemTransition_ToID tmp)
|
||||
{
|
||||
TransitionInfo tmpInfo = GetExistingByPrimaryKey(tmp.TransitionID);
|
||||
if (tmpInfo == null) return;
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
string key = tmp.TransitionID.ToString();
|
||||
ConvertListToDictionary();
|
||||
if (_AllByPrimaryKey.ContainsKey(key))
|
||||
foreach (TransitionInfo tmpInfo in _AllByPrimaryKey[key])
|
||||
tmpInfo.RefreshFields(tmp);
|
||||
}
|
||||
private void RefreshFields(ItemTransition_ToID tmp)
|
||||
{
|
||||
@@ -375,16 +398,16 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
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
|
||||
MyContent.RefreshContentTransitions(); // Update List for new 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
|
||||
_RangeID = tmp.RangeID; // Update the value
|
||||
_MyItemRangeID = null; // Reset list so that the next line gets a new list
|
||||
MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for new value
|
||||
}
|
||||
_MyItemRangeID = null; // Reset list so that the next line gets a new list
|
||||
if (MyItemRangeID != null) MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for new value
|
||||
_TranType = tmp.TranType;
|
||||
_Config = tmp.Config;
|
||||
_DTS = tmp.DTS;
|
||||
@@ -406,7 +429,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<TransitionInfo>(new PKCriteria(transitionID));
|
||||
_AllList.Add(tmp);
|
||||
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
@@ -420,14 +443,15 @@ namespace VEPROMS.CSLA.Library
|
||||
#region Data Access Portal
|
||||
internal TransitionInfo(SafeDataReader dr)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] TransitionInfo.Constructor", GetHashCode());
|
||||
_MyTransitionInfoUnique = ++_TransitionInfoUnique;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] TransitionInfo.Constructor", GetHashCode());
|
||||
try
|
||||
{
|
||||
ReadData(dr);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("TransitionInfo.Constructor", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("TransitionInfo.Constructor", ex);
|
||||
throw new DbCslaException("TransitionInfo.Constructor", ex);
|
||||
}
|
||||
}
|
||||
@@ -444,7 +468,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] TransitionInfo.ReadData", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] TransitionInfo.ReadData", GetHashCode());
|
||||
try
|
||||
{
|
||||
_TransitionID = dr.GetInt32("TransitionID");
|
||||
@@ -459,14 +483,14 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("TransitionInfo.ReadData", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("TransitionInfo.ReadData", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("TransitionInfo.ReadData", ex);
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(PKCriteria criteria)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] TransitionInfo.DataPortal_Fetch", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] TransitionInfo.DataPortal_Fetch", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
@@ -494,7 +518,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("TransitionInfo.DataPortal_Fetch", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("TransitionInfo.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("TransitionInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
@@ -504,7 +528,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#region extension
|
||||
TransitionInfoExtension _TransitionInfoExtension = new TransitionInfoExtension();
|
||||
[Serializable()]
|
||||
partial class TransitionInfoExtension : extensionBase {}
|
||||
partial class TransitionInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
class extensionBase
|
||||
{
|
||||
|
Reference in New Issue
Block a user