This commit is contained in:
@@ -47,19 +47,23 @@ namespace VEPROMS.CSLA.Library
|
||||
foreach (RoUsage tmp in _RefreshRoUsages)
|
||||
{
|
||||
RoUsageInfo.Refresh(tmp);
|
||||
if(tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent);
|
||||
if (tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Collection
|
||||
protected static List<RoUsage> _AllList = new List<RoUsage>();
|
||||
private static Dictionary<string, RoUsage> _AllByPrimaryKey = new Dictionary<string, RoUsage>();
|
||||
private static Dictionary<string, List<RoUsage>> _AllByPrimaryKey = new Dictionary<string, List<RoUsage>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<RoUsage> remove = new List<RoUsage>();
|
||||
foreach (RoUsage tmp in _AllList)
|
||||
{
|
||||
_AllByPrimaryKey[tmp.ROUsageID.ToString()]=tmp; // Primary Key
|
||||
if (!_AllByPrimaryKey.ContainsKey(tmp.ROUsageID.ToString()))
|
||||
{
|
||||
_AllByPrimaryKey[tmp.ROUsageID.ToString()] = new List<RoUsage>(); // Add new list for PrimaryKey
|
||||
}
|
||||
_AllByPrimaryKey[tmp.ROUsageID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
remove.Add(tmp);
|
||||
}
|
||||
foreach (RoUsage tmp in remove)
|
||||
@@ -69,7 +73,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
|
||||
@@ -91,7 +95,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("ROUsageID",true);
|
||||
CanReadProperty("ROUsageID", true);
|
||||
return _ROUsageID;
|
||||
}
|
||||
}
|
||||
@@ -101,7 +105,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;
|
||||
}
|
||||
@@ -112,14 +116,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;
|
||||
@@ -133,13 +137,13 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("ROID",true);
|
||||
CanReadProperty("ROID", true);
|
||||
return _ROID;
|
||||
}
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
set
|
||||
{
|
||||
CanWriteProperty("ROID",true);
|
||||
CanWriteProperty("ROID", true);
|
||||
if (value == null) value = string.Empty;
|
||||
if (_ROID != value)
|
||||
{
|
||||
@@ -154,13 +158,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)
|
||||
{
|
||||
@@ -175,13 +179,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;
|
||||
@@ -195,13 +199,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)
|
||||
{
|
||||
@@ -213,11 +217,11 @@ namespace VEPROMS.CSLA.Library
|
||||
private byte[] _LastChanged = new byte[8];//timestamp
|
||||
public override bool IsDirty
|
||||
{
|
||||
get { return base.IsDirty || (_MyContent == null? false : _MyContent.IsDirty); }
|
||||
get { return base.IsDirty || (_MyContent == null ? false : _MyContent.IsDirty); }
|
||||
}
|
||||
public override bool IsValid
|
||||
{
|
||||
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyContent == null? true : _MyContent.IsValid); }
|
||||
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyContent == null ? true : _MyContent.IsValid); }
|
||||
}
|
||||
// TODO: Replace base RoUsage.ToString function as necessary
|
||||
/// <summary>
|
||||
@@ -240,22 +244,23 @@ 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 (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules;
|
||||
if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules;
|
||||
return hasBrokenRules;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_CheckingBrokenRules=false;
|
||||
_CheckingBrokenRules = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -366,14 +371,25 @@ namespace VEPROMS.CSLA.Library
|
||||
#region Factory Methods
|
||||
public int CurrentEditLevel
|
||||
{ get { return EditLevel; } }
|
||||
private static int _RoUsageUnique = 0;
|
||||
private int _MyRoUsageUnique;
|
||||
public int MyRoUsageUnique
|
||||
{
|
||||
get { return _MyRoUsageUnique; }
|
||||
}
|
||||
protected RoUsage()
|
||||
{/* require use of factory methods */
|
||||
_MyRoUsageUnique = ++_RoUsageUnique;
|
||||
_AllList.Add(this);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
_AllList.Remove(this);
|
||||
_AllByPrimaryKey.Remove(ROUsageID.ToString());
|
||||
if (!_AllByPrimaryKey.ContainsKey(ROUsageID.ToString())) return;
|
||||
List<RoUsage> listRoUsage = _AllByPrimaryKey[ROUsageID.ToString()]; // Get the list of items
|
||||
listRoUsage.Remove(this); // Remove the item from the list
|
||||
if (listRoUsage.Count == 0) //If there are no items left in the list
|
||||
_AllByPrimaryKey.Remove(ROUsageID.ToString()); // remove the list
|
||||
}
|
||||
public static RoUsage New()
|
||||
{
|
||||
@@ -454,7 +470,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<RoUsage>(new PKCriteria(rOUsageID));
|
||||
_AllList.Add(tmp);
|
||||
if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found") tmp = null;
|
||||
return tmp;
|
||||
@@ -534,7 +550,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.ReadData", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.ReadData", GetHashCode());
|
||||
try
|
||||
{
|
||||
_ROUsageID = dr.GetInt32("ROUsageID");
|
||||
@@ -548,14 +564,14 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.ReadData", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.ReadData", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("RoUsage.ReadData", ex);
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(PKCriteria criteria)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Fetch", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Fetch", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
@@ -583,7 +599,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.DataPortal_Fetch", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("RoUsage.DataPortal_Fetch", ex);
|
||||
}
|
||||
@@ -604,13 +620,13 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.DataPortal_Insert", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.DataPortal_Insert", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("RoUsage.DataPortal_Insert", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Insert", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Insert", GetHashCode());
|
||||
}
|
||||
}
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
@@ -619,7 +635,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())
|
||||
{
|
||||
@@ -646,11 +662,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
MarkOld();
|
||||
// update child objects
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.SQLInsert", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.SQLInsert", GetHashCode());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.SQLInsert", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.SQLInsert", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("RoUsage.SQLInsert", ex);
|
||||
}
|
||||
@@ -658,7 +674,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
public static byte[] Add(SqlConnection cn, ref int rOUsageID, Content myContent, string roid, string config, DateTime dts, string userID)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.Add", 0);
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.Add", 0);
|
||||
try
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
@@ -687,7 +703,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.Add", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.Add", ex);
|
||||
throw new DbCslaException("RoUsage.Add", ex);
|
||||
}
|
||||
}
|
||||
@@ -695,7 +711,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}] RoUsage.DataPortal_Update", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Update", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
@@ -709,7 +725,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.DataPortal_Update", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.DataPortal_Update", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
|
||||
}
|
||||
@@ -718,10 +734,10 @@ namespace VEPROMS.CSLA.Library
|
||||
internal void SQLUpdate()
|
||||
{
|
||||
if (!IsDirty) return; // If not dirty - nothing to do
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.SQLUpdate", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.SQLUpdate", GetHashCode());
|
||||
try
|
||||
{
|
||||
if(_MyContent != null) _MyContent.Update();
|
||||
if (_MyContent != null) _MyContent.Update();
|
||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
||||
if (base.IsDirty)
|
||||
{
|
||||
@@ -752,7 +768,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.SQLUpdate", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.SQLUpdate", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
|
||||
}
|
||||
@@ -773,7 +789,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
public static byte[] Update(SqlConnection cn, ref int rOUsageID, Content myContent, string roid, string config, DateTime dts, string userID, ref byte[] lastChanged)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.Update", 0);
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.Update", 0);
|
||||
try
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
@@ -800,7 +816,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.Update", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.Update", ex);
|
||||
throw new DbCslaException("RoUsage.Update", ex);
|
||||
}
|
||||
}
|
||||
@@ -812,7 +828,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
private void DataPortal_Delete(PKCriteria criteria)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Delete", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Delete", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
@@ -828,7 +844,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.DataPortal_Delete", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.DataPortal_Delete", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("RoUsage.DataPortal_Delete", ex);
|
||||
}
|
||||
@@ -836,7 +852,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
public static void Remove(SqlConnection cn, int rOUsageID)
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.Remove", 0);
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.Remove", 0);
|
||||
try
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
@@ -851,7 +867,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.Remove", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.Remove", ex);
|
||||
throw new DbCslaException("RoUsage.Remove", ex);
|
||||
}
|
||||
}
|
||||
@@ -885,7 +901,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
protected override void DataPortal_Execute()
|
||||
{
|
||||
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Execute", GetHashCode());
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Execute", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
@@ -903,7 +919,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.DataPortal_Execute", ex);
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.DataPortal_Execute", ex);
|
||||
throw new DbCslaException("RoUsage.DataPortal_Execute", ex);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user