This commit is contained in:
Jsj
2008-05-16 18:07:47 +00:00
parent 9d0b3cd543
commit cda0291dbd
116 changed files with 4257 additions and 3382 deletions

View File

@@ -47,21 +47,25 @@ namespace VEPROMS.CSLA.Library
foreach (Transition tmp in _RefreshTransitions)
{
TransitionInfo.Refresh(tmp);
if(tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent);
if(tmp._MyItemRangeID != null) ItemInfo.Refresh(tmp._MyItemRangeID);
if(tmp._MyItemToID != null) ItemInfo.Refresh(tmp._MyItemToID);
if (tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent);
if (tmp._MyItemRangeID != null) ItemInfo.Refresh(tmp._MyItemRangeID);
if (tmp._MyItemToID != null) ItemInfo.Refresh(tmp._MyItemToID);
}
}
#endregion
#region Collection
protected static List<Transition> _AllList = new List<Transition>();
private static Dictionary<string, Transition> _AllByPrimaryKey = new Dictionary<string, Transition>();
private static Dictionary<string, List<Transition>> _AllByPrimaryKey = new Dictionary<string, List<Transition>>();
private static void ConvertListToDictionary()
{
List<Transition> remove = new List<Transition>();
foreach (Transition tmp in _AllList)
{
_AllByPrimaryKey[tmp.TransitionID.ToString()]=tmp; // Primary Key
if (!_AllByPrimaryKey.ContainsKey(tmp.TransitionID.ToString()))
{
_AllByPrimaryKey[tmp.TransitionID.ToString()] = new List<Transition>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.TransitionID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (Transition tmp in remove)
@@ -71,7 +75,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
@@ -93,7 +97,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TransitionID",true);
CanReadProperty("TransitionID", true);
return _TransitionID;
}
}
@@ -103,7 +107,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;
}
@@ -114,14 +118,14 @@ 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 = Content.Get(_FromID);
return _MyContent;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyContent",true);
CanWriteProperty("MyContent", true);
if (_MyContent != value)
{
_MyContent = value;
@@ -138,7 +142,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;
}
@@ -149,14 +153,14 @@ 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 = Item.Get(_ToID);
return _MyItemToID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyItemToID",true);
CanWriteProperty("MyItemToID", true);
if (_MyItemToID != value)
{
_MyItemToID = value;
@@ -170,7 +174,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;
}
@@ -181,14 +185,14 @@ 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 = Item.Get(_RangeID);
return _MyItemRangeID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyItemRangeID",true);
CanWriteProperty("MyItemRangeID", true);
if (_MyItemRangeID != value)
{
_MyItemRangeID = value;
@@ -202,13 +206,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TranType",true);
CanReadProperty("TranType", true);
return _TranType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("TranType",true);
CanWriteProperty("TranType", true);
if (_TranType != value)
{
_TranType = value;
@@ -222,13 +226,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
CanReadProperty("Config", true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config",true);
CanWriteProperty("Config", true);
if (value == null) value = string.Empty;
if (_Config != value)
{
@@ -243,13 +247,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
CanReadProperty("DTS", true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
CanWriteProperty("DTS", true);
if (_DTS != value)
{
_DTS = value;
@@ -263,13 +267,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
CanReadProperty("UserID", true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID",true);
CanWriteProperty("UserID", true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
@@ -288,7 +292,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TransitionZTransitionCount",true);
CanReadProperty("TransitionZTransitionCount", true);
return _TransitionZTransitionCount;
}
}
@@ -302,18 +306,18 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyZTransition",true);
if ( _MyZTransition == null) _MyZTransition = ZTransition.New(this);
CanReadProperty("MyZTransition", true);
if (_MyZTransition == null) _MyZTransition = ZTransition.New(this);
return _MyZTransition;
}
}
public override bool IsDirty
{
get { return base.IsDirty || (_MyZTransition == null? false : _MyZTransition.IsDirty) || (_MyContent == null? false : _MyContent.IsDirty) || (_MyItemRangeID == null? false : _MyItemRangeID.IsDirty) || (_MyItemToID == null? false : _MyItemToID.IsDirty); }
get { return base.IsDirty || (_MyZTransition == null ? false : _MyZTransition.IsDirty) || (_MyContent == null ? false : _MyContent.IsDirty) || (_MyItemRangeID == null ? false : _MyItemRangeID.IsDirty) || (_MyItemToID == null ? false : _MyItemToID.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyZTransition == null? true : _MyZTransition.IsValid) && (_MyContent == null? true : _MyContent.IsValid) && (_MyItemRangeID == null? true : _MyItemRangeID.IsValid) && (_MyItemToID == null? true : _MyItemToID.IsValid); }
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyZTransition == null ? true : _MyZTransition.IsValid) && (_MyContent == null ? true : _MyContent.IsValid) && (_MyItemRangeID == null ? true : _MyItemRangeID.IsValid) && (_MyItemToID == null ? true : _MyItemToID.IsValid); }
}
// TODO: Replace base Transition.ToString function as necessary
/// <summary>
@@ -336,25 +340,26 @@ namespace VEPROMS.CSLA.Library
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules=false;
private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules
{
get {
if(_CheckingBrokenRules)return null;
get
{
if (_CheckingBrokenRules) return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules=true;
_CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyZTransition != null && (hasBrokenRules = _MyZTransition.HasBrokenRules) != null) return hasBrokenRules;
if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules;
if (_MyItemToID != null && (hasBrokenRules = _MyItemToID.HasBrokenRules) != null) return hasBrokenRules;
if (_MyItemRangeID != null && (hasBrokenRules = _MyItemRangeID.HasBrokenRules) != null) return hasBrokenRules;
if (_MyZTransition != null && (hasBrokenRules = _MyZTransition.HasBrokenRules) != null) return hasBrokenRules;
if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules;
if (_MyItemToID != null && (hasBrokenRules = _MyItemToID.HasBrokenRules) != null) return hasBrokenRules;
if (_MyItemRangeID != null && (hasBrokenRules = _MyItemRangeID.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
_CheckingBrokenRules = false;
}
}
}
@@ -497,14 +502,25 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private static int _TransitionUnique = 0;
private int _MyTransitionUnique;
public int MyTransitionUnique
{
get { return _MyTransitionUnique; }
}
protected Transition()
{/* require use of factory methods */
_MyTransitionUnique = ++_TransitionUnique;
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(TransitionID.ToString());
if (!_AllByPrimaryKey.ContainsKey(TransitionID.ToString())) return;
List<Transition> listTransition = _AllByPrimaryKey[TransitionID.ToString()]; // Get the list of items
listTransition.Remove(this); // Remove the item from the list
if (listTransition.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(TransitionID.ToString()); // remove the list
}
public static Transition New()
{
@@ -590,7 +606,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null)
{
tmp = DataPortal.Fetch<Transition>(new PKCriteria(transitionID));
_AllList.Add(tmp);
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
@@ -670,7 +686,7 @@ namespace VEPROMS.CSLA.Library
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.ReadData", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.ReadData", GetHashCode());
try
{
_TransitionID = dr.GetInt32("TransitionID");
@@ -687,14 +703,14 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.ReadData", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Transition.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.DataPortal_Fetch", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@@ -725,7 +741,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.DataPortal_Fetch", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Transition.DataPortal_Fetch", ex);
}
@@ -746,13 +762,13 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.DataPortal_Insert", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.DataPortal_Insert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Transition.DataPortal_Insert", ex);
}
finally
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.DataPortal_Insert", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.DataPortal_Insert", GetHashCode());
}
}
[Transactional(TransactionalTypes.TransactionScope)]
@@ -761,9 +777,9 @@ namespace VEPROMS.CSLA.Library
if (!this.IsDirty) return;
try
{
if(_MyContent != null) _MyContent.Update();
if(_MyItemRangeID != null) _MyItemRangeID.Update();
if(_MyItemToID != null) _MyItemToID.Update();
if (_MyContent != null) _MyContent.Update();
if (_MyItemRangeID != null) _MyItemRangeID.Update();
if (_MyItemToID != null) _MyItemToID.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand())
{
@@ -793,11 +809,11 @@ namespace VEPROMS.CSLA.Library
MarkOld();
// update child objects
if (_MyZTransition != null) _MyZTransition.Update(this);
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.SQLInsert", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.SQLInsert", GetHashCode());
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.SQLInsert", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.SQLInsert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Transition.SQLInsert", ex);
}
@@ -805,7 +821,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int transitionID, Content myContent, Item myItemToID, Item myItemRangeID, int tranType, string config, DateTime dts, string userID)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.Add", 0);
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.Add", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
@@ -836,7 +852,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.Add", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.Add", ex);
throw new DbCslaException("Transition.Add", ex);
}
}
@@ -844,7 +860,7 @@ namespace VEPROMS.CSLA.Library
protected override void DataPortal_Update()
{
if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.DataPortal_Update", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.DataPortal_Update", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@@ -858,7 +874,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.DataPortal_Update", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.DataPortal_Update", ex);
_ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
}
@@ -867,12 +883,12 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate()
{
if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.SQLUpdate", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.SQLUpdate", GetHashCode());
try
{
if(_MyContent != null) _MyContent.Update();
if(_MyItemRangeID != null) _MyItemRangeID.Update();
if(_MyItemToID != null) _MyItemToID.Update();
if (_MyContent != null) _MyContent.Update();
if (_MyItemRangeID != null) _MyItemRangeID.Update();
if (_MyItemToID != null) _MyItemToID.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty)
{
@@ -906,7 +922,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.SQLUpdate", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.SQLUpdate", ex);
_ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
}
@@ -928,7 +944,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int transitionID, Content myContent, Item myItemToID, Item myItemRangeID, int tranType, string config, DateTime dts, string userID, ref byte[] lastChanged)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.Update", 0);
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.Update", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
@@ -957,7 +973,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.Update", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.Update", ex);
throw new DbCslaException("Transition.Update", ex);
}
}
@@ -969,7 +985,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.DataPortal_Delete", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.DataPortal_Delete", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@@ -985,7 +1001,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.DataPortal_Delete", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.DataPortal_Delete", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Transition.DataPortal_Delete", ex);
}
@@ -993,7 +1009,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int transitionID)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.Remove", 0);
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.Remove", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
@@ -1008,7 +1024,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.Remove", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.Remove", ex);
throw new DbCslaException("Transition.Remove", ex);
}
}
@@ -1042,7 +1058,7 @@ namespace VEPROMS.CSLA.Library
}
protected override void DataPortal_Execute()
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.DataPortal_Execute", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.DataPortal_Execute", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@@ -1060,7 +1076,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.DataPortal_Execute", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.DataPortal_Execute", ex);
throw new DbCslaException("Transition.DataPortal_Execute", ex);
}
}