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

@@ -45,14 +45,14 @@ namespace VEPROMS.CSLA.Library
{
foreach (ItemAnnotation tmp in _ItemAnnotations)
{
if(tmp.IsDirty)refreshItemAnnotations.Add(tmp);
if (tmp.IsDirty) refreshItemAnnotations.Add(tmp);
}
}
if (_ItemDocVersions != null && _ItemDocVersions.IsDirty)
{
foreach (ItemDocVersion tmp in _ItemDocVersions)
{
if(tmp.IsDirty)refreshItemDocVersions.Add(tmp);
if (tmp.IsDirty) refreshItemDocVersions.Add(tmp);
}
}
if (_NextItems != null && _NextItems.IsDirty)
@@ -66,21 +66,21 @@ namespace VEPROMS.CSLA.Library
{
foreach (ItemPart tmp in _ItemParts)
{
if(tmp.IsDirty)refreshItemParts.Add(tmp);
if (tmp.IsDirty) refreshItemParts.Add(tmp);
}
}
if (_ItemTransitions_RangeID != null && _ItemTransitions_RangeID.IsDirty)
{
foreach (ItemTransition_RangeID tmp in _ItemTransitions_RangeID)
{
if(tmp.IsDirty)refreshItemTransitions_RangeID.Add(tmp);
if (tmp.IsDirty) refreshItemTransitions_RangeID.Add(tmp);
}
}
if (_ItemTransitions_ToID != null && _ItemTransitions_ToID.IsDirty)
{
foreach (ItemTransition_ToID tmp in _ItemTransitions_ToID)
{
if(tmp.IsDirty)refreshItemTransitions_ToID.Add(tmp);
if (tmp.IsDirty) refreshItemTransitions_ToID.Add(tmp);
}
}
}
@@ -99,7 +99,7 @@ namespace VEPROMS.CSLA.Library
foreach (Item tmp in _RefreshItems)
{
ItemInfo.Refresh(tmp);
if(tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent);
if (tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent);
}
foreach (ItemAnnotation tmp in _RefreshItemAnnotations)
{
@@ -125,13 +125,17 @@ namespace VEPROMS.CSLA.Library
#endregion
#region Collection
protected static List<Item> _AllList = new List<Item>();
private static Dictionary<string, Item> _AllByPrimaryKey = new Dictionary<string, Item>();
private static Dictionary<string, List<Item>> _AllByPrimaryKey = new Dictionary<string, List<Item>>();
private static void ConvertListToDictionary()
{
List<Item> remove = new List<Item>();
foreach (Item tmp in _AllList)
{
_AllByPrimaryKey[tmp.ItemID.ToString()]=tmp; // Primary Key
if (!_AllByPrimaryKey.ContainsKey(tmp.ItemID.ToString()))
{
_AllByPrimaryKey[tmp.ItemID.ToString()] = new List<Item>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.ItemID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (Item tmp in remove)
@@ -141,7 +145,7 @@ namespace VEPROMS.CSLA.Library
{
ConvertListToDictionary();
string key = itemID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null;
}
#endregion
@@ -163,7 +167,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID",true);
CanReadProperty("ItemID", true);
return _ItemID;
}
}
@@ -173,7 +177,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("PreviousID",true);
CanReadProperty("PreviousID", true);
if (_MyPrevious != null) _PreviousID = _MyPrevious.ItemID;
return _PreviousID;
}
@@ -184,18 +188,18 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyPrevious",true);
CanReadProperty("MyPrevious", true);
if (_MyPrevious == null && _PreviousID != null) _MyPrevious = Item.Get((int)_PreviousID);
return _MyPrevious;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyPrevious",true);
CanWriteProperty("MyPrevious", true);
if (_MyPrevious != value)
{
_MyPrevious = value;
_PreviousID = (value == null ? null : (int?) value.ItemID);
_PreviousID = (value == null ? null : (int?)value.ItemID);
PropertyHasChanged();
}
}
@@ -206,7 +210,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;
}
@@ -217,14 +221,14 @@ 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 = Content.Get(_ContentID);
return _MyContent;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyContent",true);
CanWriteProperty("MyContent", true);
if (_MyContent != value)
{
_MyContent = value;
@@ -238,13 +242,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;
@@ -258,13 +262,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)
{
@@ -283,7 +287,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemAnnotationCount",true);
CanReadProperty("ItemAnnotationCount", true);
return _ItemAnnotationCount;
}
}
@@ -297,10 +301,10 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemAnnotations",true);
if(_ItemAnnotationCount > 0 && _ItemAnnotations == null)
CanReadProperty("ItemAnnotations", true);
if (_ItemAnnotationCount > 0 && _ItemAnnotations == null)
_ItemAnnotations = ItemAnnotations.GetByItemID(ItemID);
else if(_ItemAnnotations == null)
else if (_ItemAnnotations == null)
_ItemAnnotations = ItemAnnotations.New();
return _ItemAnnotations;
}
@@ -314,7 +318,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemDocVersionCount",true);
CanReadProperty("ItemDocVersionCount", true);
return _ItemDocVersionCount;
}
}
@@ -328,10 +332,10 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemDocVersions",true);
if(_ItemDocVersionCount > 0 && _ItemDocVersions == null)
CanReadProperty("ItemDocVersions", true);
if (_ItemDocVersionCount > 0 && _ItemDocVersions == null)
_ItemDocVersions = ItemDocVersions.GetByItemID(ItemID);
else if(_ItemDocVersions == null)
else if (_ItemDocVersions == null)
_ItemDocVersions = ItemDocVersions.New();
return _ItemDocVersions;
}
@@ -345,7 +349,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("NextItemCount",true);
CanReadProperty("NextItemCount", true);
return _NextItemCount;
}
}
@@ -359,10 +363,10 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("NextItems",true);
if(_NextItemCount > 0 && _NextItems == null)
CanReadProperty("NextItems", true);
if (_NextItemCount > 0 && _NextItems == null)
_NextItems = NextItems.GetByPreviousID(ItemID);
else if(_NextItems == null)
else if (_NextItems == null)
_NextItems = NextItems.New();
return _NextItems;
}
@@ -376,7 +380,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemPartCount",true);
CanReadProperty("ItemPartCount", true);
return _ItemPartCount;
}
}
@@ -390,10 +394,10 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemParts",true);
if(_ItemPartCount > 0 && _ItemParts == null)
CanReadProperty("ItemParts", true);
if (_ItemPartCount > 0 && _ItemParts == null)
_ItemParts = ItemParts.GetByItemID(ItemID);
else if(_ItemParts == null)
else if (_ItemParts == null)
_ItemParts = ItemParts.New();
return _ItemParts;
}
@@ -407,7 +411,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemTransition_RangeIDCount",true);
CanReadProperty("ItemTransition_RangeIDCount", true);
return _ItemTransition_RangeIDCount;
}
}
@@ -421,10 +425,10 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemTransitions_RangeID",true);
if(_ItemTransition_RangeIDCount > 0 && _ItemTransitions_RangeID == null)
CanReadProperty("ItemTransitions_RangeID", true);
if (_ItemTransition_RangeIDCount > 0 && _ItemTransitions_RangeID == null)
_ItemTransitions_RangeID = ItemTransitions_RangeID.GetByRangeID(ItemID);
else if(_ItemTransitions_RangeID == null)
else if (_ItemTransitions_RangeID == null)
_ItemTransitions_RangeID = ItemTransitions_RangeID.New();
return _ItemTransitions_RangeID;
}
@@ -438,7 +442,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemTransition_ToIDCount",true);
CanReadProperty("ItemTransition_ToIDCount", true);
return _ItemTransition_ToIDCount;
}
}
@@ -452,21 +456,21 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemTransitions_ToID",true);
if(_ItemTransition_ToIDCount > 0 && _ItemTransitions_ToID == null)
CanReadProperty("ItemTransitions_ToID", true);
if (_ItemTransition_ToIDCount > 0 && _ItemTransitions_ToID == null)
_ItemTransitions_ToID = ItemTransitions_ToID.GetByToID(ItemID);
else if(_ItemTransitions_ToID == null)
else if (_ItemTransitions_ToID == null)
_ItemTransitions_ToID = ItemTransitions_ToID.New();
return _ItemTransitions_ToID;
}
}
public override bool IsDirty
{
get { return base.IsDirty || (_ItemAnnotations == null? false : _ItemAnnotations.IsDirty) || (_ItemDocVersions == null? false : _ItemDocVersions.IsDirty) || (_NextItems == null? false : _NextItems.IsDirty) || (_ItemParts == null? false : _ItemParts.IsDirty) || (_ItemTransitions_RangeID == null? false : _ItemTransitions_RangeID.IsDirty) || (_ItemTransitions_ToID == null? false : _ItemTransitions_ToID.IsDirty) || (_MyContent == null? false : _MyContent.IsDirty); }
get { return base.IsDirty || (_ItemAnnotations == null ? false : _ItemAnnotations.IsDirty) || (_ItemDocVersions == null ? false : _ItemDocVersions.IsDirty) || (_NextItems == null ? false : _NextItems.IsDirty) || (_ItemParts == null ? false : _ItemParts.IsDirty) || (_ItemTransitions_RangeID == null ? false : _ItemTransitions_RangeID.IsDirty) || (_ItemTransitions_ToID == null ? false : _ItemTransitions_ToID.IsDirty) || (_MyContent == null ? false : _MyContent.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_ItemAnnotations == null? true : _ItemAnnotations.IsValid) && (_ItemDocVersions == null? true : _ItemDocVersions.IsValid) && (_NextItems == null? true : _NextItems.IsValid) && (_ItemParts == null? true : _ItemParts.IsValid) && (_ItemTransitions_RangeID == null? true : _ItemTransitions_RangeID.IsValid) && (_ItemTransitions_ToID == null? true : _ItemTransitions_ToID.IsValid) && (_MyContent == null? true : _MyContent.IsValid); }
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_ItemAnnotations == null ? true : _ItemAnnotations.IsValid) && (_ItemDocVersions == null ? true : _ItemDocVersions.IsValid) && (_NextItems == null ? true : _NextItems.IsValid) && (_ItemParts == null ? true : _ItemParts.IsValid) && (_ItemTransitions_RangeID == null ? true : _ItemTransitions_RangeID.IsValid) && (_ItemTransitions_ToID == null ? true : _ItemTransitions_ToID.IsValid) && (_MyContent == null ? true : _MyContent.IsValid); }
}
// TODO: Replace base Item.ToString function as necessary
/// <summary>
@@ -489,28 +493,29 @@ 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 (_ItemAnnotations != null && (hasBrokenRules = _ItemAnnotations.HasBrokenRules) != null) return hasBrokenRules;
if (_ItemDocVersions != null && (hasBrokenRules = _ItemDocVersions.HasBrokenRules) != null) return hasBrokenRules;
if (_NextItems != null && (hasBrokenRules = _NextItems.HasBrokenRules) != null) return hasBrokenRules;
if (_ItemParts != null && (hasBrokenRules = _ItemParts.HasBrokenRules) != null) return hasBrokenRules;
if (_ItemTransitions_RangeID != null && (hasBrokenRules = _ItemTransitions_RangeID.HasBrokenRules) != null) return hasBrokenRules;
if (_ItemTransitions_ToID != null && (hasBrokenRules = _ItemTransitions_ToID.HasBrokenRules) != null) return hasBrokenRules;
if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules;
if (_ItemAnnotations != null && (hasBrokenRules = _ItemAnnotations.HasBrokenRules) != null) return hasBrokenRules;
if (_ItemDocVersions != null && (hasBrokenRules = _ItemDocVersions.HasBrokenRules) != null) return hasBrokenRules;
if (_NextItems != null && (hasBrokenRules = _NextItems.HasBrokenRules) != null) return hasBrokenRules;
if (_ItemParts != null && (hasBrokenRules = _ItemParts.HasBrokenRules) != null) return hasBrokenRules;
if (_ItemTransitions_RangeID != null && (hasBrokenRules = _ItemTransitions_RangeID.HasBrokenRules) != null) return hasBrokenRules;
if (_ItemTransitions_ToID != null && (hasBrokenRules = _ItemTransitions_ToID.HasBrokenRules) != null) return hasBrokenRules;
if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
_CheckingBrokenRules = false;
}
}
}
@@ -629,14 +634,25 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private static int _ItemUnique = 0;
private int _MyItemUnique;
public int MyItemUnique
{
get { return _MyItemUnique; }
}
protected Item()
{/* require use of factory methods */
_MyItemUnique = ++_ItemUnique;
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(ItemID.ToString());
if (!_AllByPrimaryKey.ContainsKey(ItemID.ToString())) return;
List<Item> listItem = _AllByPrimaryKey[ItemID.ToString()]; // Get the list of items
listItem.Remove(this); // Remove the item from the list
if (listItem.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(ItemID.ToString()); // remove the list
}
public static Item New()
{
@@ -715,7 +731,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null)
{
tmp = DataPortal.Fetch<Item>(new PKCriteria(itemID));
_AllList.Add(tmp);
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
@@ -804,7 +820,7 @@ namespace VEPROMS.CSLA.Library
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.ReadData", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.ReadData", GetHashCode());
try
{
_ItemID = dr.GetInt32("ItemID");
@@ -823,14 +839,14 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.ReadData", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Item.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.DataPortal_Fetch", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@@ -873,7 +889,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.DataPortal_Fetch", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Item.DataPortal_Fetch", ex);
}
@@ -894,13 +910,13 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.DataPortal_Insert", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.DataPortal_Insert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Item.DataPortal_Insert", ex);
}
finally
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.DataPortal_Insert", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.DataPortal_Insert", GetHashCode());
}
}
[Transactional(TransactionalTypes.TransactionScope)]
@@ -909,7 +925,7 @@ namespace VEPROMS.CSLA.Library
if (!this.IsDirty) return;
try
{
if(_MyContent != null) _MyContent.Update();
if (_MyContent != null) _MyContent.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand())
{
@@ -941,11 +957,11 @@ namespace VEPROMS.CSLA.Library
if (_ItemParts != null) _ItemParts.Update(this);
if (_ItemTransitions_RangeID != null) _ItemTransitions_RangeID.Update(this);
if (_ItemTransitions_ToID != null) _ItemTransitions_ToID.Update(this);
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.SQLInsert", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.SQLInsert", GetHashCode());
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.SQLInsert", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.SQLInsert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Item.SQLInsert", ex);
}
@@ -953,7 +969,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int itemID, Item myPrevious, Content myContent, DateTime dts, string userID)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.Add", 0);
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.Add", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
@@ -961,7 +977,7 @@ namespace VEPROMS.CSLA.Library
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addItem";
// Input All Fields - Except Calculated Columns
if(myPrevious != null)cm.Parameters.AddWithValue("@PreviousID", myPrevious.ItemID);
if (myPrevious != null) cm.Parameters.AddWithValue("@PreviousID", myPrevious.ItemID);
cm.Parameters.AddWithValue("@ContentID", myContent.ContentID);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
@@ -981,7 +997,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.Add", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.Add", ex);
throw new DbCslaException("Item.Add", ex);
}
}
@@ -989,7 +1005,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}] Item.DataPortal_Update", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.DataPortal_Update", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@@ -1003,7 +1019,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.DataPortal_Update", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.DataPortal_Update", ex);
_ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
}
@@ -1012,10 +1028,10 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate()
{
if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.SQLUpdate", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.SQLUpdate", GetHashCode());
try
{
if(_MyContent != null) _MyContent.Update();
if (_MyContent != null) _MyContent.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty)
{
@@ -1051,7 +1067,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.SQLUpdate", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.SQLUpdate", ex);
_ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
}
@@ -1088,7 +1104,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int itemID, Item myPrevious, Content myContent, DateTime dts, string userID, ref byte[] lastChanged)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.Update", 0);
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.Update", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
@@ -1097,7 +1113,7 @@ namespace VEPROMS.CSLA.Library
cm.CommandText = "updateItem";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ItemID", itemID);
if(myPrevious != null)cm.Parameters.AddWithValue("@PreviousID", myPrevious.ItemID);
if (myPrevious != null) cm.Parameters.AddWithValue("@PreviousID", myPrevious.ItemID);
cm.Parameters.AddWithValue("@ContentID", myContent.ContentID);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
@@ -1114,7 +1130,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.Update", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.Update", ex);
throw new DbCslaException("Item.Update", ex);
}
}
@@ -1126,7 +1142,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.DataPortal_Delete", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.DataPortal_Delete", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@@ -1142,7 +1158,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.DataPortal_Delete", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.DataPortal_Delete", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Item.DataPortal_Delete", ex);
}
@@ -1150,7 +1166,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int itemID)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.Remove", 0);
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.Remove", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
@@ -1165,7 +1181,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.Remove", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.Remove", ex);
throw new DbCslaException("Item.Remove", ex);
}
}
@@ -1199,7 +1215,7 @@ namespace VEPROMS.CSLA.Library
}
protected override void DataPortal_Execute()
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.DataPortal_Execute", GetHashCode());
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.DataPortal_Execute", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@@ -1217,7 +1233,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.DataPortal_Execute", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.DataPortal_Execute", ex);
throw new DbCslaException("Item.DataPortal_Execute", ex);
}
}