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

@ -11,30 +11,13 @@ namespace VEPROMS.CSLA.Library
return _SearchText; return _SearchText;
} }
} }
public partial class AnnotationType public partial class AnnotationType
{ {
public override string ToString() public override string ToString()
{ {
return _Name; return _Name;
} }
public static IList<AnnotationType> AllTypes()
{
List<AnnotationType> tlst = new List<AnnotationType>();
foreach (AnnotationType at in _AllByPrimaryKey.Values)
{
tlst.Add(at);
}
return tlst;
}
public static Dictionary<string, AnnotationType> AllByName()
{
return _AllByName;
}
} }
public partial class AnnotationTypeInfo public partial class AnnotationTypeInfo
{ {
public static List<AnnotationTypeInfo> AllList() public static List<AnnotationTypeInfo> AllList()
@ -42,14 +25,11 @@ namespace VEPROMS.CSLA.Library
//return _AllList; //return _AllList;
return AnnotationTypeInfo._AllList; return AnnotationTypeInfo._AllList;
} }
public override string ToString() public override string ToString()
{ {
return _Name; return _Name;
} }
} }
public partial class Annotation public partial class Annotation
{ {
/// <summary> /// <summary>
@ -73,7 +53,6 @@ namespace VEPROMS.CSLA.Library
//Update(); //Update();
} }
} }
//public partial class AnnotationTypeAnnotations //public partial class AnnotationTypeAnnotations
//{ //{
// public static int GetAnnotationID() // public static int GetAnnotationID()

View File

@ -47,20 +47,24 @@ namespace VEPROMS.CSLA.Library
foreach (Annotation tmp in _RefreshAnnotations) foreach (Annotation tmp in _RefreshAnnotations)
{ {
AnnotationInfo.Refresh(tmp); AnnotationInfo.Refresh(tmp);
if(tmp._MyAnnotationType != null) AnnotationTypeInfo.Refresh(tmp._MyAnnotationType); if (tmp._MyAnnotationType != null) AnnotationTypeInfo.Refresh(tmp._MyAnnotationType);
if(tmp._MyItem != null) ItemInfo.Refresh(tmp._MyItem); if (tmp._MyItem != null) ItemInfo.Refresh(tmp._MyItem);
} }
} }
#endregion #endregion
#region Collection #region Collection
protected static List<Annotation> _AllList = new List<Annotation>(); protected static List<Annotation> _AllList = new List<Annotation>();
private static Dictionary<string, Annotation> _AllByPrimaryKey = new Dictionary<string, Annotation>(); private static Dictionary<string, List<Annotation>> _AllByPrimaryKey = new Dictionary<string, List<Annotation>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<Annotation> remove = new List<Annotation>(); List<Annotation> remove = new List<Annotation>();
foreach (Annotation tmp in _AllList) foreach (Annotation tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.AnnotationID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.AnnotationID.ToString()))
{
_AllByPrimaryKey[tmp.AnnotationID.ToString()] = new List<Annotation>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.AnnotationID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (Annotation tmp in remove) foreach (Annotation tmp in remove)
@ -70,7 +74,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = annotationID.ToString(); string key = annotationID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -92,7 +96,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationID",true); CanReadProperty("AnnotationID", true);
return _AnnotationID; return _AnnotationID;
} }
} }
@ -102,7 +106,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemID",true); CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID; if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID; return _ItemID;
} }
@ -113,14 +117,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItem",true); CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID); if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
return _MyItem; return _MyItem;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyItem",true); CanWriteProperty("MyItem", true);
if (_MyItem != value) if (_MyItem != value)
{ {
_MyItem = value; _MyItem = value;
@ -134,7 +138,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("TypeID",true); CanReadProperty("TypeID", true);
if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID; if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID;
return _TypeID; return _TypeID;
} }
@ -145,14 +149,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyAnnotationType",true); CanReadProperty("MyAnnotationType", true);
if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationType.Get(_TypeID); if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationType.Get(_TypeID);
return _MyAnnotationType; return _MyAnnotationType;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyAnnotationType",true); CanWriteProperty("MyAnnotationType", true);
if (_MyAnnotationType != value) if (_MyAnnotationType != value)
{ {
_MyAnnotationType = value; _MyAnnotationType = value;
@ -166,13 +170,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RtfText",true); CanReadProperty("RtfText", true);
return _RtfText; return _RtfText;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("RtfText",true); CanWriteProperty("RtfText", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_RtfText != value) if (_RtfText != value)
{ {
@ -187,13 +191,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("SearchText",true); CanReadProperty("SearchText", true);
return _SearchText; return _SearchText;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("SearchText",true); CanWriteProperty("SearchText", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_SearchText != value) if (_SearchText != value)
{ {
@ -208,13 +212,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -229,13 +233,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -249,13 +253,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -267,11 +271,11 @@ namespace VEPROMS.CSLA.Library
private byte[] _LastChanged = new byte[8];//timestamp private byte[] _LastChanged = new byte[8];//timestamp
public override bool IsDirty public override bool IsDirty
{ {
get { return base.IsDirty || (_MyAnnotationType == null? false : _MyAnnotationType.IsDirty) || (_MyItem == null? false : _MyItem.IsDirty); } get { return base.IsDirty || (_MyAnnotationType == null ? false : _MyAnnotationType.IsDirty) || (_MyItem == null ? false : _MyItem.IsDirty); }
} }
public override bool IsValid public override bool IsValid
{ {
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyAnnotationType == null? true : _MyAnnotationType.IsValid) && (_MyItem == null? true : _MyItem.IsValid); } get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyAnnotationType == null ? true : _MyAnnotationType.IsValid) && (_MyItem == null ? true : _MyItem.IsValid); }
} }
// TODO: Replace base Annotation.ToString function as necessary // TODO: Replace base Annotation.ToString function as necessary
/// <summary> /// <summary>
@ -294,23 +298,24 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get { get
if(_CheckingBrokenRules)return null; {
if (_CheckingBrokenRules) return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules;
if (_MyAnnotationType != null && (hasBrokenRules = _MyAnnotationType.HasBrokenRules) != null) return hasBrokenRules; if (_MyAnnotationType != null && (hasBrokenRules = _MyAnnotationType.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -436,14 +441,25 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods #region Factory Methods
public int CurrentEditLevel public int CurrentEditLevel
{ get { return EditLevel; } } { get { return EditLevel; } }
private static int _AnnotationUnique = 0;
private int _MyAnnotationUnique;
public int MyAnnotationUnique
{
get { return _MyAnnotationUnique; }
}
protected Annotation() protected Annotation()
{/* require use of factory methods */ {/* require use of factory methods */
_MyAnnotationUnique = ++_AnnotationUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(AnnotationID.ToString()); if (!_AllByPrimaryKey.ContainsKey(AnnotationID.ToString())) return;
List<Annotation> listAnnotation = _AllByPrimaryKey[AnnotationID.ToString()]; // Get the list of items
listAnnotation.Remove(this); // Remove the item from the list
if (listAnnotation.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(AnnotationID.ToString()); // remove the list
} }
public static Annotation New() public static Annotation New()
{ {
@ -529,7 +545,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<Annotation>(new PKCriteria(annotationID)); tmp = DataPortal.Fetch<Annotation>(new PKCriteria(annotationID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -608,7 +624,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Annotation.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.ReadData", GetHashCode());
try try
{ {
_AnnotationID = dr.GetInt32("AnnotationID"); _AnnotationID = dr.GetInt32("AnnotationID");
@ -624,14 +640,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Annotation.ReadData", ex); throw new DbCslaException("Annotation.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Annotation.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -659,7 +675,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Annotation.DataPortal_Fetch", ex); throw new DbCslaException("Annotation.DataPortal_Fetch", ex);
} }
@ -680,13 +696,13 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.DataPortal_Insert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.DataPortal_Insert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Annotation.DataPortal_Insert", ex); throw new DbCslaException("Annotation.DataPortal_Insert", ex);
} }
finally finally
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Annotation.DataPortal_Insert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.DataPortal_Insert", GetHashCode());
} }
} }
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
@ -695,8 +711,8 @@ namespace VEPROMS.CSLA.Library
if (!this.IsDirty) return; if (!this.IsDirty) return;
try try
{ {
if(_MyAnnotationType != null) _MyAnnotationType.Update(); if (_MyAnnotationType != null) _MyAnnotationType.Update();
if(_MyItem != null) _MyItem.Update(); if (_MyItem != null) _MyItem.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
{ {
@ -725,11 +741,11 @@ namespace VEPROMS.CSLA.Library
} }
MarkOld(); MarkOld();
// update child objects // update child objects
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Annotation.SQLInsert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.SQLInsert", GetHashCode());
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.SQLInsert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.SQLInsert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Annotation.SQLInsert", ex); throw new DbCslaException("Annotation.SQLInsert", ex);
} }
@ -737,7 +753,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int annotationID, Item myItem, AnnotationType myAnnotationType, string rtfText, string searchText, string config, DateTime dts, string userID) public static byte[] Add(SqlConnection cn, ref int annotationID, Item myItem, AnnotationType myAnnotationType, string rtfText, string searchText, string config, DateTime dts, string userID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Annotation.Add", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.Add", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -768,7 +784,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.Add", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.Add", ex);
throw new DbCslaException("Annotation.Add", ex); throw new DbCslaException("Annotation.Add", ex);
} }
} }
@ -776,7 +792,7 @@ namespace VEPROMS.CSLA.Library
protected override void DataPortal_Update() protected override void DataPortal_Update()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Annotation.DataPortal_Update", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.DataPortal_Update", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -790,7 +806,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.DataPortal_Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.DataPortal_Update", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -799,11 +815,11 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate() internal void SQLUpdate()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Annotation.SQLUpdate", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.SQLUpdate", GetHashCode());
try try
{ {
if(_MyAnnotationType != null) _MyAnnotationType.Update(); if (_MyAnnotationType != null) _MyAnnotationType.Update();
if(_MyItem != null) _MyItem.Update(); if (_MyItem != null) _MyItem.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty) if (base.IsDirty)
{ {
@ -836,7 +852,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.SQLUpdate", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.SQLUpdate", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -857,7 +873,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int annotationID, Item myItem, AnnotationType myAnnotationType, string rtfText, string searchText, string config, DateTime dts, string userID, ref byte[] lastChanged) public static byte[] Update(SqlConnection cn, ref int annotationID, Item myItem, AnnotationType myAnnotationType, string rtfText, string searchText, string config, DateTime dts, string userID, ref byte[] lastChanged)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Annotation.Update", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.Update", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -886,7 +902,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.Update", ex);
throw new DbCslaException("Annotation.Update", ex); throw new DbCslaException("Annotation.Update", ex);
} }
} }
@ -898,7 +914,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria) private void DataPortal_Delete(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Annotation.DataPortal_Delete", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.DataPortal_Delete", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -914,7 +930,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.DataPortal_Delete", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.DataPortal_Delete", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Annotation.DataPortal_Delete", ex); throw new DbCslaException("Annotation.DataPortal_Delete", ex);
} }
@ -922,7 +938,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int annotationID) public static void Remove(SqlConnection cn, int annotationID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Annotation.Remove", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.Remove", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -937,7 +953,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.Remove", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.Remove", ex);
throw new DbCslaException("Annotation.Remove", ex); throw new DbCslaException("Annotation.Remove", ex);
} }
} }
@ -971,7 +987,7 @@ namespace VEPROMS.CSLA.Library
} }
protected override void DataPortal_Execute() protected override void DataPortal_Execute()
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Annotation.DataPortal_Execute", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.DataPortal_Execute", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -989,7 +1005,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.DataPortal_Execute", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.DataPortal_Execute", ex);
throw new DbCslaException("Annotation.DataPortal_Execute", ex); throw new DbCslaException("Annotation.DataPortal_Execute", ex);
} }
} }

View File

@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<AnnotationInfo> _AllList = new List<AnnotationInfo>(); protected static List<AnnotationInfo> _AllList = new List<AnnotationInfo>();
private static Dictionary<string, AnnotationInfo> _AllByPrimaryKey = new Dictionary<string, AnnotationInfo>(); private static Dictionary<string, List<AnnotationInfo>> _AllByPrimaryKey = new Dictionary<string, List<AnnotationInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<AnnotationInfo> remove = new List<AnnotationInfo>(); List<AnnotationInfo> remove = new List<AnnotationInfo>();
foreach (AnnotationInfo tmp in _AllList) foreach (AnnotationInfo tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.AnnotationID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.AnnotationID.ToString()))
{
_AllByPrimaryKey[tmp.AnnotationID.ToString()] = new List<AnnotationInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.AnnotationID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (AnnotationInfo tmp in remove) foreach (AnnotationInfo tmp in remove)
@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = annotationID.ToString(); string key = annotationID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationID",true); CanReadProperty("AnnotationID", true);
return _AnnotationID; return _AnnotationID;
} }
} }
@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemID",true); CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID; if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID; return _ItemID;
} }
@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItem",true); CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != 0) _MyItem = ItemInfo.Get(_ItemID); if (_MyItem == null && _ItemID != 0) _MyItem = ItemInfo.Get(_ItemID);
return _MyItem; return _MyItem;
} }
@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("TypeID",true); CanReadProperty("TypeID", true);
if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID; if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID;
return _TypeID; return _TypeID;
} }
@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyAnnotationType",true); CanReadProperty("MyAnnotationType", true);
if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationTypeInfo.Get(_TypeID); if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationTypeInfo.Get(_TypeID);
return _MyAnnotationType; return _MyAnnotationType;
} }
@ -139,7 +143,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RtfText",true); CanReadProperty("RtfText", true);
return _RtfText; return _RtfText;
} }
} }
@ -149,7 +153,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("SearchText",true); CanReadProperty("SearchText", true);
return _SearchText; return _SearchText;
} }
} }
@ -159,7 +163,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
} }
@ -169,7 +173,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -179,7 +183,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
} }
@ -203,14 +207,25 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _AnnotationInfoUnique = 0;
private int _MyAnnotationInfoUnique;
public int MyAnnotationInfoUnique
{
get { return _MyAnnotationInfoUnique; }
}
private AnnotationInfo() private AnnotationInfo()
{/* require use of factory methods */ {/* require use of factory methods */
_MyAnnotationInfoUnique = ++_AnnotationInfoUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(AnnotationID.ToString()); if (!_AllByPrimaryKey.ContainsKey(AnnotationID.ToString())) return;
List<AnnotationInfo> listAnnotationInfo = _AllByPrimaryKey[AnnotationID.ToString()]; // Get the list of items
listAnnotationInfo.Remove(this); // Remove the item from the list
if (listAnnotationInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(AnnotationID.ToString()); // remove the list
} }
public virtual Annotation Get() public virtual Annotation Get()
{ {
@ -218,9 +233,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(Annotation tmp) public static void Refresh(Annotation tmp)
{ {
AnnotationInfo tmpInfo = GetExistingByPrimaryKey(tmp.AnnotationID); string key = tmp.AnnotationID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (AnnotationInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(Annotation tmp) private void RefreshFields(Annotation tmp)
{ {
@ -228,16 +245,16 @@ namespace VEPROMS.CSLA.Library
{ {
MyItem.RefreshItemAnnotations(); // Update List for old value MyItem.RefreshItemAnnotations(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value _ItemID = tmp.ItemID; // Update the value
_MyItem = null; // Reset list so that the next line gets a new list
MyItem.RefreshItemAnnotations(); // Update List for new value
} }
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for new value
if (_TypeID != tmp.TypeID) if (_TypeID != tmp.TypeID)
{ {
MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old value MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old value
_TypeID = tmp.TypeID; // Update the value _TypeID = tmp.TypeID; // Update the value
_MyAnnotationType = null; // Reset list so that the next line gets a new list
MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for new value
} }
_MyAnnotationType = null; // Reset list so that the next line gets a new list
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for new value
_RtfText = tmp.RtfText; _RtfText = tmp.RtfText;
_SearchText = tmp.SearchText; _SearchText = tmp.SearchText;
_Config = tmp.Config; _Config = tmp.Config;
@ -250,9 +267,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(AnnotationTypeAnnotation tmp) public static void Refresh(AnnotationTypeAnnotation tmp)
{ {
AnnotationInfo tmpInfo = GetExistingByPrimaryKey(tmp.AnnotationID); string key = tmp.AnnotationID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (AnnotationInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(AnnotationTypeAnnotation tmp) private void RefreshFields(AnnotationTypeAnnotation tmp)
{ {
@ -260,9 +279,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyItem.RefreshItemAnnotations(); // Update List for old value MyItem.RefreshItemAnnotations(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value _ItemID = tmp.ItemID; // Update the value
_MyItem = null; // Reset list so that the next line gets a new list
MyItem.RefreshItemAnnotations(); // Update List for new value
} }
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for new value
_RtfText = tmp.RtfText; _RtfText = tmp.RtfText;
_SearchText = tmp.SearchText; _SearchText = tmp.SearchText;
_Config = tmp.Config; _Config = tmp.Config;
@ -275,9 +294,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(ItemAnnotation tmp) public static void Refresh(ItemAnnotation tmp)
{ {
AnnotationInfo tmpInfo = GetExistingByPrimaryKey(tmp.AnnotationID); string key = tmp.AnnotationID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (AnnotationInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(ItemAnnotation tmp) private void RefreshFields(ItemAnnotation tmp)
{ {
@ -285,9 +306,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old value MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old value
_TypeID = tmp.TypeID; // Update the value _TypeID = tmp.TypeID; // Update the value
_MyAnnotationType = null; // Reset list so that the next line gets a new list
MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for new value
} }
_MyAnnotationType = null; // Reset list so that the next line gets a new list
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for new value
_RtfText = tmp.RtfText; _RtfText = tmp.RtfText;
_SearchText = tmp.SearchText; _SearchText = tmp.SearchText;
_Config = tmp.Config; _Config = tmp.Config;
@ -308,7 +329,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<AnnotationInfo>(new PKCriteria(annotationID)); tmp = DataPortal.Fetch<AnnotationInfo>(new PKCriteria(annotationID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -322,14 +343,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
internal AnnotationInfo(SafeDataReader dr) internal AnnotationInfo(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationInfo.Constructor", GetHashCode()); _MyAnnotationInfoUnique = ++_AnnotationInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.Constructor", GetHashCode());
try try
{ {
ReadData(dr); ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationInfo.Constructor", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfo.Constructor", ex);
throw new DbCslaException("AnnotationInfo.Constructor", ex); throw new DbCslaException("AnnotationInfo.Constructor", ex);
} }
} }
@ -346,7 +368,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationInfo.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.ReadData", GetHashCode());
try try
{ {
_AnnotationID = dr.GetInt32("AnnotationID"); _AnnotationID = dr.GetInt32("AnnotationID");
@ -360,14 +382,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationInfo.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfo.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationInfo.ReadData", ex); throw new DbCslaException("AnnotationInfo.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -395,7 +417,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationInfo.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationInfo.DataPortal_Fetch", ex); throw new DbCslaException("AnnotationInfo.DataPortal_Fetch", ex);
} }
@ -405,7 +427,7 @@ namespace VEPROMS.CSLA.Library
#region extension #region extension
AnnotationInfoExtension _AnnotationInfoExtension = new AnnotationInfoExtension(); AnnotationInfoExtension _AnnotationInfoExtension = new AnnotationInfoExtension();
[Serializable()] [Serializable()]
partial class AnnotationInfoExtension : extensionBase {} partial class AnnotationInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {

View File

@ -124,7 +124,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -144,7 +144,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("AnnotationInfoList.DataPortal_Fetch", ex); throw new DbCslaException("AnnotationInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -166,7 +166,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(TypeIDCriteria criteria) private void DataPortal_Fetch(TypeIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationInfoList.DataPortal_FetchTypeID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfoList.DataPortal_FetchTypeID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -187,7 +187,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationInfoList.DataPortal_FetchTypeID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfoList.DataPortal_FetchTypeID", ex);
throw new DbCslaException("AnnotationInfoList.DataPortal_Fetch", ex); throw new DbCslaException("AnnotationInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -209,7 +209,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ItemIDCriteria criteria) private void DataPortal_Fetch(ItemIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationInfoList.DataPortal_FetchItemID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfoList.DataPortal_FetchItemID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -230,7 +230,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationInfoList.DataPortal_FetchItemID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfoList.DataPortal_FetchItemID", ex);
throw new DbCslaException("AnnotationInfoList.DataPortal_Fetch", ex); throw new DbCslaException("AnnotationInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -291,8 +291,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class AnnotationInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class AnnotationInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private AnnotationInfo Item { get { return (AnnotationInfo) _Item;} } private AnnotationInfo Item { get { return (AnnotationInfo)_Item; } }
public AnnotationInfoListPropertyDescriptor(AnnotationInfoList collection, int index):base(collection, index){;} public AnnotationInfoListPropertyDescriptor(AnnotationInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -303,7 +303,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is AnnotationInfoList) if (destType == typeof(string) && value is AnnotationInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((AnnotationInfoList) value).Items.Count.ToString() + " Annotations"; return ((AnnotationInfoList)value).Items.Count.ToString() + " Annotations";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -41,7 +41,7 @@ namespace VEPROMS.CSLA.Library
{ {
foreach (AnnotationTypeAnnotation tmp in _AnnotationTypeAnnotations) foreach (AnnotationTypeAnnotation tmp in _AnnotationTypeAnnotations)
{ {
if(tmp.IsDirty)refreshAnnotationTypeAnnotations.Add(tmp); if (tmp.IsDirty) refreshAnnotationTypeAnnotations.Add(tmp);
} }
} }
} }
@ -65,15 +65,20 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<AnnotationType> _AllList = new List<AnnotationType>(); protected static List<AnnotationType> _AllList = new List<AnnotationType>();
private static Dictionary<string, AnnotationType> _AllByPrimaryKey = new Dictionary<string, AnnotationType>(); private static Dictionary<string, List<AnnotationType>> _AllByPrimaryKey = new Dictionary<string, List<AnnotationType>>();
private static Dictionary<string, AnnotationType> _AllByName = new Dictionary<string, AnnotationType>(); private static Dictionary<string, List<AnnotationType>> _AllByName = new Dictionary<string, List<AnnotationType>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<AnnotationType> remove = new List<AnnotationType>(); List<AnnotationType> remove = new List<AnnotationType>();
foreach (AnnotationType tmp in _AllList) foreach (AnnotationType tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.TypeID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.TypeID.ToString()))
_AllByName[tmp.Name.ToString()] = tmp; // Unique Index {
_AllByPrimaryKey[tmp.TypeID.ToString()] = new List<AnnotationType>(); // Add new list for PrimaryKey
_AllByName[tmp.Name.ToString()] = new List<AnnotationType>(); // Add new list for Name
}
_AllByPrimaryKey[tmp.TypeID.ToString()].Add(tmp); // Add to Primary Key list
_AllByName[tmp.Name.ToString()].Add(tmp); // Unique Index
remove.Add(tmp); remove.Add(tmp);
} }
foreach (AnnotationType tmp in remove) foreach (AnnotationType tmp in remove)
@ -83,14 +88,14 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = typeID.ToString(); string key = typeID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
public static AnnotationType GetExistingByName(string name) public static AnnotationType GetExistingByName(string name)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = name.ToString(); string key = name.ToString();
if (_AllByName.ContainsKey(key)) return _AllByName[key]; if (_AllByName.ContainsKey(key)) return _AllByName[key][0];
return null; return null;
} }
#endregion #endregion
@ -112,7 +117,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("TypeID",true); CanReadProperty("TypeID", true);
return _TypeID; return _TypeID;
} }
} }
@ -122,13 +127,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name",true); CanReadProperty("Name", true);
return _Name; return _Name;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Name",true); CanWriteProperty("Name", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Name != value) if (_Name != value)
{ {
@ -143,13 +148,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -164,13 +169,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -184,13 +189,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -209,7 +214,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationTypeAnnotationCount",true); CanReadProperty("AnnotationTypeAnnotationCount", true);
return _AnnotationTypeAnnotationCount; return _AnnotationTypeAnnotationCount;
} }
} }
@ -223,21 +228,21 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationTypeAnnotations",true); CanReadProperty("AnnotationTypeAnnotations", true);
if(_AnnotationTypeAnnotationCount > 0 && _AnnotationTypeAnnotations == null) if (_AnnotationTypeAnnotationCount > 0 && _AnnotationTypeAnnotations == null)
_AnnotationTypeAnnotations = AnnotationTypeAnnotations.GetByTypeID(TypeID); _AnnotationTypeAnnotations = AnnotationTypeAnnotations.GetByTypeID(TypeID);
else if(_AnnotationTypeAnnotations == null) else if (_AnnotationTypeAnnotations == null)
_AnnotationTypeAnnotations = AnnotationTypeAnnotations.New(); _AnnotationTypeAnnotations = AnnotationTypeAnnotations.New();
return _AnnotationTypeAnnotations; return _AnnotationTypeAnnotations;
} }
} }
public override bool IsDirty public override bool IsDirty
{ {
get { return base.IsDirty || (_AnnotationTypeAnnotations == null? false : _AnnotationTypeAnnotations.IsDirty); } get { return base.IsDirty || (_AnnotationTypeAnnotations == null ? false : _AnnotationTypeAnnotations.IsDirty); }
} }
public override bool IsValid public override bool IsValid
{ {
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_AnnotationTypeAnnotations == null? true : _AnnotationTypeAnnotations.IsValid); } get { return (IsNew && !IsDirty ? true : base.IsValid) && (_AnnotationTypeAnnotations == null ? true : _AnnotationTypeAnnotations.IsValid); }
} }
// TODO: Replace base AnnotationType.ToString function as necessary // TODO: Replace base AnnotationType.ToString function as necessary
/// <summary> /// <summary>
@ -260,22 +265,23 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get { get
if(_CheckingBrokenRules)return null; {
if (_CheckingBrokenRules) return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_AnnotationTypeAnnotations != null && (hasBrokenRules = _AnnotationTypeAnnotations.HasBrokenRules) != null) return hasBrokenRules; if (_AnnotationTypeAnnotations != null && (hasBrokenRules = _AnnotationTypeAnnotations.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -387,15 +393,29 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods #region Factory Methods
public int CurrentEditLevel public int CurrentEditLevel
{ get { return EditLevel; } } { get { return EditLevel; } }
private static int _AnnotationTypeUnique = 0;
private int _MyAnnotationTypeUnique;
public int MyAnnotationTypeUnique
{
get { return _MyAnnotationTypeUnique; }
}
protected AnnotationType() protected AnnotationType()
{/* require use of factory methods */ {/* require use of factory methods */
_MyAnnotationTypeUnique = ++_AnnotationTypeUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(TypeID.ToString()); if (!_AllByPrimaryKey.ContainsKey(TypeID.ToString())) return;
_AllByName.Remove(Name.ToString()); List<AnnotationType> listAnnotationType = _AllByPrimaryKey[TypeID.ToString()]; // Get the list of items
listAnnotationType.Remove(this); // Remove the item from the list
if (listAnnotationType.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(TypeID.ToString()); // remove the list
listAnnotationType = _AllByName[TypeID.ToString()]; // Get the list of items
listAnnotationType.Remove(this); // Remove the item from the list
if (listAnnotationType.Count == 0) //If there are no items left in the list
_AllByName.Remove(TypeID.ToString()); // remove the list
} }
public static AnnotationType New() public static AnnotationType New()
{ {
@ -474,7 +494,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<AnnotationType>(new PKCriteria(typeID)); tmp = DataPortal.Fetch<AnnotationType>(new PKCriteria(typeID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -493,8 +513,8 @@ namespace VEPROMS.CSLA.Library
AnnotationType tmp = GetExistingByName(name); AnnotationType tmp = GetExistingByName(name);
if (tmp == null) if (tmp == null)
{ {
tmp=DataPortal.Fetch<AnnotationType>(new NameCriteria(name)); tmp = DataPortal.Fetch<AnnotationType>(new NameCriteria(name));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -584,7 +604,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationType.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.ReadData", GetHashCode());
try try
{ {
_TypeID = dr.GetInt32("TypeID"); _TypeID = dr.GetInt32("TypeID");
@ -598,14 +618,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationType.ReadData", ex); throw new DbCslaException("AnnotationType.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -636,14 +656,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationType.DataPortal_Fetch", ex); throw new DbCslaException("AnnotationType.DataPortal_Fetch", ex);
} }
} }
private void DataPortal_Fetch(NameCriteria criteria) private void DataPortal_Fetch(NameCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -671,7 +691,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationType.DataPortal_Fetch", ex); throw new DbCslaException("AnnotationType.DataPortal_Fetch", ex);
} }
@ -692,13 +712,13 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.DataPortal_Insert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.DataPortal_Insert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationType.DataPortal_Insert", ex); throw new DbCslaException("AnnotationType.DataPortal_Insert", ex);
} }
finally finally
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Insert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Insert", GetHashCode());
} }
} }
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
@ -733,11 +753,11 @@ namespace VEPROMS.CSLA.Library
MarkOld(); MarkOld();
// update child objects // update child objects
if (_AnnotationTypeAnnotations != null) _AnnotationTypeAnnotations.Update(this); if (_AnnotationTypeAnnotations != null) _AnnotationTypeAnnotations.Update(this);
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationType.SQLInsert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.SQLInsert", GetHashCode());
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.SQLInsert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.SQLInsert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationType.SQLInsert", ex); throw new DbCslaException("AnnotationType.SQLInsert", ex);
} }
@ -745,7 +765,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int typeID, string name, string config, DateTime dts, string userID) public static byte[] Add(SqlConnection cn, ref int typeID, string name, string config, DateTime dts, string userID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationType.Add", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.Add", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -773,7 +793,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.Add", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.Add", ex);
throw new DbCslaException("AnnotationType.Add", ex); throw new DbCslaException("AnnotationType.Add", ex);
} }
} }
@ -781,7 +801,7 @@ namespace VEPROMS.CSLA.Library
protected override void DataPortal_Update() protected override void DataPortal_Update()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Update", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Update", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -795,7 +815,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.DataPortal_Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.DataPortal_Update", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -804,7 +824,7 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate() internal void SQLUpdate()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationType.SQLUpdate", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.SQLUpdate", GetHashCode());
try try
{ {
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
@ -837,7 +857,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.SQLUpdate", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.SQLUpdate", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -859,7 +879,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int typeID, string name, string config, DateTime dts, string userID, ref byte[] lastChanged) public static byte[] Update(SqlConnection cn, ref int typeID, string name, string config, DateTime dts, string userID, ref byte[] lastChanged)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationType.Update", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.Update", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -885,7 +905,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.Update", ex);
throw new DbCslaException("AnnotationType.Update", ex); throw new DbCslaException("AnnotationType.Update", ex);
} }
} }
@ -897,7 +917,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria) private void DataPortal_Delete(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Delete", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Delete", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -913,7 +933,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.DataPortal_Delete", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.DataPortal_Delete", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationType.DataPortal_Delete", ex); throw new DbCslaException("AnnotationType.DataPortal_Delete", ex);
} }
@ -921,7 +941,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int typeID) public static void Remove(SqlConnection cn, int typeID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationType.Remove", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.Remove", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -936,7 +956,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.Remove", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.Remove", ex);
throw new DbCslaException("AnnotationType.Remove", ex); throw new DbCslaException("AnnotationType.Remove", ex);
} }
} }
@ -970,7 +990,7 @@ namespace VEPROMS.CSLA.Library
} }
protected override void DataPortal_Execute() protected override void DataPortal_Execute()
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Execute", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Execute", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -988,7 +1008,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.DataPortal_Execute", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.DataPortal_Execute", ex);
throw new DbCslaException("AnnotationType.DataPortal_Execute", ex); throw new DbCslaException("AnnotationType.DataPortal_Execute", ex);
} }
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationID",true); CanReadProperty("AnnotationID", true);
if (_MyAnnotation != null) _AnnotationID = _MyAnnotation.AnnotationID; if (_MyAnnotation != null) _AnnotationID = _MyAnnotation.AnnotationID;
return _AnnotationID; return _AnnotationID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyAnnotation",true); CanReadProperty("MyAnnotation", true);
if (_MyAnnotation == null && _AnnotationID != 0) _MyAnnotation = Annotation.Get(_AnnotationID); if (_MyAnnotation == null && _AnnotationID != 0) _MyAnnotation = Annotation.Get(_AnnotationID);
return _MyAnnotation; return _MyAnnotation;
} }
@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemID",true); CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID; if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID; return _ItemID;
} }
@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItem",true); CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID); if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
return _MyItem; return _MyItem;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyItem",true); CanWriteProperty("MyItem", true);
if (_MyItem != value) if (_MyItem != value)
{ {
_MyItem = value; _MyItem = value;
@ -97,13 +97,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RtfText",true); CanReadProperty("RtfText", true);
return _RtfText; return _RtfText;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("RtfText",true); CanWriteProperty("RtfText", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_RtfText != value) if (_RtfText != value)
{ {
@ -118,13 +118,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("SearchText",true); CanReadProperty("SearchText", true);
return _SearchText; return _SearchText;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("SearchText",true); CanWriteProperty("SearchText", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_SearchText != value) if (_SearchText != value)
{ {
@ -139,13 +139,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -160,13 +160,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -180,13 +180,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -202,7 +202,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_PreviousID",true); CanReadProperty("Item_PreviousID", true);
return _Item_PreviousID; return _Item_PreviousID;
} }
} }
@ -212,7 +212,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_ContentID",true); CanReadProperty("Item_ContentID", true);
return _Item_ContentID; return _Item_ContentID;
} }
} }
@ -222,7 +222,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_DTS",true); CanReadProperty("Item_DTS", true);
return _Item_DTS; return _Item_DTS;
} }
} }
@ -232,7 +232,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_UserID",true); CanReadProperty("Item_UserID", true);
return _Item_UserID; return _Item_UserID;
} }
} }
@ -265,23 +265,23 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -404,7 +404,7 @@ namespace VEPROMS.CSLA.Library
// TODO: Add any initialization & defaults // TODO: Add any initialization & defaults
_DTS = _AnnotationTypeAnnotationExtension.DefaultDTS; _DTS = _AnnotationTypeAnnotationExtension.DefaultDTS;
_UserID = _AnnotationTypeAnnotationExtension.DefaultUserID; _UserID = _AnnotationTypeAnnotationExtension.DefaultUserID;
_MyItem = myItem; _MyItem = myItem;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal AnnotationTypeAnnotation(SafeDataReader dr) internal AnnotationTypeAnnotation(SafeDataReader dr)
@ -416,7 +416,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationTypeAnnotation.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeAnnotation.FetchDR", GetHashCode());
try try
{ {
_AnnotationID = dr.GetInt32("AnnotationID"); _AnnotationID = dr.GetInt32("AnnotationID");
@ -434,7 +434,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationTypeAnnotation.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeAnnotation.FetchDR", ex);
throw new DbCslaException("AnnotationTypeAnnotation.Fetch", ex); throw new DbCslaException("AnnotationTypeAnnotation.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public AnnotationTypeAnnotation Add(Item myItem) // One to Many public AnnotationTypeAnnotation Add(Item myItem) // One to Many
{ {
AnnotationTypeAnnotation annotation = AnnotationTypeAnnotation.New(myItem); AnnotationTypeAnnotation annotation = AnnotationTypeAnnotation.New(myItem);
this.Add(annotation); this.Add(annotation);
return annotation; return annotation;
} }
public void Remove(Annotation myAnnotation) public void Remove(Annotation myAnnotation)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(AnnotationTypeAnnotation annotationTypeAnnotation in this) foreach (AnnotationTypeAnnotation annotationTypeAnnotation in this)
if ((hasBrokenRules = annotationTypeAnnotation.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = annotationTypeAnnotation.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(TypeIDCriteria criteria) private void DataPortal_Fetch(TypeIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationTypeAnnotations.DataPortal_FetchTypeID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeAnnotations.DataPortal_FetchTypeID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationTypeAnnotations.DataPortal_FetchTypeID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeAnnotations.DataPortal_FetchTypeID", ex);
throw new DbCslaException("AnnotationTypeAnnotations.DataPortal_Fetch", ex); throw new DbCslaException("AnnotationTypeAnnotations.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class AnnotationTypeAnnotationsPropertyDescriptor : vlnListPropertyDescriptor public partial class AnnotationTypeAnnotationsPropertyDescriptor : vlnListPropertyDescriptor
{ {
private AnnotationTypeAnnotation Item { get { return (AnnotationTypeAnnotation) _Item;} } private AnnotationTypeAnnotation Item { get { return (AnnotationTypeAnnotation)_Item; } }
public AnnotationTypeAnnotationsPropertyDescriptor(AnnotationTypeAnnotations collection, int index):base(collection, index){;} public AnnotationTypeAnnotationsPropertyDescriptor(AnnotationTypeAnnotations collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is AnnotationTypeAnnotations) if (destType == typeof(string) && value is AnnotationTypeAnnotations)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((AnnotationTypeAnnotations) value).Items.Count.ToString() + " Annotations"; return ((AnnotationTypeAnnotations)value).Items.Count.ToString() + " Annotations";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<AnnotationTypeInfo> _AllList = new List<AnnotationTypeInfo>(); protected static List<AnnotationTypeInfo> _AllList = new List<AnnotationTypeInfo>();
private static Dictionary<string, AnnotationTypeInfo> _AllByPrimaryKey = new Dictionary<string, AnnotationTypeInfo>(); private static Dictionary<string, List<AnnotationTypeInfo>> _AllByPrimaryKey = new Dictionary<string, List<AnnotationTypeInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<AnnotationTypeInfo> remove = new List<AnnotationTypeInfo>(); List<AnnotationTypeInfo> remove = new List<AnnotationTypeInfo>();
foreach (AnnotationTypeInfo tmp in _AllList) foreach (AnnotationTypeInfo tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.TypeID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.TypeID.ToString()))
{
_AllByPrimaryKey[tmp.TypeID.ToString()] = new List<AnnotationTypeInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.TypeID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (AnnotationTypeInfo tmp in remove) foreach (AnnotationTypeInfo tmp in remove)
@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = typeID.ToString(); string key = typeID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("TypeID",true); CanReadProperty("TypeID", true);
return _TypeID; return _TypeID;
} }
} }
@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name",true); CanReadProperty("Name", true);
return _Name; return _Name;
} }
} }
@ -105,7 +109,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
} }
@ -115,7 +119,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -125,7 +129,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
} }
@ -138,7 +142,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationTypeAnnotationCount",true); CanReadProperty("AnnotationTypeAnnotationCount", true);
return _AnnotationTypeAnnotationCount; return _AnnotationTypeAnnotationCount;
} }
} }
@ -149,7 +153,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationTypeAnnotations",true); CanReadProperty("AnnotationTypeAnnotations", true);
if (_AnnotationTypeAnnotationCount < 0 || (_AnnotationTypeAnnotationCount > 0 && _AnnotationTypeAnnotations == null)) if (_AnnotationTypeAnnotationCount < 0 || (_AnnotationTypeAnnotationCount > 0 && _AnnotationTypeAnnotations == null))
_AnnotationTypeAnnotations = AnnotationInfoList.GetByTypeID(_TypeID); _AnnotationTypeAnnotations = AnnotationInfoList.GetByTypeID(_TypeID);
if (_AnnotationTypeAnnotationCount < 0) if (_AnnotationTypeAnnotationCount < 0)
@ -159,7 +163,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshAnnotationTypeAnnotations() internal void RefreshAnnotationTypeAnnotations()
{ {
_AnnotationTypeAnnotationCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_TypeID.ToString()))
foreach (AnnotationTypeInfo tmp in _AllByPrimaryKey[_TypeID.ToString()])
tmp._AnnotationTypeAnnotationCount = -1; // This will cause the data to be requeried
} }
// TODO: Replace base AnnotationTypeInfo.ToString function as necessary // TODO: Replace base AnnotationTypeInfo.ToString function as necessary
/// <summary> /// <summary>
@ -181,14 +188,25 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _AnnotationTypeInfoUnique = 0;
private int _MyAnnotationTypeInfoUnique;
public int MyAnnotationTypeInfoUnique
{
get { return _MyAnnotationTypeInfoUnique; }
}
private AnnotationTypeInfo() private AnnotationTypeInfo()
{/* require use of factory methods */ {/* require use of factory methods */
_MyAnnotationTypeInfoUnique = ++_AnnotationTypeInfoUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(TypeID.ToString()); if (!_AllByPrimaryKey.ContainsKey(TypeID.ToString())) return;
List<AnnotationTypeInfo> listAnnotationTypeInfo = _AllByPrimaryKey[TypeID.ToString()]; // Get the list of items
listAnnotationTypeInfo.Remove(this); // Remove the item from the list
if (listAnnotationTypeInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(TypeID.ToString()); // remove the list
} }
public virtual AnnotationType Get() public virtual AnnotationType Get()
{ {
@ -196,9 +214,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(AnnotationType tmp) public static void Refresh(AnnotationType tmp)
{ {
AnnotationTypeInfo tmpInfo = GetExistingByPrimaryKey(tmp.TypeID); string key = tmp.TypeID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (AnnotationTypeInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(AnnotationType tmp) private void RefreshFields(AnnotationType tmp)
{ {
@ -219,7 +239,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<AnnotationTypeInfo>(new PKCriteria(typeID)); tmp = DataPortal.Fetch<AnnotationTypeInfo>(new PKCriteria(typeID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -233,14 +253,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
internal AnnotationTypeInfo(SafeDataReader dr) internal AnnotationTypeInfo(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationTypeInfo.Constructor", GetHashCode()); _MyAnnotationTypeInfoUnique = ++_AnnotationTypeInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.Constructor", GetHashCode());
try try
{ {
ReadData(dr); ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationTypeInfo.Constructor", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeInfo.Constructor", ex);
throw new DbCslaException("AnnotationTypeInfo.Constructor", ex); throw new DbCslaException("AnnotationTypeInfo.Constructor", ex);
} }
} }
@ -257,7 +278,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationTypeInfo.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.ReadData", GetHashCode());
try try
{ {
_TypeID = dr.GetInt32("TypeID"); _TypeID = dr.GetInt32("TypeID");
@ -269,14 +290,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationTypeInfo.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeInfo.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationTypeInfo.ReadData", ex); throw new DbCslaException("AnnotationTypeInfo.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationTypeInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -304,7 +325,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationTypeInfo.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationTypeInfo.DataPortal_Fetch", ex); throw new DbCslaException("AnnotationTypeInfo.DataPortal_Fetch", ex);
} }
@ -314,7 +335,7 @@ namespace VEPROMS.CSLA.Library
#region extension #region extension
AnnotationTypeInfoExtension _AnnotationTypeInfoExtension = new AnnotationTypeInfoExtension(); AnnotationTypeInfoExtension _AnnotationTypeInfoExtension = new AnnotationTypeInfoExtension();
[Serializable()] [Serializable()]
partial class AnnotationTypeInfoExtension : extensionBase {} partial class AnnotationTypeInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {

View File

@ -96,7 +96,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationTypeInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -116,7 +116,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationTypeInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("AnnotationTypeInfoList.DataPortal_Fetch", ex); throw new DbCslaException("AnnotationTypeInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -177,8 +177,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class AnnotationTypeInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class AnnotationTypeInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private AnnotationTypeInfo Item { get { return (AnnotationTypeInfo) _Item;} } private AnnotationTypeInfo Item { get { return (AnnotationTypeInfo)_Item; } }
public AnnotationTypeInfoListPropertyDescriptor(AnnotationTypeInfoList collection, int index):base(collection, index){;} public AnnotationTypeInfoListPropertyDescriptor(AnnotationTypeInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -189,7 +189,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is AnnotationTypeInfoList) if (destType == typeof(string) && value is AnnotationTypeInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((AnnotationTypeInfoList) value).Items.Count.ToString() + " AnnotationTypes"; return ((AnnotationTypeInfoList)value).Items.Count.ToString() + " AnnotationTypes";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -47,21 +47,25 @@ namespace VEPROMS.CSLA.Library
foreach (Assignment tmp in _RefreshAssignments) foreach (Assignment tmp in _RefreshAssignments)
{ {
AssignmentInfo.Refresh(tmp); AssignmentInfo.Refresh(tmp);
if(tmp._MyFolder != null) FolderInfo.Refresh(tmp._MyFolder); if (tmp._MyFolder != null) FolderInfo.Refresh(tmp._MyFolder);
if(tmp._MyGroup != null) GroupInfo.Refresh(tmp._MyGroup); if (tmp._MyGroup != null) GroupInfo.Refresh(tmp._MyGroup);
if(tmp._MyRole != null) RoleInfo.Refresh(tmp._MyRole); if (tmp._MyRole != null) RoleInfo.Refresh(tmp._MyRole);
} }
} }
#endregion #endregion
#region Collection #region Collection
protected static List<Assignment> _AllList = new List<Assignment>(); protected static List<Assignment> _AllList = new List<Assignment>();
private static Dictionary<string, Assignment> _AllByPrimaryKey = new Dictionary<string, Assignment>(); private static Dictionary<string, List<Assignment>> _AllByPrimaryKey = new Dictionary<string, List<Assignment>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<Assignment> remove = new List<Assignment>(); List<Assignment> remove = new List<Assignment>();
foreach (Assignment tmp in _AllList) foreach (Assignment tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.AID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.AID.ToString()))
{
_AllByPrimaryKey[tmp.AID.ToString()] = new List<Assignment>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.AID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (Assignment tmp in remove) foreach (Assignment tmp in remove)
@ -71,7 +75,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = aid.ToString(); string key = aid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -93,7 +97,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AID",true); CanReadProperty("AID", true);
return _AID; return _AID;
} }
} }
@ -103,7 +107,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GID",true); CanReadProperty("GID", true);
if (_MyGroup != null) _GID = _MyGroup.GID; if (_MyGroup != null) _GID = _MyGroup.GID;
return _GID; return _GID;
} }
@ -114,14 +118,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyGroup",true); CanReadProperty("MyGroup", true);
if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID); if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID);
return _MyGroup; return _MyGroup;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyGroup",true); CanWriteProperty("MyGroup", true);
if (_MyGroup != value) if (_MyGroup != value)
{ {
_MyGroup = value; _MyGroup = value;
@ -135,7 +139,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RID",true); CanReadProperty("RID", true);
if (_MyRole != null) _RID = _MyRole.RID; if (_MyRole != null) _RID = _MyRole.RID;
return _RID; return _RID;
} }
@ -146,14 +150,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyRole",true); CanReadProperty("MyRole", true);
if (_MyRole == null && _RID != 0) _MyRole = Role.Get(_RID); if (_MyRole == null && _RID != 0) _MyRole = Role.Get(_RID);
return _MyRole; return _MyRole;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyRole",true); CanWriteProperty("MyRole", true);
if (_MyRole != value) if (_MyRole != value)
{ {
_MyRole = value; _MyRole = value;
@ -167,7 +171,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderID",true); CanReadProperty("FolderID", true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID; if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID; return _FolderID;
} }
@ -178,14 +182,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFolder",true); CanReadProperty("MyFolder", true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID); if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder; return _MyFolder;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyFolder",true); CanWriteProperty("MyFolder", true);
if (_MyFolder != value) if (_MyFolder != value)
{ {
_MyFolder = value; _MyFolder = value;
@ -199,13 +203,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("StartDate",true); CanReadProperty("StartDate", true);
return _StartDate; return _StartDate;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("StartDate",true); CanWriteProperty("StartDate", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
_StartDate = value; _StartDate = value;
try try
@ -229,13 +233,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("EndDate",true); CanReadProperty("EndDate", true);
return _EndDate; return _EndDate;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("EndDate",true); CanWriteProperty("EndDate", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
_EndDate = value; _EndDate = value;
try try
@ -259,13 +263,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -279,13 +283,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UsrID",true); CanWriteProperty("UsrID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UsrID != value) if (_UsrID != value)
{ {
@ -297,11 +301,11 @@ namespace VEPROMS.CSLA.Library
private byte[] _LastChanged = new byte[8];//timestamp private byte[] _LastChanged = new byte[8];//timestamp
public override bool IsDirty public override bool IsDirty
{ {
get { return base.IsDirty || (_MyFolder == null? false : _MyFolder.IsDirty) || (_MyGroup == null? false : _MyGroup.IsDirty) || (_MyRole == null? false : _MyRole.IsDirty); } get { return base.IsDirty || (_MyFolder == null ? false : _MyFolder.IsDirty) || (_MyGroup == null ? false : _MyGroup.IsDirty) || (_MyRole == null ? false : _MyRole.IsDirty); }
} }
public override bool IsValid public override bool IsValid
{ {
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyFolder == null? true : _MyFolder.IsValid) && (_MyGroup == null? true : _MyGroup.IsValid) && (_MyRole == null? true : _MyRole.IsValid); } get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyFolder == null ? true : _MyFolder.IsValid) && (_MyGroup == null ? true : _MyGroup.IsValid) && (_MyRole == null ? true : _MyRole.IsValid); }
} }
// TODO: Replace base Assignment.ToString function as necessary // TODO: Replace base Assignment.ToString function as necessary
/// <summary> /// <summary>
@ -324,24 +328,25 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get { get
if(_CheckingBrokenRules)return null; {
if (_CheckingBrokenRules) return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules; if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules;
if (_MyRole != null && (hasBrokenRules = _MyRole.HasBrokenRules) != null) return hasBrokenRules; if (_MyRole != null && (hasBrokenRules = _MyRole.HasBrokenRules) != null) return hasBrokenRules;
if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -498,14 +503,25 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods #region Factory Methods
public int CurrentEditLevel public int CurrentEditLevel
{ get { return EditLevel; } } { get { return EditLevel; } }
private static int _AssignmentUnique = 0;
private int _MyAssignmentUnique;
public int MyAssignmentUnique
{
get { return _MyAssignmentUnique; }
}
protected Assignment() protected Assignment()
{/* require use of factory methods */ {/* require use of factory methods */
_MyAssignmentUnique = ++_AssignmentUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(AID.ToString()); if (!_AllByPrimaryKey.ContainsKey(AID.ToString())) return;
List<Assignment> listAssignment = _AllByPrimaryKey[AID.ToString()]; // Get the list of items
listAssignment.Remove(this); // Remove the item from the list
if (listAssignment.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(AID.ToString()); // remove the list
} }
public static Assignment New() public static Assignment New()
{ {
@ -591,7 +607,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<Assignment>(new PKCriteria(aid)); tmp = DataPortal.Fetch<Assignment>(new PKCriteria(aid));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -671,7 +687,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Assignment.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.ReadData", GetHashCode());
try try
{ {
_AID = dr.GetInt32("AID"); _AID = dr.GetInt32("AID");
@ -687,14 +703,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Assignment.ReadData", ex); throw new DbCslaException("Assignment.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Assignment.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -722,7 +738,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Assignment.DataPortal_Fetch", ex); throw new DbCslaException("Assignment.DataPortal_Fetch", ex);
} }
@ -743,13 +759,13 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.DataPortal_Insert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.DataPortal_Insert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Assignment.DataPortal_Insert", ex); throw new DbCslaException("Assignment.DataPortal_Insert", ex);
} }
finally finally
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Assignment.DataPortal_Insert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.DataPortal_Insert", GetHashCode());
} }
} }
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
@ -758,9 +774,9 @@ namespace VEPROMS.CSLA.Library
if (!this.IsDirty) return; if (!this.IsDirty) return;
try try
{ {
if(_MyFolder != null) _MyFolder.Update(); if (_MyFolder != null) _MyFolder.Update();
if(_MyGroup != null) _MyGroup.Update(); if (_MyGroup != null) _MyGroup.Update();
if(_MyRole != null) _MyRole.Update(); if (_MyRole != null) _MyRole.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
{ {
@ -789,11 +805,11 @@ namespace VEPROMS.CSLA.Library
} }
MarkOld(); MarkOld();
// update child objects // update child objects
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Assignment.SQLInsert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.SQLInsert", GetHashCode());
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.SQLInsert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.SQLInsert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Assignment.SQLInsert", ex); throw new DbCslaException("Assignment.SQLInsert", ex);
} }
@ -801,7 +817,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int aid, Group myGroup, Role myRole, Folder myFolder, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID) public static byte[] Add(SqlConnection cn, ref int aid, Group myGroup, Role myRole, Folder myFolder, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Assignment.Add", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.Add", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -832,7 +848,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.Add", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.Add", ex);
throw new DbCslaException("Assignment.Add", ex); throw new DbCslaException("Assignment.Add", ex);
} }
} }
@ -840,7 +856,7 @@ namespace VEPROMS.CSLA.Library
protected override void DataPortal_Update() protected override void DataPortal_Update()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Assignment.DataPortal_Update", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.DataPortal_Update", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -854,7 +870,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.DataPortal_Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.DataPortal_Update", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -863,12 +879,12 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate() internal void SQLUpdate()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Assignment.SQLUpdate", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.SQLUpdate", GetHashCode());
try try
{ {
if(_MyFolder != null) _MyFolder.Update(); if (_MyFolder != null) _MyFolder.Update();
if(_MyGroup != null) _MyGroup.Update(); if (_MyGroup != null) _MyGroup.Update();
if(_MyRole != null) _MyRole.Update(); if (_MyRole != null) _MyRole.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty) if (base.IsDirty)
{ {
@ -901,7 +917,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.SQLUpdate", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.SQLUpdate", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -922,7 +938,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int aid, Group myGroup, Role myRole, Folder myFolder, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID, ref byte[] lastChanged) public static byte[] Update(SqlConnection cn, ref int aid, Group myGroup, Role myRole, Folder myFolder, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID, ref byte[] lastChanged)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Assignment.Update", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.Update", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -951,7 +967,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.Update", ex);
throw new DbCslaException("Assignment.Update", ex); throw new DbCslaException("Assignment.Update", ex);
} }
} }
@ -963,7 +979,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria) private void DataPortal_Delete(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Assignment.DataPortal_Delete", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.DataPortal_Delete", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -979,7 +995,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.DataPortal_Delete", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.DataPortal_Delete", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Assignment.DataPortal_Delete", ex); throw new DbCslaException("Assignment.DataPortal_Delete", ex);
} }
@ -987,7 +1003,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int aid) public static void Remove(SqlConnection cn, int aid)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Assignment.Remove", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.Remove", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -1002,7 +1018,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.Remove", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.Remove", ex);
throw new DbCslaException("Assignment.Remove", ex); throw new DbCslaException("Assignment.Remove", ex);
} }
} }
@ -1036,7 +1052,7 @@ namespace VEPROMS.CSLA.Library
} }
protected override void DataPortal_Execute() protected override void DataPortal_Execute()
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Assignment.DataPortal_Execute", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.DataPortal_Execute", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1054,7 +1070,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.DataPortal_Execute", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.DataPortal_Execute", ex);
throw new DbCslaException("Assignment.DataPortal_Execute", ex); throw new DbCslaException("Assignment.DataPortal_Execute", ex);
} }
} }

View File

@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<AssignmentInfo> _AllList = new List<AssignmentInfo>(); protected static List<AssignmentInfo> _AllList = new List<AssignmentInfo>();
private static Dictionary<string, AssignmentInfo> _AllByPrimaryKey = new Dictionary<string, AssignmentInfo>(); private static Dictionary<string, List<AssignmentInfo>> _AllByPrimaryKey = new Dictionary<string, List<AssignmentInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<AssignmentInfo> remove = new List<AssignmentInfo>(); List<AssignmentInfo> remove = new List<AssignmentInfo>();
foreach (AssignmentInfo tmp in _AllList) foreach (AssignmentInfo tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.AID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.AID.ToString()))
{
_AllByPrimaryKey[tmp.AID.ToString()] = new List<AssignmentInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.AID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (AssignmentInfo tmp in remove) foreach (AssignmentInfo tmp in remove)
@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = aid.ToString(); string key = aid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AID",true); CanReadProperty("AID", true);
return _AID; return _AID;
} }
} }
@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GID",true); CanReadProperty("GID", true);
if (_MyGroup != null) _GID = _MyGroup.GID; if (_MyGroup != null) _GID = _MyGroup.GID;
return _GID; return _GID;
} }
@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyGroup",true); CanReadProperty("MyGroup", true);
if (_MyGroup == null && _GID != 0) _MyGroup = GroupInfo.Get(_GID); if (_MyGroup == null && _GID != 0) _MyGroup = GroupInfo.Get(_GID);
return _MyGroup; return _MyGroup;
} }
@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RID",true); CanReadProperty("RID", true);
if (_MyRole != null) _RID = _MyRole.RID; if (_MyRole != null) _RID = _MyRole.RID;
return _RID; return _RID;
} }
@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyRole",true); CanReadProperty("MyRole", true);
if (_MyRole == null && _RID != 0) _MyRole = RoleInfo.Get(_RID); if (_MyRole == null && _RID != 0) _MyRole = RoleInfo.Get(_RID);
return _MyRole; return _MyRole;
} }
@ -139,7 +143,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderID",true); CanReadProperty("FolderID", true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID; if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID; return _FolderID;
} }
@ -150,7 +154,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFolder",true); CanReadProperty("MyFolder", true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = FolderInfo.Get(_FolderID); if (_MyFolder == null && _FolderID != 0) _MyFolder = FolderInfo.Get(_FolderID);
return _MyFolder; return _MyFolder;
} }
@ -161,7 +165,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("StartDate",true); CanReadProperty("StartDate", true);
return _StartDate; return _StartDate;
} }
} }
@ -171,7 +175,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("EndDate",true); CanReadProperty("EndDate", true);
return _EndDate; return _EndDate;
} }
} }
@ -181,7 +185,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -191,7 +195,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
} }
@ -215,14 +219,25 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _AssignmentInfoUnique = 0;
private int _MyAssignmentInfoUnique;
public int MyAssignmentInfoUnique
{
get { return _MyAssignmentInfoUnique; }
}
private AssignmentInfo() private AssignmentInfo()
{/* require use of factory methods */ {/* require use of factory methods */
_MyAssignmentInfoUnique = ++_AssignmentInfoUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(AID.ToString()); if (!_AllByPrimaryKey.ContainsKey(AID.ToString())) return;
List<AssignmentInfo> listAssignmentInfo = _AllByPrimaryKey[AID.ToString()]; // Get the list of items
listAssignmentInfo.Remove(this); // Remove the item from the list
if (listAssignmentInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(AID.ToString()); // remove the list
} }
public virtual Assignment Get() public virtual Assignment Get()
{ {
@ -230,9 +245,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(Assignment tmp) public static void Refresh(Assignment tmp)
{ {
AssignmentInfo tmpInfo = GetExistingByPrimaryKey(tmp.AID); string key = tmp.AID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(Assignment tmp) private void RefreshFields(Assignment tmp)
{ {
@ -240,23 +257,23 @@ namespace VEPROMS.CSLA.Library
{ {
MyGroup.RefreshGroupAssignments(); // Update List for old value MyGroup.RefreshGroupAssignments(); // Update List for old value
_GID = tmp.GID; // Update the value _GID = tmp.GID; // Update the value
_MyGroup = null; // Reset list so that the next line gets a new list
MyGroup.RefreshGroupAssignments(); // Update List for new value
} }
_MyGroup = null; // Reset list so that the next line gets a new list
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
if (_RID != tmp.RID) if (_RID != tmp.RID)
{ {
MyRole.RefreshRoleAssignments(); // Update List for old value MyRole.RefreshRoleAssignments(); // Update List for old value
_RID = tmp.RID; // Update the value _RID = tmp.RID; // Update the value
_MyRole = null; // Reset list so that the next line gets a new list
MyRole.RefreshRoleAssignments(); // Update List for new value
} }
_MyRole = null; // Reset list so that the next line gets a new list
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
if (_FolderID != tmp.FolderID) if (_FolderID != tmp.FolderID)
{ {
MyFolder.RefreshFolderAssignments(); // Update List for old value MyFolder.RefreshFolderAssignments(); // Update List for old value
_FolderID = tmp.FolderID; // Update the value _FolderID = tmp.FolderID; // Update the value
_MyFolder = null; // Reset list so that the next line gets a new list
MyFolder.RefreshFolderAssignments(); // Update List for new value
} }
_MyFolder = null; // Reset list so that the next line gets a new list
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for new value
_StartDate = tmp.StartDate; _StartDate = tmp.StartDate;
_EndDate = tmp.EndDate; _EndDate = tmp.EndDate;
_DTS = tmp.DTS; _DTS = tmp.DTS;
@ -269,9 +286,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(FolderAssignment tmp) public static void Refresh(FolderAssignment tmp)
{ {
AssignmentInfo tmpInfo = GetExistingByPrimaryKey(tmp.AID); string key = tmp.AID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(FolderAssignment tmp) private void RefreshFields(FolderAssignment tmp)
{ {
@ -279,16 +298,16 @@ namespace VEPROMS.CSLA.Library
{ {
MyGroup.RefreshGroupAssignments(); // Update List for old value MyGroup.RefreshGroupAssignments(); // Update List for old value
_GID = tmp.GID; // Update the value _GID = tmp.GID; // Update the value
_MyGroup = null; // Reset list so that the next line gets a new list
MyGroup.RefreshGroupAssignments(); // Update List for new value
} }
_MyGroup = null; // Reset list so that the next line gets a new list
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
if (_RID != tmp.RID) if (_RID != tmp.RID)
{ {
MyRole.RefreshRoleAssignments(); // Update List for old value MyRole.RefreshRoleAssignments(); // Update List for old value
_RID = tmp.RID; // Update the value _RID = tmp.RID; // Update the value
_MyRole = null; // Reset list so that the next line gets a new list
MyRole.RefreshRoleAssignments(); // Update List for new value
} }
_MyRole = null; // Reset list so that the next line gets a new list
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
_StartDate = tmp.StartDate; _StartDate = tmp.StartDate;
_EndDate = tmp.EndDate; _EndDate = tmp.EndDate;
_DTS = tmp.DTS; _DTS = tmp.DTS;
@ -301,9 +320,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(GroupAssignment tmp) public static void Refresh(GroupAssignment tmp)
{ {
AssignmentInfo tmpInfo = GetExistingByPrimaryKey(tmp.AID); string key = tmp.AID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(GroupAssignment tmp) private void RefreshFields(GroupAssignment tmp)
{ {
@ -311,16 +332,16 @@ namespace VEPROMS.CSLA.Library
{ {
MyRole.RefreshRoleAssignments(); // Update List for old value MyRole.RefreshRoleAssignments(); // Update List for old value
_RID = tmp.RID; // Update the value _RID = tmp.RID; // Update the value
_MyRole = null; // Reset list so that the next line gets a new list
MyRole.RefreshRoleAssignments(); // Update List for new value
} }
_MyRole = null; // Reset list so that the next line gets a new list
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
if (_FolderID != tmp.FolderID) if (_FolderID != tmp.FolderID)
{ {
MyFolder.RefreshFolderAssignments(); // Update List for old value MyFolder.RefreshFolderAssignments(); // Update List for old value
_FolderID = tmp.FolderID; // Update the value _FolderID = tmp.FolderID; // Update the value
_MyFolder = null; // Reset list so that the next line gets a new list
MyFolder.RefreshFolderAssignments(); // Update List for new value
} }
_MyFolder = null; // Reset list so that the next line gets a new list
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for new value
_StartDate = tmp.StartDate; _StartDate = tmp.StartDate;
_EndDate = tmp.EndDate; _EndDate = tmp.EndDate;
_DTS = tmp.DTS; _DTS = tmp.DTS;
@ -333,9 +354,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(RoleAssignment tmp) public static void Refresh(RoleAssignment tmp)
{ {
AssignmentInfo tmpInfo = GetExistingByPrimaryKey(tmp.AID); string key = tmp.AID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(RoleAssignment tmp) private void RefreshFields(RoleAssignment tmp)
{ {
@ -343,16 +366,16 @@ namespace VEPROMS.CSLA.Library
{ {
MyGroup.RefreshGroupAssignments(); // Update List for old value MyGroup.RefreshGroupAssignments(); // Update List for old value
_GID = tmp.GID; // Update the value _GID = tmp.GID; // Update the value
_MyGroup = null; // Reset list so that the next line gets a new list
MyGroup.RefreshGroupAssignments(); // Update List for new value
} }
_MyGroup = null; // Reset list so that the next line gets a new list
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
if (_FolderID != tmp.FolderID) if (_FolderID != tmp.FolderID)
{ {
MyFolder.RefreshFolderAssignments(); // Update List for old value MyFolder.RefreshFolderAssignments(); // Update List for old value
_FolderID = tmp.FolderID; // Update the value _FolderID = tmp.FolderID; // Update the value
_MyFolder = null; // Reset list so that the next line gets a new list
MyFolder.RefreshFolderAssignments(); // Update List for new value
} }
_MyFolder = null; // Reset list so that the next line gets a new list
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for new value
_StartDate = tmp.StartDate; _StartDate = tmp.StartDate;
_EndDate = tmp.EndDate; _EndDate = tmp.EndDate;
_DTS = tmp.DTS; _DTS = tmp.DTS;
@ -373,7 +396,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<AssignmentInfo>(new PKCriteria(aid)); tmp = DataPortal.Fetch<AssignmentInfo>(new PKCriteria(aid));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -387,14 +410,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
internal AssignmentInfo(SafeDataReader dr) internal AssignmentInfo(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfo.Constructor", GetHashCode()); _MyAssignmentInfoUnique = ++_AssignmentInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfo.Constructor", GetHashCode());
try try
{ {
ReadData(dr); ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AssignmentInfo.Constructor", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AssignmentInfo.Constructor", ex);
throw new DbCslaException("AssignmentInfo.Constructor", ex); throw new DbCslaException("AssignmentInfo.Constructor", ex);
} }
} }
@ -411,7 +435,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfo.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfo.ReadData", GetHashCode());
try try
{ {
_AID = dr.GetInt32("AID"); _AID = dr.GetInt32("AID");
@ -425,14 +449,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AssignmentInfo.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AssignmentInfo.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("AssignmentInfo.ReadData", ex); throw new DbCslaException("AssignmentInfo.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfo.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -460,7 +484,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AssignmentInfo.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AssignmentInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("AssignmentInfo.DataPortal_Fetch", ex); throw new DbCslaException("AssignmentInfo.DataPortal_Fetch", ex);
} }
@ -470,7 +494,7 @@ namespace VEPROMS.CSLA.Library
#region extension #region extension
AssignmentInfoExtension _AssignmentInfoExtension = new AssignmentInfoExtension(); AssignmentInfoExtension _AssignmentInfoExtension = new AssignmentInfoExtension();
[Serializable()] [Serializable()]
partial class AssignmentInfoExtension : extensionBase {} partial class AssignmentInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {

View File

@ -138,7 +138,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -158,7 +158,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AssignmentInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AssignmentInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("AssignmentInfoList.DataPortal_Fetch", ex); throw new DbCslaException("AssignmentInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -180,7 +180,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(FolderIDCriteria criteria) private void DataPortal_Fetch(FolderIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfoList.DataPortal_FetchFolderID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfoList.DataPortal_FetchFolderID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -201,7 +201,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AssignmentInfoList.DataPortal_FetchFolderID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AssignmentInfoList.DataPortal_FetchFolderID", ex);
throw new DbCslaException("AssignmentInfoList.DataPortal_Fetch", ex); throw new DbCslaException("AssignmentInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -223,7 +223,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(GIDCriteria criteria) private void DataPortal_Fetch(GIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfoList.DataPortal_FetchGID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfoList.DataPortal_FetchGID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -244,7 +244,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AssignmentInfoList.DataPortal_FetchGID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AssignmentInfoList.DataPortal_FetchGID", ex);
throw new DbCslaException("AssignmentInfoList.DataPortal_Fetch", ex); throw new DbCslaException("AssignmentInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -266,7 +266,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(RIDCriteria criteria) private void DataPortal_Fetch(RIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfoList.DataPortal_FetchRID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfoList.DataPortal_FetchRID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -287,7 +287,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("AssignmentInfoList.DataPortal_FetchRID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("AssignmentInfoList.DataPortal_FetchRID", ex);
throw new DbCslaException("AssignmentInfoList.DataPortal_Fetch", ex); throw new DbCslaException("AssignmentInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -348,8 +348,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class AssignmentInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class AssignmentInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private AssignmentInfo Item { get { return (AssignmentInfo) _Item;} } private AssignmentInfo Item { get { return (AssignmentInfo)_Item; } }
public AssignmentInfoListPropertyDescriptor(AssignmentInfoList collection, int index):base(collection, index){;} public AssignmentInfoListPropertyDescriptor(AssignmentInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -360,7 +360,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is AssignmentInfoList) if (destType == typeof(string) && value is AssignmentInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((AssignmentInfoList) value).Items.Count.ToString() + " Assignments"; return ((AssignmentInfoList)value).Items.Count.ToString() + " Assignments";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -113,8 +113,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(Folder folder in this) foreach (Folder folder in this)
if ((hasBrokenRules = folder.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = folder.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -123,8 +123,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ParentIDCriteria criteria) private void DataPortal_Fetch(ParentIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ChildFolders.DataPortal_FetchParentID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ChildFolders.DataPortal_FetchParentID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -203,7 +203,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ChildFolders.DataPortal_FetchParentID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ChildFolders.DataPortal_FetchParentID", ex);
throw new DbCslaException("ChildFolders.DataPortal_Fetch", ex); throw new DbCslaException("ChildFolders.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -288,8 +288,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class ChildFoldersPropertyDescriptor : vlnListPropertyDescriptor public partial class ChildFoldersPropertyDescriptor : vlnListPropertyDescriptor
{ {
private Folder Item { get { return (Folder) _Item;} } private Folder Item { get { return (Folder)_Item; } }
public ChildFoldersPropertyDescriptor(ChildFolders collection, int index):base(collection, index){;} public ChildFoldersPropertyDescriptor(ChildFolders collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -300,7 +300,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is ChildFolders) if (destType == typeof(string) && value is ChildFolders)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((ChildFolders) value).Items.Count.ToString() + " Folders"; return ((ChildFolders)value).Items.Count.ToString() + " Folders";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -113,8 +113,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(Format format in this) foreach (Format format in this)
if ((hasBrokenRules = format.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = format.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -123,8 +123,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ParentIDCriteria criteria) private void DataPortal_Fetch(ParentIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ChildFormats.DataPortal_FetchParentID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ChildFormats.DataPortal_FetchParentID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -203,7 +203,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ChildFormats.DataPortal_FetchParentID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ChildFormats.DataPortal_FetchParentID", ex);
throw new DbCslaException("ChildFormats.DataPortal_Fetch", ex); throw new DbCslaException("ChildFormats.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -288,8 +288,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class ChildFormatsPropertyDescriptor : vlnListPropertyDescriptor public partial class ChildFormatsPropertyDescriptor : vlnListPropertyDescriptor
{ {
private Format Item { get { return (Format) _Item;} } private Format Item { get { return (Format)_Item; } }
public ChildFormatsPropertyDescriptor(ChildFormats collection, int index):base(collection, index){;} public ChildFormatsPropertyDescriptor(ChildFormats collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -300,7 +300,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is ChildFormats) if (destType == typeof(string) && value is ChildFormats)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((ChildFormats) value).Items.Count.ToString() + " Formats"; return ((ChildFormats)value).Items.Count.ToString() + " Formats";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -41,7 +41,7 @@ namespace VEPROMS.CSLA.Library
{ {
foreach (ConnectionFolder tmp in _ConnectionFolders) foreach (ConnectionFolder tmp in _ConnectionFolders)
{ {
if(tmp.IsDirty)refreshConnectionFolders.Add(tmp); if (tmp.IsDirty) refreshConnectionFolders.Add(tmp);
} }
} }
} }
@ -65,15 +65,20 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<Connection> _AllList = new List<Connection>(); protected static List<Connection> _AllList = new List<Connection>();
private static Dictionary<string, Connection> _AllByPrimaryKey = new Dictionary<string, Connection>(); private static Dictionary<string, List<Connection>> _AllByPrimaryKey = new Dictionary<string, List<Connection>>();
private static Dictionary<string, Connection> _AllByName = new Dictionary<string, Connection>(); private static Dictionary<string, List<Connection>> _AllByName = new Dictionary<string, List<Connection>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<Connection> remove = new List<Connection>(); List<Connection> remove = new List<Connection>();
foreach (Connection tmp in _AllList) foreach (Connection tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.DBID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.DBID.ToString()))
_AllByName[tmp.Name.ToString()] = tmp; // Unique Index {
_AllByPrimaryKey[tmp.DBID.ToString()] = new List<Connection>(); // Add new list for PrimaryKey
_AllByName[tmp.Name.ToString()] = new List<Connection>(); // Add new list for Name
}
_AllByPrimaryKey[tmp.DBID.ToString()].Add(tmp); // Add to Primary Key list
_AllByName[tmp.Name.ToString()].Add(tmp); // Unique Index
remove.Add(tmp); remove.Add(tmp);
} }
foreach (Connection tmp in remove) foreach (Connection tmp in remove)
@ -83,14 +88,14 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = dbid.ToString(); string key = dbid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
public static Connection GetExistingByName(string name) public static Connection GetExistingByName(string name)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = name.ToString(); string key = name.ToString();
if (_AllByName.ContainsKey(key)) return _AllByName[key]; if (_AllByName.ContainsKey(key)) return _AllByName[key][0];
return null; return null;
} }
#endregion #endregion
@ -112,7 +117,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DBID",true); CanReadProperty("DBID", true);
return _DBID; return _DBID;
} }
} }
@ -122,13 +127,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name",true); CanReadProperty("Name", true);
return _Name; return _Name;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Name",true); CanWriteProperty("Name", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Name != value) if (_Name != value)
{ {
@ -143,13 +148,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Title",true); CanReadProperty("Title", true);
return _Title; return _Title;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Title",true); CanWriteProperty("Title", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Title != value) if (_Title != value)
{ {
@ -164,13 +169,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ConnectionString",true); CanReadProperty("ConnectionString", true);
return _ConnectionString; return _ConnectionString;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("ConnectionString",true); CanWriteProperty("ConnectionString", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_ConnectionString != value) if (_ConnectionString != value)
{ {
@ -188,13 +193,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ServerType",true); CanReadProperty("ServerType", true);
return _ServerType; return _ServerType;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("ServerType",true); CanWriteProperty("ServerType", true);
if (_ServerType != value) if (_ServerType != value)
{ {
_ServerType = value; _ServerType = value;
@ -208,13 +213,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -229,13 +234,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -249,13 +254,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UsrID",true); CanWriteProperty("UsrID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UsrID != value) if (_UsrID != value)
{ {
@ -274,7 +279,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ConnectionFolderCount",true); CanReadProperty("ConnectionFolderCount", true);
return _ConnectionFolderCount; return _ConnectionFolderCount;
} }
} }
@ -288,21 +293,21 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ConnectionFolders",true); CanReadProperty("ConnectionFolders", true);
if(_ConnectionFolderCount > 0 && _ConnectionFolders == null) if (_ConnectionFolderCount > 0 && _ConnectionFolders == null)
_ConnectionFolders = ConnectionFolders.GetByDBID(DBID); _ConnectionFolders = ConnectionFolders.GetByDBID(DBID);
else if(_ConnectionFolders == null) else if (_ConnectionFolders == null)
_ConnectionFolders = ConnectionFolders.New(); _ConnectionFolders = ConnectionFolders.New();
return _ConnectionFolders; return _ConnectionFolders;
} }
} }
public override bool IsDirty public override bool IsDirty
{ {
get { return base.IsDirty || (_ConnectionFolders == null? false : _ConnectionFolders.IsDirty); } get { return base.IsDirty || (_ConnectionFolders == null ? false : _ConnectionFolders.IsDirty); }
} }
public override bool IsValid public override bool IsValid
{ {
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_ConnectionFolders == null? true : _ConnectionFolders.IsValid); } get { return (IsNew && !IsDirty ? true : base.IsValid) && (_ConnectionFolders == null ? true : _ConnectionFolders.IsValid); }
} }
// TODO: Replace base Connection.ToString function as necessary // TODO: Replace base Connection.ToString function as necessary
/// <summary> /// <summary>
@ -325,22 +330,23 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get { get
if(_CheckingBrokenRules)return null; {
if (_CheckingBrokenRules) return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_ConnectionFolders != null && (hasBrokenRules = _ConnectionFolders.HasBrokenRules) != null) return hasBrokenRules; if (_ConnectionFolders != null && (hasBrokenRules = _ConnectionFolders.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -462,15 +468,29 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods #region Factory Methods
public int CurrentEditLevel public int CurrentEditLevel
{ get { return EditLevel; } } { get { return EditLevel; } }
private static int _ConnectionUnique = 0;
private int _MyConnectionUnique;
public int MyConnectionUnique
{
get { return _MyConnectionUnique; }
}
protected Connection() protected Connection()
{/* require use of factory methods */ {/* require use of factory methods */
_MyConnectionUnique = ++_ConnectionUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(DBID.ToString()); if (!_AllByPrimaryKey.ContainsKey(DBID.ToString())) return;
_AllByName.Remove(Name.ToString()); List<Connection> listConnection = _AllByPrimaryKey[DBID.ToString()]; // Get the list of items
listConnection.Remove(this); // Remove the item from the list
if (listConnection.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(DBID.ToString()); // remove the list
listConnection = _AllByName[DBID.ToString()]; // Get the list of items
listConnection.Remove(this); // Remove the item from the list
if (listConnection.Count == 0) //If there are no items left in the list
_AllByName.Remove(DBID.ToString()); // remove the list
} }
public static Connection New() public static Connection New()
{ {
@ -548,7 +568,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<Connection>(new PKCriteria(dbid)); tmp = DataPortal.Fetch<Connection>(new PKCriteria(dbid));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -567,8 +587,8 @@ namespace VEPROMS.CSLA.Library
Connection tmp = GetExistingByName(name); Connection tmp = GetExistingByName(name);
if (tmp == null) if (tmp == null)
{ {
tmp=DataPortal.Fetch<Connection>(new NameCriteria(name)); tmp = DataPortal.Fetch<Connection>(new NameCriteria(name));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -659,7 +679,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Connection.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Connection.ReadData", GetHashCode());
try try
{ {
_DBID = dr.GetInt32("DBID"); _DBID = dr.GetInt32("DBID");
@ -676,14 +696,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Connection.ReadData", ex); throw new DbCslaException("Connection.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Connection.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Connection.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -714,14 +734,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Connection.DataPortal_Fetch", ex); throw new DbCslaException("Connection.DataPortal_Fetch", ex);
} }
} }
private void DataPortal_Fetch(NameCriteria criteria) private void DataPortal_Fetch(NameCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Connection.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Connection.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -749,7 +769,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Connection.DataPortal_Fetch", ex); throw new DbCslaException("Connection.DataPortal_Fetch", ex);
} }
@ -770,13 +790,13 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.DataPortal_Insert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.DataPortal_Insert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Connection.DataPortal_Insert", ex); throw new DbCslaException("Connection.DataPortal_Insert", ex);
} }
finally finally
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Connection.DataPortal_Insert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Connection.DataPortal_Insert", GetHashCode());
} }
} }
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
@ -814,11 +834,11 @@ namespace VEPROMS.CSLA.Library
MarkOld(); MarkOld();
// update child objects // update child objects
if (_ConnectionFolders != null) _ConnectionFolders.Update(this); if (_ConnectionFolders != null) _ConnectionFolders.Update(this);
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Connection.SQLInsert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Connection.SQLInsert", GetHashCode());
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.SQLInsert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.SQLInsert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Connection.SQLInsert", ex); throw new DbCslaException("Connection.SQLInsert", ex);
} }
@ -826,7 +846,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int dbid, string name, string title, string connectionString, int serverType, string config, DateTime dts, string usrID) public static byte[] Add(SqlConnection cn, ref int dbid, string name, string title, string connectionString, int serverType, string config, DateTime dts, string usrID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Connection.Add", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Connection.Add", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -857,7 +877,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.Add", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.Add", ex);
throw new DbCslaException("Connection.Add", ex); throw new DbCslaException("Connection.Add", ex);
} }
} }
@ -865,7 +885,7 @@ namespace VEPROMS.CSLA.Library
protected override void DataPortal_Update() protected override void DataPortal_Update()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Connection.DataPortal_Update", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Connection.DataPortal_Update", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -879,7 +899,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.DataPortal_Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.DataPortal_Update", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -888,7 +908,7 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate() internal void SQLUpdate()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Connection.SQLUpdate", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Connection.SQLUpdate", GetHashCode());
try try
{ {
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
@ -924,7 +944,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.SQLUpdate", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.SQLUpdate", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -946,7 +966,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int dbid, string name, string title, string connectionString, int serverType, string config, DateTime dts, string usrID, ref byte[] lastChanged) public static byte[] Update(SqlConnection cn, ref int dbid, string name, string title, string connectionString, int serverType, string config, DateTime dts, string usrID, ref byte[] lastChanged)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Connection.Update", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Connection.Update", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -975,7 +995,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.Update", ex);
throw new DbCslaException("Connection.Update", ex); throw new DbCslaException("Connection.Update", ex);
} }
} }
@ -987,7 +1007,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria) private void DataPortal_Delete(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Connection.DataPortal_Delete", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Connection.DataPortal_Delete", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1003,7 +1023,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.DataPortal_Delete", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.DataPortal_Delete", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Connection.DataPortal_Delete", ex); throw new DbCslaException("Connection.DataPortal_Delete", ex);
} }
@ -1011,7 +1031,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int dbid) public static void Remove(SqlConnection cn, int dbid)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Connection.Remove", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Connection.Remove", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -1026,7 +1046,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.Remove", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.Remove", ex);
throw new DbCslaException("Connection.Remove", ex); throw new DbCslaException("Connection.Remove", ex);
} }
} }
@ -1060,7 +1080,7 @@ namespace VEPROMS.CSLA.Library
} }
protected override void DataPortal_Execute() protected override void DataPortal_Execute()
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Connection.DataPortal_Execute", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Connection.DataPortal_Execute", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1078,7 +1098,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.DataPortal_Execute", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.DataPortal_Execute", ex);
throw new DbCslaException("Connection.DataPortal_Execute", ex); throw new DbCslaException("Connection.DataPortal_Execute", ex);
} }
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderID",true); CanReadProperty("FolderID", true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID; if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID; return _FolderID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFolder",true); CanReadProperty("MyFolder", true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID); if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder; return _MyFolder;
} }
@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ParentID",true); CanReadProperty("ParentID", true);
if (_MyParent != null) _ParentID = _MyParent.FolderID; if (_MyParent != null) _ParentID = _MyParent.FolderID;
return _ParentID; return _ParentID;
} }
@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyParent",true); CanReadProperty("MyParent", true);
if (_MyParent == null && _ParentID != _FolderID) _MyParent = Folder.Get(_ParentID); if (_MyParent == null && _ParentID != _FolderID) _MyParent = Folder.Get(_ParentID);
return _MyParent; return _MyParent;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyParent",true); CanWriteProperty("MyParent", true);
if (_MyParent != value) if (_MyParent != value)
{ {
_MyParent = value; _MyParent = value;
@ -97,13 +97,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name",true); CanReadProperty("Name", true);
return _Name; return _Name;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Name",true); CanWriteProperty("Name", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Name != value) if (_Name != value)
{ {
@ -118,13 +118,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Title",true); CanReadProperty("Title", true);
return _Title; return _Title;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Title",true); CanWriteProperty("Title", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Title != value) if (_Title != value)
{ {
@ -139,13 +139,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ShortName",true); CanReadProperty("ShortName", true);
return _ShortName; return _ShortName;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("ShortName",true); CanWriteProperty("ShortName", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_ShortName != value) if (_ShortName != value)
{ {
@ -160,7 +160,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatID",true); CanReadProperty("FormatID", true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID; if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID; return _FormatID;
} }
@ -171,18 +171,18 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFormat",true); CanReadProperty("MyFormat", true);
if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID); if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID);
return _MyFormat; return _MyFormat;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyFormat",true); CanWriteProperty("MyFormat", true);
if (_MyFormat != value) if (_MyFormat != value)
{ {
_MyFormat = value; _MyFormat = value;
_FormatID = (value == null ? null : (int?) value.FormatID); _FormatID = (value == null ? null : (int?)value.FormatID);
PropertyHasChanged(); PropertyHasChanged();
} }
} }
@ -193,13 +193,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -214,13 +214,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -234,13 +234,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UsrID",true); CanWriteProperty("UsrID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UsrID != value) if (_UsrID != value)
{ {
@ -279,24 +279,24 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules;
if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -432,9 +432,9 @@ namespace VEPROMS.CSLA.Library
_ParentID = _ConnectionFolderExtension.DefaultParentID; _ParentID = _ConnectionFolderExtension.DefaultParentID;
_DTS = _ConnectionFolderExtension.DefaultDTS; _DTS = _ConnectionFolderExtension.DefaultDTS;
_UsrID = _ConnectionFolderExtension.DefaultUsrID; _UsrID = _ConnectionFolderExtension.DefaultUsrID;
_MyParent = myParent; _MyParent = myParent;
_Name = name; _Name = name;
_ShortName = shortName; _ShortName = shortName;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal ConnectionFolder(SafeDataReader dr) internal ConnectionFolder(SafeDataReader dr)
@ -446,7 +446,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ConnectionFolder.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionFolder.FetchDR", GetHashCode());
try try
{ {
_FolderID = dr.GetInt32("FolderID"); _FolderID = dr.GetInt32("FolderID");
@ -462,7 +462,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ConnectionFolder.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionFolder.FetchDR", ex);
throw new DbCslaException("ConnectionFolder.Fetch", ex); throw new DbCslaException("ConnectionFolder.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public ConnectionFolder Add(Folder myParent, string name, string shortName) // One to Many public ConnectionFolder Add(Folder myParent, string name, string shortName) // One to Many
{ {
ConnectionFolder folder = ConnectionFolder.New(myParent, name, shortName); ConnectionFolder folder = ConnectionFolder.New(myParent, name, shortName);
this.Add(folder); this.Add(folder);
return folder; return folder;
} }
public void Remove(Folder myFolder) public void Remove(Folder myFolder)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(ConnectionFolder connectionFolder in this) foreach (ConnectionFolder connectionFolder in this)
if ((hasBrokenRules = connectionFolder.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = connectionFolder.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(DBIDCriteria criteria) private void DataPortal_Fetch(DBIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ConnectionFolders.DataPortal_FetchDBID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionFolders.DataPortal_FetchDBID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ConnectionFolders.DataPortal_FetchDBID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionFolders.DataPortal_FetchDBID", ex);
throw new DbCslaException("ConnectionFolders.DataPortal_Fetch", ex); throw new DbCslaException("ConnectionFolders.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class ConnectionFoldersPropertyDescriptor : vlnListPropertyDescriptor public partial class ConnectionFoldersPropertyDescriptor : vlnListPropertyDescriptor
{ {
private ConnectionFolder Item { get { return (ConnectionFolder) _Item;} } private ConnectionFolder Item { get { return (ConnectionFolder)_Item; } }
public ConnectionFoldersPropertyDescriptor(ConnectionFolders collection, int index):base(collection, index){;} public ConnectionFoldersPropertyDescriptor(ConnectionFolders collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is ConnectionFolders) if (destType == typeof(string) && value is ConnectionFolders)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((ConnectionFolders) value).Items.Count.ToString() + " Folders"; return ((ConnectionFolders)value).Items.Count.ToString() + " Folders";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<ConnectionInfo> _AllList = new List<ConnectionInfo>(); protected static List<ConnectionInfo> _AllList = new List<ConnectionInfo>();
private static Dictionary<string, ConnectionInfo> _AllByPrimaryKey = new Dictionary<string, ConnectionInfo>(); private static Dictionary<string, List<ConnectionInfo>> _AllByPrimaryKey = new Dictionary<string, List<ConnectionInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<ConnectionInfo> remove = new List<ConnectionInfo>(); List<ConnectionInfo> remove = new List<ConnectionInfo>();
foreach (ConnectionInfo tmp in _AllList) foreach (ConnectionInfo tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.DBID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.DBID.ToString()))
{
_AllByPrimaryKey[tmp.DBID.ToString()] = new List<ConnectionInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.DBID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (ConnectionInfo tmp in remove) foreach (ConnectionInfo tmp in remove)
@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = dbid.ToString(); string key = dbid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DBID",true); CanReadProperty("DBID", true);
return _DBID; return _DBID;
} }
} }
@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name",true); CanReadProperty("Name", true);
return _Name; return _Name;
} }
} }
@ -105,7 +109,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Title",true); CanReadProperty("Title", true);
return _Title; return _Title;
} }
} }
@ -115,7 +119,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ConnectionString",true); CanReadProperty("ConnectionString", true);
return _ConnectionString; return _ConnectionString;
} }
} }
@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ServerType",true); CanReadProperty("ServerType", true);
return _ServerType; return _ServerType;
} }
} }
@ -138,7 +142,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
} }
@ -148,7 +152,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -158,7 +162,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
} }
@ -171,7 +175,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ConnectionFolderCount",true); CanReadProperty("ConnectionFolderCount", true);
return _ConnectionFolderCount; return _ConnectionFolderCount;
} }
} }
@ -182,7 +186,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ConnectionFolders",true); CanReadProperty("ConnectionFolders", true);
if (_ConnectionFolderCount < 0 || (_ConnectionFolderCount > 0 && _ConnectionFolders == null)) if (_ConnectionFolderCount < 0 || (_ConnectionFolderCount > 0 && _ConnectionFolders == null))
_ConnectionFolders = FolderInfoList.GetByDBID(_DBID); _ConnectionFolders = FolderInfoList.GetByDBID(_DBID);
if (_ConnectionFolderCount < 0) if (_ConnectionFolderCount < 0)
@ -192,7 +196,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshConnectionFolders() internal void RefreshConnectionFolders()
{ {
_ConnectionFolderCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_DBID.ToString()))
foreach (ConnectionInfo tmp in _AllByPrimaryKey[_DBID.ToString()])
tmp._ConnectionFolderCount = -1; // This will cause the data to be requeried
} }
// TODO: Replace base ConnectionInfo.ToString function as necessary // TODO: Replace base ConnectionInfo.ToString function as necessary
/// <summary> /// <summary>
@ -214,14 +221,25 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _ConnectionInfoUnique = 0;
private int _MyConnectionInfoUnique;
public int MyConnectionInfoUnique
{
get { return _MyConnectionInfoUnique; }
}
private ConnectionInfo() private ConnectionInfo()
{/* require use of factory methods */ {/* require use of factory methods */
_MyConnectionInfoUnique = ++_ConnectionInfoUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(DBID.ToString()); if (!_AllByPrimaryKey.ContainsKey(DBID.ToString())) return;
List<ConnectionInfo> listConnectionInfo = _AllByPrimaryKey[DBID.ToString()]; // Get the list of items
listConnectionInfo.Remove(this); // Remove the item from the list
if (listConnectionInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(DBID.ToString()); // remove the list
} }
public virtual Connection Get() public virtual Connection Get()
{ {
@ -229,9 +247,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(Connection tmp) public static void Refresh(Connection tmp)
{ {
ConnectionInfo tmpInfo = GetExistingByPrimaryKey(tmp.DBID); string key = tmp.DBID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (ConnectionInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(Connection tmp) private void RefreshFields(Connection tmp)
{ {
@ -255,7 +275,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<ConnectionInfo>(new PKCriteria(dbid)); tmp = DataPortal.Fetch<ConnectionInfo>(new PKCriteria(dbid));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -269,14 +289,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
internal ConnectionInfo(SafeDataReader dr) internal ConnectionInfo(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ConnectionInfo.Constructor", GetHashCode()); _MyConnectionInfoUnique = ++_ConnectionInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.Constructor", GetHashCode());
try try
{ {
ReadData(dr); ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ConnectionInfo.Constructor", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.Constructor", ex);
throw new DbCslaException("ConnectionInfo.Constructor", ex); throw new DbCslaException("ConnectionInfo.Constructor", ex);
} }
} }
@ -293,7 +314,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ConnectionInfo.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.ReadData", GetHashCode());
try try
{ {
_DBID = dr.GetInt32("DBID"); _DBID = dr.GetInt32("DBID");
@ -308,14 +329,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ConnectionInfo.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("ConnectionInfo.ReadData", ex); throw new DbCslaException("ConnectionInfo.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ConnectionInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -343,7 +364,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ConnectionInfo.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("ConnectionInfo.DataPortal_Fetch", ex); throw new DbCslaException("ConnectionInfo.DataPortal_Fetch", ex);
} }
@ -353,7 +374,7 @@ namespace VEPROMS.CSLA.Library
#region extension #region extension
ConnectionInfoExtension _ConnectionInfoExtension = new ConnectionInfoExtension(); ConnectionInfoExtension _ConnectionInfoExtension = new ConnectionInfoExtension();
[Serializable()] [Serializable()]
partial class ConnectionInfoExtension : extensionBase {} partial class ConnectionInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {

View File

@ -96,7 +96,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ConnectionInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -116,7 +116,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ConnectionInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ConnectionInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ConnectionInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -177,8 +177,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class ConnectionInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class ConnectionInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private ConnectionInfo Item { get { return (ConnectionInfo) _Item;} } private ConnectionInfo Item { get { return (ConnectionInfo)_Item; } }
public ConnectionInfoListPropertyDescriptor(ConnectionInfoList collection, int index):base(collection, index){;} public ConnectionInfoListPropertyDescriptor(ConnectionInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -189,7 +189,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is ConnectionInfoList) if (destType == typeof(string) && value is ConnectionInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((ConnectionInfoList) value).Items.Count.ToString() + " Connections"; return ((ConnectionInfoList)value).Items.Count.ToString() + " Connections";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -45,35 +45,35 @@ namespace VEPROMS.CSLA.Library
{ {
foreach (ContentDetail tmp in _ContentDetails) foreach (ContentDetail tmp in _ContentDetails)
{ {
if(tmp.IsDirty)refreshContentDetails.Add(tmp); if (tmp.IsDirty) refreshContentDetails.Add(tmp);
} }
} }
if (_ContentItems != null && _ContentItems.IsDirty) if (_ContentItems != null && _ContentItems.IsDirty)
{ {
foreach (ContentItem tmp in _ContentItems) foreach (ContentItem tmp in _ContentItems)
{ {
if(tmp.IsDirty)refreshContentItems.Add(tmp); if (tmp.IsDirty) refreshContentItems.Add(tmp);
} }
} }
if (_ContentParts != null && _ContentParts.IsDirty) if (_ContentParts != null && _ContentParts.IsDirty)
{ {
foreach (ContentPart tmp in _ContentParts) foreach (ContentPart tmp in _ContentParts)
{ {
if(tmp.IsDirty)refreshContentParts.Add(tmp); if (tmp.IsDirty) refreshContentParts.Add(tmp);
} }
} }
if (_ContentRoUsages != null && _ContentRoUsages.IsDirty) if (_ContentRoUsages != null && _ContentRoUsages.IsDirty)
{ {
foreach (ContentRoUsage tmp in _ContentRoUsages) foreach (ContentRoUsage tmp in _ContentRoUsages)
{ {
if(tmp.IsDirty)refreshContentRoUsages.Add(tmp); if (tmp.IsDirty) refreshContentRoUsages.Add(tmp);
} }
} }
if (_ContentTransitions != null && _ContentTransitions.IsDirty) if (_ContentTransitions != null && _ContentTransitions.IsDirty)
{ {
foreach (ContentTransition tmp in _ContentTransitions) foreach (ContentTransition tmp in _ContentTransitions)
{ {
if(tmp.IsDirty)refreshContentTransitions.Add(tmp); if (tmp.IsDirty) refreshContentTransitions.Add(tmp);
} }
} }
} }
@ -92,7 +92,7 @@ namespace VEPROMS.CSLA.Library
foreach (Content tmp in _RefreshContents) foreach (Content tmp in _RefreshContents)
{ {
ContentInfo.Refresh(tmp); ContentInfo.Refresh(tmp);
if(tmp._MyFormat != null) FormatInfo.Refresh(tmp._MyFormat); if (tmp._MyFormat != null) FormatInfo.Refresh(tmp._MyFormat);
} }
foreach (ContentDetail tmp in _RefreshContentDetails) foreach (ContentDetail tmp in _RefreshContentDetails)
{ {
@ -118,13 +118,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<Content> _AllList = new List<Content>(); protected static List<Content> _AllList = new List<Content>();
private static Dictionary<string, Content> _AllByPrimaryKey = new Dictionary<string, Content>(); private static Dictionary<string, List<Content>> _AllByPrimaryKey = new Dictionary<string, List<Content>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<Content> remove = new List<Content>(); List<Content> remove = new List<Content>();
foreach (Content tmp in _AllList) foreach (Content tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.ContentID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
{
_AllByPrimaryKey[tmp.ContentID.ToString()] = new List<Content>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (Content tmp in remove) foreach (Content tmp in remove)
@ -134,7 +138,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = contentID.ToString(); string key = contentID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -156,7 +160,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentID",true); CanReadProperty("ContentID", true);
return _ContentID; return _ContentID;
} }
} }
@ -166,13 +170,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Number",true); CanReadProperty("Number", true);
return _Number; return _Number;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Number",true); CanWriteProperty("Number", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Number != value) if (_Number != value)
{ {
@ -187,13 +191,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Text",true); CanReadProperty("Text", true);
return _Text; return _Text;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Text",true); CanWriteProperty("Text", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Text != value) if (_Text != value)
{ {
@ -211,13 +215,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Type",true); CanReadProperty("Type", true);
return _Type; return _Type;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Type",true); CanWriteProperty("Type", true);
if (_Type != value) if (_Type != value)
{ {
_Type = value; _Type = value;
@ -231,7 +235,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatID",true); CanReadProperty("FormatID", true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID; if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID; return _FormatID;
} }
@ -242,18 +246,18 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFormat",true); CanReadProperty("MyFormat", true);
if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID); if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID);
return _MyFormat; return _MyFormat;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyFormat",true); CanWriteProperty("MyFormat", true);
if (_MyFormat != value) if (_MyFormat != value)
{ {
_MyFormat = value; _MyFormat = value;
_FormatID = (value == null ? null : (int?) value.FormatID); _FormatID = (value == null ? null : (int?)value.FormatID);
PropertyHasChanged(); PropertyHasChanged();
} }
} }
@ -264,13 +268,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -285,13 +289,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -305,13 +309,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -330,7 +334,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentDetailCount",true); CanReadProperty("ContentDetailCount", true);
return _ContentDetailCount; return _ContentDetailCount;
} }
} }
@ -344,10 +348,10 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentDetails",true); CanReadProperty("ContentDetails", true);
if(_ContentDetailCount > 0 && _ContentDetails == null) if (_ContentDetailCount > 0 && _ContentDetails == null)
_ContentDetails = ContentDetails.GetByContentID(ContentID); _ContentDetails = ContentDetails.GetByContentID(ContentID);
else if(_ContentDetails == null) else if (_ContentDetails == null)
_ContentDetails = ContentDetails.New(); _ContentDetails = ContentDetails.New();
return _ContentDetails; return _ContentDetails;
} }
@ -361,7 +365,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentEntryCount",true); CanReadProperty("ContentEntryCount", true);
return _ContentEntryCount; return _ContentEntryCount;
} }
} }
@ -375,8 +379,8 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyEntry",true); CanReadProperty("MyEntry", true);
if ( _MyEntry == null) _MyEntry = Entry.New(this); if (_MyEntry == null) _MyEntry = Entry.New(this);
return _MyEntry; return _MyEntry;
} }
} }
@ -389,7 +393,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentItemCount",true); CanReadProperty("ContentItemCount", true);
return _ContentItemCount; return _ContentItemCount;
} }
} }
@ -403,10 +407,10 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentItems",true); CanReadProperty("ContentItems", true);
if(_ContentItemCount > 0 && _ContentItems == null) if (_ContentItemCount > 0 && _ContentItems == null)
_ContentItems = ContentItems.GetByContentID(ContentID); _ContentItems = ContentItems.GetByContentID(ContentID);
else if(_ContentItems == null) else if (_ContentItems == null)
_ContentItems = ContentItems.New(); _ContentItems = ContentItems.New();
return _ContentItems; return _ContentItems;
} }
@ -420,7 +424,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentPartCount",true); CanReadProperty("ContentPartCount", true);
return _ContentPartCount; return _ContentPartCount;
} }
} }
@ -434,10 +438,10 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentParts",true); CanReadProperty("ContentParts", true);
if(_ContentPartCount > 0 && _ContentParts == null) if (_ContentPartCount > 0 && _ContentParts == null)
_ContentParts = ContentParts.GetByContentID(ContentID); _ContentParts = ContentParts.GetByContentID(ContentID);
else if(_ContentParts == null) else if (_ContentParts == null)
_ContentParts = ContentParts.New(); _ContentParts = ContentParts.New();
return _ContentParts; return _ContentParts;
} }
@ -451,7 +455,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentRoUsageCount",true); CanReadProperty("ContentRoUsageCount", true);
return _ContentRoUsageCount; return _ContentRoUsageCount;
} }
} }
@ -465,10 +469,10 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentRoUsages",true); CanReadProperty("ContentRoUsages", true);
if(_ContentRoUsageCount > 0 && _ContentRoUsages == null) if (_ContentRoUsageCount > 0 && _ContentRoUsages == null)
_ContentRoUsages = ContentRoUsages.GetByContentID(ContentID); _ContentRoUsages = ContentRoUsages.GetByContentID(ContentID);
else if(_ContentRoUsages == null) else if (_ContentRoUsages == null)
_ContentRoUsages = ContentRoUsages.New(); _ContentRoUsages = ContentRoUsages.New();
return _ContentRoUsages; return _ContentRoUsages;
} }
@ -482,7 +486,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentTransitionCount",true); CanReadProperty("ContentTransitionCount", true);
return _ContentTransitionCount; return _ContentTransitionCount;
} }
} }
@ -496,10 +500,10 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentTransitions",true); CanReadProperty("ContentTransitions", true);
if(_ContentTransitionCount > 0 && _ContentTransitions == null) if (_ContentTransitionCount > 0 && _ContentTransitions == null)
_ContentTransitions = ContentTransitions.GetByFromID(ContentID); _ContentTransitions = ContentTransitions.GetByFromID(ContentID);
else if(_ContentTransitions == null) else if (_ContentTransitions == null)
_ContentTransitions = ContentTransitions.New(); _ContentTransitions = ContentTransitions.New();
return _ContentTransitions; return _ContentTransitions;
} }
@ -513,7 +517,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentZContentCount",true); CanReadProperty("ContentZContentCount", true);
return _ContentZContentCount; return _ContentZContentCount;
} }
} }
@ -527,18 +531,18 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyZContent",true); CanReadProperty("MyZContent", true);
if ( _MyZContent == null) _MyZContent = ZContent.New(this); if (_MyZContent == null) _MyZContent = ZContent.New(this);
return _MyZContent; return _MyZContent;
} }
} }
public override bool IsDirty public override bool IsDirty
{ {
get { return base.IsDirty || (_ContentDetails == null? false : _ContentDetails.IsDirty) || (_MyEntry == null? false : _MyEntry.IsDirty) || (_ContentItems == null? false : _ContentItems.IsDirty) || (_ContentParts == null? false : _ContentParts.IsDirty) || (_ContentRoUsages == null? false : _ContentRoUsages.IsDirty) || (_ContentTransitions == null? false : _ContentTransitions.IsDirty) || (_MyZContent == null? false : _MyZContent.IsDirty) || (_MyFormat == null? false : _MyFormat.IsDirty); } get { return base.IsDirty || (_ContentDetails == null ? false : _ContentDetails.IsDirty) || (_MyEntry == null ? false : _MyEntry.IsDirty) || (_ContentItems == null ? false : _ContentItems.IsDirty) || (_ContentParts == null ? false : _ContentParts.IsDirty) || (_ContentRoUsages == null ? false : _ContentRoUsages.IsDirty) || (_ContentTransitions == null ? false : _ContentTransitions.IsDirty) || (_MyZContent == null ? false : _MyZContent.IsDirty) || (_MyFormat == null ? false : _MyFormat.IsDirty); }
} }
public override bool IsValid public override bool IsValid
{ {
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_ContentDetails == null? true : _ContentDetails.IsValid) && (_MyEntry == null? true : _MyEntry.IsValid) && (_ContentItems == null? true : _ContentItems.IsValid) && (_ContentParts == null? true : _ContentParts.IsValid) && (_ContentRoUsages == null? true : _ContentRoUsages.IsValid) && (_ContentTransitions == null? true : _ContentTransitions.IsValid) && (_MyZContent == null? true : _MyZContent.IsValid) && (_MyFormat == null? true : _MyFormat.IsValid); } get { return (IsNew && !IsDirty ? true : base.IsValid) && (_ContentDetails == null ? true : _ContentDetails.IsValid) && (_MyEntry == null ? true : _MyEntry.IsValid) && (_ContentItems == null ? true : _ContentItems.IsValid) && (_ContentParts == null ? true : _ContentParts.IsValid) && (_ContentRoUsages == null ? true : _ContentRoUsages.IsValid) && (_ContentTransitions == null ? true : _ContentTransitions.IsValid) && (_MyZContent == null ? true : _MyZContent.IsValid) && (_MyFormat == null ? true : _MyFormat.IsValid); }
} }
// TODO: Replace base Content.ToString function as necessary // TODO: Replace base Content.ToString function as necessary
/// <summary> /// <summary>
@ -561,29 +565,30 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get { get
if(_CheckingBrokenRules)return null; {
if (_CheckingBrokenRules) return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_ContentItems != null && (hasBrokenRules = _ContentItems.HasBrokenRules) != null) return hasBrokenRules; if (_ContentItems != null && (hasBrokenRules = _ContentItems.HasBrokenRules) != null) return hasBrokenRules;
if (_ContentDetails != null && (hasBrokenRules = _ContentDetails.HasBrokenRules) != null) return hasBrokenRules; if (_ContentDetails != null && (hasBrokenRules = _ContentDetails.HasBrokenRules) != null) return hasBrokenRules;
if (_MyEntry != null && (hasBrokenRules = _MyEntry.HasBrokenRules) != null) return hasBrokenRules; if (_MyEntry != null && (hasBrokenRules = _MyEntry.HasBrokenRules) != null) return hasBrokenRules;
if (_ContentParts != null && (hasBrokenRules = _ContentParts.HasBrokenRules) != null) return hasBrokenRules; if (_ContentParts != null && (hasBrokenRules = _ContentParts.HasBrokenRules) != null) return hasBrokenRules;
if (_ContentRoUsages != null && (hasBrokenRules = _ContentRoUsages.HasBrokenRules) != null) return hasBrokenRules; if (_ContentRoUsages != null && (hasBrokenRules = _ContentRoUsages.HasBrokenRules) != null) return hasBrokenRules;
if (_ContentTransitions != null && (hasBrokenRules = _ContentTransitions.HasBrokenRules) != null) return hasBrokenRules; if (_ContentTransitions != null && (hasBrokenRules = _ContentTransitions.HasBrokenRules) != null) return hasBrokenRules;
if (_MyZContent != null && (hasBrokenRules = _MyZContent.HasBrokenRules) != null) return hasBrokenRules; if (_MyZContent != null && (hasBrokenRules = _MyZContent.HasBrokenRules) != null) return hasBrokenRules;
if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -708,14 +713,25 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods #region Factory Methods
public int CurrentEditLevel public int CurrentEditLevel
{ get { return EditLevel; } } { get { return EditLevel; } }
private static int _ContentUnique = 0;
private int _MyContentUnique;
public int MyContentUnique
{
get { return _MyContentUnique; }
}
protected Content() protected Content()
{/* require use of factory methods */ {/* require use of factory methods */
_MyContentUnique = ++_ContentUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(ContentID.ToString()); if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString())) return;
List<Content> listContent = _AllByPrimaryKey[ContentID.ToString()]; // Get the list of items
listContent.Remove(this); // Remove the item from the list
if (listContent.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(ContentID.ToString()); // remove the list
} }
public static Content New() public static Content New()
{ {
@ -794,7 +810,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<Content>(new PKCriteria(contentID)); tmp = DataPortal.Fetch<Content>(new PKCriteria(contentID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -873,7 +889,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Content.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.ReadData", GetHashCode());
try try
{ {
_ContentID = dr.GetInt32("ContentID"); _ContentID = dr.GetInt32("ContentID");
@ -896,14 +912,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Content.ReadData", ex); throw new DbCslaException("Content.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Content.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -952,7 +968,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Content.DataPortal_Fetch", ex); throw new DbCslaException("Content.DataPortal_Fetch", ex);
} }
@ -973,13 +989,13 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.DataPortal_Insert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.DataPortal_Insert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Content.DataPortal_Insert", ex); throw new DbCslaException("Content.DataPortal_Insert", ex);
} }
finally finally
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Content.DataPortal_Insert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.DataPortal_Insert", GetHashCode());
} }
} }
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
@ -988,7 +1004,7 @@ namespace VEPROMS.CSLA.Library
if (!this.IsDirty) return; if (!this.IsDirty) return;
try try
{ {
if(_MyFormat != null) _MyFormat.Update(); if (_MyFormat != null) _MyFormat.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
{ {
@ -1024,11 +1040,11 @@ namespace VEPROMS.CSLA.Library
if (_ContentRoUsages != null) _ContentRoUsages.Update(this); if (_ContentRoUsages != null) _ContentRoUsages.Update(this);
if (_ContentTransitions != null) _ContentTransitions.Update(this); if (_ContentTransitions != null) _ContentTransitions.Update(this);
if (_MyZContent != null) _MyZContent.Update(this); if (_MyZContent != null) _MyZContent.Update(this);
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Content.SQLInsert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.SQLInsert", GetHashCode());
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.SQLInsert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.SQLInsert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Content.SQLInsert", ex); throw new DbCslaException("Content.SQLInsert", ex);
} }
@ -1036,7 +1052,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int contentID, string number, string text, int? type, Format myFormat, string config, DateTime dts, string userID) public static byte[] Add(SqlConnection cn, ref int contentID, string number, string text, int? type, Format myFormat, string config, DateTime dts, string userID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Content.Add", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.Add", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -1047,7 +1063,7 @@ namespace VEPROMS.CSLA.Library
cm.Parameters.AddWithValue("@Number", number); cm.Parameters.AddWithValue("@Number", number);
cm.Parameters.AddWithValue("@Text", text); cm.Parameters.AddWithValue("@Text", text);
cm.Parameters.AddWithValue("@Type", type); cm.Parameters.AddWithValue("@Type", type);
if(myFormat != null)cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID); if (myFormat != null) cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID);
cm.Parameters.AddWithValue("@Config", config); cm.Parameters.AddWithValue("@Config", config);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts); if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID); cm.Parameters.AddWithValue("@UserID", userID);
@ -1067,7 +1083,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.Add", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.Add", ex);
throw new DbCslaException("Content.Add", ex); throw new DbCslaException("Content.Add", ex);
} }
} }
@ -1075,7 +1091,7 @@ namespace VEPROMS.CSLA.Library
protected override void DataPortal_Update() protected override void DataPortal_Update()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Content.DataPortal_Update", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.DataPortal_Update", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1089,7 +1105,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.DataPortal_Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.DataPortal_Update", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -1098,10 +1114,10 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate() internal void SQLUpdate()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Content.SQLUpdate", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.SQLUpdate", GetHashCode());
try try
{ {
if(_MyFormat != null) _MyFormat.Update(); if (_MyFormat != null) _MyFormat.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty) if (base.IsDirty)
{ {
@ -1141,7 +1157,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.SQLUpdate", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.SQLUpdate", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -1169,7 +1185,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int contentID, string number, string text, int? type, Format myFormat, string config, DateTime dts, string userID, ref byte[] lastChanged) public static byte[] Update(SqlConnection cn, ref int contentID, string number, string text, int? type, Format myFormat, string config, DateTime dts, string userID, ref byte[] lastChanged)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Content.Update", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.Update", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -1181,7 +1197,7 @@ namespace VEPROMS.CSLA.Library
cm.Parameters.AddWithValue("@Number", number); cm.Parameters.AddWithValue("@Number", number);
cm.Parameters.AddWithValue("@Text", text); cm.Parameters.AddWithValue("@Text", text);
cm.Parameters.AddWithValue("@Type", type); cm.Parameters.AddWithValue("@Type", type);
if(myFormat != null)cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID); if (myFormat != null) cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID);
cm.Parameters.AddWithValue("@Config", config); cm.Parameters.AddWithValue("@Config", config);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts); if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID); cm.Parameters.AddWithValue("@UserID", userID);
@ -1198,7 +1214,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.Update", ex);
throw new DbCslaException("Content.Update", ex); throw new DbCslaException("Content.Update", ex);
} }
} }
@ -1210,7 +1226,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria) private void DataPortal_Delete(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Content.DataPortal_Delete", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.DataPortal_Delete", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1226,7 +1242,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.DataPortal_Delete", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.DataPortal_Delete", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Content.DataPortal_Delete", ex); throw new DbCslaException("Content.DataPortal_Delete", ex);
} }
@ -1234,7 +1250,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int contentID) public static void Remove(SqlConnection cn, int contentID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Content.Remove", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.Remove", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -1249,7 +1265,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.Remove", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.Remove", ex);
throw new DbCslaException("Content.Remove", ex); throw new DbCslaException("Content.Remove", ex);
} }
} }
@ -1283,7 +1299,7 @@ namespace VEPROMS.CSLA.Library
} }
protected override void DataPortal_Execute() protected override void DataPortal_Execute()
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Content.DataPortal_Execute", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.DataPortal_Execute", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1301,7 +1317,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.DataPortal_Execute", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.DataPortal_Execute", ex);
throw new DbCslaException("Content.DataPortal_Execute", ex); throw new DbCslaException("Content.DataPortal_Execute", ex);
} }
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DetailID",true); CanReadProperty("DetailID", true);
if (_MyDetail != null) _DetailID = _MyDetail.DetailID; if (_MyDetail != null) _DetailID = _MyDetail.DetailID;
return _DetailID; return _DetailID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyDetail",true); CanReadProperty("MyDetail", true);
if (_MyDetail == null && _DetailID != 0) _MyDetail = Detail.Get(_DetailID); if (_MyDetail == null && _DetailID != 0) _MyDetail = Detail.Get(_DetailID);
return _MyDetail; return _MyDetail;
} }
@ -65,13 +65,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemType",true); CanReadProperty("ItemType", true);
return _ItemType; return _ItemType;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("ItemType",true); CanWriteProperty("ItemType", true);
if (_ItemType != value) if (_ItemType != value)
{ {
_ItemType = value; _ItemType = value;
@ -85,13 +85,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Text",true); CanReadProperty("Text", true);
return _Text; return _Text;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Text",true); CanWriteProperty("Text", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Text != value) if (_Text != value)
{ {
@ -106,13 +106,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -127,13 +127,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -147,13 +147,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -184,22 +184,22 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -309,8 +309,8 @@ namespace VEPROMS.CSLA.Library
// TODO: Add any initialization & defaults // TODO: Add any initialization & defaults
_DTS = _ContentDetailExtension.DefaultDTS; _DTS = _ContentDetailExtension.DefaultDTS;
_UserID = _ContentDetailExtension.DefaultUserID; _UserID = _ContentDetailExtension.DefaultUserID;
_ItemType = itemType; _ItemType = itemType;
_Text = text; _Text = text;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal ContentDetail(SafeDataReader dr) internal ContentDetail(SafeDataReader dr)
@ -322,7 +322,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentDetail.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentDetail.FetchDR", GetHashCode());
try try
{ {
_DetailID = dr.GetInt32("DetailID"); _DetailID = dr.GetInt32("DetailID");
@ -335,7 +335,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentDetail.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentDetail.FetchDR", ex);
throw new DbCslaException("ContentDetail.Fetch", ex); throw new DbCslaException("ContentDetail.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public ContentDetail Add(int itemType, string text) // One to Many public ContentDetail Add(int itemType, string text) // One to Many
{ {
ContentDetail detail = ContentDetail.New(itemType, text); ContentDetail detail = ContentDetail.New(itemType, text);
this.Add(detail); this.Add(detail);
return detail; return detail;
} }
public void Remove(Detail myDetail) public void Remove(Detail myDetail)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(ContentDetail contentDetail in this) foreach (ContentDetail contentDetail in this)
if ((hasBrokenRules = contentDetail.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = contentDetail.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ContentIDCriteria criteria) private void DataPortal_Fetch(ContentIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentDetails.DataPortal_FetchContentID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentDetails.DataPortal_FetchContentID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentDetails.DataPortal_FetchContentID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentDetails.DataPortal_FetchContentID", ex);
throw new DbCslaException("ContentDetails.DataPortal_Fetch", ex); throw new DbCslaException("ContentDetails.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class ContentDetailsPropertyDescriptor : vlnListPropertyDescriptor public partial class ContentDetailsPropertyDescriptor : vlnListPropertyDescriptor
{ {
private ContentDetail Item { get { return (ContentDetail) _Item;} } private ContentDetail Item { get { return (ContentDetail)_Item; } }
public ContentDetailsPropertyDescriptor(ContentDetails collection, int index):base(collection, index){;} public ContentDetailsPropertyDescriptor(ContentDetails collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is ContentDetails) if (destType == typeof(string) && value is ContentDetails)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((ContentDetails) value).Items.Count.ToString() + " Details"; return ((ContentDetails)value).Items.Count.ToString() + " Details";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<ContentInfo> _AllList = new List<ContentInfo>(); protected static List<ContentInfo> _AllList = new List<ContentInfo>();
private static Dictionary<string, ContentInfo> _AllByPrimaryKey = new Dictionary<string, ContentInfo>(); private static Dictionary<string, List<ContentInfo>> _AllByPrimaryKey = new Dictionary<string, List<ContentInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<ContentInfo> remove = new List<ContentInfo>(); List<ContentInfo> remove = new List<ContentInfo>();
foreach (ContentInfo tmp in _AllList) foreach (ContentInfo tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.ContentID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
{
_AllByPrimaryKey[tmp.ContentID.ToString()] = new List<ContentInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (ContentInfo tmp in remove) foreach (ContentInfo tmp in remove)
@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = contentID.ToString(); string key = contentID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentID",true); CanReadProperty("ContentID", true);
return _ContentID; return _ContentID;
} }
} }
@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Number",true); CanReadProperty("Number", true);
return _Number; return _Number;
} }
} }
@ -105,7 +109,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Text",true); CanReadProperty("Text", true);
return _Text; return _Text;
} }
} }
@ -118,7 +122,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Type",true); CanReadProperty("Type", true);
return _Type; return _Type;
} }
} }
@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatID",true); CanReadProperty("FormatID", true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID; if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID; return _FormatID;
} }
@ -139,7 +143,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFormat",true); CanReadProperty("MyFormat", true);
if (_MyFormat == null && _FormatID != null) _MyFormat = FormatInfo.Get((int)_FormatID); if (_MyFormat == null && _FormatID != null) _MyFormat = FormatInfo.Get((int)_FormatID);
return _MyFormat; return _MyFormat;
} }
@ -150,7 +154,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
} }
@ -160,7 +164,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -170,7 +174,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
} }
@ -183,7 +187,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentDetailCount",true); CanReadProperty("ContentDetailCount", true);
return _ContentDetailCount; return _ContentDetailCount;
} }
} }
@ -194,7 +198,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentDetails",true); CanReadProperty("ContentDetails", true);
if (_ContentDetailCount < 0 || (_ContentDetailCount > 0 && _ContentDetails == null)) if (_ContentDetailCount < 0 || (_ContentDetailCount > 0 && _ContentDetails == null))
_ContentDetails = DetailInfoList.GetByContentID(_ContentID); _ContentDetails = DetailInfoList.GetByContentID(_ContentID);
if (_ContentDetailCount < 0) if (_ContentDetailCount < 0)
@ -204,7 +208,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshContentDetails() internal void RefreshContentDetails()
{ {
_ContentDetailCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_ContentID.ToString()))
foreach (ContentInfo tmp in _AllByPrimaryKey[_ContentID.ToString()])
tmp._ContentDetailCount = -1; // This will cause the data to be requeried
} }
private int _ContentEntryCount = 0; private int _ContentEntryCount = 0;
/// <summary> /// <summary>
@ -215,7 +222,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentEntryCount",true); CanReadProperty("ContentEntryCount", true);
return _ContentEntryCount; return _ContentEntryCount;
} }
} }
@ -226,7 +233,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyEntry",true); CanReadProperty("MyEntry", true);
if (_ContentEntryCount > 0 && _MyEntry == null) if (_ContentEntryCount > 0 && _MyEntry == null)
_MyEntry = EntryInfo.Get(_ContentID); _MyEntry = EntryInfo.Get(_ContentID);
return _MyEntry; return _MyEntry;
@ -241,7 +248,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentItemCount",true); CanReadProperty("ContentItemCount", true);
return _ContentItemCount; return _ContentItemCount;
} }
} }
@ -252,7 +259,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentItems",true); CanReadProperty("ContentItems", true);
if (_ContentItemCount < 0 || (_ContentItemCount > 0 && _ContentItems == null)) if (_ContentItemCount < 0 || (_ContentItemCount > 0 && _ContentItems == null))
_ContentItems = ItemInfoList.GetByContentID(_ContentID); _ContentItems = ItemInfoList.GetByContentID(_ContentID);
if (_ContentItemCount < 0) if (_ContentItemCount < 0)
@ -262,7 +269,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshContentItems() internal void RefreshContentItems()
{ {
_ContentItemCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_ContentID.ToString()))
foreach (ContentInfo tmp in _AllByPrimaryKey[_ContentID.ToString()])
tmp._ContentItemCount = -1; // This will cause the data to be requeried
} }
private int _ContentPartCount = 0; private int _ContentPartCount = 0;
/// <summary> /// <summary>
@ -273,7 +283,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentPartCount",true); CanReadProperty("ContentPartCount", true);
return _ContentPartCount; return _ContentPartCount;
} }
} }
@ -284,7 +294,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentParts",true); CanReadProperty("ContentParts", true);
if (_ContentPartCount < 0 || (_ContentPartCount > 0 && _ContentParts == null)) if (_ContentPartCount < 0 || (_ContentPartCount > 0 && _ContentParts == null))
_ContentParts = PartInfoList.GetByContentID(_ContentID); _ContentParts = PartInfoList.GetByContentID(_ContentID);
if (_ContentPartCount < 0) if (_ContentPartCount < 0)
@ -294,7 +304,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshContentParts() internal void RefreshContentParts()
{ {
_ContentPartCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_ContentID.ToString()))
foreach (ContentInfo tmp in _AllByPrimaryKey[_ContentID.ToString()])
tmp._ContentPartCount = -1; // This will cause the data to be requeried
} }
private int _ContentRoUsageCount = 0; private int _ContentRoUsageCount = 0;
/// <summary> /// <summary>
@ -305,7 +318,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentRoUsageCount",true); CanReadProperty("ContentRoUsageCount", true);
return _ContentRoUsageCount; return _ContentRoUsageCount;
} }
} }
@ -316,7 +329,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentRoUsages",true); CanReadProperty("ContentRoUsages", true);
if (_ContentRoUsageCount < 0 || (_ContentRoUsageCount > 0 && _ContentRoUsages == null)) if (_ContentRoUsageCount < 0 || (_ContentRoUsageCount > 0 && _ContentRoUsages == null))
_ContentRoUsages = RoUsageInfoList.GetByContentID(_ContentID); _ContentRoUsages = RoUsageInfoList.GetByContentID(_ContentID);
if (_ContentRoUsageCount < 0) if (_ContentRoUsageCount < 0)
@ -326,7 +339,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshContentRoUsages() internal void RefreshContentRoUsages()
{ {
_ContentRoUsageCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_ContentID.ToString()))
foreach (ContentInfo tmp in _AllByPrimaryKey[_ContentID.ToString()])
tmp._ContentRoUsageCount = -1; // This will cause the data to be requeried
} }
private int _ContentTransitionCount = 0; private int _ContentTransitionCount = 0;
/// <summary> /// <summary>
@ -337,7 +353,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentTransitionCount",true); CanReadProperty("ContentTransitionCount", true);
return _ContentTransitionCount; return _ContentTransitionCount;
} }
} }
@ -348,7 +364,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentTransitions",true); CanReadProperty("ContentTransitions", true);
if (_ContentTransitionCount < 0 || (_ContentTransitionCount > 0 && _ContentTransitions == null)) if (_ContentTransitionCount < 0 || (_ContentTransitionCount > 0 && _ContentTransitions == null))
_ContentTransitions = TransitionInfoList.GetByFromID(_ContentID); _ContentTransitions = TransitionInfoList.GetByFromID(_ContentID);
if (_ContentTransitionCount < 0) if (_ContentTransitionCount < 0)
@ -358,7 +374,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshContentTransitions() internal void RefreshContentTransitions()
{ {
_ContentTransitionCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_ContentID.ToString()))
foreach (ContentInfo tmp in _AllByPrimaryKey[_ContentID.ToString()])
tmp._ContentTransitionCount = -1; // This will cause the data to be requeried
} }
private int _ContentZContentCount = 0; private int _ContentZContentCount = 0;
/// <summary> /// <summary>
@ -369,7 +388,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentZContentCount",true); CanReadProperty("ContentZContentCount", true);
return _ContentZContentCount; return _ContentZContentCount;
} }
} }
@ -380,7 +399,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyZContent",true); CanReadProperty("MyZContent", true);
if (_ContentZContentCount > 0 && _MyZContent == null) if (_ContentZContentCount > 0 && _MyZContent == null)
_MyZContent = ZContentInfo.Get(_ContentID); _MyZContent = ZContentInfo.Get(_ContentID);
return _MyZContent; return _MyZContent;
@ -406,14 +425,25 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _ContentInfoUnique = 0;
private int _MyContentInfoUnique;
public int MyContentInfoUnique
{
get { return _MyContentInfoUnique; }
}
private ContentInfo() private ContentInfo()
{/* require use of factory methods */ {/* require use of factory methods */
_MyContentInfoUnique = ++_ContentInfoUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(ContentID.ToString()); if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString())) return;
List<ContentInfo> listContentInfo = _AllByPrimaryKey[ContentID.ToString()]; // Get the list of items
listContentInfo.Remove(this); // Remove the item from the list
if (listContentInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(ContentID.ToString()); // remove the list
} }
public virtual Content Get() public virtual Content Get()
{ {
@ -421,9 +451,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(Content tmp) public static void Refresh(Content tmp)
{ {
ContentInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID); string key = tmp.ContentID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (ContentInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(Content tmp) private void RefreshFields(Content tmp)
{ {
@ -434,9 +466,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyFormat.RefreshFormatContents(); // Update List for old value MyFormat.RefreshFormatContents(); // Update List for old value
_FormatID = tmp.FormatID; // Update the value _FormatID = tmp.FormatID; // Update the value
_MyFormat = null; // Reset list so that the next line gets a new list
MyFormat.RefreshFormatContents(); // Update List for new value
} }
_MyFormat = null; // Reset list so that the next line gets a new list
if (MyFormat != null) MyFormat.RefreshFormatContents(); // Update List for new value
_Config = tmp.Config; _Config = tmp.Config;
_DTS = tmp.DTS; _DTS = tmp.DTS;
_UserID = tmp.UserID; _UserID = tmp.UserID;
@ -448,9 +480,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(FormatContent tmp) public static void Refresh(FormatContent tmp)
{ {
ContentInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID); string key = tmp.ContentID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (ContentInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(FormatContent tmp) private void RefreshFields(FormatContent tmp)
{ {
@ -476,7 +510,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<ContentInfo>(new PKCriteria(contentID)); tmp = DataPortal.Fetch<ContentInfo>(new PKCriteria(contentID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -490,14 +524,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
internal ContentInfo(SafeDataReader dr) internal ContentInfo(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentInfo.Constructor", GetHashCode()); _MyContentInfoUnique = ++_ContentInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.Constructor", GetHashCode());
try try
{ {
ReadData(dr); ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentInfo.Constructor", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfo.Constructor", ex);
throw new DbCslaException("ContentInfo.Constructor", ex); throw new DbCslaException("ContentInfo.Constructor", ex);
} }
} }
@ -514,7 +549,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentInfo.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.ReadData", GetHashCode());
try try
{ {
_ContentID = dr.GetInt32("ContentID"); _ContentID = dr.GetInt32("ContentID");
@ -535,14 +570,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentInfo.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfo.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("ContentInfo.ReadData", ex); throw new DbCslaException("ContentInfo.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -570,7 +605,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentInfo.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("ContentInfo.DataPortal_Fetch", ex); throw new DbCslaException("ContentInfo.DataPortal_Fetch", ex);
} }
@ -580,7 +615,7 @@ namespace VEPROMS.CSLA.Library
#region extension #region extension
ContentInfoExtension _ContentInfoExtension = new ContentInfoExtension(); ContentInfoExtension _ContentInfoExtension = new ContentInfoExtension();
[Serializable()] [Serializable()]
partial class ContentInfoExtension : extensionBase {} partial class ContentInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {

View File

@ -110,7 +110,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -130,7 +130,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ContentInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ContentInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -152,7 +152,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(FormatIDCriteria criteria) private void DataPortal_Fetch(FormatIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentInfoList.DataPortal_FetchFormatID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfoList.DataPortal_FetchFormatID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -173,7 +173,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentInfoList.DataPortal_FetchFormatID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfoList.DataPortal_FetchFormatID", ex);
throw new DbCslaException("ContentInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ContentInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -234,8 +234,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class ContentInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class ContentInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private ContentInfo Item { get { return (ContentInfo) _Item;} } private ContentInfo Item { get { return (ContentInfo)_Item; } }
public ContentInfoListPropertyDescriptor(ContentInfoList collection, int index):base(collection, index){;} public ContentInfoListPropertyDescriptor(ContentInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -246,7 +246,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is ContentInfoList) if (destType == typeof(string) && value is ContentInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((ContentInfoList) value).Items.Count.ToString() + " Contents"; return ((ContentInfoList)value).Items.Count.ToString() + " Contents";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemID",true); CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID; if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID; return _ItemID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItem",true); CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID); if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
return _MyItem; return _MyItem;
} }
@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("PreviousID",true); CanReadProperty("PreviousID", true);
if (_MyPrevious != null) _PreviousID = _MyPrevious.ItemID; if (_MyPrevious != null) _PreviousID = _MyPrevious.ItemID;
return _PreviousID; return _PreviousID;
} }
@ -76,18 +76,18 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyPrevious",true); CanReadProperty("MyPrevious", true);
if (_MyPrevious == null && _PreviousID != null) _MyPrevious = Item.Get((int)_PreviousID); if (_MyPrevious == null && _PreviousID != null) _MyPrevious = Item.Get((int)_PreviousID);
return _MyPrevious; return _MyPrevious;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyPrevious",true); CanWriteProperty("MyPrevious", true);
if (_MyPrevious != value) if (_MyPrevious != value)
{ {
_MyPrevious = value; _MyPrevious = value;
_PreviousID = (value == null ? null : (int?) value.ItemID); _PreviousID = (value == null ? null : (int?)value.ItemID);
PropertyHasChanged(); PropertyHasChanged();
} }
} }
@ -98,13 +98,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -118,13 +118,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -155,23 +155,23 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -272,7 +272,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentItem.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentItem.FetchDR", GetHashCode());
try try
{ {
_ItemID = dr.GetInt32("ItemID"); _ItemID = dr.GetInt32("ItemID");
@ -283,7 +283,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentItem.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentItem.FetchDR", ex);
throw new DbCslaException("ContentItem.Fetch", ex); throw new DbCslaException("ContentItem.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public ContentItem Add() // One to Many public ContentItem Add() // One to Many
{ {
ContentItem item = ContentItem.New(); ContentItem item = ContentItem.New();
this.Add(item); this.Add(item);
return item; return item;
} }
public void Remove(Item myItem) public void Remove(Item myItem)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(ContentItem contentItem in this) foreach (ContentItem contentItem in this)
if ((hasBrokenRules = contentItem.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = contentItem.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ContentIDCriteria criteria) private void DataPortal_Fetch(ContentIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentItems.DataPortal_FetchContentID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentItems.DataPortal_FetchContentID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentItems.DataPortal_FetchContentID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentItems.DataPortal_FetchContentID", ex);
throw new DbCslaException("ContentItems.DataPortal_Fetch", ex); throw new DbCslaException("ContentItems.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class ContentItemsPropertyDescriptor : vlnListPropertyDescriptor public partial class ContentItemsPropertyDescriptor : vlnListPropertyDescriptor
{ {
private ContentItem Item { get { return (ContentItem) _Item;} } private ContentItem Item { get { return (ContentItem)_Item; } }
public ContentItemsPropertyDescriptor(ContentItems collection, int index):base(collection, index){;} public ContentItemsPropertyDescriptor(ContentItems collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is ContentItems) if (destType == typeof(string) && value is ContentItems)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((ContentItems) value).Items.Count.ToString() + " Items"; return ((ContentItems)value).Items.Count.ToString() + " Items";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FromType",true); CanReadProperty("FromType", true);
return _FromType; return _FromType;
} }
} }
@ -52,7 +52,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemID",true); CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID; if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID; return _ItemID;
} }
@ -63,14 +63,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItem",true); CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID); if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
return _MyItem; return _MyItem;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyItem",true); CanWriteProperty("MyItem", true);
if (_MyItem != value) if (_MyItem != value)
{ {
_MyItem = value; _MyItem = value;
@ -84,13 +84,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -104,13 +104,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -126,7 +126,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_PreviousID",true); CanReadProperty("Item_PreviousID", true);
return _Item_PreviousID; return _Item_PreviousID;
} }
} }
@ -136,7 +136,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_ContentID",true); CanReadProperty("Item_ContentID", true);
return _Item_ContentID; return _Item_ContentID;
} }
} }
@ -146,7 +146,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_DTS",true); CanReadProperty("Item_DTS", true);
return _Item_DTS; return _Item_DTS;
} }
} }
@ -156,7 +156,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_UserID",true); CanReadProperty("Item_UserID", true);
return _Item_UserID; return _Item_UserID;
} }
} }
@ -189,23 +189,23 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -313,8 +313,8 @@ namespace VEPROMS.CSLA.Library
// TODO: Add any initialization & defaults // TODO: Add any initialization & defaults
_DTS = _ContentPartExtension.DefaultDTS; _DTS = _ContentPartExtension.DefaultDTS;
_UserID = _ContentPartExtension.DefaultUserID; _UserID = _ContentPartExtension.DefaultUserID;
_FromType = fromType; _FromType = fromType;
_MyItem = myItem; _MyItem = myItem;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal ContentPart(SafeDataReader dr) internal ContentPart(SafeDataReader dr)
@ -326,7 +326,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentPart.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentPart.FetchDR", GetHashCode());
try try
{ {
_FromType = dr.GetInt32("FromType"); _FromType = dr.GetInt32("FromType");
@ -341,7 +341,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentPart.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentPart.FetchDR", ex);
throw new DbCslaException("ContentPart.Fetch", ex); throw new DbCslaException("ContentPart.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -99,8 +99,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(ContentPart contentPart in this) foreach (ContentPart contentPart in this)
if ((hasBrokenRules = contentPart.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = contentPart.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -109,8 +109,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -170,7 +170,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ContentIDCriteria criteria) private void DataPortal_Fetch(ContentIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentParts.DataPortal_FetchContentID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentParts.DataPortal_FetchContentID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -189,7 +189,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentParts.DataPortal_FetchContentID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentParts.DataPortal_FetchContentID", ex);
throw new DbCslaException("ContentParts.DataPortal_Fetch", ex); throw new DbCslaException("ContentParts.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -274,8 +274,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class ContentPartsPropertyDescriptor : vlnListPropertyDescriptor public partial class ContentPartsPropertyDescriptor : vlnListPropertyDescriptor
{ {
private ContentPart Item { get { return (ContentPart) _Item;} } private ContentPart Item { get { return (ContentPart)_Item; } }
public ContentPartsPropertyDescriptor(ContentParts collection, int index):base(collection, index){;} public ContentPartsPropertyDescriptor(ContentParts collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -286,7 +286,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is ContentParts) if (destType == typeof(string) && value is ContentParts)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((ContentParts) value).Items.Count.ToString() + " Parts"; return ((ContentParts)value).Items.Count.ToString() + " Parts";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ROUsageID",true); CanReadProperty("ROUsageID", true);
if (_MyRoUsage != null) _ROUsageID = _MyRoUsage.ROUsageID; if (_MyRoUsage != null) _ROUsageID = _MyRoUsage.ROUsageID;
return _ROUsageID; return _ROUsageID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyRoUsage",true); CanReadProperty("MyRoUsage", true);
if (_MyRoUsage == null && _ROUsageID != 0) _MyRoUsage = RoUsage.Get(_ROUsageID); if (_MyRoUsage == null && _ROUsageID != 0) _MyRoUsage = RoUsage.Get(_ROUsageID);
return _MyRoUsage; return _MyRoUsage;
} }
@ -65,13 +65,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ROID",true); CanReadProperty("ROID", true);
return _ROID; return _ROID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("ROID",true); CanWriteProperty("ROID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_ROID != value) if (_ROID != value)
{ {
@ -86,13 +86,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -107,13 +107,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -127,13 +127,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -164,22 +164,22 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -287,7 +287,7 @@ namespace VEPROMS.CSLA.Library
// TODO: Add any initialization & defaults // TODO: Add any initialization & defaults
_DTS = _ContentRoUsageExtension.DefaultDTS; _DTS = _ContentRoUsageExtension.DefaultDTS;
_UserID = _ContentRoUsageExtension.DefaultUserID; _UserID = _ContentRoUsageExtension.DefaultUserID;
_ROID = roid; _ROID = roid;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal ContentRoUsage(SafeDataReader dr) internal ContentRoUsage(SafeDataReader dr)
@ -299,7 +299,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentRoUsage.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentRoUsage.FetchDR", GetHashCode());
try try
{ {
_ROUsageID = dr.GetInt32("ROUsageID"); _ROUsageID = dr.GetInt32("ROUsageID");
@ -311,7 +311,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentRoUsage.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentRoUsage.FetchDR", ex);
throw new DbCslaException("ContentRoUsage.Fetch", ex); throw new DbCslaException("ContentRoUsage.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public ContentRoUsage Add(string roid) // One to Many public ContentRoUsage Add(string roid) // One to Many
{ {
ContentRoUsage roUsage = ContentRoUsage.New(roid); ContentRoUsage roUsage = ContentRoUsage.New(roid);
this.Add(roUsage); this.Add(roUsage);
return roUsage; return roUsage;
} }
public void Remove(RoUsage myRoUsage) public void Remove(RoUsage myRoUsage)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(ContentRoUsage contentRoUsage in this) foreach (ContentRoUsage contentRoUsage in this)
if ((hasBrokenRules = contentRoUsage.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = contentRoUsage.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ContentIDCriteria criteria) private void DataPortal_Fetch(ContentIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentRoUsages.DataPortal_FetchContentID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentRoUsages.DataPortal_FetchContentID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentRoUsages.DataPortal_FetchContentID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentRoUsages.DataPortal_FetchContentID", ex);
throw new DbCslaException("ContentRoUsages.DataPortal_Fetch", ex); throw new DbCslaException("ContentRoUsages.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class ContentRoUsagesPropertyDescriptor : vlnListPropertyDescriptor public partial class ContentRoUsagesPropertyDescriptor : vlnListPropertyDescriptor
{ {
private ContentRoUsage Item { get { return (ContentRoUsage) _Item;} } private ContentRoUsage Item { get { return (ContentRoUsage)_Item; } }
public ContentRoUsagesPropertyDescriptor(ContentRoUsages collection, int index):base(collection, index){;} public ContentRoUsagesPropertyDescriptor(ContentRoUsages collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is ContentRoUsages) if (destType == typeof(string) && value is ContentRoUsages)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((ContentRoUsages) value).Items.Count.ToString() + " RoUsages"; return ((ContentRoUsages)value).Items.Count.ToString() + " RoUsages";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("TransitionID",true); CanReadProperty("TransitionID", true);
if (_MyTransition != null) _TransitionID = _MyTransition.TransitionID; if (_MyTransition != null) _TransitionID = _MyTransition.TransitionID;
return _TransitionID; return _TransitionID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyTransition",true); CanReadProperty("MyTransition", true);
if (_MyTransition == null && _TransitionID != 0) _MyTransition = Transition.Get(_TransitionID); if (_MyTransition == null && _TransitionID != 0) _MyTransition = Transition.Get(_TransitionID);
return _MyTransition; return _MyTransition;
} }
@ -68,7 +68,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ToID",true); CanReadProperty("ToID", true);
if (_MyItemToID != null) _ToID = _MyItemToID.ItemID; if (_MyItemToID != null) _ToID = _MyItemToID.ItemID;
return _ToID; return _ToID;
} }
@ -79,14 +79,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItemToID",true); CanReadProperty("MyItemToID", true);
if (_MyItemToID == null && _ToID != 0) _MyItemToID = Item.Get(_ToID); if (_MyItemToID == null && _ToID != 0) _MyItemToID = Item.Get(_ToID);
return _MyItemToID; return _MyItemToID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyItemToID",true); CanWriteProperty("MyItemToID", true);
if (_MyItemToID != value) if (_MyItemToID != value)
{ {
_MyItemToID = value; _MyItemToID = value;
@ -100,7 +100,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RangeID",true); CanReadProperty("RangeID", true);
if (_MyItemRangeID != null) _RangeID = _MyItemRangeID.ItemID; if (_MyItemRangeID != null) _RangeID = _MyItemRangeID.ItemID;
return _RangeID; return _RangeID;
} }
@ -111,14 +111,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItemRangeID",true); CanReadProperty("MyItemRangeID", true);
if (_MyItemRangeID == null && _RangeID != 0) _MyItemRangeID = Item.Get(_RangeID); if (_MyItemRangeID == null && _RangeID != 0) _MyItemRangeID = Item.Get(_RangeID);
return _MyItemRangeID; return _MyItemRangeID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyItemRangeID",true); CanWriteProperty("MyItemRangeID", true);
if (_MyItemRangeID != value) if (_MyItemRangeID != value)
{ {
_MyItemRangeID = value; _MyItemRangeID = value;
@ -132,13 +132,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("TranType",true); CanReadProperty("TranType", true);
return _TranType; return _TranType;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("TranType",true); CanWriteProperty("TranType", true);
if (_TranType != value) if (_TranType != value)
{ {
_TranType = value; _TranType = value;
@ -152,13 +152,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -173,13 +173,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -193,13 +193,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -215,7 +215,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_RangeID_PreviousID",true); CanReadProperty("Item_RangeID_PreviousID", true);
return _Item_RangeID_PreviousID; return _Item_RangeID_PreviousID;
} }
} }
@ -225,7 +225,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_RangeID_ContentID",true); CanReadProperty("Item_RangeID_ContentID", true);
return _Item_RangeID_ContentID; return _Item_RangeID_ContentID;
} }
} }
@ -235,7 +235,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_RangeID_DTS",true); CanReadProperty("Item_RangeID_DTS", true);
return _Item_RangeID_DTS; return _Item_RangeID_DTS;
} }
} }
@ -245,7 +245,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_RangeID_UserID",true); CanReadProperty("Item_RangeID_UserID", true);
return _Item_RangeID_UserID; return _Item_RangeID_UserID;
} }
} }
@ -255,7 +255,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_ToID_PreviousID",true); CanReadProperty("Item_ToID_PreviousID", true);
return _Item_ToID_PreviousID; return _Item_ToID_PreviousID;
} }
} }
@ -265,7 +265,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_ToID_ContentID",true); CanReadProperty("Item_ToID_ContentID", true);
return _Item_ToID_ContentID; return _Item_ToID_ContentID;
} }
} }
@ -275,7 +275,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_ToID_DTS",true); CanReadProperty("Item_ToID_DTS", true);
return _Item_ToID_DTS; return _Item_ToID_DTS;
} }
} }
@ -285,7 +285,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_ToID_UserID",true); CanReadProperty("Item_ToID_UserID", true);
return _Item_ToID_UserID; return _Item_ToID_UserID;
} }
} }
@ -318,24 +318,24 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyItemToID != null && (hasBrokenRules = _MyItemToID.HasBrokenRules) != null) return hasBrokenRules; if (_MyItemToID != null && (hasBrokenRules = _MyItemToID.HasBrokenRules) != null) return hasBrokenRules;
if (_MyItemRangeID != null && (hasBrokenRules = _MyItemRangeID.HasBrokenRules) != null) return hasBrokenRules; if (_MyItemRangeID != null && (hasBrokenRules = _MyItemRangeID.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -464,8 +464,8 @@ namespace VEPROMS.CSLA.Library
_TranType = _ContentTransitionExtension.DefaultTranType; _TranType = _ContentTransitionExtension.DefaultTranType;
_DTS = _ContentTransitionExtension.DefaultDTS; _DTS = _ContentTransitionExtension.DefaultDTS;
_UserID = _ContentTransitionExtension.DefaultUserID; _UserID = _ContentTransitionExtension.DefaultUserID;
_MyItemToID = myItemToID; _MyItemToID = myItemToID;
_MyItemRangeID = myItemRangeID; _MyItemRangeID = myItemRangeID;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal ContentTransition(SafeDataReader dr) internal ContentTransition(SafeDataReader dr)
@ -477,7 +477,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentTransition.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentTransition.FetchDR", GetHashCode());
try try
{ {
_TransitionID = dr.GetInt32("TransitionID"); _TransitionID = dr.GetInt32("TransitionID");
@ -499,7 +499,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentTransition.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentTransition.FetchDR", ex);
throw new DbCslaException("ContentTransition.Fetch", ex); throw new DbCslaException("ContentTransition.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public ContentTransition Add(Item myItemToID, Item myItemRangeID) // One to Many public ContentTransition Add(Item myItemToID, Item myItemRangeID) // One to Many
{ {
ContentTransition transition = ContentTransition.New(myItemToID, myItemRangeID); ContentTransition transition = ContentTransition.New(myItemToID, myItemRangeID);
this.Add(transition); this.Add(transition);
return transition; return transition;
} }
public void Remove(Transition myTransition) public void Remove(Transition myTransition)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(ContentTransition contentTransition in this) foreach (ContentTransition contentTransition in this)
if ((hasBrokenRules = contentTransition.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = contentTransition.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(FromIDCriteria criteria) private void DataPortal_Fetch(FromIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentTransitions.DataPortal_FetchFromID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentTransitions.DataPortal_FetchFromID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentTransitions.DataPortal_FetchFromID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentTransitions.DataPortal_FetchFromID", ex);
throw new DbCslaException("ContentTransitions.DataPortal_Fetch", ex); throw new DbCslaException("ContentTransitions.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class ContentTransitionsPropertyDescriptor : vlnListPropertyDescriptor public partial class ContentTransitionsPropertyDescriptor : vlnListPropertyDescriptor
{ {
private ContentTransition Item { get { return (ContentTransition) _Item;} } private ContentTransition Item { get { return (ContentTransition)_Item; } }
public ContentTransitionsPropertyDescriptor(ContentTransitions collection, int index):base(collection, index){;} public ContentTransitionsPropertyDescriptor(ContentTransitions collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is ContentTransitions) if (destType == typeof(string) && value is ContentTransitions)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((ContentTransitions) value).Items.Count.ToString() + " Transitions"; return ((ContentTransitions)value).Items.Count.ToString() + " Transitions";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -28,7 +28,7 @@ namespace VEPROMS.CSLA.Library
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
public static void LogException(string s,Exception ex) public static void LogException(string s, Exception ex)
{ {
int i = 0; int i = 0;
Console.WriteLine("Error - {0}", s); Console.WriteLine("Error - {0}", s);
@ -44,12 +44,12 @@ namespace VEPROMS.CSLA.Library
set { _LoggingInfo = value; } set { _LoggingInfo = value; }
} }
static System.Diagnostics.Process _CurrentProcess = System.Diagnostics.Process.GetCurrentProcess(); static System.Diagnostics.Process _CurrentProcess = System.Diagnostics.Process.GetCurrentProcess();
public static void LogInfo(string s,int hashCode) public static void LogInfo(string s, int hashCode)
{ {
if (_LoggingInfo) if (_LoggingInfo)
Console.WriteLine("{0} MB {1}", _CurrentProcess.WorkingSet64 / 1000000, string.Format(s, hashCode)); Console.WriteLine("{0} MB {1}", _CurrentProcess.WorkingSet64 / 1000000, string.Format(s, hashCode));
} }
public static void LogDebug(string s,int hashCode) public static void LogDebug(string s, int hashCode)
{ {
if (_LoggingInfo) if (_LoggingInfo)
Console.WriteLine("{0} MB {1}", _CurrentProcess.WorkingSet64 / 1000000, string.Format(s, hashCode)); Console.WriteLine("{0} MB {1}", _CurrentProcess.WorkingSet64 / 1000000, string.Format(s, hashCode));
@ -107,7 +107,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex)// Throw Application Exception on Failure catch (Exception ex)// Throw Application Exception on Failure
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection Error", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection Error", ex);
throw new ApplicationException("Failure on Connect", ex); throw new ApplicationException("Failure on Connect", ex);
} }
} }
@ -124,14 +124,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Purge Error", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Purge Error", ex);
throw new ApplicationException("Failure on Purge", ex); throw new ApplicationException("Failure on Purge", ex);
} }
} }
} }
public class DbCslaException : Exception public class DbCslaException : Exception
{ {
internal DbCslaException(string message, Exception innerException):base(message,innerException){;} internal DbCslaException(string message, Exception innerException) : base(message, innerException) { ;}
internal DbCslaException(string message) : base(message) { ;} internal DbCslaException(string message) : base(message) { ;}
internal DbCslaException() : base() { ;} internal DbCslaException() : base() { ;}
} // Class } // Class

View File

@ -47,19 +47,23 @@ namespace VEPROMS.CSLA.Library
foreach (Detail tmp in _RefreshDetails) foreach (Detail tmp in _RefreshDetails)
{ {
DetailInfo.Refresh(tmp); DetailInfo.Refresh(tmp);
if(tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent); if (tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent);
} }
} }
#endregion #endregion
#region Collection #region Collection
protected static List<Detail> _AllList = new List<Detail>(); protected static List<Detail> _AllList = new List<Detail>();
private static Dictionary<string, Detail> _AllByPrimaryKey = new Dictionary<string, Detail>(); private static Dictionary<string, List<Detail>> _AllByPrimaryKey = new Dictionary<string, List<Detail>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<Detail> remove = new List<Detail>(); List<Detail> remove = new List<Detail>();
foreach (Detail tmp in _AllList) foreach (Detail tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.DetailID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.DetailID.ToString()))
{
_AllByPrimaryKey[tmp.DetailID.ToString()] = new List<Detail>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.DetailID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (Detail tmp in remove) foreach (Detail tmp in remove)
@ -69,7 +73,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = detailID.ToString(); string key = detailID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -91,7 +95,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DetailID",true); CanReadProperty("DetailID", true);
return _DetailID; return _DetailID;
} }
} }
@ -101,7 +105,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentID",true); CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID; if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID; return _ContentID;
} }
@ -112,14 +116,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyContent",true); CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID); if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID);
return _MyContent; return _MyContent;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyContent",true); CanWriteProperty("MyContent", true);
if (_MyContent != value) if (_MyContent != value)
{ {
_MyContent = value; _MyContent = value;
@ -133,13 +137,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemType",true); CanReadProperty("ItemType", true);
return _ItemType; return _ItemType;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("ItemType",true); CanWriteProperty("ItemType", true);
if (_ItemType != value) if (_ItemType != value)
{ {
_ItemType = value; _ItemType = value;
@ -153,13 +157,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Text",true); CanReadProperty("Text", true);
return _Text; return _Text;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Text",true); CanWriteProperty("Text", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Text != value) if (_Text != value)
{ {
@ -174,13 +178,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -195,13 +199,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -215,13 +219,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -233,11 +237,11 @@ namespace VEPROMS.CSLA.Library
private byte[] _LastChanged = new byte[8];//timestamp private byte[] _LastChanged = new byte[8];//timestamp
public override bool IsDirty 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 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 Detail.ToString function as necessary // TODO: Replace base Detail.ToString function as necessary
/// <summary> /// <summary>
@ -260,22 +264,23 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get { get
if(_CheckingBrokenRules)return null; {
if (_CheckingBrokenRules) return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules; if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -388,14 +393,25 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods #region Factory Methods
public int CurrentEditLevel public int CurrentEditLevel
{ get { return EditLevel; } } { get { return EditLevel; } }
private static int _DetailUnique = 0;
private int _MyDetailUnique;
public int MyDetailUnique
{
get { return _MyDetailUnique; }
}
protected Detail() protected Detail()
{/* require use of factory methods */ {/* require use of factory methods */
_MyDetailUnique = ++_DetailUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(DetailID.ToString()); if (!_AllByPrimaryKey.ContainsKey(DetailID.ToString())) return;
List<Detail> listDetail = _AllByPrimaryKey[DetailID.ToString()]; // Get the list of items
listDetail.Remove(this); // Remove the item from the list
if (listDetail.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(DetailID.ToString()); // remove the list
} }
public static Detail New() public static Detail New()
{ {
@ -480,7 +496,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<Detail>(new PKCriteria(detailID)); tmp = DataPortal.Fetch<Detail>(new PKCriteria(detailID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -559,7 +575,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Detail.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.ReadData", GetHashCode());
try try
{ {
_DetailID = dr.GetInt32("DetailID"); _DetailID = dr.GetInt32("DetailID");
@ -574,14 +590,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Detail.ReadData", ex); throw new DbCslaException("Detail.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Detail.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -609,7 +625,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Detail.DataPortal_Fetch", ex); throw new DbCslaException("Detail.DataPortal_Fetch", ex);
} }
@ -630,13 +646,13 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.DataPortal_Insert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.DataPortal_Insert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Detail.DataPortal_Insert", ex); throw new DbCslaException("Detail.DataPortal_Insert", ex);
} }
finally finally
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Detail.DataPortal_Insert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.DataPortal_Insert", GetHashCode());
} }
} }
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
@ -645,7 +661,7 @@ namespace VEPROMS.CSLA.Library
if (!this.IsDirty) return; if (!this.IsDirty) return;
try try
{ {
if(_MyContent != null) _MyContent.Update(); if (_MyContent != null) _MyContent.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
{ {
@ -673,11 +689,11 @@ namespace VEPROMS.CSLA.Library
} }
MarkOld(); MarkOld();
// update child objects // update child objects
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Detail.SQLInsert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.SQLInsert", GetHashCode());
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.SQLInsert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.SQLInsert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Detail.SQLInsert", ex); throw new DbCslaException("Detail.SQLInsert", ex);
} }
@ -685,7 +701,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int detailID, Content myContent, int itemType, string text, string config, DateTime dts, string userID) public static byte[] Add(SqlConnection cn, ref int detailID, Content myContent, int itemType, string text, string config, DateTime dts, string userID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Detail.Add", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.Add", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -715,7 +731,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.Add", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.Add", ex);
throw new DbCslaException("Detail.Add", ex); throw new DbCslaException("Detail.Add", ex);
} }
} }
@ -723,7 +739,7 @@ namespace VEPROMS.CSLA.Library
protected override void DataPortal_Update() protected override void DataPortal_Update()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Detail.DataPortal_Update", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.DataPortal_Update", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -737,7 +753,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.DataPortal_Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.DataPortal_Update", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -746,10 +762,10 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate() internal void SQLUpdate()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Detail.SQLUpdate", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.SQLUpdate", GetHashCode());
try try
{ {
if(_MyContent != null) _MyContent.Update(); if (_MyContent != null) _MyContent.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty) if (base.IsDirty)
{ {
@ -781,7 +797,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.SQLUpdate", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.SQLUpdate", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -802,7 +818,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int detailID, Content myContent, int itemType, string text, string config, DateTime dts, string userID, ref byte[] lastChanged) public static byte[] Update(SqlConnection cn, ref int detailID, Content myContent, int itemType, string text, string config, DateTime dts, string userID, ref byte[] lastChanged)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Detail.Update", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.Update", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -830,7 +846,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.Update", ex);
throw new DbCslaException("Detail.Update", ex); throw new DbCslaException("Detail.Update", ex);
} }
} }
@ -842,7 +858,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria) private void DataPortal_Delete(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Detail.DataPortal_Delete", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.DataPortal_Delete", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -858,7 +874,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.DataPortal_Delete", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.DataPortal_Delete", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Detail.DataPortal_Delete", ex); throw new DbCslaException("Detail.DataPortal_Delete", ex);
} }
@ -866,7 +882,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int detailID) public static void Remove(SqlConnection cn, int detailID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Detail.Remove", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.Remove", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -881,7 +897,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.Remove", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.Remove", ex);
throw new DbCslaException("Detail.Remove", ex); throw new DbCslaException("Detail.Remove", ex);
} }
} }
@ -915,7 +931,7 @@ namespace VEPROMS.CSLA.Library
} }
protected override void DataPortal_Execute() protected override void DataPortal_Execute()
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Detail.DataPortal_Execute", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.DataPortal_Execute", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -933,7 +949,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.DataPortal_Execute", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.DataPortal_Execute", ex);
throw new DbCslaException("Detail.DataPortal_Execute", ex); throw new DbCslaException("Detail.DataPortal_Execute", ex);
} }
} }

View File

@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<DetailInfo> _AllList = new List<DetailInfo>(); protected static List<DetailInfo> _AllList = new List<DetailInfo>();
private static Dictionary<string, DetailInfo> _AllByPrimaryKey = new Dictionary<string, DetailInfo>(); private static Dictionary<string, List<DetailInfo>> _AllByPrimaryKey = new Dictionary<string, List<DetailInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<DetailInfo> remove = new List<DetailInfo>(); List<DetailInfo> remove = new List<DetailInfo>();
foreach (DetailInfo tmp in _AllList) foreach (DetailInfo tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.DetailID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.DetailID.ToString()))
{
_AllByPrimaryKey[tmp.DetailID.ToString()] = new List<DetailInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.DetailID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (DetailInfo tmp in remove) foreach (DetailInfo tmp in remove)
@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = detailID.ToString(); string key = detailID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DetailID",true); CanReadProperty("DetailID", true);
return _DetailID; return _DetailID;
} }
} }
@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentID",true); CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID; if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID; return _ContentID;
} }
@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyContent",true); CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID); if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent; return _MyContent;
} }
@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemType",true); CanReadProperty("ItemType", true);
return _ItemType; return _ItemType;
} }
} }
@ -127,7 +131,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Text",true); CanReadProperty("Text", true);
return _Text; return _Text;
} }
} }
@ -137,7 +141,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
} }
@ -147,7 +151,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -157,7 +161,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
} }
@ -181,14 +185,25 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _DetailInfoUnique = 0;
private int _MyDetailInfoUnique;
public int MyDetailInfoUnique
{
get { return _MyDetailInfoUnique; }
}
private DetailInfo() private DetailInfo()
{/* require use of factory methods */ {/* require use of factory methods */
_MyDetailInfoUnique = ++_DetailInfoUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(DetailID.ToString()); if (!_AllByPrimaryKey.ContainsKey(DetailID.ToString())) return;
List<DetailInfo> listDetailInfo = _AllByPrimaryKey[DetailID.ToString()]; // Get the list of items
listDetailInfo.Remove(this); // Remove the item from the list
if (listDetailInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(DetailID.ToString()); // remove the list
} }
public virtual Detail Get() public virtual Detail Get()
{ {
@ -196,9 +211,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(Detail tmp) public static void Refresh(Detail tmp)
{ {
DetailInfo tmpInfo = GetExistingByPrimaryKey(tmp.DetailID); string key = tmp.DetailID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (DetailInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(Detail tmp) private void RefreshFields(Detail tmp)
{ {
@ -206,9 +223,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyContent.RefreshContentDetails(); // Update List for old value MyContent.RefreshContentDetails(); // Update List for old value
_ContentID = tmp.ContentID; // Update the value _ContentID = tmp.ContentID; // Update the value
_MyContent = null; // Reset list so that the next line gets a new list
MyContent.RefreshContentDetails(); // Update List for new value
} }
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentDetails(); // Update List for new value
_ItemType = tmp.ItemType; _ItemType = tmp.ItemType;
_Text = tmp.Text; _Text = tmp.Text;
_Config = tmp.Config; _Config = tmp.Config;
@ -220,9 +237,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(ContentDetail tmp) public static void Refresh(ContentDetail tmp)
{ {
DetailInfo tmpInfo = GetExistingByPrimaryKey(tmp.DetailID); string key = tmp.DetailID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (DetailInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(ContentDetail tmp) private void RefreshFields(ContentDetail tmp)
{ {
@ -245,7 +264,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<DetailInfo>(new PKCriteria(detailID)); tmp = DataPortal.Fetch<DetailInfo>(new PKCriteria(detailID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -259,14 +278,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
internal DetailInfo(SafeDataReader dr) internal DetailInfo(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DetailInfo.Constructor", GetHashCode()); _MyDetailInfoUnique = ++_DetailInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfo.Constructor", GetHashCode());
try try
{ {
ReadData(dr); ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DetailInfo.Constructor", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DetailInfo.Constructor", ex);
throw new DbCslaException("DetailInfo.Constructor", ex); throw new DbCslaException("DetailInfo.Constructor", ex);
} }
} }
@ -283,7 +303,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DetailInfo.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfo.ReadData", GetHashCode());
try try
{ {
_DetailID = dr.GetInt32("DetailID"); _DetailID = dr.GetInt32("DetailID");
@ -296,14 +316,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DetailInfo.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DetailInfo.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("DetailInfo.ReadData", ex); throw new DbCslaException("DetailInfo.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DetailInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfo.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -331,7 +351,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DetailInfo.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DetailInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("DetailInfo.DataPortal_Fetch", ex); throw new DbCslaException("DetailInfo.DataPortal_Fetch", ex);
} }
@ -341,7 +361,7 @@ namespace VEPROMS.CSLA.Library
#region extension #region extension
DetailInfoExtension _DetailInfoExtension = new DetailInfoExtension(); DetailInfoExtension _DetailInfoExtension = new DetailInfoExtension();
[Serializable()] [Serializable()]
partial class DetailInfoExtension : extensionBase {} partial class DetailInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {

View File

@ -110,7 +110,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DetailInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -130,7 +130,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DetailInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DetailInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("DetailInfoList.DataPortal_Fetch", ex); throw new DbCslaException("DetailInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -152,7 +152,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ContentIDCriteria criteria) private void DataPortal_Fetch(ContentIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DetailInfoList.DataPortal_FetchContentID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfoList.DataPortal_FetchContentID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -173,7 +173,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DetailInfoList.DataPortal_FetchContentID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DetailInfoList.DataPortal_FetchContentID", ex);
throw new DbCslaException("DetailInfoList.DataPortal_Fetch", ex); throw new DbCslaException("DetailInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -234,8 +234,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class DetailInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class DetailInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private DetailInfo Item { get { return (DetailInfo) _Item;} } private DetailInfo Item { get { return (DetailInfo)_Item; } }
public DetailInfoListPropertyDescriptor(DetailInfoList collection, int index):base(collection, index){;} public DetailInfoListPropertyDescriptor(DetailInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -246,7 +246,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is DetailInfoList) if (destType == typeof(string) && value is DetailInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((DetailInfoList) value).Items.Count.ToString() + " Details"; return ((DetailInfoList)value).Items.Count.ToString() + " Details";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -47,21 +47,25 @@ namespace VEPROMS.CSLA.Library
foreach (DocVersion tmp in _RefreshDocVersions) foreach (DocVersion tmp in _RefreshDocVersions)
{ {
DocVersionInfo.Refresh(tmp); DocVersionInfo.Refresh(tmp);
if(tmp._MyFolder != null) FolderInfo.Refresh(tmp._MyFolder); if (tmp._MyFolder != null) FolderInfo.Refresh(tmp._MyFolder);
if(tmp._MyFormat != null) FormatInfo.Refresh(tmp._MyFormat); if (tmp._MyFormat != null) FormatInfo.Refresh(tmp._MyFormat);
if(tmp._MyItem != null) ItemInfo.Refresh(tmp._MyItem); if (tmp._MyItem != null) ItemInfo.Refresh(tmp._MyItem);
} }
} }
#endregion #endregion
#region Collection #region Collection
protected static List<DocVersion> _AllList = new List<DocVersion>(); protected static List<DocVersion> _AllList = new List<DocVersion>();
private static Dictionary<string, DocVersion> _AllByPrimaryKey = new Dictionary<string, DocVersion>(); private static Dictionary<string, List<DocVersion>> _AllByPrimaryKey = new Dictionary<string, List<DocVersion>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<DocVersion> remove = new List<DocVersion>(); List<DocVersion> remove = new List<DocVersion>();
foreach (DocVersion tmp in _AllList) foreach (DocVersion tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.VersionID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.VersionID.ToString()))
{
_AllByPrimaryKey[tmp.VersionID.ToString()] = new List<DocVersion>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.VersionID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (DocVersion tmp in remove) foreach (DocVersion tmp in remove)
@ -71,7 +75,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = versionID.ToString(); string key = versionID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -93,7 +97,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("VersionID",true); CanReadProperty("VersionID", true);
return _VersionID; return _VersionID;
} }
} }
@ -103,7 +107,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderID",true); CanReadProperty("FolderID", true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID; if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID; return _FolderID;
} }
@ -114,14 +118,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFolder",true); CanReadProperty("MyFolder", true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID); if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder; return _MyFolder;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyFolder",true); CanWriteProperty("MyFolder", true);
if (_MyFolder != value) if (_MyFolder != value)
{ {
_MyFolder = value; _MyFolder = value;
@ -138,13 +142,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("VersionType",true); CanReadProperty("VersionType", true);
return _VersionType; return _VersionType;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("VersionType",true); CanWriteProperty("VersionType", true);
if (_VersionType != value) if (_VersionType != value)
{ {
_VersionType = value; _VersionType = value;
@ -158,13 +162,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name",true); CanReadProperty("Name", true);
return _Name; return _Name;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Name",true); CanWriteProperty("Name", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Name != value) if (_Name != value)
{ {
@ -179,13 +183,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Title",true); CanReadProperty("Title", true);
return _Title; return _Title;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Title",true); CanWriteProperty("Title", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Title != value) if (_Title != value)
{ {
@ -200,7 +204,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemID",true); CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID; if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID; return _ItemID;
} }
@ -211,18 +215,18 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItem",true); CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != null) _MyItem = Item.Get((int)_ItemID); if (_MyItem == null && _ItemID != null) _MyItem = Item.Get((int)_ItemID);
return _MyItem; return _MyItem;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyItem",true); CanWriteProperty("MyItem", true);
if (_MyItem != value) if (_MyItem != value)
{ {
_MyItem = value; _MyItem = value;
_ItemID = (value == null ? null : (int?) value.ItemID); _ItemID = (value == null ? null : (int?)value.ItemID);
PropertyHasChanged(); PropertyHasChanged();
} }
} }
@ -233,7 +237,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatID",true); CanReadProperty("FormatID", true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID; if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID; return _FormatID;
} }
@ -244,18 +248,18 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFormat",true); CanReadProperty("MyFormat", true);
if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID); if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID);
return _MyFormat; return _MyFormat;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyFormat",true); CanWriteProperty("MyFormat", true);
if (_MyFormat != value) if (_MyFormat != value)
{ {
_MyFormat = value; _MyFormat = value;
_FormatID = (value == null ? null : (int?) value.FormatID); _FormatID = (value == null ? null : (int?)value.FormatID);
PropertyHasChanged(); PropertyHasChanged();
} }
} }
@ -266,13 +270,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -287,13 +291,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -307,13 +311,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -325,11 +329,11 @@ namespace VEPROMS.CSLA.Library
private byte[] _LastChanged = new byte[8];//timestamp private byte[] _LastChanged = new byte[8];//timestamp
public override bool IsDirty public override bool IsDirty
{ {
get { return base.IsDirty || (_MyFolder == null? false : _MyFolder.IsDirty) || (_MyFormat == null? false : _MyFormat.IsDirty) || (_MyItem == null? false : _MyItem.IsDirty); } get { return base.IsDirty || (_MyFolder == null ? false : _MyFolder.IsDirty) || (_MyFormat == null ? false : _MyFormat.IsDirty) || (_MyItem == null ? false : _MyItem.IsDirty); }
} }
public override bool IsValid public override bool IsValid
{ {
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyFolder == null? true : _MyFolder.IsValid) && (_MyFormat == null? true : _MyFormat.IsValid) && (_MyItem == null? true : _MyItem.IsValid); } get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyFolder == null ? true : _MyFolder.IsValid) && (_MyFormat == null ? true : _MyFormat.IsValid) && (_MyItem == null ? true : _MyItem.IsValid); }
} }
// TODO: Replace base DocVersion.ToString function as necessary // TODO: Replace base DocVersion.ToString function as necessary
/// <summary> /// <summary>
@ -352,24 +356,25 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get { get
if(_CheckingBrokenRules)return null; {
if (_CheckingBrokenRules) return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules;
if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules;
if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -491,14 +496,25 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods #region Factory Methods
public int CurrentEditLevel public int CurrentEditLevel
{ get { return EditLevel; } } { get { return EditLevel; } }
private static int _DocVersionUnique = 0;
private int _MyDocVersionUnique;
public int MyDocVersionUnique
{
get { return _MyDocVersionUnique; }
}
protected DocVersion() protected DocVersion()
{/* require use of factory methods */ {/* require use of factory methods */
_MyDocVersionUnique = ++_DocVersionUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(VersionID.ToString()); if (!_AllByPrimaryKey.ContainsKey(VersionID.ToString())) return;
List<DocVersion> listDocVersion = _AllByPrimaryKey[VersionID.ToString()]; // Get the list of items
listDocVersion.Remove(this); // Remove the item from the list
if (listDocVersion.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(VersionID.ToString()); // remove the list
} }
public static DocVersion New() public static DocVersion New()
{ {
@ -587,7 +603,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<DocVersion>(new PKCriteria(versionID)); tmp = DataPortal.Fetch<DocVersion>(new PKCriteria(versionID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -667,7 +683,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersion.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.ReadData", GetHashCode());
try try
{ {
_VersionID = dr.GetInt32("VersionID"); _VersionID = dr.GetInt32("VersionID");
@ -685,14 +701,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("DocVersion.ReadData", ex); throw new DbCslaException("DocVersion.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersion.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -720,7 +736,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("DocVersion.DataPortal_Fetch", ex); throw new DbCslaException("DocVersion.DataPortal_Fetch", ex);
} }
@ -741,13 +757,13 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.DataPortal_Insert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.DataPortal_Insert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("DocVersion.DataPortal_Insert", ex); throw new DbCslaException("DocVersion.DataPortal_Insert", ex);
} }
finally finally
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersion.DataPortal_Insert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.DataPortal_Insert", GetHashCode());
} }
} }
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
@ -756,9 +772,9 @@ namespace VEPROMS.CSLA.Library
if (!this.IsDirty) return; if (!this.IsDirty) return;
try try
{ {
if(_MyFolder != null) _MyFolder.Update(); if (_MyFolder != null) _MyFolder.Update();
if(_MyFormat != null) _MyFormat.Update(); if (_MyFormat != null) _MyFormat.Update();
if(_MyItem != null) _MyItem.Update(); if (_MyItem != null) _MyItem.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
{ {
@ -789,11 +805,11 @@ namespace VEPROMS.CSLA.Library
} }
MarkOld(); MarkOld();
// update child objects // update child objects
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersion.SQLInsert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.SQLInsert", GetHashCode());
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.SQLInsert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.SQLInsert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("DocVersion.SQLInsert", ex); throw new DbCslaException("DocVersion.SQLInsert", ex);
} }
@ -801,7 +817,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int versionID, Folder myFolder, int versionType, string name, string title, Item myItem, Format myFormat, string config, DateTime dts, string userID) public static byte[] Add(SqlConnection cn, ref int versionID, Folder myFolder, int versionType, string name, string title, Item myItem, Format myFormat, string config, DateTime dts, string userID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersion.Add", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.Add", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -813,8 +829,8 @@ namespace VEPROMS.CSLA.Library
cm.Parameters.AddWithValue("@VersionType", versionType); cm.Parameters.AddWithValue("@VersionType", versionType);
cm.Parameters.AddWithValue("@Name", name); cm.Parameters.AddWithValue("@Name", name);
cm.Parameters.AddWithValue("@Title", title); cm.Parameters.AddWithValue("@Title", title);
if(myItem != null)cm.Parameters.AddWithValue("@ItemID", myItem.ItemID); if (myItem != null) cm.Parameters.AddWithValue("@ItemID", myItem.ItemID);
if(myFormat != null)cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID); if (myFormat != null) cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID);
cm.Parameters.AddWithValue("@Config", config); cm.Parameters.AddWithValue("@Config", config);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts); if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID); cm.Parameters.AddWithValue("@UserID", userID);
@ -834,7 +850,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.Add", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.Add", ex);
throw new DbCslaException("DocVersion.Add", ex); throw new DbCslaException("DocVersion.Add", ex);
} }
} }
@ -842,7 +858,7 @@ namespace VEPROMS.CSLA.Library
protected override void DataPortal_Update() protected override void DataPortal_Update()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersion.DataPortal_Update", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.DataPortal_Update", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -856,7 +872,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.DataPortal_Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.DataPortal_Update", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -865,12 +881,12 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate() internal void SQLUpdate()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersion.SQLUpdate", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.SQLUpdate", GetHashCode());
try try
{ {
if(_MyFolder != null) _MyFolder.Update(); if (_MyFolder != null) _MyFolder.Update();
if(_MyFormat != null) _MyFormat.Update(); if (_MyFormat != null) _MyFormat.Update();
if(_MyItem != null) _MyItem.Update(); if (_MyItem != null) _MyItem.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty) if (base.IsDirty)
{ {
@ -905,7 +921,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.SQLUpdate", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.SQLUpdate", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -926,7 +942,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int versionID, Folder myFolder, int versionType, string name, string title, Item myItem, Format myFormat, string config, DateTime dts, string userID, ref byte[] lastChanged) public static byte[] Update(SqlConnection cn, ref int versionID, Folder myFolder, int versionType, string name, string title, Item myItem, Format myFormat, string config, DateTime dts, string userID, ref byte[] lastChanged)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersion.Update", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.Update", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -939,8 +955,8 @@ namespace VEPROMS.CSLA.Library
cm.Parameters.AddWithValue("@VersionType", versionType); cm.Parameters.AddWithValue("@VersionType", versionType);
cm.Parameters.AddWithValue("@Name", name); cm.Parameters.AddWithValue("@Name", name);
cm.Parameters.AddWithValue("@Title", title); cm.Parameters.AddWithValue("@Title", title);
if(myItem != null)cm.Parameters.AddWithValue("@ItemID", myItem.ItemID); if (myItem != null) cm.Parameters.AddWithValue("@ItemID", myItem.ItemID);
if(myFormat != null)cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID); if (myFormat != null) cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID);
cm.Parameters.AddWithValue("@Config", config); cm.Parameters.AddWithValue("@Config", config);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts); if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID); cm.Parameters.AddWithValue("@UserID", userID);
@ -957,7 +973,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.Update", ex);
throw new DbCslaException("DocVersion.Update", ex); throw new DbCslaException("DocVersion.Update", ex);
} }
} }
@ -969,7 +985,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria) private void DataPortal_Delete(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersion.DataPortal_Delete", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.DataPortal_Delete", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -985,7 +1001,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.DataPortal_Delete", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.DataPortal_Delete", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("DocVersion.DataPortal_Delete", ex); throw new DbCslaException("DocVersion.DataPortal_Delete", ex);
} }
@ -993,7 +1009,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int versionID) public static void Remove(SqlConnection cn, int versionID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersion.Remove", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.Remove", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -1008,7 +1024,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.Remove", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.Remove", ex);
throw new DbCslaException("DocVersion.Remove", ex); throw new DbCslaException("DocVersion.Remove", ex);
} }
} }
@ -1042,7 +1058,7 @@ namespace VEPROMS.CSLA.Library
} }
protected override void DataPortal_Execute() protected override void DataPortal_Execute()
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersion.DataPortal_Execute", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.DataPortal_Execute", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1060,7 +1076,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.DataPortal_Execute", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.DataPortal_Execute", ex);
throw new DbCslaException("DocVersion.DataPortal_Execute", ex); throw new DbCslaException("DocVersion.DataPortal_Execute", ex);
} }
} }

View File

@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<DocVersionInfo> _AllList = new List<DocVersionInfo>(); protected static List<DocVersionInfo> _AllList = new List<DocVersionInfo>();
private static Dictionary<string, DocVersionInfo> _AllByPrimaryKey = new Dictionary<string, DocVersionInfo>(); private static Dictionary<string, List<DocVersionInfo>> _AllByPrimaryKey = new Dictionary<string, List<DocVersionInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<DocVersionInfo> remove = new List<DocVersionInfo>(); List<DocVersionInfo> remove = new List<DocVersionInfo>();
foreach (DocVersionInfo tmp in _AllList) foreach (DocVersionInfo tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.VersionID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.VersionID.ToString()))
{
_AllByPrimaryKey[tmp.VersionID.ToString()] = new List<DocVersionInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.VersionID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (DocVersionInfo tmp in remove) foreach (DocVersionInfo tmp in remove)
@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = versionID.ToString(); string key = versionID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("VersionID",true); CanReadProperty("VersionID", true);
return _VersionID; return _VersionID;
} }
} }
@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderID",true); CanReadProperty("FolderID", true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID; if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID; return _FolderID;
} }
@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFolder",true); CanReadProperty("MyFolder", true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = FolderInfo.Get(_FolderID); if (_MyFolder == null && _FolderID != 0) _MyFolder = FolderInfo.Get(_FolderID);
return _MyFolder; return _MyFolder;
} }
@ -120,7 +124,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("VersionType",true); CanReadProperty("VersionType", true);
return _VersionType; return _VersionType;
} }
} }
@ -130,7 +134,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name",true); CanReadProperty("Name", true);
return _Name; return _Name;
} }
} }
@ -140,7 +144,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Title",true); CanReadProperty("Title", true);
return _Title; return _Title;
} }
} }
@ -150,7 +154,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemID",true); CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID; if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID; return _ItemID;
} }
@ -161,7 +165,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItem",true); CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != null) _MyItem = ItemInfo.Get((int)_ItemID); if (_MyItem == null && _ItemID != null) _MyItem = ItemInfo.Get((int)_ItemID);
return _MyItem; return _MyItem;
} }
@ -172,7 +176,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatID",true); CanReadProperty("FormatID", true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID; if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID; return _FormatID;
} }
@ -183,7 +187,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFormat",true); CanReadProperty("MyFormat", true);
if (_MyFormat == null && _FormatID != null) _MyFormat = FormatInfo.Get((int)_FormatID); if (_MyFormat == null && _FormatID != null) _MyFormat = FormatInfo.Get((int)_FormatID);
return _MyFormat; return _MyFormat;
} }
@ -194,7 +198,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
} }
@ -204,7 +208,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -214,7 +218,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
} }
@ -238,14 +242,25 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _DocVersionInfoUnique = 0;
private int _MyDocVersionInfoUnique;
public int MyDocVersionInfoUnique
{
get { return _MyDocVersionInfoUnique; }
}
private DocVersionInfo() private DocVersionInfo()
{/* require use of factory methods */ {/* require use of factory methods */
_MyDocVersionInfoUnique = ++_DocVersionInfoUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(VersionID.ToString()); if (!_AllByPrimaryKey.ContainsKey(VersionID.ToString())) return;
List<DocVersionInfo> listDocVersionInfo = _AllByPrimaryKey[VersionID.ToString()]; // Get the list of items
listDocVersionInfo.Remove(this); // Remove the item from the list
if (listDocVersionInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(VersionID.ToString()); // remove the list
} }
public virtual DocVersion Get() public virtual DocVersion Get()
{ {
@ -253,9 +268,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(DocVersion tmp) public static void Refresh(DocVersion tmp)
{ {
DocVersionInfo tmpInfo = GetExistingByPrimaryKey(tmp.VersionID); string key = tmp.VersionID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (DocVersionInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(DocVersion tmp) private void RefreshFields(DocVersion tmp)
{ {
@ -263,9 +280,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyFolder.RefreshFolderDocVersions(); // Update List for old value MyFolder.RefreshFolderDocVersions(); // Update List for old value
_FolderID = tmp.FolderID; // Update the value _FolderID = tmp.FolderID; // Update the value
_MyFolder = null; // Reset list so that the next line gets a new list
MyFolder.RefreshFolderDocVersions(); // Update List for new value
} }
_MyFolder = null; // Reset list so that the next line gets a new list
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for new value
_VersionType = tmp.VersionType; _VersionType = tmp.VersionType;
_Name = tmp.Name; _Name = tmp.Name;
_Title = tmp.Title; _Title = tmp.Title;
@ -273,16 +290,16 @@ namespace VEPROMS.CSLA.Library
{ {
MyItem.RefreshItemDocVersions(); // Update List for old value MyItem.RefreshItemDocVersions(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value _ItemID = tmp.ItemID; // Update the value
_MyItem = null; // Reset list so that the next line gets a new list
MyItem.RefreshItemDocVersions(); // Update List for new value
} }
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for new value
if (_FormatID != tmp.FormatID) if (_FormatID != tmp.FormatID)
{ {
MyFormat.RefreshFormatDocVersions(); // Update List for old value MyFormat.RefreshFormatDocVersions(); // Update List for old value
_FormatID = tmp.FormatID; // Update the value _FormatID = tmp.FormatID; // Update the value
_MyFormat = null; // Reset list so that the next line gets a new list
MyFormat.RefreshFormatDocVersions(); // Update List for new value
} }
_MyFormat = null; // Reset list so that the next line gets a new list
if (MyFormat != null) MyFormat.RefreshFormatDocVersions(); // Update List for new value
_Config = tmp.Config; _Config = tmp.Config;
_DTS = tmp.DTS; _DTS = tmp.DTS;
_UserID = tmp.UserID; _UserID = tmp.UserID;
@ -294,9 +311,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(FolderDocVersion tmp) public static void Refresh(FolderDocVersion tmp)
{ {
DocVersionInfo tmpInfo = GetExistingByPrimaryKey(tmp.VersionID); string key = tmp.VersionID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (DocVersionInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(FolderDocVersion tmp) private void RefreshFields(FolderDocVersion tmp)
{ {
@ -307,16 +326,16 @@ namespace VEPROMS.CSLA.Library
{ {
MyItem.RefreshItemDocVersions(); // Update List for old value MyItem.RefreshItemDocVersions(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value _ItemID = tmp.ItemID; // Update the value
_MyItem = null; // Reset list so that the next line gets a new list
MyItem.RefreshItemDocVersions(); // Update List for new value
} }
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for new value
if (_FormatID != tmp.FormatID) if (_FormatID != tmp.FormatID)
{ {
MyFormat.RefreshFormatDocVersions(); // Update List for old value MyFormat.RefreshFormatDocVersions(); // Update List for old value
_FormatID = tmp.FormatID; // Update the value _FormatID = tmp.FormatID; // Update the value
_MyFormat = null; // Reset list so that the next line gets a new list
MyFormat.RefreshFormatDocVersions(); // Update List for new value
} }
_MyFormat = null; // Reset list so that the next line gets a new list
if (MyFormat != null) MyFormat.RefreshFormatDocVersions(); // Update List for new value
_Config = tmp.Config; _Config = tmp.Config;
_DTS = tmp.DTS; _DTS = tmp.DTS;
_UserID = tmp.UserID; _UserID = tmp.UserID;
@ -328,9 +347,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(FormatDocVersion tmp) public static void Refresh(FormatDocVersion tmp)
{ {
DocVersionInfo tmpInfo = GetExistingByPrimaryKey(tmp.VersionID); string key = tmp.VersionID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (DocVersionInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(FormatDocVersion tmp) private void RefreshFields(FormatDocVersion tmp)
{ {
@ -338,9 +359,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyFolder.RefreshFolderDocVersions(); // Update List for old value MyFolder.RefreshFolderDocVersions(); // Update List for old value
_FolderID = tmp.FolderID; // Update the value _FolderID = tmp.FolderID; // Update the value
_MyFolder = null; // Reset list so that the next line gets a new list
MyFolder.RefreshFolderDocVersions(); // Update List for new value
} }
_MyFolder = null; // Reset list so that the next line gets a new list
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for new value
_VersionType = tmp.VersionType; _VersionType = tmp.VersionType;
_Name = tmp.Name; _Name = tmp.Name;
_Title = tmp.Title; _Title = tmp.Title;
@ -348,9 +369,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyItem.RefreshItemDocVersions(); // Update List for old value MyItem.RefreshItemDocVersions(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value _ItemID = tmp.ItemID; // Update the value
_MyItem = null; // Reset list so that the next line gets a new list
MyItem.RefreshItemDocVersions(); // Update List for new value
} }
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for new value
_Config = tmp.Config; _Config = tmp.Config;
_DTS = tmp.DTS; _DTS = tmp.DTS;
_UserID = tmp.UserID; _UserID = tmp.UserID;
@ -362,9 +383,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(ItemDocVersion tmp) public static void Refresh(ItemDocVersion tmp)
{ {
DocVersionInfo tmpInfo = GetExistingByPrimaryKey(tmp.VersionID); string key = tmp.VersionID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (DocVersionInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(ItemDocVersion tmp) private void RefreshFields(ItemDocVersion tmp)
{ {
@ -372,9 +395,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyFolder.RefreshFolderDocVersions(); // Update List for old value MyFolder.RefreshFolderDocVersions(); // Update List for old value
_FolderID = tmp.FolderID; // Update the value _FolderID = tmp.FolderID; // Update the value
_MyFolder = null; // Reset list so that the next line gets a new list
MyFolder.RefreshFolderDocVersions(); // Update List for new value
} }
_MyFolder = null; // Reset list so that the next line gets a new list
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for new value
_VersionType = tmp.VersionType; _VersionType = tmp.VersionType;
_Name = tmp.Name; _Name = tmp.Name;
_Title = tmp.Title; _Title = tmp.Title;
@ -382,9 +405,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyFormat.RefreshFormatDocVersions(); // Update List for old value MyFormat.RefreshFormatDocVersions(); // Update List for old value
_FormatID = tmp.FormatID; // Update the value _FormatID = tmp.FormatID; // Update the value
_MyFormat = null; // Reset list so that the next line gets a new list
MyFormat.RefreshFormatDocVersions(); // Update List for new value
} }
_MyFormat = null; // Reset list so that the next line gets a new list
if (MyFormat != null) MyFormat.RefreshFormatDocVersions(); // Update List for new value
_Config = tmp.Config; _Config = tmp.Config;
_DTS = tmp.DTS; _DTS = tmp.DTS;
_UserID = tmp.UserID; _UserID = tmp.UserID;
@ -404,7 +427,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<DocVersionInfo>(new PKCriteria(versionID)); tmp = DataPortal.Fetch<DocVersionInfo>(new PKCriteria(versionID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -418,14 +441,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
internal DocVersionInfo(SafeDataReader dr) internal DocVersionInfo(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfo.Constructor", GetHashCode()); _MyDocVersionInfoUnique = ++_DocVersionInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfo.Constructor", GetHashCode());
try try
{ {
ReadData(dr); ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersionInfo.Constructor", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfo.Constructor", ex);
throw new DbCslaException("DocVersionInfo.Constructor", ex); throw new DbCslaException("DocVersionInfo.Constructor", ex);
} }
} }
@ -442,7 +466,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfo.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfo.ReadData", GetHashCode());
try try
{ {
_VersionID = dr.GetInt32("VersionID"); _VersionID = dr.GetInt32("VersionID");
@ -458,14 +482,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersionInfo.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfo.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("DocVersionInfo.ReadData", ex); throw new DbCslaException("DocVersionInfo.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfo.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -493,7 +517,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersionInfo.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("DocVersionInfo.DataPortal_Fetch", ex); throw new DbCslaException("DocVersionInfo.DataPortal_Fetch", ex);
} }
@ -503,7 +527,7 @@ namespace VEPROMS.CSLA.Library
#region extension #region extension
DocVersionInfoExtension _DocVersionInfoExtension = new DocVersionInfoExtension(); DocVersionInfoExtension _DocVersionInfoExtension = new DocVersionInfoExtension();
[Serializable()] [Serializable()]
partial class DocVersionInfoExtension : extensionBase {} partial class DocVersionInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {

View File

@ -138,7 +138,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -158,7 +158,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersionInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex); throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -180,7 +180,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(FolderIDCriteria criteria) private void DataPortal_Fetch(FolderIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchFolderID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchFolderID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -201,7 +201,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersionInfoList.DataPortal_FetchFolderID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfoList.DataPortal_FetchFolderID", ex);
throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex); throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -223,7 +223,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(FormatIDCriteria criteria) private void DataPortal_Fetch(FormatIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchFormatID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchFormatID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -244,7 +244,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersionInfoList.DataPortal_FetchFormatID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfoList.DataPortal_FetchFormatID", ex);
throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex); throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -266,7 +266,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ItemIDCriteria criteria) private void DataPortal_Fetch(ItemIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchItemID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchItemID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -287,7 +287,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersionInfoList.DataPortal_FetchItemID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfoList.DataPortal_FetchItemID", ex);
throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex); throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -348,8 +348,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class DocVersionInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class DocVersionInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private DocVersionInfo Item { get { return (DocVersionInfo) _Item;} } private DocVersionInfo Item { get { return (DocVersionInfo)_Item; } }
public DocVersionInfoListPropertyDescriptor(DocVersionInfoList collection, int index):base(collection, index){;} public DocVersionInfoListPropertyDescriptor(DocVersionInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -360,7 +360,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is DocVersionInfoList) if (destType == typeof(string) && value is DocVersionInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((DocVersionInfoList) value).Items.Count.ToString() + " DocVersions"; return ((DocVersionInfoList)value).Items.Count.ToString() + " DocVersions";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -41,7 +41,7 @@ namespace VEPROMS.CSLA.Library
{ {
foreach (DocumentEntry tmp in _DocumentEntries) foreach (DocumentEntry tmp in _DocumentEntries)
{ {
if(tmp.IsDirty)refreshDocumentEntries.Add(tmp); if (tmp.IsDirty) refreshDocumentEntries.Add(tmp);
} }
} }
} }
@ -65,13 +65,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<Document> _AllList = new List<Document>(); protected static List<Document> _AllList = new List<Document>();
private static Dictionary<string, Document> _AllByPrimaryKey = new Dictionary<string, Document>(); private static Dictionary<string, List<Document>> _AllByPrimaryKey = new Dictionary<string, List<Document>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<Document> remove = new List<Document>(); List<Document> remove = new List<Document>();
foreach (Document tmp in _AllList) foreach (Document tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.DocID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.DocID.ToString()))
{
_AllByPrimaryKey[tmp.DocID.ToString()] = new List<Document>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.DocID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (Document tmp in remove) foreach (Document tmp in remove)
@ -81,7 +85,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = docID.ToString(); string key = docID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -103,7 +107,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DocID",true); CanReadProperty("DocID", true);
return _DocID; return _DocID;
} }
} }
@ -113,13 +117,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("LibTitle",true); CanReadProperty("LibTitle", true);
return _LibTitle; return _LibTitle;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("LibTitle",true); CanWriteProperty("LibTitle", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_LibTitle != value) if (_LibTitle != value)
{ {
@ -137,13 +141,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DocContent",true); CanReadProperty("DocContent", true);
return _DocContent; return _DocContent;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DocContent",true); CanWriteProperty("DocContent", true);
if (_DocContent != value) if (_DocContent != value)
{ {
_DocContent = value; _DocContent = value;
@ -160,13 +164,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DocAscii",true); CanReadProperty("DocAscii", true);
return _DocAscii; return _DocAscii;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DocAscii",true); CanWriteProperty("DocAscii", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_DocAscii != value) if (_DocAscii != value)
{ {
@ -181,13 +185,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -202,13 +206,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -222,13 +226,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -247,7 +251,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DocumentEntryCount",true); CanReadProperty("DocumentEntryCount", true);
return _DocumentEntryCount; return _DocumentEntryCount;
} }
} }
@ -261,21 +265,21 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DocumentEntries",true); CanReadProperty("DocumentEntries", true);
if(_DocumentEntryCount > 0 && _DocumentEntries == null) if (_DocumentEntryCount > 0 && _DocumentEntries == null)
_DocumentEntries = DocumentEntries.GetByDocID(DocID); _DocumentEntries = DocumentEntries.GetByDocID(DocID);
else if(_DocumentEntries == null) else if (_DocumentEntries == null)
_DocumentEntries = DocumentEntries.New(); _DocumentEntries = DocumentEntries.New();
return _DocumentEntries; return _DocumentEntries;
} }
} }
public override bool IsDirty public override bool IsDirty
{ {
get { return base.IsDirty || (_DocumentEntries == null? false : _DocumentEntries.IsDirty); } get { return base.IsDirty || (_DocumentEntries == null ? false : _DocumentEntries.IsDirty); }
} }
public override bool IsValid public override bool IsValid
{ {
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_DocumentEntries == null? true : _DocumentEntries.IsValid); } get { return (IsNew && !IsDirty ? true : base.IsValid) && (_DocumentEntries == null ? true : _DocumentEntries.IsValid); }
} }
// TODO: Replace base Document.ToString function as necessary // TODO: Replace base Document.ToString function as necessary
/// <summary> /// <summary>
@ -298,22 +302,23 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get { get
if(_CheckingBrokenRules)return null; {
if (_CheckingBrokenRules) return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_DocumentEntries != null && (hasBrokenRules = _DocumentEntries.HasBrokenRules) != null) return hasBrokenRules; if (_DocumentEntries != null && (hasBrokenRules = _DocumentEntries.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -430,14 +435,25 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods #region Factory Methods
public int CurrentEditLevel public int CurrentEditLevel
{ get { return EditLevel; } } { get { return EditLevel; } }
private static int _DocumentUnique = 0;
private int _MyDocumentUnique;
public int MyDocumentUnique
{
get { return _MyDocumentUnique; }
}
protected Document() protected Document()
{/* require use of factory methods */ {/* require use of factory methods */
_MyDocumentUnique = ++_DocumentUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(DocID.ToString()); if (!_AllByPrimaryKey.ContainsKey(DocID.ToString())) return;
List<Document> listDocument = _AllByPrimaryKey[DocID.ToString()]; // Get the list of items
listDocument.Remove(this); // Remove the item from the list
if (listDocument.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(DocID.ToString()); // remove the list
} }
public static Document New() public static Document New()
{ {
@ -514,7 +530,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<Document>(new PKCriteria(docID)); tmp = DataPortal.Fetch<Document>(new PKCriteria(docID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -593,7 +609,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Document.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.ReadData", GetHashCode());
try try
{ {
_DocID = dr.GetInt32("DocID"); _DocID = dr.GetInt32("DocID");
@ -609,14 +625,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Document.ReadData", ex); throw new DbCslaException("Document.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Document.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -647,7 +663,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Document.DataPortal_Fetch", ex); throw new DbCslaException("Document.DataPortal_Fetch", ex);
} }
@ -668,13 +684,13 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.DataPortal_Insert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.DataPortal_Insert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Document.DataPortal_Insert", ex); throw new DbCslaException("Document.DataPortal_Insert", ex);
} }
finally finally
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Document.DataPortal_Insert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.DataPortal_Insert", GetHashCode());
} }
} }
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
@ -711,11 +727,11 @@ namespace VEPROMS.CSLA.Library
MarkOld(); MarkOld();
// update child objects // update child objects
if (_DocumentEntries != null) _DocumentEntries.Update(this); if (_DocumentEntries != null) _DocumentEntries.Update(this);
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Document.SQLInsert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.SQLInsert", GetHashCode());
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.SQLInsert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.SQLInsert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Document.SQLInsert", ex); throw new DbCslaException("Document.SQLInsert", ex);
} }
@ -723,7 +739,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int docID, string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID) public static byte[] Add(SqlConnection cn, ref int docID, string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Document.Add", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.Add", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -753,7 +769,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.Add", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.Add", ex);
throw new DbCslaException("Document.Add", ex); throw new DbCslaException("Document.Add", ex);
} }
} }
@ -761,7 +777,7 @@ namespace VEPROMS.CSLA.Library
protected override void DataPortal_Update() protected override void DataPortal_Update()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Document.DataPortal_Update", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.DataPortal_Update", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -775,7 +791,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.DataPortal_Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.DataPortal_Update", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -784,7 +800,7 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate() internal void SQLUpdate()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Document.SQLUpdate", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.SQLUpdate", GetHashCode());
try try
{ {
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
@ -819,7 +835,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.SQLUpdate", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.SQLUpdate", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -841,7 +857,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int docID, string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID, ref byte[] lastChanged) public static byte[] Update(SqlConnection cn, ref int docID, string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID, ref byte[] lastChanged)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Document.Update", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.Update", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -869,7 +885,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.Update", ex);
throw new DbCslaException("Document.Update", ex); throw new DbCslaException("Document.Update", ex);
} }
} }
@ -881,7 +897,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria) private void DataPortal_Delete(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Document.DataPortal_Delete", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.DataPortal_Delete", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -897,7 +913,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.DataPortal_Delete", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.DataPortal_Delete", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Document.DataPortal_Delete", ex); throw new DbCslaException("Document.DataPortal_Delete", ex);
} }
@ -905,7 +921,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int docID) public static void Remove(SqlConnection cn, int docID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Document.Remove", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.Remove", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -920,7 +936,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.Remove", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.Remove", ex);
throw new DbCslaException("Document.Remove", ex); throw new DbCslaException("Document.Remove", ex);
} }
} }
@ -954,7 +970,7 @@ namespace VEPROMS.CSLA.Library
} }
protected override void DataPortal_Execute() protected override void DataPortal_Execute()
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Document.DataPortal_Execute", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.DataPortal_Execute", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -972,7 +988,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.DataPortal_Execute", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.DataPortal_Execute", ex);
throw new DbCslaException("Document.DataPortal_Execute", ex); throw new DbCslaException("Document.DataPortal_Execute", ex);
} }
} }

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public DocumentEntry Add(Entry myEntry) // One to Many public DocumentEntry Add(Entry myEntry) // One to Many
{ {
DocumentEntry entry = DocumentEntry.New(myEntry); DocumentEntry entry = DocumentEntry.New(myEntry);
this.Add(entry); this.Add(entry);
return entry; return entry;
} }
public void Remove(Entry myEntry) public void Remove(Entry myEntry)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(DocumentEntry documentEntry in this) foreach (DocumentEntry documentEntry in this)
if ((hasBrokenRules = documentEntry.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = documentEntry.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(DocIDCriteria criteria) private void DataPortal_Fetch(DocIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocumentEntries.DataPortal_FetchDocID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentEntries.DataPortal_FetchDocID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocumentEntries.DataPortal_FetchDocID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentEntries.DataPortal_FetchDocID", ex);
throw new DbCslaException("DocumentEntries.DataPortal_Fetch", ex); throw new DbCslaException("DocumentEntries.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class DocumentEntriesPropertyDescriptor : vlnListPropertyDescriptor public partial class DocumentEntriesPropertyDescriptor : vlnListPropertyDescriptor
{ {
private DocumentEntry Item { get { return (DocumentEntry) _Item;} } private DocumentEntry Item { get { return (DocumentEntry)_Item; } }
public DocumentEntriesPropertyDescriptor(DocumentEntries collection, int index):base(collection, index){;} public DocumentEntriesPropertyDescriptor(DocumentEntries collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is DocumentEntries) if (destType == typeof(string) && value is DocumentEntries)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((DocumentEntries) value).Items.Count.ToString() + " Entries"; return ((DocumentEntries)value).Items.Count.ToString() + " Entries";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentID",true); CanReadProperty("ContentID", true);
if (_MyEntry != null) _ContentID = _MyEntry.ContentID; if (_MyEntry != null) _ContentID = _MyEntry.ContentID;
return _ContentID; return _ContentID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyEntry",true); CanReadProperty("MyEntry", true);
if (_MyEntry == null && _ContentID != 0) _MyEntry = Entry.Get(_ContentID); if (_MyEntry == null && _ContentID != 0) _MyEntry = Entry.Get(_ContentID);
return _MyEntry; return _MyEntry;
} }
@ -65,13 +65,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -85,13 +85,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -107,7 +107,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_Number",true); CanReadProperty("Content_Number", true);
return _Content_Number; return _Content_Number;
} }
} }
@ -117,7 +117,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_Text",true); CanReadProperty("Content_Text", true);
return _Content_Text; return _Content_Text;
} }
} }
@ -130,7 +130,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_Type",true); CanReadProperty("Content_Type", true);
return _Content_Type; return _Content_Type;
} }
} }
@ -140,7 +140,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_FormatID",true); CanReadProperty("Content_FormatID", true);
return _Content_FormatID; return _Content_FormatID;
} }
} }
@ -150,7 +150,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_Config",true); CanReadProperty("Content_Config", true);
return _Content_Config; return _Content_Config;
} }
} }
@ -160,7 +160,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_DTS",true); CanReadProperty("Content_DTS", true);
return _Content_DTS; return _Content_DTS;
} }
} }
@ -170,7 +170,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_UserID",true); CanReadProperty("Content_UserID", true);
return _Content_UserID; return _Content_UserID;
} }
} }
@ -195,22 +195,22 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -306,7 +306,7 @@ namespace VEPROMS.CSLA.Library
// TODO: Add any initialization & defaults // TODO: Add any initialization & defaults
_DTS = _DocumentEntryExtension.DefaultDTS; _DTS = _DocumentEntryExtension.DefaultDTS;
_UserID = _DocumentEntryExtension.DefaultUserID; _UserID = _DocumentEntryExtension.DefaultUserID;
_MyEntry = myEntry; _MyEntry = myEntry;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal DocumentEntry(SafeDataReader dr) internal DocumentEntry(SafeDataReader dr)
@ -318,7 +318,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocumentEntry.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentEntry.FetchDR", GetHashCode());
try try
{ {
_ContentID = dr.GetInt32("ContentID"); _ContentID = dr.GetInt32("ContentID");
@ -335,7 +335,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocumentEntry.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentEntry.FetchDR", ex);
throw new DbCslaException("DocumentEntry.Fetch", ex); throw new DbCslaException("DocumentEntry.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<DocumentInfo> _AllList = new List<DocumentInfo>(); protected static List<DocumentInfo> _AllList = new List<DocumentInfo>();
private static Dictionary<string, DocumentInfo> _AllByPrimaryKey = new Dictionary<string, DocumentInfo>(); private static Dictionary<string, List<DocumentInfo>> _AllByPrimaryKey = new Dictionary<string, List<DocumentInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<DocumentInfo> remove = new List<DocumentInfo>(); List<DocumentInfo> remove = new List<DocumentInfo>();
foreach (DocumentInfo tmp in _AllList) foreach (DocumentInfo tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.DocID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.DocID.ToString()))
{
_AllByPrimaryKey[tmp.DocID.ToString()] = new List<DocumentInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.DocID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (DocumentInfo tmp in remove) foreach (DocumentInfo tmp in remove)
@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = docID.ToString(); string key = docID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DocID",true); CanReadProperty("DocID", true);
return _DocID; return _DocID;
} }
} }
@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("LibTitle",true); CanReadProperty("LibTitle", true);
return _LibTitle; return _LibTitle;
} }
} }
@ -108,7 +112,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DocContent",true); CanReadProperty("DocContent", true);
return _DocContent; return _DocContent;
} }
} }
@ -121,7 +125,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DocAscii",true); CanReadProperty("DocAscii", true);
return _DocAscii; return _DocAscii;
} }
} }
@ -131,7 +135,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
} }
@ -141,7 +145,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -151,7 +155,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
} }
@ -164,7 +168,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DocumentEntryCount",true); CanReadProperty("DocumentEntryCount", true);
return _DocumentEntryCount; return _DocumentEntryCount;
} }
} }
@ -175,7 +179,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DocumentEntries",true); CanReadProperty("DocumentEntries", true);
if (_DocumentEntryCount < 0 || (_DocumentEntryCount > 0 && _DocumentEntries == null)) if (_DocumentEntryCount < 0 || (_DocumentEntryCount > 0 && _DocumentEntries == null))
_DocumentEntries = EntryInfoList.GetByDocID(_DocID); _DocumentEntries = EntryInfoList.GetByDocID(_DocID);
if (_DocumentEntryCount < 0) if (_DocumentEntryCount < 0)
@ -185,7 +189,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshDocumentEntries() internal void RefreshDocumentEntries()
{ {
_DocumentEntryCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_DocID.ToString()))
foreach (DocumentInfo tmp in _AllByPrimaryKey[_DocID.ToString()])
tmp._DocumentEntryCount = -1; // This will cause the data to be requeried
} }
// TODO: Replace base DocumentInfo.ToString function as necessary // TODO: Replace base DocumentInfo.ToString function as necessary
/// <summary> /// <summary>
@ -207,14 +214,25 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _DocumentInfoUnique = 0;
private int _MyDocumentInfoUnique;
public int MyDocumentInfoUnique
{
get { return _MyDocumentInfoUnique; }
}
private DocumentInfo() private DocumentInfo()
{/* require use of factory methods */ {/* require use of factory methods */
_MyDocumentInfoUnique = ++_DocumentInfoUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(DocID.ToString()); if (!_AllByPrimaryKey.ContainsKey(DocID.ToString())) return;
List<DocumentInfo> listDocumentInfo = _AllByPrimaryKey[DocID.ToString()]; // Get the list of items
listDocumentInfo.Remove(this); // Remove the item from the list
if (listDocumentInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(DocID.ToString()); // remove the list
} }
public virtual Document Get() public virtual Document Get()
{ {
@ -222,9 +240,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(Document tmp) public static void Refresh(Document tmp)
{ {
DocumentInfo tmpInfo = GetExistingByPrimaryKey(tmp.DocID); string key = tmp.DocID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (DocumentInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(Document tmp) private void RefreshFields(Document tmp)
{ {
@ -247,7 +267,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<DocumentInfo>(new PKCriteria(docID)); tmp = DataPortal.Fetch<DocumentInfo>(new PKCriteria(docID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -261,14 +281,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
internal DocumentInfo(SafeDataReader dr) internal DocumentInfo(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocumentInfo.Constructor", GetHashCode()); _MyDocumentInfoUnique = ++_DocumentInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfo.Constructor", GetHashCode());
try try
{ {
ReadData(dr); ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocumentInfo.Constructor", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfo.Constructor", ex);
throw new DbCslaException("DocumentInfo.Constructor", ex); throw new DbCslaException("DocumentInfo.Constructor", ex);
} }
} }
@ -285,7 +306,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocumentInfo.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfo.ReadData", GetHashCode());
try try
{ {
_DocID = dr.GetInt32("DocID"); _DocID = dr.GetInt32("DocID");
@ -299,14 +320,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocumentInfo.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfo.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("DocumentInfo.ReadData", ex); throw new DbCslaException("DocumentInfo.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocumentInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfo.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -334,7 +355,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocumentInfo.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("DocumentInfo.DataPortal_Fetch", ex); throw new DbCslaException("DocumentInfo.DataPortal_Fetch", ex);
} }
@ -344,7 +365,7 @@ namespace VEPROMS.CSLA.Library
#region extension #region extension
DocumentInfoExtension _DocumentInfoExtension = new DocumentInfoExtension(); DocumentInfoExtension _DocumentInfoExtension = new DocumentInfoExtension();
[Serializable()] [Serializable()]
partial class DocumentInfoExtension : extensionBase {} partial class DocumentInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {

View File

@ -96,7 +96,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocumentInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -116,7 +116,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocumentInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("DocumentInfoList.DataPortal_Fetch", ex); throw new DbCslaException("DocumentInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -177,8 +177,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class DocumentInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class DocumentInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private DocumentInfo Item { get { return (DocumentInfo) _Item;} } private DocumentInfo Item { get { return (DocumentInfo)_Item; } }
public DocumentInfoListPropertyDescriptor(DocumentInfoList collection, int index):base(collection, index){;} public DocumentInfoListPropertyDescriptor(DocumentInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -189,7 +189,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is DocumentInfoList) if (destType == typeof(string) && value is DocumentInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((DocumentInfoList) value).Items.Count.ToString() + " Documents"; return ((DocumentInfoList)value).Items.Count.ToString() + " Documents";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -47,19 +47,23 @@ namespace VEPROMS.CSLA.Library
foreach (Entry tmp in _RefreshEntries) foreach (Entry tmp in _RefreshEntries)
{ {
EntryInfo.Refresh(tmp); EntryInfo.Refresh(tmp);
if(tmp._MyDocument != null) DocumentInfo.Refresh(tmp._MyDocument); if (tmp._MyDocument != null) DocumentInfo.Refresh(tmp._MyDocument);
} }
} }
#endregion #endregion
#region Collection #region Collection
protected static List<Entry> _AllList = new List<Entry>(); protected static List<Entry> _AllList = new List<Entry>();
private static Dictionary<string, Entry> _AllByPrimaryKey = new Dictionary<string, Entry>(); private static Dictionary<string, List<Entry>> _AllByPrimaryKey = new Dictionary<string, List<Entry>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<Entry> remove = new List<Entry>(); List<Entry> remove = new List<Entry>();
foreach (Entry tmp in _AllList) foreach (Entry tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.ContentID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
{
_AllByPrimaryKey[tmp.ContentID.ToString()] = new List<Entry>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (Entry tmp in remove) foreach (Entry tmp in remove)
@ -69,7 +73,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = contentID.ToString(); string key = contentID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -86,7 +90,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentID",true); CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID; if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID; return _ContentID;
} }
@ -98,7 +102,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyContent",true); CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID); if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID);
return _MyContent; return _MyContent;
} }
@ -109,7 +113,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DocID",true); CanReadProperty("DocID", true);
if (_MyDocument != null) _DocID = _MyDocument.DocID; if (_MyDocument != null) _DocID = _MyDocument.DocID;
return _DocID; return _DocID;
} }
@ -120,14 +124,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyDocument",true); CanReadProperty("MyDocument", true);
if (_MyDocument == null && _DocID != 0) _MyDocument = Document.Get(_DocID); if (_MyDocument == null && _DocID != 0) _MyDocument = Document.Get(_DocID);
return _MyDocument; return _MyDocument;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyDocument",true); CanWriteProperty("MyDocument", true);
if (_MyDocument != value) if (_MyDocument != value)
{ {
_MyDocument = value; _MyDocument = value;
@ -141,13 +145,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -161,13 +165,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -179,11 +183,11 @@ namespace VEPROMS.CSLA.Library
private byte[] _LastChanged = new byte[8];//timestamp private byte[] _LastChanged = new byte[8];//timestamp
public override bool IsDirty public override bool IsDirty
{ {
get { return base.IsDirty || (_MyDocument == null? false : _MyDocument.IsDirty); } get { return base.IsDirty || (_MyDocument == null ? false : _MyDocument.IsDirty); }
} }
public override bool IsValid public override bool IsValid
{ {
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyDocument == null? true : _MyDocument.IsValid); } get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyDocument == null ? true : _MyDocument.IsValid); }
} }
// TODO: Replace base Entry.ToString function as necessary // TODO: Replace base Entry.ToString function as necessary
/// <summary> /// <summary>
@ -206,22 +210,23 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get { get
if(_CheckingBrokenRules)return null; {
if (_CheckingBrokenRules) return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyDocument != null && (hasBrokenRules = _MyDocument.HasBrokenRules) != null) return hasBrokenRules; if (_MyDocument != null && (hasBrokenRules = _MyDocument.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -320,14 +325,25 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods #region Factory Methods
public int CurrentEditLevel public int CurrentEditLevel
{ get { return EditLevel; } } { get { return EditLevel; } }
private static int _EntryUnique = 0;
private int _MyEntryUnique;
public int MyEntryUnique
{
get { return _MyEntryUnique; }
}
protected Entry() protected Entry()
{/* require use of factory methods */ {/* require use of factory methods */
_MyEntryUnique = ++_EntryUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(ContentID.ToString()); if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString())) return;
List<Entry> listEntry = _AllByPrimaryKey[ContentID.ToString()]; // Get the list of items
listEntry.Remove(this); // Remove the item from the list
if (listEntry.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(ContentID.ToString()); // remove the list
} }
public static Entry New() public static Entry New()
{ {
@ -392,7 +408,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<Entry>(new PKCriteria(contentID)); tmp = DataPortal.Fetch<Entry>(new PKCriteria(contentID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -471,7 +487,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.ReadData", GetHashCode());
try try
{ {
_ContentID = dr.GetInt32("ContentID"); _ContentID = dr.GetInt32("ContentID");
@ -483,14 +499,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Entry.ReadData", ex); throw new DbCslaException("Entry.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -518,7 +534,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Entry.DataPortal_Fetch", ex); throw new DbCslaException("Entry.DataPortal_Fetch", ex);
} }
@ -539,13 +555,13 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.DataPortal_Insert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.DataPortal_Insert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Entry.DataPortal_Insert", ex); throw new DbCslaException("Entry.DataPortal_Insert", ex);
} }
finally finally
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.DataPortal_Insert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.DataPortal_Insert", GetHashCode());
} }
} }
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
@ -554,7 +570,7 @@ namespace VEPROMS.CSLA.Library
if (!this.IsDirty) return; if (!this.IsDirty) return;
try try
{ {
if(_MyDocument != null) _MyDocument.Update(); if (_MyDocument != null) _MyDocument.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
{ {
@ -576,11 +592,11 @@ namespace VEPROMS.CSLA.Library
} }
MarkOld(); MarkOld();
// update child objects // update child objects
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.SQLInsert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.SQLInsert", GetHashCode());
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.SQLInsert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.SQLInsert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Entry.SQLInsert", ex); throw new DbCslaException("Entry.SQLInsert", ex);
} }
@ -588,7 +604,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, Content myContent, Document myDocument, DateTime dts, string userID) public static byte[] Add(SqlConnection cn, Content myContent, Document myDocument, DateTime dts, string userID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.Add", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.Add", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -612,7 +628,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.Add", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.Add", ex);
throw new DbCslaException("Entry.Add", ex); throw new DbCslaException("Entry.Add", ex);
} }
} }
@ -620,7 +636,7 @@ namespace VEPROMS.CSLA.Library
protected override void DataPortal_Update() protected override void DataPortal_Update()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.DataPortal_Update", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.DataPortal_Update", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -634,7 +650,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.DataPortal_Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.DataPortal_Update", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -643,10 +659,10 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate() internal void SQLUpdate()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.SQLUpdate", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.SQLUpdate", GetHashCode());
try try
{ {
if(_MyDocument != null) _MyDocument.Update(); if (_MyDocument != null) _MyDocument.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty) if (base.IsDirty)
{ {
@ -675,7 +691,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.SQLUpdate", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.SQLUpdate", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -685,18 +701,18 @@ namespace VEPROMS.CSLA.Library
if (!this.IsDirty) return; if (!this.IsDirty) return;
if (base.IsDirty) if (base.IsDirty)
{ {
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (IsNew) if (IsNew)
_LastChanged = Entry.Add(cn, content, MyDocument, _DTS, _UserID); _LastChanged = Entry.Add(cn, content, MyDocument, _DTS, _UserID);
else else
_LastChanged = Entry.Update(cn, content, MyDocument, _DTS, _UserID, ref _LastChanged); _LastChanged = Entry.Update(cn, content, MyDocument, _DTS, _UserID, ref _LastChanged);
MarkOld(); MarkOld();
} }
} }
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, Content myContent, Document myDocument, DateTime dts, string userID, ref byte[] lastChanged) public static byte[] Update(SqlConnection cn, Content myContent, Document myDocument, DateTime dts, string userID, ref byte[] lastChanged)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.Update", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.Update", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -721,7 +737,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.Update", ex);
throw new DbCslaException("Entry.Update", ex); throw new DbCslaException("Entry.Update", ex);
} }
} }
@ -733,7 +749,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria) private void DataPortal_Delete(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.DataPortal_Delete", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.DataPortal_Delete", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -749,7 +765,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.DataPortal_Delete", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.DataPortal_Delete", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Entry.DataPortal_Delete", ex); throw new DbCslaException("Entry.DataPortal_Delete", ex);
} }
@ -757,7 +773,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int contentID) public static void Remove(SqlConnection cn, int contentID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.Remove", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.Remove", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -772,7 +788,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.Remove", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.Remove", ex);
throw new DbCslaException("Entry.Remove", ex); throw new DbCslaException("Entry.Remove", ex);
} }
} }
@ -806,7 +822,7 @@ namespace VEPROMS.CSLA.Library
} }
protected override void DataPortal_Execute() protected override void DataPortal_Execute()
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.DataPortal_Execute", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.DataPortal_Execute", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -824,7 +840,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.DataPortal_Execute", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.DataPortal_Execute", ex);
throw new DbCslaException("Entry.DataPortal_Execute", ex); throw new DbCslaException("Entry.DataPortal_Execute", ex);
} }
} }

View File

@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<EntryInfo> _AllList = new List<EntryInfo>(); protected static List<EntryInfo> _AllList = new List<EntryInfo>();
private static Dictionary<string, EntryInfo> _AllByPrimaryKey = new Dictionary<string, EntryInfo>(); private static Dictionary<string, List<EntryInfo>> _AllByPrimaryKey = new Dictionary<string, List<EntryInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<EntryInfo> remove = new List<EntryInfo>(); List<EntryInfo> remove = new List<EntryInfo>();
foreach (EntryInfo tmp in _AllList) foreach (EntryInfo tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.ContentID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
{
_AllByPrimaryKey[tmp.ContentID.ToString()] = new List<EntryInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (EntryInfo tmp in remove) foreach (EntryInfo tmp in remove)
@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = contentID.ToString(); string key = contentID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentID",true); CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID; if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID; return _ContentID;
} }
@ -97,7 +101,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyContent",true); CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID); if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent; return _MyContent;
} }
@ -108,7 +112,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DocID",true); CanReadProperty("DocID", true);
if (_MyDocument != null) _DocID = _MyDocument.DocID; if (_MyDocument != null) _DocID = _MyDocument.DocID;
return _DocID; return _DocID;
} }
@ -119,7 +123,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyDocument",true); CanReadProperty("MyDocument", true);
if (_MyDocument == null && _DocID != 0) _MyDocument = DocumentInfo.Get(_DocID); if (_MyDocument == null && _DocID != 0) _MyDocument = DocumentInfo.Get(_DocID);
return _MyDocument; return _MyDocument;
} }
@ -130,7 +134,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -140,7 +144,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
} }
@ -164,14 +168,25 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _EntryInfoUnique = 0;
private int _MyEntryInfoUnique;
public int MyEntryInfoUnique
{
get { return _MyEntryInfoUnique; }
}
private EntryInfo() private EntryInfo()
{/* require use of factory methods */ {/* require use of factory methods */
_MyEntryInfoUnique = ++_EntryInfoUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(ContentID.ToString()); if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString())) return;
List<EntryInfo> listEntryInfo = _AllByPrimaryKey[ContentID.ToString()]; // Get the list of items
listEntryInfo.Remove(this); // Remove the item from the list
if (listEntryInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(ContentID.ToString()); // remove the list
} }
public virtual Entry Get() public virtual Entry Get()
{ {
@ -179,9 +194,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(Entry tmp) public static void Refresh(Entry tmp)
{ {
EntryInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID); string key = tmp.ContentID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (EntryInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(Entry tmp) private void RefreshFields(Entry tmp)
{ {
@ -189,9 +206,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyDocument.RefreshDocumentEntries(); // Update List for old value MyDocument.RefreshDocumentEntries(); // Update List for old value
_DocID = tmp.DocID; // Update the value _DocID = tmp.DocID; // Update the value
_MyDocument = null; // Reset list so that the next line gets a new list
MyDocument.RefreshDocumentEntries(); // Update List for new value
} }
_MyDocument = null; // Reset list so that the next line gets a new list
if (MyDocument != null) MyDocument.RefreshDocumentEntries(); // Update List for new value
_DTS = tmp.DTS; _DTS = tmp.DTS;
_UserID = tmp.UserID; _UserID = tmp.UserID;
_EntryInfoExtension.Refresh(this); _EntryInfoExtension.Refresh(this);
@ -201,9 +218,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(DocumentEntry tmp) public static void Refresh(DocumentEntry tmp)
{ {
EntryInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID); string key = tmp.ContentID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (EntryInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(DocumentEntry tmp) private void RefreshFields(DocumentEntry tmp)
{ {
@ -224,7 +243,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<EntryInfo>(new PKCriteria(contentID)); tmp = DataPortal.Fetch<EntryInfo>(new PKCriteria(contentID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") if (tmp.ErrorMessage == "No Record Found")
{ {
@ -241,14 +260,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
internal EntryInfo(SafeDataReader dr) internal EntryInfo(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] EntryInfo.Constructor", GetHashCode()); _MyEntryInfoUnique = ++_EntryInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.Constructor", GetHashCode());
try try
{ {
ReadData(dr); ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("EntryInfo.Constructor", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.Constructor", ex);
throw new DbCslaException("EntryInfo.Constructor", ex); throw new DbCslaException("EntryInfo.Constructor", ex);
} }
} }
@ -265,7 +285,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] EntryInfo.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.ReadData", GetHashCode());
try try
{ {
_ContentID = dr.GetInt32("ContentID"); _ContentID = dr.GetInt32("ContentID");
@ -275,14 +295,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("EntryInfo.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("EntryInfo.ReadData", ex); throw new DbCslaException("EntryInfo.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] EntryInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -310,7 +330,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("EntryInfo.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("EntryInfo.DataPortal_Fetch", ex); throw new DbCslaException("EntryInfo.DataPortal_Fetch", ex);
} }
@ -320,7 +340,7 @@ namespace VEPROMS.CSLA.Library
#region extension #region extension
EntryInfoExtension _EntryInfoExtension = new EntryInfoExtension(); EntryInfoExtension _EntryInfoExtension = new EntryInfoExtension();
[Serializable()] [Serializable()]
partial class EntryInfoExtension : extensionBase {} partial class EntryInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {

View File

@ -124,7 +124,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] EntryInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -144,7 +144,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("EntryInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("EntryInfoList.DataPortal_Fetch", ex); throw new DbCslaException("EntryInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -166,7 +166,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ContentIDCriteria criteria) private void DataPortal_Fetch(ContentIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] EntryInfoList.DataPortal_FetchContentID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfoList.DataPortal_FetchContentID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -187,7 +187,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("EntryInfoList.DataPortal_FetchContentID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfoList.DataPortal_FetchContentID", ex);
throw new DbCslaException("EntryInfoList.DataPortal_Fetch", ex); throw new DbCslaException("EntryInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -209,7 +209,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(DocIDCriteria criteria) private void DataPortal_Fetch(DocIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] EntryInfoList.DataPortal_FetchDocID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfoList.DataPortal_FetchDocID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -230,7 +230,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("EntryInfoList.DataPortal_FetchDocID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfoList.DataPortal_FetchDocID", ex);
throw new DbCslaException("EntryInfoList.DataPortal_Fetch", ex); throw new DbCslaException("EntryInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -291,8 +291,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class EntryInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class EntryInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private EntryInfo Item { get { return (EntryInfo) _Item;} } private EntryInfo Item { get { return (EntryInfo)_Item; } }
public EntryInfoListPropertyDescriptor(EntryInfoList collection, int index):base(collection, index){;} public EntryInfoListPropertyDescriptor(EntryInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -303,7 +303,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is EntryInfoList) if (destType == typeof(string) && value is EntryInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((EntryInfoList) value).Items.Count.ToString() + " Entries"; return ((EntryInfoList)value).Items.Count.ToString() + " Entries";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -42,14 +42,14 @@ namespace VEPROMS.CSLA.Library
{ {
foreach (FolderAssignment tmp in _FolderAssignments) foreach (FolderAssignment tmp in _FolderAssignments)
{ {
if(tmp.IsDirty)refreshFolderAssignments.Add(tmp); if (tmp.IsDirty) refreshFolderAssignments.Add(tmp);
} }
} }
if (_FolderDocVersions != null && _FolderDocVersions.IsDirty) if (_FolderDocVersions != null && _FolderDocVersions.IsDirty)
{ {
foreach (FolderDocVersion tmp in _FolderDocVersions) foreach (FolderDocVersion tmp in _FolderDocVersions)
{ {
if(tmp.IsDirty)refreshFolderDocVersions.Add(tmp); if (tmp.IsDirty) refreshFolderDocVersions.Add(tmp);
} }
} }
if (_ChildFolders != null && _ChildFolders.IsDirty) if (_ChildFolders != null && _ChildFolders.IsDirty)
@ -72,8 +72,8 @@ namespace VEPROMS.CSLA.Library
foreach (Folder tmp in _RefreshFolders) foreach (Folder tmp in _RefreshFolders)
{ {
FolderInfo.Refresh(tmp); FolderInfo.Refresh(tmp);
if(tmp._MyConnection != null) ConnectionInfo.Refresh(tmp._MyConnection); if (tmp._MyConnection != null) ConnectionInfo.Refresh(tmp._MyConnection);
if(tmp._MyFormat != null) FormatInfo.Refresh(tmp._MyFormat); if (tmp._MyFormat != null) FormatInfo.Refresh(tmp._MyFormat);
} }
foreach (FolderAssignment tmp in _RefreshFolderAssignments) foreach (FolderAssignment tmp in _RefreshFolderAssignments)
{ {
@ -87,15 +87,20 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<Folder> _AllList = new List<Folder>(); protected static List<Folder> _AllList = new List<Folder>();
private static Dictionary<string, Folder> _AllByPrimaryKey = new Dictionary<string, Folder>(); private static Dictionary<string, List<Folder>> _AllByPrimaryKey = new Dictionary<string, List<Folder>>();
private static Dictionary<string, Folder> _AllByParentID_Name = new Dictionary<string, Folder>(); private static Dictionary<string, List<Folder>> _AllByParentID_Name = new Dictionary<string, List<Folder>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<Folder> remove = new List<Folder>(); List<Folder> remove = new List<Folder>();
foreach (Folder tmp in _AllList) foreach (Folder tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.FolderID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.FolderID.ToString()))
_AllByParentID_Name[tmp.ParentID.ToString() + "_" + tmp.Name.ToString()] = tmp; // Unique Index {
_AllByPrimaryKey[tmp.FolderID.ToString()] = new List<Folder>(); // Add new list for PrimaryKey
_AllByParentID_Name[tmp.ParentID.ToString() + "_" + tmp.Name.ToString()] = new List<Folder>(); // Add new list for ParentID_Name
}
_AllByPrimaryKey[tmp.FolderID.ToString()].Add(tmp); // Add to Primary Key list
_AllByParentID_Name[tmp.ParentID.ToString() + "_" + tmp.Name.ToString()].Add(tmp); // Unique Index
remove.Add(tmp); remove.Add(tmp);
} }
foreach (Folder tmp in remove) foreach (Folder tmp in remove)
@ -105,14 +110,14 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = folderID.ToString(); string key = folderID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
public static Folder GetExistingByParentID_Name(int parentID, string name) public static Folder GetExistingByParentID_Name(int parentID, string name)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = parentID.ToString() + "_" + name.ToString(); string key = parentID.ToString() + "_" + name.ToString();
if (_AllByParentID_Name.ContainsKey(key)) return _AllByParentID_Name[key]; if (_AllByParentID_Name.ContainsKey(key)) return _AllByParentID_Name[key][0];
return null; return null;
} }
#endregion #endregion
@ -134,7 +139,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderID",true); CanReadProperty("FolderID", true);
return _FolderID; return _FolderID;
} }
} }
@ -144,7 +149,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ParentID",true); CanReadProperty("ParentID", true);
if (_MyParent != null) _ParentID = _MyParent.FolderID; if (_MyParent != null) _ParentID = _MyParent.FolderID;
return _ParentID; return _ParentID;
} }
@ -155,14 +160,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyParent",true); CanReadProperty("MyParent", true);
if (_MyParent == null && _ParentID != _FolderID) _MyParent = Folder.Get(_ParentID); if (_MyParent == null && _ParentID != _FolderID) _MyParent = Folder.Get(_ParentID);
return _MyParent; return _MyParent;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyParent",true); CanWriteProperty("MyParent", true);
if (_MyParent != value) if (_MyParent != value)
{ {
_MyParent = value; _MyParent = value;
@ -176,7 +181,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DBID",true); CanReadProperty("DBID", true);
if (_MyConnection != null) _DBID = _MyConnection.DBID; if (_MyConnection != null) _DBID = _MyConnection.DBID;
return _DBID; return _DBID;
} }
@ -187,14 +192,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyConnection",true); CanReadProperty("MyConnection", true);
if (_MyConnection == null && _DBID != 0) _MyConnection = Connection.Get(_DBID); if (_MyConnection == null && _DBID != 0) _MyConnection = Connection.Get(_DBID);
return _MyConnection; return _MyConnection;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyConnection",true); CanWriteProperty("MyConnection", true);
if (_MyConnection != value) if (_MyConnection != value)
{ {
_MyConnection = value; _MyConnection = value;
@ -208,13 +213,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name",true); CanReadProperty("Name", true);
return _Name; return _Name;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Name",true); CanWriteProperty("Name", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Name != value) if (_Name != value)
{ {
@ -229,13 +234,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Title",true); CanReadProperty("Title", true);
return _Title; return _Title;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Title",true); CanWriteProperty("Title", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Title != value) if (_Title != value)
{ {
@ -250,13 +255,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ShortName",true); CanReadProperty("ShortName", true);
return _ShortName; return _ShortName;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("ShortName",true); CanWriteProperty("ShortName", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_ShortName != value) if (_ShortName != value)
{ {
@ -271,7 +276,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatID",true); CanReadProperty("FormatID", true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID; if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID; return _FormatID;
} }
@ -282,18 +287,18 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFormat",true); CanReadProperty("MyFormat", true);
if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID); if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID);
return _MyFormat; return _MyFormat;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyFormat",true); CanWriteProperty("MyFormat", true);
if (_MyFormat != value) if (_MyFormat != value)
{ {
_MyFormat = value; _MyFormat = value;
_FormatID = (value == null ? null : (int?) value.FormatID); _FormatID = (value == null ? null : (int?)value.FormatID);
PropertyHasChanged(); PropertyHasChanged();
} }
} }
@ -304,13 +309,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -325,13 +330,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -345,13 +350,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UsrID",true); CanWriteProperty("UsrID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UsrID != value) if (_UsrID != value)
{ {
@ -370,7 +375,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderAssignmentCount",true); CanReadProperty("FolderAssignmentCount", true);
return _FolderAssignmentCount; return _FolderAssignmentCount;
} }
} }
@ -384,10 +389,10 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderAssignments",true); CanReadProperty("FolderAssignments", true);
if(_FolderAssignmentCount > 0 && _FolderAssignments == null) if (_FolderAssignmentCount > 0 && _FolderAssignments == null)
_FolderAssignments = FolderAssignments.GetByFolderID(FolderID); _FolderAssignments = FolderAssignments.GetByFolderID(FolderID);
else if(_FolderAssignments == null) else if (_FolderAssignments == null)
_FolderAssignments = FolderAssignments.New(); _FolderAssignments = FolderAssignments.New();
return _FolderAssignments; return _FolderAssignments;
} }
@ -401,7 +406,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderDocVersionCount",true); CanReadProperty("FolderDocVersionCount", true);
return _FolderDocVersionCount; return _FolderDocVersionCount;
} }
} }
@ -415,10 +420,10 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderDocVersions",true); CanReadProperty("FolderDocVersions", true);
if(_FolderDocVersionCount > 0 && _FolderDocVersions == null) if (_FolderDocVersionCount > 0 && _FolderDocVersions == null)
_FolderDocVersions = FolderDocVersions.GetByFolderID(FolderID); _FolderDocVersions = FolderDocVersions.GetByFolderID(FolderID);
else if(_FolderDocVersions == null) else if (_FolderDocVersions == null)
_FolderDocVersions = FolderDocVersions.New(); _FolderDocVersions = FolderDocVersions.New();
return _FolderDocVersions; return _FolderDocVersions;
} }
@ -432,7 +437,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ChildFolderCount",true); CanReadProperty("ChildFolderCount", true);
return _ChildFolderCount; return _ChildFolderCount;
} }
} }
@ -446,21 +451,21 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ChildFolders",true); CanReadProperty("ChildFolders", true);
if(_ChildFolderCount > 0 && _ChildFolders == null) if (_ChildFolderCount > 0 && _ChildFolders == null)
_ChildFolders = ChildFolders.GetByParentID(FolderID); _ChildFolders = ChildFolders.GetByParentID(FolderID);
else if(_ChildFolders == null) else if (_ChildFolders == null)
_ChildFolders = ChildFolders.New(); _ChildFolders = ChildFolders.New();
return _ChildFolders; return _ChildFolders;
} }
} }
public override bool IsDirty public override bool IsDirty
{ {
get { return base.IsDirty || (_FolderAssignments == null? false : _FolderAssignments.IsDirty) || (_FolderDocVersions == null? false : _FolderDocVersions.IsDirty) || (_ChildFolders == null? false : _ChildFolders.IsDirty) || (_MyConnection == null? false : _MyConnection.IsDirty) || (_MyFormat == null? false : _MyFormat.IsDirty); } get { return base.IsDirty || (_FolderAssignments == null ? false : _FolderAssignments.IsDirty) || (_FolderDocVersions == null ? false : _FolderDocVersions.IsDirty) || (_ChildFolders == null ? false : _ChildFolders.IsDirty) || (_MyConnection == null ? false : _MyConnection.IsDirty) || (_MyFormat == null ? false : _MyFormat.IsDirty); }
} }
public override bool IsValid public override bool IsValid
{ {
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_FolderAssignments == null? true : _FolderAssignments.IsValid) && (_FolderDocVersions == null? true : _FolderDocVersions.IsValid) && (_ChildFolders == null? true : _ChildFolders.IsValid) && (_MyConnection == null? true : _MyConnection.IsValid) && (_MyFormat == null? true : _MyFormat.IsValid); } get { return (IsNew && !IsDirty ? true : base.IsValid) && (_FolderAssignments == null ? true : _FolderAssignments.IsValid) && (_FolderDocVersions == null ? true : _FolderDocVersions.IsValid) && (_ChildFolders == null ? true : _ChildFolders.IsValid) && (_MyConnection == null ? true : _MyConnection.IsValid) && (_MyFormat == null ? true : _MyFormat.IsValid); }
} }
// TODO: Replace base Folder.ToString function as necessary // TODO: Replace base Folder.ToString function as necessary
/// <summary> /// <summary>
@ -483,26 +488,27 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get { get
if(_CheckingBrokenRules)return null; {
if (_CheckingBrokenRules) return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_FolderAssignments != null && (hasBrokenRules = _FolderAssignments.HasBrokenRules) != null) return hasBrokenRules; if (_FolderAssignments != null && (hasBrokenRules = _FolderAssignments.HasBrokenRules) != null) return hasBrokenRules;
if (_FolderDocVersions != null && (hasBrokenRules = _FolderDocVersions.HasBrokenRules) != null) return hasBrokenRules; if (_FolderDocVersions != null && (hasBrokenRules = _FolderDocVersions.HasBrokenRules) != null) return hasBrokenRules;
if (_ChildFolders != null && (hasBrokenRules = _ChildFolders.HasBrokenRules) != null) return hasBrokenRules; if (_ChildFolders != null && (hasBrokenRules = _ChildFolders.HasBrokenRules) != null) return hasBrokenRules;
if (_MyConnection != null && (hasBrokenRules = _MyConnection.HasBrokenRules) != null) return hasBrokenRules; if (_MyConnection != null && (hasBrokenRules = _MyConnection.HasBrokenRules) != null) return hasBrokenRules;
if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -644,15 +650,29 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods #region Factory Methods
public int CurrentEditLevel public int CurrentEditLevel
{ get { return EditLevel; } } { get { return EditLevel; } }
private static int _FolderUnique = 0;
private int _MyFolderUnique;
public int MyFolderUnique
{
get { return _MyFolderUnique; }
}
protected Folder() protected Folder()
{/* require use of factory methods */ {/* require use of factory methods */
_MyFolderUnique = ++_FolderUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(FolderID.ToString()); if (!_AllByPrimaryKey.ContainsKey(FolderID.ToString())) return;
_AllByParentID_Name.Remove(ParentID.ToString() + "_" + Name.ToString()); List<Folder> listFolder = _AllByPrimaryKey[FolderID.ToString()]; // Get the list of items
listFolder.Remove(this); // Remove the item from the list
if (listFolder.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(FolderID.ToString()); // remove the list
listFolder = _AllByParentID_Name[FolderID.ToString()]; // Get the list of items
listFolder.Remove(this); // Remove the item from the list
if (listFolder.Count == 0) //If there are no items left in the list
_AllByParentID_Name.Remove(FolderID.ToString()); // remove the list
} }
public static Folder New() public static Folder New()
{ {
@ -743,7 +763,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<Folder>(new PKCriteria(folderID)); tmp = DataPortal.Fetch<Folder>(new PKCriteria(folderID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -762,8 +782,8 @@ namespace VEPROMS.CSLA.Library
Folder tmp = GetExistingByParentID_Name(parentID, name); Folder tmp = GetExistingByParentID_Name(parentID, name);
if (tmp == null) if (tmp == null)
{ {
tmp=DataPortal.Fetch<Folder>(new ParentID_NameCriteria(parentID, name)); tmp = DataPortal.Fetch<Folder>(new ParentID_NameCriteria(parentID, name));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -869,7 +889,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Folder.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.ReadData", GetHashCode());
try try
{ {
_FolderID = dr.GetInt32("FolderID"); _FolderID = dr.GetInt32("FolderID");
@ -890,14 +910,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Folder.ReadData", ex); throw new DbCslaException("Folder.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Folder.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -931,14 +951,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Folder.DataPortal_Fetch", ex); throw new DbCslaException("Folder.DataPortal_Fetch", ex);
} }
} }
private void DataPortal_Fetch(ParentID_NameCriteria criteria) private void DataPortal_Fetch(ParentID_NameCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Folder.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -967,7 +987,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Folder.DataPortal_Fetch", ex); throw new DbCslaException("Folder.DataPortal_Fetch", ex);
} }
@ -988,13 +1008,13 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.DataPortal_Insert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.DataPortal_Insert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Folder.DataPortal_Insert", ex); throw new DbCslaException("Folder.DataPortal_Insert", ex);
} }
finally finally
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Folder.DataPortal_Insert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.DataPortal_Insert", GetHashCode());
} }
} }
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
@ -1003,8 +1023,8 @@ namespace VEPROMS.CSLA.Library
if (!this.IsDirty) return; if (!this.IsDirty) return;
try try
{ {
if(_MyConnection != null) _MyConnection.Update(); if (_MyConnection != null) _MyConnection.Update();
if(_MyFormat != null) _MyFormat.Update(); if (_MyFormat != null) _MyFormat.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
{ {
@ -1038,11 +1058,11 @@ namespace VEPROMS.CSLA.Library
if (_FolderAssignments != null) _FolderAssignments.Update(this); if (_FolderAssignments != null) _FolderAssignments.Update(this);
if (_FolderDocVersions != null) _FolderDocVersions.Update(this); if (_FolderDocVersions != null) _FolderDocVersions.Update(this);
if (_ChildFolders != null) _ChildFolders.Update(this); if (_ChildFolders != null) _ChildFolders.Update(this);
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Folder.SQLInsert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.SQLInsert", GetHashCode());
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.SQLInsert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.SQLInsert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Folder.SQLInsert", ex); throw new DbCslaException("Folder.SQLInsert", ex);
} }
@ -1050,7 +1070,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int folderID, Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, string config, DateTime dts, string usrID) public static byte[] Add(SqlConnection cn, ref int folderID, Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, string config, DateTime dts, string usrID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Folder.Add", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.Add", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -1063,7 +1083,7 @@ namespace VEPROMS.CSLA.Library
cm.Parameters.AddWithValue("@Name", name); cm.Parameters.AddWithValue("@Name", name);
cm.Parameters.AddWithValue("@Title", title); cm.Parameters.AddWithValue("@Title", title);
cm.Parameters.AddWithValue("@ShortName", shortName); cm.Parameters.AddWithValue("@ShortName", shortName);
if(myFormat != null)cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID); if (myFormat != null) cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID);
cm.Parameters.AddWithValue("@Config", config); cm.Parameters.AddWithValue("@Config", config);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts); if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID); cm.Parameters.AddWithValue("@UsrID", usrID);
@ -1083,7 +1103,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.Add", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.Add", ex);
throw new DbCslaException("Folder.Add", ex); throw new DbCslaException("Folder.Add", ex);
} }
} }
@ -1091,7 +1111,7 @@ namespace VEPROMS.CSLA.Library
protected override void DataPortal_Update() protected override void DataPortal_Update()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Folder.DataPortal_Update", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.DataPortal_Update", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1105,7 +1125,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.DataPortal_Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.DataPortal_Update", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -1114,11 +1134,11 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate() internal void SQLUpdate()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Folder.SQLUpdate", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.SQLUpdate", GetHashCode());
try try
{ {
if(_MyConnection != null) _MyConnection.Update(); if (_MyConnection != null) _MyConnection.Update();
if(_MyFormat != null) _MyFormat.Update(); if (_MyFormat != null) _MyFormat.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty) if (base.IsDirty)
{ {
@ -1156,7 +1176,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.SQLUpdate", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.SQLUpdate", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -1190,7 +1210,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int folderID, Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, string config, DateTime dts, string usrID, ref byte[] lastChanged) public static byte[] Update(SqlConnection cn, ref int folderID, Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, string config, DateTime dts, string usrID, ref byte[] lastChanged)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Folder.Update", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.Update", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -1204,7 +1224,7 @@ namespace VEPROMS.CSLA.Library
cm.Parameters.AddWithValue("@Name", name); cm.Parameters.AddWithValue("@Name", name);
cm.Parameters.AddWithValue("@Title", title); cm.Parameters.AddWithValue("@Title", title);
cm.Parameters.AddWithValue("@ShortName", shortName); cm.Parameters.AddWithValue("@ShortName", shortName);
if(myFormat != null)cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID); if (myFormat != null) cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID);
cm.Parameters.AddWithValue("@Config", config); cm.Parameters.AddWithValue("@Config", config);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts); if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID); cm.Parameters.AddWithValue("@UsrID", usrID);
@ -1221,7 +1241,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.Update", ex);
throw new DbCslaException("Folder.Update", ex); throw new DbCslaException("Folder.Update", ex);
} }
} }
@ -1233,7 +1253,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria) private void DataPortal_Delete(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Folder.DataPortal_Delete", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.DataPortal_Delete", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1249,7 +1269,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.DataPortal_Delete", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.DataPortal_Delete", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Folder.DataPortal_Delete", ex); throw new DbCslaException("Folder.DataPortal_Delete", ex);
} }
@ -1257,7 +1277,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int folderID) public static void Remove(SqlConnection cn, int folderID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Folder.Remove", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.Remove", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -1272,7 +1292,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.Remove", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.Remove", ex);
throw new DbCslaException("Folder.Remove", ex); throw new DbCslaException("Folder.Remove", ex);
} }
} }
@ -1306,7 +1326,7 @@ namespace VEPROMS.CSLA.Library
} }
protected override void DataPortal_Execute() protected override void DataPortal_Execute()
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Folder.DataPortal_Execute", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.DataPortal_Execute", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1324,7 +1344,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.DataPortal_Execute", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.DataPortal_Execute", ex);
throw new DbCslaException("Folder.DataPortal_Execute", ex); throw new DbCslaException("Folder.DataPortal_Execute", ex);
} }
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AID",true); CanReadProperty("AID", true);
if (_MyAssignment != null) _AID = _MyAssignment.AID; if (_MyAssignment != null) _AID = _MyAssignment.AID;
return _AID; return _AID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyAssignment",true); CanReadProperty("MyAssignment", true);
if (_MyAssignment == null && _AID != 0) _MyAssignment = Assignment.Get(_AID); if (_MyAssignment == null && _AID != 0) _MyAssignment = Assignment.Get(_AID);
return _MyAssignment; return _MyAssignment;
} }
@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GID",true); CanReadProperty("GID", true);
if (_MyGroup != null) _GID = _MyGroup.GID; if (_MyGroup != null) _GID = _MyGroup.GID;
return _GID; return _GID;
} }
@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyGroup",true); CanReadProperty("MyGroup", true);
if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID); if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID);
return _MyGroup; return _MyGroup;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyGroup",true); CanWriteProperty("MyGroup", true);
if (_MyGroup != value) if (_MyGroup != value)
{ {
_MyGroup = value; _MyGroup = value;
@ -97,7 +97,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RID",true); CanReadProperty("RID", true);
if (_MyRole != null) _RID = _MyRole.RID; if (_MyRole != null) _RID = _MyRole.RID;
return _RID; return _RID;
} }
@ -108,14 +108,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyRole",true); CanReadProperty("MyRole", true);
if (_MyRole == null && _RID != 0) _MyRole = Role.Get(_RID); if (_MyRole == null && _RID != 0) _MyRole = Role.Get(_RID);
return _MyRole; return _MyRole;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyRole",true); CanWriteProperty("MyRole", true);
if (_MyRole != value) if (_MyRole != value)
{ {
_MyRole = value; _MyRole = value;
@ -129,13 +129,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("StartDate",true); CanReadProperty("StartDate", true);
return _StartDate; return _StartDate;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("StartDate",true); CanWriteProperty("StartDate", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
_StartDate = value; _StartDate = value;
try try
@ -159,13 +159,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("EndDate",true); CanReadProperty("EndDate", true);
return _EndDate; return _EndDate;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("EndDate",true); CanWriteProperty("EndDate", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
_EndDate = value; _EndDate = value;
try try
@ -189,13 +189,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -209,13 +209,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UsrID",true); CanWriteProperty("UsrID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UsrID != value) if (_UsrID != value)
{ {
@ -231,7 +231,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Group_GroupName",true); CanReadProperty("Group_GroupName", true);
return _Group_GroupName; return _Group_GroupName;
} }
} }
@ -241,7 +241,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Group_GroupType",true); CanReadProperty("Group_GroupType", true);
return _Group_GroupType; return _Group_GroupType;
} }
} }
@ -251,7 +251,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Group_Config",true); CanReadProperty("Group_Config", true);
return _Group_Config; return _Group_Config;
} }
} }
@ -261,7 +261,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Group_DTS",true); CanReadProperty("Group_DTS", true);
return _Group_DTS; return _Group_DTS;
} }
} }
@ -271,7 +271,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Group_UsrID",true); CanReadProperty("Group_UsrID", true);
return _Group_UsrID; return _Group_UsrID;
} }
} }
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Role_Name",true); CanReadProperty("Role_Name", true);
return _Role_Name; return _Role_Name;
} }
} }
@ -291,7 +291,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Role_Title",true); CanReadProperty("Role_Title", true);
return _Role_Title; return _Role_Title;
} }
} }
@ -301,7 +301,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Role_DTS",true); CanReadProperty("Role_DTS", true);
return _Role_DTS; return _Role_DTS;
} }
} }
@ -311,7 +311,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Role_UsrID",true); CanReadProperty("Role_UsrID", true);
return _Role_UsrID; return _Role_UsrID;
} }
} }
@ -344,24 +344,24 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules; if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules;
if (_MyRole != null && (hasBrokenRules = _MyRole.HasBrokenRules) != null) return hasBrokenRules; if (_MyRole != null && (hasBrokenRules = _MyRole.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -517,8 +517,8 @@ namespace VEPROMS.CSLA.Library
_StartDate = _FolderAssignmentExtension.DefaultStartDate; _StartDate = _FolderAssignmentExtension.DefaultStartDate;
_DTS = _FolderAssignmentExtension.DefaultDTS; _DTS = _FolderAssignmentExtension.DefaultDTS;
_UsrID = _FolderAssignmentExtension.DefaultUsrID; _UsrID = _FolderAssignmentExtension.DefaultUsrID;
_MyGroup = myGroup; _MyGroup = myGroup;
_MyRole = myRole; _MyRole = myRole;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal FolderAssignment(SafeDataReader dr) internal FolderAssignment(SafeDataReader dr)
@ -530,7 +530,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderAssignment.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderAssignment.FetchDR", GetHashCode());
try try
{ {
_AID = dr.GetInt32("AID"); _AID = dr.GetInt32("AID");
@ -553,7 +553,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderAssignment.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderAssignment.FetchDR", ex);
throw new DbCslaException("FolderAssignment.Fetch", ex); throw new DbCslaException("FolderAssignment.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public FolderAssignment Add(Group myGroup, Role myRole) // One to Many public FolderAssignment Add(Group myGroup, Role myRole) // One to Many
{ {
FolderAssignment assignment = FolderAssignment.New(myGroup, myRole); FolderAssignment assignment = FolderAssignment.New(myGroup, myRole);
this.Add(assignment); this.Add(assignment);
return assignment; return assignment;
} }
public void Remove(Assignment myAssignment) public void Remove(Assignment myAssignment)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(FolderAssignment folderAssignment in this) foreach (FolderAssignment folderAssignment in this)
if ((hasBrokenRules = folderAssignment.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = folderAssignment.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(FolderIDCriteria criteria) private void DataPortal_Fetch(FolderIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderAssignments.DataPortal_FetchFolderID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderAssignments.DataPortal_FetchFolderID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderAssignments.DataPortal_FetchFolderID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderAssignments.DataPortal_FetchFolderID", ex);
throw new DbCslaException("FolderAssignments.DataPortal_Fetch", ex); throw new DbCslaException("FolderAssignments.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class FolderAssignmentsPropertyDescriptor : vlnListPropertyDescriptor public partial class FolderAssignmentsPropertyDescriptor : vlnListPropertyDescriptor
{ {
private FolderAssignment Item { get { return (FolderAssignment) _Item;} } private FolderAssignment Item { get { return (FolderAssignment)_Item; } }
public FolderAssignmentsPropertyDescriptor(FolderAssignments collection, int index):base(collection, index){;} public FolderAssignmentsPropertyDescriptor(FolderAssignments collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is FolderAssignments) if (destType == typeof(string) && value is FolderAssignments)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((FolderAssignments) value).Items.Count.ToString() + " Assignments"; return ((FolderAssignments)value).Items.Count.ToString() + " Assignments";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("VersionID",true); CanReadProperty("VersionID", true);
if (_MyDocVersion != null) _VersionID = _MyDocVersion.VersionID; if (_MyDocVersion != null) _VersionID = _MyDocVersion.VersionID;
return _VersionID; return _VersionID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyDocVersion",true); CanReadProperty("MyDocVersion", true);
if (_MyDocVersion == null && _VersionID != 0) _MyDocVersion = DocVersion.Get(_VersionID); if (_MyDocVersion == null && _VersionID != 0) _MyDocVersion = DocVersion.Get(_VersionID);
return _MyDocVersion; return _MyDocVersion;
} }
@ -68,13 +68,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("VersionType",true); CanReadProperty("VersionType", true);
return _VersionType; return _VersionType;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("VersionType",true); CanWriteProperty("VersionType", true);
if (_VersionType != value) if (_VersionType != value)
{ {
_VersionType = value; _VersionType = value;
@ -88,13 +88,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name",true); CanReadProperty("Name", true);
return _Name; return _Name;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Name",true); CanWriteProperty("Name", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Name != value) if (_Name != value)
{ {
@ -109,13 +109,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Title",true); CanReadProperty("Title", true);
return _Title; return _Title;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Title",true); CanWriteProperty("Title", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Title != value) if (_Title != value)
{ {
@ -130,7 +130,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemID",true); CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID; if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID; return _ItemID;
} }
@ -141,18 +141,18 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItem",true); CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != null) _MyItem = Item.Get((int)_ItemID); if (_MyItem == null && _ItemID != null) _MyItem = Item.Get((int)_ItemID);
return _MyItem; return _MyItem;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyItem",true); CanWriteProperty("MyItem", true);
if (_MyItem != value) if (_MyItem != value)
{ {
_MyItem = value; _MyItem = value;
_ItemID = (value == null ? null : (int?) value.ItemID); _ItemID = (value == null ? null : (int?)value.ItemID);
PropertyHasChanged(); PropertyHasChanged();
} }
} }
@ -163,7 +163,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatID",true); CanReadProperty("FormatID", true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID; if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID; return _FormatID;
} }
@ -174,18 +174,18 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFormat",true); CanReadProperty("MyFormat", true);
if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID); if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID);
return _MyFormat; return _MyFormat;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyFormat",true); CanWriteProperty("MyFormat", true);
if (_MyFormat != value) if (_MyFormat != value)
{ {
_MyFormat = value; _MyFormat = value;
_FormatID = (value == null ? null : (int?) value.FormatID); _FormatID = (value == null ? null : (int?)value.FormatID);
PropertyHasChanged(); PropertyHasChanged();
} }
} }
@ -196,13 +196,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -217,13 +217,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -237,13 +237,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -274,24 +274,24 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules;
if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -412,7 +412,7 @@ namespace VEPROMS.CSLA.Library
_VersionType = _FolderDocVersionExtension.DefaultVersionType; _VersionType = _FolderDocVersionExtension.DefaultVersionType;
_DTS = _FolderDocVersionExtension.DefaultDTS; _DTS = _FolderDocVersionExtension.DefaultDTS;
_UserID = _FolderDocVersionExtension.DefaultUserID; _UserID = _FolderDocVersionExtension.DefaultUserID;
_Name = name; _Name = name;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal FolderDocVersion(SafeDataReader dr) internal FolderDocVersion(SafeDataReader dr)
@ -424,7 +424,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderDocVersion.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderDocVersion.FetchDR", GetHashCode());
try try
{ {
_VersionID = dr.GetInt32("VersionID"); _VersionID = dr.GetInt32("VersionID");
@ -440,7 +440,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderDocVersion.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderDocVersion.FetchDR", ex);
throw new DbCslaException("FolderDocVersion.Fetch", ex); throw new DbCslaException("FolderDocVersion.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public FolderDocVersion Add(string name) // One to Many public FolderDocVersion Add(string name) // One to Many
{ {
FolderDocVersion docVersion = FolderDocVersion.New(name); FolderDocVersion docVersion = FolderDocVersion.New(name);
this.Add(docVersion); this.Add(docVersion);
return docVersion; return docVersion;
} }
public void Remove(DocVersion myDocVersion) public void Remove(DocVersion myDocVersion)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(FolderDocVersion folderDocVersion in this) foreach (FolderDocVersion folderDocVersion in this)
if ((hasBrokenRules = folderDocVersion.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = folderDocVersion.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(FolderIDCriteria criteria) private void DataPortal_Fetch(FolderIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderDocVersions.DataPortal_FetchFolderID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderDocVersions.DataPortal_FetchFolderID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderDocVersions.DataPortal_FetchFolderID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderDocVersions.DataPortal_FetchFolderID", ex);
throw new DbCslaException("FolderDocVersions.DataPortal_Fetch", ex); throw new DbCslaException("FolderDocVersions.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class FolderDocVersionsPropertyDescriptor : vlnListPropertyDescriptor public partial class FolderDocVersionsPropertyDescriptor : vlnListPropertyDescriptor
{ {
private FolderDocVersion Item { get { return (FolderDocVersion) _Item;} } private FolderDocVersion Item { get { return (FolderDocVersion)_Item; } }
public FolderDocVersionsPropertyDescriptor(FolderDocVersions collection, int index):base(collection, index){;} public FolderDocVersionsPropertyDescriptor(FolderDocVersions collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is FolderDocVersions) if (destType == typeof(string) && value is FolderDocVersions)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((FolderDocVersions) value).Items.Count.ToString() + " DocVersions"; return ((FolderDocVersions)value).Items.Count.ToString() + " DocVersions";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<FolderInfo> _AllList = new List<FolderInfo>(); protected static List<FolderInfo> _AllList = new List<FolderInfo>();
private static Dictionary<string, FolderInfo> _AllByPrimaryKey = new Dictionary<string, FolderInfo>(); private static Dictionary<string, List<FolderInfo>> _AllByPrimaryKey = new Dictionary<string, List<FolderInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<FolderInfo> remove = new List<FolderInfo>(); List<FolderInfo> remove = new List<FolderInfo>();
foreach (FolderInfo tmp in _AllList) foreach (FolderInfo tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.FolderID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.FolderID.ToString()))
{
_AllByPrimaryKey[tmp.FolderID.ToString()] = new List<FolderInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.FolderID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (FolderInfo tmp in remove) foreach (FolderInfo tmp in remove)
@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = folderID.ToString(); string key = folderID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderID",true); CanReadProperty("FolderID", true);
return _FolderID; return _FolderID;
} }
} }
@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ParentID",true); CanReadProperty("ParentID", true);
if (_MyParent != null) _ParentID = _MyParent.FolderID; if (_MyParent != null) _ParentID = _MyParent.FolderID;
return _ParentID; return _ParentID;
} }
@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyParent",true); CanReadProperty("MyParent", true);
if (_MyParent == null && _ParentID != _FolderID) _MyParent = FolderInfo.Get(_ParentID); if (_MyParent == null && _ParentID != _FolderID) _MyParent = FolderInfo.Get(_ParentID);
return _MyParent; return _MyParent;
} }
@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DBID",true); CanReadProperty("DBID", true);
if (_MyConnection != null) _DBID = _MyConnection.DBID; if (_MyConnection != null) _DBID = _MyConnection.DBID;
return _DBID; return _DBID;
} }
@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyConnection",true); CanReadProperty("MyConnection", true);
if (_MyConnection == null && _DBID != 0) _MyConnection = ConnectionInfo.Get(_DBID); if (_MyConnection == null && _DBID != 0) _MyConnection = ConnectionInfo.Get(_DBID);
return _MyConnection; return _MyConnection;
} }
@ -139,7 +143,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name",true); CanReadProperty("Name", true);
return _Name; return _Name;
} }
} }
@ -149,7 +153,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Title",true); CanReadProperty("Title", true);
return _Title; return _Title;
} }
} }
@ -159,7 +163,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ShortName",true); CanReadProperty("ShortName", true);
return _ShortName; return _ShortName;
} }
} }
@ -169,7 +173,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatID",true); CanReadProperty("FormatID", true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID; if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID; return _FormatID;
} }
@ -180,7 +184,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFormat",true); CanReadProperty("MyFormat", true);
if (_MyFormat == null && _FormatID != null) _MyFormat = FormatInfo.Get((int)_FormatID); if (_MyFormat == null && _FormatID != null) _MyFormat = FormatInfo.Get((int)_FormatID);
return _MyFormat; return _MyFormat;
} }
@ -191,7 +195,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
} }
@ -201,7 +205,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -211,7 +215,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
} }
@ -224,7 +228,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderAssignmentCount",true); CanReadProperty("FolderAssignmentCount", true);
return _FolderAssignmentCount; return _FolderAssignmentCount;
} }
} }
@ -235,7 +239,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderAssignments",true); CanReadProperty("FolderAssignments", true);
if (_FolderAssignmentCount < 0 || (_FolderAssignmentCount > 0 && _FolderAssignments == null)) if (_FolderAssignmentCount < 0 || (_FolderAssignmentCount > 0 && _FolderAssignments == null))
_FolderAssignments = AssignmentInfoList.GetByFolderID(_FolderID); _FolderAssignments = AssignmentInfoList.GetByFolderID(_FolderID);
if (_FolderAssignmentCount < 0) if (_FolderAssignmentCount < 0)
@ -245,7 +249,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshFolderAssignments() internal void RefreshFolderAssignments()
{ {
_FolderAssignmentCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_FolderID.ToString()))
foreach (FolderInfo tmp in _AllByPrimaryKey[_FolderID.ToString()])
tmp._FolderAssignmentCount = -1; // This will cause the data to be requeried
} }
private int _FolderDocVersionCount = 0; private int _FolderDocVersionCount = 0;
/// <summary> /// <summary>
@ -256,7 +263,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderDocVersionCount",true); CanReadProperty("FolderDocVersionCount", true);
return _FolderDocVersionCount; return _FolderDocVersionCount;
} }
} }
@ -267,7 +274,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderDocVersions",true); CanReadProperty("FolderDocVersions", true);
if (_FolderDocVersionCount < 0 || (_FolderDocVersionCount > 0 && _FolderDocVersions == null)) if (_FolderDocVersionCount < 0 || (_FolderDocVersionCount > 0 && _FolderDocVersions == null))
_FolderDocVersions = DocVersionInfoList.GetByFolderID(_FolderID); _FolderDocVersions = DocVersionInfoList.GetByFolderID(_FolderID);
if (_FolderDocVersionCount < 0) if (_FolderDocVersionCount < 0)
@ -277,7 +284,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshFolderDocVersions() internal void RefreshFolderDocVersions()
{ {
_FolderDocVersionCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_FolderID.ToString()))
foreach (FolderInfo tmp in _AllByPrimaryKey[_FolderID.ToString()])
tmp._FolderDocVersionCount = -1; // This will cause the data to be requeried
} }
private int _ChildFolderCount = 0; private int _ChildFolderCount = 0;
/// <summary> /// <summary>
@ -288,7 +298,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ChildFolderCount",true); CanReadProperty("ChildFolderCount", true);
return _ChildFolderCount; return _ChildFolderCount;
} }
} }
@ -299,7 +309,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ChildFolders",true); CanReadProperty("ChildFolders", true);
if (_ChildFolderCount < 0 || (_ChildFolderCount > 0 && _ChildFolders == null)) if (_ChildFolderCount < 0 || (_ChildFolderCount > 0 && _ChildFolders == null))
_ChildFolders = FolderInfoList.GetChildren(_FolderID); _ChildFolders = FolderInfoList.GetChildren(_FolderID);
if (_ChildFolderCount < 0) if (_ChildFolderCount < 0)
@ -309,7 +319,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshChildFolders() internal void RefreshChildFolders()
{ {
_ChildFolderCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_FolderID.ToString()))
foreach (FolderInfo tmp in _AllByPrimaryKey[_FolderID.ToString()])
tmp._ChildFolderCount = -1; // This will cause the data to be requeried
} }
// TODO: Replace base FolderInfo.ToString function as necessary // TODO: Replace base FolderInfo.ToString function as necessary
/// <summary> /// <summary>
@ -331,14 +344,25 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _FolderInfoUnique = 0;
private int _MyFolderInfoUnique;
public int MyFolderInfoUnique
{
get { return _MyFolderInfoUnique; }
}
private FolderInfo() private FolderInfo()
{/* require use of factory methods */ {/* require use of factory methods */
_MyFolderInfoUnique = ++_FolderInfoUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(FolderID.ToString()); if (!_AllByPrimaryKey.ContainsKey(FolderID.ToString())) return;
List<FolderInfo> listFolderInfo = _AllByPrimaryKey[FolderID.ToString()]; // Get the list of items
listFolderInfo.Remove(this); // Remove the item from the list
if (listFolderInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(FolderID.ToString()); // remove the list
} }
public virtual Folder Get() public virtual Folder Get()
{ {
@ -346,9 +370,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(Folder tmp) public static void Refresh(Folder tmp)
{ {
FolderInfo tmpInfo = GetExistingByPrimaryKey(tmp.FolderID); string key = tmp.FolderID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (FolderInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(Folder tmp) private void RefreshFields(Folder tmp)
{ {
@ -356,16 +382,16 @@ namespace VEPROMS.CSLA.Library
{ {
MyParent.RefreshChildFolders(); // Update List for old value MyParent.RefreshChildFolders(); // Update List for old value
_ParentID = tmp.ParentID; // Update the value _ParentID = tmp.ParentID; // Update the value
_MyParent = null; // Reset list so that the next line gets a new list
MyParent.RefreshChildFolders(); // Update List for new value
} }
_MyParent = null; // Reset list so that the next line gets a new list
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for new value
if (_DBID != tmp.DBID) if (_DBID != tmp.DBID)
{ {
MyConnection.RefreshConnectionFolders(); // Update List for old value MyConnection.RefreshConnectionFolders(); // Update List for old value
_DBID = tmp.DBID; // Update the value _DBID = tmp.DBID; // Update the value
_MyConnection = null; // Reset list so that the next line gets a new list
MyConnection.RefreshConnectionFolders(); // Update List for new value
} }
_MyConnection = null; // Reset list so that the next line gets a new list
if (MyConnection != null) MyConnection.RefreshConnectionFolders(); // Update List for new value
_Name = tmp.Name; _Name = tmp.Name;
_Title = tmp.Title; _Title = tmp.Title;
_ShortName = tmp.ShortName; _ShortName = tmp.ShortName;
@ -373,9 +399,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyFormat.RefreshFormatFolders(); // Update List for old value MyFormat.RefreshFormatFolders(); // Update List for old value
_FormatID = tmp.FormatID; // Update the value _FormatID = tmp.FormatID; // Update the value
_MyFormat = null; // Reset list so that the next line gets a new list
MyFormat.RefreshFormatFolders(); // Update List for new value
} }
_MyFormat = null; // Reset list so that the next line gets a new list
if (MyFormat != null) MyFormat.RefreshFormatFolders(); // Update List for new value
_Config = tmp.Config; _Config = tmp.Config;
_DTS = tmp.DTS; _DTS = tmp.DTS;
_UsrID = tmp.UsrID; _UsrID = tmp.UsrID;
@ -387,9 +413,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(ConnectionFolder tmp) public static void Refresh(ConnectionFolder tmp)
{ {
FolderInfo tmpInfo = GetExistingByPrimaryKey(tmp.FolderID); string key = tmp.FolderID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (FolderInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(ConnectionFolder tmp) private void RefreshFields(ConnectionFolder tmp)
{ {
@ -397,9 +425,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyParent.RefreshChildFolders(); // Update List for old value MyParent.RefreshChildFolders(); // Update List for old value
_ParentID = tmp.ParentID; // Update the value _ParentID = tmp.ParentID; // Update the value
_MyParent = null; // Reset list so that the next line gets a new list
MyParent.RefreshChildFolders(); // Update List for new value
} }
_MyParent = null; // Reset list so that the next line gets a new list
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for new value
_Name = tmp.Name; _Name = tmp.Name;
_Title = tmp.Title; _Title = tmp.Title;
_ShortName = tmp.ShortName; _ShortName = tmp.ShortName;
@ -407,9 +435,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyFormat.RefreshFormatFolders(); // Update List for old value MyFormat.RefreshFormatFolders(); // Update List for old value
_FormatID = tmp.FormatID; // Update the value _FormatID = tmp.FormatID; // Update the value
_MyFormat = null; // Reset list so that the next line gets a new list
MyFormat.RefreshFormatFolders(); // Update List for new value
} }
_MyFormat = null; // Reset list so that the next line gets a new list
if (MyFormat != null) MyFormat.RefreshFormatFolders(); // Update List for new value
_Config = tmp.Config; _Config = tmp.Config;
_DTS = tmp.DTS; _DTS = tmp.DTS;
_UsrID = tmp.UsrID; _UsrID = tmp.UsrID;
@ -421,9 +449,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(FormatFolder tmp) public static void Refresh(FormatFolder tmp)
{ {
FolderInfo tmpInfo = GetExistingByPrimaryKey(tmp.FolderID); string key = tmp.FolderID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (FolderInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(FormatFolder tmp) private void RefreshFields(FormatFolder tmp)
{ {
@ -431,16 +461,16 @@ namespace VEPROMS.CSLA.Library
{ {
MyParent.RefreshChildFolders(); // Update List for old value MyParent.RefreshChildFolders(); // Update List for old value
_ParentID = tmp.ParentID; // Update the value _ParentID = tmp.ParentID; // Update the value
_MyParent = null; // Reset list so that the next line gets a new list
MyParent.RefreshChildFolders(); // Update List for new value
} }
_MyParent = null; // Reset list so that the next line gets a new list
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for new value
if (_DBID != tmp.DBID) if (_DBID != tmp.DBID)
{ {
MyConnection.RefreshConnectionFolders(); // Update List for old value MyConnection.RefreshConnectionFolders(); // Update List for old value
_DBID = tmp.DBID; // Update the value _DBID = tmp.DBID; // Update the value
_MyConnection = null; // Reset list so that the next line gets a new list
MyConnection.RefreshConnectionFolders(); // Update List for new value
} }
_MyConnection = null; // Reset list so that the next line gets a new list
if (MyConnection != null) MyConnection.RefreshConnectionFolders(); // Update List for new value
_Name = tmp.Name; _Name = tmp.Name;
_Title = tmp.Title; _Title = tmp.Title;
_ShortName = tmp.ShortName; _ShortName = tmp.ShortName;
@ -463,7 +493,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<FolderInfo>(new PKCriteria(folderID)); tmp = DataPortal.Fetch<FolderInfo>(new PKCriteria(folderID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -477,14 +507,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
internal FolderInfo(SafeDataReader dr) internal FolderInfo(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfo.Constructor", GetHashCode()); _MyFolderInfoUnique = ++_FolderInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderInfo.Constructor", GetHashCode());
try try
{ {
ReadData(dr); ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderInfo.Constructor", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderInfo.Constructor", ex);
throw new DbCslaException("FolderInfo.Constructor", ex); throw new DbCslaException("FolderInfo.Constructor", ex);
} }
} }
@ -501,7 +532,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfo.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderInfo.ReadData", GetHashCode());
try try
{ {
_FolderID = dr.GetInt32("FolderID"); _FolderID = dr.GetInt32("FolderID");
@ -520,14 +551,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderInfo.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderInfo.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("FolderInfo.ReadData", ex); throw new DbCslaException("FolderInfo.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderInfo.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -555,7 +586,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderInfo.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("FolderInfo.DataPortal_Fetch", ex); throw new DbCslaException("FolderInfo.DataPortal_Fetch", ex);
} }
@ -565,7 +596,7 @@ namespace VEPROMS.CSLA.Library
#region extension #region extension
FolderInfoExtension _FolderInfoExtension = new FolderInfoExtension(); FolderInfoExtension _FolderInfoExtension = new FolderInfoExtension();
[Serializable()] [Serializable()]
partial class FolderInfoExtension : extensionBase {} partial class FolderInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {

View File

@ -138,7 +138,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -158,7 +158,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("FolderInfoList.DataPortal_Fetch", ex); throw new DbCslaException("FolderInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -180,7 +180,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ParentIDCriteria criteria) private void DataPortal_Fetch(ParentIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfoList.DataPortal_FetchParentID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderInfoList.DataPortal_FetchParentID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -201,7 +201,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderInfoList.DataPortal_FetchParentID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderInfoList.DataPortal_FetchParentID", ex);
throw new DbCslaException("FolderInfoList.DataPortal_Fetch", ex); throw new DbCslaException("FolderInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -223,7 +223,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(DBIDCriteria criteria) private void DataPortal_Fetch(DBIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfoList.DataPortal_FetchDBID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderInfoList.DataPortal_FetchDBID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -244,7 +244,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderInfoList.DataPortal_FetchDBID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderInfoList.DataPortal_FetchDBID", ex);
throw new DbCslaException("FolderInfoList.DataPortal_Fetch", ex); throw new DbCslaException("FolderInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -266,7 +266,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(FormatIDCriteria criteria) private void DataPortal_Fetch(FormatIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfoList.DataPortal_FetchFormatID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderInfoList.DataPortal_FetchFormatID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -287,7 +287,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderInfoList.DataPortal_FetchFormatID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderInfoList.DataPortal_FetchFormatID", ex);
throw new DbCslaException("FolderInfoList.DataPortal_Fetch", ex); throw new DbCslaException("FolderInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -348,8 +348,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class FolderInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class FolderInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private FolderInfo Item { get { return (FolderInfo) _Item;} } private FolderInfo Item { get { return (FolderInfo)_Item; } }
public FolderInfoListPropertyDescriptor(FolderInfoList collection, int index):base(collection, index){;} public FolderInfoListPropertyDescriptor(FolderInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -360,7 +360,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is FolderInfoList) if (destType == typeof(string) && value is FolderInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((FolderInfoList) value).Items.Count.ToString() + " Folders"; return ((FolderInfoList)value).Items.Count.ToString() + " Folders";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -43,21 +43,21 @@ namespace VEPROMS.CSLA.Library
{ {
foreach (FormatContent tmp in _FormatContents) foreach (FormatContent tmp in _FormatContents)
{ {
if(tmp.IsDirty)refreshFormatContents.Add(tmp); if (tmp.IsDirty) refreshFormatContents.Add(tmp);
} }
} }
if (_FormatDocVersions != null && _FormatDocVersions.IsDirty) if (_FormatDocVersions != null && _FormatDocVersions.IsDirty)
{ {
foreach (FormatDocVersion tmp in _FormatDocVersions) foreach (FormatDocVersion tmp in _FormatDocVersions)
{ {
if(tmp.IsDirty)refreshFormatDocVersions.Add(tmp); if (tmp.IsDirty) refreshFormatDocVersions.Add(tmp);
} }
} }
if (_FormatFolders != null && _FormatFolders.IsDirty) if (_FormatFolders != null && _FormatFolders.IsDirty)
{ {
foreach (FormatFolder tmp in _FormatFolders) foreach (FormatFolder tmp in _FormatFolders)
{ {
if(tmp.IsDirty)refreshFormatFolders.Add(tmp); if (tmp.IsDirty) refreshFormatFolders.Add(tmp);
} }
} }
if (_ChildFormats != null && _ChildFormats.IsDirty) if (_ChildFormats != null && _ChildFormats.IsDirty)
@ -98,15 +98,20 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<Format> _AllList = new List<Format>(); protected static List<Format> _AllList = new List<Format>();
private static Dictionary<string, Format> _AllByPrimaryKey = new Dictionary<string, Format>(); private static Dictionary<string, List<Format>> _AllByPrimaryKey = new Dictionary<string, List<Format>>();
private static Dictionary<string, Format> _AllByParentID_Name = new Dictionary<string, Format>(); private static Dictionary<string, List<Format>> _AllByParentID_Name = new Dictionary<string, List<Format>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<Format> remove = new List<Format>(); List<Format> remove = new List<Format>();
foreach (Format tmp in _AllList) foreach (Format tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.FormatID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.FormatID.ToString()))
_AllByParentID_Name[tmp.ParentID.ToString() + "_" + tmp.Name.ToString()] = tmp; // Unique Index {
_AllByPrimaryKey[tmp.FormatID.ToString()] = new List<Format>(); // Add new list for PrimaryKey
_AllByParentID_Name[tmp.ParentID.ToString() + "_" + tmp.Name.ToString()] = new List<Format>(); // Add new list for ParentID_Name
}
_AllByPrimaryKey[tmp.FormatID.ToString()].Add(tmp); // Add to Primary Key list
_AllByParentID_Name[tmp.ParentID.ToString() + "_" + tmp.Name.ToString()].Add(tmp); // Unique Index
remove.Add(tmp); remove.Add(tmp);
} }
foreach (Format tmp in remove) foreach (Format tmp in remove)
@ -116,14 +121,14 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = formatID.ToString(); string key = formatID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
public static Format GetExistingByParentID_Name(int parentID, string name) public static Format GetExistingByParentID_Name(int parentID, string name)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = parentID.ToString() + "_" + name.ToString(); string key = parentID.ToString() + "_" + name.ToString();
if (_AllByParentID_Name.ContainsKey(key)) return _AllByParentID_Name[key]; if (_AllByParentID_Name.ContainsKey(key)) return _AllByParentID_Name[key][0];
return null; return null;
} }
#endregion #endregion
@ -145,7 +150,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatID",true); CanReadProperty("FormatID", true);
return _FormatID; return _FormatID;
} }
} }
@ -155,7 +160,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ParentID",true); CanReadProperty("ParentID", true);
if (_MyParent != null) _ParentID = _MyParent.FormatID; if (_MyParent != null) _ParentID = _MyParent.FormatID;
return _ParentID; return _ParentID;
} }
@ -166,14 +171,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyParent",true); CanReadProperty("MyParent", true);
if (_MyParent == null && _ParentID != _FormatID) _MyParent = Format.Get(_ParentID); if (_MyParent == null && _ParentID != _FormatID) _MyParent = Format.Get(_ParentID);
return _MyParent; return _MyParent;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyParent",true); CanWriteProperty("MyParent", true);
if (_MyParent != value) if (_MyParent != value)
{ {
_MyParent = value; _MyParent = value;
@ -187,13 +192,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name",true); CanReadProperty("Name", true);
return _Name; return _Name;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Name",true); CanWriteProperty("Name", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Name != value) if (_Name != value)
{ {
@ -208,13 +213,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Description",true); CanReadProperty("Description", true);
return _Description; return _Description;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Description",true); CanWriteProperty("Description", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Description != value) if (_Description != value)
{ {
@ -229,13 +234,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Data",true); CanReadProperty("Data", true);
return _Data; return _Data;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Data",true); CanWriteProperty("Data", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Data != value) if (_Data != value)
{ {
@ -250,13 +255,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GenMac",true); CanReadProperty("GenMac", true);
return _GenMac; return _GenMac;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("GenMac",true); CanWriteProperty("GenMac", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_GenMac != value) if (_GenMac != value)
{ {
@ -271,13 +276,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -291,13 +296,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -316,7 +321,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatContentCount",true); CanReadProperty("FormatContentCount", true);
return _FormatContentCount; return _FormatContentCount;
} }
} }
@ -330,10 +335,10 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatContents",true); CanReadProperty("FormatContents", true);
if(_FormatContentCount > 0 && _FormatContents == null) if (_FormatContentCount > 0 && _FormatContents == null)
_FormatContents = FormatContents.GetByFormatID(FormatID); _FormatContents = FormatContents.GetByFormatID(FormatID);
else if(_FormatContents == null) else if (_FormatContents == null)
_FormatContents = FormatContents.New(); _FormatContents = FormatContents.New();
return _FormatContents; return _FormatContents;
} }
@ -347,7 +352,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatDocVersionCount",true); CanReadProperty("FormatDocVersionCount", true);
return _FormatDocVersionCount; return _FormatDocVersionCount;
} }
} }
@ -361,10 +366,10 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatDocVersions",true); CanReadProperty("FormatDocVersions", true);
if(_FormatDocVersionCount > 0 && _FormatDocVersions == null) if (_FormatDocVersionCount > 0 && _FormatDocVersions == null)
_FormatDocVersions = FormatDocVersions.GetByFormatID(FormatID); _FormatDocVersions = FormatDocVersions.GetByFormatID(FormatID);
else if(_FormatDocVersions == null) else if (_FormatDocVersions == null)
_FormatDocVersions = FormatDocVersions.New(); _FormatDocVersions = FormatDocVersions.New();
return _FormatDocVersions; return _FormatDocVersions;
} }
@ -378,7 +383,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatFolderCount",true); CanReadProperty("FormatFolderCount", true);
return _FormatFolderCount; return _FormatFolderCount;
} }
} }
@ -392,10 +397,10 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatFolders",true); CanReadProperty("FormatFolders", true);
if(_FormatFolderCount > 0 && _FormatFolders == null) if (_FormatFolderCount > 0 && _FormatFolders == null)
_FormatFolders = FormatFolders.GetByFormatID(FormatID); _FormatFolders = FormatFolders.GetByFormatID(FormatID);
else if(_FormatFolders == null) else if (_FormatFolders == null)
_FormatFolders = FormatFolders.New(); _FormatFolders = FormatFolders.New();
return _FormatFolders; return _FormatFolders;
} }
@ -409,7 +414,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ChildFormatCount",true); CanReadProperty("ChildFormatCount", true);
return _ChildFormatCount; return _ChildFormatCount;
} }
} }
@ -423,21 +428,21 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ChildFormats",true); CanReadProperty("ChildFormats", true);
if(_ChildFormatCount > 0 && _ChildFormats == null) if (_ChildFormatCount > 0 && _ChildFormats == null)
_ChildFormats = ChildFormats.GetByParentID(FormatID); _ChildFormats = ChildFormats.GetByParentID(FormatID);
else if(_ChildFormats == null) else if (_ChildFormats == null)
_ChildFormats = ChildFormats.New(); _ChildFormats = ChildFormats.New();
return _ChildFormats; return _ChildFormats;
} }
} }
public override bool IsDirty public override bool IsDirty
{ {
get { return base.IsDirty || (_FormatContents == null? false : _FormatContents.IsDirty) || (_FormatDocVersions == null? false : _FormatDocVersions.IsDirty) || (_FormatFolders == null? false : _FormatFolders.IsDirty) || (_ChildFormats == null? false : _ChildFormats.IsDirty); } get { return base.IsDirty || (_FormatContents == null ? false : _FormatContents.IsDirty) || (_FormatDocVersions == null ? false : _FormatDocVersions.IsDirty) || (_FormatFolders == null ? false : _FormatFolders.IsDirty) || (_ChildFormats == null ? false : _ChildFormats.IsDirty); }
} }
public override bool IsValid public override bool IsValid
{ {
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_FormatContents == null? true : _FormatContents.IsValid) && (_FormatDocVersions == null? true : _FormatDocVersions.IsValid) && (_FormatFolders == null? true : _FormatFolders.IsValid) && (_ChildFormats == null? true : _ChildFormats.IsValid); } get { return (IsNew && !IsDirty ? true : base.IsValid) && (_FormatContents == null ? true : _FormatContents.IsValid) && (_FormatDocVersions == null ? true : _FormatDocVersions.IsValid) && (_FormatFolders == null ? true : _FormatFolders.IsValid) && (_ChildFormats == null ? true : _ChildFormats.IsValid); }
} }
// TODO: Replace base Format.ToString function as necessary // TODO: Replace base Format.ToString function as necessary
/// <summary> /// <summary>
@ -460,25 +465,26 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get { get
if(_CheckingBrokenRules)return null; {
if (_CheckingBrokenRules) return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_FormatFolders != null && (hasBrokenRules = _FormatFolders.HasBrokenRules) != null) return hasBrokenRules; if (_FormatFolders != null && (hasBrokenRules = _FormatFolders.HasBrokenRules) != null) return hasBrokenRules;
if (_FormatContents != null && (hasBrokenRules = _FormatContents.HasBrokenRules) != null) return hasBrokenRules; if (_FormatContents != null && (hasBrokenRules = _FormatContents.HasBrokenRules) != null) return hasBrokenRules;
if (_FormatDocVersions != null && (hasBrokenRules = _FormatDocVersions.HasBrokenRules) != null) return hasBrokenRules; if (_FormatDocVersions != null && (hasBrokenRules = _FormatDocVersions.HasBrokenRules) != null) return hasBrokenRules;
if (_ChildFormats != null && (hasBrokenRules = _ChildFormats.HasBrokenRules) != null) return hasBrokenRules; if (_ChildFormats != null && (hasBrokenRules = _ChildFormats.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -607,15 +613,29 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods #region Factory Methods
public int CurrentEditLevel public int CurrentEditLevel
{ get { return EditLevel; } } { get { return EditLevel; } }
private static int _FormatUnique = 0;
private int _MyFormatUnique;
public int MyFormatUnique
{
get { return _MyFormatUnique; }
}
protected Format() protected Format()
{/* require use of factory methods */ {/* require use of factory methods */
_MyFormatUnique = ++_FormatUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(FormatID.ToString()); if (!_AllByPrimaryKey.ContainsKey(FormatID.ToString())) return;
_AllByParentID_Name.Remove(ParentID.ToString() + "_" + Name.ToString()); List<Format> listFormat = _AllByPrimaryKey[FormatID.ToString()]; // Get the list of items
listFormat.Remove(this); // Remove the item from the list
if (listFormat.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(FormatID.ToString()); // remove the list
listFormat = _AllByParentID_Name[FormatID.ToString()]; // Get the list of items
listFormat.Remove(this); // Remove the item from the list
if (listFormat.Count == 0) //If there are no items left in the list
_AllByParentID_Name.Remove(FormatID.ToString()); // remove the list
} }
public static Format New() public static Format New()
{ {
@ -702,7 +722,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<Format>(new PKCriteria(formatID)); tmp = DataPortal.Fetch<Format>(new PKCriteria(formatID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -721,8 +741,8 @@ namespace VEPROMS.CSLA.Library
Format tmp = GetExistingByParentID_Name(parentID, name); Format tmp = GetExistingByParentID_Name(parentID, name);
if (tmp == null) if (tmp == null)
{ {
tmp=DataPortal.Fetch<Format>(new ParentID_NameCriteria(parentID, name)); tmp = DataPortal.Fetch<Format>(new ParentID_NameCriteria(parentID, name));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -827,7 +847,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Format.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.ReadData", GetHashCode());
try try
{ {
_FormatID = dr.GetInt32("FormatID"); _FormatID = dr.GetInt32("FormatID");
@ -847,14 +867,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Format.ReadData", ex); throw new DbCslaException("Format.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Format.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -891,14 +911,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Format.DataPortal_Fetch", ex); throw new DbCslaException("Format.DataPortal_Fetch", ex);
} }
} }
private void DataPortal_Fetch(ParentID_NameCriteria criteria) private void DataPortal_Fetch(ParentID_NameCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Format.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -927,7 +947,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Format.DataPortal_Fetch", ex); throw new DbCslaException("Format.DataPortal_Fetch", ex);
} }
@ -948,13 +968,13 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.DataPortal_Insert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.DataPortal_Insert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Format.DataPortal_Insert", ex); throw new DbCslaException("Format.DataPortal_Insert", ex);
} }
finally finally
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Format.DataPortal_Insert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.DataPortal_Insert", GetHashCode());
} }
} }
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
@ -995,11 +1015,11 @@ namespace VEPROMS.CSLA.Library
if (_FormatContents != null) _FormatContents.Update(this); if (_FormatContents != null) _FormatContents.Update(this);
if (_FormatDocVersions != null) _FormatDocVersions.Update(this); if (_FormatDocVersions != null) _FormatDocVersions.Update(this);
if (_ChildFormats != null) _ChildFormats.Update(this); if (_ChildFormats != null) _ChildFormats.Update(this);
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Format.SQLInsert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.SQLInsert", GetHashCode());
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.SQLInsert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.SQLInsert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Format.SQLInsert", ex); throw new DbCslaException("Format.SQLInsert", ex);
} }
@ -1007,7 +1027,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int formatID, Format myParent, string name, string description, string data, string genMac, DateTime dts, string userID) public static byte[] Add(SqlConnection cn, ref int formatID, Format myParent, string name, string description, string data, string genMac, DateTime dts, string userID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Format.Add", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.Add", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -1038,7 +1058,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.Add", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.Add", ex);
throw new DbCslaException("Format.Add", ex); throw new DbCslaException("Format.Add", ex);
} }
} }
@ -1046,7 +1066,7 @@ namespace VEPROMS.CSLA.Library
protected override void DataPortal_Update() protected override void DataPortal_Update()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Format.DataPortal_Update", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.DataPortal_Update", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1060,7 +1080,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.DataPortal_Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.DataPortal_Update", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -1069,7 +1089,7 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate() internal void SQLUpdate()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Format.SQLUpdate", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.SQLUpdate", GetHashCode());
try try
{ {
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
@ -1108,7 +1128,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.SQLUpdate", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.SQLUpdate", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -1143,7 +1163,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int formatID, Format myParent, string name, string description, string data, string genMac, DateTime dts, string userID, ref byte[] lastChanged) public static byte[] Update(SqlConnection cn, ref int formatID, Format myParent, string name, string description, string data, string genMac, DateTime dts, string userID, ref byte[] lastChanged)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Format.Update", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.Update", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -1172,7 +1192,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.Update", ex);
throw new DbCslaException("Format.Update", ex); throw new DbCslaException("Format.Update", ex);
} }
} }
@ -1184,7 +1204,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria) private void DataPortal_Delete(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Format.DataPortal_Delete", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.DataPortal_Delete", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1200,7 +1220,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.DataPortal_Delete", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.DataPortal_Delete", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Format.DataPortal_Delete", ex); throw new DbCslaException("Format.DataPortal_Delete", ex);
} }
@ -1208,7 +1228,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int formatID) public static void Remove(SqlConnection cn, int formatID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Format.Remove", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.Remove", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -1223,7 +1243,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.Remove", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.Remove", ex);
throw new DbCslaException("Format.Remove", ex); throw new DbCslaException("Format.Remove", ex);
} }
} }
@ -1257,7 +1277,7 @@ namespace VEPROMS.CSLA.Library
} }
protected override void DataPortal_Execute() protected override void DataPortal_Execute()
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Format.DataPortal_Execute", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.DataPortal_Execute", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1275,7 +1295,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.DataPortal_Execute", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.DataPortal_Execute", ex);
throw new DbCslaException("Format.DataPortal_Execute", ex); throw new DbCslaException("Format.DataPortal_Execute", ex);
} }
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentID",true); CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID; if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID; return _ContentID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyContent",true); CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID); if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID);
return _MyContent; return _MyContent;
} }
@ -65,13 +65,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Number",true); CanReadProperty("Number", true);
return _Number; return _Number;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Number",true); CanWriteProperty("Number", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Number != value) if (_Number != value)
{ {
@ -86,13 +86,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Text",true); CanReadProperty("Text", true);
return _Text; return _Text;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Text",true); CanWriteProperty("Text", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Text != value) if (_Text != value)
{ {
@ -110,13 +110,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Type",true); CanReadProperty("Type", true);
return _Type; return _Type;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Type",true); CanWriteProperty("Type", true);
if (_Type != value) if (_Type != value)
{ {
_Type = value; _Type = value;
@ -130,13 +130,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -151,13 +151,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -171,13 +171,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -208,22 +208,22 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -339,7 +339,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatContent.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatContent.FetchDR", GetHashCode());
try try
{ {
_ContentID = dr.GetInt32("ContentID"); _ContentID = dr.GetInt32("ContentID");
@ -353,7 +353,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatContent.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatContent.FetchDR", ex);
throw new DbCslaException("FormatContent.Fetch", ex); throw new DbCslaException("FormatContent.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public FormatContent Add() // One to Many public FormatContent Add() // One to Many
{ {
FormatContent content = FormatContent.New(); FormatContent content = FormatContent.New();
this.Add(content); this.Add(content);
return content; return content;
} }
public void Remove(Content myContent) public void Remove(Content myContent)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(FormatContent formatContent in this) foreach (FormatContent formatContent in this)
if ((hasBrokenRules = formatContent.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = formatContent.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(FormatIDCriteria criteria) private void DataPortal_Fetch(FormatIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatContents.DataPortal_FetchFormatID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatContents.DataPortal_FetchFormatID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatContents.DataPortal_FetchFormatID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatContents.DataPortal_FetchFormatID", ex);
throw new DbCslaException("FormatContents.DataPortal_Fetch", ex); throw new DbCslaException("FormatContents.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class FormatContentsPropertyDescriptor : vlnListPropertyDescriptor public partial class FormatContentsPropertyDescriptor : vlnListPropertyDescriptor
{ {
private FormatContent Item { get { return (FormatContent) _Item;} } private FormatContent Item { get { return (FormatContent)_Item; } }
public FormatContentsPropertyDescriptor(FormatContents collection, int index):base(collection, index){;} public FormatContentsPropertyDescriptor(FormatContents collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is FormatContents) if (destType == typeof(string) && value is FormatContents)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((FormatContents) value).Items.Count.ToString() + " Contents"; return ((FormatContents)value).Items.Count.ToString() + " Contents";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("VersionID",true); CanReadProperty("VersionID", true);
if (_MyDocVersion != null) _VersionID = _MyDocVersion.VersionID; if (_MyDocVersion != null) _VersionID = _MyDocVersion.VersionID;
return _VersionID; return _VersionID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyDocVersion",true); CanReadProperty("MyDocVersion", true);
if (_MyDocVersion == null && _VersionID != 0) _MyDocVersion = DocVersion.Get(_VersionID); if (_MyDocVersion == null && _VersionID != 0) _MyDocVersion = DocVersion.Get(_VersionID);
return _MyDocVersion; return _MyDocVersion;
} }
@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderID",true); CanReadProperty("FolderID", true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID; if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID; return _FolderID;
} }
@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFolder",true); CanReadProperty("MyFolder", true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID); if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder; return _MyFolder;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyFolder",true); CanWriteProperty("MyFolder", true);
if (_MyFolder != value) if (_MyFolder != value)
{ {
_MyFolder = value; _MyFolder = value;
@ -100,13 +100,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("VersionType",true); CanReadProperty("VersionType", true);
return _VersionType; return _VersionType;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("VersionType",true); CanWriteProperty("VersionType", true);
if (_VersionType != value) if (_VersionType != value)
{ {
_VersionType = value; _VersionType = value;
@ -120,13 +120,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name",true); CanReadProperty("Name", true);
return _Name; return _Name;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Name",true); CanWriteProperty("Name", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Name != value) if (_Name != value)
{ {
@ -141,13 +141,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Title",true); CanReadProperty("Title", true);
return _Title; return _Title;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Title",true); CanWriteProperty("Title", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Title != value) if (_Title != value)
{ {
@ -162,7 +162,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemID",true); CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID; if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID; return _ItemID;
} }
@ -173,18 +173,18 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItem",true); CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != null) _MyItem = Item.Get((int)_ItemID); if (_MyItem == null && _ItemID != null) _MyItem = Item.Get((int)_ItemID);
return _MyItem; return _MyItem;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyItem",true); CanWriteProperty("MyItem", true);
if (_MyItem != value) if (_MyItem != value)
{ {
_MyItem = value; _MyItem = value;
_ItemID = (value == null ? null : (int?) value.ItemID); _ItemID = (value == null ? null : (int?)value.ItemID);
PropertyHasChanged(); PropertyHasChanged();
} }
} }
@ -195,13 +195,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -216,13 +216,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -236,13 +236,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -258,7 +258,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_ParentID",true); CanReadProperty("Folder_ParentID", true);
return _Folder_ParentID; return _Folder_ParentID;
} }
} }
@ -268,7 +268,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_DBID",true); CanReadProperty("Folder_DBID", true);
return _Folder_DBID; return _Folder_DBID;
} }
} }
@ -278,7 +278,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_Name",true); CanReadProperty("Folder_Name", true);
return _Folder_Name; return _Folder_Name;
} }
} }
@ -288,7 +288,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_Title",true); CanReadProperty("Folder_Title", true);
return _Folder_Title; return _Folder_Title;
} }
} }
@ -298,7 +298,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_ShortName",true); CanReadProperty("Folder_ShortName", true);
return _Folder_ShortName; return _Folder_ShortName;
} }
} }
@ -308,7 +308,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_FormatID",true); CanReadProperty("Folder_FormatID", true);
return _Folder_FormatID; return _Folder_FormatID;
} }
} }
@ -318,7 +318,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_Config",true); CanReadProperty("Folder_Config", true);
return _Folder_Config; return _Folder_Config;
} }
} }
@ -328,7 +328,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_DTS",true); CanReadProperty("Folder_DTS", true);
return _Folder_DTS; return _Folder_DTS;
} }
} }
@ -338,7 +338,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_UsrID",true); CanReadProperty("Folder_UsrID", true);
return _Folder_UsrID; return _Folder_UsrID;
} }
} }
@ -371,24 +371,24 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules;
if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -519,8 +519,8 @@ namespace VEPROMS.CSLA.Library
_VersionType = _FormatDocVersionExtension.DefaultVersionType; _VersionType = _FormatDocVersionExtension.DefaultVersionType;
_DTS = _FormatDocVersionExtension.DefaultDTS; _DTS = _FormatDocVersionExtension.DefaultDTS;
_UserID = _FormatDocVersionExtension.DefaultUserID; _UserID = _FormatDocVersionExtension.DefaultUserID;
_MyFolder = myFolder; _MyFolder = myFolder;
_Name = name; _Name = name;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal FormatDocVersion(SafeDataReader dr) internal FormatDocVersion(SafeDataReader dr)
@ -532,7 +532,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatDocVersion.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatDocVersion.FetchDR", GetHashCode());
try try
{ {
_VersionID = dr.GetInt32("VersionID"); _VersionID = dr.GetInt32("VersionID");
@ -557,7 +557,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatDocVersion.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatDocVersion.FetchDR", ex);
throw new DbCslaException("FormatDocVersion.Fetch", ex); throw new DbCslaException("FormatDocVersion.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public FormatDocVersion Add(Folder myFolder, string name) // One to Many public FormatDocVersion Add(Folder myFolder, string name) // One to Many
{ {
FormatDocVersion docVersion = FormatDocVersion.New(myFolder, name); FormatDocVersion docVersion = FormatDocVersion.New(myFolder, name);
this.Add(docVersion); this.Add(docVersion);
return docVersion; return docVersion;
} }
public void Remove(DocVersion myDocVersion) public void Remove(DocVersion myDocVersion)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(FormatDocVersion formatDocVersion in this) foreach (FormatDocVersion formatDocVersion in this)
if ((hasBrokenRules = formatDocVersion.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = formatDocVersion.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(FormatIDCriteria criteria) private void DataPortal_Fetch(FormatIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatDocVersions.DataPortal_FetchFormatID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatDocVersions.DataPortal_FetchFormatID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatDocVersions.DataPortal_FetchFormatID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatDocVersions.DataPortal_FetchFormatID", ex);
throw new DbCslaException("FormatDocVersions.DataPortal_Fetch", ex); throw new DbCslaException("FormatDocVersions.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class FormatDocVersionsPropertyDescriptor : vlnListPropertyDescriptor public partial class FormatDocVersionsPropertyDescriptor : vlnListPropertyDescriptor
{ {
private FormatDocVersion Item { get { return (FormatDocVersion) _Item;} } private FormatDocVersion Item { get { return (FormatDocVersion)_Item; } }
public FormatDocVersionsPropertyDescriptor(FormatDocVersions collection, int index):base(collection, index){;} public FormatDocVersionsPropertyDescriptor(FormatDocVersions collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is FormatDocVersions) if (destType == typeof(string) && value is FormatDocVersions)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((FormatDocVersions) value).Items.Count.ToString() + " DocVersions"; return ((FormatDocVersions)value).Items.Count.ToString() + " DocVersions";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderID",true); CanReadProperty("FolderID", true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID; if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID; return _FolderID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFolder",true); CanReadProperty("MyFolder", true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID); if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder; return _MyFolder;
} }
@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ParentID",true); CanReadProperty("ParentID", true);
if (_MyParent != null) _ParentID = _MyParent.FolderID; if (_MyParent != null) _ParentID = _MyParent.FolderID;
return _ParentID; return _ParentID;
} }
@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyParent",true); CanReadProperty("MyParent", true);
if (_MyParent == null && _ParentID != _FolderID) _MyParent = Folder.Get(_ParentID); if (_MyParent == null && _ParentID != _FolderID) _MyParent = Folder.Get(_ParentID);
return _MyParent; return _MyParent;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyParent",true); CanWriteProperty("MyParent", true);
if (_MyParent != value) if (_MyParent != value)
{ {
_MyParent = value; _MyParent = value;
@ -97,7 +97,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DBID",true); CanReadProperty("DBID", true);
if (_MyConnection != null) _DBID = _MyConnection.DBID; if (_MyConnection != null) _DBID = _MyConnection.DBID;
return _DBID; return _DBID;
} }
@ -108,14 +108,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyConnection",true); CanReadProperty("MyConnection", true);
if (_MyConnection == null && _DBID != 0) _MyConnection = Connection.Get(_DBID); if (_MyConnection == null && _DBID != 0) _MyConnection = Connection.Get(_DBID);
return _MyConnection; return _MyConnection;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyConnection",true); CanWriteProperty("MyConnection", true);
if (_MyConnection != value) if (_MyConnection != value)
{ {
_MyConnection = value; _MyConnection = value;
@ -129,13 +129,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name",true); CanReadProperty("Name", true);
return _Name; return _Name;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Name",true); CanWriteProperty("Name", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Name != value) if (_Name != value)
{ {
@ -150,13 +150,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Title",true); CanReadProperty("Title", true);
return _Title; return _Title;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Title",true); CanWriteProperty("Title", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Title != value) if (_Title != value)
{ {
@ -171,13 +171,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ShortName",true); CanReadProperty("ShortName", true);
return _ShortName; return _ShortName;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("ShortName",true); CanWriteProperty("ShortName", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_ShortName != value) if (_ShortName != value)
{ {
@ -192,13 +192,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -213,13 +213,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -233,13 +233,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UsrID",true); CanWriteProperty("UsrID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UsrID != value) if (_UsrID != value)
{ {
@ -255,7 +255,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Connection_Name",true); CanReadProperty("Connection_Name", true);
return _Connection_Name; return _Connection_Name;
} }
} }
@ -265,7 +265,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Connection_Title",true); CanReadProperty("Connection_Title", true);
return _Connection_Title; return _Connection_Title;
} }
} }
@ -275,7 +275,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Connection_ConnectionString",true); CanReadProperty("Connection_ConnectionString", true);
return _Connection_ConnectionString; return _Connection_ConnectionString;
} }
} }
@ -288,7 +288,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Connection_ServerType",true); CanReadProperty("Connection_ServerType", true);
return _Connection_ServerType; return _Connection_ServerType;
} }
} }
@ -298,7 +298,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Connection_Config",true); CanReadProperty("Connection_Config", true);
return _Connection_Config; return _Connection_Config;
} }
} }
@ -308,7 +308,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Connection_DTS",true); CanReadProperty("Connection_DTS", true);
return _Connection_DTS; return _Connection_DTS;
} }
} }
@ -318,7 +318,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Connection_UsrID",true); CanReadProperty("Connection_UsrID", true);
return _Connection_UsrID; return _Connection_UsrID;
} }
} }
@ -351,24 +351,24 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules;
if (_MyConnection != null && (hasBrokenRules = _MyConnection.HasBrokenRules) != null) return hasBrokenRules; if (_MyConnection != null && (hasBrokenRules = _MyConnection.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -516,9 +516,9 @@ namespace VEPROMS.CSLA.Library
_DBID = _FormatFolderExtension.DefaultDBID; _DBID = _FormatFolderExtension.DefaultDBID;
_DTS = _FormatFolderExtension.DefaultDTS; _DTS = _FormatFolderExtension.DefaultDTS;
_UsrID = _FormatFolderExtension.DefaultUsrID; _UsrID = _FormatFolderExtension.DefaultUsrID;
_MyParent = myParent; _MyParent = myParent;
_Name = name; _Name = name;
_ShortName = shortName; _ShortName = shortName;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal FormatFolder(SafeDataReader dr) internal FormatFolder(SafeDataReader dr)
@ -530,7 +530,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatFolder.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatFolder.FetchDR", GetHashCode());
try try
{ {
_FolderID = dr.GetInt32("FolderID"); _FolderID = dr.GetInt32("FolderID");
@ -553,7 +553,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatFolder.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatFolder.FetchDR", ex);
throw new DbCslaException("FormatFolder.Fetch", ex); throw new DbCslaException("FormatFolder.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public FormatFolder Add(Folder myParent, string name, string shortName) // One to Many public FormatFolder Add(Folder myParent, string name, string shortName) // One to Many
{ {
FormatFolder folder = FormatFolder.New(myParent, name, shortName); FormatFolder folder = FormatFolder.New(myParent, name, shortName);
this.Add(folder); this.Add(folder);
return folder; return folder;
} }
public void Remove(Folder myFolder) public void Remove(Folder myFolder)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(FormatFolder formatFolder in this) foreach (FormatFolder formatFolder in this)
if ((hasBrokenRules = formatFolder.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = formatFolder.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(FormatIDCriteria criteria) private void DataPortal_Fetch(FormatIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatFolders.DataPortal_FetchFormatID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatFolders.DataPortal_FetchFormatID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatFolders.DataPortal_FetchFormatID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatFolders.DataPortal_FetchFormatID", ex);
throw new DbCslaException("FormatFolders.DataPortal_Fetch", ex); throw new DbCslaException("FormatFolders.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class FormatFoldersPropertyDescriptor : vlnListPropertyDescriptor public partial class FormatFoldersPropertyDescriptor : vlnListPropertyDescriptor
{ {
private FormatFolder Item { get { return (FormatFolder) _Item;} } private FormatFolder Item { get { return (FormatFolder)_Item; } }
public FormatFoldersPropertyDescriptor(FormatFolders collection, int index):base(collection, index){;} public FormatFoldersPropertyDescriptor(FormatFolders collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is FormatFolders) if (destType == typeof(string) && value is FormatFolders)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((FormatFolders) value).Items.Count.ToString() + " Folders"; return ((FormatFolders)value).Items.Count.ToString() + " Folders";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<FormatInfo> _AllList = new List<FormatInfo>(); protected static List<FormatInfo> _AllList = new List<FormatInfo>();
private static Dictionary<string, FormatInfo> _AllByPrimaryKey = new Dictionary<string, FormatInfo>(); private static Dictionary<string, List<FormatInfo>> _AllByPrimaryKey = new Dictionary<string, List<FormatInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<FormatInfo> remove = new List<FormatInfo>(); List<FormatInfo> remove = new List<FormatInfo>();
foreach (FormatInfo tmp in _AllList) foreach (FormatInfo tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.FormatID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.FormatID.ToString()))
{
_AllByPrimaryKey[tmp.FormatID.ToString()] = new List<FormatInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.FormatID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (FormatInfo tmp in remove) foreach (FormatInfo tmp in remove)
@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = formatID.ToString(); string key = formatID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatID",true); CanReadProperty("FormatID", true);
return _FormatID; return _FormatID;
} }
} }
@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ParentID",true); CanReadProperty("ParentID", true);
if (_MyParent != null) _ParentID = _MyParent.FormatID; if (_MyParent != null) _ParentID = _MyParent.FormatID;
return _ParentID; return _ParentID;
} }
@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyParent",true); CanReadProperty("MyParent", true);
if (_MyParent == null && _ParentID != _FormatID) _MyParent = FormatInfo.Get(_ParentID); if (_MyParent == null && _ParentID != _FormatID) _MyParent = FormatInfo.Get(_ParentID);
return _MyParent; return _MyParent;
} }
@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name",true); CanReadProperty("Name", true);
return _Name; return _Name;
} }
} }
@ -127,7 +131,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Description",true); CanReadProperty("Description", true);
return _Description; return _Description;
} }
} }
@ -137,7 +141,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Data",true); CanReadProperty("Data", true);
return _Data; return _Data;
} }
} }
@ -147,7 +151,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GenMac",true); CanReadProperty("GenMac", true);
return _GenMac; return _GenMac;
} }
} }
@ -157,7 +161,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -167,7 +171,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
} }
@ -180,7 +184,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatContentCount",true); CanReadProperty("FormatContentCount", true);
return _FormatContentCount; return _FormatContentCount;
} }
} }
@ -191,7 +195,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatContents",true); CanReadProperty("FormatContents", true);
if (_FormatContentCount < 0 || (_FormatContentCount > 0 && _FormatContents == null)) if (_FormatContentCount < 0 || (_FormatContentCount > 0 && _FormatContents == null))
_FormatContents = ContentInfoList.GetByFormatID(_FormatID); _FormatContents = ContentInfoList.GetByFormatID(_FormatID);
if (_FormatContentCount < 0) if (_FormatContentCount < 0)
@ -201,7 +205,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshFormatContents() internal void RefreshFormatContents()
{ {
_FormatContentCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_FormatID.ToString()))
foreach (FormatInfo tmp in _AllByPrimaryKey[_FormatID.ToString()])
tmp._FormatContentCount = -1; // This will cause the data to be requeried
} }
private int _FormatDocVersionCount = 0; private int _FormatDocVersionCount = 0;
/// <summary> /// <summary>
@ -212,7 +219,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatDocVersionCount",true); CanReadProperty("FormatDocVersionCount", true);
return _FormatDocVersionCount; return _FormatDocVersionCount;
} }
} }
@ -223,7 +230,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatDocVersions",true); CanReadProperty("FormatDocVersions", true);
if (_FormatDocVersionCount < 0 || (_FormatDocVersionCount > 0 && _FormatDocVersions == null)) if (_FormatDocVersionCount < 0 || (_FormatDocVersionCount > 0 && _FormatDocVersions == null))
_FormatDocVersions = DocVersionInfoList.GetByFormatID(_FormatID); _FormatDocVersions = DocVersionInfoList.GetByFormatID(_FormatID);
if (_FormatDocVersionCount < 0) if (_FormatDocVersionCount < 0)
@ -233,7 +240,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshFormatDocVersions() internal void RefreshFormatDocVersions()
{ {
_FormatDocVersionCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_FormatID.ToString()))
foreach (FormatInfo tmp in _AllByPrimaryKey[_FormatID.ToString()])
tmp._FormatDocVersionCount = -1; // This will cause the data to be requeried
} }
private int _FormatFolderCount = 0; private int _FormatFolderCount = 0;
/// <summary> /// <summary>
@ -244,7 +254,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatFolderCount",true); CanReadProperty("FormatFolderCount", true);
return _FormatFolderCount; return _FormatFolderCount;
} }
} }
@ -255,7 +265,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatFolders",true); CanReadProperty("FormatFolders", true);
if (_FormatFolderCount < 0 || (_FormatFolderCount > 0 && _FormatFolders == null)) if (_FormatFolderCount < 0 || (_FormatFolderCount > 0 && _FormatFolders == null))
_FormatFolders = FolderInfoList.GetByFormatID(_FormatID); _FormatFolders = FolderInfoList.GetByFormatID(_FormatID);
if (_FormatFolderCount < 0) if (_FormatFolderCount < 0)
@ -265,7 +275,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshFormatFolders() internal void RefreshFormatFolders()
{ {
_FormatFolderCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_FormatID.ToString()))
foreach (FormatInfo tmp in _AllByPrimaryKey[_FormatID.ToString()])
tmp._FormatFolderCount = -1; // This will cause the data to be requeried
} }
private int _ChildFormatCount = 0; private int _ChildFormatCount = 0;
/// <summary> /// <summary>
@ -276,7 +289,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ChildFormatCount",true); CanReadProperty("ChildFormatCount", true);
return _ChildFormatCount; return _ChildFormatCount;
} }
} }
@ -287,7 +300,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ChildFormats",true); CanReadProperty("ChildFormats", true);
if (_ChildFormatCount < 0 || (_ChildFormatCount > 0 && _ChildFormats == null)) if (_ChildFormatCount < 0 || (_ChildFormatCount > 0 && _ChildFormats == null))
_ChildFormats = FormatInfoList.GetChildren(_FormatID); _ChildFormats = FormatInfoList.GetChildren(_FormatID);
if (_ChildFormatCount < 0) if (_ChildFormatCount < 0)
@ -297,7 +310,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshChildFormats() internal void RefreshChildFormats()
{ {
_ChildFormatCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_FormatID.ToString()))
foreach (FormatInfo tmp in _AllByPrimaryKey[_FormatID.ToString()])
tmp._ChildFormatCount = -1; // This will cause the data to be requeried
} }
// TODO: Replace base FormatInfo.ToString function as necessary // TODO: Replace base FormatInfo.ToString function as necessary
/// <summary> /// <summary>
@ -319,14 +335,25 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _FormatInfoUnique = 0;
private int _MyFormatInfoUnique;
public int MyFormatInfoUnique
{
get { return _MyFormatInfoUnique; }
}
private FormatInfo() private FormatInfo()
{/* require use of factory methods */ {/* require use of factory methods */
_MyFormatInfoUnique = ++_FormatInfoUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(FormatID.ToString()); if (!_AllByPrimaryKey.ContainsKey(FormatID.ToString())) return;
List<FormatInfo> listFormatInfo = _AllByPrimaryKey[FormatID.ToString()]; // Get the list of items
listFormatInfo.Remove(this); // Remove the item from the list
if (listFormatInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(FormatID.ToString()); // remove the list
} }
public virtual Format Get() public virtual Format Get()
{ {
@ -334,9 +361,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(Format tmp) public static void Refresh(Format tmp)
{ {
FormatInfo tmpInfo = GetExistingByPrimaryKey(tmp.FormatID); string key = tmp.FormatID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (FormatInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(Format tmp) private void RefreshFields(Format tmp)
{ {
@ -344,9 +373,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyParent.RefreshChildFormats(); // Update List for old value MyParent.RefreshChildFormats(); // Update List for old value
_ParentID = tmp.ParentID; // Update the value _ParentID = tmp.ParentID; // Update the value
_MyParent = null; // Reset list so that the next line gets a new list
MyParent.RefreshChildFormats(); // Update List for new value
} }
_MyParent = null; // Reset list so that the next line gets a new list
if (MyParent != null) MyParent.RefreshChildFormats(); // Update List for new value
_Name = tmp.Name; _Name = tmp.Name;
_Description = tmp.Description; _Description = tmp.Description;
_Data = tmp.Data; _Data = tmp.Data;
@ -367,7 +396,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<FormatInfo>(new PKCriteria(formatID)); tmp = DataPortal.Fetch<FormatInfo>(new PKCriteria(formatID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -381,14 +410,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
internal FormatInfo(SafeDataReader dr) internal FormatInfo(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatInfo.Constructor", GetHashCode()); _MyFormatInfoUnique = ++_FormatInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfo.Constructor", GetHashCode());
try try
{ {
ReadData(dr); ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatInfo.Constructor", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatInfo.Constructor", ex);
throw new DbCslaException("FormatInfo.Constructor", ex); throw new DbCslaException("FormatInfo.Constructor", ex);
} }
} }
@ -405,7 +435,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatInfo.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfo.ReadData", GetHashCode());
try try
{ {
_FormatID = dr.GetInt32("FormatID"); _FormatID = dr.GetInt32("FormatID");
@ -423,14 +453,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatInfo.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatInfo.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("FormatInfo.ReadData", ex); throw new DbCslaException("FormatInfo.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfo.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -458,7 +488,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatInfo.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("FormatInfo.DataPortal_Fetch", ex); throw new DbCslaException("FormatInfo.DataPortal_Fetch", ex);
} }
@ -468,7 +498,7 @@ namespace VEPROMS.CSLA.Library
#region extension #region extension
FormatInfoExtension _FormatInfoExtension = new FormatInfoExtension(); FormatInfoExtension _FormatInfoExtension = new FormatInfoExtension();
[Serializable()] [Serializable()]
partial class FormatInfoExtension : extensionBase {} partial class FormatInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {

View File

@ -110,7 +110,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -130,7 +130,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("FormatInfoList.DataPortal_Fetch", ex); throw new DbCslaException("FormatInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -152,7 +152,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ParentIDCriteria criteria) private void DataPortal_Fetch(ParentIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatInfoList.DataPortal_FetchParentID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfoList.DataPortal_FetchParentID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -173,7 +173,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatInfoList.DataPortal_FetchParentID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatInfoList.DataPortal_FetchParentID", ex);
throw new DbCslaException("FormatInfoList.DataPortal_Fetch", ex); throw new DbCslaException("FormatInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -234,8 +234,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class FormatInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class FormatInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private FormatInfo Item { get { return (FormatInfo) _Item;} } private FormatInfo Item { get { return (FormatInfo)_Item; } }
public FormatInfoListPropertyDescriptor(FormatInfoList collection, int index):base(collection, index){;} public FormatInfoListPropertyDescriptor(FormatInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -246,7 +246,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is FormatInfoList) if (destType == typeof(string) && value is FormatInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((FormatInfoList) value).Items.Count.ToString() + " Formats"; return ((FormatInfoList)value).Items.Count.ToString() + " Formats";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -42,14 +42,14 @@ namespace VEPROMS.CSLA.Library
{ {
foreach (GroupAssignment tmp in _GroupAssignments) foreach (GroupAssignment tmp in _GroupAssignments)
{ {
if(tmp.IsDirty)refreshGroupAssignments.Add(tmp); if (tmp.IsDirty) refreshGroupAssignments.Add(tmp);
} }
} }
if (_GroupMemberships != null && _GroupMemberships.IsDirty) if (_GroupMemberships != null && _GroupMemberships.IsDirty)
{ {
foreach (GroupMembership tmp in _GroupMemberships) foreach (GroupMembership tmp in _GroupMemberships)
{ {
if(tmp.IsDirty)refreshGroupMemberships.Add(tmp); if (tmp.IsDirty) refreshGroupMemberships.Add(tmp);
} }
} }
} }
@ -78,15 +78,20 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<Group> _AllList = new List<Group>(); protected static List<Group> _AllList = new List<Group>();
private static Dictionary<string, Group> _AllByPrimaryKey = new Dictionary<string, Group>(); private static Dictionary<string, List<Group>> _AllByPrimaryKey = new Dictionary<string, List<Group>>();
private static Dictionary<string, Group> _AllByGroupName = new Dictionary<string, Group>(); private static Dictionary<string, List<Group>> _AllByGroupName = new Dictionary<string, List<Group>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<Group> remove = new List<Group>(); List<Group> remove = new List<Group>();
foreach (Group tmp in _AllList) foreach (Group tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.GID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.GID.ToString()))
_AllByGroupName[tmp.GroupName.ToString()] = tmp; // Unique Index {
_AllByPrimaryKey[tmp.GID.ToString()] = new List<Group>(); // Add new list for PrimaryKey
_AllByGroupName[tmp.GroupName.ToString()] = new List<Group>(); // Add new list for GroupName
}
_AllByPrimaryKey[tmp.GID.ToString()].Add(tmp); // Add to Primary Key list
_AllByGroupName[tmp.GroupName.ToString()].Add(tmp); // Unique Index
remove.Add(tmp); remove.Add(tmp);
} }
foreach (Group tmp in remove) foreach (Group tmp in remove)
@ -96,14 +101,14 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = gid.ToString(); string key = gid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
public static Group GetExistingByGroupName(string groupName) public static Group GetExistingByGroupName(string groupName)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = groupName.ToString(); string key = groupName.ToString();
if (_AllByGroupName.ContainsKey(key)) return _AllByGroupName[key]; if (_AllByGroupName.ContainsKey(key)) return _AllByGroupName[key][0];
return null; return null;
} }
#endregion #endregion
@ -125,7 +130,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GID",true); CanReadProperty("GID", true);
return _GID; return _GID;
} }
} }
@ -135,13 +140,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GroupName",true); CanReadProperty("GroupName", true);
return _GroupName; return _GroupName;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("GroupName",true); CanWriteProperty("GroupName", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_GroupName != value) if (_GroupName != value)
{ {
@ -156,13 +161,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GroupType",true); CanReadProperty("GroupType", true);
return _GroupType; return _GroupType;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("GroupType",true); CanWriteProperty("GroupType", true);
if (_GroupType != value) if (_GroupType != value)
{ {
_GroupType = value; _GroupType = value;
@ -176,13 +181,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -197,13 +202,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -217,13 +222,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UsrID",true); CanWriteProperty("UsrID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UsrID != value) if (_UsrID != value)
{ {
@ -242,7 +247,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GroupAssignmentCount",true); CanReadProperty("GroupAssignmentCount", true);
return _GroupAssignmentCount; return _GroupAssignmentCount;
} }
} }
@ -256,10 +261,10 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GroupAssignments",true); CanReadProperty("GroupAssignments", true);
if(_GroupAssignmentCount > 0 && _GroupAssignments == null) if (_GroupAssignmentCount > 0 && _GroupAssignments == null)
_GroupAssignments = GroupAssignments.GetByGID(GID); _GroupAssignments = GroupAssignments.GetByGID(GID);
else if(_GroupAssignments == null) else if (_GroupAssignments == null)
_GroupAssignments = GroupAssignments.New(); _GroupAssignments = GroupAssignments.New();
return _GroupAssignments; return _GroupAssignments;
} }
@ -273,7 +278,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GroupMembershipCount",true); CanReadProperty("GroupMembershipCount", true);
return _GroupMembershipCount; return _GroupMembershipCount;
} }
} }
@ -287,21 +292,21 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GroupMemberships",true); CanReadProperty("GroupMemberships", true);
if(_GroupMembershipCount > 0 && _GroupMemberships == null) if (_GroupMembershipCount > 0 && _GroupMemberships == null)
_GroupMemberships = GroupMemberships.GetByGID(GID); _GroupMemberships = GroupMemberships.GetByGID(GID);
else if(_GroupMemberships == null) else if (_GroupMemberships == null)
_GroupMemberships = GroupMemberships.New(); _GroupMemberships = GroupMemberships.New();
return _GroupMemberships; return _GroupMemberships;
} }
} }
public override bool IsDirty public override bool IsDirty
{ {
get { return base.IsDirty || (_GroupAssignments == null? false : _GroupAssignments.IsDirty) || (_GroupMemberships == null? false : _GroupMemberships.IsDirty); } get { return base.IsDirty || (_GroupAssignments == null ? false : _GroupAssignments.IsDirty) || (_GroupMemberships == null ? false : _GroupMemberships.IsDirty); }
} }
public override bool IsValid public override bool IsValid
{ {
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_GroupAssignments == null? true : _GroupAssignments.IsValid) && (_GroupMemberships == null? true : _GroupMemberships.IsValid); } get { return (IsNew && !IsDirty ? true : base.IsValid) && (_GroupAssignments == null ? true : _GroupAssignments.IsValid) && (_GroupMemberships == null ? true : _GroupMemberships.IsValid); }
} }
// TODO: Replace base Group.ToString function as necessary // TODO: Replace base Group.ToString function as necessary
/// <summary> /// <summary>
@ -324,23 +329,24 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get { get
if(_CheckingBrokenRules)return null; {
if (_CheckingBrokenRules) return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_GroupAssignments != null && (hasBrokenRules = _GroupAssignments.HasBrokenRules) != null) return hasBrokenRules; if (_GroupAssignments != null && (hasBrokenRules = _GroupAssignments.HasBrokenRules) != null) return hasBrokenRules;
if (_GroupMemberships != null && (hasBrokenRules = _GroupMemberships.HasBrokenRules) != null) return hasBrokenRules; if (_GroupMemberships != null && (hasBrokenRules = _GroupMemberships.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -455,15 +461,29 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods #region Factory Methods
public int CurrentEditLevel public int CurrentEditLevel
{ get { return EditLevel; } } { get { return EditLevel; } }
private static int _GroupUnique = 0;
private int _MyGroupUnique;
public int MyGroupUnique
{
get { return _MyGroupUnique; }
}
protected Group() protected Group()
{/* require use of factory methods */ {/* require use of factory methods */
_MyGroupUnique = ++_GroupUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(GID.ToString()); if (!_AllByPrimaryKey.ContainsKey(GID.ToString())) return;
_AllByGroupName.Remove(GroupName.ToString()); List<Group> listGroup = _AllByPrimaryKey[GID.ToString()]; // Get the list of items
listGroup.Remove(this); // Remove the item from the list
if (listGroup.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(GID.ToString()); // remove the list
listGroup = _AllByGroupName[GID.ToString()]; // Get the list of items
listGroup.Remove(this); // Remove the item from the list
if (listGroup.Count == 0) //If there are no items left in the list
_AllByGroupName.Remove(GID.ToString()); // remove the list
} }
public static Group New() public static Group New()
{ {
@ -544,7 +564,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<Group>(new PKCriteria(gid)); tmp = DataPortal.Fetch<Group>(new PKCriteria(gid));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -563,8 +583,8 @@ namespace VEPROMS.CSLA.Library
Group tmp = GetExistingByGroupName(groupName); Group tmp = GetExistingByGroupName(groupName);
if (tmp == null) if (tmp == null)
{ {
tmp=DataPortal.Fetch<Group>(new GroupNameCriteria(groupName)); tmp = DataPortal.Fetch<Group>(new GroupNameCriteria(groupName));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -654,7 +674,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Group.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.ReadData", GetHashCode());
try try
{ {
_GID = dr.GetInt32("GID"); _GID = dr.GetInt32("GID");
@ -670,14 +690,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Group.ReadData", ex); throw new DbCslaException("Group.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Group.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -711,14 +731,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Group.DataPortal_Fetch", ex); throw new DbCslaException("Group.DataPortal_Fetch", ex);
} }
} }
private void DataPortal_Fetch(GroupNameCriteria criteria) private void DataPortal_Fetch(GroupNameCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Group.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -746,7 +766,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Group.DataPortal_Fetch", ex); throw new DbCslaException("Group.DataPortal_Fetch", ex);
} }
@ -767,13 +787,13 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.DataPortal_Insert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.DataPortal_Insert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Group.DataPortal_Insert", ex); throw new DbCslaException("Group.DataPortal_Insert", ex);
} }
finally finally
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Group.DataPortal_Insert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.DataPortal_Insert", GetHashCode());
} }
} }
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
@ -810,11 +830,11 @@ namespace VEPROMS.CSLA.Library
// update child objects // update child objects
if (_GroupAssignments != null) _GroupAssignments.Update(this); if (_GroupAssignments != null) _GroupAssignments.Update(this);
if (_GroupMemberships != null) _GroupMemberships.Update(this); if (_GroupMemberships != null) _GroupMemberships.Update(this);
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Group.SQLInsert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.SQLInsert", GetHashCode());
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.SQLInsert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.SQLInsert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Group.SQLInsert", ex); throw new DbCslaException("Group.SQLInsert", ex);
} }
@ -822,7 +842,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int gid, string groupName, int? groupType, string config, DateTime dts, string usrID) public static byte[] Add(SqlConnection cn, ref int gid, string groupName, int? groupType, string config, DateTime dts, string usrID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Group.Add", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.Add", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -851,7 +871,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.Add", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.Add", ex);
throw new DbCslaException("Group.Add", ex); throw new DbCslaException("Group.Add", ex);
} }
} }
@ -859,7 +879,7 @@ namespace VEPROMS.CSLA.Library
protected override void DataPortal_Update() protected override void DataPortal_Update()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Group.DataPortal_Update", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.DataPortal_Update", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -873,7 +893,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.DataPortal_Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.DataPortal_Update", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -882,7 +902,7 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate() internal void SQLUpdate()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Group.SQLUpdate", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.SQLUpdate", GetHashCode());
try try
{ {
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
@ -917,7 +937,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.SQLUpdate", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.SQLUpdate", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -940,7 +960,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int gid, string groupName, int? groupType, string config, DateTime dts, string usrID, ref byte[] lastChanged) public static byte[] Update(SqlConnection cn, ref int gid, string groupName, int? groupType, string config, DateTime dts, string usrID, ref byte[] lastChanged)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Group.Update", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.Update", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -967,7 +987,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.Update", ex);
throw new DbCslaException("Group.Update", ex); throw new DbCslaException("Group.Update", ex);
} }
} }
@ -979,7 +999,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria) private void DataPortal_Delete(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Group.DataPortal_Delete", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.DataPortal_Delete", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -995,7 +1015,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.DataPortal_Delete", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.DataPortal_Delete", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Group.DataPortal_Delete", ex); throw new DbCslaException("Group.DataPortal_Delete", ex);
} }
@ -1003,7 +1023,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int gid) public static void Remove(SqlConnection cn, int gid)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Group.Remove", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.Remove", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -1018,7 +1038,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.Remove", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.Remove", ex);
throw new DbCslaException("Group.Remove", ex); throw new DbCslaException("Group.Remove", ex);
} }
} }
@ -1052,7 +1072,7 @@ namespace VEPROMS.CSLA.Library
} }
protected override void DataPortal_Execute() protected override void DataPortal_Execute()
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Group.DataPortal_Execute", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.DataPortal_Execute", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1070,7 +1090,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.DataPortal_Execute", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.DataPortal_Execute", ex);
throw new DbCslaException("Group.DataPortal_Execute", ex); throw new DbCslaException("Group.DataPortal_Execute", ex);
} }
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AID",true); CanReadProperty("AID", true);
if (_MyAssignment != null) _AID = _MyAssignment.AID; if (_MyAssignment != null) _AID = _MyAssignment.AID;
return _AID; return _AID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyAssignment",true); CanReadProperty("MyAssignment", true);
if (_MyAssignment == null && _AID != 0) _MyAssignment = Assignment.Get(_AID); if (_MyAssignment == null && _AID != 0) _MyAssignment = Assignment.Get(_AID);
return _MyAssignment; return _MyAssignment;
} }
@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RID",true); CanReadProperty("RID", true);
if (_MyRole != null) _RID = _MyRole.RID; if (_MyRole != null) _RID = _MyRole.RID;
return _RID; return _RID;
} }
@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyRole",true); CanReadProperty("MyRole", true);
if (_MyRole == null && _RID != 0) _MyRole = Role.Get(_RID); if (_MyRole == null && _RID != 0) _MyRole = Role.Get(_RID);
return _MyRole; return _MyRole;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyRole",true); CanWriteProperty("MyRole", true);
if (_MyRole != value) if (_MyRole != value)
{ {
_MyRole = value; _MyRole = value;
@ -97,7 +97,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderID",true); CanReadProperty("FolderID", true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID; if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID; return _FolderID;
} }
@ -108,14 +108,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFolder",true); CanReadProperty("MyFolder", true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID); if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder; return _MyFolder;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyFolder",true); CanWriteProperty("MyFolder", true);
if (_MyFolder != value) if (_MyFolder != value)
{ {
_MyFolder = value; _MyFolder = value;
@ -129,13 +129,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("StartDate",true); CanReadProperty("StartDate", true);
return _StartDate; return _StartDate;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("StartDate",true); CanWriteProperty("StartDate", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
_StartDate = value; _StartDate = value;
try try
@ -159,13 +159,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("EndDate",true); CanReadProperty("EndDate", true);
return _EndDate; return _EndDate;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("EndDate",true); CanWriteProperty("EndDate", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
_EndDate = value; _EndDate = value;
try try
@ -189,13 +189,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -209,13 +209,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UsrID",true); CanWriteProperty("UsrID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UsrID != value) if (_UsrID != value)
{ {
@ -231,7 +231,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_ParentID",true); CanReadProperty("Folder_ParentID", true);
return _Folder_ParentID; return _Folder_ParentID;
} }
} }
@ -241,7 +241,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_DBID",true); CanReadProperty("Folder_DBID", true);
return _Folder_DBID; return _Folder_DBID;
} }
} }
@ -251,7 +251,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_Name",true); CanReadProperty("Folder_Name", true);
return _Folder_Name; return _Folder_Name;
} }
} }
@ -261,7 +261,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_Title",true); CanReadProperty("Folder_Title", true);
return _Folder_Title; return _Folder_Title;
} }
} }
@ -271,7 +271,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_ShortName",true); CanReadProperty("Folder_ShortName", true);
return _Folder_ShortName; return _Folder_ShortName;
} }
} }
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_FormatID",true); CanReadProperty("Folder_FormatID", true);
return _Folder_FormatID; return _Folder_FormatID;
} }
} }
@ -291,7 +291,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_Config",true); CanReadProperty("Folder_Config", true);
return _Folder_Config; return _Folder_Config;
} }
} }
@ -301,7 +301,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_DTS",true); CanReadProperty("Folder_DTS", true);
return _Folder_DTS; return _Folder_DTS;
} }
} }
@ -311,7 +311,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_UsrID",true); CanReadProperty("Folder_UsrID", true);
return _Folder_UsrID; return _Folder_UsrID;
} }
} }
@ -321,7 +321,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Role_Name",true); CanReadProperty("Role_Name", true);
return _Role_Name; return _Role_Name;
} }
} }
@ -331,7 +331,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Role_Title",true); CanReadProperty("Role_Title", true);
return _Role_Title; return _Role_Title;
} }
} }
@ -341,7 +341,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Role_DTS",true); CanReadProperty("Role_DTS", true);
return _Role_DTS; return _Role_DTS;
} }
} }
@ -351,7 +351,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Role_UsrID",true); CanReadProperty("Role_UsrID", true);
return _Role_UsrID; return _Role_UsrID;
} }
} }
@ -384,24 +384,24 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyRole != null && (hasBrokenRules = _MyRole.HasBrokenRules) != null) return hasBrokenRules; if (_MyRole != null && (hasBrokenRules = _MyRole.HasBrokenRules) != null) return hasBrokenRules;
if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -557,8 +557,8 @@ namespace VEPROMS.CSLA.Library
_StartDate = _GroupAssignmentExtension.DefaultStartDate; _StartDate = _GroupAssignmentExtension.DefaultStartDate;
_DTS = _GroupAssignmentExtension.DefaultDTS; _DTS = _GroupAssignmentExtension.DefaultDTS;
_UsrID = _GroupAssignmentExtension.DefaultUsrID; _UsrID = _GroupAssignmentExtension.DefaultUsrID;
_MyRole = myRole; _MyRole = myRole;
_MyFolder = myFolder; _MyFolder = myFolder;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal GroupAssignment(SafeDataReader dr) internal GroupAssignment(SafeDataReader dr)
@ -570,7 +570,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupAssignment.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupAssignment.FetchDR", GetHashCode());
try try
{ {
_AID = dr.GetInt32("AID"); _AID = dr.GetInt32("AID");
@ -597,7 +597,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupAssignment.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupAssignment.FetchDR", ex);
throw new DbCslaException("GroupAssignment.Fetch", ex); throw new DbCslaException("GroupAssignment.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public GroupAssignment Add(Role myRole, Folder myFolder) // One to Many public GroupAssignment Add(Role myRole, Folder myFolder) // One to Many
{ {
GroupAssignment assignment = GroupAssignment.New(myRole, myFolder); GroupAssignment assignment = GroupAssignment.New(myRole, myFolder);
this.Add(assignment); this.Add(assignment);
return assignment; return assignment;
} }
public void Remove(Assignment myAssignment) public void Remove(Assignment myAssignment)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(GroupAssignment groupAssignment in this) foreach (GroupAssignment groupAssignment in this)
if ((hasBrokenRules = groupAssignment.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = groupAssignment.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(GIDCriteria criteria) private void DataPortal_Fetch(GIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupAssignments.DataPortal_FetchGID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupAssignments.DataPortal_FetchGID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupAssignments.DataPortal_FetchGID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupAssignments.DataPortal_FetchGID", ex);
throw new DbCslaException("GroupAssignments.DataPortal_Fetch", ex); throw new DbCslaException("GroupAssignments.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class GroupAssignmentsPropertyDescriptor : vlnListPropertyDescriptor public partial class GroupAssignmentsPropertyDescriptor : vlnListPropertyDescriptor
{ {
private GroupAssignment Item { get { return (GroupAssignment) _Item;} } private GroupAssignment Item { get { return (GroupAssignment)_Item; } }
public GroupAssignmentsPropertyDescriptor(GroupAssignments collection, int index):base(collection, index){;} public GroupAssignmentsPropertyDescriptor(GroupAssignments collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is GroupAssignments) if (destType == typeof(string) && value is GroupAssignments)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((GroupAssignments) value).Items.Count.ToString() + " Assignments"; return ((GroupAssignments)value).Items.Count.ToString() + " Assignments";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<GroupInfo> _AllList = new List<GroupInfo>(); protected static List<GroupInfo> _AllList = new List<GroupInfo>();
private static Dictionary<string, GroupInfo> _AllByPrimaryKey = new Dictionary<string, GroupInfo>(); private static Dictionary<string, List<GroupInfo>> _AllByPrimaryKey = new Dictionary<string, List<GroupInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<GroupInfo> remove = new List<GroupInfo>(); List<GroupInfo> remove = new List<GroupInfo>();
foreach (GroupInfo tmp in _AllList) foreach (GroupInfo tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.GID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.GID.ToString()))
{
_AllByPrimaryKey[tmp.GID.ToString()] = new List<GroupInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.GID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (GroupInfo tmp in remove) foreach (GroupInfo tmp in remove)
@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = gid.ToString(); string key = gid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GID",true); CanReadProperty("GID", true);
return _GID; return _GID;
} }
} }
@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GroupName",true); CanReadProperty("GroupName", true);
return _GroupName; return _GroupName;
} }
} }
@ -105,7 +109,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GroupType",true); CanReadProperty("GroupType", true);
return _GroupType; return _GroupType;
} }
} }
@ -115,7 +119,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
} }
@ -125,7 +129,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -135,7 +139,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
} }
@ -148,7 +152,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GroupAssignmentCount",true); CanReadProperty("GroupAssignmentCount", true);
return _GroupAssignmentCount; return _GroupAssignmentCount;
} }
} }
@ -159,7 +163,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GroupAssignments",true); CanReadProperty("GroupAssignments", true);
if (_GroupAssignmentCount < 0 || (_GroupAssignmentCount > 0 && _GroupAssignments == null)) if (_GroupAssignmentCount < 0 || (_GroupAssignmentCount > 0 && _GroupAssignments == null))
_GroupAssignments = AssignmentInfoList.GetByGID(_GID); _GroupAssignments = AssignmentInfoList.GetByGID(_GID);
if (_GroupAssignmentCount < 0) if (_GroupAssignmentCount < 0)
@ -169,7 +173,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshGroupAssignments() internal void RefreshGroupAssignments()
{ {
_GroupAssignmentCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_GID.ToString()))
foreach (GroupInfo tmp in _AllByPrimaryKey[_GID.ToString()])
tmp._GroupAssignmentCount = -1; // This will cause the data to be requeried
} }
private int _GroupMembershipCount = 0; private int _GroupMembershipCount = 0;
/// <summary> /// <summary>
@ -180,7 +187,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GroupMembershipCount",true); CanReadProperty("GroupMembershipCount", true);
return _GroupMembershipCount; return _GroupMembershipCount;
} }
} }
@ -191,7 +198,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GroupMemberships",true); CanReadProperty("GroupMemberships", true);
if (_GroupMembershipCount < 0 || (_GroupMembershipCount > 0 && _GroupMemberships == null)) if (_GroupMembershipCount < 0 || (_GroupMembershipCount > 0 && _GroupMemberships == null))
_GroupMemberships = MembershipInfoList.GetByGID(_GID); _GroupMemberships = MembershipInfoList.GetByGID(_GID);
if (_GroupMembershipCount < 0) if (_GroupMembershipCount < 0)
@ -201,7 +208,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshGroupMemberships() internal void RefreshGroupMemberships()
{ {
_GroupMembershipCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_GID.ToString()))
foreach (GroupInfo tmp in _AllByPrimaryKey[_GID.ToString()])
tmp._GroupMembershipCount = -1; // This will cause the data to be requeried
} }
// TODO: Replace base GroupInfo.ToString function as necessary // TODO: Replace base GroupInfo.ToString function as necessary
/// <summary> /// <summary>
@ -223,14 +233,25 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _GroupInfoUnique = 0;
private int _MyGroupInfoUnique;
public int MyGroupInfoUnique
{
get { return _MyGroupInfoUnique; }
}
private GroupInfo() private GroupInfo()
{/* require use of factory methods */ {/* require use of factory methods */
_MyGroupInfoUnique = ++_GroupInfoUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(GID.ToString()); if (!_AllByPrimaryKey.ContainsKey(GID.ToString())) return;
List<GroupInfo> listGroupInfo = _AllByPrimaryKey[GID.ToString()]; // Get the list of items
listGroupInfo.Remove(this); // Remove the item from the list
if (listGroupInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(GID.ToString()); // remove the list
} }
public virtual Group Get() public virtual Group Get()
{ {
@ -238,9 +259,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(Group tmp) public static void Refresh(Group tmp)
{ {
GroupInfo tmpInfo = GetExistingByPrimaryKey(tmp.GID); string key = tmp.GID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (GroupInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(Group tmp) private void RefreshFields(Group tmp)
{ {
@ -262,7 +285,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<GroupInfo>(new PKCriteria(gid)); tmp = DataPortal.Fetch<GroupInfo>(new PKCriteria(gid));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -276,14 +299,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
internal GroupInfo(SafeDataReader dr) internal GroupInfo(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupInfo.Constructor", GetHashCode()); _MyGroupInfoUnique = ++_GroupInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfo.Constructor", GetHashCode());
try try
{ {
ReadData(dr); ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupInfo.Constructor", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupInfo.Constructor", ex);
throw new DbCslaException("GroupInfo.Constructor", ex); throw new DbCslaException("GroupInfo.Constructor", ex);
} }
} }
@ -300,7 +324,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupInfo.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfo.ReadData", GetHashCode());
try try
{ {
_GID = dr.GetInt32("GID"); _GID = dr.GetInt32("GID");
@ -314,14 +338,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupInfo.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupInfo.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("GroupInfo.ReadData", ex); throw new DbCslaException("GroupInfo.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfo.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -349,7 +373,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupInfo.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("GroupInfo.DataPortal_Fetch", ex); throw new DbCslaException("GroupInfo.DataPortal_Fetch", ex);
} }
@ -359,7 +383,7 @@ namespace VEPROMS.CSLA.Library
#region extension #region extension
GroupInfoExtension _GroupInfoExtension = new GroupInfoExtension(); GroupInfoExtension _GroupInfoExtension = new GroupInfoExtension();
[Serializable()] [Serializable()]
partial class GroupInfoExtension : extensionBase {} partial class GroupInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {

View File

@ -96,7 +96,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -116,7 +116,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("GroupInfoList.DataPortal_Fetch", ex); throw new DbCslaException("GroupInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -177,8 +177,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class GroupInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class GroupInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private GroupInfo Item { get { return (GroupInfo) _Item;} } private GroupInfo Item { get { return (GroupInfo)_Item; } }
public GroupInfoListPropertyDescriptor(GroupInfoList collection, int index):base(collection, index){;} public GroupInfoListPropertyDescriptor(GroupInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -189,7 +189,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is GroupInfoList) if (destType == typeof(string) && value is GroupInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((GroupInfoList) value).Items.Count.ToString() + " Groups"; return ((GroupInfoList)value).Items.Count.ToString() + " Groups";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UGID",true); CanReadProperty("UGID", true);
if (_MyMembership != null) _UGID = _MyMembership.UGID; if (_MyMembership != null) _UGID = _MyMembership.UGID;
return _UGID; return _UGID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyMembership",true); CanReadProperty("MyMembership", true);
if (_MyMembership == null && _UGID != 0) _MyMembership = Membership.Get(_UGID); if (_MyMembership == null && _UGID != 0) _MyMembership = Membership.Get(_UGID);
return _MyMembership; return _MyMembership;
} }
@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UID",true); CanReadProperty("UID", true);
if (_MyUser != null) _UID = _MyUser.UID; if (_MyUser != null) _UID = _MyUser.UID;
return _UID; return _UID;
} }
@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyUser",true); CanReadProperty("MyUser", true);
if (_MyUser == null && _UID != 0) _MyUser = User.Get(_UID); if (_MyUser == null && _UID != 0) _MyUser = User.Get(_UID);
return _MyUser; return _MyUser;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyUser",true); CanWriteProperty("MyUser", true);
if (_MyUser != value) if (_MyUser != value)
{ {
_MyUser = value; _MyUser = value;
@ -97,13 +97,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("StartDate",true); CanReadProperty("StartDate", true);
return _StartDate; return _StartDate;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("StartDate",true); CanWriteProperty("StartDate", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
_StartDate = value; _StartDate = value;
try try
@ -127,13 +127,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("EndDate",true); CanReadProperty("EndDate", true);
return _EndDate; return _EndDate;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("EndDate",true); CanWriteProperty("EndDate", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
_EndDate = value; _EndDate = value;
try try
@ -157,13 +157,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -178,13 +178,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -198,13 +198,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UsrID",true); CanWriteProperty("UsrID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UsrID != value) if (_UsrID != value)
{ {
@ -220,7 +220,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("User_UserID",true); CanReadProperty("User_UserID", true);
return _User_UserID; return _User_UserID;
} }
} }
@ -230,7 +230,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("User_FirstName",true); CanReadProperty("User_FirstName", true);
return _User_FirstName; return _User_FirstName;
} }
} }
@ -240,7 +240,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("User_MiddleName",true); CanReadProperty("User_MiddleName", true);
return _User_MiddleName; return _User_MiddleName;
} }
} }
@ -250,7 +250,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("User_LastName",true); CanReadProperty("User_LastName", true);
return _User_LastName; return _User_LastName;
} }
} }
@ -260,7 +260,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("User_Suffix",true); CanReadProperty("User_Suffix", true);
return _User_Suffix; return _User_Suffix;
} }
} }
@ -270,7 +270,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("User_CourtesyTitle",true); CanReadProperty("User_CourtesyTitle", true);
return _User_CourtesyTitle; return _User_CourtesyTitle;
} }
} }
@ -280,7 +280,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("User_PhoneNumber",true); CanReadProperty("User_PhoneNumber", true);
return _User_PhoneNumber; return _User_PhoneNumber;
} }
} }
@ -290,7 +290,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("User_CFGName",true); CanReadProperty("User_CFGName", true);
return _User_CFGName; return _User_CFGName;
} }
} }
@ -300,7 +300,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("User_UserLogin",true); CanReadProperty("User_UserLogin", true);
return _User_UserLogin; return _User_UserLogin;
} }
} }
@ -310,7 +310,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("User_UserName",true); CanReadProperty("User_UserName", true);
return _User_UserName; return _User_UserName;
} }
} }
@ -320,7 +320,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("User_Config",true); CanReadProperty("User_Config", true);
return _User_Config; return _User_Config;
} }
} }
@ -330,7 +330,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("User_DTS",true); CanReadProperty("User_DTS", true);
return _User_DTS; return _User_DTS;
} }
} }
@ -340,7 +340,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("User_UsrID",true); CanReadProperty("User_UsrID", true);
return _User_UsrID; return _User_UsrID;
} }
} }
@ -373,23 +373,23 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyUser != null && (hasBrokenRules = _MyUser.HasBrokenRules) != null) return hasBrokenRules; if (_MyUser != null && (hasBrokenRules = _MyUser.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -538,7 +538,7 @@ namespace VEPROMS.CSLA.Library
_StartDate = _GroupMembershipExtension.DefaultStartDate; _StartDate = _GroupMembershipExtension.DefaultStartDate;
_DTS = _GroupMembershipExtension.DefaultDTS; _DTS = _GroupMembershipExtension.DefaultDTS;
_UsrID = _GroupMembershipExtension.DefaultUsrID; _UsrID = _GroupMembershipExtension.DefaultUsrID;
_MyUser = myUser; _MyUser = myUser;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal GroupMembership(SafeDataReader dr) internal GroupMembership(SafeDataReader dr)
@ -550,7 +550,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupMembership.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupMembership.FetchDR", GetHashCode());
try try
{ {
_UGID = dr.GetInt32("UGID"); _UGID = dr.GetInt32("UGID");
@ -577,7 +577,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupMembership.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupMembership.FetchDR", ex);
throw new DbCslaException("GroupMembership.Fetch", ex); throw new DbCslaException("GroupMembership.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public GroupMembership Add(User myUser) // One to Many public GroupMembership Add(User myUser) // One to Many
{ {
GroupMembership membership = GroupMembership.New(myUser); GroupMembership membership = GroupMembership.New(myUser);
this.Add(membership); this.Add(membership);
return membership; return membership;
} }
public void Remove(Membership myMembership) public void Remove(Membership myMembership)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(GroupMembership groupMembership in this) foreach (GroupMembership groupMembership in this)
if ((hasBrokenRules = groupMembership.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = groupMembership.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(GIDCriteria criteria) private void DataPortal_Fetch(GIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupMemberships.DataPortal_FetchGID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupMemberships.DataPortal_FetchGID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupMemberships.DataPortal_FetchGID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupMemberships.DataPortal_FetchGID", ex);
throw new DbCslaException("GroupMemberships.DataPortal_Fetch", ex); throw new DbCslaException("GroupMemberships.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class GroupMembershipsPropertyDescriptor : vlnListPropertyDescriptor public partial class GroupMembershipsPropertyDescriptor : vlnListPropertyDescriptor
{ {
private GroupMembership Item { get { return (GroupMembership) _Item;} } private GroupMembership Item { get { return (GroupMembership)_Item; } }
public GroupMembershipsPropertyDescriptor(GroupMemberships collection, int index):base(collection, index){;} public GroupMembershipsPropertyDescriptor(GroupMemberships collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is GroupMemberships) if (destType == typeof(string) && value is GroupMemberships)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((GroupMemberships) value).Items.Count.ToString() + " Memberships"; return ((GroupMemberships)value).Items.Count.ToString() + " Memberships";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

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

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationID",true); CanReadProperty("AnnotationID", true);
if (_MyAnnotation != null) _AnnotationID = _MyAnnotation.AnnotationID; if (_MyAnnotation != null) _AnnotationID = _MyAnnotation.AnnotationID;
return _AnnotationID; return _AnnotationID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyAnnotation",true); CanReadProperty("MyAnnotation", true);
if (_MyAnnotation == null && _AnnotationID != 0) _MyAnnotation = Annotation.Get(_AnnotationID); if (_MyAnnotation == null && _AnnotationID != 0) _MyAnnotation = Annotation.Get(_AnnotationID);
return _MyAnnotation; return _MyAnnotation;
} }
@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("TypeID",true); CanReadProperty("TypeID", true);
if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID; if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID;
return _TypeID; return _TypeID;
} }
@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyAnnotationType",true); CanReadProperty("MyAnnotationType", true);
if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationType.Get(_TypeID); if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationType.Get(_TypeID);
return _MyAnnotationType; return _MyAnnotationType;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyAnnotationType",true); CanWriteProperty("MyAnnotationType", true);
if (_MyAnnotationType != value) if (_MyAnnotationType != value)
{ {
_MyAnnotationType = value; _MyAnnotationType = value;
@ -97,13 +97,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RtfText",true); CanReadProperty("RtfText", true);
return _RtfText; return _RtfText;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("RtfText",true); CanWriteProperty("RtfText", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_RtfText != value) if (_RtfText != value)
{ {
@ -118,13 +118,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("SearchText",true); CanReadProperty("SearchText", true);
return _SearchText; return _SearchText;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("SearchText",true); CanWriteProperty("SearchText", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_SearchText != value) if (_SearchText != value)
{ {
@ -139,13 +139,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -160,13 +160,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -180,13 +180,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -202,7 +202,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationType_Name",true); CanReadProperty("AnnotationType_Name", true);
return _AnnotationType_Name; return _AnnotationType_Name;
} }
} }
@ -212,7 +212,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationType_Config",true); CanReadProperty("AnnotationType_Config", true);
return _AnnotationType_Config; return _AnnotationType_Config;
} }
} }
@ -222,7 +222,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationType_DTS",true); CanReadProperty("AnnotationType_DTS", true);
return _AnnotationType_DTS; return _AnnotationType_DTS;
} }
} }
@ -232,7 +232,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationType_UserID",true); CanReadProperty("AnnotationType_UserID", true);
return _AnnotationType_UserID; return _AnnotationType_UserID;
} }
} }
@ -265,23 +265,23 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyAnnotationType != null && (hasBrokenRules = _MyAnnotationType.HasBrokenRules) != null) return hasBrokenRules; if (_MyAnnotationType != null && (hasBrokenRules = _MyAnnotationType.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -404,7 +404,7 @@ namespace VEPROMS.CSLA.Library
// TODO: Add any initialization & defaults // TODO: Add any initialization & defaults
_DTS = _ItemAnnotationExtension.DefaultDTS; _DTS = _ItemAnnotationExtension.DefaultDTS;
_UserID = _ItemAnnotationExtension.DefaultUserID; _UserID = _ItemAnnotationExtension.DefaultUserID;
_MyAnnotationType = myAnnotationType; _MyAnnotationType = myAnnotationType;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal ItemAnnotation(SafeDataReader dr) internal ItemAnnotation(SafeDataReader dr)
@ -416,7 +416,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemAnnotation.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAnnotation.FetchDR", GetHashCode());
try try
{ {
_AnnotationID = dr.GetInt32("AnnotationID"); _AnnotationID = dr.GetInt32("AnnotationID");
@ -434,7 +434,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemAnnotation.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAnnotation.FetchDR", ex);
throw new DbCslaException("ItemAnnotation.Fetch", ex); throw new DbCslaException("ItemAnnotation.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public ItemAnnotation Add(AnnotationType myAnnotationType) // One to Many public ItemAnnotation Add(AnnotationType myAnnotationType) // One to Many
{ {
ItemAnnotation annotation = ItemAnnotation.New(myAnnotationType); ItemAnnotation annotation = ItemAnnotation.New(myAnnotationType);
this.Add(annotation); this.Add(annotation);
return annotation; return annotation;
} }
public void Remove(Annotation myAnnotation) public void Remove(Annotation myAnnotation)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(ItemAnnotation itemAnnotation in this) foreach (ItemAnnotation itemAnnotation in this)
if ((hasBrokenRules = itemAnnotation.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = itemAnnotation.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ItemIDCriteria criteria) private void DataPortal_Fetch(ItemIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemAnnotations.DataPortal_FetchItemID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAnnotations.DataPortal_FetchItemID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemAnnotations.DataPortal_FetchItemID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAnnotations.DataPortal_FetchItemID", ex);
throw new DbCslaException("ItemAnnotations.DataPortal_Fetch", ex); throw new DbCslaException("ItemAnnotations.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class ItemAnnotationsPropertyDescriptor : vlnListPropertyDescriptor public partial class ItemAnnotationsPropertyDescriptor : vlnListPropertyDescriptor
{ {
private ItemAnnotation Item { get { return (ItemAnnotation) _Item;} } private ItemAnnotation Item { get { return (ItemAnnotation)_Item; } }
public ItemAnnotationsPropertyDescriptor(ItemAnnotations collection, int index):base(collection, index){;} public ItemAnnotationsPropertyDescriptor(ItemAnnotations collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is ItemAnnotations) if (destType == typeof(string) && value is ItemAnnotations)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((ItemAnnotations) value).Items.Count.ToString() + " Annotations"; return ((ItemAnnotations)value).Items.Count.ToString() + " Annotations";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("VersionID",true); CanReadProperty("VersionID", true);
if (_MyDocVersion != null) _VersionID = _MyDocVersion.VersionID; if (_MyDocVersion != null) _VersionID = _MyDocVersion.VersionID;
return _VersionID; return _VersionID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyDocVersion",true); CanReadProperty("MyDocVersion", true);
if (_MyDocVersion == null && _VersionID != 0) _MyDocVersion = DocVersion.Get(_VersionID); if (_MyDocVersion == null && _VersionID != 0) _MyDocVersion = DocVersion.Get(_VersionID);
return _MyDocVersion; return _MyDocVersion;
} }
@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderID",true); CanReadProperty("FolderID", true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID; if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID; return _FolderID;
} }
@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFolder",true); CanReadProperty("MyFolder", true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID); if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder; return _MyFolder;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyFolder",true); CanWriteProperty("MyFolder", true);
if (_MyFolder != value) if (_MyFolder != value)
{ {
_MyFolder = value; _MyFolder = value;
@ -100,13 +100,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("VersionType",true); CanReadProperty("VersionType", true);
return _VersionType; return _VersionType;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("VersionType",true); CanWriteProperty("VersionType", true);
if (_VersionType != value) if (_VersionType != value)
{ {
_VersionType = value; _VersionType = value;
@ -120,13 +120,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name",true); CanReadProperty("Name", true);
return _Name; return _Name;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Name",true); CanWriteProperty("Name", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Name != value) if (_Name != value)
{ {
@ -141,13 +141,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Title",true); CanReadProperty("Title", true);
return _Title; return _Title;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Title",true); CanWriteProperty("Title", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Title != value) if (_Title != value)
{ {
@ -162,7 +162,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FormatID",true); CanReadProperty("FormatID", true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID; if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID; return _FormatID;
} }
@ -173,18 +173,18 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFormat",true); CanReadProperty("MyFormat", true);
if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID); if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID);
return _MyFormat; return _MyFormat;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyFormat",true); CanWriteProperty("MyFormat", true);
if (_MyFormat != value) if (_MyFormat != value)
{ {
_MyFormat = value; _MyFormat = value;
_FormatID = (value == null ? null : (int?) value.FormatID); _FormatID = (value == null ? null : (int?)value.FormatID);
PropertyHasChanged(); PropertyHasChanged();
} }
} }
@ -195,13 +195,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -216,13 +216,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -236,13 +236,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -258,7 +258,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_ParentID",true); CanReadProperty("Folder_ParentID", true);
return _Folder_ParentID; return _Folder_ParentID;
} }
} }
@ -268,7 +268,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_DBID",true); CanReadProperty("Folder_DBID", true);
return _Folder_DBID; return _Folder_DBID;
} }
} }
@ -278,7 +278,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_Name",true); CanReadProperty("Folder_Name", true);
return _Folder_Name; return _Folder_Name;
} }
} }
@ -288,7 +288,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_Title",true); CanReadProperty("Folder_Title", true);
return _Folder_Title; return _Folder_Title;
} }
} }
@ -298,7 +298,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_ShortName",true); CanReadProperty("Folder_ShortName", true);
return _Folder_ShortName; return _Folder_ShortName;
} }
} }
@ -308,7 +308,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_FormatID",true); CanReadProperty("Folder_FormatID", true);
return _Folder_FormatID; return _Folder_FormatID;
} }
} }
@ -318,7 +318,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_Config",true); CanReadProperty("Folder_Config", true);
return _Folder_Config; return _Folder_Config;
} }
} }
@ -328,7 +328,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_DTS",true); CanReadProperty("Folder_DTS", true);
return _Folder_DTS; return _Folder_DTS;
} }
} }
@ -338,7 +338,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_UsrID",true); CanReadProperty("Folder_UsrID", true);
return _Folder_UsrID; return _Folder_UsrID;
} }
} }
@ -371,24 +371,24 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules;
if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -519,8 +519,8 @@ namespace VEPROMS.CSLA.Library
_VersionType = _ItemDocVersionExtension.DefaultVersionType; _VersionType = _ItemDocVersionExtension.DefaultVersionType;
_DTS = _ItemDocVersionExtension.DefaultDTS; _DTS = _ItemDocVersionExtension.DefaultDTS;
_UserID = _ItemDocVersionExtension.DefaultUserID; _UserID = _ItemDocVersionExtension.DefaultUserID;
_MyFolder = myFolder; _MyFolder = myFolder;
_Name = name; _Name = name;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal ItemDocVersion(SafeDataReader dr) internal ItemDocVersion(SafeDataReader dr)
@ -532,7 +532,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemDocVersion.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemDocVersion.FetchDR", GetHashCode());
try try
{ {
_VersionID = dr.GetInt32("VersionID"); _VersionID = dr.GetInt32("VersionID");
@ -557,7 +557,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemDocVersion.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemDocVersion.FetchDR", ex);
throw new DbCslaException("ItemDocVersion.Fetch", ex); throw new DbCslaException("ItemDocVersion.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public ItemDocVersion Add(Folder myFolder, string name) // One to Many public ItemDocVersion Add(Folder myFolder, string name) // One to Many
{ {
ItemDocVersion docVersion = ItemDocVersion.New(myFolder, name); ItemDocVersion docVersion = ItemDocVersion.New(myFolder, name);
this.Add(docVersion); this.Add(docVersion);
return docVersion; return docVersion;
} }
public void Remove(DocVersion myDocVersion) public void Remove(DocVersion myDocVersion)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(ItemDocVersion itemDocVersion in this) foreach (ItemDocVersion itemDocVersion in this)
if ((hasBrokenRules = itemDocVersion.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = itemDocVersion.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ItemIDCriteria criteria) private void DataPortal_Fetch(ItemIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemDocVersions.DataPortal_FetchItemID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemDocVersions.DataPortal_FetchItemID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemDocVersions.DataPortal_FetchItemID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemDocVersions.DataPortal_FetchItemID", ex);
throw new DbCslaException("ItemDocVersions.DataPortal_Fetch", ex); throw new DbCslaException("ItemDocVersions.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class ItemDocVersionsPropertyDescriptor : vlnListPropertyDescriptor public partial class ItemDocVersionsPropertyDescriptor : vlnListPropertyDescriptor
{ {
private ItemDocVersion Item { get { return (ItemDocVersion) _Item;} } private ItemDocVersion Item { get { return (ItemDocVersion)_Item; } }
public ItemDocVersionsPropertyDescriptor(ItemDocVersions collection, int index):base(collection, index){;} public ItemDocVersionsPropertyDescriptor(ItemDocVersions collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is ItemDocVersions) if (destType == typeof(string) && value is ItemDocVersions)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((ItemDocVersions) value).Items.Count.ToString() + " DocVersions"; return ((ItemDocVersions)value).Items.Count.ToString() + " DocVersions";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<ItemInfo> _AllList = new List<ItemInfo>(); protected static List<ItemInfo> _AllList = new List<ItemInfo>();
private static Dictionary<string, ItemInfo> _AllByPrimaryKey = new Dictionary<string, ItemInfo>(); private static Dictionary<string, List<ItemInfo>> _AllByPrimaryKey = new Dictionary<string, List<ItemInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<ItemInfo> remove = new List<ItemInfo>(); List<ItemInfo> remove = new List<ItemInfo>();
foreach (ItemInfo tmp in _AllList) foreach (ItemInfo tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.ItemID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.ItemID.ToString()))
{
_AllByPrimaryKey[tmp.ItemID.ToString()] = new List<ItemInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.ItemID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (ItemInfo tmp in remove) foreach (ItemInfo tmp in remove)
@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = itemID.ToString(); string key = itemID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemID",true); CanReadProperty("ItemID", true);
return _ItemID; return _ItemID;
} }
} }
@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("PreviousID",true); CanReadProperty("PreviousID", true);
if (_MyPrevious != null) _PreviousID = _MyPrevious.ItemID; if (_MyPrevious != null) _PreviousID = _MyPrevious.ItemID;
return _PreviousID; return _PreviousID;
} }
@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyPrevious",true); CanReadProperty("MyPrevious", true);
if (_MyPrevious == null && _PreviousID != null) _MyPrevious = ItemInfo.Get((int)_PreviousID); if (_MyPrevious == null && _PreviousID != null) _MyPrevious = ItemInfo.Get((int)_PreviousID);
return _MyPrevious; return _MyPrevious;
} }
@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentID",true); CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID; if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID; return _ContentID;
} }
@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyContent",true); CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID); if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent; return _MyContent;
} }
@ -139,7 +143,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -149,7 +153,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
} }
@ -162,7 +166,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemAnnotationCount",true); CanReadProperty("ItemAnnotationCount", true);
return _ItemAnnotationCount; return _ItemAnnotationCount;
} }
} }
@ -173,7 +177,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemAnnotations",true); CanReadProperty("ItemAnnotations", true);
if (_ItemAnnotationCount < 0 || (_ItemAnnotationCount > 0 && _ItemAnnotations == null)) if (_ItemAnnotationCount < 0 || (_ItemAnnotationCount > 0 && _ItemAnnotations == null))
_ItemAnnotations = AnnotationInfoList.GetByItemID(_ItemID); _ItemAnnotations = AnnotationInfoList.GetByItemID(_ItemID);
if (_ItemAnnotationCount < 0) if (_ItemAnnotationCount < 0)
@ -183,7 +187,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshItemAnnotations() internal void RefreshItemAnnotations()
{ {
_ItemAnnotationCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _AllByPrimaryKey[_ItemID.ToString()])
tmp._ItemAnnotationCount = -1; // This will cause the data to be requeried
} }
private int _ItemDocVersionCount = 0; private int _ItemDocVersionCount = 0;
/// <summary> /// <summary>
@ -194,7 +201,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemDocVersionCount",true); CanReadProperty("ItemDocVersionCount", true);
return _ItemDocVersionCount; return _ItemDocVersionCount;
} }
} }
@ -205,7 +212,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemDocVersions",true); CanReadProperty("ItemDocVersions", true);
if (_ItemDocVersionCount < 0 || (_ItemDocVersionCount > 0 && _ItemDocVersions == null)) if (_ItemDocVersionCount < 0 || (_ItemDocVersionCount > 0 && _ItemDocVersions == null))
_ItemDocVersions = DocVersionInfoList.GetByItemID(_ItemID); _ItemDocVersions = DocVersionInfoList.GetByItemID(_ItemID);
if (_ItemDocVersionCount < 0) if (_ItemDocVersionCount < 0)
@ -215,7 +222,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshItemDocVersions() internal void RefreshItemDocVersions()
{ {
_ItemDocVersionCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _AllByPrimaryKey[_ItemID.ToString()])
tmp._ItemDocVersionCount = -1; // This will cause the data to be requeried
} }
private int _NextItemCount = 0; private int _NextItemCount = 0;
/// <summary> /// <summary>
@ -226,7 +236,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("NextItemCount",true); CanReadProperty("NextItemCount", true);
return _NextItemCount; return _NextItemCount;
} }
} }
@ -237,7 +247,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("NextItems",true); CanReadProperty("NextItems", true);
if (_NextItemCount < 0 || (_NextItemCount > 0 && _NextItems == null)) if (_NextItemCount < 0 || (_NextItemCount > 0 && _NextItems == null))
_NextItems = ItemInfoList.GetNext(_ItemID); _NextItems = ItemInfoList.GetNext(_ItemID);
if (_NextItemCount < 0) if (_NextItemCount < 0)
@ -247,7 +257,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshNextItems() internal void RefreshNextItems()
{ {
_NextItemCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _AllByPrimaryKey[_ItemID.ToString()])
tmp._NextItemCount = -1; // This will cause the data to be requeried
} }
private int _ItemPartCount = 0; private int _ItemPartCount = 0;
/// <summary> /// <summary>
@ -258,7 +271,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemPartCount",true); CanReadProperty("ItemPartCount", true);
return _ItemPartCount; return _ItemPartCount;
} }
} }
@ -269,7 +282,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemParts",true); CanReadProperty("ItemParts", true);
if (_ItemPartCount < 0 || (_ItemPartCount > 0 && _ItemParts == null)) if (_ItemPartCount < 0 || (_ItemPartCount > 0 && _ItemParts == null))
_ItemParts = PartInfoList.GetByItemID(_ItemID); _ItemParts = PartInfoList.GetByItemID(_ItemID);
if (_ItemPartCount < 0) if (_ItemPartCount < 0)
@ -279,7 +292,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshItemParts() internal void RefreshItemParts()
{ {
_ItemPartCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _AllByPrimaryKey[_ItemID.ToString()])
tmp._ItemPartCount = -1; // This will cause the data to be requeried
} }
private int _ItemTransition_RangeIDCount = 0; private int _ItemTransition_RangeIDCount = 0;
/// <summary> /// <summary>
@ -290,7 +306,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemTransition_RangeIDCount",true); CanReadProperty("ItemTransition_RangeIDCount", true);
return _ItemTransition_RangeIDCount; return _ItemTransition_RangeIDCount;
} }
} }
@ -301,7 +317,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemTransitions_RangeID",true); CanReadProperty("ItemTransitions_RangeID", true);
if (_ItemTransition_RangeIDCount < 0 || (_ItemTransition_RangeIDCount > 0 && _ItemTransitions_RangeID == null)) if (_ItemTransition_RangeIDCount < 0 || (_ItemTransition_RangeIDCount > 0 && _ItemTransitions_RangeID == null))
_ItemTransitions_RangeID = TransitionInfoList.GetByRangeID(_ItemID); _ItemTransitions_RangeID = TransitionInfoList.GetByRangeID(_ItemID);
if (_ItemTransition_RangeIDCount < 0) if (_ItemTransition_RangeIDCount < 0)
@ -311,7 +327,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshItemTransitions_RangeID() internal void RefreshItemTransitions_RangeID()
{ {
_ItemTransition_RangeIDCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _AllByPrimaryKey[_ItemID.ToString()])
tmp._ItemTransition_RangeIDCount = -1; // This will cause the data to be requeried
} }
private int _ItemTransition_ToIDCount = 0; private int _ItemTransition_ToIDCount = 0;
/// <summary> /// <summary>
@ -322,7 +341,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemTransition_ToIDCount",true); CanReadProperty("ItemTransition_ToIDCount", true);
return _ItemTransition_ToIDCount; return _ItemTransition_ToIDCount;
} }
} }
@ -333,7 +352,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemTransitions_ToID",true); CanReadProperty("ItemTransitions_ToID", true);
if (_ItemTransition_ToIDCount < 0 || (_ItemTransition_ToIDCount > 0 && _ItemTransitions_ToID == null)) if (_ItemTransition_ToIDCount < 0 || (_ItemTransition_ToIDCount > 0 && _ItemTransitions_ToID == null))
_ItemTransitions_ToID = TransitionInfoList.GetByToID(_ItemID); _ItemTransitions_ToID = TransitionInfoList.GetByToID(_ItemID);
if (_ItemTransition_ToIDCount < 0) if (_ItemTransition_ToIDCount < 0)
@ -343,7 +362,10 @@ namespace VEPROMS.CSLA.Library
} }
internal void RefreshItemTransitions_ToID() internal void RefreshItemTransitions_ToID()
{ {
_ItemTransition_ToIDCount = -1; // This will cause the data to be requeried ConvertListToDictionary();
if (_AllByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _AllByPrimaryKey[_ItemID.ToString()])
tmp._ItemTransition_ToIDCount = -1; // This will cause the data to be requeried
} }
// TODO: Replace base ItemInfo.ToString function as necessary // TODO: Replace base ItemInfo.ToString function as necessary
/// <summary> /// <summary>
@ -365,14 +387,25 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _ItemInfoUnique = 0;
private int _MyItemInfoUnique;
public int MyItemInfoUnique
{
get { return _MyItemInfoUnique; }
}
private ItemInfo() private ItemInfo()
{/* require use of factory methods */ {/* require use of factory methods */
_MyItemInfoUnique = ++_ItemInfoUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(ItemID.ToString()); if (!_AllByPrimaryKey.ContainsKey(ItemID.ToString())) return;
List<ItemInfo> listItemInfo = _AllByPrimaryKey[ItemID.ToString()]; // Get the list of items
listItemInfo.Remove(this); // Remove the item from the list
if (listItemInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(ItemID.ToString()); // remove the list
} }
public virtual Item Get() public virtual Item Get()
{ {
@ -380,9 +413,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(Item tmp) public static void Refresh(Item tmp)
{ {
ItemInfo tmpInfo = GetExistingByPrimaryKey(tmp.ItemID); string key = tmp.ItemID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (ItemInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(Item tmp) private void RefreshFields(Item tmp)
{ {
@ -390,16 +425,16 @@ namespace VEPROMS.CSLA.Library
{ {
MyPrevious.RefreshNextItems(); // Update List for old value MyPrevious.RefreshNextItems(); // Update List for old value
_PreviousID = tmp.PreviousID; // Update the value _PreviousID = tmp.PreviousID; // Update the value
_MyPrevious = null; // Reset list so that the next line gets a new list
MyPrevious.RefreshNextItems(); // Update List for new value
} }
_MyPrevious = null; // Reset list so that the next line gets a new list
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for new value
if (_ContentID != tmp.ContentID) if (_ContentID != tmp.ContentID)
{ {
MyContent.RefreshContentItems(); // Update List for old value MyContent.RefreshContentItems(); // Update List for old value
_ContentID = tmp.ContentID; // Update the value _ContentID = tmp.ContentID; // Update the value
_MyContent = null; // Reset list so that the next line gets a new list
MyContent.RefreshContentItems(); // Update List for new value
} }
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentItems(); // Update List for new value
_DTS = tmp.DTS; _DTS = tmp.DTS;
_UserID = tmp.UserID; _UserID = tmp.UserID;
_ItemInfoExtension.Refresh(this); _ItemInfoExtension.Refresh(this);
@ -409,9 +444,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(ContentItem tmp) public static void Refresh(ContentItem tmp)
{ {
ItemInfo tmpInfo = GetExistingByPrimaryKey(tmp.ItemID); string key = tmp.ItemID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (ItemInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(ContentItem tmp) private void RefreshFields(ContentItem tmp)
{ {
@ -419,9 +456,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyPrevious.RefreshNextItems(); // Update List for old value MyPrevious.RefreshNextItems(); // Update List for old value
_PreviousID = tmp.PreviousID; // Update the value _PreviousID = tmp.PreviousID; // Update the value
_MyPrevious = null; // Reset list so that the next line gets a new list
MyPrevious.RefreshNextItems(); // Update List for new value
} }
_MyPrevious = null; // Reset list so that the next line gets a new list
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for new value
_DTS = tmp.DTS; _DTS = tmp.DTS;
_UserID = tmp.UserID; _UserID = tmp.UserID;
_ItemInfoExtension.Refresh(this); _ItemInfoExtension.Refresh(this);
@ -439,7 +476,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<ItemInfo>(new PKCriteria(itemID)); tmp = DataPortal.Fetch<ItemInfo>(new PKCriteria(itemID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -453,14 +490,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
internal ItemInfo(SafeDataReader dr) internal ItemInfo(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemInfo.Constructor", GetHashCode()); _MyItemInfoUnique = ++_ItemInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.Constructor", GetHashCode());
try try
{ {
ReadData(dr); ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemInfo.Constructor", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfo.Constructor", ex);
throw new DbCslaException("ItemInfo.Constructor", ex); throw new DbCslaException("ItemInfo.Constructor", ex);
} }
} }
@ -477,7 +515,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemInfo.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.ReadData", GetHashCode());
try try
{ {
_ItemID = dr.GetInt32("ItemID"); _ItemID = dr.GetInt32("ItemID");
@ -494,14 +532,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemInfo.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfo.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("ItemInfo.ReadData", ex); throw new DbCslaException("ItemInfo.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -529,7 +567,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemInfo.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("ItemInfo.DataPortal_Fetch", ex); throw new DbCslaException("ItemInfo.DataPortal_Fetch", ex);
} }
@ -539,7 +577,7 @@ namespace VEPROMS.CSLA.Library
#region extension #region extension
ItemInfoExtension _ItemInfoExtension = new ItemInfoExtension(); ItemInfoExtension _ItemInfoExtension = new ItemInfoExtension();
[Serializable()] [Serializable()]
partial class ItemInfoExtension : extensionBase {} partial class ItemInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {

View File

@ -124,7 +124,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -144,7 +144,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -166,7 +166,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(PreviousIDCriteria criteria) private void DataPortal_Fetch(PreviousIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_FetchPreviousID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_FetchPreviousID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -187,7 +187,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemInfoList.DataPortal_FetchPreviousID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfoList.DataPortal_FetchPreviousID", ex);
throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -209,7 +209,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ContentIDCriteria criteria) private void DataPortal_Fetch(ContentIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_FetchContentID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_FetchContentID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -230,7 +230,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemInfoList.DataPortal_FetchContentID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfoList.DataPortal_FetchContentID", ex);
throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -291,8 +291,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class ItemInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class ItemInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private ItemInfo Item { get { return (ItemInfo) _Item;} } private ItemInfo Item { get { return (ItemInfo)_Item; } }
public ItemInfoListPropertyDescriptor(ItemInfoList collection, int index):base(collection, index){;} public ItemInfoListPropertyDescriptor(ItemInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -303,7 +303,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is ItemInfoList) if (destType == typeof(string) && value is ItemInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((ItemInfoList) value).Items.Count.ToString() + " Items"; return ((ItemInfoList)value).Items.Count.ToString() + " Items";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentID",true); CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID; if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID; return _ContentID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyContent",true); CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID); if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID);
return _MyContent; return _MyContent;
} }
@ -66,7 +66,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FromType",true); CanReadProperty("FromType", true);
return _FromType; return _FromType;
} }
} }
@ -76,13 +76,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -96,13 +96,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -118,7 +118,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_Number",true); CanReadProperty("Content_Number", true);
return _Content_Number; return _Content_Number;
} }
} }
@ -128,7 +128,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_Text",true); CanReadProperty("Content_Text", true);
return _Content_Text; return _Content_Text;
} }
} }
@ -141,7 +141,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_Type",true); CanReadProperty("Content_Type", true);
return _Content_Type; return _Content_Type;
} }
} }
@ -151,7 +151,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_FormatID",true); CanReadProperty("Content_FormatID", true);
return _Content_FormatID; return _Content_FormatID;
} }
} }
@ -161,7 +161,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_Config",true); CanReadProperty("Content_Config", true);
return _Content_Config; return _Content_Config;
} }
} }
@ -171,7 +171,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_DTS",true); CanReadProperty("Content_DTS", true);
return _Content_DTS; return _Content_DTS;
} }
} }
@ -181,7 +181,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_UserID",true); CanReadProperty("Content_UserID", true);
return _Content_UserID; return _Content_UserID;
} }
} }
@ -206,22 +206,22 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -318,8 +318,8 @@ namespace VEPROMS.CSLA.Library
// TODO: Add any initialization & defaults // TODO: Add any initialization & defaults
_DTS = _ItemPartExtension.DefaultDTS; _DTS = _ItemPartExtension.DefaultDTS;
_UserID = _ItemPartExtension.DefaultUserID; _UserID = _ItemPartExtension.DefaultUserID;
_MyContent = myContent; _MyContent = myContent;
_FromType = fromType; _FromType = fromType;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal ItemPart(SafeDataReader dr) internal ItemPart(SafeDataReader dr)
@ -331,7 +331,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemPart.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemPart.FetchDR", GetHashCode());
try try
{ {
_ContentID = dr.GetInt32("ContentID"); _ContentID = dr.GetInt32("ContentID");
@ -349,7 +349,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemPart.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemPart.FetchDR", ex);
throw new DbCslaException("ItemPart.Fetch", ex); throw new DbCslaException("ItemPart.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public ItemPart Add(Content myContent, int fromType) // One to Many public ItemPart Add(Content myContent, int fromType) // One to Many
{ {
ItemPart part = ItemPart.New(myContent, fromType); ItemPart part = ItemPart.New(myContent, fromType);
this.Add(part); this.Add(part);
return part; return part;
} }
public void Remove(Content myContent, int fromType) public void Remove(Content myContent, int fromType)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(ItemPart itemPart in this) foreach (ItemPart itemPart in this)
if ((hasBrokenRules = itemPart.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = itemPart.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ItemIDCriteria criteria) private void DataPortal_Fetch(ItemIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemParts.DataPortal_FetchItemID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemParts.DataPortal_FetchItemID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemParts.DataPortal_FetchItemID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemParts.DataPortal_FetchItemID", ex);
throw new DbCslaException("ItemParts.DataPortal_Fetch", ex); throw new DbCslaException("ItemParts.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class ItemPartsPropertyDescriptor : vlnListPropertyDescriptor public partial class ItemPartsPropertyDescriptor : vlnListPropertyDescriptor
{ {
private ItemPart Item { get { return (ItemPart) _Item;} } private ItemPart Item { get { return (ItemPart)_Item; } }
public ItemPartsPropertyDescriptor(ItemParts collection, int index):base(collection, index){;} public ItemPartsPropertyDescriptor(ItemParts collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is ItemParts) if (destType == typeof(string) && value is ItemParts)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((ItemParts) value).Items.Count.ToString() + " Parts"; return ((ItemParts)value).Items.Count.ToString() + " Parts";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("TransitionID",true); CanReadProperty("TransitionID", true);
if (_MyTransition != null) _TransitionID = _MyTransition.TransitionID; if (_MyTransition != null) _TransitionID = _MyTransition.TransitionID;
return _TransitionID; return _TransitionID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyTransition",true); CanReadProperty("MyTransition", true);
if (_MyTransition == null && _TransitionID != 0) _MyTransition = Transition.Get(_TransitionID); if (_MyTransition == null && _TransitionID != 0) _MyTransition = Transition.Get(_TransitionID);
return _MyTransition; return _MyTransition;
} }
@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FromID",true); CanReadProperty("FromID", true);
if (_MyContent != null) _FromID = _MyContent.ContentID; if (_MyContent != null) _FromID = _MyContent.ContentID;
return _FromID; return _FromID;
} }
@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyContent",true); CanReadProperty("MyContent", true);
if (_MyContent == null && _FromID != 0) _MyContent = Content.Get(_FromID); if (_MyContent == null && _FromID != 0) _MyContent = Content.Get(_FromID);
return _MyContent; return _MyContent;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyContent",true); CanWriteProperty("MyContent", true);
if (_MyContent != value) if (_MyContent != value)
{ {
_MyContent = value; _MyContent = value;
@ -100,7 +100,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ToID",true); CanReadProperty("ToID", true);
if (_MyItemToID != null) _ToID = _MyItemToID.ItemID; if (_MyItemToID != null) _ToID = _MyItemToID.ItemID;
return _ToID; return _ToID;
} }
@ -111,14 +111,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItemToID",true); CanReadProperty("MyItemToID", true);
if (_MyItemToID == null && _ToID != 0) _MyItemToID = Item.Get(_ToID); if (_MyItemToID == null && _ToID != 0) _MyItemToID = Item.Get(_ToID);
return _MyItemToID; return _MyItemToID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyItemToID",true); CanWriteProperty("MyItemToID", true);
if (_MyItemToID != value) if (_MyItemToID != value)
{ {
_MyItemToID = value; _MyItemToID = value;
@ -132,13 +132,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("TranType",true); CanReadProperty("TranType", true);
return _TranType; return _TranType;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("TranType",true); CanWriteProperty("TranType", true);
if (_TranType != value) if (_TranType != value)
{ {
_TranType = value; _TranType = value;
@ -152,13 +152,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -173,13 +173,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -193,13 +193,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -215,7 +215,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_Number",true); CanReadProperty("Content_Number", true);
return _Content_Number; return _Content_Number;
} }
} }
@ -225,7 +225,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_Text",true); CanReadProperty("Content_Text", true);
return _Content_Text; return _Content_Text;
} }
} }
@ -238,7 +238,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_Type",true); CanReadProperty("Content_Type", true);
return _Content_Type; return _Content_Type;
} }
} }
@ -248,7 +248,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_FormatID",true); CanReadProperty("Content_FormatID", true);
return _Content_FormatID; return _Content_FormatID;
} }
} }
@ -258,7 +258,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_Config",true); CanReadProperty("Content_Config", true);
return _Content_Config; return _Content_Config;
} }
} }
@ -268,7 +268,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_DTS",true); CanReadProperty("Content_DTS", true);
return _Content_DTS; return _Content_DTS;
} }
} }
@ -278,7 +278,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_UserID",true); CanReadProperty("Content_UserID", true);
return _Content_UserID; return _Content_UserID;
} }
} }
@ -311,23 +311,23 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules; if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -446,8 +446,8 @@ namespace VEPROMS.CSLA.Library
_TranType = _ItemTransition_RangeIDExtension.DefaultTranType; _TranType = _ItemTransition_RangeIDExtension.DefaultTranType;
_DTS = _ItemTransition_RangeIDExtension.DefaultDTS; _DTS = _ItemTransition_RangeIDExtension.DefaultDTS;
_UserID = _ItemTransition_RangeIDExtension.DefaultUserID; _UserID = _ItemTransition_RangeIDExtension.DefaultUserID;
_MyContent = myContent; _MyContent = myContent;
_MyItemToID = myItemToID; _MyItemToID = myItemToID;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal ItemTransition_RangeID(SafeDataReader dr) internal ItemTransition_RangeID(SafeDataReader dr)
@ -459,7 +459,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemTransition_RangeID.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemTransition_RangeID.FetchDR", GetHashCode());
try try
{ {
_TransitionID = dr.GetInt32("TransitionID"); _TransitionID = dr.GetInt32("TransitionID");
@ -480,7 +480,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemTransition_RangeID.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemTransition_RangeID.FetchDR", ex);
throw new DbCslaException("ItemTransition_RangeID.Fetch", ex); throw new DbCslaException("ItemTransition_RangeID.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("TransitionID",true); CanReadProperty("TransitionID", true);
if (_MyTransition != null) _TransitionID = _MyTransition.TransitionID; if (_MyTransition != null) _TransitionID = _MyTransition.TransitionID;
return _TransitionID; return _TransitionID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyTransition",true); CanReadProperty("MyTransition", true);
if (_MyTransition == null && _TransitionID != 0) _MyTransition = Transition.Get(_TransitionID); if (_MyTransition == null && _TransitionID != 0) _MyTransition = Transition.Get(_TransitionID);
return _MyTransition; return _MyTransition;
} }
@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FromID",true); CanReadProperty("FromID", true);
if (_MyContent != null) _FromID = _MyContent.ContentID; if (_MyContent != null) _FromID = _MyContent.ContentID;
return _FromID; return _FromID;
} }
@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyContent",true); CanReadProperty("MyContent", true);
if (_MyContent == null && _FromID != 0) _MyContent = Content.Get(_FromID); if (_MyContent == null && _FromID != 0) _MyContent = Content.Get(_FromID);
return _MyContent; return _MyContent;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyContent",true); CanWriteProperty("MyContent", true);
if (_MyContent != value) if (_MyContent != value)
{ {
_MyContent = value; _MyContent = value;
@ -97,7 +97,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RangeID",true); CanReadProperty("RangeID", true);
if (_MyItemRangeID != null) _RangeID = _MyItemRangeID.ItemID; if (_MyItemRangeID != null) _RangeID = _MyItemRangeID.ItemID;
return _RangeID; return _RangeID;
} }
@ -108,14 +108,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItemRangeID",true); CanReadProperty("MyItemRangeID", true);
if (_MyItemRangeID == null && _RangeID != 0) _MyItemRangeID = Item.Get(_RangeID); if (_MyItemRangeID == null && _RangeID != 0) _MyItemRangeID = Item.Get(_RangeID);
return _MyItemRangeID; return _MyItemRangeID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyItemRangeID",true); CanWriteProperty("MyItemRangeID", true);
if (_MyItemRangeID != value) if (_MyItemRangeID != value)
{ {
_MyItemRangeID = value; _MyItemRangeID = value;
@ -129,13 +129,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("TranType",true); CanReadProperty("TranType", true);
return _TranType; return _TranType;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("TranType",true); CanWriteProperty("TranType", true);
if (_TranType != value) if (_TranType != value)
{ {
_TranType = value; _TranType = value;
@ -149,13 +149,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -170,13 +170,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -190,13 +190,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -212,7 +212,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_Number",true); CanReadProperty("Content_Number", true);
return _Content_Number; return _Content_Number;
} }
} }
@ -222,7 +222,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_Text",true); CanReadProperty("Content_Text", true);
return _Content_Text; return _Content_Text;
} }
} }
@ -235,7 +235,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_Type",true); CanReadProperty("Content_Type", true);
return _Content_Type; return _Content_Type;
} }
} }
@ -245,7 +245,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_FormatID",true); CanReadProperty("Content_FormatID", true);
return _Content_FormatID; return _Content_FormatID;
} }
} }
@ -255,7 +255,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_Config",true); CanReadProperty("Content_Config", true);
return _Content_Config; return _Content_Config;
} }
} }
@ -265,7 +265,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_DTS",true); CanReadProperty("Content_DTS", true);
return _Content_DTS; return _Content_DTS;
} }
} }
@ -275,7 +275,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Content_UserID",true); CanReadProperty("Content_UserID", true);
return _Content_UserID; return _Content_UserID;
} }
} }
@ -308,23 +308,23 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules; if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -443,8 +443,8 @@ namespace VEPROMS.CSLA.Library
_TranType = _ItemTransition_ToIDExtension.DefaultTranType; _TranType = _ItemTransition_ToIDExtension.DefaultTranType;
_DTS = _ItemTransition_ToIDExtension.DefaultDTS; _DTS = _ItemTransition_ToIDExtension.DefaultDTS;
_UserID = _ItemTransition_ToIDExtension.DefaultUserID; _UserID = _ItemTransition_ToIDExtension.DefaultUserID;
_MyContent = myContent; _MyContent = myContent;
_MyItemRangeID = myItemRangeID; _MyItemRangeID = myItemRangeID;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal ItemTransition_ToID(SafeDataReader dr) internal ItemTransition_ToID(SafeDataReader dr)
@ -456,7 +456,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemTransition_ToID.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemTransition_ToID.FetchDR", GetHashCode());
try try
{ {
_TransitionID = dr.GetInt32("TransitionID"); _TransitionID = dr.GetInt32("TransitionID");
@ -477,7 +477,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemTransition_ToID.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemTransition_ToID.FetchDR", ex);
throw new DbCslaException("ItemTransition_ToID.Fetch", ex); throw new DbCslaException("ItemTransition_ToID.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public ItemTransition_RangeID Add(Content myContent, Item myItemToID) // One to Many public ItemTransition_RangeID Add(Content myContent, Item myItemToID) // One to Many
{ {
ItemTransition_RangeID transition = ItemTransition_RangeID.New(myContent, myItemToID); ItemTransition_RangeID transition = ItemTransition_RangeID.New(myContent, myItemToID);
this.Add(transition); this.Add(transition);
return transition; return transition;
} }
public void Remove(Transition myTransition) public void Remove(Transition myTransition)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(ItemTransition_RangeID itemTransitionRangeID in this) foreach (ItemTransition_RangeID itemTransitionRangeID in this)
if ((hasBrokenRules = itemTransitionRangeID.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = itemTransitionRangeID.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(RangeIDCriteria criteria) private void DataPortal_Fetch(RangeIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemTransitions_RangeID.DataPortal_FetchRangeID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemTransitions_RangeID.DataPortal_FetchRangeID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemTransitions_RangeID.DataPortal_FetchRangeID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemTransitions_RangeID.DataPortal_FetchRangeID", ex);
throw new DbCslaException("ItemTransitions_RangeID.DataPortal_Fetch", ex); throw new DbCslaException("ItemTransitions_RangeID.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class ItemTransitions_RangeIDPropertyDescriptor : vlnListPropertyDescriptor public partial class ItemTransitions_RangeIDPropertyDescriptor : vlnListPropertyDescriptor
{ {
private ItemTransition_RangeID Item { get { return (ItemTransition_RangeID) _Item;} } private ItemTransition_RangeID Item { get { return (ItemTransition_RangeID)_Item; } }
public ItemTransitions_RangeIDPropertyDescriptor(ItemTransitions_RangeID collection, int index):base(collection, index){;} public ItemTransitions_RangeIDPropertyDescriptor(ItemTransitions_RangeID collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is ItemTransitions_RangeID) if (destType == typeof(string) && value is ItemTransitions_RangeID)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((ItemTransitions_RangeID) value).Items.Count.ToString() + " Transitions_RangeID"; return ((ItemTransitions_RangeID)value).Items.Count.ToString() + " Transitions_RangeID";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public ItemTransition_ToID Add(Content myContent, Item myItemRangeID) // One to Many public ItemTransition_ToID Add(Content myContent, Item myItemRangeID) // One to Many
{ {
ItemTransition_ToID transition = ItemTransition_ToID.New(myContent, myItemRangeID); ItemTransition_ToID transition = ItemTransition_ToID.New(myContent, myItemRangeID);
this.Add(transition); this.Add(transition);
return transition; return transition;
} }
public void Remove(Transition myTransition) public void Remove(Transition myTransition)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(ItemTransition_ToID itemTransitionToID in this) foreach (ItemTransition_ToID itemTransitionToID in this)
if ((hasBrokenRules = itemTransitionToID.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = itemTransitionToID.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ToIDCriteria criteria) private void DataPortal_Fetch(ToIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemTransitions_ToID.DataPortal_FetchToID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemTransitions_ToID.DataPortal_FetchToID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemTransitions_ToID.DataPortal_FetchToID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemTransitions_ToID.DataPortal_FetchToID", ex);
throw new DbCslaException("ItemTransitions_ToID.DataPortal_Fetch", ex); throw new DbCslaException("ItemTransitions_ToID.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class ItemTransitions_ToIDPropertyDescriptor : vlnListPropertyDescriptor public partial class ItemTransitions_ToIDPropertyDescriptor : vlnListPropertyDescriptor
{ {
private ItemTransition_ToID Item { get { return (ItemTransition_ToID) _Item;} } private ItemTransition_ToID Item { get { return (ItemTransition_ToID)_Item; } }
public ItemTransitions_ToIDPropertyDescriptor(ItemTransitions_ToID collection, int index):base(collection, index){;} public ItemTransitions_ToIDPropertyDescriptor(ItemTransitions_ToID collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is ItemTransitions_ToID) if (destType == typeof(string) && value is ItemTransitions_ToID)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((ItemTransitions_ToID) value).Items.Count.ToString() + " Transitions_ToID"; return ((ItemTransitions_ToID)value).Items.Count.ToString() + " Transitions_ToID";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -47,20 +47,24 @@ namespace VEPROMS.CSLA.Library
foreach (Membership tmp in _RefreshMemberships) foreach (Membership tmp in _RefreshMemberships)
{ {
MembershipInfo.Refresh(tmp); MembershipInfo.Refresh(tmp);
if(tmp._MyGroup != null) GroupInfo.Refresh(tmp._MyGroup); if (tmp._MyGroup != null) GroupInfo.Refresh(tmp._MyGroup);
if(tmp._MyUser != null) UserInfo.Refresh(tmp._MyUser); if (tmp._MyUser != null) UserInfo.Refresh(tmp._MyUser);
} }
} }
#endregion #endregion
#region Collection #region Collection
protected static List<Membership> _AllList = new List<Membership>(); protected static List<Membership> _AllList = new List<Membership>();
private static Dictionary<string, Membership> _AllByPrimaryKey = new Dictionary<string, Membership>(); private static Dictionary<string, List<Membership>> _AllByPrimaryKey = new Dictionary<string, List<Membership>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<Membership> remove = new List<Membership>(); List<Membership> remove = new List<Membership>();
foreach (Membership tmp in _AllList) foreach (Membership tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.UGID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.UGID.ToString()))
{
_AllByPrimaryKey[tmp.UGID.ToString()] = new List<Membership>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.UGID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (Membership tmp in remove) foreach (Membership tmp in remove)
@ -70,7 +74,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = ugid.ToString(); string key = ugid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -92,7 +96,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UGID",true); CanReadProperty("UGID", true);
return _UGID; return _UGID;
} }
} }
@ -102,7 +106,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UID",true); CanReadProperty("UID", true);
if (_MyUser != null) _UID = _MyUser.UID; if (_MyUser != null) _UID = _MyUser.UID;
return _UID; return _UID;
} }
@ -113,14 +117,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyUser",true); CanReadProperty("MyUser", true);
if (_MyUser == null && _UID != 0) _MyUser = User.Get(_UID); if (_MyUser == null && _UID != 0) _MyUser = User.Get(_UID);
return _MyUser; return _MyUser;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyUser",true); CanWriteProperty("MyUser", true);
if (_MyUser != value) if (_MyUser != value)
{ {
_MyUser = value; _MyUser = value;
@ -134,7 +138,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GID",true); CanReadProperty("GID", true);
if (_MyGroup != null) _GID = _MyGroup.GID; if (_MyGroup != null) _GID = _MyGroup.GID;
return _GID; return _GID;
} }
@ -145,14 +149,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyGroup",true); CanReadProperty("MyGroup", true);
if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID); if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID);
return _MyGroup; return _MyGroup;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyGroup",true); CanWriteProperty("MyGroup", true);
if (_MyGroup != value) if (_MyGroup != value)
{ {
_MyGroup = value; _MyGroup = value;
@ -166,13 +170,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("StartDate",true); CanReadProperty("StartDate", true);
return _StartDate; return _StartDate;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("StartDate",true); CanWriteProperty("StartDate", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
_StartDate = value; _StartDate = value;
try try
@ -196,13 +200,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("EndDate",true); CanReadProperty("EndDate", true);
return _EndDate; return _EndDate;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("EndDate",true); CanWriteProperty("EndDate", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
_EndDate = value; _EndDate = value;
try try
@ -226,13 +230,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -247,13 +251,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -267,13 +271,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UsrID",true); CanWriteProperty("UsrID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UsrID != value) if (_UsrID != value)
{ {
@ -285,11 +289,11 @@ namespace VEPROMS.CSLA.Library
private byte[] _LastChanged = new byte[8];//timestamp private byte[] _LastChanged = new byte[8];//timestamp
public override bool IsDirty public override bool IsDirty
{ {
get { return base.IsDirty || (_MyGroup == null? false : _MyGroup.IsDirty) || (_MyUser == null? false : _MyUser.IsDirty); } get { return base.IsDirty || (_MyGroup == null ? false : _MyGroup.IsDirty) || (_MyUser == null ? false : _MyUser.IsDirty); }
} }
public override bool IsValid public override bool IsValid
{ {
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyGroup == null? true : _MyGroup.IsValid) && (_MyUser == null? true : _MyUser.IsValid); } get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyGroup == null ? true : _MyGroup.IsValid) && (_MyUser == null ? true : _MyUser.IsValid); }
} }
// TODO: Replace base Membership.ToString function as necessary // TODO: Replace base Membership.ToString function as necessary
/// <summary> /// <summary>
@ -312,23 +316,24 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get { get
if(_CheckingBrokenRules)return null; {
if (_CheckingBrokenRules) return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyUser != null && (hasBrokenRules = _MyUser.HasBrokenRules) != null) return hasBrokenRules; if (_MyUser != null && (hasBrokenRules = _MyUser.HasBrokenRules) != null) return hasBrokenRules;
if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules; if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -478,14 +483,25 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods #region Factory Methods
public int CurrentEditLevel public int CurrentEditLevel
{ get { return EditLevel; } } { get { return EditLevel; } }
private static int _MembershipUnique = 0;
private int _MyMembershipUnique;
public int MyMembershipUnique
{
get { return _MyMembershipUnique; }
}
protected Membership() protected Membership()
{/* require use of factory methods */ {/* require use of factory methods */
_MyMembershipUnique = ++_MembershipUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(UGID.ToString()); if (!_AllByPrimaryKey.ContainsKey(UGID.ToString())) return;
List<Membership> listMembership = _AllByPrimaryKey[UGID.ToString()]; // Get the list of items
listMembership.Remove(this); // Remove the item from the list
if (listMembership.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(UGID.ToString()); // remove the list
} }
public static Membership New() public static Membership New()
{ {
@ -570,7 +586,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<Membership>(new PKCriteria(ugid)); tmp = DataPortal.Fetch<Membership>(new PKCriteria(ugid));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -650,7 +666,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Membership.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Membership.ReadData", GetHashCode());
try try
{ {
_UGID = dr.GetInt32("UGID"); _UGID = dr.GetInt32("UGID");
@ -666,14 +682,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Membership.ReadData", ex); throw new DbCslaException("Membership.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Membership.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Membership.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -701,7 +717,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Membership.DataPortal_Fetch", ex); throw new DbCslaException("Membership.DataPortal_Fetch", ex);
} }
@ -722,13 +738,13 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.DataPortal_Insert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.DataPortal_Insert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Membership.DataPortal_Insert", ex); throw new DbCslaException("Membership.DataPortal_Insert", ex);
} }
finally finally
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Membership.DataPortal_Insert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Membership.DataPortal_Insert", GetHashCode());
} }
} }
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
@ -737,8 +753,8 @@ namespace VEPROMS.CSLA.Library
if (!this.IsDirty) return; if (!this.IsDirty) return;
try try
{ {
if(_MyGroup != null) _MyGroup.Update(); if (_MyGroup != null) _MyGroup.Update();
if(_MyUser != null) _MyUser.Update(); if (_MyUser != null) _MyUser.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
{ {
@ -767,11 +783,11 @@ namespace VEPROMS.CSLA.Library
} }
MarkOld(); MarkOld();
// update child objects // update child objects
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Membership.SQLInsert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Membership.SQLInsert", GetHashCode());
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.SQLInsert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.SQLInsert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Membership.SQLInsert", ex); throw new DbCslaException("Membership.SQLInsert", ex);
} }
@ -779,7 +795,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int ugid, User myUser, Group myGroup, SmartDate startDate, SmartDate endDate, string config, DateTime dts, string usrID) public static byte[] Add(SqlConnection cn, ref int ugid, User myUser, Group myGroup, SmartDate startDate, SmartDate endDate, string config, DateTime dts, string usrID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Membership.Add", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Membership.Add", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -810,7 +826,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.Add", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.Add", ex);
throw new DbCslaException("Membership.Add", ex); throw new DbCslaException("Membership.Add", ex);
} }
} }
@ -818,7 +834,7 @@ namespace VEPROMS.CSLA.Library
protected override void DataPortal_Update() protected override void DataPortal_Update()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Membership.DataPortal_Update", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Membership.DataPortal_Update", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -832,7 +848,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.DataPortal_Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.DataPortal_Update", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -841,11 +857,11 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate() internal void SQLUpdate()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Membership.SQLUpdate", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Membership.SQLUpdate", GetHashCode());
try try
{ {
if(_MyGroup != null) _MyGroup.Update(); if (_MyGroup != null) _MyGroup.Update();
if(_MyUser != null) _MyUser.Update(); if (_MyUser != null) _MyUser.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty) if (base.IsDirty)
{ {
@ -878,7 +894,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.SQLUpdate", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.SQLUpdate", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -899,7 +915,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int ugid, User myUser, Group myGroup, SmartDate startDate, SmartDate endDate, string config, DateTime dts, string usrID, ref byte[] lastChanged) public static byte[] Update(SqlConnection cn, ref int ugid, User myUser, Group myGroup, SmartDate startDate, SmartDate endDate, string config, DateTime dts, string usrID, ref byte[] lastChanged)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Membership.Update", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Membership.Update", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -928,7 +944,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.Update", ex);
throw new DbCslaException("Membership.Update", ex); throw new DbCslaException("Membership.Update", ex);
} }
} }
@ -940,7 +956,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria) private void DataPortal_Delete(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Membership.DataPortal_Delete", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Membership.DataPortal_Delete", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -956,7 +972,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.DataPortal_Delete", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.DataPortal_Delete", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Membership.DataPortal_Delete", ex); throw new DbCslaException("Membership.DataPortal_Delete", ex);
} }
@ -964,7 +980,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int ugid) public static void Remove(SqlConnection cn, int ugid)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Membership.Remove", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Membership.Remove", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -979,7 +995,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.Remove", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.Remove", ex);
throw new DbCslaException("Membership.Remove", ex); throw new DbCslaException("Membership.Remove", ex);
} }
} }
@ -1013,7 +1029,7 @@ namespace VEPROMS.CSLA.Library
} }
protected override void DataPortal_Execute() protected override void DataPortal_Execute()
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Membership.DataPortal_Execute", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Membership.DataPortal_Execute", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1031,7 +1047,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.DataPortal_Execute", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.DataPortal_Execute", ex);
throw new DbCslaException("Membership.DataPortal_Execute", ex); throw new DbCslaException("Membership.DataPortal_Execute", ex);
} }
} }

View File

@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<MembershipInfo> _AllList = new List<MembershipInfo>(); protected static List<MembershipInfo> _AllList = new List<MembershipInfo>();
private static Dictionary<string, MembershipInfo> _AllByPrimaryKey = new Dictionary<string, MembershipInfo>(); private static Dictionary<string, List<MembershipInfo>> _AllByPrimaryKey = new Dictionary<string, List<MembershipInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<MembershipInfo> remove = new List<MembershipInfo>(); List<MembershipInfo> remove = new List<MembershipInfo>();
foreach (MembershipInfo tmp in _AllList) foreach (MembershipInfo tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.UGID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.UGID.ToString()))
{
_AllByPrimaryKey[tmp.UGID.ToString()] = new List<MembershipInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.UGID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (MembershipInfo tmp in remove) foreach (MembershipInfo tmp in remove)
@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = ugid.ToString(); string key = ugid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UGID",true); CanReadProperty("UGID", true);
return _UGID; return _UGID;
} }
} }
@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UID",true); CanReadProperty("UID", true);
if (_MyUser != null) _UID = _MyUser.UID; if (_MyUser != null) _UID = _MyUser.UID;
return _UID; return _UID;
} }
@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyUser",true); CanReadProperty("MyUser", true);
if (_MyUser == null && _UID != 0) _MyUser = UserInfo.Get(_UID); if (_MyUser == null && _UID != 0) _MyUser = UserInfo.Get(_UID);
return _MyUser; return _MyUser;
} }
@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GID",true); CanReadProperty("GID", true);
if (_MyGroup != null) _GID = _MyGroup.GID; if (_MyGroup != null) _GID = _MyGroup.GID;
return _GID; return _GID;
} }
@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyGroup",true); CanReadProperty("MyGroup", true);
if (_MyGroup == null && _GID != 0) _MyGroup = GroupInfo.Get(_GID); if (_MyGroup == null && _GID != 0) _MyGroup = GroupInfo.Get(_GID);
return _MyGroup; return _MyGroup;
} }
@ -139,7 +143,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("StartDate",true); CanReadProperty("StartDate", true);
return _StartDate; return _StartDate;
} }
} }
@ -149,7 +153,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("EndDate",true); CanReadProperty("EndDate", true);
return _EndDate; return _EndDate;
} }
} }
@ -159,7 +163,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
} }
@ -169,7 +173,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -179,7 +183,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
} }
@ -203,14 +207,25 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _MembershipInfoUnique = 0;
private int _MyMembershipInfoUnique;
public int MyMembershipInfoUnique
{
get { return _MyMembershipInfoUnique; }
}
private MembershipInfo() private MembershipInfo()
{/* require use of factory methods */ {/* require use of factory methods */
_MyMembershipInfoUnique = ++_MembershipInfoUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(UGID.ToString()); if (!_AllByPrimaryKey.ContainsKey(UGID.ToString())) return;
List<MembershipInfo> listMembershipInfo = _AllByPrimaryKey[UGID.ToString()]; // Get the list of items
listMembershipInfo.Remove(this); // Remove the item from the list
if (listMembershipInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(UGID.ToString()); // remove the list
} }
public virtual Membership Get() public virtual Membership Get()
{ {
@ -218,9 +233,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(Membership tmp) public static void Refresh(Membership tmp)
{ {
MembershipInfo tmpInfo = GetExistingByPrimaryKey(tmp.UGID); string key = tmp.UGID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (MembershipInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(Membership tmp) private void RefreshFields(Membership tmp)
{ {
@ -228,16 +245,16 @@ namespace VEPROMS.CSLA.Library
{ {
MyUser.RefreshUserMemberships(); // Update List for old value MyUser.RefreshUserMemberships(); // Update List for old value
_UID = tmp.UID; // Update the value _UID = tmp.UID; // Update the value
_MyUser = null; // Reset list so that the next line gets a new list
MyUser.RefreshUserMemberships(); // Update List for new value
} }
_MyUser = null; // Reset list so that the next line gets a new list
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for new value
if (_GID != tmp.GID) if (_GID != tmp.GID)
{ {
MyGroup.RefreshGroupMemberships(); // Update List for old value MyGroup.RefreshGroupMemberships(); // Update List for old value
_GID = tmp.GID; // Update the value _GID = tmp.GID; // Update the value
_MyGroup = null; // Reset list so that the next line gets a new list
MyGroup.RefreshGroupMemberships(); // Update List for new value
} }
_MyGroup = null; // Reset list so that the next line gets a new list
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for new value
_StartDate = tmp.StartDate; _StartDate = tmp.StartDate;
_EndDate = tmp.EndDate; _EndDate = tmp.EndDate;
_Config = tmp.Config; _Config = tmp.Config;
@ -250,9 +267,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(GroupMembership tmp) public static void Refresh(GroupMembership tmp)
{ {
MembershipInfo tmpInfo = GetExistingByPrimaryKey(tmp.UGID); string key = tmp.UGID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (MembershipInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(GroupMembership tmp) private void RefreshFields(GroupMembership tmp)
{ {
@ -260,9 +279,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyUser.RefreshUserMemberships(); // Update List for old value MyUser.RefreshUserMemberships(); // Update List for old value
_UID = tmp.UID; // Update the value _UID = tmp.UID; // Update the value
_MyUser = null; // Reset list so that the next line gets a new list
MyUser.RefreshUserMemberships(); // Update List for new value
} }
_MyUser = null; // Reset list so that the next line gets a new list
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for new value
_StartDate = tmp.StartDate; _StartDate = tmp.StartDate;
_EndDate = tmp.EndDate; _EndDate = tmp.EndDate;
_Config = tmp.Config; _Config = tmp.Config;
@ -275,9 +294,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(UserMembership tmp) public static void Refresh(UserMembership tmp)
{ {
MembershipInfo tmpInfo = GetExistingByPrimaryKey(tmp.UGID); string key = tmp.UGID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (MembershipInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(UserMembership tmp) private void RefreshFields(UserMembership tmp)
{ {
@ -285,9 +306,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyGroup.RefreshGroupMemberships(); // Update List for old value MyGroup.RefreshGroupMemberships(); // Update List for old value
_GID = tmp.GID; // Update the value _GID = tmp.GID; // Update the value
_MyGroup = null; // Reset list so that the next line gets a new list
MyGroup.RefreshGroupMemberships(); // Update List for new value
} }
_MyGroup = null; // Reset list so that the next line gets a new list
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for new value
_StartDate = tmp.StartDate; _StartDate = tmp.StartDate;
_EndDate = tmp.EndDate; _EndDate = tmp.EndDate;
_Config = tmp.Config; _Config = tmp.Config;
@ -308,7 +329,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<MembershipInfo>(new PKCriteria(ugid)); tmp = DataPortal.Fetch<MembershipInfo>(new PKCriteria(ugid));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -322,14 +343,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
internal MembershipInfo(SafeDataReader dr) internal MembershipInfo(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] MembershipInfo.Constructor", GetHashCode()); _MyMembershipInfoUnique = ++_MembershipInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.Constructor", GetHashCode());
try try
{ {
ReadData(dr); ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("MembershipInfo.Constructor", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.Constructor", ex);
throw new DbCslaException("MembershipInfo.Constructor", ex); throw new DbCslaException("MembershipInfo.Constructor", ex);
} }
} }
@ -346,7 +368,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] MembershipInfo.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.ReadData", GetHashCode());
try try
{ {
_UGID = dr.GetInt32("UGID"); _UGID = dr.GetInt32("UGID");
@ -360,14 +382,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("MembershipInfo.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("MembershipInfo.ReadData", ex); throw new DbCslaException("MembershipInfo.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] MembershipInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -395,7 +417,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("MembershipInfo.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("MembershipInfo.DataPortal_Fetch", ex); throw new DbCslaException("MembershipInfo.DataPortal_Fetch", ex);
} }
@ -405,7 +427,7 @@ namespace VEPROMS.CSLA.Library
#region extension #region extension
MembershipInfoExtension _MembershipInfoExtension = new MembershipInfoExtension(); MembershipInfoExtension _MembershipInfoExtension = new MembershipInfoExtension();
[Serializable()] [Serializable()]
partial class MembershipInfoExtension : extensionBase {} partial class MembershipInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {

View File

@ -124,7 +124,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] MembershipInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -144,7 +144,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("MembershipInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("MembershipInfoList.DataPortal_Fetch", ex); throw new DbCslaException("MembershipInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -166,7 +166,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(GIDCriteria criteria) private void DataPortal_Fetch(GIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] MembershipInfoList.DataPortal_FetchGID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfoList.DataPortal_FetchGID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -187,7 +187,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("MembershipInfoList.DataPortal_FetchGID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfoList.DataPortal_FetchGID", ex);
throw new DbCslaException("MembershipInfoList.DataPortal_Fetch", ex); throw new DbCslaException("MembershipInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -209,7 +209,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(UIDCriteria criteria) private void DataPortal_Fetch(UIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] MembershipInfoList.DataPortal_FetchUID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfoList.DataPortal_FetchUID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -230,7 +230,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("MembershipInfoList.DataPortal_FetchUID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfoList.DataPortal_FetchUID", ex);
throw new DbCslaException("MembershipInfoList.DataPortal_Fetch", ex); throw new DbCslaException("MembershipInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -291,8 +291,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class MembershipInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class MembershipInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private MembershipInfo Item { get { return (MembershipInfo) _Item;} } private MembershipInfo Item { get { return (MembershipInfo)_Item; } }
public MembershipInfoListPropertyDescriptor(MembershipInfoList collection, int index):base(collection, index){;} public MembershipInfoListPropertyDescriptor(MembershipInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -303,7 +303,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is MembershipInfoList) if (destType == typeof(string) && value is MembershipInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((MembershipInfoList) value).Items.Count.ToString() + " Memberships"; return ((MembershipInfoList)value).Items.Count.ToString() + " Memberships";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public Item Add(Content myContent) // One to Many public Item Add(Content myContent) // One to Many
{ {
Item item = Item.New(myContent); Item item = Item.New(myContent);
this.Add(item); this.Add(item);
return item; return item;
} }
public void Remove(int itemID) public void Remove(int itemID)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(Item item in this) foreach (Item item in this)
if ((hasBrokenRules = item.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = item.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(PreviousIDCriteria criteria) private void DataPortal_Fetch(PreviousIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] NextItems.DataPortal_FetchPreviousID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] NextItems.DataPortal_FetchPreviousID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("NextItems.DataPortal_FetchPreviousID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("NextItems.DataPortal_FetchPreviousID", ex);
throw new DbCslaException("NextItems.DataPortal_Fetch", ex); throw new DbCslaException("NextItems.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class NextItemsPropertyDescriptor : vlnListPropertyDescriptor public partial class NextItemsPropertyDescriptor : vlnListPropertyDescriptor
{ {
private Item Item { get { return (Item) _Item;} } private Item Item { get { return (Item)_Item; } }
public NextItemsPropertyDescriptor(NextItems collection, int index):base(collection, index){;} public NextItemsPropertyDescriptor(NextItems collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is NextItems) if (destType == typeof(string) && value is NextItems)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((NextItems) value).Items.Count.ToString() + " Items"; return ((NextItems)value).Items.Count.ToString() + " Items";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -47,20 +47,24 @@ namespace VEPROMS.CSLA.Library
foreach (Part tmp in _RefreshParts) foreach (Part tmp in _RefreshParts)
{ {
PartInfo.Refresh(tmp); PartInfo.Refresh(tmp);
if(tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent); if (tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent);
if(tmp._MyItem != null) ItemInfo.Refresh(tmp._MyItem); if (tmp._MyItem != null) ItemInfo.Refresh(tmp._MyItem);
} }
} }
#endregion #endregion
#region Collection #region Collection
protected static List<Part> _AllList = new List<Part>(); protected static List<Part> _AllList = new List<Part>();
private static Dictionary<string, Part> _AllByPrimaryKey = new Dictionary<string, Part>(); private static Dictionary<string, List<Part>> _AllByPrimaryKey = new Dictionary<string, List<Part>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<Part> remove = new List<Part>(); List<Part> remove = new List<Part>();
foreach (Part tmp in _AllList) foreach (Part tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()))
{
_AllByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()] = new List<Part>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (Part tmp in remove) foreach (Part tmp in remove)
@ -70,7 +74,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = contentID.ToString() + "_" + fromType.ToString(); string key = contentID.ToString() + "_" + fromType.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -87,7 +91,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentID",true); CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID; if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID; return _ContentID;
} }
@ -99,7 +103,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyContent",true); CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID); if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID);
return _MyContent; return _MyContent;
} }
@ -111,7 +115,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FromType",true); CanReadProperty("FromType", true);
return _FromType; return _FromType;
} }
} }
@ -121,7 +125,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemID",true); CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID; if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID; return _ItemID;
} }
@ -132,14 +136,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItem",true); CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID); if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
return _MyItem; return _MyItem;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyItem",true); CanWriteProperty("MyItem", true);
if (_MyItem != value) if (_MyItem != value)
{ {
_MyItem = value; _MyItem = value;
@ -153,13 +157,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -173,13 +177,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID",true); CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -191,11 +195,11 @@ namespace VEPROMS.CSLA.Library
private byte[] _LastChanged = new byte[8];//timestamp private byte[] _LastChanged = new byte[8];//timestamp
public override bool IsDirty public override bool IsDirty
{ {
get { return base.IsDirty || (_MyContent == null? false : _MyContent.IsDirty) || (_MyItem == null? false : _MyItem.IsDirty); } get { return base.IsDirty || (_MyContent == null ? false : _MyContent.IsDirty) || (_MyItem == null ? false : _MyItem.IsDirty); }
} }
public override bool IsValid public override bool IsValid
{ {
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyContent == null? true : _MyContent.IsValid) && (_MyItem == null? true : _MyItem.IsValid); } get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyContent == null ? true : _MyContent.IsValid) && (_MyItem == null ? true : _MyItem.IsValid); }
} }
// TODO: Replace base Part.ToString function as necessary // TODO: Replace base Part.ToString function as necessary
/// <summary> /// <summary>
@ -213,27 +217,28 @@ namespace VEPROMS.CSLA.Library
/// <returns>A Unique ID for the current Part</returns> /// <returns>A Unique ID for the current Part</returns>
protected override object GetIdValue() protected override object GetIdValue()
{ {
return (_ContentID.ToString()+"."+_FromType.ToString()).GetHashCode(); return (_ContentID.ToString() + "." + _FromType.ToString()).GetHashCode();
} }
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get { get
if(_CheckingBrokenRules)return null; {
if (_CheckingBrokenRules) return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -333,14 +338,25 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods #region Factory Methods
public int CurrentEditLevel public int CurrentEditLevel
{ get { return EditLevel; } } { get { return EditLevel; } }
private static int _PartUnique = 0;
private int _MyPartUnique;
public int MyPartUnique
{
get { return _MyPartUnique; }
}
protected Part() protected Part()
{/* require use of factory methods */ {/* require use of factory methods */
_MyPartUnique = ++_PartUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(ContentID.ToString() + "_" + FromType.ToString()); if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString() + "_" + FromType.ToString())) return;
List<Part> listPart = _AllByPrimaryKey[ContentID.ToString() + "_" + FromType.ToString()]; // Get the list of items
listPart.Remove(this); // Remove the item from the list
if (listPart.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(ContentID.ToString() + "_" + FromType.ToString()); // remove the list
} }
public static Part New() public static Part New()
{ {
@ -399,7 +415,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<Part>(new PKCriteria(contentID, fromType)); tmp = DataPortal.Fetch<Part>(new PKCriteria(contentID, fromType));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -482,7 +498,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Part.ReadData", GetHashCode());
try try
{ {
_ContentID = dr.GetInt32("ContentID"); _ContentID = dr.GetInt32("ContentID");
@ -495,14 +511,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Part.ReadData", ex); throw new DbCslaException("Part.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Part.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -531,7 +547,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Part.DataPortal_Fetch", ex); throw new DbCslaException("Part.DataPortal_Fetch", ex);
} }
@ -552,13 +568,13 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.DataPortal_Insert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.DataPortal_Insert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Part.DataPortal_Insert", ex); throw new DbCslaException("Part.DataPortal_Insert", ex);
} }
finally finally
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.DataPortal_Insert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Part.DataPortal_Insert", GetHashCode());
} }
} }
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
@ -567,8 +583,8 @@ namespace VEPROMS.CSLA.Library
if (!this.IsDirty) return; if (!this.IsDirty) return;
try try
{ {
if(_MyContent != null) _MyContent.Update(); if (_MyContent != null) _MyContent.Update();
if(_MyItem != null) _MyItem.Update(); if (_MyItem != null) _MyItem.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
{ {
@ -591,11 +607,11 @@ namespace VEPROMS.CSLA.Library
} }
MarkOld(); MarkOld();
// update child objects // update child objects
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.SQLInsert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Part.SQLInsert", GetHashCode());
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.SQLInsert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.SQLInsert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Part.SQLInsert", ex); throw new DbCslaException("Part.SQLInsert", ex);
} }
@ -603,7 +619,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, Content myContent, int fromType, Item myItem, DateTime dts, string userID) public static byte[] Add(SqlConnection cn, Content myContent, int fromType, Item myItem, DateTime dts, string userID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.Add", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Part.Add", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -628,7 +644,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.Add", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.Add", ex);
throw new DbCslaException("Part.Add", ex); throw new DbCslaException("Part.Add", ex);
} }
} }
@ -636,7 +652,7 @@ namespace VEPROMS.CSLA.Library
protected override void DataPortal_Update() protected override void DataPortal_Update()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.DataPortal_Update", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Part.DataPortal_Update", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -650,7 +666,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.DataPortal_Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.DataPortal_Update", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -659,11 +675,11 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate() internal void SQLUpdate()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.SQLUpdate", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Part.SQLUpdate", GetHashCode());
try try
{ {
if(_MyContent != null) _MyContent.Update(); if (_MyContent != null) _MyContent.Update();
if(_MyItem != null) _MyItem.Update(); if (_MyItem != null) _MyItem.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty) if (base.IsDirty)
{ {
@ -693,7 +709,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.SQLUpdate", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.SQLUpdate", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -714,7 +730,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, Content myContent, int fromType, Item myItem, DateTime dts, string userID, ref byte[] lastChanged) public static byte[] Update(SqlConnection cn, Content myContent, int fromType, Item myItem, DateTime dts, string userID, ref byte[] lastChanged)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.Update", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Part.Update", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -740,7 +756,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.Update", ex);
throw new DbCslaException("Part.Update", ex); throw new DbCslaException("Part.Update", ex);
} }
} }
@ -752,7 +768,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria) private void DataPortal_Delete(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.DataPortal_Delete", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Part.DataPortal_Delete", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -769,7 +785,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.DataPortal_Delete", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.DataPortal_Delete", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Part.DataPortal_Delete", ex); throw new DbCslaException("Part.DataPortal_Delete", ex);
} }
@ -777,7 +793,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int contentID, int fromType) public static void Remove(SqlConnection cn, int contentID, int fromType)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.Remove", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Part.Remove", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -793,7 +809,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.Remove", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.Remove", ex);
throw new DbCslaException("Part.Remove", ex); throw new DbCslaException("Part.Remove", ex);
} }
} }
@ -829,7 +845,7 @@ namespace VEPROMS.CSLA.Library
} }
protected override void DataPortal_Execute() protected override void DataPortal_Execute()
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.DataPortal_Execute", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Part.DataPortal_Execute", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -848,7 +864,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.DataPortal_Execute", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.DataPortal_Execute", ex);
throw new DbCslaException("Part.DataPortal_Execute", ex); throw new DbCslaException("Part.DataPortal_Execute", ex);
} }
} }

View File

@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<PartInfo> _AllList = new List<PartInfo>(); protected static List<PartInfo> _AllList = new List<PartInfo>();
private static Dictionary<string, PartInfo> _AllByPrimaryKey = new Dictionary<string, PartInfo>(); private static Dictionary<string, List<PartInfo>> _AllByPrimaryKey = new Dictionary<string, List<PartInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<PartInfo> remove = new List<PartInfo>(); List<PartInfo> remove = new List<PartInfo>();
foreach (PartInfo tmp in _AllList) foreach (PartInfo tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()))
{
_AllByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()] = new List<PartInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (PartInfo tmp in remove) foreach (PartInfo tmp in remove)
@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = contentID.ToString() + "_" + fromType.ToString(); string key = contentID.ToString() + "_" + fromType.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentID",true); CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID; if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID; return _ContentID;
} }
@ -97,7 +101,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyContent",true); CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID); if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent; return _MyContent;
} }
@ -109,7 +113,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FromType",true); CanReadProperty("FromType", true);
return _FromType; return _FromType;
} }
} }
@ -119,7 +123,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemID",true); CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID; if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID; return _ItemID;
} }
@ -130,7 +134,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItem",true); CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != 0) _MyItem = ItemInfo.Get(_ItemID); if (_MyItem == null && _ItemID != 0) _MyItem = ItemInfo.Get(_ItemID);
return _MyItem; return _MyItem;
} }
@ -141,7 +145,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -151,7 +155,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
} }
@ -171,18 +175,29 @@ namespace VEPROMS.CSLA.Library
/// <returns>A Unique ID for the current PartInfo</returns> /// <returns>A Unique ID for the current PartInfo</returns>
protected override object GetIdValue() protected override object GetIdValue()
{ {
return (_ContentID.ToString()+"."+_FromType.ToString()).GetHashCode(); return (_ContentID.ToString() + "." + _FromType.ToString()).GetHashCode();
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _PartInfoUnique = 0;
private int _MyPartInfoUnique;
public int MyPartInfoUnique
{
get { return _MyPartInfoUnique; }
}
private PartInfo() private PartInfo()
{/* require use of factory methods */ {/* require use of factory methods */
_MyPartInfoUnique = ++_PartInfoUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(ContentID.ToString() + "_" + FromType.ToString()); if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString() + "_" + FromType.ToString())) return;
List<PartInfo> listPartInfo = _AllByPrimaryKey[ContentID.ToString() + "_" + FromType.ToString()]; // Get the list of items
listPartInfo.Remove(this); // Remove the item from the list
if (listPartInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(ContentID.ToString() + "_" + FromType.ToString()); // remove the list
} }
public virtual Part Get() public virtual Part Get()
{ {
@ -190,9 +205,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(Part tmp) public static void Refresh(Part tmp)
{ {
PartInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID, tmp.FromType); string key = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (PartInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(Part tmp) private void RefreshFields(Part tmp)
{ {
@ -200,9 +217,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyItem.RefreshItemParts(); // Update List for old value MyItem.RefreshItemParts(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value _ItemID = tmp.ItemID; // Update the value
_MyItem = null; // Reset list so that the next line gets a new list
MyItem.RefreshItemParts(); // Update List for new value
} }
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for new value
_DTS = tmp.DTS; _DTS = tmp.DTS;
_UserID = tmp.UserID; _UserID = tmp.UserID;
_PartInfoExtension.Refresh(this); _PartInfoExtension.Refresh(this);
@ -212,9 +229,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(Content myContent, ContentPart tmp) public static void Refresh(Content myContent, ContentPart tmp)
{ {
PartInfo tmpInfo = GetExistingByPrimaryKey(myContent.ContentID, tmp.FromType); string key = myContent.ContentID.ToString() + "_" + tmp.FromType.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (PartInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(ContentPart tmp) private void RefreshFields(ContentPart tmp)
{ {
@ -222,9 +241,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyItem.RefreshItemParts(); // Update List for old value MyItem.RefreshItemParts(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value _ItemID = tmp.ItemID; // Update the value
_MyItem = null; // Reset list so that the next line gets a new list
MyItem.RefreshItemParts(); // Update List for new value
} }
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for new value
_DTS = tmp.DTS; _DTS = tmp.DTS;
_UserID = tmp.UserID; _UserID = tmp.UserID;
_PartInfoExtension.Refresh(this); _PartInfoExtension.Refresh(this);
@ -234,9 +253,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(ItemPart tmp) public static void Refresh(ItemPart tmp)
{ {
PartInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID, tmp.FromType); string key = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (PartInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(ItemPart tmp) private void RefreshFields(ItemPart tmp)
{ {
@ -257,7 +278,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<PartInfo>(new PKCriteria(contentID, fromType)); tmp = DataPortal.Fetch<PartInfo>(new PKCriteria(contentID, fromType));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -271,14 +292,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
internal PartInfo(SafeDataReader dr) internal PartInfo(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PartInfo.Constructor", GetHashCode()); _MyPartInfoUnique = ++_PartInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.Constructor", GetHashCode());
try try
{ {
ReadData(dr); ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("PartInfo.Constructor", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.Constructor", ex);
throw new DbCslaException("PartInfo.Constructor", ex); throw new DbCslaException("PartInfo.Constructor", ex);
} }
} }
@ -299,7 +321,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PartInfo.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.ReadData", GetHashCode());
try try
{ {
_ContentID = dr.GetInt32("ContentID"); _ContentID = dr.GetInt32("ContentID");
@ -310,14 +332,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("PartInfo.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("PartInfo.ReadData", ex); throw new DbCslaException("PartInfo.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PartInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -346,7 +368,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("PartInfo.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("PartInfo.DataPortal_Fetch", ex); throw new DbCslaException("PartInfo.DataPortal_Fetch", ex);
} }
@ -356,7 +378,7 @@ namespace VEPROMS.CSLA.Library
#region extension #region extension
PartInfoExtension _PartInfoExtension = new PartInfoExtension(); PartInfoExtension _PartInfoExtension = new PartInfoExtension();
[Serializable()] [Serializable()]
partial class PartInfoExtension : extensionBase {} partial class PartInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {

View File

@ -124,7 +124,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -144,7 +144,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("PartInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("PartInfoList.DataPortal_Fetch", ex); throw new DbCslaException("PartInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -166,7 +166,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ContentIDCriteria criteria) private void DataPortal_Fetch(ContentIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_FetchContentID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_FetchContentID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -187,7 +187,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("PartInfoList.DataPortal_FetchContentID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfoList.DataPortal_FetchContentID", ex);
throw new DbCslaException("PartInfoList.DataPortal_Fetch", ex); throw new DbCslaException("PartInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -209,7 +209,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ItemIDCriteria criteria) private void DataPortal_Fetch(ItemIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_FetchItemID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_FetchItemID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -230,7 +230,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("PartInfoList.DataPortal_FetchItemID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfoList.DataPortal_FetchItemID", ex);
throw new DbCslaException("PartInfoList.DataPortal_Fetch", ex); throw new DbCslaException("PartInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -291,8 +291,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class PartInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class PartInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private PartInfo Item { get { return (PartInfo) _Item;} } private PartInfo Item { get { return (PartInfo)_Item; } }
public PartInfoListPropertyDescriptor(PartInfoList collection, int index):base(collection, index){;} public PartInfoListPropertyDescriptor(PartInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -303,7 +303,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is PartInfoList) if (destType == typeof(string) && value is PartInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((PartInfoList) value).Items.Count.ToString() + " Parts"; return ((PartInfoList)value).Items.Count.ToString() + " Parts";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -47,19 +47,23 @@ namespace VEPROMS.CSLA.Library
foreach (Permission tmp in _RefreshPermissions) foreach (Permission tmp in _RefreshPermissions)
{ {
PermissionInfo.Refresh(tmp); PermissionInfo.Refresh(tmp);
if(tmp._MyRole != null) RoleInfo.Refresh(tmp._MyRole); if (tmp._MyRole != null) RoleInfo.Refresh(tmp._MyRole);
} }
} }
#endregion #endregion
#region Collection #region Collection
protected static List<Permission> _AllList = new List<Permission>(); protected static List<Permission> _AllList = new List<Permission>();
private static Dictionary<string, Permission> _AllByPrimaryKey = new Dictionary<string, Permission>(); private static Dictionary<string, List<Permission>> _AllByPrimaryKey = new Dictionary<string, List<Permission>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<Permission> remove = new List<Permission>(); List<Permission> remove = new List<Permission>();
foreach (Permission tmp in _AllList) foreach (Permission tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.PID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.PID.ToString()))
{
_AllByPrimaryKey[tmp.PID.ToString()] = new List<Permission>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.PID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (Permission tmp in remove) foreach (Permission tmp in remove)
@ -69,7 +73,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = pid.ToString(); string key = pid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -91,7 +95,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("PID",true); CanReadProperty("PID", true);
return _PID; return _PID;
} }
} }
@ -101,7 +105,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RID",true); CanReadProperty("RID", true);
if (_MyRole != null) _RID = _MyRole.RID; if (_MyRole != null) _RID = _MyRole.RID;
return _RID; return _RID;
} }
@ -112,14 +116,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyRole",true); CanReadProperty("MyRole", true);
if (_MyRole == null && _RID != 0) _MyRole = Role.Get(_RID); if (_MyRole == null && _RID != 0) _MyRole = Role.Get(_RID);
return _MyRole; return _MyRole;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyRole",true); CanWriteProperty("MyRole", true);
if (_MyRole != value) if (_MyRole != value)
{ {
_MyRole = value; _MyRole = value;
@ -136,13 +140,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("PermLevel",true); CanReadProperty("PermLevel", true);
return _PermLevel; return _PermLevel;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("PermLevel",true); CanWriteProperty("PermLevel", true);
if (_PermLevel != value) if (_PermLevel != value)
{ {
_PermLevel = value; _PermLevel = value;
@ -159,13 +163,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("VersionType",true); CanReadProperty("VersionType", true);
return _VersionType; return _VersionType;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("VersionType",true); CanWriteProperty("VersionType", true);
if (_VersionType != value) if (_VersionType != value)
{ {
_VersionType = value; _VersionType = value;
@ -182,13 +186,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("PermValue",true); CanReadProperty("PermValue", true);
return _PermValue; return _PermValue;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("PermValue",true); CanWriteProperty("PermValue", true);
if (_PermValue != value) if (_PermValue != value)
{ {
_PermValue = value; _PermValue = value;
@ -205,13 +209,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("PermAD",true); CanReadProperty("PermAD", true);
return _PermAD; return _PermAD;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("PermAD",true); CanWriteProperty("PermAD", true);
if (_PermAD != value) if (_PermAD != value)
{ {
_PermAD = value; _PermAD = value;
@ -225,13 +229,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("StartDate",true); CanReadProperty("StartDate", true);
return _StartDate; return _StartDate;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("StartDate",true); CanWriteProperty("StartDate", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
_StartDate = value; _StartDate = value;
try try
@ -255,13 +259,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("EndDate",true); CanReadProperty("EndDate", true);
return _EndDate; return _EndDate;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("EndDate",true); CanWriteProperty("EndDate", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
_EndDate = value; _EndDate = value;
try try
@ -285,13 +289,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config",true); CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -306,13 +310,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -326,13 +330,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UsrID",true); CanWriteProperty("UsrID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UsrID != value) if (_UsrID != value)
{ {
@ -344,11 +348,11 @@ namespace VEPROMS.CSLA.Library
private byte[] _LastChanged = new byte[8];//timestamp private byte[] _LastChanged = new byte[8];//timestamp
public override bool IsDirty public override bool IsDirty
{ {
get { return base.IsDirty || (_MyRole == null? false : _MyRole.IsDirty); } get { return base.IsDirty || (_MyRole == null ? false : _MyRole.IsDirty); }
} }
public override bool IsValid public override bool IsValid
{ {
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyRole == null? true : _MyRole.IsValid); } get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyRole == null ? true : _MyRole.IsValid); }
} }
// TODO: Replace base Permission.ToString function as necessary // TODO: Replace base Permission.ToString function as necessary
/// <summary> /// <summary>
@ -371,22 +375,23 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get { get
if(_CheckingBrokenRules)return null; {
if (_CheckingBrokenRules) return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyRole != null && (hasBrokenRules = _MyRole.HasBrokenRules) != null) return hasBrokenRules; if (_MyRole != null && (hasBrokenRules = _MyRole.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -532,14 +537,25 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods #region Factory Methods
public int CurrentEditLevel public int CurrentEditLevel
{ get { return EditLevel; } } { get { return EditLevel; } }
private static int _PermissionUnique = 0;
private int _MyPermissionUnique;
public int MyPermissionUnique
{
get { return _MyPermissionUnique; }
}
protected Permission() protected Permission()
{/* require use of factory methods */ {/* require use of factory methods */
_MyPermissionUnique = ++_PermissionUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(PID.ToString()); if (!_AllByPrimaryKey.ContainsKey(PID.ToString())) return;
List<Permission> listPermission = _AllByPrimaryKey[PID.ToString()]; // Get the list of items
listPermission.Remove(this); // Remove the item from the list
if (listPermission.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(PID.ToString()); // remove the list
} }
public static Permission New() public static Permission New()
{ {
@ -631,7 +647,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<Permission>(new PKCriteria(pid)); tmp = DataPortal.Fetch<Permission>(new PKCriteria(pid));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -712,7 +728,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Permission.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Permission.ReadData", GetHashCode());
try try
{ {
_PID = dr.GetInt32("PID"); _PID = dr.GetInt32("PID");
@ -731,14 +747,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Permission.ReadData", ex); throw new DbCslaException("Permission.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Permission.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Permission.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -766,7 +782,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Permission.DataPortal_Fetch", ex); throw new DbCslaException("Permission.DataPortal_Fetch", ex);
} }
@ -787,13 +803,13 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.DataPortal_Insert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.DataPortal_Insert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Permission.DataPortal_Insert", ex); throw new DbCslaException("Permission.DataPortal_Insert", ex);
} }
finally finally
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Permission.DataPortal_Insert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Permission.DataPortal_Insert", GetHashCode());
} }
} }
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
@ -802,7 +818,7 @@ namespace VEPROMS.CSLA.Library
if (!this.IsDirty) return; if (!this.IsDirty) return;
try try
{ {
if(_MyRole != null) _MyRole.Update(); if (_MyRole != null) _MyRole.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
{ {
@ -834,11 +850,11 @@ namespace VEPROMS.CSLA.Library
} }
MarkOld(); MarkOld();
// update child objects // update child objects
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Permission.SQLInsert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Permission.SQLInsert", GetHashCode());
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.SQLInsert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.SQLInsert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Permission.SQLInsert", ex); throw new DbCslaException("Permission.SQLInsert", ex);
} }
@ -846,7 +862,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int pid, Role myRole, int permLevel, int versionType, int permValue, int permAD, SmartDate startDate, SmartDate endDate, string config, DateTime dts, string usrID) public static byte[] Add(SqlConnection cn, ref int pid, Role myRole, int permLevel, int versionType, int permValue, int permAD, SmartDate startDate, SmartDate endDate, string config, DateTime dts, string usrID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Permission.Add", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Permission.Add", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -880,7 +896,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.Add", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.Add", ex);
throw new DbCslaException("Permission.Add", ex); throw new DbCslaException("Permission.Add", ex);
} }
} }
@ -888,7 +904,7 @@ namespace VEPROMS.CSLA.Library
protected override void DataPortal_Update() protected override void DataPortal_Update()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Permission.DataPortal_Update", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Permission.DataPortal_Update", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -902,7 +918,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.DataPortal_Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.DataPortal_Update", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -911,10 +927,10 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate() internal void SQLUpdate()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Permission.SQLUpdate", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Permission.SQLUpdate", GetHashCode());
try try
{ {
if(_MyRole != null) _MyRole.Update(); if (_MyRole != null) _MyRole.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty) if (base.IsDirty)
{ {
@ -950,7 +966,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.SQLUpdate", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.SQLUpdate", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -971,7 +987,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int pid, Role myRole, int permLevel, int versionType, int permValue, int permAD, SmartDate startDate, SmartDate endDate, string config, DateTime dts, string usrID, ref byte[] lastChanged) public static byte[] Update(SqlConnection cn, ref int pid, Role myRole, int permLevel, int versionType, int permValue, int permAD, SmartDate startDate, SmartDate endDate, string config, DateTime dts, string usrID, ref byte[] lastChanged)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Permission.Update", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Permission.Update", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -1003,7 +1019,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.Update", ex);
throw new DbCslaException("Permission.Update", ex); throw new DbCslaException("Permission.Update", ex);
} }
} }
@ -1015,7 +1031,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria) private void DataPortal_Delete(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Permission.DataPortal_Delete", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Permission.DataPortal_Delete", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1031,7 +1047,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.DataPortal_Delete", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.DataPortal_Delete", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Permission.DataPortal_Delete", ex); throw new DbCslaException("Permission.DataPortal_Delete", ex);
} }
@ -1039,7 +1055,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int pid) public static void Remove(SqlConnection cn, int pid)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Permission.Remove", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Permission.Remove", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -1054,7 +1070,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.Remove", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.Remove", ex);
throw new DbCslaException("Permission.Remove", ex); throw new DbCslaException("Permission.Remove", ex);
} }
} }
@ -1088,7 +1104,7 @@ namespace VEPROMS.CSLA.Library
} }
protected override void DataPortal_Execute() protected override void DataPortal_Execute()
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Permission.DataPortal_Execute", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Permission.DataPortal_Execute", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1106,7 +1122,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.DataPortal_Execute", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.DataPortal_Execute", ex);
throw new DbCslaException("Permission.DataPortal_Execute", ex); throw new DbCslaException("Permission.DataPortal_Execute", ex);
} }
} }

View File

@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<PermissionInfo> _AllList = new List<PermissionInfo>(); protected static List<PermissionInfo> _AllList = new List<PermissionInfo>();
private static Dictionary<string, PermissionInfo> _AllByPrimaryKey = new Dictionary<string, PermissionInfo>(); private static Dictionary<string, List<PermissionInfo>> _AllByPrimaryKey = new Dictionary<string, List<PermissionInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<PermissionInfo> remove = new List<PermissionInfo>(); List<PermissionInfo> remove = new List<PermissionInfo>();
foreach (PermissionInfo tmp in _AllList) foreach (PermissionInfo tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.PID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.PID.ToString()))
{
_AllByPrimaryKey[tmp.PID.ToString()] = new List<PermissionInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.PID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (PermissionInfo tmp in remove) foreach (PermissionInfo tmp in remove)
@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = pid.ToString(); string key = pid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("PID",true); CanReadProperty("PID", true);
return _PID; return _PID;
} }
} }
@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RID",true); CanReadProperty("RID", true);
if (_MyRole != null) _RID = _MyRole.RID; if (_MyRole != null) _RID = _MyRole.RID;
return _RID; return _RID;
} }
@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyRole",true); CanReadProperty("MyRole", true);
if (_MyRole == null && _RID != 0) _MyRole = RoleInfo.Get(_RID); if (_MyRole == null && _RID != 0) _MyRole = RoleInfo.Get(_RID);
return _MyRole; return _MyRole;
} }
@ -120,7 +124,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("PermLevel",true); CanReadProperty("PermLevel", true);
return _PermLevel; return _PermLevel;
} }
} }
@ -133,7 +137,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("VersionType",true); CanReadProperty("VersionType", true);
return _VersionType; return _VersionType;
} }
} }
@ -146,7 +150,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("PermValue",true); CanReadProperty("PermValue", true);
return _PermValue; return _PermValue;
} }
} }
@ -159,7 +163,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("PermAD",true); CanReadProperty("PermAD", true);
return _PermAD; return _PermAD;
} }
} }
@ -169,7 +173,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("StartDate",true); CanReadProperty("StartDate", true);
return _StartDate; return _StartDate;
} }
} }
@ -179,7 +183,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("EndDate",true); CanReadProperty("EndDate", true);
return _EndDate; return _EndDate;
} }
} }
@ -189,7 +193,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
} }
@ -199,7 +203,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -209,7 +213,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
} }
@ -233,14 +237,25 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _PermissionInfoUnique = 0;
private int _MyPermissionInfoUnique;
public int MyPermissionInfoUnique
{
get { return _MyPermissionInfoUnique; }
}
private PermissionInfo() private PermissionInfo()
{/* require use of factory methods */ {/* require use of factory methods */
_MyPermissionInfoUnique = ++_PermissionInfoUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(PID.ToString()); if (!_AllByPrimaryKey.ContainsKey(PID.ToString())) return;
List<PermissionInfo> listPermissionInfo = _AllByPrimaryKey[PID.ToString()]; // Get the list of items
listPermissionInfo.Remove(this); // Remove the item from the list
if (listPermissionInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(PID.ToString()); // remove the list
} }
public virtual Permission Get() public virtual Permission Get()
{ {
@ -248,9 +263,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(Permission tmp) public static void Refresh(Permission tmp)
{ {
PermissionInfo tmpInfo = GetExistingByPrimaryKey(tmp.PID); string key = tmp.PID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (PermissionInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(Permission tmp) private void RefreshFields(Permission tmp)
{ {
@ -258,9 +275,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyRole.RefreshRolePermissions(); // Update List for old value MyRole.RefreshRolePermissions(); // Update List for old value
_RID = tmp.RID; // Update the value _RID = tmp.RID; // Update the value
_MyRole = null; // Reset list so that the next line gets a new list
MyRole.RefreshRolePermissions(); // Update List for new value
} }
_MyRole = null; // Reset list so that the next line gets a new list
if (MyRole != null) MyRole.RefreshRolePermissions(); // Update List for new value
_PermLevel = tmp.PermLevel; _PermLevel = tmp.PermLevel;
_VersionType = tmp.VersionType; _VersionType = tmp.VersionType;
_PermValue = tmp.PermValue; _PermValue = tmp.PermValue;
@ -276,9 +293,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(RolePermission tmp) public static void Refresh(RolePermission tmp)
{ {
PermissionInfo tmpInfo = GetExistingByPrimaryKey(tmp.PID); string key = tmp.PID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (PermissionInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(RolePermission tmp) private void RefreshFields(RolePermission tmp)
{ {
@ -305,7 +324,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<PermissionInfo>(new PKCriteria(pid)); tmp = DataPortal.Fetch<PermissionInfo>(new PKCriteria(pid));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -319,14 +338,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
internal PermissionInfo(SafeDataReader dr) internal PermissionInfo(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PermissionInfo.Constructor", GetHashCode()); _MyPermissionInfoUnique = ++_PermissionInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PermissionInfo.Constructor", GetHashCode());
try try
{ {
ReadData(dr); ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("PermissionInfo.Constructor", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("PermissionInfo.Constructor", ex);
throw new DbCslaException("PermissionInfo.Constructor", ex); throw new DbCslaException("PermissionInfo.Constructor", ex);
} }
} }
@ -343,7 +363,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PermissionInfo.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PermissionInfo.ReadData", GetHashCode());
try try
{ {
_PID = dr.GetInt32("PID"); _PID = dr.GetInt32("PID");
@ -360,14 +380,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("PermissionInfo.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("PermissionInfo.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("PermissionInfo.ReadData", ex); throw new DbCslaException("PermissionInfo.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PermissionInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PermissionInfo.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -395,7 +415,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("PermissionInfo.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("PermissionInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("PermissionInfo.DataPortal_Fetch", ex); throw new DbCslaException("PermissionInfo.DataPortal_Fetch", ex);
} }
@ -405,7 +425,7 @@ namespace VEPROMS.CSLA.Library
#region extension #region extension
PermissionInfoExtension _PermissionInfoExtension = new PermissionInfoExtension(); PermissionInfoExtension _PermissionInfoExtension = new PermissionInfoExtension();
[Serializable()] [Serializable()]
partial class PermissionInfoExtension : extensionBase {} partial class PermissionInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {

View File

@ -110,7 +110,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PermissionInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PermissionInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -130,7 +130,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("PermissionInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("PermissionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("PermissionInfoList.DataPortal_Fetch", ex); throw new DbCslaException("PermissionInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -152,7 +152,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(RIDCriteria criteria) private void DataPortal_Fetch(RIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PermissionInfoList.DataPortal_FetchRID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PermissionInfoList.DataPortal_FetchRID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -173,7 +173,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("PermissionInfoList.DataPortal_FetchRID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("PermissionInfoList.DataPortal_FetchRID", ex);
throw new DbCslaException("PermissionInfoList.DataPortal_Fetch", ex); throw new DbCslaException("PermissionInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -234,8 +234,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class PermissionInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class PermissionInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private PermissionInfo Item { get { return (PermissionInfo) _Item;} } private PermissionInfo Item { get { return (PermissionInfo)_Item; } }
public PermissionInfoListPropertyDescriptor(PermissionInfoList collection, int index):base(collection, index){;} public PermissionInfoListPropertyDescriptor(PermissionInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -246,7 +246,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is PermissionInfoList) if (destType == typeof(string) && value is PermissionInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((PermissionInfoList) value).Items.Count.ToString() + " Permissions"; return ((PermissionInfoList)value).Items.Count.ToString() + " Permissions";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -57,7 +57,7 @@ namespace VEPROMS.CSLA.Library
public interface IVEHasBrokenRules public interface IVEHasBrokenRules
{ {
IVEHasBrokenRules HasBrokenRules { get; } IVEHasBrokenRules HasBrokenRules { get; }
BrokenRulesCollection BrokenRules { get; } BrokenRulesCollection BrokenRules { get; }
} }
} // Namespace } // Namespace
// The following are samples of ToString overrides // The following are samples of ToString overrides

View File

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

View File

@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<RoUsageInfo> _AllList = new List<RoUsageInfo>(); protected static List<RoUsageInfo> _AllList = new List<RoUsageInfo>();
private static Dictionary<string, RoUsageInfo> _AllByPrimaryKey = new Dictionary<string, RoUsageInfo>(); private static Dictionary<string, List<RoUsageInfo>> _AllByPrimaryKey = new Dictionary<string, List<RoUsageInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<RoUsageInfo> remove = new List<RoUsageInfo>(); List<RoUsageInfo> remove = new List<RoUsageInfo>();
foreach (RoUsageInfo tmp in _AllList) foreach (RoUsageInfo tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.ROUsageID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.ROUsageID.ToString()))
{
_AllByPrimaryKey[tmp.ROUsageID.ToString()] = new List<RoUsageInfo>(); // Add new list for PrimaryKey
}
_AllByPrimaryKey[tmp.ROUsageID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp); remove.Add(tmp);
} }
foreach (RoUsageInfo tmp in remove) foreach (RoUsageInfo tmp in remove)
@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = rOUsageID.ToString(); string key = rOUsageID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ROUsageID",true); CanReadProperty("ROUsageID", true);
return _ROUsageID; return _ROUsageID;
} }
} }
@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ContentID",true); CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID; if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID; return _ContentID;
} }
@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyContent",true); CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID); if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent; return _MyContent;
} }
@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ROID",true); CanReadProperty("ROID", true);
return _ROID; return _ROID;
} }
} }
@ -127,7 +131,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config",true); CanReadProperty("Config", true);
return _Config; return _Config;
} }
} }
@ -137,7 +141,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -147,7 +151,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID",true); CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
} }
@ -171,14 +175,25 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _RoUsageInfoUnique = 0;
private int _MyRoUsageInfoUnique;
public int MyRoUsageInfoUnique
{
get { return _MyRoUsageInfoUnique; }
}
private RoUsageInfo() private RoUsageInfo()
{/* require use of factory methods */ {/* require use of factory methods */
_MyRoUsageInfoUnique = ++_RoUsageInfoUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(ROUsageID.ToString()); if (!_AllByPrimaryKey.ContainsKey(ROUsageID.ToString())) return;
List<RoUsageInfo> listRoUsageInfo = _AllByPrimaryKey[ROUsageID.ToString()]; // Get the list of items
listRoUsageInfo.Remove(this); // Remove the item from the list
if (listRoUsageInfo.Count == 0) // If there are no items left in the list
_AllByPrimaryKey.Remove(ROUsageID.ToString()); // remove the list
} }
public virtual RoUsage Get() public virtual RoUsage Get()
{ {
@ -186,9 +201,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(RoUsage tmp) public static void Refresh(RoUsage tmp)
{ {
RoUsageInfo tmpInfo = GetExistingByPrimaryKey(tmp.ROUsageID); string key = tmp.ROUsageID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (RoUsageInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(RoUsage tmp) private void RefreshFields(RoUsage tmp)
{ {
@ -196,9 +213,9 @@ namespace VEPROMS.CSLA.Library
{ {
MyContent.RefreshContentRoUsages(); // Update List for old value MyContent.RefreshContentRoUsages(); // Update List for old value
_ContentID = tmp.ContentID; // Update the value _ContentID = tmp.ContentID; // Update the value
_MyContent = null; // Reset list so that the next line gets a new list
MyContent.RefreshContentRoUsages(); // Update List for new value
} }
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentRoUsages(); // Update List for new value
_ROID = tmp.ROID; _ROID = tmp.ROID;
_Config = tmp.Config; _Config = tmp.Config;
_DTS = tmp.DTS; _DTS = tmp.DTS;
@ -209,9 +226,11 @@ namespace VEPROMS.CSLA.Library
} }
public static void Refresh(ContentRoUsage tmp) public static void Refresh(ContentRoUsage tmp)
{ {
RoUsageInfo tmpInfo = GetExistingByPrimaryKey(tmp.ROUsageID); string key = tmp.ROUsageID.ToString();
if (tmpInfo == null) return; ConvertListToDictionary();
tmpInfo.RefreshFields(tmp); if (_AllByPrimaryKey.ContainsKey(key))
foreach (RoUsageInfo tmpInfo in _AllByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
} }
private void RefreshFields(ContentRoUsage tmp) private void RefreshFields(ContentRoUsage tmp)
{ {
@ -233,7 +252,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<RoUsageInfo>(new PKCriteria(rOUsageID)); tmp = DataPortal.Fetch<RoUsageInfo>(new PKCriteria(rOUsageID));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -247,14 +266,15 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
internal RoUsageInfo(SafeDataReader dr) internal RoUsageInfo(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsageInfo.Constructor", GetHashCode()); _MyRoUsageInfoUnique = ++_RoUsageInfoUnique;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfo.Constructor", GetHashCode());
try try
{ {
ReadData(dr); ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsageInfo.Constructor", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsageInfo.Constructor", ex);
throw new DbCslaException("RoUsageInfo.Constructor", ex); throw new DbCslaException("RoUsageInfo.Constructor", ex);
} }
} }
@ -271,7 +291,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsageInfo.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfo.ReadData", GetHashCode());
try try
{ {
_ROUsageID = dr.GetInt32("ROUsageID"); _ROUsageID = dr.GetInt32("ROUsageID");
@ -283,14 +303,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsageInfo.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsageInfo.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("RoUsageInfo.ReadData", ex); throw new DbCslaException("RoUsageInfo.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsageInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfo.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -318,7 +338,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsageInfo.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsageInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("RoUsageInfo.DataPortal_Fetch", ex); throw new DbCslaException("RoUsageInfo.DataPortal_Fetch", ex);
} }
@ -328,7 +348,7 @@ namespace VEPROMS.CSLA.Library
#region extension #region extension
RoUsageInfoExtension _RoUsageInfoExtension = new RoUsageInfoExtension(); RoUsageInfoExtension _RoUsageInfoExtension = new RoUsageInfoExtension();
[Serializable()] [Serializable()]
partial class RoUsageInfoExtension : extensionBase {} partial class RoUsageInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {

View File

@ -110,7 +110,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsageInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -130,7 +130,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsageInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsageInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("RoUsageInfoList.DataPortal_Fetch", ex); throw new DbCslaException("RoUsageInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -152,7 +152,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ContentIDCriteria criteria) private void DataPortal_Fetch(ContentIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsageInfoList.DataPortal_FetchContentID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfoList.DataPortal_FetchContentID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -173,7 +173,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsageInfoList.DataPortal_FetchContentID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsageInfoList.DataPortal_FetchContentID", ex);
throw new DbCslaException("RoUsageInfoList.DataPortal_Fetch", ex); throw new DbCslaException("RoUsageInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -234,8 +234,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class RoUsageInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class RoUsageInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private RoUsageInfo Item { get { return (RoUsageInfo) _Item;} } private RoUsageInfo Item { get { return (RoUsageInfo)_Item; } }
public RoUsageInfoListPropertyDescriptor(RoUsageInfoList collection, int index):base(collection, index){;} public RoUsageInfoListPropertyDescriptor(RoUsageInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -246,7 +246,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is RoUsageInfoList) if (destType == typeof(string) && value is RoUsageInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((RoUsageInfoList) value).Items.Count.ToString() + " RoUsages"; return ((RoUsageInfoList)value).Items.Count.ToString() + " RoUsages";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

View File

@ -42,14 +42,14 @@ namespace VEPROMS.CSLA.Library
{ {
foreach (RoleAssignment tmp in _RoleAssignments) foreach (RoleAssignment tmp in _RoleAssignments)
{ {
if(tmp.IsDirty)refreshRoleAssignments.Add(tmp); if (tmp.IsDirty) refreshRoleAssignments.Add(tmp);
} }
} }
if (_RolePermissions != null && _RolePermissions.IsDirty) if (_RolePermissions != null && _RolePermissions.IsDirty)
{ {
foreach (RolePermission tmp in _RolePermissions) foreach (RolePermission tmp in _RolePermissions)
{ {
if(tmp.IsDirty)refreshRolePermissions.Add(tmp); if (tmp.IsDirty) refreshRolePermissions.Add(tmp);
} }
} }
} }
@ -78,15 +78,20 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region Collection #region Collection
protected static List<Role> _AllList = new List<Role>(); protected static List<Role> _AllList = new List<Role>();
private static Dictionary<string, Role> _AllByPrimaryKey = new Dictionary<string, Role>(); private static Dictionary<string, List<Role>> _AllByPrimaryKey = new Dictionary<string, List<Role>>();
private static Dictionary<string, Role> _AllByName = new Dictionary<string, Role>(); private static Dictionary<string, List<Role>> _AllByName = new Dictionary<string, List<Role>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
List<Role> remove = new List<Role>(); List<Role> remove = new List<Role>();
foreach (Role tmp in _AllList) foreach (Role tmp in _AllList)
{ {
_AllByPrimaryKey[tmp.RID.ToString()]=tmp; // Primary Key if (!_AllByPrimaryKey.ContainsKey(tmp.RID.ToString()))
_AllByName[tmp.Name.ToString()] = tmp; // Unique Index {
_AllByPrimaryKey[tmp.RID.ToString()] = new List<Role>(); // Add new list for PrimaryKey
_AllByName[tmp.Name.ToString()] = new List<Role>(); // Add new list for Name
}
_AllByPrimaryKey[tmp.RID.ToString()].Add(tmp); // Add to Primary Key list
_AllByName[tmp.Name.ToString()].Add(tmp); // Unique Index
remove.Add(tmp); remove.Add(tmp);
} }
foreach (Role tmp in remove) foreach (Role tmp in remove)
@ -96,14 +101,14 @@ namespace VEPROMS.CSLA.Library
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = rid.ToString(); string key = rid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0];
return null; return null;
} }
public static Role GetExistingByName(string name) public static Role GetExistingByName(string name)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = name.ToString(); string key = name.ToString();
if (_AllByName.ContainsKey(key)) return _AllByName[key]; if (_AllByName.ContainsKey(key)) return _AllByName[key][0];
return null; return null;
} }
#endregion #endregion
@ -125,7 +130,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RID",true); CanReadProperty("RID", true);
return _RID; return _RID;
} }
} }
@ -135,13 +140,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name",true); CanReadProperty("Name", true);
return _Name; return _Name;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Name",true); CanWriteProperty("Name", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Name != value) if (_Name != value)
{ {
@ -156,13 +161,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Title",true); CanReadProperty("Title", true);
return _Title; return _Title;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Title",true); CanWriteProperty("Title", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Title != value) if (_Title != value)
{ {
@ -177,13 +182,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -197,13 +202,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UsrID",true); CanWriteProperty("UsrID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UsrID != value) if (_UsrID != value)
{ {
@ -222,7 +227,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RoleAssignmentCount",true); CanReadProperty("RoleAssignmentCount", true);
return _RoleAssignmentCount; return _RoleAssignmentCount;
} }
} }
@ -236,10 +241,10 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RoleAssignments",true); CanReadProperty("RoleAssignments", true);
if(_RoleAssignmentCount > 0 && _RoleAssignments == null) if (_RoleAssignmentCount > 0 && _RoleAssignments == null)
_RoleAssignments = RoleAssignments.GetByRID(RID); _RoleAssignments = RoleAssignments.GetByRID(RID);
else if(_RoleAssignments == null) else if (_RoleAssignments == null)
_RoleAssignments = RoleAssignments.New(); _RoleAssignments = RoleAssignments.New();
return _RoleAssignments; return _RoleAssignments;
} }
@ -253,7 +258,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RolePermissionCount",true); CanReadProperty("RolePermissionCount", true);
return _RolePermissionCount; return _RolePermissionCount;
} }
} }
@ -267,21 +272,21 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RolePermissions",true); CanReadProperty("RolePermissions", true);
if(_RolePermissionCount > 0 && _RolePermissions == null) if (_RolePermissionCount > 0 && _RolePermissions == null)
_RolePermissions = RolePermissions.GetByRID(RID); _RolePermissions = RolePermissions.GetByRID(RID);
else if(_RolePermissions == null) else if (_RolePermissions == null)
_RolePermissions = RolePermissions.New(); _RolePermissions = RolePermissions.New();
return _RolePermissions; return _RolePermissions;
} }
} }
public override bool IsDirty public override bool IsDirty
{ {
get { return base.IsDirty || (_RoleAssignments == null? false : _RoleAssignments.IsDirty) || (_RolePermissions == null? false : _RolePermissions.IsDirty); } get { return base.IsDirty || (_RoleAssignments == null ? false : _RoleAssignments.IsDirty) || (_RolePermissions == null ? false : _RolePermissions.IsDirty); }
} }
public override bool IsValid public override bool IsValid
{ {
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_RoleAssignments == null? true : _RoleAssignments.IsValid) && (_RolePermissions == null? true : _RolePermissions.IsValid); } get { return (IsNew && !IsDirty ? true : base.IsValid) && (_RoleAssignments == null ? true : _RoleAssignments.IsValid) && (_RolePermissions == null ? true : _RolePermissions.IsValid); }
} }
// TODO: Replace base Role.ToString function as necessary // TODO: Replace base Role.ToString function as necessary
/// <summary> /// <summary>
@ -304,23 +309,24 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get { get
if(_CheckingBrokenRules)return null; {
if (_CheckingBrokenRules) return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_RoleAssignments != null && (hasBrokenRules = _RoleAssignments.HasBrokenRules) != null) return hasBrokenRules; if (_RoleAssignments != null && (hasBrokenRules = _RoleAssignments.HasBrokenRules) != null) return hasBrokenRules;
if (_RolePermissions != null && (hasBrokenRules = _RolePermissions.HasBrokenRules) != null) return hasBrokenRules; if (_RolePermissions != null && (hasBrokenRules = _RolePermissions.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -435,15 +441,29 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods #region Factory Methods
public int CurrentEditLevel public int CurrentEditLevel
{ get { return EditLevel; } } { get { return EditLevel; } }
private static int _RoleUnique = 0;
private int _MyRoleUnique;
public int MyRoleUnique
{
get { return _MyRoleUnique; }
}
protected Role() protected Role()
{/* require use of factory methods */ {/* require use of factory methods */
_MyRoleUnique = ++_RoleUnique;
_AllList.Add(this); _AllList.Add(this);
} }
public void Dispose() public void Dispose()
{ {
_AllList.Remove(this); _AllList.Remove(this);
_AllByPrimaryKey.Remove(RID.ToString()); if (!_AllByPrimaryKey.ContainsKey(RID.ToString())) return;
_AllByName.Remove(Name.ToString()); List<Role> listRole = _AllByPrimaryKey[RID.ToString()]; // Get the list of items
listRole.Remove(this); // Remove the item from the list
if (listRole.Count == 0) //If there are no items left in the list
_AllByPrimaryKey.Remove(RID.ToString()); // remove the list
listRole = _AllByName[RID.ToString()]; // Get the list of items
listRole.Remove(this); // Remove the item from the list
if (listRole.Count == 0) //If there are no items left in the list
_AllByName.Remove(RID.ToString()); // remove the list
} }
public static Role New() public static Role New()
{ {
@ -500,7 +520,7 @@ namespace VEPROMS.CSLA.Library
if (tmp == null) if (tmp == null)
{ {
tmp = DataPortal.Fetch<Role>(new PKCriteria(rid)); tmp = DataPortal.Fetch<Role>(new PKCriteria(rid));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -519,8 +539,8 @@ namespace VEPROMS.CSLA.Library
Role tmp = GetExistingByName(name); Role tmp = GetExistingByName(name);
if (tmp == null) if (tmp == null)
{ {
tmp=DataPortal.Fetch<Role>(new NameCriteria(name)); tmp = DataPortal.Fetch<Role>(new NameCriteria(name));
_AllList.Add(tmp); if (!_AllList.Contains(tmp)) _AllList.Add(tmp);
} }
if (tmp.ErrorMessage == "No Record Found") tmp = null; if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp; return tmp;
@ -610,7 +630,7 @@ namespace VEPROMS.CSLA.Library
} }
private void ReadData(SafeDataReader dr) private void ReadData(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Role.ReadData", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Role.ReadData", GetHashCode());
try try
{ {
_RID = dr.GetInt32("RID"); _RID = dr.GetInt32("RID");
@ -625,14 +645,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.ReadData", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.ReadData", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Role.ReadData", ex); throw new DbCslaException("Role.ReadData", ex);
} }
} }
private void DataPortal_Fetch(PKCriteria criteria) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Role.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Role.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -666,14 +686,14 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Role.DataPortal_Fetch", ex); throw new DbCslaException("Role.DataPortal_Fetch", ex);
} }
} }
private void DataPortal_Fetch(NameCriteria criteria) private void DataPortal_Fetch(NameCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Role.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Role.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -701,7 +721,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Role.DataPortal_Fetch", ex); throw new DbCslaException("Role.DataPortal_Fetch", ex);
} }
@ -722,13 +742,13 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.DataPortal_Insert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.DataPortal_Insert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Role.DataPortal_Insert", ex); throw new DbCslaException("Role.DataPortal_Insert", ex);
} }
finally finally
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Role.DataPortal_Insert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Role.DataPortal_Insert", GetHashCode());
} }
} }
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
@ -764,11 +784,11 @@ namespace VEPROMS.CSLA.Library
// update child objects // update child objects
if (_RoleAssignments != null) _RoleAssignments.Update(this); if (_RoleAssignments != null) _RoleAssignments.Update(this);
if (_RolePermissions != null) _RolePermissions.Update(this); if (_RolePermissions != null) _RolePermissions.Update(this);
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Role.SQLInsert", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Role.SQLInsert", GetHashCode());
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.SQLInsert", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.SQLInsert", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Role.SQLInsert", ex); throw new DbCslaException("Role.SQLInsert", ex);
} }
@ -776,7 +796,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int rid, string name, string title, DateTime dts, string usrID) public static byte[] Add(SqlConnection cn, ref int rid, string name, string title, DateTime dts, string usrID)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Role.Add", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Role.Add", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -804,7 +824,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.Add", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.Add", ex);
throw new DbCslaException("Role.Add", ex); throw new DbCslaException("Role.Add", ex);
} }
} }
@ -812,7 +832,7 @@ namespace VEPROMS.CSLA.Library
protected override void DataPortal_Update() protected override void DataPortal_Update()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Role.DataPortal_Update", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Role.DataPortal_Update", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -826,7 +846,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.DataPortal_Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.DataPortal_Update", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -835,7 +855,7 @@ namespace VEPROMS.CSLA.Library
internal void SQLUpdate() internal void SQLUpdate()
{ {
if (!IsDirty) return; // If not dirty - nothing to do if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Role.SQLUpdate", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Role.SQLUpdate", GetHashCode());
try try
{ {
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
@ -869,7 +889,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.SQLUpdate", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.SQLUpdate", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
} }
@ -892,7 +912,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int rid, string name, string title, DateTime dts, string usrID, ref byte[] lastChanged) public static byte[] Update(SqlConnection cn, ref int rid, string name, string title, DateTime dts, string usrID, ref byte[] lastChanged)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Role.Update", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Role.Update", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -918,7 +938,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.Update", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.Update", ex);
throw new DbCslaException("Role.Update", ex); throw new DbCslaException("Role.Update", ex);
} }
} }
@ -930,7 +950,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria) private void DataPortal_Delete(PKCriteria criteria)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Role.DataPortal_Delete", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Role.DataPortal_Delete", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -946,7 +966,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.DataPortal_Delete", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.DataPortal_Delete", ex);
_ErrorMessage = ex.Message; _ErrorMessage = ex.Message;
throw new DbCslaException("Role.DataPortal_Delete", ex); throw new DbCslaException("Role.DataPortal_Delete", ex);
} }
@ -954,7 +974,7 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)] [Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int rid) public static void Remove(SqlConnection cn, int rid)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Role.Remove", 0); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Role.Remove", 0);
try try
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
@ -969,7 +989,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.Remove", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.Remove", ex);
throw new DbCslaException("Role.Remove", ex); throw new DbCslaException("Role.Remove", ex);
} }
} }
@ -1003,7 +1023,7 @@ namespace VEPROMS.CSLA.Library
} }
protected override void DataPortal_Execute() protected override void DataPortal_Execute()
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Role.DataPortal_Execute", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Role.DataPortal_Execute", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -1021,7 +1041,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.DataPortal_Execute", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.DataPortal_Execute", ex);
throw new DbCslaException("Role.DataPortal_Execute", ex); throw new DbCslaException("Role.DataPortal_Execute", ex);
} }
} }

View File

@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AID",true); CanReadProperty("AID", true);
if (_MyAssignment != null) _AID = _MyAssignment.AID; if (_MyAssignment != null) _AID = _MyAssignment.AID;
return _AID; return _AID;
} }
@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyAssignment",true); CanReadProperty("MyAssignment", true);
if (_MyAssignment == null && _AID != 0) _MyAssignment = Assignment.Get(_AID); if (_MyAssignment == null && _AID != 0) _MyAssignment = Assignment.Get(_AID);
return _MyAssignment; return _MyAssignment;
} }
@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GID",true); CanReadProperty("GID", true);
if (_MyGroup != null) _GID = _MyGroup.GID; if (_MyGroup != null) _GID = _MyGroup.GID;
return _GID; return _GID;
} }
@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyGroup",true); CanReadProperty("MyGroup", true);
if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID); if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID);
return _MyGroup; return _MyGroup;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyGroup",true); CanWriteProperty("MyGroup", true);
if (_MyGroup != value) if (_MyGroup != value)
{ {
_MyGroup = value; _MyGroup = value;
@ -97,7 +97,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderID",true); CanReadProperty("FolderID", true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID; if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID; return _FolderID;
} }
@ -108,14 +108,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFolder",true); CanReadProperty("MyFolder", true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID); if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder; return _MyFolder;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyFolder",true); CanWriteProperty("MyFolder", true);
if (_MyFolder != value) if (_MyFolder != value)
{ {
_MyFolder = value; _MyFolder = value;
@ -129,13 +129,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("StartDate",true); CanReadProperty("StartDate", true);
return _StartDate; return _StartDate;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("StartDate",true); CanWriteProperty("StartDate", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
_StartDate = value; _StartDate = value;
try try
@ -159,13 +159,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("EndDate",true); CanReadProperty("EndDate", true);
return _EndDate; return _EndDate;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("EndDate",true); CanWriteProperty("EndDate", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
_EndDate = value; _EndDate = value;
try try
@ -189,13 +189,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS",true); CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS",true); CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -209,13 +209,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID",true); CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UsrID",true); CanWriteProperty("UsrID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UsrID != value) if (_UsrID != value)
{ {
@ -231,7 +231,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_ParentID",true); CanReadProperty("Folder_ParentID", true);
return _Folder_ParentID; return _Folder_ParentID;
} }
} }
@ -241,7 +241,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_DBID",true); CanReadProperty("Folder_DBID", true);
return _Folder_DBID; return _Folder_DBID;
} }
} }
@ -251,7 +251,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_Name",true); CanReadProperty("Folder_Name", true);
return _Folder_Name; return _Folder_Name;
} }
} }
@ -261,7 +261,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_Title",true); CanReadProperty("Folder_Title", true);
return _Folder_Title; return _Folder_Title;
} }
} }
@ -271,7 +271,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_ShortName",true); CanReadProperty("Folder_ShortName", true);
return _Folder_ShortName; return _Folder_ShortName;
} }
} }
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_FormatID",true); CanReadProperty("Folder_FormatID", true);
return _Folder_FormatID; return _Folder_FormatID;
} }
} }
@ -291,7 +291,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_Config",true); CanReadProperty("Folder_Config", true);
return _Folder_Config; return _Folder_Config;
} }
} }
@ -301,7 +301,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_DTS",true); CanReadProperty("Folder_DTS", true);
return _Folder_DTS; return _Folder_DTS;
} }
} }
@ -311,7 +311,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Folder_UsrID",true); CanReadProperty("Folder_UsrID", true);
return _Folder_UsrID; return _Folder_UsrID;
} }
} }
@ -321,7 +321,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Group_GroupName",true); CanReadProperty("Group_GroupName", true);
return _Group_GroupName; return _Group_GroupName;
} }
} }
@ -331,7 +331,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Group_GroupType",true); CanReadProperty("Group_GroupType", true);
return _Group_GroupType; return _Group_GroupType;
} }
} }
@ -341,7 +341,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Group_Config",true); CanReadProperty("Group_Config", true);
return _Group_Config; return _Group_Config;
} }
} }
@ -351,7 +351,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Group_DTS",true); CanReadProperty("Group_DTS", true);
return _Group_DTS; return _Group_DTS;
} }
} }
@ -361,7 +361,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Group_UsrID",true); CanReadProperty("Group_UsrID", true);
return _Group_UsrID; return _Group_UsrID;
} }
} }
@ -394,24 +394,24 @@ namespace VEPROMS.CSLA.Library
#endregion #endregion
#region ValidationRules #region ValidationRules
[NonSerialized] [NonSerialized]
private bool _CheckingBrokenRules=false; private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules public IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
if(_CheckingBrokenRules)return null; if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this; if (BrokenRulesCollection.Count > 0) return this;
try try
{ {
_CheckingBrokenRules=true; _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules; if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules;
if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
finally finally
{ {
_CheckingBrokenRules=false; _CheckingBrokenRules = false;
} }
} }
} }
@ -567,8 +567,8 @@ namespace VEPROMS.CSLA.Library
_StartDate = _RoleAssignmentExtension.DefaultStartDate; _StartDate = _RoleAssignmentExtension.DefaultStartDate;
_DTS = _RoleAssignmentExtension.DefaultDTS; _DTS = _RoleAssignmentExtension.DefaultDTS;
_UsrID = _RoleAssignmentExtension.DefaultUsrID; _UsrID = _RoleAssignmentExtension.DefaultUsrID;
_MyGroup = myGroup; _MyGroup = myGroup;
_MyFolder = myFolder; _MyFolder = myFolder;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal RoleAssignment(SafeDataReader dr) internal RoleAssignment(SafeDataReader dr)
@ -580,7 +580,7 @@ namespace VEPROMS.CSLA.Library
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoleAssignment.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoleAssignment.FetchDR", GetHashCode());
try try
{ {
_AID = dr.GetInt32("AID"); _AID = dr.GetInt32("AID");
@ -608,7 +608,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoleAssignment.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("RoleAssignment.FetchDR", ex);
throw new DbCslaException("RoleAssignment.Fetch", ex); throw new DbCslaException("RoleAssignment.Fetch", ex);
} }
MarkOld(); MarkOld();

View File

@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library
} }
public RoleAssignment Add(Group myGroup, Folder myFolder) // One to Many public RoleAssignment Add(Group myGroup, Folder myFolder) // One to Many
{ {
RoleAssignment assignment = RoleAssignment.New(myGroup, myFolder); RoleAssignment assignment = RoleAssignment.New(myGroup, myFolder);
this.Add(assignment); this.Add(assignment);
return assignment; return assignment;
} }
public void Remove(Assignment myAssignment) public void Remove(Assignment myAssignment)
{ {
@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules=null; IVEHasBrokenRules hasBrokenRules = null;
foreach(RoleAssignment roleAssignment in this) foreach (RoleAssignment roleAssignment in this)
if ((hasBrokenRules = roleAssignment.HasBrokenRules) != null) return hasBrokenRules; if ((hasBrokenRules = roleAssignment.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
} }
} }
#endregion #endregion
@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(RIDCriteria criteria) private void DataPortal_Fetch(RIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoleAssignments.DataPortal_FetchRID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoleAssignments.DataPortal_FetchRID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoleAssignments.DataPortal_FetchRID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("RoleAssignments.DataPortal_FetchRID", ex);
throw new DbCslaException("RoleAssignments.DataPortal_Fetch", ex); throw new DbCslaException("RoleAssignments.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library
/// </summary> /// </summary>
public partial class RoleAssignmentsPropertyDescriptor : vlnListPropertyDescriptor public partial class RoleAssignmentsPropertyDescriptor : vlnListPropertyDescriptor
{ {
private RoleAssignment Item { get { return (RoleAssignment) _Item;} } private RoleAssignment Item { get { return (RoleAssignment)_Item; } }
public RoleAssignmentsPropertyDescriptor(RoleAssignments collection, int index):base(collection, index){;} public RoleAssignmentsPropertyDescriptor(RoleAssignments collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library
if (destType == typeof(string) && value is RoleAssignments) if (destType == typeof(string) && value is RoleAssignments)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((RoleAssignments) value).Items.Count.ToString() + " Assignments"; return ((RoleAssignments)value).Items.Count.ToString() + " Assignments";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }

Some files were not shown because too many files have changed in this diff Show More