diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/AnnotationExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/AnnotationExt.cs index 3c83d82e..1dfcd910 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/AnnotationExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/AnnotationExt.cs @@ -11,30 +11,13 @@ namespace VEPROMS.CSLA.Library return _SearchText; } } - public partial class AnnotationType { public override string ToString() { return _Name; } - - - public static IList AllTypes() - { - List tlst = new List(); - foreach (AnnotationType at in _AllByPrimaryKey.Values) - { - tlst.Add(at); - } - return tlst; - } - public static Dictionary AllByName() - { - return _AllByName; - } } - public partial class AnnotationTypeInfo { public static List AllList() @@ -42,14 +25,11 @@ namespace VEPROMS.CSLA.Library //return _AllList; return AnnotationTypeInfo._AllList; } - public override string ToString() { return _Name; } - } - public partial class Annotation { /// @@ -73,7 +53,6 @@ namespace VEPROMS.CSLA.Library //Update(); } } - //public partial class AnnotationTypeAnnotations //{ // public static int GetAnnotationID() diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Annotation.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Annotation.cs index 39eb6630..65171f2f 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Annotation.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Annotation.cs @@ -47,20 +47,24 @@ namespace VEPROMS.CSLA.Library foreach (Annotation tmp in _RefreshAnnotations) { AnnotationInfo.Refresh(tmp); - if(tmp._MyAnnotationType != null) AnnotationTypeInfo.Refresh(tmp._MyAnnotationType); - if(tmp._MyItem != null) ItemInfo.Refresh(tmp._MyItem); + if (tmp._MyAnnotationType != null) AnnotationTypeInfo.Refresh(tmp._MyAnnotationType); + if (tmp._MyItem != null) ItemInfo.Refresh(tmp._MyItem); } } #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (Annotation tmp in _AllList) { - _AllByPrimaryKey[tmp.AnnotationID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.AnnotationID.ToString())) + { + _AllByPrimaryKey[tmp.AnnotationID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.AnnotationID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (Annotation tmp in remove) @@ -70,7 +74,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = annotationID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -92,7 +96,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("AnnotationID",true); + CanReadProperty("AnnotationID", true); return _AnnotationID; } } @@ -102,7 +106,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemID",true); + CanReadProperty("ItemID", true); if (_MyItem != null) _ItemID = _MyItem.ItemID; return _ItemID; } @@ -113,14 +117,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItem",true); + CanReadProperty("MyItem", true); if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID); return _MyItem; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyItem",true); + CanWriteProperty("MyItem", true); if (_MyItem != value) { _MyItem = value; @@ -134,7 +138,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TypeID",true); + CanReadProperty("TypeID", true); if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID; return _TypeID; } @@ -145,14 +149,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyAnnotationType",true); + CanReadProperty("MyAnnotationType", true); if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationType.Get(_TypeID); return _MyAnnotationType; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyAnnotationType",true); + CanWriteProperty("MyAnnotationType", true); if (_MyAnnotationType != value) { _MyAnnotationType = value; @@ -166,13 +170,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RtfText",true); + CanReadProperty("RtfText", true); return _RtfText; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("RtfText",true); + CanWriteProperty("RtfText", true); if (value == null) value = string.Empty; if (_RtfText != value) { @@ -187,13 +191,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("SearchText",true); + CanReadProperty("SearchText", true); return _SearchText; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("SearchText",true); + CanWriteProperty("SearchText", true); if (value == null) value = string.Empty; if (_SearchText != value) { @@ -208,13 +212,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -229,13 +233,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -249,13 +253,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -267,11 +271,11 @@ namespace VEPROMS.CSLA.Library private byte[] _LastChanged = new byte[8];//timestamp 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 { - 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 /// @@ -294,23 +298,24 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; - if (_MyAnnotationType != null && (hasBrokenRules = _MyAnnotationType.HasBrokenRules) != null) return hasBrokenRules; + if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; + if (_MyAnnotationType != null && (hasBrokenRules = _MyAnnotationType.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -436,14 +441,25 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _AnnotationUnique = 0; + private int _MyAnnotationUnique; + public int MyAnnotationUnique + { + get { return _MyAnnotationUnique; } + } protected Annotation() {/* require use of factory methods */ + _MyAnnotationUnique = ++_AnnotationUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(AnnotationID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(AnnotationID.ToString())) return; + List 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() { @@ -529,7 +545,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(annotationID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -608,7 +624,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Annotation.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.ReadData", GetHashCode()); try { _AnnotationID = dr.GetInt32("AnnotationID"); @@ -624,14 +640,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Annotation.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -659,7 +675,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Annotation.DataPortal_Fetch", ex); } @@ -680,13 +696,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Annotation.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Annotation.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -695,8 +711,8 @@ namespace VEPROMS.CSLA.Library if (!this.IsDirty) return; try { - if(_MyAnnotationType != null) _MyAnnotationType.Update(); - if(_MyItem != null) _MyItem.Update(); + if (_MyAnnotationType != null) _MyAnnotationType.Update(); + if (_MyItem != null) _MyItem.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; using (SqlCommand cm = cn.CreateCommand()) { @@ -725,11 +741,11 @@ namespace VEPROMS.CSLA.Library } MarkOld(); // update child objects - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Annotation.SQLInsert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.SQLInsert", GetHashCode()); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Annotation.SQLInsert", ex); } @@ -737,7 +753,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Annotation.Add", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.Add", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -768,7 +784,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -776,7 +792,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Annotation.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -790,7 +806,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -799,11 +815,11 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { 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 { - if(_MyAnnotationType != null) _MyAnnotationType.Update(); - if(_MyItem != null) _MyItem.Update(); + if (_MyAnnotationType != null) _MyAnnotationType.Update(); + if (_MyItem != null) _MyItem.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; if (base.IsDirty) { @@ -836,7 +852,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -857,7 +873,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Annotation.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -886,7 +902,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -898,7 +914,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -914,7 +930,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Annotation.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Annotation.DataPortal_Delete", ex); } @@ -922,7 +938,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -937,7 +953,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -971,7 +987,7 @@ namespace VEPROMS.CSLA.Library } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -989,7 +1005,7 @@ namespace VEPROMS.CSLA.Library } 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); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationInfo.cs index 3a2ee624..dd491076 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (AnnotationInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.AnnotationID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.AnnotationID.ToString())) + { + _AllByPrimaryKey[tmp.AnnotationID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.AnnotationID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (AnnotationInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = annotationID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("AnnotationID",true); + CanReadProperty("AnnotationID", true); return _AnnotationID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemID",true); + CanReadProperty("ItemID", true); if (_MyItem != null) _ItemID = _MyItem.ItemID; return _ItemID; } @@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItem",true); + CanReadProperty("MyItem", true); if (_MyItem == null && _ItemID != 0) _MyItem = ItemInfo.Get(_ItemID); return _MyItem; } @@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TypeID",true); + CanReadProperty("TypeID", true); if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID; return _TypeID; } @@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyAnnotationType",true); + CanReadProperty("MyAnnotationType", true); if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationTypeInfo.Get(_TypeID); return _MyAnnotationType; } @@ -139,7 +143,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RtfText",true); + CanReadProperty("RtfText", true); return _RtfText; } } @@ -149,7 +153,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("SearchText",true); + CanReadProperty("SearchText", true); return _SearchText; } } @@ -159,7 +163,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } } @@ -169,7 +173,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -179,7 +183,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } } @@ -203,14 +207,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _AnnotationInfoUnique = 0; + private int _MyAnnotationInfoUnique; + public int MyAnnotationInfoUnique + { + get { return _MyAnnotationInfoUnique; } + } private AnnotationInfo() {/* require use of factory methods */ + _MyAnnotationInfoUnique = ++_AnnotationInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(AnnotationID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(AnnotationID.ToString())) return; + List 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() { @@ -218,9 +233,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(Annotation tmp) { - AnnotationInfo tmpInfo = GetExistingByPrimaryKey(tmp.AnnotationID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.AnnotationID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (AnnotationInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(Annotation tmp) { @@ -228,16 +245,16 @@ namespace VEPROMS.CSLA.Library { MyItem.RefreshItemAnnotations(); // Update List for old 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) { MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old 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; _SearchText = tmp.SearchText; _Config = tmp.Config; @@ -250,9 +267,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(AnnotationTypeAnnotation tmp) { - AnnotationInfo tmpInfo = GetExistingByPrimaryKey(tmp.AnnotationID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.AnnotationID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (AnnotationInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(AnnotationTypeAnnotation tmp) { @@ -260,9 +279,9 @@ namespace VEPROMS.CSLA.Library { MyItem.RefreshItemAnnotations(); // Update List for old 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; _SearchText = tmp.SearchText; _Config = tmp.Config; @@ -275,9 +294,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(ItemAnnotation tmp) { - AnnotationInfo tmpInfo = GetExistingByPrimaryKey(tmp.AnnotationID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.AnnotationID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (AnnotationInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(ItemAnnotation tmp) { @@ -285,9 +306,9 @@ namespace VEPROMS.CSLA.Library { MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old 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; _SearchText = tmp.SearchText; _Config = tmp.Config; @@ -308,7 +329,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(annotationID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -322,14 +343,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { ReadData(dr); } 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); } } @@ -346,7 +368,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.ReadData", GetHashCode()); try { _AnnotationID = dr.GetInt32("AnnotationID"); @@ -360,14 +382,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("AnnotationInfo.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -395,7 +417,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("AnnotationInfo.DataPortal_Fetch", ex); } @@ -405,7 +427,7 @@ namespace VEPROMS.CSLA.Library #region extension AnnotationInfoExtension _AnnotationInfoExtension = new AnnotationInfoExtension(); [Serializable()] - partial class AnnotationInfoExtension : extensionBase {} + partial class AnnotationInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationInfoList.cs index cb5df860..07442abd 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationInfoList.cs @@ -124,7 +124,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -144,7 +144,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -166,7 +166,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(TypeIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationInfoList.DataPortal_FetchTypeID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfoList.DataPortal_FetchTypeID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -187,7 +187,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -209,7 +209,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ItemIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationInfoList.DataPortal_FetchItemID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfoList.DataPortal_FetchItemID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -230,7 +230,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -291,8 +291,8 @@ namespace VEPROMS.CSLA.Library /// public partial class AnnotationInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private AnnotationInfo Item { get { return (AnnotationInfo) _Item;} } - public AnnotationInfoListPropertyDescriptor(AnnotationInfoList collection, int index):base(collection, index){;} + private AnnotationInfo Item { get { return (AnnotationInfo)_Item; } } + public AnnotationInfoListPropertyDescriptor(AnnotationInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -303,7 +303,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is AnnotationInfoList) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationType.cs b/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationType.cs index 0057ed56..a0758782 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationType.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationType.cs @@ -41,7 +41,7 @@ namespace VEPROMS.CSLA.Library { 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 #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); - private static Dictionary _AllByName = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); + private static Dictionary> _AllByName = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (AnnotationType tmp in _AllList) { - _AllByPrimaryKey[tmp.TypeID.ToString()]=tmp; // Primary Key - _AllByName[tmp.Name.ToString()] = tmp; // Unique Index + if (!_AllByPrimaryKey.ContainsKey(tmp.TypeID.ToString())) + { + _AllByPrimaryKey[tmp.TypeID.ToString()] = new List(); // Add new list for PrimaryKey + _AllByName[tmp.Name.ToString()] = new List(); // 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); } foreach (AnnotationType tmp in remove) @@ -83,14 +88,14 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = typeID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } public static AnnotationType GetExistingByName(string name) { ConvertListToDictionary(); string key = name.ToString(); - if (_AllByName.ContainsKey(key)) return _AllByName[key]; + if (_AllByName.ContainsKey(key)) return _AllByName[key][0]; return null; } #endregion @@ -112,7 +117,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TypeID",true); + CanReadProperty("TypeID", true); return _TypeID; } } @@ -122,13 +127,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Name",true); + CanReadProperty("Name", true); return _Name; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Name",true); + CanWriteProperty("Name", true); if (value == null) value = string.Empty; if (_Name != value) { @@ -143,13 +148,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -164,13 +169,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -184,13 +189,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -209,7 +214,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("AnnotationTypeAnnotationCount",true); + CanReadProperty("AnnotationTypeAnnotationCount", true); return _AnnotationTypeAnnotationCount; } } @@ -223,21 +228,21 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("AnnotationTypeAnnotations",true); - if(_AnnotationTypeAnnotationCount > 0 && _AnnotationTypeAnnotations == null) + CanReadProperty("AnnotationTypeAnnotations", true); + if (_AnnotationTypeAnnotationCount > 0 && _AnnotationTypeAnnotations == null) _AnnotationTypeAnnotations = AnnotationTypeAnnotations.GetByTypeID(TypeID); - else if(_AnnotationTypeAnnotations == null) + else if (_AnnotationTypeAnnotations == null) _AnnotationTypeAnnotations = AnnotationTypeAnnotations.New(); return _AnnotationTypeAnnotations; } } 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 { - 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 /// @@ -260,22 +265,23 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_AnnotationTypeAnnotations != null && (hasBrokenRules = _AnnotationTypeAnnotations.HasBrokenRules) != null) return hasBrokenRules; + if (_AnnotationTypeAnnotations != null && (hasBrokenRules = _AnnotationTypeAnnotations.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -387,15 +393,29 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _AnnotationTypeUnique = 0; + private int _MyAnnotationTypeUnique; + public int MyAnnotationTypeUnique + { + get { return _MyAnnotationTypeUnique; } + } protected AnnotationType() {/* require use of factory methods */ + _MyAnnotationTypeUnique = ++_AnnotationTypeUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(TypeID.ToString()); - _AllByName.Remove(Name.ToString()); + if (!_AllByPrimaryKey.ContainsKey(TypeID.ToString())) return; + List 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() { @@ -474,7 +494,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(typeID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -493,8 +513,8 @@ namespace VEPROMS.CSLA.Library AnnotationType tmp = GetExistingByName(name); if (tmp == null) { - tmp=DataPortal.Fetch(new NameCriteria(name)); - _AllList.Add(tmp); + tmp = DataPortal.Fetch(new NameCriteria(name)); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -584,7 +604,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationType.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.ReadData", GetHashCode()); try { _TypeID = dr.GetInt32("TypeID"); @@ -598,14 +618,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("AnnotationType.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -636,14 +656,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("AnnotationType.DataPortal_Fetch", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -671,7 +691,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("AnnotationType.DataPortal_Fetch", ex); } @@ -692,13 +712,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("AnnotationType.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -733,11 +753,11 @@ namespace VEPROMS.CSLA.Library MarkOld(); // update child objects 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) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("AnnotationType.SQLInsert", ex); } @@ -745,7 +765,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -773,7 +793,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -781,7 +801,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -795,7 +815,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -804,7 +824,7 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { 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 { SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; @@ -837,7 +857,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -859,7 +879,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -885,7 +905,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -897,7 +917,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -913,7 +933,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationType.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("AnnotationType.DataPortal_Delete", ex); } @@ -921,7 +941,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -936,7 +956,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -970,7 +990,7 @@ namespace VEPROMS.CSLA.Library } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -988,7 +1008,7 @@ namespace VEPROMS.CSLA.Library } 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); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationTypeAnnotation.cs b/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationTypeAnnotation.cs index 605e853a..29e65140 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationTypeAnnotation.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationTypeAnnotation.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("AnnotationID",true); + CanReadProperty("AnnotationID", true); if (_MyAnnotation != null) _AnnotationID = _MyAnnotation.AnnotationID; return _AnnotationID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyAnnotation",true); + CanReadProperty("MyAnnotation", true); if (_MyAnnotation == null && _AnnotationID != 0) _MyAnnotation = Annotation.Get(_AnnotationID); return _MyAnnotation; } @@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemID",true); + CanReadProperty("ItemID", true); if (_MyItem != null) _ItemID = _MyItem.ItemID; return _ItemID; } @@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItem",true); + CanReadProperty("MyItem", true); if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID); return _MyItem; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyItem",true); + CanWriteProperty("MyItem", true); if (_MyItem != value) { _MyItem = value; @@ -97,13 +97,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RtfText",true); + CanReadProperty("RtfText", true); return _RtfText; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("RtfText",true); + CanWriteProperty("RtfText", true); if (value == null) value = string.Empty; if (_RtfText != value) { @@ -118,13 +118,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("SearchText",true); + CanReadProperty("SearchText", true); return _SearchText; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("SearchText",true); + CanWriteProperty("SearchText", true); if (value == null) value = string.Empty; if (_SearchText != value) { @@ -139,13 +139,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -160,13 +160,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -180,13 +180,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -202,7 +202,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Item_PreviousID",true); + CanReadProperty("Item_PreviousID", true); return _Item_PreviousID; } } @@ -212,7 +212,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Item_ContentID",true); + CanReadProperty("Item_ContentID", true); return _Item_ContentID; } } @@ -222,7 +222,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Item_DTS",true); + CanReadProperty("Item_DTS", true); return _Item_DTS; } } @@ -232,7 +232,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Item_UserID",true); + CanReadProperty("Item_UserID", true); return _Item_UserID; } } @@ -265,23 +265,23 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -404,7 +404,7 @@ namespace VEPROMS.CSLA.Library // TODO: Add any initialization & defaults _DTS = _AnnotationTypeAnnotationExtension.DefaultDTS; _UserID = _AnnotationTypeAnnotationExtension.DefaultUserID; - _MyItem = myItem; + _MyItem = myItem; ValidationRules.CheckRules(); } internal AnnotationTypeAnnotation(SafeDataReader dr) @@ -416,7 +416,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationTypeAnnotation.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeAnnotation.FetchDR", GetHashCode()); try { _AnnotationID = dr.GetInt32("AnnotationID"); @@ -434,7 +434,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationTypeAnnotations.cs b/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationTypeAnnotations.cs index e6b7c49a..b05ade0f 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationTypeAnnotations.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationTypeAnnotations.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public AnnotationTypeAnnotation Add(Item myItem) // One to Many { - AnnotationTypeAnnotation annotation = AnnotationTypeAnnotation.New(myItem); - this.Add(annotation); - return annotation; + AnnotationTypeAnnotation annotation = AnnotationTypeAnnotation.New(myItem); + this.Add(annotation); + return annotation; } public void Remove(Annotation myAnnotation) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(AnnotationTypeAnnotation annotationTypeAnnotation in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (AnnotationTypeAnnotation annotationTypeAnnotation in this) if ((hasBrokenRules = annotationTypeAnnotation.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(TypeIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationTypeAnnotations.DataPortal_FetchTypeID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeAnnotations.DataPortal_FetchTypeID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class AnnotationTypeAnnotationsPropertyDescriptor : vlnListPropertyDescriptor { - private AnnotationTypeAnnotation Item { get { return (AnnotationTypeAnnotation) _Item;} } - public AnnotationTypeAnnotationsPropertyDescriptor(AnnotationTypeAnnotations collection, int index):base(collection, index){;} + private AnnotationTypeAnnotation Item { get { return (AnnotationTypeAnnotation)_Item; } } + public AnnotationTypeAnnotationsPropertyDescriptor(AnnotationTypeAnnotations collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is AnnotationTypeAnnotations) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationTypeInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationTypeInfo.cs index 48d709ba..91a95fef 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationTypeInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationTypeInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (AnnotationTypeInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.TypeID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.TypeID.ToString())) + { + _AllByPrimaryKey[tmp.TypeID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.TypeID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (AnnotationTypeInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = typeID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TypeID",true); + CanReadProperty("TypeID", true); return _TypeID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Name",true); + CanReadProperty("Name", true); return _Name; } } @@ -105,7 +109,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } } @@ -115,7 +119,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -125,7 +129,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } } @@ -138,7 +142,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("AnnotationTypeAnnotationCount",true); + CanReadProperty("AnnotationTypeAnnotationCount", true); return _AnnotationTypeAnnotationCount; } } @@ -149,7 +153,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("AnnotationTypeAnnotations",true); + CanReadProperty("AnnotationTypeAnnotations", true); if (_AnnotationTypeAnnotationCount < 0 || (_AnnotationTypeAnnotationCount > 0 && _AnnotationTypeAnnotations == null)) _AnnotationTypeAnnotations = AnnotationInfoList.GetByTypeID(_TypeID); if (_AnnotationTypeAnnotationCount < 0) @@ -159,7 +163,10 @@ namespace VEPROMS.CSLA.Library } 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 /// @@ -181,14 +188,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _AnnotationTypeInfoUnique = 0; + private int _MyAnnotationTypeInfoUnique; + public int MyAnnotationTypeInfoUnique + { + get { return _MyAnnotationTypeInfoUnique; } + } private AnnotationTypeInfo() {/* require use of factory methods */ + _MyAnnotationTypeInfoUnique = ++_AnnotationTypeInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(TypeID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(TypeID.ToString())) return; + List 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() { @@ -196,9 +214,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(AnnotationType tmp) { - AnnotationTypeInfo tmpInfo = GetExistingByPrimaryKey(tmp.TypeID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.TypeID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (AnnotationTypeInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(AnnotationType tmp) { @@ -219,7 +239,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(typeID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -233,14 +253,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { ReadData(dr); } 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); } } @@ -257,7 +278,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationTypeInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.ReadData", GetHashCode()); try { _TypeID = dr.GetInt32("TypeID"); @@ -269,14 +290,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationTypeInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("AnnotationTypeInfo.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -304,7 +325,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationTypeInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("AnnotationTypeInfo.DataPortal_Fetch", ex); } @@ -314,7 +335,7 @@ namespace VEPROMS.CSLA.Library #region extension AnnotationTypeInfoExtension _AnnotationTypeInfoExtension = new AnnotationTypeInfoExtension(); [Serializable()] - partial class AnnotationTypeInfoExtension : extensionBase {} + partial class AnnotationTypeInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationTypeInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationTypeInfoList.cs index 13064575..7f04a375 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationTypeInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/AnnotationTypeInfoList.cs @@ -96,7 +96,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationTypeInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -116,7 +116,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -177,8 +177,8 @@ namespace VEPROMS.CSLA.Library /// public partial class AnnotationTypeInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private AnnotationTypeInfo Item { get { return (AnnotationTypeInfo) _Item;} } - public AnnotationTypeInfoListPropertyDescriptor(AnnotationTypeInfoList collection, int index):base(collection, index){;} + private AnnotationTypeInfo Item { get { return (AnnotationTypeInfo)_Item; } } + public AnnotationTypeInfoListPropertyDescriptor(AnnotationTypeInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -189,7 +189,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is AnnotationTypeInfoList) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Assignment.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Assignment.cs index 532a4d17..9edc3a58 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Assignment.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Assignment.cs @@ -47,21 +47,25 @@ namespace VEPROMS.CSLA.Library foreach (Assignment tmp in _RefreshAssignments) { AssignmentInfo.Refresh(tmp); - if(tmp._MyFolder != null) FolderInfo.Refresh(tmp._MyFolder); - if(tmp._MyGroup != null) GroupInfo.Refresh(tmp._MyGroup); - if(tmp._MyRole != null) RoleInfo.Refresh(tmp._MyRole); + if (tmp._MyFolder != null) FolderInfo.Refresh(tmp._MyFolder); + if (tmp._MyGroup != null) GroupInfo.Refresh(tmp._MyGroup); + if (tmp._MyRole != null) RoleInfo.Refresh(tmp._MyRole); } } #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (Assignment tmp in _AllList) { - _AllByPrimaryKey[tmp.AID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.AID.ToString())) + { + _AllByPrimaryKey[tmp.AID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.AID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (Assignment tmp in remove) @@ -71,7 +75,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = aid.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -93,7 +97,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("AID",true); + CanReadProperty("AID", true); return _AID; } } @@ -103,7 +107,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GID",true); + CanReadProperty("GID", true); if (_MyGroup != null) _GID = _MyGroup.GID; return _GID; } @@ -114,14 +118,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyGroup",true); + CanReadProperty("MyGroup", true); if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID); return _MyGroup; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyGroup",true); + CanWriteProperty("MyGroup", true); if (_MyGroup != value) { _MyGroup = value; @@ -135,7 +139,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RID",true); + CanReadProperty("RID", true); if (_MyRole != null) _RID = _MyRole.RID; return _RID; } @@ -146,14 +150,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyRole",true); + CanReadProperty("MyRole", true); if (_MyRole == null && _RID != 0) _MyRole = Role.Get(_RID); return _MyRole; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyRole",true); + CanWriteProperty("MyRole", true); if (_MyRole != value) { _MyRole = value; @@ -167,7 +171,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderID",true); + CanReadProperty("FolderID", true); if (_MyFolder != null) _FolderID = _MyFolder.FolderID; return _FolderID; } @@ -178,14 +182,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFolder",true); + CanReadProperty("MyFolder", true); if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID); return _MyFolder; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyFolder",true); + CanWriteProperty("MyFolder", true); if (_MyFolder != value) { _MyFolder = value; @@ -199,13 +203,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("StartDate",true); + CanReadProperty("StartDate", true); return _StartDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("StartDate",true); + CanWriteProperty("StartDate", true); if (value == null) value = string.Empty; _StartDate = value; try @@ -229,13 +233,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("EndDate",true); + CanReadProperty("EndDate", true); return _EndDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("EndDate",true); + CanWriteProperty("EndDate", true); if (value == null) value = string.Empty; _EndDate = value; try @@ -259,13 +263,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -279,13 +283,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UsrID",true); + CanWriteProperty("UsrID", true); if (value == null) value = string.Empty; if (_UsrID != value) { @@ -297,11 +301,11 @@ namespace VEPROMS.CSLA.Library private byte[] _LastChanged = new byte[8];//timestamp 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 { - 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 /// @@ -324,24 +328,25 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules; - if (_MyRole != null && (hasBrokenRules = _MyRole.HasBrokenRules) != null) return hasBrokenRules; - if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; + if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules; + if (_MyRole != null && (hasBrokenRules = _MyRole.HasBrokenRules) != null) return hasBrokenRules; + if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -498,14 +503,25 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _AssignmentUnique = 0; + private int _MyAssignmentUnique; + public int MyAssignmentUnique + { + get { return _MyAssignmentUnique; } + } protected Assignment() {/* require use of factory methods */ + _MyAssignmentUnique = ++_AssignmentUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(AID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(AID.ToString())) return; + List 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() { @@ -591,7 +607,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(aid)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -671,7 +687,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Assignment.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.ReadData", GetHashCode()); try { _AID = dr.GetInt32("AID"); @@ -687,14 +703,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Assignment.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -722,7 +738,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Assignment.DataPortal_Fetch", ex); } @@ -743,13 +759,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Assignment.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Assignment.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -758,9 +774,9 @@ namespace VEPROMS.CSLA.Library if (!this.IsDirty) return; try { - if(_MyFolder != null) _MyFolder.Update(); - if(_MyGroup != null) _MyGroup.Update(); - if(_MyRole != null) _MyRole.Update(); + if (_MyFolder != null) _MyFolder.Update(); + if (_MyGroup != null) _MyGroup.Update(); + if (_MyRole != null) _MyRole.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; using (SqlCommand cm = cn.CreateCommand()) { @@ -789,11 +805,11 @@ namespace VEPROMS.CSLA.Library } MarkOld(); // update child objects - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Assignment.SQLInsert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.SQLInsert", GetHashCode()); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Assignment.SQLInsert", ex); } @@ -801,7 +817,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Assignment.Add", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.Add", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -832,7 +848,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -840,7 +856,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Assignment.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -854,7 +870,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -863,12 +879,12 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { 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 { - if(_MyFolder != null) _MyFolder.Update(); - if(_MyGroup != null) _MyGroup.Update(); - if(_MyRole != null) _MyRole.Update(); + if (_MyFolder != null) _MyFolder.Update(); + if (_MyGroup != null) _MyGroup.Update(); + if (_MyRole != null) _MyRole.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; if (base.IsDirty) { @@ -901,7 +917,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -922,7 +938,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Assignment.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -951,7 +967,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -963,7 +979,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -979,7 +995,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Assignment.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Assignment.DataPortal_Delete", ex); } @@ -987,7 +1003,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -1002,7 +1018,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -1036,7 +1052,7 @@ namespace VEPROMS.CSLA.Library } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1054,7 +1070,7 @@ namespace VEPROMS.CSLA.Library } 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); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/AssignmentInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/AssignmentInfo.cs index 9f7b4e06..a9606ccd 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/AssignmentInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/AssignmentInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (AssignmentInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.AID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.AID.ToString())) + { + _AllByPrimaryKey[tmp.AID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.AID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (AssignmentInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = aid.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("AID",true); + CanReadProperty("AID", true); return _AID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GID",true); + CanReadProperty("GID", true); if (_MyGroup != null) _GID = _MyGroup.GID; return _GID; } @@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyGroup",true); + CanReadProperty("MyGroup", true); if (_MyGroup == null && _GID != 0) _MyGroup = GroupInfo.Get(_GID); return _MyGroup; } @@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RID",true); + CanReadProperty("RID", true); if (_MyRole != null) _RID = _MyRole.RID; return _RID; } @@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyRole",true); + CanReadProperty("MyRole", true); if (_MyRole == null && _RID != 0) _MyRole = RoleInfo.Get(_RID); return _MyRole; } @@ -139,7 +143,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderID",true); + CanReadProperty("FolderID", true); if (_MyFolder != null) _FolderID = _MyFolder.FolderID; return _FolderID; } @@ -150,7 +154,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFolder",true); + CanReadProperty("MyFolder", true); if (_MyFolder == null && _FolderID != 0) _MyFolder = FolderInfo.Get(_FolderID); return _MyFolder; } @@ -161,7 +165,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("StartDate",true); + CanReadProperty("StartDate", true); return _StartDate; } } @@ -171,7 +175,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("EndDate",true); + CanReadProperty("EndDate", true); return _EndDate; } } @@ -181,7 +185,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -191,7 +195,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } } @@ -215,14 +219,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _AssignmentInfoUnique = 0; + private int _MyAssignmentInfoUnique; + public int MyAssignmentInfoUnique + { + get { return _MyAssignmentInfoUnique; } + } private AssignmentInfo() {/* require use of factory methods */ + _MyAssignmentInfoUnique = ++_AssignmentInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(AID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(AID.ToString())) return; + List 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() { @@ -230,9 +245,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(Assignment tmp) { - AssignmentInfo tmpInfo = GetExistingByPrimaryKey(tmp.AID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.AID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(Assignment tmp) { @@ -240,23 +257,23 @@ namespace VEPROMS.CSLA.Library { MyGroup.RefreshGroupAssignments(); // Update List for old 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) { MyRole.RefreshRoleAssignments(); // Update List for old 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) { MyFolder.RefreshFolderAssignments(); // Update List for old 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; _EndDate = tmp.EndDate; _DTS = tmp.DTS; @@ -269,9 +286,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(FolderAssignment tmp) { - AssignmentInfo tmpInfo = GetExistingByPrimaryKey(tmp.AID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.AID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(FolderAssignment tmp) { @@ -279,16 +298,16 @@ namespace VEPROMS.CSLA.Library { MyGroup.RefreshGroupAssignments(); // Update List for old 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) { MyRole.RefreshRoleAssignments(); // Update List for old 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; _EndDate = tmp.EndDate; _DTS = tmp.DTS; @@ -301,9 +320,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(GroupAssignment tmp) { - AssignmentInfo tmpInfo = GetExistingByPrimaryKey(tmp.AID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.AID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(GroupAssignment tmp) { @@ -311,16 +332,16 @@ namespace VEPROMS.CSLA.Library { MyRole.RefreshRoleAssignments(); // Update List for old 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) { MyFolder.RefreshFolderAssignments(); // Update List for old 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; _EndDate = tmp.EndDate; _DTS = tmp.DTS; @@ -333,9 +354,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(RoleAssignment tmp) { - AssignmentInfo tmpInfo = GetExistingByPrimaryKey(tmp.AID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.AID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (AssignmentInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(RoleAssignment tmp) { @@ -343,16 +366,16 @@ namespace VEPROMS.CSLA.Library { MyGroup.RefreshGroupAssignments(); // Update List for old 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) { MyFolder.RefreshFolderAssignments(); // Update List for old 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; _EndDate = tmp.EndDate; _DTS = tmp.DTS; @@ -373,7 +396,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(aid)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -387,14 +410,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { ReadData(dr); } 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); } } @@ -411,7 +435,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfo.ReadData", GetHashCode()); try { _AID = dr.GetInt32("AID"); @@ -425,14 +449,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("AssignmentInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("AssignmentInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("AssignmentInfo.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -460,7 +484,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("AssignmentInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("AssignmentInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("AssignmentInfo.DataPortal_Fetch", ex); } @@ -470,7 +494,7 @@ namespace VEPROMS.CSLA.Library #region extension AssignmentInfoExtension _AssignmentInfoExtension = new AssignmentInfoExtension(); [Serializable()] - partial class AssignmentInfoExtension : extensionBase {} + partial class AssignmentInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/AssignmentInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/AssignmentInfoList.cs index 60f2eb8c..ff4a630a 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/AssignmentInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/AssignmentInfoList.cs @@ -138,7 +138,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -158,7 +158,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -180,7 +180,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(FolderIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfoList.DataPortal_FetchFolderID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfoList.DataPortal_FetchFolderID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -201,7 +201,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -223,7 +223,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(GIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfoList.DataPortal_FetchGID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfoList.DataPortal_FetchGID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -244,7 +244,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -266,7 +266,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(RIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfoList.DataPortal_FetchRID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssignmentInfoList.DataPortal_FetchRID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -287,7 +287,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -348,8 +348,8 @@ namespace VEPROMS.CSLA.Library /// public partial class AssignmentInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private AssignmentInfo Item { get { return (AssignmentInfo) _Item;} } - public AssignmentInfoListPropertyDescriptor(AssignmentInfoList collection, int index):base(collection, index){;} + private AssignmentInfo Item { get { return (AssignmentInfo)_Item; } } + public AssignmentInfoListPropertyDescriptor(AssignmentInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -360,7 +360,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is AssignmentInfoList) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ChildFolders.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ChildFolders.cs index 93d3825e..4fe873d8 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ChildFolders.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ChildFolders.cs @@ -113,8 +113,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(Folder folder in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (Folder folder in this) if ((hasBrokenRules = folder.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -123,8 +123,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ParentIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ChildFolders.DataPortal_FetchParentID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ChildFolders.DataPortal_FetchParentID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -203,7 +203,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -288,8 +288,8 @@ namespace VEPROMS.CSLA.Library /// public partial class ChildFoldersPropertyDescriptor : vlnListPropertyDescriptor { - private Folder Item { get { return (Folder) _Item;} } - public ChildFoldersPropertyDescriptor(ChildFolders collection, int index):base(collection, index){;} + private Folder Item { get { return (Folder)_Item; } } + public ChildFoldersPropertyDescriptor(ChildFolders collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -300,7 +300,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is ChildFolders) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ChildFormats.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ChildFormats.cs index 2d3a2eac..3969d506 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ChildFormats.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ChildFormats.cs @@ -113,8 +113,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(Format format in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (Format format in this) if ((hasBrokenRules = format.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -123,8 +123,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ParentIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ChildFormats.DataPortal_FetchParentID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ChildFormats.DataPortal_FetchParentID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -203,7 +203,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -288,8 +288,8 @@ namespace VEPROMS.CSLA.Library /// public partial class ChildFormatsPropertyDescriptor : vlnListPropertyDescriptor { - private Format Item { get { return (Format) _Item;} } - public ChildFormatsPropertyDescriptor(ChildFormats collection, int index):base(collection, index){;} + private Format Item { get { return (Format)_Item; } } + public ChildFormatsPropertyDescriptor(ChildFormats collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -300,7 +300,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is ChildFormats) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Connection.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Connection.cs index 780de51b..e8104cf7 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Connection.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Connection.cs @@ -41,7 +41,7 @@ namespace VEPROMS.CSLA.Library { 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 #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); - private static Dictionary _AllByName = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); + private static Dictionary> _AllByName = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (Connection tmp in _AllList) { - _AllByPrimaryKey[tmp.DBID.ToString()]=tmp; // Primary Key - _AllByName[tmp.Name.ToString()] = tmp; // Unique Index + if (!_AllByPrimaryKey.ContainsKey(tmp.DBID.ToString())) + { + _AllByPrimaryKey[tmp.DBID.ToString()] = new List(); // Add new list for PrimaryKey + _AllByName[tmp.Name.ToString()] = new List(); // 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); } foreach (Connection tmp in remove) @@ -83,14 +88,14 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = dbid.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } public static Connection GetExistingByName(string name) { ConvertListToDictionary(); string key = name.ToString(); - if (_AllByName.ContainsKey(key)) return _AllByName[key]; + if (_AllByName.ContainsKey(key)) return _AllByName[key][0]; return null; } #endregion @@ -112,7 +117,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DBID",true); + CanReadProperty("DBID", true); return _DBID; } } @@ -122,13 +127,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Name",true); + CanReadProperty("Name", true); return _Name; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Name",true); + CanWriteProperty("Name", true); if (value == null) value = string.Empty; if (_Name != value) { @@ -143,13 +148,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Title",true); + CanReadProperty("Title", true); return _Title; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Title",true); + CanWriteProperty("Title", true); if (value == null) value = string.Empty; if (_Title != value) { @@ -164,13 +169,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ConnectionString",true); + CanReadProperty("ConnectionString", true); return _ConnectionString; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("ConnectionString",true); + CanWriteProperty("ConnectionString", true); if (value == null) value = string.Empty; if (_ConnectionString != value) { @@ -188,13 +193,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ServerType",true); + CanReadProperty("ServerType", true); return _ServerType; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("ServerType",true); + CanWriteProperty("ServerType", true); if (_ServerType != value) { _ServerType = value; @@ -208,13 +213,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -229,13 +234,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -249,13 +254,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UsrID",true); + CanWriteProperty("UsrID", true); if (value == null) value = string.Empty; if (_UsrID != value) { @@ -274,7 +279,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ConnectionFolderCount",true); + CanReadProperty("ConnectionFolderCount", true); return _ConnectionFolderCount; } } @@ -288,21 +293,21 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ConnectionFolders",true); - if(_ConnectionFolderCount > 0 && _ConnectionFolders == null) + CanReadProperty("ConnectionFolders", true); + if (_ConnectionFolderCount > 0 && _ConnectionFolders == null) _ConnectionFolders = ConnectionFolders.GetByDBID(DBID); - else if(_ConnectionFolders == null) + else if (_ConnectionFolders == null) _ConnectionFolders = ConnectionFolders.New(); return _ConnectionFolders; } } 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 { - 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 /// @@ -325,22 +330,23 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_ConnectionFolders != null && (hasBrokenRules = _ConnectionFolders.HasBrokenRules) != null) return hasBrokenRules; + if (_ConnectionFolders != null && (hasBrokenRules = _ConnectionFolders.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -462,15 +468,29 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _ConnectionUnique = 0; + private int _MyConnectionUnique; + public int MyConnectionUnique + { + get { return _MyConnectionUnique; } + } protected Connection() {/* require use of factory methods */ + _MyConnectionUnique = ++_ConnectionUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(DBID.ToString()); - _AllByName.Remove(Name.ToString()); + if (!_AllByPrimaryKey.ContainsKey(DBID.ToString())) return; + List 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() { @@ -548,7 +568,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(dbid)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -567,8 +587,8 @@ namespace VEPROMS.CSLA.Library Connection tmp = GetExistingByName(name); if (tmp == null) { - tmp=DataPortal.Fetch(new NameCriteria(name)); - _AllList.Add(tmp); + tmp = DataPortal.Fetch(new NameCriteria(name)); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -659,7 +679,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Connection.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Connection.ReadData", GetHashCode()); try { _DBID = dr.GetInt32("DBID"); @@ -676,14 +696,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Connection.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -714,14 +734,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Connection.DataPortal_Fetch", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -749,7 +769,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Connection.DataPortal_Fetch", ex); } @@ -770,13 +790,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Connection.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Connection.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Connection.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -814,11 +834,11 @@ namespace VEPROMS.CSLA.Library MarkOld(); // update child objects 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) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Connection.SQLInsert", ex); } @@ -826,7 +846,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Connection.Add", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Connection.Add", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -857,7 +877,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -865,7 +885,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Connection.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Connection.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -879,7 +899,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -888,7 +908,7 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { 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 { SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; @@ -924,7 +944,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -946,7 +966,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Connection.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Connection.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -975,7 +995,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -987,7 +1007,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1003,7 +1023,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Connection.DataPortal_Delete", ex); } @@ -1011,7 +1031,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -1026,7 +1046,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -1060,7 +1080,7 @@ namespace VEPROMS.CSLA.Library } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1078,7 +1098,7 @@ namespace VEPROMS.CSLA.Library } 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); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ConnectionFolder.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ConnectionFolder.cs index 621188a2..e77d36a0 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ConnectionFolder.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ConnectionFolder.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderID",true); + CanReadProperty("FolderID", true); if (_MyFolder != null) _FolderID = _MyFolder.FolderID; return _FolderID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFolder",true); + CanReadProperty("MyFolder", true); if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID); return _MyFolder; } @@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ParentID",true); + CanReadProperty("ParentID", true); if (_MyParent != null) _ParentID = _MyParent.FolderID; return _ParentID; } @@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyParent",true); + CanReadProperty("MyParent", true); if (_MyParent == null && _ParentID != _FolderID) _MyParent = Folder.Get(_ParentID); return _MyParent; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyParent",true); + CanWriteProperty("MyParent", true); if (_MyParent != value) { _MyParent = value; @@ -97,13 +97,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Name",true); + CanReadProperty("Name", true); return _Name; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Name",true); + CanWriteProperty("Name", true); if (value == null) value = string.Empty; if (_Name != value) { @@ -118,13 +118,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Title",true); + CanReadProperty("Title", true); return _Title; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Title",true); + CanWriteProperty("Title", true); if (value == null) value = string.Empty; if (_Title != value) { @@ -139,13 +139,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ShortName",true); + CanReadProperty("ShortName", true); return _ShortName; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("ShortName",true); + CanWriteProperty("ShortName", true); if (value == null) value = string.Empty; if (_ShortName != value) { @@ -160,7 +160,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatID",true); + CanReadProperty("FormatID", true); if (_MyFormat != null) _FormatID = _MyFormat.FormatID; return _FormatID; } @@ -171,18 +171,18 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFormat",true); + CanReadProperty("MyFormat", true); if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID); return _MyFormat; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyFormat",true); + CanWriteProperty("MyFormat", true); if (_MyFormat != value) { _MyFormat = value; - _FormatID = (value == null ? null : (int?) value.FormatID); + _FormatID = (value == null ? null : (int?)value.FormatID); PropertyHasChanged(); } } @@ -193,13 +193,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -214,13 +214,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -234,13 +234,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UsrID",true); + CanWriteProperty("UsrID", true); if (value == null) value = string.Empty; if (_UsrID != value) { @@ -279,24 +279,24 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; - if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; + if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -432,9 +432,9 @@ namespace VEPROMS.CSLA.Library _ParentID = _ConnectionFolderExtension.DefaultParentID; _DTS = _ConnectionFolderExtension.DefaultDTS; _UsrID = _ConnectionFolderExtension.DefaultUsrID; - _MyParent = myParent; - _Name = name; - _ShortName = shortName; + _MyParent = myParent; + _Name = name; + _ShortName = shortName; ValidationRules.CheckRules(); } internal ConnectionFolder(SafeDataReader dr) @@ -446,7 +446,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ConnectionFolder.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionFolder.FetchDR", GetHashCode()); try { _FolderID = dr.GetInt32("FolderID"); @@ -462,7 +462,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ConnectionFolders.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ConnectionFolders.cs index 49111446..722fbc92 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ConnectionFolders.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ConnectionFolders.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public ConnectionFolder Add(Folder myParent, string name, string shortName) // One to Many { - ConnectionFolder folder = ConnectionFolder.New(myParent, name, shortName); - this.Add(folder); - return folder; + ConnectionFolder folder = ConnectionFolder.New(myParent, name, shortName); + this.Add(folder); + return folder; } public void Remove(Folder myFolder) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(ConnectionFolder connectionFolder in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (ConnectionFolder connectionFolder in this) if ((hasBrokenRules = connectionFolder.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(DBIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ConnectionFolders.DataPortal_FetchDBID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionFolders.DataPortal_FetchDBID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class ConnectionFoldersPropertyDescriptor : vlnListPropertyDescriptor { - private ConnectionFolder Item { get { return (ConnectionFolder) _Item;} } - public ConnectionFoldersPropertyDescriptor(ConnectionFolders collection, int index):base(collection, index){;} + private ConnectionFolder Item { get { return (ConnectionFolder)_Item; } } + public ConnectionFoldersPropertyDescriptor(ConnectionFolders collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is ConnectionFolders) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ConnectionInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ConnectionInfo.cs index d2a89671..a32c53e3 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ConnectionInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ConnectionInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (ConnectionInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.DBID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.DBID.ToString())) + { + _AllByPrimaryKey[tmp.DBID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.DBID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (ConnectionInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = dbid.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DBID",true); + CanReadProperty("DBID", true); return _DBID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Name",true); + CanReadProperty("Name", true); return _Name; } } @@ -105,7 +109,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Title",true); + CanReadProperty("Title", true); return _Title; } } @@ -115,7 +119,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ConnectionString",true); + CanReadProperty("ConnectionString", true); return _ConnectionString; } } @@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ServerType",true); + CanReadProperty("ServerType", true); return _ServerType; } } @@ -138,7 +142,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } } @@ -148,7 +152,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -158,7 +162,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } } @@ -171,7 +175,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ConnectionFolderCount",true); + CanReadProperty("ConnectionFolderCount", true); return _ConnectionFolderCount; } } @@ -182,7 +186,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ConnectionFolders",true); + CanReadProperty("ConnectionFolders", true); if (_ConnectionFolderCount < 0 || (_ConnectionFolderCount > 0 && _ConnectionFolders == null)) _ConnectionFolders = FolderInfoList.GetByDBID(_DBID); if (_ConnectionFolderCount < 0) @@ -192,7 +196,10 @@ namespace VEPROMS.CSLA.Library } 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 /// @@ -214,14 +221,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _ConnectionInfoUnique = 0; + private int _MyConnectionInfoUnique; + public int MyConnectionInfoUnique + { + get { return _MyConnectionInfoUnique; } + } private ConnectionInfo() {/* require use of factory methods */ + _MyConnectionInfoUnique = ++_ConnectionInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(DBID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(DBID.ToString())) return; + List 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() { @@ -229,9 +247,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(Connection tmp) { - ConnectionInfo tmpInfo = GetExistingByPrimaryKey(tmp.DBID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.DBID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (ConnectionInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(Connection tmp) { @@ -255,7 +275,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(dbid)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -269,14 +289,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { ReadData(dr); } 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); } } @@ -293,7 +314,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ConnectionInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.ReadData", GetHashCode()); try { _DBID = dr.GetInt32("DBID"); @@ -308,14 +329,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ConnectionInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ConnectionInfo.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -343,7 +364,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ConnectionInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ConnectionInfo.DataPortal_Fetch", ex); } @@ -353,7 +374,7 @@ namespace VEPROMS.CSLA.Library #region extension ConnectionInfoExtension _ConnectionInfoExtension = new ConnectionInfoExtension(); [Serializable()] - partial class ConnectionInfoExtension : extensionBase {} + partial class ConnectionInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ConnectionInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ConnectionInfoList.cs index f3048ff3..31d27679 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ConnectionInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ConnectionInfoList.cs @@ -96,7 +96,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ConnectionInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -116,7 +116,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -177,8 +177,8 @@ namespace VEPROMS.CSLA.Library /// public partial class ConnectionInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private ConnectionInfo Item { get { return (ConnectionInfo) _Item;} } - public ConnectionInfoListPropertyDescriptor(ConnectionInfoList collection, int index):base(collection, index){;} + private ConnectionInfo Item { get { return (ConnectionInfo)_Item; } } + public ConnectionInfoListPropertyDescriptor(ConnectionInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -189,7 +189,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is ConnectionInfoList) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Content.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Content.cs index 50171743..7e50b3db 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Content.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Content.cs @@ -45,35 +45,35 @@ namespace VEPROMS.CSLA.Library { foreach (ContentDetail tmp in _ContentDetails) { - if(tmp.IsDirty)refreshContentDetails.Add(tmp); + if (tmp.IsDirty) refreshContentDetails.Add(tmp); } } if (_ContentItems != null && _ContentItems.IsDirty) { foreach (ContentItem tmp in _ContentItems) { - if(tmp.IsDirty)refreshContentItems.Add(tmp); + if (tmp.IsDirty) refreshContentItems.Add(tmp); } } if (_ContentParts != null && _ContentParts.IsDirty) { foreach (ContentPart tmp in _ContentParts) { - if(tmp.IsDirty)refreshContentParts.Add(tmp); + if (tmp.IsDirty) refreshContentParts.Add(tmp); } } if (_ContentRoUsages != null && _ContentRoUsages.IsDirty) { foreach (ContentRoUsage tmp in _ContentRoUsages) { - if(tmp.IsDirty)refreshContentRoUsages.Add(tmp); + if (tmp.IsDirty) refreshContentRoUsages.Add(tmp); } } if (_ContentTransitions != null && _ContentTransitions.IsDirty) { 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) { ContentInfo.Refresh(tmp); - if(tmp._MyFormat != null) FormatInfo.Refresh(tmp._MyFormat); + if (tmp._MyFormat != null) FormatInfo.Refresh(tmp._MyFormat); } foreach (ContentDetail tmp in _RefreshContentDetails) { @@ -118,13 +118,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (Content tmp in _AllList) { - _AllByPrimaryKey[tmp.ContentID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString())) + { + _AllByPrimaryKey[tmp.ContentID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (Content tmp in remove) @@ -134,7 +138,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = contentID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -156,7 +160,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentID",true); + CanReadProperty("ContentID", true); return _ContentID; } } @@ -166,13 +170,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Number",true); + CanReadProperty("Number", true); return _Number; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Number",true); + CanWriteProperty("Number", true); if (value == null) value = string.Empty; if (_Number != value) { @@ -187,13 +191,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Text",true); + CanReadProperty("Text", true); return _Text; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Text",true); + CanWriteProperty("Text", true); if (value == null) value = string.Empty; if (_Text != value) { @@ -211,13 +215,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Type",true); + CanReadProperty("Type", true); return _Type; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Type",true); + CanWriteProperty("Type", true); if (_Type != value) { _Type = value; @@ -231,7 +235,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatID",true); + CanReadProperty("FormatID", true); if (_MyFormat != null) _FormatID = _MyFormat.FormatID; return _FormatID; } @@ -242,18 +246,18 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFormat",true); + CanReadProperty("MyFormat", true); if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID); return _MyFormat; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyFormat",true); + CanWriteProperty("MyFormat", true); if (_MyFormat != value) { _MyFormat = value; - _FormatID = (value == null ? null : (int?) value.FormatID); + _FormatID = (value == null ? null : (int?)value.FormatID); PropertyHasChanged(); } } @@ -264,13 +268,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -285,13 +289,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -305,13 +309,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -330,7 +334,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentDetailCount",true); + CanReadProperty("ContentDetailCount", true); return _ContentDetailCount; } } @@ -344,10 +348,10 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentDetails",true); - if(_ContentDetailCount > 0 && _ContentDetails == null) + CanReadProperty("ContentDetails", true); + if (_ContentDetailCount > 0 && _ContentDetails == null) _ContentDetails = ContentDetails.GetByContentID(ContentID); - else if(_ContentDetails == null) + else if (_ContentDetails == null) _ContentDetails = ContentDetails.New(); return _ContentDetails; } @@ -361,7 +365,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentEntryCount",true); + CanReadProperty("ContentEntryCount", true); return _ContentEntryCount; } } @@ -375,8 +379,8 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyEntry",true); - if ( _MyEntry == null) _MyEntry = Entry.New(this); + CanReadProperty("MyEntry", true); + if (_MyEntry == null) _MyEntry = Entry.New(this); return _MyEntry; } } @@ -389,7 +393,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentItemCount",true); + CanReadProperty("ContentItemCount", true); return _ContentItemCount; } } @@ -403,10 +407,10 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentItems",true); - if(_ContentItemCount > 0 && _ContentItems == null) + CanReadProperty("ContentItems", true); + if (_ContentItemCount > 0 && _ContentItems == null) _ContentItems = ContentItems.GetByContentID(ContentID); - else if(_ContentItems == null) + else if (_ContentItems == null) _ContentItems = ContentItems.New(); return _ContentItems; } @@ -420,7 +424,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentPartCount",true); + CanReadProperty("ContentPartCount", true); return _ContentPartCount; } } @@ -434,10 +438,10 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentParts",true); - if(_ContentPartCount > 0 && _ContentParts == null) + CanReadProperty("ContentParts", true); + if (_ContentPartCount > 0 && _ContentParts == null) _ContentParts = ContentParts.GetByContentID(ContentID); - else if(_ContentParts == null) + else if (_ContentParts == null) _ContentParts = ContentParts.New(); return _ContentParts; } @@ -451,7 +455,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentRoUsageCount",true); + CanReadProperty("ContentRoUsageCount", true); return _ContentRoUsageCount; } } @@ -465,10 +469,10 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentRoUsages",true); - if(_ContentRoUsageCount > 0 && _ContentRoUsages == null) + CanReadProperty("ContentRoUsages", true); + if (_ContentRoUsageCount > 0 && _ContentRoUsages == null) _ContentRoUsages = ContentRoUsages.GetByContentID(ContentID); - else if(_ContentRoUsages == null) + else if (_ContentRoUsages == null) _ContentRoUsages = ContentRoUsages.New(); return _ContentRoUsages; } @@ -482,7 +486,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentTransitionCount",true); + CanReadProperty("ContentTransitionCount", true); return _ContentTransitionCount; } } @@ -496,10 +500,10 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentTransitions",true); - if(_ContentTransitionCount > 0 && _ContentTransitions == null) + CanReadProperty("ContentTransitions", true); + if (_ContentTransitionCount > 0 && _ContentTransitions == null) _ContentTransitions = ContentTransitions.GetByFromID(ContentID); - else if(_ContentTransitions == null) + else if (_ContentTransitions == null) _ContentTransitions = ContentTransitions.New(); return _ContentTransitions; } @@ -513,7 +517,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentZContentCount",true); + CanReadProperty("ContentZContentCount", true); return _ContentZContentCount; } } @@ -527,18 +531,18 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyZContent",true); - if ( _MyZContent == null) _MyZContent = ZContent.New(this); + CanReadProperty("MyZContent", true); + if (_MyZContent == null) _MyZContent = ZContent.New(this); return _MyZContent; } } 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 { - 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 /// @@ -561,29 +565,30 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_ContentItems != null && (hasBrokenRules = _ContentItems.HasBrokenRules) != null) return hasBrokenRules; - if (_ContentDetails != null && (hasBrokenRules = _ContentDetails.HasBrokenRules) != null) return hasBrokenRules; - if (_MyEntry != null && (hasBrokenRules = _MyEntry.HasBrokenRules) != null) return hasBrokenRules; - if (_ContentParts != null && (hasBrokenRules = _ContentParts.HasBrokenRules) != null) return hasBrokenRules; - if (_ContentRoUsages != null && (hasBrokenRules = _ContentRoUsages.HasBrokenRules) != null) return hasBrokenRules; - if (_ContentTransitions != null && (hasBrokenRules = _ContentTransitions.HasBrokenRules) != null) return hasBrokenRules; - if (_MyZContent != null && (hasBrokenRules = _MyZContent.HasBrokenRules) != null) return hasBrokenRules; - if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; + if (_ContentItems != null && (hasBrokenRules = _ContentItems.HasBrokenRules) != null) return hasBrokenRules; + if (_ContentDetails != null && (hasBrokenRules = _ContentDetails.HasBrokenRules) != null) return hasBrokenRules; + if (_MyEntry != null && (hasBrokenRules = _MyEntry.HasBrokenRules) != null) return hasBrokenRules; + if (_ContentParts != null && (hasBrokenRules = _ContentParts.HasBrokenRules) != null) return hasBrokenRules; + if (_ContentRoUsages != null && (hasBrokenRules = _ContentRoUsages.HasBrokenRules) != null) return hasBrokenRules; + if (_ContentTransitions != null && (hasBrokenRules = _ContentTransitions.HasBrokenRules) != null) return hasBrokenRules; + if (_MyZContent != null && (hasBrokenRules = _MyZContent.HasBrokenRules) != null) return hasBrokenRules; + if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -708,14 +713,25 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _ContentUnique = 0; + private int _MyContentUnique; + public int MyContentUnique + { + get { return _MyContentUnique; } + } protected Content() {/* require use of factory methods */ + _MyContentUnique = ++_ContentUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(ContentID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString())) return; + List 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() { @@ -794,7 +810,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(contentID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -873,7 +889,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Content.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.ReadData", GetHashCode()); try { _ContentID = dr.GetInt32("ContentID"); @@ -896,14 +912,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Content.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -952,7 +968,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Content.DataPortal_Fetch", ex); } @@ -973,13 +989,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Content.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Content.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -988,7 +1004,7 @@ namespace VEPROMS.CSLA.Library if (!this.IsDirty) return; try { - if(_MyFormat != null) _MyFormat.Update(); + if (_MyFormat != null) _MyFormat.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; using (SqlCommand cm = cn.CreateCommand()) { @@ -1024,11 +1040,11 @@ namespace VEPROMS.CSLA.Library if (_ContentRoUsages != null) _ContentRoUsages.Update(this); if (_ContentTransitions != null) _ContentTransitions.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) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Content.SQLInsert", ex); } @@ -1036,7 +1052,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Content.Add", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.Add", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -1047,7 +1063,7 @@ namespace VEPROMS.CSLA.Library cm.Parameters.AddWithValue("@Number", number); cm.Parameters.AddWithValue("@Text", text); 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); if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts); cm.Parameters.AddWithValue("@UserID", userID); @@ -1067,7 +1083,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -1075,7 +1091,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Content.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1089,7 +1105,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -1098,10 +1114,10 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { 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 { - if(_MyFormat != null) _MyFormat.Update(); + if (_MyFormat != null) _MyFormat.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; if (base.IsDirty) { @@ -1141,7 +1157,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -1169,7 +1185,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Content.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -1181,7 +1197,7 @@ namespace VEPROMS.CSLA.Library cm.Parameters.AddWithValue("@Number", number); cm.Parameters.AddWithValue("@Text", text); 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); if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts); cm.Parameters.AddWithValue("@UserID", userID); @@ -1198,7 +1214,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -1210,7 +1226,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1226,7 +1242,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Content.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Content.DataPortal_Delete", ex); } @@ -1234,7 +1250,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -1249,7 +1265,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -1283,7 +1299,7 @@ namespace VEPROMS.CSLA.Library } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1301,7 +1317,7 @@ namespace VEPROMS.CSLA.Library } 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); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ContentDetail.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ContentDetail.cs index 8a6a9dae..1f71e42f 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ContentDetail.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ContentDetail.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DetailID",true); + CanReadProperty("DetailID", true); if (_MyDetail != null) _DetailID = _MyDetail.DetailID; return _DetailID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyDetail",true); + CanReadProperty("MyDetail", true); if (_MyDetail == null && _DetailID != 0) _MyDetail = Detail.Get(_DetailID); return _MyDetail; } @@ -65,13 +65,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemType",true); + CanReadProperty("ItemType", true); return _ItemType; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("ItemType",true); + CanWriteProperty("ItemType", true); if (_ItemType != value) { _ItemType = value; @@ -85,13 +85,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Text",true); + CanReadProperty("Text", true); return _Text; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Text",true); + CanWriteProperty("Text", true); if (value == null) value = string.Empty; if (_Text != value) { @@ -106,13 +106,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -127,13 +127,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -147,13 +147,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -184,22 +184,22 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -309,8 +309,8 @@ namespace VEPROMS.CSLA.Library // TODO: Add any initialization & defaults _DTS = _ContentDetailExtension.DefaultDTS; _UserID = _ContentDetailExtension.DefaultUserID; - _ItemType = itemType; - _Text = text; + _ItemType = itemType; + _Text = text; ValidationRules.CheckRules(); } internal ContentDetail(SafeDataReader dr) @@ -322,7 +322,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentDetail.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentDetail.FetchDR", GetHashCode()); try { _DetailID = dr.GetInt32("DetailID"); @@ -335,7 +335,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ContentDetails.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ContentDetails.cs index 72562d84..071c3bac 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ContentDetails.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ContentDetails.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public ContentDetail Add(int itemType, string text) // One to Many { - ContentDetail detail = ContentDetail.New(itemType, text); - this.Add(detail); - return detail; + ContentDetail detail = ContentDetail.New(itemType, text); + this.Add(detail); + return detail; } public void Remove(Detail myDetail) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(ContentDetail contentDetail in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (ContentDetail contentDetail in this) if ((hasBrokenRules = contentDetail.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ContentIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentDetails.DataPortal_FetchContentID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentDetails.DataPortal_FetchContentID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class ContentDetailsPropertyDescriptor : vlnListPropertyDescriptor { - private ContentDetail Item { get { return (ContentDetail) _Item;} } - public ContentDetailsPropertyDescriptor(ContentDetails collection, int index):base(collection, index){;} + private ContentDetail Item { get { return (ContentDetail)_Item; } } + public ContentDetailsPropertyDescriptor(ContentDetails collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is ContentDetails) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ContentInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ContentInfo.cs index a62da43d..c291cbc9 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ContentInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ContentInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (ContentInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.ContentID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString())) + { + _AllByPrimaryKey[tmp.ContentID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (ContentInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = contentID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentID",true); + CanReadProperty("ContentID", true); return _ContentID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Number",true); + CanReadProperty("Number", true); return _Number; } } @@ -105,7 +109,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Text",true); + CanReadProperty("Text", true); return _Text; } } @@ -118,7 +122,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Type",true); + CanReadProperty("Type", true); return _Type; } } @@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatID",true); + CanReadProperty("FormatID", true); if (_MyFormat != null) _FormatID = _MyFormat.FormatID; return _FormatID; } @@ -139,7 +143,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFormat",true); + CanReadProperty("MyFormat", true); if (_MyFormat == null && _FormatID != null) _MyFormat = FormatInfo.Get((int)_FormatID); return _MyFormat; } @@ -150,7 +154,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } } @@ -160,7 +164,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -170,7 +174,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } } @@ -183,7 +187,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentDetailCount",true); + CanReadProperty("ContentDetailCount", true); return _ContentDetailCount; } } @@ -194,7 +198,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentDetails",true); + CanReadProperty("ContentDetails", true); if (_ContentDetailCount < 0 || (_ContentDetailCount > 0 && _ContentDetails == null)) _ContentDetails = DetailInfoList.GetByContentID(_ContentID); if (_ContentDetailCount < 0) @@ -204,7 +208,10 @@ namespace VEPROMS.CSLA.Library } 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; /// @@ -215,7 +222,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentEntryCount",true); + CanReadProperty("ContentEntryCount", true); return _ContentEntryCount; } } @@ -226,7 +233,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyEntry",true); + CanReadProperty("MyEntry", true); if (_ContentEntryCount > 0 && _MyEntry == null) _MyEntry = EntryInfo.Get(_ContentID); return _MyEntry; @@ -241,7 +248,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentItemCount",true); + CanReadProperty("ContentItemCount", true); return _ContentItemCount; } } @@ -252,7 +259,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentItems",true); + CanReadProperty("ContentItems", true); if (_ContentItemCount < 0 || (_ContentItemCount > 0 && _ContentItems == null)) _ContentItems = ItemInfoList.GetByContentID(_ContentID); if (_ContentItemCount < 0) @@ -262,7 +269,10 @@ namespace VEPROMS.CSLA.Library } 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; /// @@ -273,7 +283,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentPartCount",true); + CanReadProperty("ContentPartCount", true); return _ContentPartCount; } } @@ -284,7 +294,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentParts",true); + CanReadProperty("ContentParts", true); if (_ContentPartCount < 0 || (_ContentPartCount > 0 && _ContentParts == null)) _ContentParts = PartInfoList.GetByContentID(_ContentID); if (_ContentPartCount < 0) @@ -294,7 +304,10 @@ namespace VEPROMS.CSLA.Library } 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; /// @@ -305,7 +318,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentRoUsageCount",true); + CanReadProperty("ContentRoUsageCount", true); return _ContentRoUsageCount; } } @@ -316,7 +329,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentRoUsages",true); + CanReadProperty("ContentRoUsages", true); if (_ContentRoUsageCount < 0 || (_ContentRoUsageCount > 0 && _ContentRoUsages == null)) _ContentRoUsages = RoUsageInfoList.GetByContentID(_ContentID); if (_ContentRoUsageCount < 0) @@ -326,7 +339,10 @@ namespace VEPROMS.CSLA.Library } 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; /// @@ -337,7 +353,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentTransitionCount",true); + CanReadProperty("ContentTransitionCount", true); return _ContentTransitionCount; } } @@ -348,7 +364,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentTransitions",true); + CanReadProperty("ContentTransitions", true); if (_ContentTransitionCount < 0 || (_ContentTransitionCount > 0 && _ContentTransitions == null)) _ContentTransitions = TransitionInfoList.GetByFromID(_ContentID); if (_ContentTransitionCount < 0) @@ -358,7 +374,10 @@ namespace VEPROMS.CSLA.Library } 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; /// @@ -369,7 +388,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentZContentCount",true); + CanReadProperty("ContentZContentCount", true); return _ContentZContentCount; } } @@ -380,7 +399,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyZContent",true); + CanReadProperty("MyZContent", true); if (_ContentZContentCount > 0 && _MyZContent == null) _MyZContent = ZContentInfo.Get(_ContentID); return _MyZContent; @@ -406,14 +425,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _ContentInfoUnique = 0; + private int _MyContentInfoUnique; + public int MyContentInfoUnique + { + get { return _MyContentInfoUnique; } + } private ContentInfo() {/* require use of factory methods */ + _MyContentInfoUnique = ++_ContentInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(ContentID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString())) return; + List 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() { @@ -421,9 +451,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(Content tmp) { - ContentInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.ContentID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (ContentInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(Content tmp) { @@ -434,9 +466,9 @@ namespace VEPROMS.CSLA.Library { MyFormat.RefreshFormatContents(); // Update List for old 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; _DTS = tmp.DTS; _UserID = tmp.UserID; @@ -448,9 +480,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(FormatContent tmp) { - ContentInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.ContentID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (ContentInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(FormatContent tmp) { @@ -476,7 +510,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(contentID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -490,14 +524,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { ReadData(dr); } 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); } } @@ -514,7 +549,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.ReadData", GetHashCode()); try { _ContentID = dr.GetInt32("ContentID"); @@ -535,14 +570,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ContentInfo.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -570,7 +605,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ContentInfo.DataPortal_Fetch", ex); } @@ -580,7 +615,7 @@ namespace VEPROMS.CSLA.Library #region extension ContentInfoExtension _ContentInfoExtension = new ContentInfoExtension(); [Serializable()] - partial class ContentInfoExtension : extensionBase {} + partial class ContentInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ContentInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ContentInfoList.cs index 4322e6d4..d4dc4da8 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ContentInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ContentInfoList.cs @@ -110,7 +110,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -130,7 +130,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -152,7 +152,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(FormatIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentInfoList.DataPortal_FetchFormatID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfoList.DataPortal_FetchFormatID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -173,7 +173,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -234,8 +234,8 @@ namespace VEPROMS.CSLA.Library /// public partial class ContentInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private ContentInfo Item { get { return (ContentInfo) _Item;} } - public ContentInfoListPropertyDescriptor(ContentInfoList collection, int index):base(collection, index){;} + private ContentInfo Item { get { return (ContentInfo)_Item; } } + public ContentInfoListPropertyDescriptor(ContentInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -246,7 +246,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is ContentInfoList) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ContentItem.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ContentItem.cs index d1cad0f4..4f8081ef 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ContentItem.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ContentItem.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemID",true); + CanReadProperty("ItemID", true); if (_MyItem != null) _ItemID = _MyItem.ItemID; return _ItemID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItem",true); + CanReadProperty("MyItem", true); if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID); return _MyItem; } @@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("PreviousID",true); + CanReadProperty("PreviousID", true); if (_MyPrevious != null) _PreviousID = _MyPrevious.ItemID; return _PreviousID; } @@ -76,18 +76,18 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyPrevious",true); + CanReadProperty("MyPrevious", true); if (_MyPrevious == null && _PreviousID != null) _MyPrevious = Item.Get((int)_PreviousID); return _MyPrevious; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyPrevious",true); + CanWriteProperty("MyPrevious", true); if (_MyPrevious != value) { _MyPrevious = value; - _PreviousID = (value == null ? null : (int?) value.ItemID); + _PreviousID = (value == null ? null : (int?)value.ItemID); PropertyHasChanged(); } } @@ -98,13 +98,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -118,13 +118,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -155,23 +155,23 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -272,7 +272,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentItem.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentItem.FetchDR", GetHashCode()); try { _ItemID = dr.GetInt32("ItemID"); @@ -283,7 +283,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ContentItems.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ContentItems.cs index 0ba528a2..d4069fc9 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ContentItems.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ContentItems.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public ContentItem Add() // One to Many { - ContentItem item = ContentItem.New(); - this.Add(item); - return item; + ContentItem item = ContentItem.New(); + this.Add(item); + return item; } public void Remove(Item myItem) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(ContentItem contentItem in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (ContentItem contentItem in this) if ((hasBrokenRules = contentItem.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ContentIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentItems.DataPortal_FetchContentID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentItems.DataPortal_FetchContentID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class ContentItemsPropertyDescriptor : vlnListPropertyDescriptor { - private ContentItem Item { get { return (ContentItem) _Item;} } - public ContentItemsPropertyDescriptor(ContentItems collection, int index):base(collection, index){;} + private ContentItem Item { get { return (ContentItem)_Item; } } + public ContentItemsPropertyDescriptor(ContentItems collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is ContentItems) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ContentPart.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ContentPart.cs index e4eb1f15..02f33bbe 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ContentPart.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ContentPart.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FromType",true); + CanReadProperty("FromType", true); return _FromType; } } @@ -52,7 +52,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemID",true); + CanReadProperty("ItemID", true); if (_MyItem != null) _ItemID = _MyItem.ItemID; return _ItemID; } @@ -63,14 +63,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItem",true); + CanReadProperty("MyItem", true); if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID); return _MyItem; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyItem",true); + CanWriteProperty("MyItem", true); if (_MyItem != value) { _MyItem = value; @@ -84,13 +84,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -104,13 +104,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -126,7 +126,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Item_PreviousID",true); + CanReadProperty("Item_PreviousID", true); return _Item_PreviousID; } } @@ -136,7 +136,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Item_ContentID",true); + CanReadProperty("Item_ContentID", true); return _Item_ContentID; } } @@ -146,7 +146,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Item_DTS",true); + CanReadProperty("Item_DTS", true); return _Item_DTS; } } @@ -156,7 +156,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Item_UserID",true); + CanReadProperty("Item_UserID", true); return _Item_UserID; } } @@ -189,23 +189,23 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -313,8 +313,8 @@ namespace VEPROMS.CSLA.Library // TODO: Add any initialization & defaults _DTS = _ContentPartExtension.DefaultDTS; _UserID = _ContentPartExtension.DefaultUserID; - _FromType = fromType; - _MyItem = myItem; + _FromType = fromType; + _MyItem = myItem; ValidationRules.CheckRules(); } internal ContentPart(SafeDataReader dr) @@ -326,7 +326,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentPart.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentPart.FetchDR", GetHashCode()); try { _FromType = dr.GetInt32("FromType"); @@ -341,7 +341,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ContentParts.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ContentParts.cs index 9c9997d7..66bccb98 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ContentParts.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ContentParts.cs @@ -99,8 +99,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(ContentPart contentPart in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (ContentPart contentPart in this) if ((hasBrokenRules = contentPart.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -109,8 +109,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -170,7 +170,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ContentIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentParts.DataPortal_FetchContentID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentParts.DataPortal_FetchContentID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -189,7 +189,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -274,8 +274,8 @@ namespace VEPROMS.CSLA.Library /// public partial class ContentPartsPropertyDescriptor : vlnListPropertyDescriptor { - private ContentPart Item { get { return (ContentPart) _Item;} } - public ContentPartsPropertyDescriptor(ContentParts collection, int index):base(collection, index){;} + private ContentPart Item { get { return (ContentPart)_Item; } } + public ContentPartsPropertyDescriptor(ContentParts collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -286,7 +286,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is ContentParts) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ContentRoUsage.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ContentRoUsage.cs index c7fb1daa..715d5769 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ContentRoUsage.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ContentRoUsage.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ROUsageID",true); + CanReadProperty("ROUsageID", true); if (_MyRoUsage != null) _ROUsageID = _MyRoUsage.ROUsageID; return _ROUsageID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyRoUsage",true); + CanReadProperty("MyRoUsage", true); if (_MyRoUsage == null && _ROUsageID != 0) _MyRoUsage = RoUsage.Get(_ROUsageID); return _MyRoUsage; } @@ -65,13 +65,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ROID",true); + CanReadProperty("ROID", true); return _ROID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("ROID",true); + CanWriteProperty("ROID", true); if (value == null) value = string.Empty; if (_ROID != value) { @@ -86,13 +86,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -107,13 +107,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -127,13 +127,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -164,22 +164,22 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -287,7 +287,7 @@ namespace VEPROMS.CSLA.Library // TODO: Add any initialization & defaults _DTS = _ContentRoUsageExtension.DefaultDTS; _UserID = _ContentRoUsageExtension.DefaultUserID; - _ROID = roid; + _ROID = roid; ValidationRules.CheckRules(); } internal ContentRoUsage(SafeDataReader dr) @@ -299,7 +299,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentRoUsage.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentRoUsage.FetchDR", GetHashCode()); try { _ROUsageID = dr.GetInt32("ROUsageID"); @@ -311,7 +311,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ContentRoUsages.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ContentRoUsages.cs index bc74a8e2..88e81e9e 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ContentRoUsages.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ContentRoUsages.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public ContentRoUsage Add(string roid) // One to Many { - ContentRoUsage roUsage = ContentRoUsage.New(roid); - this.Add(roUsage); - return roUsage; + ContentRoUsage roUsage = ContentRoUsage.New(roid); + this.Add(roUsage); + return roUsage; } public void Remove(RoUsage myRoUsage) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(ContentRoUsage contentRoUsage in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (ContentRoUsage contentRoUsage in this) if ((hasBrokenRules = contentRoUsage.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ContentIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentRoUsages.DataPortal_FetchContentID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentRoUsages.DataPortal_FetchContentID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class ContentRoUsagesPropertyDescriptor : vlnListPropertyDescriptor { - private ContentRoUsage Item { get { return (ContentRoUsage) _Item;} } - public ContentRoUsagesPropertyDescriptor(ContentRoUsages collection, int index):base(collection, index){;} + private ContentRoUsage Item { get { return (ContentRoUsage)_Item; } } + public ContentRoUsagesPropertyDescriptor(ContentRoUsages collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is ContentRoUsages) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ContentTransition.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ContentTransition.cs index ad9ec76d..88fcfde7 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ContentTransition.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ContentTransition.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TransitionID",true); + CanReadProperty("TransitionID", true); if (_MyTransition != null) _TransitionID = _MyTransition.TransitionID; return _TransitionID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyTransition",true); + CanReadProperty("MyTransition", true); if (_MyTransition == null && _TransitionID != 0) _MyTransition = Transition.Get(_TransitionID); return _MyTransition; } @@ -68,7 +68,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ToID",true); + CanReadProperty("ToID", true); if (_MyItemToID != null) _ToID = _MyItemToID.ItemID; return _ToID; } @@ -79,14 +79,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItemToID",true); + CanReadProperty("MyItemToID", true); if (_MyItemToID == null && _ToID != 0) _MyItemToID = Item.Get(_ToID); return _MyItemToID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyItemToID",true); + CanWriteProperty("MyItemToID", true); if (_MyItemToID != value) { _MyItemToID = value; @@ -100,7 +100,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RangeID",true); + CanReadProperty("RangeID", true); if (_MyItemRangeID != null) _RangeID = _MyItemRangeID.ItemID; return _RangeID; } @@ -111,14 +111,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItemRangeID",true); + CanReadProperty("MyItemRangeID", true); if (_MyItemRangeID == null && _RangeID != 0) _MyItemRangeID = Item.Get(_RangeID); return _MyItemRangeID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyItemRangeID",true); + CanWriteProperty("MyItemRangeID", true); if (_MyItemRangeID != value) { _MyItemRangeID = value; @@ -132,13 +132,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TranType",true); + CanReadProperty("TranType", true); return _TranType; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("TranType",true); + CanWriteProperty("TranType", true); if (_TranType != value) { _TranType = value; @@ -152,13 +152,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -173,13 +173,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -193,13 +193,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -215,7 +215,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Item_RangeID_PreviousID",true); + CanReadProperty("Item_RangeID_PreviousID", true); return _Item_RangeID_PreviousID; } } @@ -225,7 +225,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Item_RangeID_ContentID",true); + CanReadProperty("Item_RangeID_ContentID", true); return _Item_RangeID_ContentID; } } @@ -235,7 +235,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Item_RangeID_DTS",true); + CanReadProperty("Item_RangeID_DTS", true); return _Item_RangeID_DTS; } } @@ -245,7 +245,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Item_RangeID_UserID",true); + CanReadProperty("Item_RangeID_UserID", true); return _Item_RangeID_UserID; } } @@ -255,7 +255,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Item_ToID_PreviousID",true); + CanReadProperty("Item_ToID_PreviousID", true); return _Item_ToID_PreviousID; } } @@ -265,7 +265,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Item_ToID_ContentID",true); + CanReadProperty("Item_ToID_ContentID", true); return _Item_ToID_ContentID; } } @@ -275,7 +275,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Item_ToID_DTS",true); + CanReadProperty("Item_ToID_DTS", true); return _Item_ToID_DTS; } } @@ -285,7 +285,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Item_ToID_UserID",true); + CanReadProperty("Item_ToID_UserID", true); return _Item_ToID_UserID; } } @@ -318,24 +318,24 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - if (_MyItemToID != null && (hasBrokenRules = _MyItemToID.HasBrokenRules) != null) return hasBrokenRules; - if (_MyItemRangeID != null && (hasBrokenRules = _MyItemRangeID.HasBrokenRules) != null) return hasBrokenRules; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + if (_MyItemToID != null && (hasBrokenRules = _MyItemToID.HasBrokenRules) != null) return hasBrokenRules; + if (_MyItemRangeID != null && (hasBrokenRules = _MyItemRangeID.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -464,8 +464,8 @@ namespace VEPROMS.CSLA.Library _TranType = _ContentTransitionExtension.DefaultTranType; _DTS = _ContentTransitionExtension.DefaultDTS; _UserID = _ContentTransitionExtension.DefaultUserID; - _MyItemToID = myItemToID; - _MyItemRangeID = myItemRangeID; + _MyItemToID = myItemToID; + _MyItemRangeID = myItemRangeID; ValidationRules.CheckRules(); } internal ContentTransition(SafeDataReader dr) @@ -477,7 +477,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentTransition.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentTransition.FetchDR", GetHashCode()); try { _TransitionID = dr.GetInt32("TransitionID"); @@ -499,7 +499,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ContentTransitions.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ContentTransitions.cs index 646f20d1..0d8270e4 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ContentTransitions.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ContentTransitions.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public ContentTransition Add(Item myItemToID, Item myItemRangeID) // One to Many { - ContentTransition transition = ContentTransition.New(myItemToID, myItemRangeID); - this.Add(transition); - return transition; + ContentTransition transition = ContentTransition.New(myItemToID, myItemRangeID); + this.Add(transition); + return transition; } public void Remove(Transition myTransition) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(ContentTransition contentTransition in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (ContentTransition contentTransition in this) if ((hasBrokenRules = contentTransition.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(FromIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentTransitions.DataPortal_FetchFromID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentTransitions.DataPortal_FetchFromID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class ContentTransitionsPropertyDescriptor : vlnListPropertyDescriptor { - private ContentTransition Item { get { return (ContentTransition) _Item;} } - public ContentTransitionsPropertyDescriptor(ContentTransitions collection, int index):base(collection, index){;} + private ContentTransition Item { get { return (ContentTransition)_Item; } } + public ContentTransitionsPropertyDescriptor(ContentTransitions collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is ContentTransitions) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Database.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Database.cs index aed9e75a..92120328 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Database.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Database.cs @@ -28,7 +28,7 @@ namespace VEPROMS.CSLA.Library #region Log4Net private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); #endregion - public static void LogException(string s,Exception ex) + public static void LogException(string s, Exception ex) { int i = 0; Console.WriteLine("Error - {0}", s); @@ -44,14 +44,14 @@ namespace VEPROMS.CSLA.Library set { _LoggingInfo = value; } } 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)); } - 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)); } public static string VEPROMS_Connection @@ -107,7 +107,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -124,14 +124,14 @@ namespace VEPROMS.CSLA.Library } 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); } } } 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() : base() { ;} } // Class diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Detail.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Detail.cs index d4283559..935bc798 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Detail.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Detail.cs @@ -47,19 +47,23 @@ namespace VEPROMS.CSLA.Library foreach (Detail tmp in _RefreshDetails) { DetailInfo.Refresh(tmp); - if(tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent); + if (tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent); } } #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (Detail tmp in _AllList) { - _AllByPrimaryKey[tmp.DetailID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.DetailID.ToString())) + { + _AllByPrimaryKey[tmp.DetailID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.DetailID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (Detail tmp in remove) @@ -69,7 +73,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = detailID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -91,7 +95,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DetailID",true); + CanReadProperty("DetailID", true); return _DetailID; } } @@ -101,7 +105,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentID",true); + CanReadProperty("ContentID", true); if (_MyContent != null) _ContentID = _MyContent.ContentID; return _ContentID; } @@ -112,14 +116,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID); return _MyContent; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyContent",true); + CanWriteProperty("MyContent", true); if (_MyContent != value) { _MyContent = value; @@ -133,13 +137,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemType",true); + CanReadProperty("ItemType", true); return _ItemType; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("ItemType",true); + CanWriteProperty("ItemType", true); if (_ItemType != value) { _ItemType = value; @@ -153,13 +157,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Text",true); + CanReadProperty("Text", true); return _Text; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Text",true); + CanWriteProperty("Text", true); if (value == null) value = string.Empty; if (_Text != value) { @@ -174,13 +178,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -195,13 +199,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -215,13 +219,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -233,11 +237,11 @@ namespace VEPROMS.CSLA.Library private byte[] _LastChanged = new byte[8];//timestamp public override bool IsDirty { - get { return base.IsDirty || (_MyContent == null? false : _MyContent.IsDirty); } + get { return base.IsDirty || (_MyContent == null ? false : _MyContent.IsDirty); } } public override bool IsValid { - get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyContent == null? true : _MyContent.IsValid); } + get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyContent == null ? true : _MyContent.IsValid); } } // TODO: Replace base Detail.ToString function as necessary /// @@ -260,22 +264,23 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules; + if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -388,14 +393,25 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _DetailUnique = 0; + private int _MyDetailUnique; + public int MyDetailUnique + { + get { return _MyDetailUnique; } + } protected Detail() {/* require use of factory methods */ + _MyDetailUnique = ++_DetailUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(DetailID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(DetailID.ToString())) return; + List 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() { @@ -480,7 +496,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(detailID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -559,7 +575,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Detail.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.ReadData", GetHashCode()); try { _DetailID = dr.GetInt32("DetailID"); @@ -574,14 +590,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Detail.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -609,7 +625,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Detail.DataPortal_Fetch", ex); } @@ -630,13 +646,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Detail.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Detail.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -645,7 +661,7 @@ namespace VEPROMS.CSLA.Library if (!this.IsDirty) return; try { - if(_MyContent != null) _MyContent.Update(); + if (_MyContent != null) _MyContent.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; using (SqlCommand cm = cn.CreateCommand()) { @@ -673,11 +689,11 @@ namespace VEPROMS.CSLA.Library } MarkOld(); // update child objects - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Detail.SQLInsert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.SQLInsert", GetHashCode()); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Detail.SQLInsert", ex); } @@ -685,7 +701,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -715,7 +731,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -723,7 +739,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Detail.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -737,7 +753,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -746,10 +762,10 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { 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 { - if(_MyContent != null) _MyContent.Update(); + if (_MyContent != null) _MyContent.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; if (base.IsDirty) { @@ -781,7 +797,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -802,7 +818,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Detail.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -830,7 +846,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -842,7 +858,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -858,7 +874,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Detail.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Detail.DataPortal_Delete", ex); } @@ -866,7 +882,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -881,7 +897,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -915,7 +931,7 @@ namespace VEPROMS.CSLA.Library } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -933,7 +949,7 @@ namespace VEPROMS.CSLA.Library } 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); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/DetailInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/DetailInfo.cs index ea8ba1c8..2999d557 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/DetailInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/DetailInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (DetailInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.DetailID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.DetailID.ToString())) + { + _AllByPrimaryKey[tmp.DetailID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.DetailID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (DetailInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = detailID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DetailID",true); + CanReadProperty("DetailID", true); return _DetailID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentID",true); + CanReadProperty("ContentID", true); if (_MyContent != null) _ContentID = _MyContent.ContentID; return _ContentID; } @@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID); return _MyContent; } @@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemType",true); + CanReadProperty("ItemType", true); return _ItemType; } } @@ -127,7 +131,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Text",true); + CanReadProperty("Text", true); return _Text; } } @@ -137,7 +141,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } } @@ -147,7 +151,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -157,7 +161,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } } @@ -181,14 +185,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _DetailInfoUnique = 0; + private int _MyDetailInfoUnique; + public int MyDetailInfoUnique + { + get { return _MyDetailInfoUnique; } + } private DetailInfo() {/* require use of factory methods */ + _MyDetailInfoUnique = ++_DetailInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(DetailID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(DetailID.ToString())) return; + List 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() { @@ -196,9 +211,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(Detail tmp) { - DetailInfo tmpInfo = GetExistingByPrimaryKey(tmp.DetailID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.DetailID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (DetailInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(Detail tmp) { @@ -206,9 +223,9 @@ namespace VEPROMS.CSLA.Library { MyContent.RefreshContentDetails(); // Update List for old 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; _Text = tmp.Text; _Config = tmp.Config; @@ -220,9 +237,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(ContentDetail tmp) { - DetailInfo tmpInfo = GetExistingByPrimaryKey(tmp.DetailID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.DetailID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (DetailInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(ContentDetail tmp) { @@ -245,7 +264,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(detailID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -259,14 +278,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { ReadData(dr); } 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); } } @@ -283,7 +303,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DetailInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfo.ReadData", GetHashCode()); try { _DetailID = dr.GetInt32("DetailID"); @@ -296,14 +316,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("DetailInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("DetailInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("DetailInfo.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -331,7 +351,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("DetailInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("DetailInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("DetailInfo.DataPortal_Fetch", ex); } @@ -341,7 +361,7 @@ namespace VEPROMS.CSLA.Library #region extension DetailInfoExtension _DetailInfoExtension = new DetailInfoExtension(); [Serializable()] - partial class DetailInfoExtension : extensionBase {} + partial class DetailInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/DetailInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/DetailInfoList.cs index 2645ac83..229d6851 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/DetailInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/DetailInfoList.cs @@ -110,7 +110,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DetailInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -130,7 +130,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -152,7 +152,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ContentIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DetailInfoList.DataPortal_FetchContentID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfoList.DataPortal_FetchContentID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -173,7 +173,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -234,8 +234,8 @@ namespace VEPROMS.CSLA.Library /// public partial class DetailInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private DetailInfo Item { get { return (DetailInfo) _Item;} } - public DetailInfoListPropertyDescriptor(DetailInfoList collection, int index):base(collection, index){;} + private DetailInfo Item { get { return (DetailInfo)_Item; } } + public DetailInfoListPropertyDescriptor(DetailInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -246,7 +246,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is DetailInfoList) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/DocVersion.cs b/PROMS/VEPROMS.CSLA.Library/Generated/DocVersion.cs index 6d74f55a..3215b47f 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/DocVersion.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/DocVersion.cs @@ -47,21 +47,25 @@ namespace VEPROMS.CSLA.Library foreach (DocVersion tmp in _RefreshDocVersions) { DocVersionInfo.Refresh(tmp); - if(tmp._MyFolder != null) FolderInfo.Refresh(tmp._MyFolder); - if(tmp._MyFormat != null) FormatInfo.Refresh(tmp._MyFormat); - if(tmp._MyItem != null) ItemInfo.Refresh(tmp._MyItem); + if (tmp._MyFolder != null) FolderInfo.Refresh(tmp._MyFolder); + if (tmp._MyFormat != null) FormatInfo.Refresh(tmp._MyFormat); + if (tmp._MyItem != null) ItemInfo.Refresh(tmp._MyItem); } } #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (DocVersion tmp in _AllList) { - _AllByPrimaryKey[tmp.VersionID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.VersionID.ToString())) + { + _AllByPrimaryKey[tmp.VersionID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.VersionID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (DocVersion tmp in remove) @@ -71,7 +75,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = versionID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -93,7 +97,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("VersionID",true); + CanReadProperty("VersionID", true); return _VersionID; } } @@ -103,7 +107,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderID",true); + CanReadProperty("FolderID", true); if (_MyFolder != null) _FolderID = _MyFolder.FolderID; return _FolderID; } @@ -114,14 +118,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFolder",true); + CanReadProperty("MyFolder", true); if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID); return _MyFolder; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyFolder",true); + CanWriteProperty("MyFolder", true); if (_MyFolder != value) { _MyFolder = value; @@ -138,13 +142,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("VersionType",true); + CanReadProperty("VersionType", true); return _VersionType; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("VersionType",true); + CanWriteProperty("VersionType", true); if (_VersionType != value) { _VersionType = value; @@ -158,13 +162,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Name",true); + CanReadProperty("Name", true); return _Name; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Name",true); + CanWriteProperty("Name", true); if (value == null) value = string.Empty; if (_Name != value) { @@ -179,13 +183,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Title",true); + CanReadProperty("Title", true); return _Title; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Title",true); + CanWriteProperty("Title", true); if (value == null) value = string.Empty; if (_Title != value) { @@ -200,7 +204,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemID",true); + CanReadProperty("ItemID", true); if (_MyItem != null) _ItemID = _MyItem.ItemID; return _ItemID; } @@ -211,18 +215,18 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItem",true); + CanReadProperty("MyItem", true); if (_MyItem == null && _ItemID != null) _MyItem = Item.Get((int)_ItemID); return _MyItem; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyItem",true); + CanWriteProperty("MyItem", true); if (_MyItem != value) { _MyItem = value; - _ItemID = (value == null ? null : (int?) value.ItemID); + _ItemID = (value == null ? null : (int?)value.ItemID); PropertyHasChanged(); } } @@ -233,7 +237,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatID",true); + CanReadProperty("FormatID", true); if (_MyFormat != null) _FormatID = _MyFormat.FormatID; return _FormatID; } @@ -244,18 +248,18 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFormat",true); + CanReadProperty("MyFormat", true); if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID); return _MyFormat; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyFormat",true); + CanWriteProperty("MyFormat", true); if (_MyFormat != value) { _MyFormat = value; - _FormatID = (value == null ? null : (int?) value.FormatID); + _FormatID = (value == null ? null : (int?)value.FormatID); PropertyHasChanged(); } } @@ -266,13 +270,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -287,13 +291,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -307,13 +311,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -325,11 +329,11 @@ namespace VEPROMS.CSLA.Library private byte[] _LastChanged = new byte[8];//timestamp 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 { - 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 /// @@ -352,24 +356,25 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; - if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; - if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; + if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; + if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; + if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -491,14 +496,25 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _DocVersionUnique = 0; + private int _MyDocVersionUnique; + public int MyDocVersionUnique + { + get { return _MyDocVersionUnique; } + } protected DocVersion() {/* require use of factory methods */ + _MyDocVersionUnique = ++_DocVersionUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(VersionID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(VersionID.ToString())) return; + List 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() { @@ -587,7 +603,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(versionID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -667,7 +683,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersion.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.ReadData", GetHashCode()); try { _VersionID = dr.GetInt32("VersionID"); @@ -685,14 +701,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("DocVersion.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -720,7 +736,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("DocVersion.DataPortal_Fetch", ex); } @@ -741,13 +757,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("DocVersion.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersion.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -756,9 +772,9 @@ namespace VEPROMS.CSLA.Library if (!this.IsDirty) return; try { - if(_MyFolder != null) _MyFolder.Update(); - if(_MyFormat != null) _MyFormat.Update(); - if(_MyItem != null) _MyItem.Update(); + if (_MyFolder != null) _MyFolder.Update(); + if (_MyFormat != null) _MyFormat.Update(); + if (_MyItem != null) _MyItem.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; using (SqlCommand cm = cn.CreateCommand()) { @@ -789,11 +805,11 @@ namespace VEPROMS.CSLA.Library } MarkOld(); // update child objects - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersion.SQLInsert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.SQLInsert", GetHashCode()); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("DocVersion.SQLInsert", ex); } @@ -801,7 +817,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersion.Add", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.Add", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -813,8 +829,8 @@ namespace VEPROMS.CSLA.Library cm.Parameters.AddWithValue("@VersionType", versionType); cm.Parameters.AddWithValue("@Name", name); cm.Parameters.AddWithValue("@Title", title); - if(myItem != null)cm.Parameters.AddWithValue("@ItemID", myItem.ItemID); - if(myFormat != null)cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID); + if (myItem != null) cm.Parameters.AddWithValue("@ItemID", myItem.ItemID); + if (myFormat != null) cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID); cm.Parameters.AddWithValue("@Config", config); if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts); cm.Parameters.AddWithValue("@UserID", userID); @@ -834,7 +850,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -842,7 +858,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersion.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -856,7 +872,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -865,12 +881,12 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { 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 { - if(_MyFolder != null) _MyFolder.Update(); - if(_MyFormat != null) _MyFormat.Update(); - if(_MyItem != null) _MyItem.Update(); + if (_MyFolder != null) _MyFolder.Update(); + if (_MyFormat != null) _MyFormat.Update(); + if (_MyItem != null) _MyItem.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; if (base.IsDirty) { @@ -905,7 +921,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -926,7 +942,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersion.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -939,8 +955,8 @@ namespace VEPROMS.CSLA.Library cm.Parameters.AddWithValue("@VersionType", versionType); cm.Parameters.AddWithValue("@Name", name); cm.Parameters.AddWithValue("@Title", title); - if(myItem != null)cm.Parameters.AddWithValue("@ItemID", myItem.ItemID); - if(myFormat != null)cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID); + if (myItem != null) cm.Parameters.AddWithValue("@ItemID", myItem.ItemID); + if (myFormat != null) cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID); cm.Parameters.AddWithValue("@Config", config); if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts); cm.Parameters.AddWithValue("@UserID", userID); @@ -957,7 +973,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -969,7 +985,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -985,7 +1001,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersion.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersion.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("DocVersion.DataPortal_Delete", ex); } @@ -993,7 +1009,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -1008,7 +1024,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -1042,7 +1058,7 @@ namespace VEPROMS.CSLA.Library } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1060,7 +1076,7 @@ namespace VEPROMS.CSLA.Library } 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); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/DocVersionInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/DocVersionInfo.cs index e7988fcc..dddea2d3 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/DocVersionInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/DocVersionInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (DocVersionInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.VersionID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.VersionID.ToString())) + { + _AllByPrimaryKey[tmp.VersionID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.VersionID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (DocVersionInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = versionID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("VersionID",true); + CanReadProperty("VersionID", true); return _VersionID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderID",true); + CanReadProperty("FolderID", true); if (_MyFolder != null) _FolderID = _MyFolder.FolderID; return _FolderID; } @@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFolder",true); + CanReadProperty("MyFolder", true); if (_MyFolder == null && _FolderID != 0) _MyFolder = FolderInfo.Get(_FolderID); return _MyFolder; } @@ -120,7 +124,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("VersionType",true); + CanReadProperty("VersionType", true); return _VersionType; } } @@ -130,7 +134,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Name",true); + CanReadProperty("Name", true); return _Name; } } @@ -140,7 +144,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Title",true); + CanReadProperty("Title", true); return _Title; } } @@ -150,7 +154,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemID",true); + CanReadProperty("ItemID", true); if (_MyItem != null) _ItemID = _MyItem.ItemID; return _ItemID; } @@ -161,7 +165,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItem",true); + CanReadProperty("MyItem", true); if (_MyItem == null && _ItemID != null) _MyItem = ItemInfo.Get((int)_ItemID); return _MyItem; } @@ -172,7 +176,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatID",true); + CanReadProperty("FormatID", true); if (_MyFormat != null) _FormatID = _MyFormat.FormatID; return _FormatID; } @@ -183,7 +187,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFormat",true); + CanReadProperty("MyFormat", true); if (_MyFormat == null && _FormatID != null) _MyFormat = FormatInfo.Get((int)_FormatID); return _MyFormat; } @@ -194,7 +198,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } } @@ -204,7 +208,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -214,7 +218,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } } @@ -238,14 +242,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _DocVersionInfoUnique = 0; + private int _MyDocVersionInfoUnique; + public int MyDocVersionInfoUnique + { + get { return _MyDocVersionInfoUnique; } + } private DocVersionInfo() {/* require use of factory methods */ + _MyDocVersionInfoUnique = ++_DocVersionInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(VersionID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(VersionID.ToString())) return; + List 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() { @@ -253,9 +268,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(DocVersion tmp) { - DocVersionInfo tmpInfo = GetExistingByPrimaryKey(tmp.VersionID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.VersionID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (DocVersionInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(DocVersion tmp) { @@ -263,9 +280,9 @@ namespace VEPROMS.CSLA.Library { MyFolder.RefreshFolderDocVersions(); // Update List for old 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; _Name = tmp.Name; _Title = tmp.Title; @@ -273,16 +290,16 @@ namespace VEPROMS.CSLA.Library { MyItem.RefreshItemDocVersions(); // Update List for old 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) { MyFormat.RefreshFormatDocVersions(); // Update List for old 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; _DTS = tmp.DTS; _UserID = tmp.UserID; @@ -294,9 +311,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(FolderDocVersion tmp) { - DocVersionInfo tmpInfo = GetExistingByPrimaryKey(tmp.VersionID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.VersionID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (DocVersionInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(FolderDocVersion tmp) { @@ -307,16 +326,16 @@ namespace VEPROMS.CSLA.Library { MyItem.RefreshItemDocVersions(); // Update List for old 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) { MyFormat.RefreshFormatDocVersions(); // Update List for old 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; _DTS = tmp.DTS; _UserID = tmp.UserID; @@ -328,9 +347,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(FormatDocVersion tmp) { - DocVersionInfo tmpInfo = GetExistingByPrimaryKey(tmp.VersionID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.VersionID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (DocVersionInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(FormatDocVersion tmp) { @@ -338,9 +359,9 @@ namespace VEPROMS.CSLA.Library { MyFolder.RefreshFolderDocVersions(); // Update List for old 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; _Name = tmp.Name; _Title = tmp.Title; @@ -348,9 +369,9 @@ namespace VEPROMS.CSLA.Library { MyItem.RefreshItemDocVersions(); // Update List for old 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; _DTS = tmp.DTS; _UserID = tmp.UserID; @@ -362,9 +383,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(ItemDocVersion tmp) { - DocVersionInfo tmpInfo = GetExistingByPrimaryKey(tmp.VersionID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.VersionID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (DocVersionInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(ItemDocVersion tmp) { @@ -372,9 +395,9 @@ namespace VEPROMS.CSLA.Library { MyFolder.RefreshFolderDocVersions(); // Update List for old 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; _Name = tmp.Name; _Title = tmp.Title; @@ -382,9 +405,9 @@ namespace VEPROMS.CSLA.Library { MyFormat.RefreshFormatDocVersions(); // Update List for old 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; _DTS = tmp.DTS; _UserID = tmp.UserID; @@ -404,7 +427,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(versionID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -418,14 +441,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { ReadData(dr); } 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); } } @@ -442,7 +466,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfo.ReadData", GetHashCode()); try { _VersionID = dr.GetInt32("VersionID"); @@ -458,14 +482,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersionInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("DocVersionInfo.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -493,7 +517,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersionInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("DocVersionInfo.DataPortal_Fetch", ex); } @@ -503,7 +527,7 @@ namespace VEPROMS.CSLA.Library #region extension DocVersionInfoExtension _DocVersionInfoExtension = new DocVersionInfoExtension(); [Serializable()] - partial class DocVersionInfoExtension : extensionBase {} + partial class DocVersionInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/DocVersionInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/DocVersionInfoList.cs index 79331617..2ee6798b 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/DocVersionInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/DocVersionInfoList.cs @@ -138,7 +138,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -158,7 +158,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -180,7 +180,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(FolderIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchFolderID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchFolderID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -201,7 +201,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -223,7 +223,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(FormatIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchFormatID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchFormatID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -244,7 +244,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -266,7 +266,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ItemIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchItemID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchItemID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -287,7 +287,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -348,8 +348,8 @@ namespace VEPROMS.CSLA.Library /// public partial class DocVersionInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private DocVersionInfo Item { get { return (DocVersionInfo) _Item;} } - public DocVersionInfoListPropertyDescriptor(DocVersionInfoList collection, int index):base(collection, index){;} + private DocVersionInfo Item { get { return (DocVersionInfo)_Item; } } + public DocVersionInfoListPropertyDescriptor(DocVersionInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -360,7 +360,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is DocVersionInfoList) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Document.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Document.cs index 2a2cfd80..9df92655 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Document.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Document.cs @@ -41,7 +41,7 @@ namespace VEPROMS.CSLA.Library { 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 #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (Document tmp in _AllList) { - _AllByPrimaryKey[tmp.DocID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.DocID.ToString())) + { + _AllByPrimaryKey[tmp.DocID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.DocID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (Document tmp in remove) @@ -81,7 +85,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = docID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -103,7 +107,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DocID",true); + CanReadProperty("DocID", true); return _DocID; } } @@ -113,13 +117,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("LibTitle",true); + CanReadProperty("LibTitle", true); return _LibTitle; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("LibTitle",true); + CanWriteProperty("LibTitle", true); if (value == null) value = string.Empty; if (_LibTitle != value) { @@ -137,13 +141,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DocContent",true); + CanReadProperty("DocContent", true); return _DocContent; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DocContent",true); + CanWriteProperty("DocContent", true); if (_DocContent != value) { _DocContent = value; @@ -160,13 +164,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DocAscii",true); + CanReadProperty("DocAscii", true); return _DocAscii; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DocAscii",true); + CanWriteProperty("DocAscii", true); if (value == null) value = string.Empty; if (_DocAscii != value) { @@ -181,13 +185,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -202,13 +206,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -222,13 +226,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -247,7 +251,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DocumentEntryCount",true); + CanReadProperty("DocumentEntryCount", true); return _DocumentEntryCount; } } @@ -261,21 +265,21 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DocumentEntries",true); - if(_DocumentEntryCount > 0 && _DocumentEntries == null) + CanReadProperty("DocumentEntries", true); + if (_DocumentEntryCount > 0 && _DocumentEntries == null) _DocumentEntries = DocumentEntries.GetByDocID(DocID); - else if(_DocumentEntries == null) + else if (_DocumentEntries == null) _DocumentEntries = DocumentEntries.New(); return _DocumentEntries; } } 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 { - 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 /// @@ -298,22 +302,23 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_DocumentEntries != null && (hasBrokenRules = _DocumentEntries.HasBrokenRules) != null) return hasBrokenRules; + if (_DocumentEntries != null && (hasBrokenRules = _DocumentEntries.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -430,14 +435,25 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _DocumentUnique = 0; + private int _MyDocumentUnique; + public int MyDocumentUnique + { + get { return _MyDocumentUnique; } + } protected Document() {/* require use of factory methods */ + _MyDocumentUnique = ++_DocumentUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(DocID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(DocID.ToString())) return; + List 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() { @@ -514,7 +530,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(docID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -593,7 +609,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Document.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.ReadData", GetHashCode()); try { _DocID = dr.GetInt32("DocID"); @@ -609,14 +625,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Document.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -647,7 +663,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Document.DataPortal_Fetch", ex); } @@ -668,13 +684,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Document.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Document.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -711,11 +727,11 @@ namespace VEPROMS.CSLA.Library MarkOld(); // update child objects 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) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Document.SQLInsert", ex); } @@ -723,7 +739,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -753,7 +769,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -761,7 +777,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Document.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -775,7 +791,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -784,7 +800,7 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { 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 { SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; @@ -819,7 +835,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -841,7 +857,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Document.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -869,7 +885,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -881,7 +897,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -897,7 +913,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Document.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Document.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Document.DataPortal_Delete", ex); } @@ -905,7 +921,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -920,7 +936,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -954,7 +970,7 @@ namespace VEPROMS.CSLA.Library } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -972,7 +988,7 @@ namespace VEPROMS.CSLA.Library } 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); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/DocumentEntries.cs b/PROMS/VEPROMS.CSLA.Library/Generated/DocumentEntries.cs index 351ec4bf..4485f12d 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/DocumentEntries.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/DocumentEntries.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public DocumentEntry Add(Entry myEntry) // One to Many { - DocumentEntry entry = DocumentEntry.New(myEntry); - this.Add(entry); - return entry; + DocumentEntry entry = DocumentEntry.New(myEntry); + this.Add(entry); + return entry; } public void Remove(Entry myEntry) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(DocumentEntry documentEntry in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (DocumentEntry documentEntry in this) if ((hasBrokenRules = documentEntry.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(DocIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocumentEntries.DataPortal_FetchDocID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentEntries.DataPortal_FetchDocID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class DocumentEntriesPropertyDescriptor : vlnListPropertyDescriptor { - private DocumentEntry Item { get { return (DocumentEntry) _Item;} } - public DocumentEntriesPropertyDescriptor(DocumentEntries collection, int index):base(collection, index){;} + private DocumentEntry Item { get { return (DocumentEntry)_Item; } } + public DocumentEntriesPropertyDescriptor(DocumentEntries collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is DocumentEntries) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/DocumentEntry.cs b/PROMS/VEPROMS.CSLA.Library/Generated/DocumentEntry.cs index 3d48b588..8b50b21b 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/DocumentEntry.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/DocumentEntry.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentID",true); + CanReadProperty("ContentID", true); if (_MyEntry != null) _ContentID = _MyEntry.ContentID; return _ContentID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyEntry",true); + CanReadProperty("MyEntry", true); if (_MyEntry == null && _ContentID != 0) _MyEntry = Entry.Get(_ContentID); return _MyEntry; } @@ -65,13 +65,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -85,13 +85,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -107,7 +107,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_Number",true); + CanReadProperty("Content_Number", true); return _Content_Number; } } @@ -117,7 +117,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_Text",true); + CanReadProperty("Content_Text", true); return _Content_Text; } } @@ -130,7 +130,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_Type",true); + CanReadProperty("Content_Type", true); return _Content_Type; } } @@ -140,7 +140,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_FormatID",true); + CanReadProperty("Content_FormatID", true); return _Content_FormatID; } } @@ -150,7 +150,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_Config",true); + CanReadProperty("Content_Config", true); return _Content_Config; } } @@ -160,7 +160,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_DTS",true); + CanReadProperty("Content_DTS", true); return _Content_DTS; } } @@ -170,7 +170,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_UserID",true); + CanReadProperty("Content_UserID", true); return _Content_UserID; } } @@ -195,22 +195,22 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -306,7 +306,7 @@ namespace VEPROMS.CSLA.Library // TODO: Add any initialization & defaults _DTS = _DocumentEntryExtension.DefaultDTS; _UserID = _DocumentEntryExtension.DefaultUserID; - _MyEntry = myEntry; + _MyEntry = myEntry; ValidationRules.CheckRules(); } internal DocumentEntry(SafeDataReader dr) @@ -318,7 +318,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocumentEntry.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentEntry.FetchDR", GetHashCode()); try { _ContentID = dr.GetInt32("ContentID"); @@ -335,7 +335,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/DocumentInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/DocumentInfo.cs index bfc0993f..7def3281 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/DocumentInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/DocumentInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (DocumentInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.DocID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.DocID.ToString())) + { + _AllByPrimaryKey[tmp.DocID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.DocID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (DocumentInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = docID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DocID",true); + CanReadProperty("DocID", true); return _DocID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("LibTitle",true); + CanReadProperty("LibTitle", true); return _LibTitle; } } @@ -108,7 +112,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DocContent",true); + CanReadProperty("DocContent", true); return _DocContent; } } @@ -121,7 +125,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DocAscii",true); + CanReadProperty("DocAscii", true); return _DocAscii; } } @@ -131,7 +135,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } } @@ -141,7 +145,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -151,7 +155,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } } @@ -164,7 +168,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DocumentEntryCount",true); + CanReadProperty("DocumentEntryCount", true); return _DocumentEntryCount; } } @@ -175,7 +179,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DocumentEntries",true); + CanReadProperty("DocumentEntries", true); if (_DocumentEntryCount < 0 || (_DocumentEntryCount > 0 && _DocumentEntries == null)) _DocumentEntries = EntryInfoList.GetByDocID(_DocID); if (_DocumentEntryCount < 0) @@ -185,7 +189,10 @@ namespace VEPROMS.CSLA.Library } 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 /// @@ -207,14 +214,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _DocumentInfoUnique = 0; + private int _MyDocumentInfoUnique; + public int MyDocumentInfoUnique + { + get { return _MyDocumentInfoUnique; } + } private DocumentInfo() {/* require use of factory methods */ + _MyDocumentInfoUnique = ++_DocumentInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(DocID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(DocID.ToString())) return; + List 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() { @@ -222,9 +240,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(Document tmp) { - DocumentInfo tmpInfo = GetExistingByPrimaryKey(tmp.DocID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.DocID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (DocumentInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(Document tmp) { @@ -247,7 +267,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(docID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -261,14 +281,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { ReadData(dr); } 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); } } @@ -285,7 +306,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocumentInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfo.ReadData", GetHashCode()); try { _DocID = dr.GetInt32("DocID"); @@ -299,14 +320,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("DocumentInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("DocumentInfo.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -334,7 +355,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("DocumentInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("DocumentInfo.DataPortal_Fetch", ex); } @@ -344,7 +365,7 @@ namespace VEPROMS.CSLA.Library #region extension DocumentInfoExtension _DocumentInfoExtension = new DocumentInfoExtension(); [Serializable()] - partial class DocumentInfoExtension : extensionBase {} + partial class DocumentInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/DocumentInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/DocumentInfoList.cs index d3515290..ff96c69d 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/DocumentInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/DocumentInfoList.cs @@ -96,7 +96,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocumentInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -116,7 +116,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -177,8 +177,8 @@ namespace VEPROMS.CSLA.Library /// public partial class DocumentInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private DocumentInfo Item { get { return (DocumentInfo) _Item;} } - public DocumentInfoListPropertyDescriptor(DocumentInfoList collection, int index):base(collection, index){;} + private DocumentInfo Item { get { return (DocumentInfo)_Item; } } + public DocumentInfoListPropertyDescriptor(DocumentInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -189,7 +189,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is DocumentInfoList) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Entry.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Entry.cs index 21241569..ff2a1df5 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Entry.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Entry.cs @@ -47,19 +47,23 @@ namespace VEPROMS.CSLA.Library foreach (Entry tmp in _RefreshEntries) { EntryInfo.Refresh(tmp); - if(tmp._MyDocument != null) DocumentInfo.Refresh(tmp._MyDocument); + if (tmp._MyDocument != null) DocumentInfo.Refresh(tmp._MyDocument); } } #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (Entry tmp in _AllList) { - _AllByPrimaryKey[tmp.ContentID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString())) + { + _AllByPrimaryKey[tmp.ContentID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (Entry tmp in remove) @@ -69,7 +73,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = contentID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -86,7 +90,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentID",true); + CanReadProperty("ContentID", true); if (_MyContent != null) _ContentID = _MyContent.ContentID; return _ContentID; } @@ -98,7 +102,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID); return _MyContent; } @@ -109,7 +113,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DocID",true); + CanReadProperty("DocID", true); if (_MyDocument != null) _DocID = _MyDocument.DocID; return _DocID; } @@ -120,14 +124,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyDocument",true); + CanReadProperty("MyDocument", true); if (_MyDocument == null && _DocID != 0) _MyDocument = Document.Get(_DocID); return _MyDocument; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyDocument",true); + CanWriteProperty("MyDocument", true); if (_MyDocument != value) { _MyDocument = value; @@ -141,13 +145,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -161,13 +165,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -179,11 +183,11 @@ namespace VEPROMS.CSLA.Library private byte[] _LastChanged = new byte[8];//timestamp 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 { - 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 /// @@ -206,22 +210,23 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_MyDocument != null && (hasBrokenRules = _MyDocument.HasBrokenRules) != null) return hasBrokenRules; + if (_MyDocument != null && (hasBrokenRules = _MyDocument.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -320,14 +325,25 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _EntryUnique = 0; + private int _MyEntryUnique; + public int MyEntryUnique + { + get { return _MyEntryUnique; } + } protected Entry() {/* require use of factory methods */ + _MyEntryUnique = ++_EntryUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(ContentID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString())) return; + List 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() { @@ -392,7 +408,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(contentID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -471,7 +487,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.ReadData", GetHashCode()); try { _ContentID = dr.GetInt32("ContentID"); @@ -483,14 +499,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Entry.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -518,7 +534,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Entry.DataPortal_Fetch", ex); } @@ -539,13 +555,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Entry.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -554,7 +570,7 @@ namespace VEPROMS.CSLA.Library if (!this.IsDirty) return; try { - if(_MyDocument != null) _MyDocument.Update(); + if (_MyDocument != null) _MyDocument.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; using (SqlCommand cm = cn.CreateCommand()) { @@ -576,11 +592,11 @@ namespace VEPROMS.CSLA.Library } MarkOld(); // update child objects - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.SQLInsert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.SQLInsert", GetHashCode()); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Entry.SQLInsert", ex); } @@ -588,7 +604,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -612,7 +628,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -620,7 +636,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -634,7 +650,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -643,10 +659,10 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { 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 { - if(_MyDocument != null) _MyDocument.Update(); + if (_MyDocument != null) _MyDocument.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; if (base.IsDirty) { @@ -675,7 +691,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.SQLUpdate", ex); _ErrorMessage = ex.Message; 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 (base.IsDirty) { - SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; - if (IsNew) - _LastChanged = Entry.Add(cn, content, MyDocument, _DTS, _UserID); - else - _LastChanged = Entry.Update(cn, content, MyDocument, _DTS, _UserID, ref _LastChanged); - MarkOld(); + SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; + if (IsNew) + _LastChanged = Entry.Add(cn, content, MyDocument, _DTS, _UserID); + else + _LastChanged = Entry.Update(cn, content, MyDocument, _DTS, _UserID, ref _LastChanged); + MarkOld(); } } [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -721,7 +737,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -733,7 +749,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -749,7 +765,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Entry.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Entry.DataPortal_Delete", ex); } @@ -757,7 +773,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -772,7 +788,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -806,7 +822,7 @@ namespace VEPROMS.CSLA.Library } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -824,7 +840,7 @@ namespace VEPROMS.CSLA.Library } 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); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/EntryInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/EntryInfo.cs index 27903e2c..2d5dae3c 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/EntryInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/EntryInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (EntryInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.ContentID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString())) + { + _AllByPrimaryKey[tmp.ContentID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (EntryInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = contentID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentID",true); + CanReadProperty("ContentID", true); if (_MyContent != null) _ContentID = _MyContent.ContentID; return _ContentID; } @@ -97,7 +101,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID); return _MyContent; } @@ -108,7 +112,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DocID",true); + CanReadProperty("DocID", true); if (_MyDocument != null) _DocID = _MyDocument.DocID; return _DocID; } @@ -119,7 +123,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyDocument",true); + CanReadProperty("MyDocument", true); if (_MyDocument == null && _DocID != 0) _MyDocument = DocumentInfo.Get(_DocID); return _MyDocument; } @@ -130,7 +134,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -140,7 +144,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } } @@ -164,14 +168,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _EntryInfoUnique = 0; + private int _MyEntryInfoUnique; + public int MyEntryInfoUnique + { + get { return _MyEntryInfoUnique; } + } private EntryInfo() {/* require use of factory methods */ + _MyEntryInfoUnique = ++_EntryInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(ContentID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString())) return; + List 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() { @@ -179,9 +194,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(Entry tmp) { - EntryInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.ContentID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (EntryInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(Entry tmp) { @@ -189,9 +206,9 @@ namespace VEPROMS.CSLA.Library { MyDocument.RefreshDocumentEntries(); // Update List for old 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; _UserID = tmp.UserID; _EntryInfoExtension.Refresh(this); @@ -201,9 +218,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(DocumentEntry tmp) { - EntryInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.ContentID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (EntryInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(DocumentEntry tmp) { @@ -224,7 +243,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(contentID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") { @@ -241,14 +260,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { ReadData(dr); } 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); } } @@ -265,7 +285,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] EntryInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.ReadData", GetHashCode()); try { _ContentID = dr.GetInt32("ContentID"); @@ -275,14 +295,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("EntryInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("EntryInfo.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -310,7 +330,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("EntryInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("EntryInfo.DataPortal_Fetch", ex); } @@ -320,7 +340,7 @@ namespace VEPROMS.CSLA.Library #region extension EntryInfoExtension _EntryInfoExtension = new EntryInfoExtension(); [Serializable()] - partial class EntryInfoExtension : extensionBase {} + partial class EntryInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/EntryInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/EntryInfoList.cs index f0dbeff7..4825d65b 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/EntryInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/EntryInfoList.cs @@ -124,7 +124,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] EntryInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -144,7 +144,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -166,7 +166,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ContentIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] EntryInfoList.DataPortal_FetchContentID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfoList.DataPortal_FetchContentID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -187,7 +187,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -209,7 +209,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(DocIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] EntryInfoList.DataPortal_FetchDocID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfoList.DataPortal_FetchDocID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -230,7 +230,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -291,8 +291,8 @@ namespace VEPROMS.CSLA.Library /// public partial class EntryInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private EntryInfo Item { get { return (EntryInfo) _Item;} } - public EntryInfoListPropertyDescriptor(EntryInfoList collection, int index):base(collection, index){;} + private EntryInfo Item { get { return (EntryInfo)_Item; } } + public EntryInfoListPropertyDescriptor(EntryInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -303,7 +303,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is EntryInfoList) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Folder.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Folder.cs index ebc8dc2a..6e64588d 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Folder.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Folder.cs @@ -42,14 +42,14 @@ namespace VEPROMS.CSLA.Library { foreach (FolderAssignment tmp in _FolderAssignments) { - if(tmp.IsDirty)refreshFolderAssignments.Add(tmp); + if (tmp.IsDirty) refreshFolderAssignments.Add(tmp); } } if (_FolderDocVersions != null && _FolderDocVersions.IsDirty) { foreach (FolderDocVersion tmp in _FolderDocVersions) { - if(tmp.IsDirty)refreshFolderDocVersions.Add(tmp); + if (tmp.IsDirty) refreshFolderDocVersions.Add(tmp); } } if (_ChildFolders != null && _ChildFolders.IsDirty) @@ -72,8 +72,8 @@ namespace VEPROMS.CSLA.Library foreach (Folder tmp in _RefreshFolders) { FolderInfo.Refresh(tmp); - if(tmp._MyConnection != null) ConnectionInfo.Refresh(tmp._MyConnection); - if(tmp._MyFormat != null) FormatInfo.Refresh(tmp._MyFormat); + if (tmp._MyConnection != null) ConnectionInfo.Refresh(tmp._MyConnection); + if (tmp._MyFormat != null) FormatInfo.Refresh(tmp._MyFormat); } foreach (FolderAssignment tmp in _RefreshFolderAssignments) { @@ -87,15 +87,20 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); - private static Dictionary _AllByParentID_Name = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); + private static Dictionary> _AllByParentID_Name = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (Folder tmp in _AllList) { - _AllByPrimaryKey[tmp.FolderID.ToString()]=tmp; // Primary Key - _AllByParentID_Name[tmp.ParentID.ToString() + "_" + tmp.Name.ToString()] = tmp; // Unique Index + if (!_AllByPrimaryKey.ContainsKey(tmp.FolderID.ToString())) + { + _AllByPrimaryKey[tmp.FolderID.ToString()] = new List(); // Add new list for PrimaryKey + _AllByParentID_Name[tmp.ParentID.ToString() + "_" + tmp.Name.ToString()] = new List(); // 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); } foreach (Folder tmp in remove) @@ -105,14 +110,14 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = folderID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } public static Folder GetExistingByParentID_Name(int parentID, string name) { ConvertListToDictionary(); 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; } #endregion @@ -134,7 +139,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderID",true); + CanReadProperty("FolderID", true); return _FolderID; } } @@ -144,7 +149,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ParentID",true); + CanReadProperty("ParentID", true); if (_MyParent != null) _ParentID = _MyParent.FolderID; return _ParentID; } @@ -155,14 +160,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyParent",true); + CanReadProperty("MyParent", true); if (_MyParent == null && _ParentID != _FolderID) _MyParent = Folder.Get(_ParentID); return _MyParent; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyParent",true); + CanWriteProperty("MyParent", true); if (_MyParent != value) { _MyParent = value; @@ -176,7 +181,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DBID",true); + CanReadProperty("DBID", true); if (_MyConnection != null) _DBID = _MyConnection.DBID; return _DBID; } @@ -187,14 +192,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyConnection",true); + CanReadProperty("MyConnection", true); if (_MyConnection == null && _DBID != 0) _MyConnection = Connection.Get(_DBID); return _MyConnection; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyConnection",true); + CanWriteProperty("MyConnection", true); if (_MyConnection != value) { _MyConnection = value; @@ -208,13 +213,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Name",true); + CanReadProperty("Name", true); return _Name; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Name",true); + CanWriteProperty("Name", true); if (value == null) value = string.Empty; if (_Name != value) { @@ -229,13 +234,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Title",true); + CanReadProperty("Title", true); return _Title; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Title",true); + CanWriteProperty("Title", true); if (value == null) value = string.Empty; if (_Title != value) { @@ -250,13 +255,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ShortName",true); + CanReadProperty("ShortName", true); return _ShortName; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("ShortName",true); + CanWriteProperty("ShortName", true); if (value == null) value = string.Empty; if (_ShortName != value) { @@ -271,7 +276,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatID",true); + CanReadProperty("FormatID", true); if (_MyFormat != null) _FormatID = _MyFormat.FormatID; return _FormatID; } @@ -282,18 +287,18 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFormat",true); + CanReadProperty("MyFormat", true); if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID); return _MyFormat; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyFormat",true); + CanWriteProperty("MyFormat", true); if (_MyFormat != value) { _MyFormat = value; - _FormatID = (value == null ? null : (int?) value.FormatID); + _FormatID = (value == null ? null : (int?)value.FormatID); PropertyHasChanged(); } } @@ -304,13 +309,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -325,13 +330,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -345,13 +350,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UsrID",true); + CanWriteProperty("UsrID", true); if (value == null) value = string.Empty; if (_UsrID != value) { @@ -370,7 +375,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderAssignmentCount",true); + CanReadProperty("FolderAssignmentCount", true); return _FolderAssignmentCount; } } @@ -384,10 +389,10 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderAssignments",true); - if(_FolderAssignmentCount > 0 && _FolderAssignments == null) + CanReadProperty("FolderAssignments", true); + if (_FolderAssignmentCount > 0 && _FolderAssignments == null) _FolderAssignments = FolderAssignments.GetByFolderID(FolderID); - else if(_FolderAssignments == null) + else if (_FolderAssignments == null) _FolderAssignments = FolderAssignments.New(); return _FolderAssignments; } @@ -401,7 +406,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderDocVersionCount",true); + CanReadProperty("FolderDocVersionCount", true); return _FolderDocVersionCount; } } @@ -415,10 +420,10 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderDocVersions",true); - if(_FolderDocVersionCount > 0 && _FolderDocVersions == null) + CanReadProperty("FolderDocVersions", true); + if (_FolderDocVersionCount > 0 && _FolderDocVersions == null) _FolderDocVersions = FolderDocVersions.GetByFolderID(FolderID); - else if(_FolderDocVersions == null) + else if (_FolderDocVersions == null) _FolderDocVersions = FolderDocVersions.New(); return _FolderDocVersions; } @@ -432,7 +437,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ChildFolderCount",true); + CanReadProperty("ChildFolderCount", true); return _ChildFolderCount; } } @@ -446,21 +451,21 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ChildFolders",true); - if(_ChildFolderCount > 0 && _ChildFolders == null) + CanReadProperty("ChildFolders", true); + if (_ChildFolderCount > 0 && _ChildFolders == null) _ChildFolders = ChildFolders.GetByParentID(FolderID); - else if(_ChildFolders == null) + else if (_ChildFolders == null) _ChildFolders = ChildFolders.New(); return _ChildFolders; } } 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 { - 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 /// @@ -483,26 +488,27 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_FolderAssignments != null && (hasBrokenRules = _FolderAssignments.HasBrokenRules) != null) return hasBrokenRules; - if (_FolderDocVersions != null && (hasBrokenRules = _FolderDocVersions.HasBrokenRules) != null) return hasBrokenRules; - if (_ChildFolders != null && (hasBrokenRules = _ChildFolders.HasBrokenRules) != null) return hasBrokenRules; - if (_MyConnection != null && (hasBrokenRules = _MyConnection.HasBrokenRules) != null) return hasBrokenRules; - if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; + if (_FolderAssignments != null && (hasBrokenRules = _FolderAssignments.HasBrokenRules) != null) return hasBrokenRules; + if (_FolderDocVersions != null && (hasBrokenRules = _FolderDocVersions.HasBrokenRules) != null) return hasBrokenRules; + if (_ChildFolders != null && (hasBrokenRules = _ChildFolders.HasBrokenRules) != null) return hasBrokenRules; + if (_MyConnection != null && (hasBrokenRules = _MyConnection.HasBrokenRules) != null) return hasBrokenRules; + if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -644,15 +650,29 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _FolderUnique = 0; + private int _MyFolderUnique; + public int MyFolderUnique + { + get { return _MyFolderUnique; } + } protected Folder() {/* require use of factory methods */ + _MyFolderUnique = ++_FolderUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(FolderID.ToString()); - _AllByParentID_Name.Remove(ParentID.ToString() + "_" + Name.ToString()); + if (!_AllByPrimaryKey.ContainsKey(FolderID.ToString())) return; + List 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() { @@ -743,7 +763,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(folderID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -762,8 +782,8 @@ namespace VEPROMS.CSLA.Library Folder tmp = GetExistingByParentID_Name(parentID, name); if (tmp == null) { - tmp=DataPortal.Fetch(new ParentID_NameCriteria(parentID, name)); - _AllList.Add(tmp); + tmp = DataPortal.Fetch(new ParentID_NameCriteria(parentID, name)); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -869,7 +889,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Folder.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.ReadData", GetHashCode()); try { _FolderID = dr.GetInt32("FolderID"); @@ -890,14 +910,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Folder.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -931,14 +951,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Folder.DataPortal_Fetch", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -967,7 +987,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Folder.DataPortal_Fetch", ex); } @@ -988,13 +1008,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Folder.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Folder.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -1003,8 +1023,8 @@ namespace VEPROMS.CSLA.Library if (!this.IsDirty) return; try { - if(_MyConnection != null) _MyConnection.Update(); - if(_MyFormat != null) _MyFormat.Update(); + if (_MyConnection != null) _MyConnection.Update(); + if (_MyFormat != null) _MyFormat.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; using (SqlCommand cm = cn.CreateCommand()) { @@ -1038,11 +1058,11 @@ namespace VEPROMS.CSLA.Library if (_FolderAssignments != null) _FolderAssignments.Update(this); if (_FolderDocVersions != null) _FolderDocVersions.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) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Folder.SQLInsert", ex); } @@ -1050,7 +1070,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Folder.Add", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.Add", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -1063,7 +1083,7 @@ namespace VEPROMS.CSLA.Library cm.Parameters.AddWithValue("@Name", name); cm.Parameters.AddWithValue("@Title", title); 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); if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts); cm.Parameters.AddWithValue("@UsrID", usrID); @@ -1083,7 +1103,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -1091,7 +1111,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Folder.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1105,7 +1125,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -1114,11 +1134,11 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { 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 { - if(_MyConnection != null) _MyConnection.Update(); - if(_MyFormat != null) _MyFormat.Update(); + if (_MyConnection != null) _MyConnection.Update(); + if (_MyFormat != null) _MyFormat.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; if (base.IsDirty) { @@ -1156,7 +1176,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -1190,7 +1210,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Folder.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -1204,7 +1224,7 @@ namespace VEPROMS.CSLA.Library cm.Parameters.AddWithValue("@Name", name); cm.Parameters.AddWithValue("@Title", title); 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); if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts); cm.Parameters.AddWithValue("@UsrID", usrID); @@ -1221,7 +1241,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -1233,7 +1253,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1249,7 +1269,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Folder.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Folder.DataPortal_Delete", ex); } @@ -1257,7 +1277,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -1272,7 +1292,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -1306,7 +1326,7 @@ namespace VEPROMS.CSLA.Library } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1324,7 +1344,7 @@ namespace VEPROMS.CSLA.Library } 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); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FolderAssignment.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FolderAssignment.cs index b381d1ec..1f75dc61 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FolderAssignment.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FolderAssignment.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("AID",true); + CanReadProperty("AID", true); if (_MyAssignment != null) _AID = _MyAssignment.AID; return _AID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyAssignment",true); + CanReadProperty("MyAssignment", true); if (_MyAssignment == null && _AID != 0) _MyAssignment = Assignment.Get(_AID); return _MyAssignment; } @@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GID",true); + CanReadProperty("GID", true); if (_MyGroup != null) _GID = _MyGroup.GID; return _GID; } @@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyGroup",true); + CanReadProperty("MyGroup", true); if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID); return _MyGroup; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyGroup",true); + CanWriteProperty("MyGroup", true); if (_MyGroup != value) { _MyGroup = value; @@ -97,7 +97,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RID",true); + CanReadProperty("RID", true); if (_MyRole != null) _RID = _MyRole.RID; return _RID; } @@ -108,14 +108,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyRole",true); + CanReadProperty("MyRole", true); if (_MyRole == null && _RID != 0) _MyRole = Role.Get(_RID); return _MyRole; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyRole",true); + CanWriteProperty("MyRole", true); if (_MyRole != value) { _MyRole = value; @@ -129,13 +129,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("StartDate",true); + CanReadProperty("StartDate", true); return _StartDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("StartDate",true); + CanWriteProperty("StartDate", true); if (value == null) value = string.Empty; _StartDate = value; try @@ -159,13 +159,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("EndDate",true); + CanReadProperty("EndDate", true); return _EndDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("EndDate",true); + CanWriteProperty("EndDate", true); if (value == null) value = string.Empty; _EndDate = value; try @@ -189,13 +189,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -209,13 +209,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UsrID",true); + CanWriteProperty("UsrID", true); if (value == null) value = string.Empty; if (_UsrID != value) { @@ -231,7 +231,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Group_GroupName",true); + CanReadProperty("Group_GroupName", true); return _Group_GroupName; } } @@ -241,7 +241,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Group_GroupType",true); + CanReadProperty("Group_GroupType", true); return _Group_GroupType; } } @@ -251,7 +251,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Group_Config",true); + CanReadProperty("Group_Config", true); return _Group_Config; } } @@ -261,7 +261,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Group_DTS",true); + CanReadProperty("Group_DTS", true); return _Group_DTS; } } @@ -271,7 +271,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Group_UsrID",true); + CanReadProperty("Group_UsrID", true); return _Group_UsrID; } } @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Role_Name",true); + CanReadProperty("Role_Name", true); return _Role_Name; } } @@ -291,7 +291,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Role_Title",true); + CanReadProperty("Role_Title", true); return _Role_Title; } } @@ -301,7 +301,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Role_DTS",true); + CanReadProperty("Role_DTS", true); return _Role_DTS; } } @@ -311,7 +311,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Role_UsrID",true); + CanReadProperty("Role_UsrID", true); return _Role_UsrID; } } @@ -344,24 +344,24 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules; - if (_MyRole != null && (hasBrokenRules = _MyRole.HasBrokenRules) != null) return hasBrokenRules; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules; + if (_MyRole != null && (hasBrokenRules = _MyRole.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -517,8 +517,8 @@ namespace VEPROMS.CSLA.Library _StartDate = _FolderAssignmentExtension.DefaultStartDate; _DTS = _FolderAssignmentExtension.DefaultDTS; _UsrID = _FolderAssignmentExtension.DefaultUsrID; - _MyGroup = myGroup; - _MyRole = myRole; + _MyGroup = myGroup; + _MyRole = myRole; ValidationRules.CheckRules(); } internal FolderAssignment(SafeDataReader dr) @@ -530,7 +530,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderAssignment.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderAssignment.FetchDR", GetHashCode()); try { _AID = dr.GetInt32("AID"); @@ -553,7 +553,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FolderAssignments.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FolderAssignments.cs index be5ff6b4..7184e3be 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FolderAssignments.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FolderAssignments.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public FolderAssignment Add(Group myGroup, Role myRole) // One to Many { - FolderAssignment assignment = FolderAssignment.New(myGroup, myRole); - this.Add(assignment); - return assignment; + FolderAssignment assignment = FolderAssignment.New(myGroup, myRole); + this.Add(assignment); + return assignment; } public void Remove(Assignment myAssignment) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(FolderAssignment folderAssignment in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (FolderAssignment folderAssignment in this) if ((hasBrokenRules = folderAssignment.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(FolderIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderAssignments.DataPortal_FetchFolderID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderAssignments.DataPortal_FetchFolderID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class FolderAssignmentsPropertyDescriptor : vlnListPropertyDescriptor { - private FolderAssignment Item { get { return (FolderAssignment) _Item;} } - public FolderAssignmentsPropertyDescriptor(FolderAssignments collection, int index):base(collection, index){;} + private FolderAssignment Item { get { return (FolderAssignment)_Item; } } + public FolderAssignmentsPropertyDescriptor(FolderAssignments collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is FolderAssignments) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FolderDocVersion.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FolderDocVersion.cs index d4e73d46..9f22af30 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FolderDocVersion.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FolderDocVersion.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("VersionID",true); + CanReadProperty("VersionID", true); if (_MyDocVersion != null) _VersionID = _MyDocVersion.VersionID; return _VersionID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyDocVersion",true); + CanReadProperty("MyDocVersion", true); if (_MyDocVersion == null && _VersionID != 0) _MyDocVersion = DocVersion.Get(_VersionID); return _MyDocVersion; } @@ -68,13 +68,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("VersionType",true); + CanReadProperty("VersionType", true); return _VersionType; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("VersionType",true); + CanWriteProperty("VersionType", true); if (_VersionType != value) { _VersionType = value; @@ -88,13 +88,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Name",true); + CanReadProperty("Name", true); return _Name; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Name",true); + CanWriteProperty("Name", true); if (value == null) value = string.Empty; if (_Name != value) { @@ -109,13 +109,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Title",true); + CanReadProperty("Title", true); return _Title; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Title",true); + CanWriteProperty("Title", true); if (value == null) value = string.Empty; if (_Title != value) { @@ -130,7 +130,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemID",true); + CanReadProperty("ItemID", true); if (_MyItem != null) _ItemID = _MyItem.ItemID; return _ItemID; } @@ -141,18 +141,18 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItem",true); + CanReadProperty("MyItem", true); if (_MyItem == null && _ItemID != null) _MyItem = Item.Get((int)_ItemID); return _MyItem; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyItem",true); + CanWriteProperty("MyItem", true); if (_MyItem != value) { _MyItem = value; - _ItemID = (value == null ? null : (int?) value.ItemID); + _ItemID = (value == null ? null : (int?)value.ItemID); PropertyHasChanged(); } } @@ -163,7 +163,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatID",true); + CanReadProperty("FormatID", true); if (_MyFormat != null) _FormatID = _MyFormat.FormatID; return _FormatID; } @@ -174,18 +174,18 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFormat",true); + CanReadProperty("MyFormat", true); if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID); return _MyFormat; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyFormat",true); + CanWriteProperty("MyFormat", true); if (_MyFormat != value) { _MyFormat = value; - _FormatID = (value == null ? null : (int?) value.FormatID); + _FormatID = (value == null ? null : (int?)value.FormatID); PropertyHasChanged(); } } @@ -196,13 +196,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -217,13 +217,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -237,13 +237,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -274,24 +274,24 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; - if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; + if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -412,7 +412,7 @@ namespace VEPROMS.CSLA.Library _VersionType = _FolderDocVersionExtension.DefaultVersionType; _DTS = _FolderDocVersionExtension.DefaultDTS; _UserID = _FolderDocVersionExtension.DefaultUserID; - _Name = name; + _Name = name; ValidationRules.CheckRules(); } internal FolderDocVersion(SafeDataReader dr) @@ -424,7 +424,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderDocVersion.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderDocVersion.FetchDR", GetHashCode()); try { _VersionID = dr.GetInt32("VersionID"); @@ -440,7 +440,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FolderDocVersions.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FolderDocVersions.cs index 2e9a58e2..8bfbdd5c 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FolderDocVersions.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FolderDocVersions.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public FolderDocVersion Add(string name) // One to Many { - FolderDocVersion docVersion = FolderDocVersion.New(name); - this.Add(docVersion); - return docVersion; + FolderDocVersion docVersion = FolderDocVersion.New(name); + this.Add(docVersion); + return docVersion; } public void Remove(DocVersion myDocVersion) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(FolderDocVersion folderDocVersion in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (FolderDocVersion folderDocVersion in this) if ((hasBrokenRules = folderDocVersion.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(FolderIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderDocVersions.DataPortal_FetchFolderID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderDocVersions.DataPortal_FetchFolderID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class FolderDocVersionsPropertyDescriptor : vlnListPropertyDescriptor { - private FolderDocVersion Item { get { return (FolderDocVersion) _Item;} } - public FolderDocVersionsPropertyDescriptor(FolderDocVersions collection, int index):base(collection, index){;} + private FolderDocVersion Item { get { return (FolderDocVersion)_Item; } } + public FolderDocVersionsPropertyDescriptor(FolderDocVersions collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is FolderDocVersions) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FolderInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FolderInfo.cs index b653c102..581ea051 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FolderInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FolderInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (FolderInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.FolderID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.FolderID.ToString())) + { + _AllByPrimaryKey[tmp.FolderID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.FolderID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (FolderInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = folderID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderID",true); + CanReadProperty("FolderID", true); return _FolderID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ParentID",true); + CanReadProperty("ParentID", true); if (_MyParent != null) _ParentID = _MyParent.FolderID; return _ParentID; } @@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyParent",true); + CanReadProperty("MyParent", true); if (_MyParent == null && _ParentID != _FolderID) _MyParent = FolderInfo.Get(_ParentID); return _MyParent; } @@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DBID",true); + CanReadProperty("DBID", true); if (_MyConnection != null) _DBID = _MyConnection.DBID; return _DBID; } @@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyConnection",true); + CanReadProperty("MyConnection", true); if (_MyConnection == null && _DBID != 0) _MyConnection = ConnectionInfo.Get(_DBID); return _MyConnection; } @@ -139,7 +143,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Name",true); + CanReadProperty("Name", true); return _Name; } } @@ -149,7 +153,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Title",true); + CanReadProperty("Title", true); return _Title; } } @@ -159,7 +163,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ShortName",true); + CanReadProperty("ShortName", true); return _ShortName; } } @@ -169,7 +173,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatID",true); + CanReadProperty("FormatID", true); if (_MyFormat != null) _FormatID = _MyFormat.FormatID; return _FormatID; } @@ -180,7 +184,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFormat",true); + CanReadProperty("MyFormat", true); if (_MyFormat == null && _FormatID != null) _MyFormat = FormatInfo.Get((int)_FormatID); return _MyFormat; } @@ -191,7 +195,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } } @@ -201,7 +205,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -211,7 +215,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } } @@ -224,7 +228,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderAssignmentCount",true); + CanReadProperty("FolderAssignmentCount", true); return _FolderAssignmentCount; } } @@ -235,7 +239,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderAssignments",true); + CanReadProperty("FolderAssignments", true); if (_FolderAssignmentCount < 0 || (_FolderAssignmentCount > 0 && _FolderAssignments == null)) _FolderAssignments = AssignmentInfoList.GetByFolderID(_FolderID); if (_FolderAssignmentCount < 0) @@ -245,7 +249,10 @@ namespace VEPROMS.CSLA.Library } 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; /// @@ -256,7 +263,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderDocVersionCount",true); + CanReadProperty("FolderDocVersionCount", true); return _FolderDocVersionCount; } } @@ -267,7 +274,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderDocVersions",true); + CanReadProperty("FolderDocVersions", true); if (_FolderDocVersionCount < 0 || (_FolderDocVersionCount > 0 && _FolderDocVersions == null)) _FolderDocVersions = DocVersionInfoList.GetByFolderID(_FolderID); if (_FolderDocVersionCount < 0) @@ -277,7 +284,10 @@ namespace VEPROMS.CSLA.Library } 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; /// @@ -288,7 +298,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ChildFolderCount",true); + CanReadProperty("ChildFolderCount", true); return _ChildFolderCount; } } @@ -299,7 +309,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ChildFolders",true); + CanReadProperty("ChildFolders", true); if (_ChildFolderCount < 0 || (_ChildFolderCount > 0 && _ChildFolders == null)) _ChildFolders = FolderInfoList.GetChildren(_FolderID); if (_ChildFolderCount < 0) @@ -309,7 +319,10 @@ namespace VEPROMS.CSLA.Library } 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 /// @@ -331,14 +344,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _FolderInfoUnique = 0; + private int _MyFolderInfoUnique; + public int MyFolderInfoUnique + { + get { return _MyFolderInfoUnique; } + } private FolderInfo() {/* require use of factory methods */ + _MyFolderInfoUnique = ++_FolderInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(FolderID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(FolderID.ToString())) return; + List 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() { @@ -346,9 +370,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(Folder tmp) { - FolderInfo tmpInfo = GetExistingByPrimaryKey(tmp.FolderID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.FolderID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (FolderInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(Folder tmp) { @@ -356,16 +382,16 @@ namespace VEPROMS.CSLA.Library { MyParent.RefreshChildFolders(); // Update List for old 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) { MyConnection.RefreshConnectionFolders(); // Update List for old 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; _Title = tmp.Title; _ShortName = tmp.ShortName; @@ -373,9 +399,9 @@ namespace VEPROMS.CSLA.Library { MyFormat.RefreshFormatFolders(); // Update List for old 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; _DTS = tmp.DTS; _UsrID = tmp.UsrID; @@ -387,9 +413,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(ConnectionFolder tmp) { - FolderInfo tmpInfo = GetExistingByPrimaryKey(tmp.FolderID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.FolderID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (FolderInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(ConnectionFolder tmp) { @@ -397,9 +425,9 @@ namespace VEPROMS.CSLA.Library { MyParent.RefreshChildFolders(); // Update List for old 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; _Title = tmp.Title; _ShortName = tmp.ShortName; @@ -407,9 +435,9 @@ namespace VEPROMS.CSLA.Library { MyFormat.RefreshFormatFolders(); // Update List for old 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; _DTS = tmp.DTS; _UsrID = tmp.UsrID; @@ -421,9 +449,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(FormatFolder tmp) { - FolderInfo tmpInfo = GetExistingByPrimaryKey(tmp.FolderID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.FolderID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (FolderInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(FormatFolder tmp) { @@ -431,16 +461,16 @@ namespace VEPROMS.CSLA.Library { MyParent.RefreshChildFolders(); // Update List for old 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) { MyConnection.RefreshConnectionFolders(); // Update List for old 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; _Title = tmp.Title; _ShortName = tmp.ShortName; @@ -463,7 +493,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(folderID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -477,14 +507,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { ReadData(dr); } 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); } } @@ -501,7 +532,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderInfo.ReadData", GetHashCode()); try { _FolderID = dr.GetInt32("FolderID"); @@ -520,14 +551,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("FolderInfo.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -555,7 +586,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("FolderInfo.DataPortal_Fetch", ex); } @@ -565,7 +596,7 @@ namespace VEPROMS.CSLA.Library #region extension FolderInfoExtension _FolderInfoExtension = new FolderInfoExtension(); [Serializable()] - partial class FolderInfoExtension : extensionBase {} + partial class FolderInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FolderInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FolderInfoList.cs index ab1c0c71..3239b29d 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FolderInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FolderInfoList.cs @@ -138,7 +138,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -158,7 +158,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -180,7 +180,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ParentIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfoList.DataPortal_FetchParentID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderInfoList.DataPortal_FetchParentID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -201,7 +201,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -223,7 +223,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(DBIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfoList.DataPortal_FetchDBID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderInfoList.DataPortal_FetchDBID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -244,7 +244,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -266,7 +266,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(FormatIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfoList.DataPortal_FetchFormatID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderInfoList.DataPortal_FetchFormatID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -287,7 +287,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -348,8 +348,8 @@ namespace VEPROMS.CSLA.Library /// public partial class FolderInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private FolderInfo Item { get { return (FolderInfo) _Item;} } - public FolderInfoListPropertyDescriptor(FolderInfoList collection, int index):base(collection, index){;} + private FolderInfo Item { get { return (FolderInfo)_Item; } } + public FolderInfoListPropertyDescriptor(FolderInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -360,7 +360,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is FolderInfoList) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Format.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Format.cs index b05ee2b3..e27da111 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Format.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Format.cs @@ -43,21 +43,21 @@ namespace VEPROMS.CSLA.Library { foreach (FormatContent tmp in _FormatContents) { - if(tmp.IsDirty)refreshFormatContents.Add(tmp); + if (tmp.IsDirty) refreshFormatContents.Add(tmp); } } if (_FormatDocVersions != null && _FormatDocVersions.IsDirty) { foreach (FormatDocVersion tmp in _FormatDocVersions) { - if(tmp.IsDirty)refreshFormatDocVersions.Add(tmp); + if (tmp.IsDirty) refreshFormatDocVersions.Add(tmp); } } if (_FormatFolders != null && _FormatFolders.IsDirty) { foreach (FormatFolder tmp in _FormatFolders) { - if(tmp.IsDirty)refreshFormatFolders.Add(tmp); + if (tmp.IsDirty) refreshFormatFolders.Add(tmp); } } if (_ChildFormats != null && _ChildFormats.IsDirty) @@ -98,15 +98,20 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); - private static Dictionary _AllByParentID_Name = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); + private static Dictionary> _AllByParentID_Name = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (Format tmp in _AllList) { - _AllByPrimaryKey[tmp.FormatID.ToString()]=tmp; // Primary Key - _AllByParentID_Name[tmp.ParentID.ToString() + "_" + tmp.Name.ToString()] = tmp; // Unique Index + if (!_AllByPrimaryKey.ContainsKey(tmp.FormatID.ToString())) + { + _AllByPrimaryKey[tmp.FormatID.ToString()] = new List(); // Add new list for PrimaryKey + _AllByParentID_Name[tmp.ParentID.ToString() + "_" + tmp.Name.ToString()] = new List(); // 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); } foreach (Format tmp in remove) @@ -116,14 +121,14 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = formatID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } public static Format GetExistingByParentID_Name(int parentID, string name) { ConvertListToDictionary(); 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; } #endregion @@ -145,7 +150,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatID",true); + CanReadProperty("FormatID", true); return _FormatID; } } @@ -155,7 +160,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ParentID",true); + CanReadProperty("ParentID", true); if (_MyParent != null) _ParentID = _MyParent.FormatID; return _ParentID; } @@ -166,14 +171,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyParent",true); + CanReadProperty("MyParent", true); if (_MyParent == null && _ParentID != _FormatID) _MyParent = Format.Get(_ParentID); return _MyParent; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyParent",true); + CanWriteProperty("MyParent", true); if (_MyParent != value) { _MyParent = value; @@ -187,13 +192,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Name",true); + CanReadProperty("Name", true); return _Name; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Name",true); + CanWriteProperty("Name", true); if (value == null) value = string.Empty; if (_Name != value) { @@ -208,13 +213,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Description",true); + CanReadProperty("Description", true); return _Description; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Description",true); + CanWriteProperty("Description", true); if (value == null) value = string.Empty; if (_Description != value) { @@ -229,13 +234,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Data",true); + CanReadProperty("Data", true); return _Data; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Data",true); + CanWriteProperty("Data", true); if (value == null) value = string.Empty; if (_Data != value) { @@ -250,13 +255,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GenMac",true); + CanReadProperty("GenMac", true); return _GenMac; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("GenMac",true); + CanWriteProperty("GenMac", true); if (value == null) value = string.Empty; if (_GenMac != value) { @@ -271,13 +276,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -291,13 +296,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -316,7 +321,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatContentCount",true); + CanReadProperty("FormatContentCount", true); return _FormatContentCount; } } @@ -330,10 +335,10 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatContents",true); - if(_FormatContentCount > 0 && _FormatContents == null) + CanReadProperty("FormatContents", true); + if (_FormatContentCount > 0 && _FormatContents == null) _FormatContents = FormatContents.GetByFormatID(FormatID); - else if(_FormatContents == null) + else if (_FormatContents == null) _FormatContents = FormatContents.New(); return _FormatContents; } @@ -347,7 +352,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatDocVersionCount",true); + CanReadProperty("FormatDocVersionCount", true); return _FormatDocVersionCount; } } @@ -361,10 +366,10 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatDocVersions",true); - if(_FormatDocVersionCount > 0 && _FormatDocVersions == null) + CanReadProperty("FormatDocVersions", true); + if (_FormatDocVersionCount > 0 && _FormatDocVersions == null) _FormatDocVersions = FormatDocVersions.GetByFormatID(FormatID); - else if(_FormatDocVersions == null) + else if (_FormatDocVersions == null) _FormatDocVersions = FormatDocVersions.New(); return _FormatDocVersions; } @@ -378,7 +383,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatFolderCount",true); + CanReadProperty("FormatFolderCount", true); return _FormatFolderCount; } } @@ -392,10 +397,10 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatFolders",true); - if(_FormatFolderCount > 0 && _FormatFolders == null) + CanReadProperty("FormatFolders", true); + if (_FormatFolderCount > 0 && _FormatFolders == null) _FormatFolders = FormatFolders.GetByFormatID(FormatID); - else if(_FormatFolders == null) + else if (_FormatFolders == null) _FormatFolders = FormatFolders.New(); return _FormatFolders; } @@ -409,7 +414,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ChildFormatCount",true); + CanReadProperty("ChildFormatCount", true); return _ChildFormatCount; } } @@ -423,21 +428,21 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ChildFormats",true); - if(_ChildFormatCount > 0 && _ChildFormats == null) + CanReadProperty("ChildFormats", true); + if (_ChildFormatCount > 0 && _ChildFormats == null) _ChildFormats = ChildFormats.GetByParentID(FormatID); - else if(_ChildFormats == null) + else if (_ChildFormats == null) _ChildFormats = ChildFormats.New(); return _ChildFormats; } } 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 { - 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 /// @@ -460,25 +465,26 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_FormatFolders != null && (hasBrokenRules = _FormatFolders.HasBrokenRules) != null) return hasBrokenRules; - if (_FormatContents != null && (hasBrokenRules = _FormatContents.HasBrokenRules) != null) return hasBrokenRules; - if (_FormatDocVersions != null && (hasBrokenRules = _FormatDocVersions.HasBrokenRules) != null) return hasBrokenRules; - if (_ChildFormats != null && (hasBrokenRules = _ChildFormats.HasBrokenRules) != null) return hasBrokenRules; + if (_FormatFolders != null && (hasBrokenRules = _FormatFolders.HasBrokenRules) != null) return hasBrokenRules; + if (_FormatContents != null && (hasBrokenRules = _FormatContents.HasBrokenRules) != null) return hasBrokenRules; + if (_FormatDocVersions != null && (hasBrokenRules = _FormatDocVersions.HasBrokenRules) != null) return hasBrokenRules; + if (_ChildFormats != null && (hasBrokenRules = _ChildFormats.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -607,15 +613,29 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _FormatUnique = 0; + private int _MyFormatUnique; + public int MyFormatUnique + { + get { return _MyFormatUnique; } + } protected Format() {/* require use of factory methods */ + _MyFormatUnique = ++_FormatUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(FormatID.ToString()); - _AllByParentID_Name.Remove(ParentID.ToString() + "_" + Name.ToString()); + if (!_AllByPrimaryKey.ContainsKey(FormatID.ToString())) return; + List 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() { @@ -702,7 +722,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(formatID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -721,8 +741,8 @@ namespace VEPROMS.CSLA.Library Format tmp = GetExistingByParentID_Name(parentID, name); if (tmp == null) { - tmp=DataPortal.Fetch(new ParentID_NameCriteria(parentID, name)); - _AllList.Add(tmp); + tmp = DataPortal.Fetch(new ParentID_NameCriteria(parentID, name)); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -827,7 +847,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Format.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.ReadData", GetHashCode()); try { _FormatID = dr.GetInt32("FormatID"); @@ -847,14 +867,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Format.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -891,14 +911,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Format.DataPortal_Fetch", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -927,7 +947,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Format.DataPortal_Fetch", ex); } @@ -948,13 +968,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Format.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Format.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -995,11 +1015,11 @@ namespace VEPROMS.CSLA.Library if (_FormatContents != null) _FormatContents.Update(this); if (_FormatDocVersions != null) _FormatDocVersions.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) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Format.SQLInsert", ex); } @@ -1007,7 +1027,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Format.Add", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.Add", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -1038,7 +1058,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -1046,7 +1066,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Format.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1060,7 +1080,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -1069,7 +1089,7 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { 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 { SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; @@ -1108,7 +1128,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -1143,7 +1163,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Format.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -1172,7 +1192,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -1184,7 +1204,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1200,7 +1220,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Format.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Format.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Format.DataPortal_Delete", ex); } @@ -1208,7 +1228,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -1223,7 +1243,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -1257,7 +1277,7 @@ namespace VEPROMS.CSLA.Library } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1275,7 +1295,7 @@ namespace VEPROMS.CSLA.Library } 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); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FormatContent.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FormatContent.cs index 87b8110e..8f5fb7f4 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FormatContent.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FormatContent.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentID",true); + CanReadProperty("ContentID", true); if (_MyContent != null) _ContentID = _MyContent.ContentID; return _ContentID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID); return _MyContent; } @@ -65,13 +65,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Number",true); + CanReadProperty("Number", true); return _Number; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Number",true); + CanWriteProperty("Number", true); if (value == null) value = string.Empty; if (_Number != value) { @@ -86,13 +86,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Text",true); + CanReadProperty("Text", true); return _Text; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Text",true); + CanWriteProperty("Text", true); if (value == null) value = string.Empty; if (_Text != value) { @@ -110,13 +110,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Type",true); + CanReadProperty("Type", true); return _Type; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Type",true); + CanWriteProperty("Type", true); if (_Type != value) { _Type = value; @@ -130,13 +130,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -151,13 +151,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -171,13 +171,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -208,22 +208,22 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -339,7 +339,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatContent.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatContent.FetchDR", GetHashCode()); try { _ContentID = dr.GetInt32("ContentID"); @@ -353,7 +353,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FormatContents.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FormatContents.cs index a631d507..9b957a92 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FormatContents.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FormatContents.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public FormatContent Add() // One to Many { - FormatContent content = FormatContent.New(); - this.Add(content); - return content; + FormatContent content = FormatContent.New(); + this.Add(content); + return content; } public void Remove(Content myContent) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(FormatContent formatContent in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (FormatContent formatContent in this) if ((hasBrokenRules = formatContent.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(FormatIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatContents.DataPortal_FetchFormatID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatContents.DataPortal_FetchFormatID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class FormatContentsPropertyDescriptor : vlnListPropertyDescriptor { - private FormatContent Item { get { return (FormatContent) _Item;} } - public FormatContentsPropertyDescriptor(FormatContents collection, int index):base(collection, index){;} + private FormatContent Item { get { return (FormatContent)_Item; } } + public FormatContentsPropertyDescriptor(FormatContents collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is FormatContents) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FormatDocVersion.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FormatDocVersion.cs index 36bd9752..aa2c1b74 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FormatDocVersion.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FormatDocVersion.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("VersionID",true); + CanReadProperty("VersionID", true); if (_MyDocVersion != null) _VersionID = _MyDocVersion.VersionID; return _VersionID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyDocVersion",true); + CanReadProperty("MyDocVersion", true); if (_MyDocVersion == null && _VersionID != 0) _MyDocVersion = DocVersion.Get(_VersionID); return _MyDocVersion; } @@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderID",true); + CanReadProperty("FolderID", true); if (_MyFolder != null) _FolderID = _MyFolder.FolderID; return _FolderID; } @@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFolder",true); + CanReadProperty("MyFolder", true); if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID); return _MyFolder; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyFolder",true); + CanWriteProperty("MyFolder", true); if (_MyFolder != value) { _MyFolder = value; @@ -100,13 +100,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("VersionType",true); + CanReadProperty("VersionType", true); return _VersionType; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("VersionType",true); + CanWriteProperty("VersionType", true); if (_VersionType != value) { _VersionType = value; @@ -120,13 +120,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Name",true); + CanReadProperty("Name", true); return _Name; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Name",true); + CanWriteProperty("Name", true); if (value == null) value = string.Empty; if (_Name != value) { @@ -141,13 +141,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Title",true); + CanReadProperty("Title", true); return _Title; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Title",true); + CanWriteProperty("Title", true); if (value == null) value = string.Empty; if (_Title != value) { @@ -162,7 +162,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemID",true); + CanReadProperty("ItemID", true); if (_MyItem != null) _ItemID = _MyItem.ItemID; return _ItemID; } @@ -173,18 +173,18 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItem",true); + CanReadProperty("MyItem", true); if (_MyItem == null && _ItemID != null) _MyItem = Item.Get((int)_ItemID); return _MyItem; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyItem",true); + CanWriteProperty("MyItem", true); if (_MyItem != value) { _MyItem = value; - _ItemID = (value == null ? null : (int?) value.ItemID); + _ItemID = (value == null ? null : (int?)value.ItemID); PropertyHasChanged(); } } @@ -195,13 +195,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -216,13 +216,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -236,13 +236,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -258,7 +258,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_ParentID",true); + CanReadProperty("Folder_ParentID", true); return _Folder_ParentID; } } @@ -268,7 +268,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_DBID",true); + CanReadProperty("Folder_DBID", true); return _Folder_DBID; } } @@ -278,7 +278,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_Name",true); + CanReadProperty("Folder_Name", true); return _Folder_Name; } } @@ -288,7 +288,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_Title",true); + CanReadProperty("Folder_Title", true); return _Folder_Title; } } @@ -298,7 +298,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_ShortName",true); + CanReadProperty("Folder_ShortName", true); return _Folder_ShortName; } } @@ -308,7 +308,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_FormatID",true); + CanReadProperty("Folder_FormatID", true); return _Folder_FormatID; } } @@ -318,7 +318,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_Config",true); + CanReadProperty("Folder_Config", true); return _Folder_Config; } } @@ -328,7 +328,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_DTS",true); + CanReadProperty("Folder_DTS", true); return _Folder_DTS; } } @@ -338,7 +338,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_UsrID",true); + CanReadProperty("Folder_UsrID", true); return _Folder_UsrID; } } @@ -371,24 +371,24 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; - if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; + if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -519,8 +519,8 @@ namespace VEPROMS.CSLA.Library _VersionType = _FormatDocVersionExtension.DefaultVersionType; _DTS = _FormatDocVersionExtension.DefaultDTS; _UserID = _FormatDocVersionExtension.DefaultUserID; - _MyFolder = myFolder; - _Name = name; + _MyFolder = myFolder; + _Name = name; ValidationRules.CheckRules(); } internal FormatDocVersion(SafeDataReader dr) @@ -532,7 +532,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatDocVersion.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatDocVersion.FetchDR", GetHashCode()); try { _VersionID = dr.GetInt32("VersionID"); @@ -557,7 +557,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FormatDocVersions.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FormatDocVersions.cs index 37e6c492..d51663f1 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FormatDocVersions.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FormatDocVersions.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public FormatDocVersion Add(Folder myFolder, string name) // One to Many { - FormatDocVersion docVersion = FormatDocVersion.New(myFolder, name); - this.Add(docVersion); - return docVersion; + FormatDocVersion docVersion = FormatDocVersion.New(myFolder, name); + this.Add(docVersion); + return docVersion; } public void Remove(DocVersion myDocVersion) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(FormatDocVersion formatDocVersion in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (FormatDocVersion formatDocVersion in this) if ((hasBrokenRules = formatDocVersion.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(FormatIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatDocVersions.DataPortal_FetchFormatID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatDocVersions.DataPortal_FetchFormatID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class FormatDocVersionsPropertyDescriptor : vlnListPropertyDescriptor { - private FormatDocVersion Item { get { return (FormatDocVersion) _Item;} } - public FormatDocVersionsPropertyDescriptor(FormatDocVersions collection, int index):base(collection, index){;} + private FormatDocVersion Item { get { return (FormatDocVersion)_Item; } } + public FormatDocVersionsPropertyDescriptor(FormatDocVersions collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is FormatDocVersions) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FormatFolder.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FormatFolder.cs index 11da4aa4..02d183b0 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FormatFolder.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FormatFolder.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderID",true); + CanReadProperty("FolderID", true); if (_MyFolder != null) _FolderID = _MyFolder.FolderID; return _FolderID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFolder",true); + CanReadProperty("MyFolder", true); if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID); return _MyFolder; } @@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ParentID",true); + CanReadProperty("ParentID", true); if (_MyParent != null) _ParentID = _MyParent.FolderID; return _ParentID; } @@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyParent",true); + CanReadProperty("MyParent", true); if (_MyParent == null && _ParentID != _FolderID) _MyParent = Folder.Get(_ParentID); return _MyParent; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyParent",true); + CanWriteProperty("MyParent", true); if (_MyParent != value) { _MyParent = value; @@ -97,7 +97,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DBID",true); + CanReadProperty("DBID", true); if (_MyConnection != null) _DBID = _MyConnection.DBID; return _DBID; } @@ -108,14 +108,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyConnection",true); + CanReadProperty("MyConnection", true); if (_MyConnection == null && _DBID != 0) _MyConnection = Connection.Get(_DBID); return _MyConnection; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyConnection",true); + CanWriteProperty("MyConnection", true); if (_MyConnection != value) { _MyConnection = value; @@ -129,13 +129,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Name",true); + CanReadProperty("Name", true); return _Name; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Name",true); + CanWriteProperty("Name", true); if (value == null) value = string.Empty; if (_Name != value) { @@ -150,13 +150,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Title",true); + CanReadProperty("Title", true); return _Title; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Title",true); + CanWriteProperty("Title", true); if (value == null) value = string.Empty; if (_Title != value) { @@ -171,13 +171,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ShortName",true); + CanReadProperty("ShortName", true); return _ShortName; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("ShortName",true); + CanWriteProperty("ShortName", true); if (value == null) value = string.Empty; if (_ShortName != value) { @@ -192,13 +192,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -213,13 +213,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -233,13 +233,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UsrID",true); + CanWriteProperty("UsrID", true); if (value == null) value = string.Empty; if (_UsrID != value) { @@ -255,7 +255,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Connection_Name",true); + CanReadProperty("Connection_Name", true); return _Connection_Name; } } @@ -265,7 +265,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Connection_Title",true); + CanReadProperty("Connection_Title", true); return _Connection_Title; } } @@ -275,7 +275,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Connection_ConnectionString",true); + CanReadProperty("Connection_ConnectionString", true); return _Connection_ConnectionString; } } @@ -288,7 +288,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Connection_ServerType",true); + CanReadProperty("Connection_ServerType", true); return _Connection_ServerType; } } @@ -298,7 +298,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Connection_Config",true); + CanReadProperty("Connection_Config", true); return _Connection_Config; } } @@ -308,7 +308,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Connection_DTS",true); + CanReadProperty("Connection_DTS", true); return _Connection_DTS; } } @@ -318,7 +318,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Connection_UsrID",true); + CanReadProperty("Connection_UsrID", true); return _Connection_UsrID; } } @@ -351,24 +351,24 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; - if (_MyConnection != null && (hasBrokenRules = _MyConnection.HasBrokenRules) != null) return hasBrokenRules; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; + if (_MyConnection != null && (hasBrokenRules = _MyConnection.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -516,9 +516,9 @@ namespace VEPROMS.CSLA.Library _DBID = _FormatFolderExtension.DefaultDBID; _DTS = _FormatFolderExtension.DefaultDTS; _UsrID = _FormatFolderExtension.DefaultUsrID; - _MyParent = myParent; - _Name = name; - _ShortName = shortName; + _MyParent = myParent; + _Name = name; + _ShortName = shortName; ValidationRules.CheckRules(); } internal FormatFolder(SafeDataReader dr) @@ -530,7 +530,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatFolder.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatFolder.FetchDR", GetHashCode()); try { _FolderID = dr.GetInt32("FolderID"); @@ -553,7 +553,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FormatFolders.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FormatFolders.cs index e74048d5..e7eae2c4 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FormatFolders.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FormatFolders.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public FormatFolder Add(Folder myParent, string name, string shortName) // One to Many { - FormatFolder folder = FormatFolder.New(myParent, name, shortName); - this.Add(folder); - return folder; + FormatFolder folder = FormatFolder.New(myParent, name, shortName); + this.Add(folder); + return folder; } public void Remove(Folder myFolder) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(FormatFolder formatFolder in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (FormatFolder formatFolder in this) if ((hasBrokenRules = formatFolder.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(FormatIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatFolders.DataPortal_FetchFormatID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatFolders.DataPortal_FetchFormatID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class FormatFoldersPropertyDescriptor : vlnListPropertyDescriptor { - private FormatFolder Item { get { return (FormatFolder) _Item;} } - public FormatFoldersPropertyDescriptor(FormatFolders collection, int index):base(collection, index){;} + private FormatFolder Item { get { return (FormatFolder)_Item; } } + public FormatFoldersPropertyDescriptor(FormatFolders collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is FormatFolders) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfo.cs index 7c67d175..81531686 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (FormatInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.FormatID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.FormatID.ToString())) + { + _AllByPrimaryKey[tmp.FormatID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.FormatID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (FormatInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = formatID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatID",true); + CanReadProperty("FormatID", true); return _FormatID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ParentID",true); + CanReadProperty("ParentID", true); if (_MyParent != null) _ParentID = _MyParent.FormatID; return _ParentID; } @@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyParent",true); + CanReadProperty("MyParent", true); if (_MyParent == null && _ParentID != _FormatID) _MyParent = FormatInfo.Get(_ParentID); return _MyParent; } @@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Name",true); + CanReadProperty("Name", true); return _Name; } } @@ -127,7 +131,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Description",true); + CanReadProperty("Description", true); return _Description; } } @@ -137,7 +141,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Data",true); + CanReadProperty("Data", true); return _Data; } } @@ -147,7 +151,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GenMac",true); + CanReadProperty("GenMac", true); return _GenMac; } } @@ -157,7 +161,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -167,7 +171,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } } @@ -180,7 +184,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatContentCount",true); + CanReadProperty("FormatContentCount", true); return _FormatContentCount; } } @@ -191,7 +195,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatContents",true); + CanReadProperty("FormatContents", true); if (_FormatContentCount < 0 || (_FormatContentCount > 0 && _FormatContents == null)) _FormatContents = ContentInfoList.GetByFormatID(_FormatID); if (_FormatContentCount < 0) @@ -201,7 +205,10 @@ namespace VEPROMS.CSLA.Library } 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; /// @@ -212,7 +219,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatDocVersionCount",true); + CanReadProperty("FormatDocVersionCount", true); return _FormatDocVersionCount; } } @@ -223,7 +230,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatDocVersions",true); + CanReadProperty("FormatDocVersions", true); if (_FormatDocVersionCount < 0 || (_FormatDocVersionCount > 0 && _FormatDocVersions == null)) _FormatDocVersions = DocVersionInfoList.GetByFormatID(_FormatID); if (_FormatDocVersionCount < 0) @@ -233,7 +240,10 @@ namespace VEPROMS.CSLA.Library } 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; /// @@ -244,7 +254,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatFolderCount",true); + CanReadProperty("FormatFolderCount", true); return _FormatFolderCount; } } @@ -255,7 +265,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatFolders",true); + CanReadProperty("FormatFolders", true); if (_FormatFolderCount < 0 || (_FormatFolderCount > 0 && _FormatFolders == null)) _FormatFolders = FolderInfoList.GetByFormatID(_FormatID); if (_FormatFolderCount < 0) @@ -265,7 +275,10 @@ namespace VEPROMS.CSLA.Library } 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; /// @@ -276,7 +289,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ChildFormatCount",true); + CanReadProperty("ChildFormatCount", true); return _ChildFormatCount; } } @@ -287,7 +300,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ChildFormats",true); + CanReadProperty("ChildFormats", true); if (_ChildFormatCount < 0 || (_ChildFormatCount > 0 && _ChildFormats == null)) _ChildFormats = FormatInfoList.GetChildren(_FormatID); if (_ChildFormatCount < 0) @@ -297,7 +310,10 @@ namespace VEPROMS.CSLA.Library } 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 /// @@ -319,14 +335,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _FormatInfoUnique = 0; + private int _MyFormatInfoUnique; + public int MyFormatInfoUnique + { + get { return _MyFormatInfoUnique; } + } private FormatInfo() {/* require use of factory methods */ + _MyFormatInfoUnique = ++_FormatInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(FormatID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(FormatID.ToString())) return; + List 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() { @@ -334,9 +361,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(Format tmp) { - FormatInfo tmpInfo = GetExistingByPrimaryKey(tmp.FormatID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.FormatID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (FormatInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(Format tmp) { @@ -344,9 +373,9 @@ namespace VEPROMS.CSLA.Library { MyParent.RefreshChildFormats(); // Update List for old 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; _Description = tmp.Description; _Data = tmp.Data; @@ -367,7 +396,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(formatID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -381,14 +410,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { ReadData(dr); } 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); } } @@ -405,7 +435,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfo.ReadData", GetHashCode()); try { _FormatID = dr.GetInt32("FormatID"); @@ -423,14 +453,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("FormatInfo.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -458,7 +488,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("FormatInfo.DataPortal_Fetch", ex); } @@ -468,7 +498,7 @@ namespace VEPROMS.CSLA.Library #region extension FormatInfoExtension _FormatInfoExtension = new FormatInfoExtension(); [Serializable()] - partial class FormatInfoExtension : extensionBase {} + partial class FormatInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfoList.cs index e304b8ea..e7ec741b 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfoList.cs @@ -110,7 +110,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -130,7 +130,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -152,7 +152,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ParentIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatInfoList.DataPortal_FetchParentID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfoList.DataPortal_FetchParentID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -173,7 +173,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -234,8 +234,8 @@ namespace VEPROMS.CSLA.Library /// public partial class FormatInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private FormatInfo Item { get { return (FormatInfo) _Item;} } - public FormatInfoListPropertyDescriptor(FormatInfoList collection, int index):base(collection, index){;} + private FormatInfo Item { get { return (FormatInfo)_Item; } } + public FormatInfoListPropertyDescriptor(FormatInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -246,7 +246,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is FormatInfoList) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Group.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Group.cs index 9d4e8589..9b2e6df6 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Group.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Group.cs @@ -42,14 +42,14 @@ namespace VEPROMS.CSLA.Library { foreach (GroupAssignment tmp in _GroupAssignments) { - if(tmp.IsDirty)refreshGroupAssignments.Add(tmp); + if (tmp.IsDirty) refreshGroupAssignments.Add(tmp); } } if (_GroupMemberships != null && _GroupMemberships.IsDirty) { 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 #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); - private static Dictionary _AllByGroupName = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); + private static Dictionary> _AllByGroupName = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (Group tmp in _AllList) { - _AllByPrimaryKey[tmp.GID.ToString()]=tmp; // Primary Key - _AllByGroupName[tmp.GroupName.ToString()] = tmp; // Unique Index + if (!_AllByPrimaryKey.ContainsKey(tmp.GID.ToString())) + { + _AllByPrimaryKey[tmp.GID.ToString()] = new List(); // Add new list for PrimaryKey + _AllByGroupName[tmp.GroupName.ToString()] = new List(); // 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); } foreach (Group tmp in remove) @@ -96,14 +101,14 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = gid.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } public static Group GetExistingByGroupName(string groupName) { ConvertListToDictionary(); string key = groupName.ToString(); - if (_AllByGroupName.ContainsKey(key)) return _AllByGroupName[key]; + if (_AllByGroupName.ContainsKey(key)) return _AllByGroupName[key][0]; return null; } #endregion @@ -125,7 +130,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GID",true); + CanReadProperty("GID", true); return _GID; } } @@ -135,13 +140,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GroupName",true); + CanReadProperty("GroupName", true); return _GroupName; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("GroupName",true); + CanWriteProperty("GroupName", true); if (value == null) value = string.Empty; if (_GroupName != value) { @@ -156,13 +161,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GroupType",true); + CanReadProperty("GroupType", true); return _GroupType; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("GroupType",true); + CanWriteProperty("GroupType", true); if (_GroupType != value) { _GroupType = value; @@ -176,13 +181,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -197,13 +202,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -217,13 +222,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UsrID",true); + CanWriteProperty("UsrID", true); if (value == null) value = string.Empty; if (_UsrID != value) { @@ -242,7 +247,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GroupAssignmentCount",true); + CanReadProperty("GroupAssignmentCount", true); return _GroupAssignmentCount; } } @@ -256,10 +261,10 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GroupAssignments",true); - if(_GroupAssignmentCount > 0 && _GroupAssignments == null) + CanReadProperty("GroupAssignments", true); + if (_GroupAssignmentCount > 0 && _GroupAssignments == null) _GroupAssignments = GroupAssignments.GetByGID(GID); - else if(_GroupAssignments == null) + else if (_GroupAssignments == null) _GroupAssignments = GroupAssignments.New(); return _GroupAssignments; } @@ -273,7 +278,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GroupMembershipCount",true); + CanReadProperty("GroupMembershipCount", true); return _GroupMembershipCount; } } @@ -287,21 +292,21 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GroupMemberships",true); - if(_GroupMembershipCount > 0 && _GroupMemberships == null) + CanReadProperty("GroupMemberships", true); + if (_GroupMembershipCount > 0 && _GroupMemberships == null) _GroupMemberships = GroupMemberships.GetByGID(GID); - else if(_GroupMemberships == null) + else if (_GroupMemberships == null) _GroupMemberships = GroupMemberships.New(); return _GroupMemberships; } } 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 { - 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 /// @@ -324,23 +329,24 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_GroupAssignments != null && (hasBrokenRules = _GroupAssignments.HasBrokenRules) != null) return hasBrokenRules; - if (_GroupMemberships != null && (hasBrokenRules = _GroupMemberships.HasBrokenRules) != null) return hasBrokenRules; + if (_GroupAssignments != null && (hasBrokenRules = _GroupAssignments.HasBrokenRules) != null) return hasBrokenRules; + if (_GroupMemberships != null && (hasBrokenRules = _GroupMemberships.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -455,15 +461,29 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _GroupUnique = 0; + private int _MyGroupUnique; + public int MyGroupUnique + { + get { return _MyGroupUnique; } + } protected Group() {/* require use of factory methods */ + _MyGroupUnique = ++_GroupUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(GID.ToString()); - _AllByGroupName.Remove(GroupName.ToString()); + if (!_AllByPrimaryKey.ContainsKey(GID.ToString())) return; + List 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() { @@ -544,7 +564,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(gid)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -563,8 +583,8 @@ namespace VEPROMS.CSLA.Library Group tmp = GetExistingByGroupName(groupName); if (tmp == null) { - tmp=DataPortal.Fetch(new GroupNameCriteria(groupName)); - _AllList.Add(tmp); + tmp = DataPortal.Fetch(new GroupNameCriteria(groupName)); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -654,7 +674,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Group.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.ReadData", GetHashCode()); try { _GID = dr.GetInt32("GID"); @@ -670,14 +690,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Group.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -711,14 +731,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Group.DataPortal_Fetch", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -746,7 +766,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Group.DataPortal_Fetch", ex); } @@ -767,13 +787,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Group.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Group.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -810,11 +830,11 @@ namespace VEPROMS.CSLA.Library // update child objects if (_GroupAssignments != null) _GroupAssignments.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) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Group.SQLInsert", ex); } @@ -822,7 +842,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -851,7 +871,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -859,7 +879,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Group.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -873,7 +893,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -882,7 +902,7 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { 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 { SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; @@ -917,7 +937,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -940,7 +960,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Group.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -967,7 +987,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -979,7 +999,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -995,7 +1015,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Group.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Group.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Group.DataPortal_Delete", ex); } @@ -1003,7 +1023,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -1018,7 +1038,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -1052,7 +1072,7 @@ namespace VEPROMS.CSLA.Library } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1070,7 +1090,7 @@ namespace VEPROMS.CSLA.Library } 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); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/GroupAssignment.cs b/PROMS/VEPROMS.CSLA.Library/Generated/GroupAssignment.cs index a6122546..5cf4f607 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/GroupAssignment.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/GroupAssignment.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("AID",true); + CanReadProperty("AID", true); if (_MyAssignment != null) _AID = _MyAssignment.AID; return _AID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyAssignment",true); + CanReadProperty("MyAssignment", true); if (_MyAssignment == null && _AID != 0) _MyAssignment = Assignment.Get(_AID); return _MyAssignment; } @@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RID",true); + CanReadProperty("RID", true); if (_MyRole != null) _RID = _MyRole.RID; return _RID; } @@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyRole",true); + CanReadProperty("MyRole", true); if (_MyRole == null && _RID != 0) _MyRole = Role.Get(_RID); return _MyRole; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyRole",true); + CanWriteProperty("MyRole", true); if (_MyRole != value) { _MyRole = value; @@ -97,7 +97,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderID",true); + CanReadProperty("FolderID", true); if (_MyFolder != null) _FolderID = _MyFolder.FolderID; return _FolderID; } @@ -108,14 +108,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFolder",true); + CanReadProperty("MyFolder", true); if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID); return _MyFolder; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyFolder",true); + CanWriteProperty("MyFolder", true); if (_MyFolder != value) { _MyFolder = value; @@ -129,13 +129,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("StartDate",true); + CanReadProperty("StartDate", true); return _StartDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("StartDate",true); + CanWriteProperty("StartDate", true); if (value == null) value = string.Empty; _StartDate = value; try @@ -159,13 +159,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("EndDate",true); + CanReadProperty("EndDate", true); return _EndDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("EndDate",true); + CanWriteProperty("EndDate", true); if (value == null) value = string.Empty; _EndDate = value; try @@ -189,13 +189,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -209,13 +209,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UsrID",true); + CanWriteProperty("UsrID", true); if (value == null) value = string.Empty; if (_UsrID != value) { @@ -231,7 +231,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_ParentID",true); + CanReadProperty("Folder_ParentID", true); return _Folder_ParentID; } } @@ -241,7 +241,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_DBID",true); + CanReadProperty("Folder_DBID", true); return _Folder_DBID; } } @@ -251,7 +251,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_Name",true); + CanReadProperty("Folder_Name", true); return _Folder_Name; } } @@ -261,7 +261,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_Title",true); + CanReadProperty("Folder_Title", true); return _Folder_Title; } } @@ -271,7 +271,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_ShortName",true); + CanReadProperty("Folder_ShortName", true); return _Folder_ShortName; } } @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_FormatID",true); + CanReadProperty("Folder_FormatID", true); return _Folder_FormatID; } } @@ -291,7 +291,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_Config",true); + CanReadProperty("Folder_Config", true); return _Folder_Config; } } @@ -301,7 +301,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_DTS",true); + CanReadProperty("Folder_DTS", true); return _Folder_DTS; } } @@ -311,7 +311,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_UsrID",true); + CanReadProperty("Folder_UsrID", true); return _Folder_UsrID; } } @@ -321,7 +321,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Role_Name",true); + CanReadProperty("Role_Name", true); return _Role_Name; } } @@ -331,7 +331,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Role_Title",true); + CanReadProperty("Role_Title", true); return _Role_Title; } } @@ -341,7 +341,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Role_DTS",true); + CanReadProperty("Role_DTS", true); return _Role_DTS; } } @@ -351,7 +351,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Role_UsrID",true); + CanReadProperty("Role_UsrID", true); return _Role_UsrID; } } @@ -384,24 +384,24 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - if (_MyRole != null && (hasBrokenRules = _MyRole.HasBrokenRules) != null) return hasBrokenRules; - if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + if (_MyRole != null && (hasBrokenRules = _MyRole.HasBrokenRules) != null) return hasBrokenRules; + if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -557,8 +557,8 @@ namespace VEPROMS.CSLA.Library _StartDate = _GroupAssignmentExtension.DefaultStartDate; _DTS = _GroupAssignmentExtension.DefaultDTS; _UsrID = _GroupAssignmentExtension.DefaultUsrID; - _MyRole = myRole; - _MyFolder = myFolder; + _MyRole = myRole; + _MyFolder = myFolder; ValidationRules.CheckRules(); } internal GroupAssignment(SafeDataReader dr) @@ -570,7 +570,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupAssignment.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupAssignment.FetchDR", GetHashCode()); try { _AID = dr.GetInt32("AID"); @@ -597,7 +597,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/GroupAssignments.cs b/PROMS/VEPROMS.CSLA.Library/Generated/GroupAssignments.cs index 0832fc25..03944b15 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/GroupAssignments.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/GroupAssignments.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public GroupAssignment Add(Role myRole, Folder myFolder) // One to Many { - GroupAssignment assignment = GroupAssignment.New(myRole, myFolder); - this.Add(assignment); - return assignment; + GroupAssignment assignment = GroupAssignment.New(myRole, myFolder); + this.Add(assignment); + return assignment; } public void Remove(Assignment myAssignment) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(GroupAssignment groupAssignment in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (GroupAssignment groupAssignment in this) if ((hasBrokenRules = groupAssignment.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(GIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupAssignments.DataPortal_FetchGID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupAssignments.DataPortal_FetchGID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class GroupAssignmentsPropertyDescriptor : vlnListPropertyDescriptor { - private GroupAssignment Item { get { return (GroupAssignment) _Item;} } - public GroupAssignmentsPropertyDescriptor(GroupAssignments collection, int index):base(collection, index){;} + private GroupAssignment Item { get { return (GroupAssignment)_Item; } } + public GroupAssignmentsPropertyDescriptor(GroupAssignments collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is GroupAssignments) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/GroupInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/GroupInfo.cs index 29d21e34..c9572e79 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/GroupInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/GroupInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (GroupInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.GID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.GID.ToString())) + { + _AllByPrimaryKey[tmp.GID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.GID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (GroupInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = gid.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GID",true); + CanReadProperty("GID", true); return _GID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GroupName",true); + CanReadProperty("GroupName", true); return _GroupName; } } @@ -105,7 +109,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GroupType",true); + CanReadProperty("GroupType", true); return _GroupType; } } @@ -115,7 +119,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } } @@ -125,7 +129,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -135,7 +139,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } } @@ -148,7 +152,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GroupAssignmentCount",true); + CanReadProperty("GroupAssignmentCount", true); return _GroupAssignmentCount; } } @@ -159,7 +163,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GroupAssignments",true); + CanReadProperty("GroupAssignments", true); if (_GroupAssignmentCount < 0 || (_GroupAssignmentCount > 0 && _GroupAssignments == null)) _GroupAssignments = AssignmentInfoList.GetByGID(_GID); if (_GroupAssignmentCount < 0) @@ -169,7 +173,10 @@ namespace VEPROMS.CSLA.Library } 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; /// @@ -180,7 +187,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GroupMembershipCount",true); + CanReadProperty("GroupMembershipCount", true); return _GroupMembershipCount; } } @@ -191,7 +198,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GroupMemberships",true); + CanReadProperty("GroupMemberships", true); if (_GroupMembershipCount < 0 || (_GroupMembershipCount > 0 && _GroupMemberships == null)) _GroupMemberships = MembershipInfoList.GetByGID(_GID); if (_GroupMembershipCount < 0) @@ -201,7 +208,10 @@ namespace VEPROMS.CSLA.Library } 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 /// @@ -223,14 +233,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _GroupInfoUnique = 0; + private int _MyGroupInfoUnique; + public int MyGroupInfoUnique + { + get { return _MyGroupInfoUnique; } + } private GroupInfo() {/* require use of factory methods */ + _MyGroupInfoUnique = ++_GroupInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(GID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(GID.ToString())) return; + List 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() { @@ -238,9 +259,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(Group tmp) { - GroupInfo tmpInfo = GetExistingByPrimaryKey(tmp.GID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.GID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (GroupInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(Group tmp) { @@ -262,7 +285,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(gid)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -276,14 +299,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { ReadData(dr); } 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); } } @@ -300,7 +324,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfo.ReadData", GetHashCode()); try { _GID = dr.GetInt32("GID"); @@ -314,14 +338,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("GroupInfo.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -349,7 +373,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("GroupInfo.DataPortal_Fetch", ex); } @@ -359,7 +383,7 @@ namespace VEPROMS.CSLA.Library #region extension GroupInfoExtension _GroupInfoExtension = new GroupInfoExtension(); [Serializable()] - partial class GroupInfoExtension : extensionBase {} + partial class GroupInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/GroupInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/GroupInfoList.cs index f85f2405..c90417fb 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/GroupInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/GroupInfoList.cs @@ -96,7 +96,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -116,7 +116,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -177,8 +177,8 @@ namespace VEPROMS.CSLA.Library /// public partial class GroupInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private GroupInfo Item { get { return (GroupInfo) _Item;} } - public GroupInfoListPropertyDescriptor(GroupInfoList collection, int index):base(collection, index){;} + private GroupInfo Item { get { return (GroupInfo)_Item; } } + public GroupInfoListPropertyDescriptor(GroupInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -189,7 +189,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is GroupInfoList) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/GroupMembership.cs b/PROMS/VEPROMS.CSLA.Library/Generated/GroupMembership.cs index 5458b7c2..c7c3966b 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/GroupMembership.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/GroupMembership.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UGID",true); + CanReadProperty("UGID", true); if (_MyMembership != null) _UGID = _MyMembership.UGID; return _UGID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyMembership",true); + CanReadProperty("MyMembership", true); if (_MyMembership == null && _UGID != 0) _MyMembership = Membership.Get(_UGID); return _MyMembership; } @@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UID",true); + CanReadProperty("UID", true); if (_MyUser != null) _UID = _MyUser.UID; return _UID; } @@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyUser",true); + CanReadProperty("MyUser", true); if (_MyUser == null && _UID != 0) _MyUser = User.Get(_UID); return _MyUser; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyUser",true); + CanWriteProperty("MyUser", true); if (_MyUser != value) { _MyUser = value; @@ -97,13 +97,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("StartDate",true); + CanReadProperty("StartDate", true); return _StartDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("StartDate",true); + CanWriteProperty("StartDate", true); if (value == null) value = string.Empty; _StartDate = value; try @@ -127,13 +127,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("EndDate",true); + CanReadProperty("EndDate", true); return _EndDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("EndDate",true); + CanWriteProperty("EndDate", true); if (value == null) value = string.Empty; _EndDate = value; try @@ -157,13 +157,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -178,13 +178,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -198,13 +198,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UsrID",true); + CanWriteProperty("UsrID", true); if (value == null) value = string.Empty; if (_UsrID != value) { @@ -220,7 +220,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("User_UserID",true); + CanReadProperty("User_UserID", true); return _User_UserID; } } @@ -230,7 +230,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("User_FirstName",true); + CanReadProperty("User_FirstName", true); return _User_FirstName; } } @@ -240,7 +240,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("User_MiddleName",true); + CanReadProperty("User_MiddleName", true); return _User_MiddleName; } } @@ -250,7 +250,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("User_LastName",true); + CanReadProperty("User_LastName", true); return _User_LastName; } } @@ -260,7 +260,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("User_Suffix",true); + CanReadProperty("User_Suffix", true); return _User_Suffix; } } @@ -270,7 +270,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("User_CourtesyTitle",true); + CanReadProperty("User_CourtesyTitle", true); return _User_CourtesyTitle; } } @@ -280,7 +280,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("User_PhoneNumber",true); + CanReadProperty("User_PhoneNumber", true); return _User_PhoneNumber; } } @@ -290,7 +290,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("User_CFGName",true); + CanReadProperty("User_CFGName", true); return _User_CFGName; } } @@ -300,7 +300,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("User_UserLogin",true); + CanReadProperty("User_UserLogin", true); return _User_UserLogin; } } @@ -310,7 +310,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("User_UserName",true); + CanReadProperty("User_UserName", true); return _User_UserName; } } @@ -320,7 +320,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("User_Config",true); + CanReadProperty("User_Config", true); return _User_Config; } } @@ -330,7 +330,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("User_DTS",true); + CanReadProperty("User_DTS", true); return _User_DTS; } } @@ -340,7 +340,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("User_UsrID",true); + CanReadProperty("User_UsrID", true); return _User_UsrID; } } @@ -373,23 +373,23 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - if (_MyUser != null && (hasBrokenRules = _MyUser.HasBrokenRules) != null) return hasBrokenRules; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + if (_MyUser != null && (hasBrokenRules = _MyUser.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -538,7 +538,7 @@ namespace VEPROMS.CSLA.Library _StartDate = _GroupMembershipExtension.DefaultStartDate; _DTS = _GroupMembershipExtension.DefaultDTS; _UsrID = _GroupMembershipExtension.DefaultUsrID; - _MyUser = myUser; + _MyUser = myUser; ValidationRules.CheckRules(); } internal GroupMembership(SafeDataReader dr) @@ -550,7 +550,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupMembership.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupMembership.FetchDR", GetHashCode()); try { _UGID = dr.GetInt32("UGID"); @@ -577,7 +577,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/GroupMemberships.cs b/PROMS/VEPROMS.CSLA.Library/Generated/GroupMemberships.cs index c1931e05..8de03e73 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/GroupMemberships.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/GroupMemberships.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public GroupMembership Add(User myUser) // One to Many { - GroupMembership membership = GroupMembership.New(myUser); - this.Add(membership); - return membership; + GroupMembership membership = GroupMembership.New(myUser); + this.Add(membership); + return membership; } public void Remove(Membership myMembership) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(GroupMembership groupMembership in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (GroupMembership groupMembership in this) if ((hasBrokenRules = groupMembership.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(GIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupMemberships.DataPortal_FetchGID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupMemberships.DataPortal_FetchGID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class GroupMembershipsPropertyDescriptor : vlnListPropertyDescriptor { - private GroupMembership Item { get { return (GroupMembership) _Item;} } - public GroupMembershipsPropertyDescriptor(GroupMemberships collection, int index):base(collection, index){;} + private GroupMembership Item { get { return (GroupMembership)_Item; } } + public GroupMembershipsPropertyDescriptor(GroupMemberships collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is GroupMemberships) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Item.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Item.cs index b49b8abd..6251646d 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Item.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Item.cs @@ -45,14 +45,14 @@ namespace VEPROMS.CSLA.Library { foreach (ItemAnnotation tmp in _ItemAnnotations) { - if(tmp.IsDirty)refreshItemAnnotations.Add(tmp); + if (tmp.IsDirty) refreshItemAnnotations.Add(tmp); } } if (_ItemDocVersions != null && _ItemDocVersions.IsDirty) { foreach (ItemDocVersion tmp in _ItemDocVersions) { - if(tmp.IsDirty)refreshItemDocVersions.Add(tmp); + if (tmp.IsDirty) refreshItemDocVersions.Add(tmp); } } if (_NextItems != null && _NextItems.IsDirty) @@ -66,21 +66,21 @@ namespace VEPROMS.CSLA.Library { foreach (ItemPart tmp in _ItemParts) { - if(tmp.IsDirty)refreshItemParts.Add(tmp); + if (tmp.IsDirty) refreshItemParts.Add(tmp); } } if (_ItemTransitions_RangeID != null && _ItemTransitions_RangeID.IsDirty) { foreach (ItemTransition_RangeID tmp in _ItemTransitions_RangeID) { - if(tmp.IsDirty)refreshItemTransitions_RangeID.Add(tmp); + if (tmp.IsDirty) refreshItemTransitions_RangeID.Add(tmp); } } if (_ItemTransitions_ToID != null && _ItemTransitions_ToID.IsDirty) { foreach (ItemTransition_ToID tmp in _ItemTransitions_ToID) { - if(tmp.IsDirty)refreshItemTransitions_ToID.Add(tmp); + if (tmp.IsDirty) refreshItemTransitions_ToID.Add(tmp); } } } @@ -99,7 +99,7 @@ namespace VEPROMS.CSLA.Library foreach (Item tmp in _RefreshItems) { ItemInfo.Refresh(tmp); - if(tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent); + if (tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent); } foreach (ItemAnnotation tmp in _RefreshItemAnnotations) { @@ -125,13 +125,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (Item tmp in _AllList) { - _AllByPrimaryKey[tmp.ItemID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.ItemID.ToString())) + { + _AllByPrimaryKey[tmp.ItemID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.ItemID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (Item tmp in remove) @@ -141,7 +145,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = itemID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -163,7 +167,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemID",true); + CanReadProperty("ItemID", true); return _ItemID; } } @@ -173,7 +177,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("PreviousID",true); + CanReadProperty("PreviousID", true); if (_MyPrevious != null) _PreviousID = _MyPrevious.ItemID; return _PreviousID; } @@ -184,18 +188,18 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyPrevious",true); + CanReadProperty("MyPrevious", true); if (_MyPrevious == null && _PreviousID != null) _MyPrevious = Item.Get((int)_PreviousID); return _MyPrevious; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyPrevious",true); + CanWriteProperty("MyPrevious", true); if (_MyPrevious != value) { _MyPrevious = value; - _PreviousID = (value == null ? null : (int?) value.ItemID); + _PreviousID = (value == null ? null : (int?)value.ItemID); PropertyHasChanged(); } } @@ -206,7 +210,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentID",true); + CanReadProperty("ContentID", true); if (_MyContent != null) _ContentID = _MyContent.ContentID; return _ContentID; } @@ -217,14 +221,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID); return _MyContent; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyContent",true); + CanWriteProperty("MyContent", true); if (_MyContent != value) { _MyContent = value; @@ -238,13 +242,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -258,13 +262,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -283,7 +287,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemAnnotationCount",true); + CanReadProperty("ItemAnnotationCount", true); return _ItemAnnotationCount; } } @@ -297,10 +301,10 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemAnnotations",true); - if(_ItemAnnotationCount > 0 && _ItemAnnotations == null) + CanReadProperty("ItemAnnotations", true); + if (_ItemAnnotationCount > 0 && _ItemAnnotations == null) _ItemAnnotations = ItemAnnotations.GetByItemID(ItemID); - else if(_ItemAnnotations == null) + else if (_ItemAnnotations == null) _ItemAnnotations = ItemAnnotations.New(); return _ItemAnnotations; } @@ -314,7 +318,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemDocVersionCount",true); + CanReadProperty("ItemDocVersionCount", true); return _ItemDocVersionCount; } } @@ -328,10 +332,10 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemDocVersions",true); - if(_ItemDocVersionCount > 0 && _ItemDocVersions == null) + CanReadProperty("ItemDocVersions", true); + if (_ItemDocVersionCount > 0 && _ItemDocVersions == null) _ItemDocVersions = ItemDocVersions.GetByItemID(ItemID); - else if(_ItemDocVersions == null) + else if (_ItemDocVersions == null) _ItemDocVersions = ItemDocVersions.New(); return _ItemDocVersions; } @@ -345,7 +349,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("NextItemCount",true); + CanReadProperty("NextItemCount", true); return _NextItemCount; } } @@ -359,10 +363,10 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("NextItems",true); - if(_NextItemCount > 0 && _NextItems == null) + CanReadProperty("NextItems", true); + if (_NextItemCount > 0 && _NextItems == null) _NextItems = NextItems.GetByPreviousID(ItemID); - else if(_NextItems == null) + else if (_NextItems == null) _NextItems = NextItems.New(); return _NextItems; } @@ -376,7 +380,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemPartCount",true); + CanReadProperty("ItemPartCount", true); return _ItemPartCount; } } @@ -390,10 +394,10 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemParts",true); - if(_ItemPartCount > 0 && _ItemParts == null) + CanReadProperty("ItemParts", true); + if (_ItemPartCount > 0 && _ItemParts == null) _ItemParts = ItemParts.GetByItemID(ItemID); - else if(_ItemParts == null) + else if (_ItemParts == null) _ItemParts = ItemParts.New(); return _ItemParts; } @@ -407,7 +411,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemTransition_RangeIDCount",true); + CanReadProperty("ItemTransition_RangeIDCount", true); return _ItemTransition_RangeIDCount; } } @@ -421,10 +425,10 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemTransitions_RangeID",true); - if(_ItemTransition_RangeIDCount > 0 && _ItemTransitions_RangeID == null) + CanReadProperty("ItemTransitions_RangeID", true); + if (_ItemTransition_RangeIDCount > 0 && _ItemTransitions_RangeID == null) _ItemTransitions_RangeID = ItemTransitions_RangeID.GetByRangeID(ItemID); - else if(_ItemTransitions_RangeID == null) + else if (_ItemTransitions_RangeID == null) _ItemTransitions_RangeID = ItemTransitions_RangeID.New(); return _ItemTransitions_RangeID; } @@ -438,7 +442,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemTransition_ToIDCount",true); + CanReadProperty("ItemTransition_ToIDCount", true); return _ItemTransition_ToIDCount; } } @@ -452,21 +456,21 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemTransitions_ToID",true); - if(_ItemTransition_ToIDCount > 0 && _ItemTransitions_ToID == null) + CanReadProperty("ItemTransitions_ToID", true); + if (_ItemTransition_ToIDCount > 0 && _ItemTransitions_ToID == null) _ItemTransitions_ToID = ItemTransitions_ToID.GetByToID(ItemID); - else if(_ItemTransitions_ToID == null) + else if (_ItemTransitions_ToID == null) _ItemTransitions_ToID = ItemTransitions_ToID.New(); return _ItemTransitions_ToID; } } public override bool IsDirty { - get { return base.IsDirty || (_ItemAnnotations == null? false : _ItemAnnotations.IsDirty) || (_ItemDocVersions == null? false : _ItemDocVersions.IsDirty) || (_NextItems == null? false : _NextItems.IsDirty) || (_ItemParts == null? false : _ItemParts.IsDirty) || (_ItemTransitions_RangeID == null? false : _ItemTransitions_RangeID.IsDirty) || (_ItemTransitions_ToID == null? false : _ItemTransitions_ToID.IsDirty) || (_MyContent == null? false : _MyContent.IsDirty); } + get { return base.IsDirty || (_ItemAnnotations == null ? false : _ItemAnnotations.IsDirty) || (_ItemDocVersions == null ? false : _ItemDocVersions.IsDirty) || (_NextItems == null ? false : _NextItems.IsDirty) || (_ItemParts == null ? false : _ItemParts.IsDirty) || (_ItemTransitions_RangeID == null ? false : _ItemTransitions_RangeID.IsDirty) || (_ItemTransitions_ToID == null ? false : _ItemTransitions_ToID.IsDirty) || (_MyContent == null ? false : _MyContent.IsDirty); } } public override bool IsValid { - get { return (IsNew && !IsDirty ? true : base.IsValid) && (_ItemAnnotations == null? true : _ItemAnnotations.IsValid) && (_ItemDocVersions == null? true : _ItemDocVersions.IsValid) && (_NextItems == null? true : _NextItems.IsValid) && (_ItemParts == null? true : _ItemParts.IsValid) && (_ItemTransitions_RangeID == null? true : _ItemTransitions_RangeID.IsValid) && (_ItemTransitions_ToID == null? true : _ItemTransitions_ToID.IsValid) && (_MyContent == null? true : _MyContent.IsValid); } + get { return (IsNew && !IsDirty ? true : base.IsValid) && (_ItemAnnotations == null ? true : _ItemAnnotations.IsValid) && (_ItemDocVersions == null ? true : _ItemDocVersions.IsValid) && (_NextItems == null ? true : _NextItems.IsValid) && (_ItemParts == null ? true : _ItemParts.IsValid) && (_ItemTransitions_RangeID == null ? true : _ItemTransitions_RangeID.IsValid) && (_ItemTransitions_ToID == null ? true : _ItemTransitions_ToID.IsValid) && (_MyContent == null ? true : _MyContent.IsValid); } } // TODO: Replace base Item.ToString function as necessary /// @@ -489,28 +493,29 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_ItemAnnotations != null && (hasBrokenRules = _ItemAnnotations.HasBrokenRules) != null) return hasBrokenRules; - if (_ItemDocVersions != null && (hasBrokenRules = _ItemDocVersions.HasBrokenRules) != null) return hasBrokenRules; - if (_NextItems != null && (hasBrokenRules = _NextItems.HasBrokenRules) != null) return hasBrokenRules; - if (_ItemParts != null && (hasBrokenRules = _ItemParts.HasBrokenRules) != null) return hasBrokenRules; - if (_ItemTransitions_RangeID != null && (hasBrokenRules = _ItemTransitions_RangeID.HasBrokenRules) != null) return hasBrokenRules; - if (_ItemTransitions_ToID != null && (hasBrokenRules = _ItemTransitions_ToID.HasBrokenRules) != null) return hasBrokenRules; - if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules; + if (_ItemAnnotations != null && (hasBrokenRules = _ItemAnnotations.HasBrokenRules) != null) return hasBrokenRules; + if (_ItemDocVersions != null && (hasBrokenRules = _ItemDocVersions.HasBrokenRules) != null) return hasBrokenRules; + if (_NextItems != null && (hasBrokenRules = _NextItems.HasBrokenRules) != null) return hasBrokenRules; + if (_ItemParts != null && (hasBrokenRules = _ItemParts.HasBrokenRules) != null) return hasBrokenRules; + if (_ItemTransitions_RangeID != null && (hasBrokenRules = _ItemTransitions_RangeID.HasBrokenRules) != null) return hasBrokenRules; + if (_ItemTransitions_ToID != null && (hasBrokenRules = _ItemTransitions_ToID.HasBrokenRules) != null) return hasBrokenRules; + if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -629,14 +634,25 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _ItemUnique = 0; + private int _MyItemUnique; + public int MyItemUnique + { + get { return _MyItemUnique; } + } protected Item() {/* require use of factory methods */ + _MyItemUnique = ++_ItemUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(ItemID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(ItemID.ToString())) return; + List listItem = _AllByPrimaryKey[ItemID.ToString()]; // Get the list of items + listItem.Remove(this); // Remove the item from the list + if (listItem.Count == 0) //If there are no items left in the list + _AllByPrimaryKey.Remove(ItemID.ToString()); // remove the list } public static Item New() { @@ -715,7 +731,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(itemID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -804,7 +820,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.ReadData", GetHashCode()); try { _ItemID = dr.GetInt32("ItemID"); @@ -823,14 +839,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Item.ReadData", ex); } } private void DataPortal_Fetch(PKCriteria criteria) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -873,7 +889,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Item.DataPortal_Fetch", ex); } @@ -894,13 +910,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Item.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -909,7 +925,7 @@ namespace VEPROMS.CSLA.Library if (!this.IsDirty) return; try { - if(_MyContent != null) _MyContent.Update(); + if (_MyContent != null) _MyContent.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; using (SqlCommand cm = cn.CreateCommand()) { @@ -941,11 +957,11 @@ namespace VEPROMS.CSLA.Library if (_ItemParts != null) _ItemParts.Update(this); if (_ItemTransitions_RangeID != null) _ItemTransitions_RangeID.Update(this); if (_ItemTransitions_ToID != null) _ItemTransitions_ToID.Update(this); - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.SQLInsert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.SQLInsert", GetHashCode()); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Item.SQLInsert", ex); } @@ -953,7 +969,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] public static byte[] Add(SqlConnection cn, ref int itemID, Item myPrevious, Content myContent, DateTime dts, string userID) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.Add", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.Add", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -961,7 +977,7 @@ namespace VEPROMS.CSLA.Library cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "addItem"; // Input All Fields - Except Calculated Columns - if(myPrevious != null)cm.Parameters.AddWithValue("@PreviousID", myPrevious.ItemID); + if (myPrevious != null) cm.Parameters.AddWithValue("@PreviousID", myPrevious.ItemID); cm.Parameters.AddWithValue("@ContentID", myContent.ContentID); if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts); cm.Parameters.AddWithValue("@UserID", userID); @@ -981,7 +997,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.Add", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.Add", ex); throw new DbCslaException("Item.Add", ex); } } @@ -989,7 +1005,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1003,7 +1019,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -1012,10 +1028,10 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.SQLUpdate", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.SQLUpdate", GetHashCode()); try { - if(_MyContent != null) _MyContent.Update(); + if (_MyContent != null) _MyContent.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; if (base.IsDirty) { @@ -1051,7 +1067,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -1088,7 +1104,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] public static byte[] Update(SqlConnection cn, ref int itemID, Item myPrevious, Content myContent, DateTime dts, string userID, ref byte[] lastChanged) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -1097,7 +1113,7 @@ namespace VEPROMS.CSLA.Library cm.CommandText = "updateItem"; // Input All Fields - Except Calculated Columns cm.Parameters.AddWithValue("@ItemID", itemID); - if(myPrevious != null)cm.Parameters.AddWithValue("@PreviousID", myPrevious.ItemID); + if (myPrevious != null) cm.Parameters.AddWithValue("@PreviousID", myPrevious.ItemID); cm.Parameters.AddWithValue("@ContentID", myContent.ContentID); if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts); cm.Parameters.AddWithValue("@UserID", userID); @@ -1114,7 +1130,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.Update", ex); throw new DbCslaException("Item.Update", ex); } } @@ -1126,7 +1142,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] private void DataPortal_Delete(PKCriteria criteria) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.DataPortal_Delete", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.DataPortal_Delete", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1142,7 +1158,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Item.DataPortal_Delete", ex); } @@ -1150,7 +1166,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] public static void Remove(SqlConnection cn, int itemID) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.Remove", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.Remove", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -1165,7 +1181,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.Remove", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.Remove", ex); throw new DbCslaException("Item.Remove", ex); } } @@ -1199,7 +1215,7 @@ namespace VEPROMS.CSLA.Library } protected override void DataPortal_Execute() { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Item.DataPortal_Execute", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.DataPortal_Execute", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1217,7 +1233,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Item.DataPortal_Execute", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.DataPortal_Execute", ex); throw new DbCslaException("Item.DataPortal_Execute", ex); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ItemAnnotation.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ItemAnnotation.cs index a6645e8a..c1d21322 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ItemAnnotation.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ItemAnnotation.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("AnnotationID",true); + CanReadProperty("AnnotationID", true); if (_MyAnnotation != null) _AnnotationID = _MyAnnotation.AnnotationID; return _AnnotationID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyAnnotation",true); + CanReadProperty("MyAnnotation", true); if (_MyAnnotation == null && _AnnotationID != 0) _MyAnnotation = Annotation.Get(_AnnotationID); return _MyAnnotation; } @@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TypeID",true); + CanReadProperty("TypeID", true); if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID; return _TypeID; } @@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyAnnotationType",true); + CanReadProperty("MyAnnotationType", true); if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationType.Get(_TypeID); return _MyAnnotationType; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyAnnotationType",true); + CanWriteProperty("MyAnnotationType", true); if (_MyAnnotationType != value) { _MyAnnotationType = value; @@ -97,13 +97,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RtfText",true); + CanReadProperty("RtfText", true); return _RtfText; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("RtfText",true); + CanWriteProperty("RtfText", true); if (value == null) value = string.Empty; if (_RtfText != value) { @@ -118,13 +118,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("SearchText",true); + CanReadProperty("SearchText", true); return _SearchText; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("SearchText",true); + CanWriteProperty("SearchText", true); if (value == null) value = string.Empty; if (_SearchText != value) { @@ -139,13 +139,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -160,13 +160,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -180,13 +180,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -202,7 +202,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("AnnotationType_Name",true); + CanReadProperty("AnnotationType_Name", true); return _AnnotationType_Name; } } @@ -212,7 +212,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("AnnotationType_Config",true); + CanReadProperty("AnnotationType_Config", true); return _AnnotationType_Config; } } @@ -222,7 +222,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("AnnotationType_DTS",true); + CanReadProperty("AnnotationType_DTS", true); return _AnnotationType_DTS; } } @@ -232,7 +232,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("AnnotationType_UserID",true); + CanReadProperty("AnnotationType_UserID", true); return _AnnotationType_UserID; } } @@ -265,23 +265,23 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - if (_MyAnnotationType != null && (hasBrokenRules = _MyAnnotationType.HasBrokenRules) != null) return hasBrokenRules; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + if (_MyAnnotationType != null && (hasBrokenRules = _MyAnnotationType.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -404,7 +404,7 @@ namespace VEPROMS.CSLA.Library // TODO: Add any initialization & defaults _DTS = _ItemAnnotationExtension.DefaultDTS; _UserID = _ItemAnnotationExtension.DefaultUserID; - _MyAnnotationType = myAnnotationType; + _MyAnnotationType = myAnnotationType; ValidationRules.CheckRules(); } internal ItemAnnotation(SafeDataReader dr) @@ -416,7 +416,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemAnnotation.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAnnotation.FetchDR", GetHashCode()); try { _AnnotationID = dr.GetInt32("AnnotationID"); @@ -434,7 +434,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ItemAnnotations.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ItemAnnotations.cs index 6d0549dd..6a595bc4 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ItemAnnotations.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ItemAnnotations.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public ItemAnnotation Add(AnnotationType myAnnotationType) // One to Many { - ItemAnnotation annotation = ItemAnnotation.New(myAnnotationType); - this.Add(annotation); - return annotation; + ItemAnnotation annotation = ItemAnnotation.New(myAnnotationType); + this.Add(annotation); + return annotation; } public void Remove(Annotation myAnnotation) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(ItemAnnotation itemAnnotation in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (ItemAnnotation itemAnnotation in this) if ((hasBrokenRules = itemAnnotation.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ItemIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemAnnotations.DataPortal_FetchItemID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAnnotations.DataPortal_FetchItemID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class ItemAnnotationsPropertyDescriptor : vlnListPropertyDescriptor { - private ItemAnnotation Item { get { return (ItemAnnotation) _Item;} } - public ItemAnnotationsPropertyDescriptor(ItemAnnotations collection, int index):base(collection, index){;} + private ItemAnnotation Item { get { return (ItemAnnotation)_Item; } } + public ItemAnnotationsPropertyDescriptor(ItemAnnotations collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is ItemAnnotations) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ItemDocVersion.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ItemDocVersion.cs index 231cf34b..d6e40d34 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ItemDocVersion.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ItemDocVersion.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("VersionID",true); + CanReadProperty("VersionID", true); if (_MyDocVersion != null) _VersionID = _MyDocVersion.VersionID; return _VersionID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyDocVersion",true); + CanReadProperty("MyDocVersion", true); if (_MyDocVersion == null && _VersionID != 0) _MyDocVersion = DocVersion.Get(_VersionID); return _MyDocVersion; } @@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderID",true); + CanReadProperty("FolderID", true); if (_MyFolder != null) _FolderID = _MyFolder.FolderID; return _FolderID; } @@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFolder",true); + CanReadProperty("MyFolder", true); if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID); return _MyFolder; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyFolder",true); + CanWriteProperty("MyFolder", true); if (_MyFolder != value) { _MyFolder = value; @@ -100,13 +100,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("VersionType",true); + CanReadProperty("VersionType", true); return _VersionType; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("VersionType",true); + CanWriteProperty("VersionType", true); if (_VersionType != value) { _VersionType = value; @@ -120,13 +120,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Name",true); + CanReadProperty("Name", true); return _Name; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Name",true); + CanWriteProperty("Name", true); if (value == null) value = string.Empty; if (_Name != value) { @@ -141,13 +141,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Title",true); + CanReadProperty("Title", true); return _Title; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Title",true); + CanWriteProperty("Title", true); if (value == null) value = string.Empty; if (_Title != value) { @@ -162,7 +162,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FormatID",true); + CanReadProperty("FormatID", true); if (_MyFormat != null) _FormatID = _MyFormat.FormatID; return _FormatID; } @@ -173,18 +173,18 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFormat",true); + CanReadProperty("MyFormat", true); if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID); return _MyFormat; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyFormat",true); + CanWriteProperty("MyFormat", true); if (_MyFormat != value) { _MyFormat = value; - _FormatID = (value == null ? null : (int?) value.FormatID); + _FormatID = (value == null ? null : (int?)value.FormatID); PropertyHasChanged(); } } @@ -195,13 +195,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -216,13 +216,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -236,13 +236,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -258,7 +258,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_ParentID",true); + CanReadProperty("Folder_ParentID", true); return _Folder_ParentID; } } @@ -268,7 +268,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_DBID",true); + CanReadProperty("Folder_DBID", true); return _Folder_DBID; } } @@ -278,7 +278,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_Name",true); + CanReadProperty("Folder_Name", true); return _Folder_Name; } } @@ -288,7 +288,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_Title",true); + CanReadProperty("Folder_Title", true); return _Folder_Title; } } @@ -298,7 +298,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_ShortName",true); + CanReadProperty("Folder_ShortName", true); return _Folder_ShortName; } } @@ -308,7 +308,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_FormatID",true); + CanReadProperty("Folder_FormatID", true); return _Folder_FormatID; } } @@ -318,7 +318,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_Config",true); + CanReadProperty("Folder_Config", true); return _Folder_Config; } } @@ -328,7 +328,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_DTS",true); + CanReadProperty("Folder_DTS", true); return _Folder_DTS; } } @@ -338,7 +338,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_UsrID",true); + CanReadProperty("Folder_UsrID", true); return _Folder_UsrID; } } @@ -371,24 +371,24 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; - if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; + if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -519,8 +519,8 @@ namespace VEPROMS.CSLA.Library _VersionType = _ItemDocVersionExtension.DefaultVersionType; _DTS = _ItemDocVersionExtension.DefaultDTS; _UserID = _ItemDocVersionExtension.DefaultUserID; - _MyFolder = myFolder; - _Name = name; + _MyFolder = myFolder; + _Name = name; ValidationRules.CheckRules(); } internal ItemDocVersion(SafeDataReader dr) @@ -532,7 +532,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemDocVersion.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemDocVersion.FetchDR", GetHashCode()); try { _VersionID = dr.GetInt32("VersionID"); @@ -557,7 +557,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ItemDocVersions.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ItemDocVersions.cs index 94d61b7b..bc9e6e1d 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ItemDocVersions.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ItemDocVersions.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public ItemDocVersion Add(Folder myFolder, string name) // One to Many { - ItemDocVersion docVersion = ItemDocVersion.New(myFolder, name); - this.Add(docVersion); - return docVersion; + ItemDocVersion docVersion = ItemDocVersion.New(myFolder, name); + this.Add(docVersion); + return docVersion; } public void Remove(DocVersion myDocVersion) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(ItemDocVersion itemDocVersion in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (ItemDocVersion itemDocVersion in this) if ((hasBrokenRules = itemDocVersion.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ItemIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemDocVersions.DataPortal_FetchItemID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemDocVersions.DataPortal_FetchItemID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class ItemDocVersionsPropertyDescriptor : vlnListPropertyDescriptor { - private ItemDocVersion Item { get { return (ItemDocVersion) _Item;} } - public ItemDocVersionsPropertyDescriptor(ItemDocVersions collection, int index):base(collection, index){;} + private ItemDocVersion Item { get { return (ItemDocVersion)_Item; } } + public ItemDocVersionsPropertyDescriptor(ItemDocVersions collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is ItemDocVersions) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfo.cs index 47225864..9c48585d 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (ItemInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.ItemID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.ItemID.ToString())) + { + _AllByPrimaryKey[tmp.ItemID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.ItemID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (ItemInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = itemID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemID",true); + CanReadProperty("ItemID", true); return _ItemID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("PreviousID",true); + CanReadProperty("PreviousID", true); if (_MyPrevious != null) _PreviousID = _MyPrevious.ItemID; return _PreviousID; } @@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyPrevious",true); + CanReadProperty("MyPrevious", true); if (_MyPrevious == null && _PreviousID != null) _MyPrevious = ItemInfo.Get((int)_PreviousID); return _MyPrevious; } @@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentID",true); + CanReadProperty("ContentID", true); if (_MyContent != null) _ContentID = _MyContent.ContentID; return _ContentID; } @@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID); return _MyContent; } @@ -139,7 +143,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -149,7 +153,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } } @@ -162,7 +166,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemAnnotationCount",true); + CanReadProperty("ItemAnnotationCount", true); return _ItemAnnotationCount; } } @@ -173,7 +177,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemAnnotations",true); + CanReadProperty("ItemAnnotations", true); if (_ItemAnnotationCount < 0 || (_ItemAnnotationCount > 0 && _ItemAnnotations == null)) _ItemAnnotations = AnnotationInfoList.GetByItemID(_ItemID); if (_ItemAnnotationCount < 0) @@ -183,7 +187,10 @@ namespace VEPROMS.CSLA.Library } 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; /// @@ -194,7 +201,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemDocVersionCount",true); + CanReadProperty("ItemDocVersionCount", true); return _ItemDocVersionCount; } } @@ -205,7 +212,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemDocVersions",true); + CanReadProperty("ItemDocVersions", true); if (_ItemDocVersionCount < 0 || (_ItemDocVersionCount > 0 && _ItemDocVersions == null)) _ItemDocVersions = DocVersionInfoList.GetByItemID(_ItemID); if (_ItemDocVersionCount < 0) @@ -215,7 +222,10 @@ namespace VEPROMS.CSLA.Library } 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; /// @@ -226,7 +236,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("NextItemCount",true); + CanReadProperty("NextItemCount", true); return _NextItemCount; } } @@ -237,7 +247,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("NextItems",true); + CanReadProperty("NextItems", true); if (_NextItemCount < 0 || (_NextItemCount > 0 && _NextItems == null)) _NextItems = ItemInfoList.GetNext(_ItemID); if (_NextItemCount < 0) @@ -247,7 +257,10 @@ namespace VEPROMS.CSLA.Library } 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; /// @@ -258,7 +271,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemPartCount",true); + CanReadProperty("ItemPartCount", true); return _ItemPartCount; } } @@ -269,7 +282,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemParts",true); + CanReadProperty("ItemParts", true); if (_ItemPartCount < 0 || (_ItemPartCount > 0 && _ItemParts == null)) _ItemParts = PartInfoList.GetByItemID(_ItemID); if (_ItemPartCount < 0) @@ -279,7 +292,10 @@ namespace VEPROMS.CSLA.Library } 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; /// @@ -290,7 +306,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemTransition_RangeIDCount",true); + CanReadProperty("ItemTransition_RangeIDCount", true); return _ItemTransition_RangeIDCount; } } @@ -301,7 +317,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemTransitions_RangeID",true); + CanReadProperty("ItemTransitions_RangeID", true); if (_ItemTransition_RangeIDCount < 0 || (_ItemTransition_RangeIDCount > 0 && _ItemTransitions_RangeID == null)) _ItemTransitions_RangeID = TransitionInfoList.GetByRangeID(_ItemID); if (_ItemTransition_RangeIDCount < 0) @@ -311,7 +327,10 @@ namespace VEPROMS.CSLA.Library } 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; /// @@ -322,7 +341,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemTransition_ToIDCount",true); + CanReadProperty("ItemTransition_ToIDCount", true); return _ItemTransition_ToIDCount; } } @@ -333,7 +352,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemTransitions_ToID",true); + CanReadProperty("ItemTransitions_ToID", true); if (_ItemTransition_ToIDCount < 0 || (_ItemTransition_ToIDCount > 0 && _ItemTransitions_ToID == null)) _ItemTransitions_ToID = TransitionInfoList.GetByToID(_ItemID); if (_ItemTransition_ToIDCount < 0) @@ -343,7 +362,10 @@ namespace VEPROMS.CSLA.Library } 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 /// @@ -365,14 +387,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _ItemInfoUnique = 0; + private int _MyItemInfoUnique; + public int MyItemInfoUnique + { + get { return _MyItemInfoUnique; } + } private ItemInfo() {/* require use of factory methods */ + _MyItemInfoUnique = ++_ItemInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(ItemID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(ItemID.ToString())) return; + List 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() { @@ -380,9 +413,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(Item tmp) { - ItemInfo tmpInfo = GetExistingByPrimaryKey(tmp.ItemID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.ItemID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (ItemInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(Item tmp) { @@ -390,16 +425,16 @@ namespace VEPROMS.CSLA.Library { MyPrevious.RefreshNextItems(); // Update List for old 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) { MyContent.RefreshContentItems(); // Update List for old 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; _UserID = tmp.UserID; _ItemInfoExtension.Refresh(this); @@ -409,9 +444,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(ContentItem tmp) { - ItemInfo tmpInfo = GetExistingByPrimaryKey(tmp.ItemID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.ItemID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (ItemInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(ContentItem tmp) { @@ -419,9 +456,9 @@ namespace VEPROMS.CSLA.Library { MyPrevious.RefreshNextItems(); // Update List for old 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; _UserID = tmp.UserID; _ItemInfoExtension.Refresh(this); @@ -439,7 +476,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(itemID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -453,14 +490,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { ReadData(dr); } 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); } } @@ -477,7 +515,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.ReadData", GetHashCode()); try { _ItemID = dr.GetInt32("ItemID"); @@ -494,14 +532,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ItemInfo.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -529,7 +567,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ItemInfo.DataPortal_Fetch", ex); } @@ -539,7 +577,7 @@ namespace VEPROMS.CSLA.Library #region extension ItemInfoExtension _ItemInfoExtension = new ItemInfoExtension(); [Serializable()] - partial class ItemInfoExtension : extensionBase {} + partial class ItemInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfoList.cs index a97b353e..9797584e 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfoList.cs @@ -124,7 +124,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -144,7 +144,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -166,7 +166,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(PreviousIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_FetchPreviousID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_FetchPreviousID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -187,7 +187,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -209,7 +209,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ContentIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_FetchContentID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_FetchContentID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -230,7 +230,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -291,8 +291,8 @@ namespace VEPROMS.CSLA.Library /// public partial class ItemInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private ItemInfo Item { get { return (ItemInfo) _Item;} } - public ItemInfoListPropertyDescriptor(ItemInfoList collection, int index):base(collection, index){;} + private ItemInfo Item { get { return (ItemInfo)_Item; } } + public ItemInfoListPropertyDescriptor(ItemInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -303,7 +303,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is ItemInfoList) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ItemPart.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ItemPart.cs index 344028a6..29796097 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ItemPart.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ItemPart.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentID",true); + CanReadProperty("ContentID", true); if (_MyContent != null) _ContentID = _MyContent.ContentID; return _ContentID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID); return _MyContent; } @@ -66,7 +66,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FromType",true); + CanReadProperty("FromType", true); return _FromType; } } @@ -76,13 +76,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -96,13 +96,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -118,7 +118,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_Number",true); + CanReadProperty("Content_Number", true); return _Content_Number; } } @@ -128,7 +128,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_Text",true); + CanReadProperty("Content_Text", true); return _Content_Text; } } @@ -141,7 +141,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_Type",true); + CanReadProperty("Content_Type", true); return _Content_Type; } } @@ -151,7 +151,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_FormatID",true); + CanReadProperty("Content_FormatID", true); return _Content_FormatID; } } @@ -161,7 +161,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_Config",true); + CanReadProperty("Content_Config", true); return _Content_Config; } } @@ -171,7 +171,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_DTS",true); + CanReadProperty("Content_DTS", true); return _Content_DTS; } } @@ -181,7 +181,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_UserID",true); + CanReadProperty("Content_UserID", true); return _Content_UserID; } } @@ -206,22 +206,22 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -318,8 +318,8 @@ namespace VEPROMS.CSLA.Library // TODO: Add any initialization & defaults _DTS = _ItemPartExtension.DefaultDTS; _UserID = _ItemPartExtension.DefaultUserID; - _MyContent = myContent; - _FromType = fromType; + _MyContent = myContent; + _FromType = fromType; ValidationRules.CheckRules(); } internal ItemPart(SafeDataReader dr) @@ -331,7 +331,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemPart.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemPart.FetchDR", GetHashCode()); try { _ContentID = dr.GetInt32("ContentID"); @@ -349,7 +349,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ItemParts.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ItemParts.cs index f4623ea9..69039767 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ItemParts.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ItemParts.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public ItemPart Add(Content myContent, int fromType) // One to Many { - ItemPart part = ItemPart.New(myContent, fromType); - this.Add(part); - return part; + ItemPart part = ItemPart.New(myContent, fromType); + this.Add(part); + return part; } public void Remove(Content myContent, int fromType) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(ItemPart itemPart in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (ItemPart itemPart in this) if ((hasBrokenRules = itemPart.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ItemIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemParts.DataPortal_FetchItemID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemParts.DataPortal_FetchItemID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class ItemPartsPropertyDescriptor : vlnListPropertyDescriptor { - private ItemPart Item { get { return (ItemPart) _Item;} } - public ItemPartsPropertyDescriptor(ItemParts collection, int index):base(collection, index){;} + private ItemPart Item { get { return (ItemPart)_Item; } } + public ItemPartsPropertyDescriptor(ItemParts collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is ItemParts) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ItemTransition_RangeID.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ItemTransition_RangeID.cs index 993f91e3..3c3f50ea 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ItemTransition_RangeID.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ItemTransition_RangeID.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TransitionID",true); + CanReadProperty("TransitionID", true); if (_MyTransition != null) _TransitionID = _MyTransition.TransitionID; return _TransitionID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyTransition",true); + CanReadProperty("MyTransition", true); if (_MyTransition == null && _TransitionID != 0) _MyTransition = Transition.Get(_TransitionID); return _MyTransition; } @@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FromID",true); + CanReadProperty("FromID", true); if (_MyContent != null) _FromID = _MyContent.ContentID; return _FromID; } @@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _FromID != 0) _MyContent = Content.Get(_FromID); return _MyContent; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyContent",true); + CanWriteProperty("MyContent", true); if (_MyContent != value) { _MyContent = value; @@ -100,7 +100,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ToID",true); + CanReadProperty("ToID", true); if (_MyItemToID != null) _ToID = _MyItemToID.ItemID; return _ToID; } @@ -111,14 +111,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItemToID",true); + CanReadProperty("MyItemToID", true); if (_MyItemToID == null && _ToID != 0) _MyItemToID = Item.Get(_ToID); return _MyItemToID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyItemToID",true); + CanWriteProperty("MyItemToID", true); if (_MyItemToID != value) { _MyItemToID = value; @@ -132,13 +132,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TranType",true); + CanReadProperty("TranType", true); return _TranType; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("TranType",true); + CanWriteProperty("TranType", true); if (_TranType != value) { _TranType = value; @@ -152,13 +152,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -173,13 +173,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -193,13 +193,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -215,7 +215,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_Number",true); + CanReadProperty("Content_Number", true); return _Content_Number; } } @@ -225,7 +225,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_Text",true); + CanReadProperty("Content_Text", true); return _Content_Text; } } @@ -238,7 +238,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_Type",true); + CanReadProperty("Content_Type", true); return _Content_Type; } } @@ -248,7 +248,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_FormatID",true); + CanReadProperty("Content_FormatID", true); return _Content_FormatID; } } @@ -258,7 +258,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_Config",true); + CanReadProperty("Content_Config", true); return _Content_Config; } } @@ -268,7 +268,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_DTS",true); + CanReadProperty("Content_DTS", true); return _Content_DTS; } } @@ -278,7 +278,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_UserID",true); + CanReadProperty("Content_UserID", true); return _Content_UserID; } } @@ -311,23 +311,23 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -446,8 +446,8 @@ namespace VEPROMS.CSLA.Library _TranType = _ItemTransition_RangeIDExtension.DefaultTranType; _DTS = _ItemTransition_RangeIDExtension.DefaultDTS; _UserID = _ItemTransition_RangeIDExtension.DefaultUserID; - _MyContent = myContent; - _MyItemToID = myItemToID; + _MyContent = myContent; + _MyItemToID = myItemToID; ValidationRules.CheckRules(); } internal ItemTransition_RangeID(SafeDataReader dr) @@ -459,7 +459,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { _TransitionID = dr.GetInt32("TransitionID"); @@ -480,7 +480,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ItemTransition_ToID.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ItemTransition_ToID.cs index 888509dd..2079bfd4 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ItemTransition_ToID.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ItemTransition_ToID.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TransitionID",true); + CanReadProperty("TransitionID", true); if (_MyTransition != null) _TransitionID = _MyTransition.TransitionID; return _TransitionID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyTransition",true); + CanReadProperty("MyTransition", true); if (_MyTransition == null && _TransitionID != 0) _MyTransition = Transition.Get(_TransitionID); return _MyTransition; } @@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FromID",true); + CanReadProperty("FromID", true); if (_MyContent != null) _FromID = _MyContent.ContentID; return _FromID; } @@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _FromID != 0) _MyContent = Content.Get(_FromID); return _MyContent; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyContent",true); + CanWriteProperty("MyContent", true); if (_MyContent != value) { _MyContent = value; @@ -97,7 +97,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RangeID",true); + CanReadProperty("RangeID", true); if (_MyItemRangeID != null) _RangeID = _MyItemRangeID.ItemID; return _RangeID; } @@ -108,14 +108,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItemRangeID",true); + CanReadProperty("MyItemRangeID", true); if (_MyItemRangeID == null && _RangeID != 0) _MyItemRangeID = Item.Get(_RangeID); return _MyItemRangeID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyItemRangeID",true); + CanWriteProperty("MyItemRangeID", true); if (_MyItemRangeID != value) { _MyItemRangeID = value; @@ -129,13 +129,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TranType",true); + CanReadProperty("TranType", true); return _TranType; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("TranType",true); + CanWriteProperty("TranType", true); if (_TranType != value) { _TranType = value; @@ -149,13 +149,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -170,13 +170,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -190,13 +190,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -212,7 +212,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_Number",true); + CanReadProperty("Content_Number", true); return _Content_Number; } } @@ -222,7 +222,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_Text",true); + CanReadProperty("Content_Text", true); return _Content_Text; } } @@ -235,7 +235,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_Type",true); + CanReadProperty("Content_Type", true); return _Content_Type; } } @@ -245,7 +245,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_FormatID",true); + CanReadProperty("Content_FormatID", true); return _Content_FormatID; } } @@ -255,7 +255,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_Config",true); + CanReadProperty("Content_Config", true); return _Content_Config; } } @@ -265,7 +265,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_DTS",true); + CanReadProperty("Content_DTS", true); return _Content_DTS; } } @@ -275,7 +275,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Content_UserID",true); + CanReadProperty("Content_UserID", true); return _Content_UserID; } } @@ -308,23 +308,23 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -443,8 +443,8 @@ namespace VEPROMS.CSLA.Library _TranType = _ItemTransition_ToIDExtension.DefaultTranType; _DTS = _ItemTransition_ToIDExtension.DefaultDTS; _UserID = _ItemTransition_ToIDExtension.DefaultUserID; - _MyContent = myContent; - _MyItemRangeID = myItemRangeID; + _MyContent = myContent; + _MyItemRangeID = myItemRangeID; ValidationRules.CheckRules(); } internal ItemTransition_ToID(SafeDataReader dr) @@ -456,7 +456,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { _TransitionID = dr.GetInt32("TransitionID"); @@ -477,7 +477,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ItemTransitions_RangeID.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ItemTransitions_RangeID.cs index fa1d16a6..d827f228 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ItemTransitions_RangeID.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ItemTransitions_RangeID.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public ItemTransition_RangeID Add(Content myContent, Item myItemToID) // One to Many { - ItemTransition_RangeID transition = ItemTransition_RangeID.New(myContent, myItemToID); - this.Add(transition); - return transition; + ItemTransition_RangeID transition = ItemTransition_RangeID.New(myContent, myItemToID); + this.Add(transition); + return transition; } public void Remove(Transition myTransition) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(ItemTransition_RangeID itemTransitionRangeID in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (ItemTransition_RangeID itemTransitionRangeID in this) if ((hasBrokenRules = itemTransitionRangeID.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(RangeIDCriteria criteria) { 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class ItemTransitions_RangeIDPropertyDescriptor : vlnListPropertyDescriptor { - private ItemTransition_RangeID Item { get { return (ItemTransition_RangeID) _Item;} } - public ItemTransitions_RangeIDPropertyDescriptor(ItemTransitions_RangeID collection, int index):base(collection, index){;} + private ItemTransition_RangeID Item { get { return (ItemTransition_RangeID)_Item; } } + public ItemTransitions_RangeIDPropertyDescriptor(ItemTransitions_RangeID collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is ItemTransitions_RangeID) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ItemTransitions_ToID.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ItemTransitions_ToID.cs index adfe8453..2d92fffd 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ItemTransitions_ToID.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ItemTransitions_ToID.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public ItemTransition_ToID Add(Content myContent, Item myItemRangeID) // One to Many { - ItemTransition_ToID transition = ItemTransition_ToID.New(myContent, myItemRangeID); - this.Add(transition); - return transition; + ItemTransition_ToID transition = ItemTransition_ToID.New(myContent, myItemRangeID); + this.Add(transition); + return transition; } public void Remove(Transition myTransition) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(ItemTransition_ToID itemTransitionToID in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (ItemTransition_ToID itemTransitionToID in this) if ((hasBrokenRules = itemTransitionToID.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ToIDCriteria criteria) { 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class ItemTransitions_ToIDPropertyDescriptor : vlnListPropertyDescriptor { - private ItemTransition_ToID Item { get { return (ItemTransition_ToID) _Item;} } - public ItemTransitions_ToIDPropertyDescriptor(ItemTransitions_ToID collection, int index):base(collection, index){;} + private ItemTransition_ToID Item { get { return (ItemTransition_ToID)_Item; } } + public ItemTransitions_ToIDPropertyDescriptor(ItemTransitions_ToID collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is ItemTransitions_ToID) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Membership.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Membership.cs index fb06ae06..6e92c167 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Membership.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Membership.cs @@ -47,20 +47,24 @@ namespace VEPROMS.CSLA.Library foreach (Membership tmp in _RefreshMemberships) { MembershipInfo.Refresh(tmp); - if(tmp._MyGroup != null) GroupInfo.Refresh(tmp._MyGroup); - if(tmp._MyUser != null) UserInfo.Refresh(tmp._MyUser); + if (tmp._MyGroup != null) GroupInfo.Refresh(tmp._MyGroup); + if (tmp._MyUser != null) UserInfo.Refresh(tmp._MyUser); } } #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (Membership tmp in _AllList) { - _AllByPrimaryKey[tmp.UGID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.UGID.ToString())) + { + _AllByPrimaryKey[tmp.UGID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.UGID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (Membership tmp in remove) @@ -70,7 +74,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = ugid.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -92,7 +96,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UGID",true); + CanReadProperty("UGID", true); return _UGID; } } @@ -102,7 +106,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UID",true); + CanReadProperty("UID", true); if (_MyUser != null) _UID = _MyUser.UID; return _UID; } @@ -113,14 +117,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyUser",true); + CanReadProperty("MyUser", true); if (_MyUser == null && _UID != 0) _MyUser = User.Get(_UID); return _MyUser; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyUser",true); + CanWriteProperty("MyUser", true); if (_MyUser != value) { _MyUser = value; @@ -134,7 +138,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GID",true); + CanReadProperty("GID", true); if (_MyGroup != null) _GID = _MyGroup.GID; return _GID; } @@ -145,14 +149,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyGroup",true); + CanReadProperty("MyGroup", true); if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID); return _MyGroup; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyGroup",true); + CanWriteProperty("MyGroup", true); if (_MyGroup != value) { _MyGroup = value; @@ -166,13 +170,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("StartDate",true); + CanReadProperty("StartDate", true); return _StartDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("StartDate",true); + CanWriteProperty("StartDate", true); if (value == null) value = string.Empty; _StartDate = value; try @@ -196,13 +200,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("EndDate",true); + CanReadProperty("EndDate", true); return _EndDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("EndDate",true); + CanWriteProperty("EndDate", true); if (value == null) value = string.Empty; _EndDate = value; try @@ -226,13 +230,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -247,13 +251,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -267,13 +271,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UsrID",true); + CanWriteProperty("UsrID", true); if (value == null) value = string.Empty; if (_UsrID != value) { @@ -285,11 +289,11 @@ namespace VEPROMS.CSLA.Library private byte[] _LastChanged = new byte[8];//timestamp 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 { - 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 /// @@ -312,23 +316,24 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_MyUser != null && (hasBrokenRules = _MyUser.HasBrokenRules) != null) return hasBrokenRules; - if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules; + if (_MyUser != null && (hasBrokenRules = _MyUser.HasBrokenRules) != null) return hasBrokenRules; + if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -478,14 +483,25 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _MembershipUnique = 0; + private int _MyMembershipUnique; + public int MyMembershipUnique + { + get { return _MyMembershipUnique; } + } protected Membership() {/* require use of factory methods */ + _MyMembershipUnique = ++_MembershipUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(UGID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(UGID.ToString())) return; + List 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() { @@ -570,7 +586,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(ugid)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -650,7 +666,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Membership.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Membership.ReadData", GetHashCode()); try { _UGID = dr.GetInt32("UGID"); @@ -666,14 +682,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Membership.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -701,7 +717,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Membership.DataPortal_Fetch", ex); } @@ -722,13 +738,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Membership.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Membership.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Membership.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -737,8 +753,8 @@ namespace VEPROMS.CSLA.Library if (!this.IsDirty) return; try { - if(_MyGroup != null) _MyGroup.Update(); - if(_MyUser != null) _MyUser.Update(); + if (_MyGroup != null) _MyGroup.Update(); + if (_MyUser != null) _MyUser.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; using (SqlCommand cm = cn.CreateCommand()) { @@ -767,11 +783,11 @@ namespace VEPROMS.CSLA.Library } MarkOld(); // update child objects - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Membership.SQLInsert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Membership.SQLInsert", GetHashCode()); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Membership.SQLInsert", ex); } @@ -779,7 +795,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Membership.Add", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Membership.Add", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -810,7 +826,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -818,7 +834,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Membership.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Membership.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -832,7 +848,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -841,11 +857,11 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { 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 { - if(_MyGroup != null) _MyGroup.Update(); - if(_MyUser != null) _MyUser.Update(); + if (_MyGroup != null) _MyGroup.Update(); + if (_MyUser != null) _MyUser.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; if (base.IsDirty) { @@ -878,7 +894,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -899,7 +915,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Membership.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Membership.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -928,7 +944,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -940,7 +956,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -956,7 +972,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Membership.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Membership.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Membership.DataPortal_Delete", ex); } @@ -964,7 +980,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -979,7 +995,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -1013,7 +1029,7 @@ namespace VEPROMS.CSLA.Library } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1031,7 +1047,7 @@ namespace VEPROMS.CSLA.Library } 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); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/MembershipInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/MembershipInfo.cs index 241bfff6..704aa509 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/MembershipInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/MembershipInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (MembershipInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.UGID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.UGID.ToString())) + { + _AllByPrimaryKey[tmp.UGID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.UGID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (MembershipInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = ugid.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UGID",true); + CanReadProperty("UGID", true); return _UGID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UID",true); + CanReadProperty("UID", true); if (_MyUser != null) _UID = _MyUser.UID; return _UID; } @@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyUser",true); + CanReadProperty("MyUser", true); if (_MyUser == null && _UID != 0) _MyUser = UserInfo.Get(_UID); return _MyUser; } @@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GID",true); + CanReadProperty("GID", true); if (_MyGroup != null) _GID = _MyGroup.GID; return _GID; } @@ -128,7 +132,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyGroup",true); + CanReadProperty("MyGroup", true); if (_MyGroup == null && _GID != 0) _MyGroup = GroupInfo.Get(_GID); return _MyGroup; } @@ -139,7 +143,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("StartDate",true); + CanReadProperty("StartDate", true); return _StartDate; } } @@ -149,7 +153,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("EndDate",true); + CanReadProperty("EndDate", true); return _EndDate; } } @@ -159,7 +163,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } } @@ -169,7 +173,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -179,7 +183,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } } @@ -203,14 +207,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _MembershipInfoUnique = 0; + private int _MyMembershipInfoUnique; + public int MyMembershipInfoUnique + { + get { return _MyMembershipInfoUnique; } + } private MembershipInfo() {/* require use of factory methods */ + _MyMembershipInfoUnique = ++_MembershipInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(UGID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(UGID.ToString())) return; + List 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() { @@ -218,9 +233,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(Membership tmp) { - MembershipInfo tmpInfo = GetExistingByPrimaryKey(tmp.UGID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.UGID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (MembershipInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(Membership tmp) { @@ -228,16 +245,16 @@ namespace VEPROMS.CSLA.Library { MyUser.RefreshUserMemberships(); // Update List for old 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) { MyGroup.RefreshGroupMemberships(); // Update List for old 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; _EndDate = tmp.EndDate; _Config = tmp.Config; @@ -250,9 +267,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(GroupMembership tmp) { - MembershipInfo tmpInfo = GetExistingByPrimaryKey(tmp.UGID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.UGID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (MembershipInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(GroupMembership tmp) { @@ -260,9 +279,9 @@ namespace VEPROMS.CSLA.Library { MyUser.RefreshUserMemberships(); // Update List for old 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; _EndDate = tmp.EndDate; _Config = tmp.Config; @@ -275,9 +294,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(UserMembership tmp) { - MembershipInfo tmpInfo = GetExistingByPrimaryKey(tmp.UGID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.UGID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (MembershipInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(UserMembership tmp) { @@ -285,9 +306,9 @@ namespace VEPROMS.CSLA.Library { MyGroup.RefreshGroupMemberships(); // Update List for old 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; _EndDate = tmp.EndDate; _Config = tmp.Config; @@ -308,7 +329,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(ugid)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -322,14 +343,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { ReadData(dr); } 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); } } @@ -346,7 +368,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] MembershipInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.ReadData", GetHashCode()); try { _UGID = dr.GetInt32("UGID"); @@ -360,14 +382,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("MembershipInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("MembershipInfo.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -395,7 +417,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("MembershipInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("MembershipInfo.DataPortal_Fetch", ex); } @@ -405,7 +427,7 @@ namespace VEPROMS.CSLA.Library #region extension MembershipInfoExtension _MembershipInfoExtension = new MembershipInfoExtension(); [Serializable()] - partial class MembershipInfoExtension : extensionBase {} + partial class MembershipInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/MembershipInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/MembershipInfoList.cs index ec17ea2e..3672a6ed 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/MembershipInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/MembershipInfoList.cs @@ -124,7 +124,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] MembershipInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -144,7 +144,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -166,7 +166,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(GIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] MembershipInfoList.DataPortal_FetchGID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfoList.DataPortal_FetchGID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -187,7 +187,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -209,7 +209,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(UIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] MembershipInfoList.DataPortal_FetchUID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfoList.DataPortal_FetchUID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -230,7 +230,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -291,8 +291,8 @@ namespace VEPROMS.CSLA.Library /// public partial class MembershipInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private MembershipInfo Item { get { return (MembershipInfo) _Item;} } - public MembershipInfoListPropertyDescriptor(MembershipInfoList collection, int index):base(collection, index){;} + private MembershipInfo Item { get { return (MembershipInfo)_Item; } } + public MembershipInfoListPropertyDescriptor(MembershipInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -303,7 +303,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is MembershipInfoList) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/NextItems.cs b/PROMS/VEPROMS.CSLA.Library/Generated/NextItems.cs index d52591d6..03cb1ee7 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/NextItems.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/NextItems.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public Item Add(Content myContent) // One to Many { - Item item = Item.New(myContent); - this.Add(item); - return item; + Item item = Item.New(myContent); + this.Add(item); + return item; } public void Remove(int itemID) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(Item item in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (Item item in this) if ((hasBrokenRules = item.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(PreviousIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] NextItems.DataPortal_FetchPreviousID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] NextItems.DataPortal_FetchPreviousID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class NextItemsPropertyDescriptor : vlnListPropertyDescriptor { - private Item Item { get { return (Item) _Item;} } - public NextItemsPropertyDescriptor(NextItems collection, int index):base(collection, index){;} + private Item Item { get { return (Item)_Item; } } + public NextItemsPropertyDescriptor(NextItems collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is NextItems) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Part.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Part.cs index 7ed0ad75..5a0ec6f9 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Part.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Part.cs @@ -47,20 +47,24 @@ namespace VEPROMS.CSLA.Library foreach (Part tmp in _RefreshParts) { PartInfo.Refresh(tmp); - if(tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent); - if(tmp._MyItem != null) ItemInfo.Refresh(tmp._MyItem); + if (tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent); + if (tmp._MyItem != null) ItemInfo.Refresh(tmp._MyItem); } } #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); 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(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (Part tmp in remove) @@ -70,7 +74,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = contentID.ToString() + "_" + fromType.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -87,7 +91,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentID",true); + CanReadProperty("ContentID", true); if (_MyContent != null) _ContentID = _MyContent.ContentID; return _ContentID; } @@ -99,7 +103,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID); return _MyContent; } @@ -111,7 +115,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FromType",true); + CanReadProperty("FromType", true); return _FromType; } } @@ -121,7 +125,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemID",true); + CanReadProperty("ItemID", true); if (_MyItem != null) _ItemID = _MyItem.ItemID; return _ItemID; } @@ -132,14 +136,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItem",true); + CanReadProperty("MyItem", true); if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID); return _MyItem; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyItem",true); + CanWriteProperty("MyItem", true); if (_MyItem != value) { _MyItem = value; @@ -153,13 +157,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -173,13 +177,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -191,11 +195,11 @@ namespace VEPROMS.CSLA.Library private byte[] _LastChanged = new byte[8];//timestamp public override bool IsDirty { - get { return base.IsDirty || (_MyContent == null? false : _MyContent.IsDirty) || (_MyItem == null? false : _MyItem.IsDirty); } + get { return base.IsDirty || (_MyContent == null ? false : _MyContent.IsDirty) || (_MyItem == null ? false : _MyItem.IsDirty); } } 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 /// @@ -213,27 +217,28 @@ namespace VEPROMS.CSLA.Library /// A Unique ID for the current Part protected override object GetIdValue() { - return (_ContentID.ToString()+"."+_FromType.ToString()).GetHashCode(); + return (_ContentID.ToString() + "." + _FromType.ToString()).GetHashCode(); } #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; + if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -333,14 +338,25 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _PartUnique = 0; + private int _MyPartUnique; + public int MyPartUnique + { + get { return _MyPartUnique; } + } protected Part() {/* require use of factory methods */ + _MyPartUnique = ++_PartUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(ContentID.ToString() + "_" + FromType.ToString()); + if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString() + "_" + FromType.ToString())) return; + List 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() { @@ -399,7 +415,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(contentID, fromType)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -482,7 +498,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Part.ReadData", GetHashCode()); try { _ContentID = dr.GetInt32("ContentID"); @@ -495,14 +511,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Part.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -531,7 +547,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Part.DataPortal_Fetch", ex); } @@ -552,13 +568,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Part.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Part.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -567,8 +583,8 @@ namespace VEPROMS.CSLA.Library if (!this.IsDirty) return; try { - if(_MyContent != null) _MyContent.Update(); - if(_MyItem != null) _MyItem.Update(); + if (_MyContent != null) _MyContent.Update(); + if (_MyItem != null) _MyItem.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; using (SqlCommand cm = cn.CreateCommand()) { @@ -591,11 +607,11 @@ namespace VEPROMS.CSLA.Library } MarkOld(); // update child objects - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.SQLInsert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Part.SQLInsert", GetHashCode()); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Part.SQLInsert", ex); } @@ -603,7 +619,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -628,7 +644,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -636,7 +652,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Part.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -650,7 +666,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -659,11 +675,11 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { 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 { - if(_MyContent != null) _MyContent.Update(); - if(_MyItem != null) _MyItem.Update(); + if (_MyContent != null) _MyContent.Update(); + if (_MyItem != null) _MyItem.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; if (base.IsDirty) { @@ -693,7 +709,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -714,7 +730,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -740,7 +756,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -752,7 +768,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -769,7 +785,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Part.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Part.DataPortal_Delete", ex); } @@ -777,7 +793,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -793,7 +809,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -829,7 +845,7 @@ namespace VEPROMS.CSLA.Library } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -848,7 +864,7 @@ namespace VEPROMS.CSLA.Library } 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); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/PartInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/PartInfo.cs index 05ebfcad..42ed2e7a 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/PartInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/PartInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); 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(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (PartInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = contentID.ToString() + "_" + fromType.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentID",true); + CanReadProperty("ContentID", true); if (_MyContent != null) _ContentID = _MyContent.ContentID; return _ContentID; } @@ -97,7 +101,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID); return _MyContent; } @@ -109,7 +113,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FromType",true); + CanReadProperty("FromType", true); return _FromType; } } @@ -119,7 +123,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ItemID",true); + CanReadProperty("ItemID", true); if (_MyItem != null) _ItemID = _MyItem.ItemID; return _ItemID; } @@ -130,7 +134,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItem",true); + CanReadProperty("MyItem", true); if (_MyItem == null && _ItemID != 0) _MyItem = ItemInfo.Get(_ItemID); return _MyItem; } @@ -141,7 +145,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -151,7 +155,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } } @@ -171,18 +175,29 @@ namespace VEPROMS.CSLA.Library /// A Unique ID for the current PartInfo protected override object GetIdValue() { - return (_ContentID.ToString()+"."+_FromType.ToString()).GetHashCode(); + return (_ContentID.ToString() + "." + _FromType.ToString()).GetHashCode(); } #endregion #region Factory Methods + private static int _PartInfoUnique = 0; + private int _MyPartInfoUnique; + public int MyPartInfoUnique + { + get { return _MyPartInfoUnique; } + } private PartInfo() {/* require use of factory methods */ + _MyPartInfoUnique = ++_PartInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(ContentID.ToString() + "_" + FromType.ToString()); + if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString() + "_" + FromType.ToString())) return; + List 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() { @@ -190,9 +205,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(Part tmp) { - PartInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID, tmp.FromType); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (PartInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(Part tmp) { @@ -200,9 +217,9 @@ namespace VEPROMS.CSLA.Library { MyItem.RefreshItemParts(); // Update List for old 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; _UserID = tmp.UserID; _PartInfoExtension.Refresh(this); @@ -212,9 +229,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(Content myContent, ContentPart tmp) { - PartInfo tmpInfo = GetExistingByPrimaryKey(myContent.ContentID, tmp.FromType); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = myContent.ContentID.ToString() + "_" + tmp.FromType.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (PartInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(ContentPart tmp) { @@ -222,9 +241,9 @@ namespace VEPROMS.CSLA.Library { MyItem.RefreshItemParts(); // Update List for old 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; _UserID = tmp.UserID; _PartInfoExtension.Refresh(this); @@ -234,9 +253,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(ItemPart tmp) { - PartInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID, tmp.FromType); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (PartInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(ItemPart tmp) { @@ -257,7 +278,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(contentID, fromType)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -271,14 +292,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { ReadData(dr); } 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); } } @@ -299,7 +321,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PartInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.ReadData", GetHashCode()); try { _ContentID = dr.GetInt32("ContentID"); @@ -310,14 +332,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("PartInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("PartInfo.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -346,7 +368,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("PartInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("PartInfo.DataPortal_Fetch", ex); } @@ -356,7 +378,7 @@ namespace VEPROMS.CSLA.Library #region extension PartInfoExtension _PartInfoExtension = new PartInfoExtension(); [Serializable()] - partial class PartInfoExtension : extensionBase {} + partial class PartInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/PartInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/PartInfoList.cs index 9932a0a2..1b78f5a0 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/PartInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/PartInfoList.cs @@ -124,7 +124,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -144,7 +144,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -166,7 +166,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ContentIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_FetchContentID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_FetchContentID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -187,7 +187,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -209,7 +209,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ItemIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_FetchItemID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_FetchItemID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -230,7 +230,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -291,8 +291,8 @@ namespace VEPROMS.CSLA.Library /// public partial class PartInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private PartInfo Item { get { return (PartInfo) _Item;} } - public PartInfoListPropertyDescriptor(PartInfoList collection, int index):base(collection, index){;} + private PartInfo Item { get { return (PartInfo)_Item; } } + public PartInfoListPropertyDescriptor(PartInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -303,7 +303,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is PartInfoList) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Permission.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Permission.cs index e2a8a91a..bc391a4e 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Permission.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Permission.cs @@ -47,19 +47,23 @@ namespace VEPROMS.CSLA.Library foreach (Permission tmp in _RefreshPermissions) { PermissionInfo.Refresh(tmp); - if(tmp._MyRole != null) RoleInfo.Refresh(tmp._MyRole); + if (tmp._MyRole != null) RoleInfo.Refresh(tmp._MyRole); } } #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (Permission tmp in _AllList) { - _AllByPrimaryKey[tmp.PID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.PID.ToString())) + { + _AllByPrimaryKey[tmp.PID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.PID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (Permission tmp in remove) @@ -69,7 +73,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = pid.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -91,7 +95,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("PID",true); + CanReadProperty("PID", true); return _PID; } } @@ -101,7 +105,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RID",true); + CanReadProperty("RID", true); if (_MyRole != null) _RID = _MyRole.RID; return _RID; } @@ -112,14 +116,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyRole",true); + CanReadProperty("MyRole", true); if (_MyRole == null && _RID != 0) _MyRole = Role.Get(_RID); return _MyRole; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyRole",true); + CanWriteProperty("MyRole", true); if (_MyRole != value) { _MyRole = value; @@ -136,13 +140,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("PermLevel",true); + CanReadProperty("PermLevel", true); return _PermLevel; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("PermLevel",true); + CanWriteProperty("PermLevel", true); if (_PermLevel != value) { _PermLevel = value; @@ -159,13 +163,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("VersionType",true); + CanReadProperty("VersionType", true); return _VersionType; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("VersionType",true); + CanWriteProperty("VersionType", true); if (_VersionType != value) { _VersionType = value; @@ -182,13 +186,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("PermValue",true); + CanReadProperty("PermValue", true); return _PermValue; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("PermValue",true); + CanWriteProperty("PermValue", true); if (_PermValue != value) { _PermValue = value; @@ -205,13 +209,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("PermAD",true); + CanReadProperty("PermAD", true); return _PermAD; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("PermAD",true); + CanWriteProperty("PermAD", true); if (_PermAD != value) { _PermAD = value; @@ -225,13 +229,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("StartDate",true); + CanReadProperty("StartDate", true); return _StartDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("StartDate",true); + CanWriteProperty("StartDate", true); if (value == null) value = string.Empty; _StartDate = value; try @@ -255,13 +259,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("EndDate",true); + CanReadProperty("EndDate", true); return _EndDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("EndDate",true); + CanWriteProperty("EndDate", true); if (value == null) value = string.Empty; _EndDate = value; try @@ -285,13 +289,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -306,13 +310,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -326,13 +330,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UsrID",true); + CanWriteProperty("UsrID", true); if (value == null) value = string.Empty; if (_UsrID != value) { @@ -344,11 +348,11 @@ namespace VEPROMS.CSLA.Library private byte[] _LastChanged = new byte[8];//timestamp 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 { - 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 /// @@ -371,22 +375,23 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_MyRole != null && (hasBrokenRules = _MyRole.HasBrokenRules) != null) return hasBrokenRules; + if (_MyRole != null && (hasBrokenRules = _MyRole.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -532,14 +537,25 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _PermissionUnique = 0; + private int _MyPermissionUnique; + public int MyPermissionUnique + { + get { return _MyPermissionUnique; } + } protected Permission() {/* require use of factory methods */ + _MyPermissionUnique = ++_PermissionUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(PID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(PID.ToString())) return; + List 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() { @@ -631,7 +647,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(pid)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -712,7 +728,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Permission.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Permission.ReadData", GetHashCode()); try { _PID = dr.GetInt32("PID"); @@ -731,14 +747,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Permission.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -766,7 +782,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Permission.DataPortal_Fetch", ex); } @@ -787,13 +803,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Permission.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Permission.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Permission.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -802,7 +818,7 @@ namespace VEPROMS.CSLA.Library if (!this.IsDirty) return; try { - if(_MyRole != null) _MyRole.Update(); + if (_MyRole != null) _MyRole.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; using (SqlCommand cm = cn.CreateCommand()) { @@ -834,11 +850,11 @@ namespace VEPROMS.CSLA.Library } MarkOld(); // update child objects - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Permission.SQLInsert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Permission.SQLInsert", GetHashCode()); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Permission.SQLInsert", ex); } @@ -846,7 +862,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Permission.Add", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Permission.Add", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -880,7 +896,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -888,7 +904,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Permission.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Permission.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -902,7 +918,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -911,10 +927,10 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { 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 { - if(_MyRole != null) _MyRole.Update(); + if (_MyRole != null) _MyRole.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; if (base.IsDirty) { @@ -950,7 +966,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -971,7 +987,7 @@ namespace VEPROMS.CSLA.Library [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) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Permission.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Permission.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -1003,7 +1019,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -1015,7 +1031,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1031,7 +1047,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Permission.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Permission.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Permission.DataPortal_Delete", ex); } @@ -1039,7 +1055,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -1054,7 +1070,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -1088,7 +1104,7 @@ namespace VEPROMS.CSLA.Library } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1106,7 +1122,7 @@ namespace VEPROMS.CSLA.Library } 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); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/PermissionInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/PermissionInfo.cs index a993cb78..10ea54ef 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/PermissionInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/PermissionInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (PermissionInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.PID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.PID.ToString())) + { + _AllByPrimaryKey[tmp.PID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.PID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (PermissionInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = pid.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("PID",true); + CanReadProperty("PID", true); return _PID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RID",true); + CanReadProperty("RID", true); if (_MyRole != null) _RID = _MyRole.RID; return _RID; } @@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyRole",true); + CanReadProperty("MyRole", true); if (_MyRole == null && _RID != 0) _MyRole = RoleInfo.Get(_RID); return _MyRole; } @@ -120,7 +124,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("PermLevel",true); + CanReadProperty("PermLevel", true); return _PermLevel; } } @@ -133,7 +137,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("VersionType",true); + CanReadProperty("VersionType", true); return _VersionType; } } @@ -146,7 +150,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("PermValue",true); + CanReadProperty("PermValue", true); return _PermValue; } } @@ -159,7 +163,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("PermAD",true); + CanReadProperty("PermAD", true); return _PermAD; } } @@ -169,7 +173,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("StartDate",true); + CanReadProperty("StartDate", true); return _StartDate; } } @@ -179,7 +183,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("EndDate",true); + CanReadProperty("EndDate", true); return _EndDate; } } @@ -189,7 +193,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } } @@ -199,7 +203,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -209,7 +213,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } } @@ -233,14 +237,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _PermissionInfoUnique = 0; + private int _MyPermissionInfoUnique; + public int MyPermissionInfoUnique + { + get { return _MyPermissionInfoUnique; } + } private PermissionInfo() {/* require use of factory methods */ + _MyPermissionInfoUnique = ++_PermissionInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(PID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(PID.ToString())) return; + List 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() { @@ -248,9 +263,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(Permission tmp) { - PermissionInfo tmpInfo = GetExistingByPrimaryKey(tmp.PID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.PID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (PermissionInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(Permission tmp) { @@ -258,9 +275,9 @@ namespace VEPROMS.CSLA.Library { MyRole.RefreshRolePermissions(); // Update List for old 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; _VersionType = tmp.VersionType; _PermValue = tmp.PermValue; @@ -276,9 +293,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(RolePermission tmp) { - PermissionInfo tmpInfo = GetExistingByPrimaryKey(tmp.PID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.PID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (PermissionInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(RolePermission tmp) { @@ -305,7 +324,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(pid)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -319,14 +338,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { ReadData(dr); } 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); } } @@ -343,7 +363,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PermissionInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PermissionInfo.ReadData", GetHashCode()); try { _PID = dr.GetInt32("PID"); @@ -360,14 +380,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("PermissionInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("PermissionInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("PermissionInfo.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -395,7 +415,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("PermissionInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("PermissionInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("PermissionInfo.DataPortal_Fetch", ex); } @@ -405,7 +425,7 @@ namespace VEPROMS.CSLA.Library #region extension PermissionInfoExtension _PermissionInfoExtension = new PermissionInfoExtension(); [Serializable()] - partial class PermissionInfoExtension : extensionBase {} + partial class PermissionInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/PermissionInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/PermissionInfoList.cs index ae109ee2..6b4500fd 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/PermissionInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/PermissionInfoList.cs @@ -110,7 +110,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PermissionInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PermissionInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -130,7 +130,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -152,7 +152,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(RIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] PermissionInfoList.DataPortal_FetchRID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PermissionInfoList.DataPortal_FetchRID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -173,7 +173,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -234,8 +234,8 @@ namespace VEPROMS.CSLA.Library /// public partial class PermissionInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private PermissionInfo Item { get { return (PermissionInfo) _Item;} } - public PermissionInfoListPropertyDescriptor(PermissionInfoList collection, int index):base(collection, index){;} + private PermissionInfo Item { get { return (PermissionInfo)_Item; } } + public PermissionInfoListPropertyDescriptor(PermissionInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -246,7 +246,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is PermissionInfoList) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/PropertyDescriptor.cs b/PROMS/VEPROMS.CSLA.Library/Generated/PropertyDescriptor.cs index 5e891bc8..8167728e 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/PropertyDescriptor.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/PropertyDescriptor.cs @@ -57,7 +57,7 @@ namespace VEPROMS.CSLA.Library public interface IVEHasBrokenRules { IVEHasBrokenRules HasBrokenRules { get; } - BrokenRulesCollection BrokenRules { get; } + BrokenRulesCollection BrokenRules { get; } } } // Namespace // The following are samples of ToString overrides diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/RoUsage.cs b/PROMS/VEPROMS.CSLA.Library/Generated/RoUsage.cs index b8b079b5..c7a8cf9b 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/RoUsage.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/RoUsage.cs @@ -47,19 +47,23 @@ namespace VEPROMS.CSLA.Library foreach (RoUsage tmp in _RefreshRoUsages) { RoUsageInfo.Refresh(tmp); - if(tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent); + if (tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent); } } #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (RoUsage tmp in _AllList) { - _AllByPrimaryKey[tmp.ROUsageID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.ROUsageID.ToString())) + { + _AllByPrimaryKey[tmp.ROUsageID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.ROUsageID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (RoUsage tmp in remove) @@ -69,7 +73,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = rOUsageID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -91,7 +95,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ROUsageID",true); + CanReadProperty("ROUsageID", true); return _ROUsageID; } } @@ -101,7 +105,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentID",true); + CanReadProperty("ContentID", true); if (_MyContent != null) _ContentID = _MyContent.ContentID; return _ContentID; } @@ -112,14 +116,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID); return _MyContent; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyContent",true); + CanWriteProperty("MyContent", true); if (_MyContent != value) { _MyContent = value; @@ -133,13 +137,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ROID",true); + CanReadProperty("ROID", true); return _ROID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("ROID",true); + CanWriteProperty("ROID", true); if (value == null) value = string.Empty; if (_ROID != value) { @@ -154,13 +158,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -175,13 +179,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -195,13 +199,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -213,11 +217,11 @@ namespace VEPROMS.CSLA.Library private byte[] _LastChanged = new byte[8];//timestamp public override bool IsDirty { - get { return base.IsDirty || (_MyContent == null? false : _MyContent.IsDirty); } + get { return base.IsDirty || (_MyContent == null ? false : _MyContent.IsDirty); } } public override bool IsValid { - get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyContent == null? true : _MyContent.IsValid); } + get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyContent == null ? true : _MyContent.IsValid); } } // TODO: Replace base RoUsage.ToString function as necessary /// @@ -240,22 +244,23 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules; + if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -366,14 +371,25 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _RoUsageUnique = 0; + private int _MyRoUsageUnique; + public int MyRoUsageUnique + { + get { return _MyRoUsageUnique; } + } protected RoUsage() {/* require use of factory methods */ + _MyRoUsageUnique = ++_RoUsageUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(ROUsageID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(ROUsageID.ToString())) return; + List listRoUsage = _AllByPrimaryKey[ROUsageID.ToString()]; // Get the list of items + listRoUsage.Remove(this); // Remove the item from the list + if (listRoUsage.Count == 0) //If there are no items left in the list + _AllByPrimaryKey.Remove(ROUsageID.ToString()); // remove the list } public static RoUsage New() { @@ -454,7 +470,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(rOUsageID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -534,7 +550,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.ReadData", GetHashCode()); try { _ROUsageID = dr.GetInt32("ROUsageID"); @@ -548,14 +564,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("RoUsage.ReadData", ex); } } private void DataPortal_Fetch(PKCriteria criteria) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -583,7 +599,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("RoUsage.DataPortal_Fetch", ex); } @@ -604,13 +620,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("RoUsage.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -619,7 +635,7 @@ namespace VEPROMS.CSLA.Library if (!this.IsDirty) return; try { - if(_MyContent != null) _MyContent.Update(); + if (_MyContent != null) _MyContent.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; using (SqlCommand cm = cn.CreateCommand()) { @@ -646,11 +662,11 @@ namespace VEPROMS.CSLA.Library } MarkOld(); // update child objects - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.SQLInsert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.SQLInsert", GetHashCode()); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("RoUsage.SQLInsert", ex); } @@ -658,7 +674,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] public static byte[] Add(SqlConnection cn, ref int rOUsageID, Content myContent, string roid, string config, DateTime dts, string userID) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.Add", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.Add", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -687,7 +703,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.Add", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.Add", ex); throw new DbCslaException("RoUsage.Add", ex); } } @@ -695,7 +711,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -709,7 +725,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -718,10 +734,10 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.SQLUpdate", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.SQLUpdate", GetHashCode()); try { - if(_MyContent != null) _MyContent.Update(); + if (_MyContent != null) _MyContent.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; if (base.IsDirty) { @@ -752,7 +768,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -773,7 +789,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] public static byte[] Update(SqlConnection cn, ref int rOUsageID, Content myContent, string roid, string config, DateTime dts, string userID, ref byte[] lastChanged) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -800,7 +816,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.Update", ex); throw new DbCslaException("RoUsage.Update", ex); } } @@ -812,7 +828,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] private void DataPortal_Delete(PKCriteria criteria) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Delete", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Delete", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -828,7 +844,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("RoUsage.DataPortal_Delete", ex); } @@ -836,7 +852,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] public static void Remove(SqlConnection cn, int rOUsageID) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.Remove", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.Remove", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -851,7 +867,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.Remove", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.Remove", ex); throw new DbCslaException("RoUsage.Remove", ex); } } @@ -885,7 +901,7 @@ namespace VEPROMS.CSLA.Library } protected override void DataPortal_Execute() { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Execute", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.DataPortal_Execute", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -903,7 +919,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsage.DataPortal_Execute", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsage.DataPortal_Execute", ex); throw new DbCslaException("RoUsage.DataPortal_Execute", ex); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/RoUsageInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/RoUsageInfo.cs index c1eece55..0c354ce1 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/RoUsageInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/RoUsageInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (RoUsageInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.ROUsageID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.ROUsageID.ToString())) + { + _AllByPrimaryKey[tmp.ROUsageID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.ROUsageID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (RoUsageInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = rOUsageID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ROUsageID",true); + CanReadProperty("ROUsageID", true); return _ROUsageID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentID",true); + CanReadProperty("ContentID", true); if (_MyContent != null) _ContentID = _MyContent.ContentID; return _ContentID; } @@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID); return _MyContent; } @@ -117,7 +121,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ROID",true); + CanReadProperty("ROID", true); return _ROID; } } @@ -127,7 +131,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } } @@ -137,7 +141,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -147,7 +151,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } } @@ -171,14 +175,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _RoUsageInfoUnique = 0; + private int _MyRoUsageInfoUnique; + public int MyRoUsageInfoUnique + { + get { return _MyRoUsageInfoUnique; } + } private RoUsageInfo() {/* require use of factory methods */ + _MyRoUsageInfoUnique = ++_RoUsageInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(ROUsageID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(ROUsageID.ToString())) return; + List 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() { @@ -186,9 +201,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(RoUsage tmp) { - RoUsageInfo tmpInfo = GetExistingByPrimaryKey(tmp.ROUsageID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.ROUsageID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (RoUsageInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(RoUsage tmp) { @@ -196,9 +213,9 @@ namespace VEPROMS.CSLA.Library { MyContent.RefreshContentRoUsages(); // Update List for old 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; _Config = tmp.Config; _DTS = tmp.DTS; @@ -209,9 +226,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(ContentRoUsage tmp) { - RoUsageInfo tmpInfo = GetExistingByPrimaryKey(tmp.ROUsageID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.ROUsageID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (RoUsageInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(ContentRoUsage tmp) { @@ -233,7 +252,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(rOUsageID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -247,14 +266,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal 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 { ReadData(dr); } 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); } } @@ -271,7 +291,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsageInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfo.ReadData", GetHashCode()); try { _ROUsageID = dr.GetInt32("ROUsageID"); @@ -283,14 +303,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsageInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsageInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("RoUsageInfo.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -318,7 +338,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RoUsageInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsageInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("RoUsageInfo.DataPortal_Fetch", ex); } @@ -328,7 +348,7 @@ namespace VEPROMS.CSLA.Library #region extension RoUsageInfoExtension _RoUsageInfoExtension = new RoUsageInfoExtension(); [Serializable()] - partial class RoUsageInfoExtension : extensionBase {} + partial class RoUsageInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/RoUsageInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/RoUsageInfoList.cs index be879125..7136abd1 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/RoUsageInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/RoUsageInfoList.cs @@ -110,7 +110,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsageInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -130,7 +130,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -152,7 +152,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ContentIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoUsageInfoList.DataPortal_FetchContentID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfoList.DataPortal_FetchContentID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -173,7 +173,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -234,8 +234,8 @@ namespace VEPROMS.CSLA.Library /// public partial class RoUsageInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private RoUsageInfo Item { get { return (RoUsageInfo) _Item;} } - public RoUsageInfoListPropertyDescriptor(RoUsageInfoList collection, int index):base(collection, index){;} + private RoUsageInfo Item { get { return (RoUsageInfo)_Item; } } + public RoUsageInfoListPropertyDescriptor(RoUsageInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -246,7 +246,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is RoUsageInfoList) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Role.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Role.cs index 56e737ff..69a78726 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Role.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Role.cs @@ -42,14 +42,14 @@ namespace VEPROMS.CSLA.Library { foreach (RoleAssignment tmp in _RoleAssignments) { - if(tmp.IsDirty)refreshRoleAssignments.Add(tmp); + if (tmp.IsDirty) refreshRoleAssignments.Add(tmp); } } if (_RolePermissions != null && _RolePermissions.IsDirty) { 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 #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); - private static Dictionary _AllByName = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); + private static Dictionary> _AllByName = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (Role tmp in _AllList) { - _AllByPrimaryKey[tmp.RID.ToString()]=tmp; // Primary Key - _AllByName[tmp.Name.ToString()] = tmp; // Unique Index + if (!_AllByPrimaryKey.ContainsKey(tmp.RID.ToString())) + { + _AllByPrimaryKey[tmp.RID.ToString()] = new List(); // Add new list for PrimaryKey + _AllByName[tmp.Name.ToString()] = new List(); // 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); } foreach (Role tmp in remove) @@ -96,14 +101,14 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = rid.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } public static Role GetExistingByName(string name) { ConvertListToDictionary(); string key = name.ToString(); - if (_AllByName.ContainsKey(key)) return _AllByName[key]; + if (_AllByName.ContainsKey(key)) return _AllByName[key][0]; return null; } #endregion @@ -125,7 +130,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RID",true); + CanReadProperty("RID", true); return _RID; } } @@ -135,13 +140,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Name",true); + CanReadProperty("Name", true); return _Name; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Name",true); + CanWriteProperty("Name", true); if (value == null) value = string.Empty; if (_Name != value) { @@ -156,13 +161,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Title",true); + CanReadProperty("Title", true); return _Title; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Title",true); + CanWriteProperty("Title", true); if (value == null) value = string.Empty; if (_Title != value) { @@ -177,13 +182,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -197,13 +202,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UsrID",true); + CanWriteProperty("UsrID", true); if (value == null) value = string.Empty; if (_UsrID != value) { @@ -222,7 +227,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RoleAssignmentCount",true); + CanReadProperty("RoleAssignmentCount", true); return _RoleAssignmentCount; } } @@ -236,10 +241,10 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RoleAssignments",true); - if(_RoleAssignmentCount > 0 && _RoleAssignments == null) + CanReadProperty("RoleAssignments", true); + if (_RoleAssignmentCount > 0 && _RoleAssignments == null) _RoleAssignments = RoleAssignments.GetByRID(RID); - else if(_RoleAssignments == null) + else if (_RoleAssignments == null) _RoleAssignments = RoleAssignments.New(); return _RoleAssignments; } @@ -253,7 +258,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RolePermissionCount",true); + CanReadProperty("RolePermissionCount", true); return _RolePermissionCount; } } @@ -267,21 +272,21 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RolePermissions",true); - if(_RolePermissionCount > 0 && _RolePermissions == null) + CanReadProperty("RolePermissions", true); + if (_RolePermissionCount > 0 && _RolePermissions == null) _RolePermissions = RolePermissions.GetByRID(RID); - else if(_RolePermissions == null) + else if (_RolePermissions == null) _RolePermissions = RolePermissions.New(); return _RolePermissions; } } 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 { - 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 /// @@ -304,23 +309,24 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_RoleAssignments != null && (hasBrokenRules = _RoleAssignments.HasBrokenRules) != null) return hasBrokenRules; - if (_RolePermissions != null && (hasBrokenRules = _RolePermissions.HasBrokenRules) != null) return hasBrokenRules; + if (_RoleAssignments != null && (hasBrokenRules = _RoleAssignments.HasBrokenRules) != null) return hasBrokenRules; + if (_RolePermissions != null && (hasBrokenRules = _RolePermissions.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -435,15 +441,29 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _RoleUnique = 0; + private int _MyRoleUnique; + public int MyRoleUnique + { + get { return _MyRoleUnique; } + } protected Role() {/* require use of factory methods */ + _MyRoleUnique = ++_RoleUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(RID.ToString()); - _AllByName.Remove(Name.ToString()); + if (!_AllByPrimaryKey.ContainsKey(RID.ToString())) return; + List 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() { @@ -500,7 +520,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(rid)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -519,8 +539,8 @@ namespace VEPROMS.CSLA.Library Role tmp = GetExistingByName(name); if (tmp == null) { - tmp=DataPortal.Fetch(new NameCriteria(name)); - _AllList.Add(tmp); + tmp = DataPortal.Fetch(new NameCriteria(name)); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -610,7 +630,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Role.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Role.ReadData", GetHashCode()); try { _RID = dr.GetInt32("RID"); @@ -625,14 +645,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Role.ReadData", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -666,14 +686,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Role.DataPortal_Fetch", ex); } } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -701,7 +721,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Role.DataPortal_Fetch", ex); } @@ -722,13 +742,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Role.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Role.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Role.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -764,11 +784,11 @@ namespace VEPROMS.CSLA.Library // update child objects if (_RoleAssignments != null) _RoleAssignments.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) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Role.SQLInsert", ex); } @@ -776,7 +796,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -804,7 +824,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -812,7 +832,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Role.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Role.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -826,7 +846,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -835,7 +855,7 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { 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 { SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; @@ -869,7 +889,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -892,7 +912,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -918,7 +938,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -930,7 +950,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -946,7 +966,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Role.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Role.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Role.DataPortal_Delete", ex); } @@ -954,7 +974,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] 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 { using (SqlCommand cm = cn.CreateCommand()) @@ -969,7 +989,7 @@ namespace VEPROMS.CSLA.Library } 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); } } @@ -1003,7 +1023,7 @@ namespace VEPROMS.CSLA.Library } 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 { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1021,7 +1041,7 @@ namespace VEPROMS.CSLA.Library } 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); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/RoleAssignment.cs b/PROMS/VEPROMS.CSLA.Library/Generated/RoleAssignment.cs index b3642ab3..b004304f 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/RoleAssignment.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/RoleAssignment.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("AID",true); + CanReadProperty("AID", true); if (_MyAssignment != null) _AID = _MyAssignment.AID; return _AID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyAssignment",true); + CanReadProperty("MyAssignment", true); if (_MyAssignment == null && _AID != 0) _MyAssignment = Assignment.Get(_AID); return _MyAssignment; } @@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GID",true); + CanReadProperty("GID", true); if (_MyGroup != null) _GID = _MyGroup.GID; return _GID; } @@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyGroup",true); + CanReadProperty("MyGroup", true); if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID); return _MyGroup; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyGroup",true); + CanWriteProperty("MyGroup", true); if (_MyGroup != value) { _MyGroup = value; @@ -97,7 +97,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FolderID",true); + CanReadProperty("FolderID", true); if (_MyFolder != null) _FolderID = _MyFolder.FolderID; return _FolderID; } @@ -108,14 +108,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyFolder",true); + CanReadProperty("MyFolder", true); if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID); return _MyFolder; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyFolder",true); + CanWriteProperty("MyFolder", true); if (_MyFolder != value) { _MyFolder = value; @@ -129,13 +129,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("StartDate",true); + CanReadProperty("StartDate", true); return _StartDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("StartDate",true); + CanWriteProperty("StartDate", true); if (value == null) value = string.Empty; _StartDate = value; try @@ -159,13 +159,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("EndDate",true); + CanReadProperty("EndDate", true); return _EndDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("EndDate",true); + CanWriteProperty("EndDate", true); if (value == null) value = string.Empty; _EndDate = value; try @@ -189,13 +189,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -209,13 +209,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UsrID",true); + CanWriteProperty("UsrID", true); if (value == null) value = string.Empty; if (_UsrID != value) { @@ -231,7 +231,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_ParentID",true); + CanReadProperty("Folder_ParentID", true); return _Folder_ParentID; } } @@ -241,7 +241,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_DBID",true); + CanReadProperty("Folder_DBID", true); return _Folder_DBID; } } @@ -251,7 +251,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_Name",true); + CanReadProperty("Folder_Name", true); return _Folder_Name; } } @@ -261,7 +261,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_Title",true); + CanReadProperty("Folder_Title", true); return _Folder_Title; } } @@ -271,7 +271,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_ShortName",true); + CanReadProperty("Folder_ShortName", true); return _Folder_ShortName; } } @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_FormatID",true); + CanReadProperty("Folder_FormatID", true); return _Folder_FormatID; } } @@ -291,7 +291,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_Config",true); + CanReadProperty("Folder_Config", true); return _Folder_Config; } } @@ -301,7 +301,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_DTS",true); + CanReadProperty("Folder_DTS", true); return _Folder_DTS; } } @@ -311,7 +311,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Folder_UsrID",true); + CanReadProperty("Folder_UsrID", true); return _Folder_UsrID; } } @@ -321,7 +321,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Group_GroupName",true); + CanReadProperty("Group_GroupName", true); return _Group_GroupName; } } @@ -331,7 +331,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Group_GroupType",true); + CanReadProperty("Group_GroupType", true); return _Group_GroupType; } } @@ -341,7 +341,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Group_Config",true); + CanReadProperty("Group_Config", true); return _Group_Config; } } @@ -351,7 +351,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Group_DTS",true); + CanReadProperty("Group_DTS", true); return _Group_DTS; } } @@ -361,7 +361,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Group_UsrID",true); + CanReadProperty("Group_UsrID", true); return _Group_UsrID; } } @@ -394,24 +394,24 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules; - if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules; + if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -567,8 +567,8 @@ namespace VEPROMS.CSLA.Library _StartDate = _RoleAssignmentExtension.DefaultStartDate; _DTS = _RoleAssignmentExtension.DefaultDTS; _UsrID = _RoleAssignmentExtension.DefaultUsrID; - _MyGroup = myGroup; - _MyFolder = myFolder; + _MyGroup = myGroup; + _MyFolder = myFolder; ValidationRules.CheckRules(); } internal RoleAssignment(SafeDataReader dr) @@ -580,7 +580,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoleAssignment.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoleAssignment.FetchDR", GetHashCode()); try { _AID = dr.GetInt32("AID"); @@ -608,7 +608,7 @@ namespace VEPROMS.CSLA.Library } 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); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/RoleAssignments.cs b/PROMS/VEPROMS.CSLA.Library/Generated/RoleAssignments.cs index 894632ec..c62cf51a 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/RoleAssignments.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/RoleAssignments.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public RoleAssignment Add(Group myGroup, Folder myFolder) // One to Many { - RoleAssignment assignment = RoleAssignment.New(myGroup, myFolder); - this.Add(assignment); - return assignment; + RoleAssignment assignment = RoleAssignment.New(myGroup, myFolder); + this.Add(assignment); + return assignment; } public void Remove(Assignment myAssignment) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(RoleAssignment roleAssignment in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (RoleAssignment roleAssignment in this) if ((hasBrokenRules = roleAssignment.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(RIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoleAssignments.DataPortal_FetchRID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoleAssignments.DataPortal_FetchRID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } 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); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class RoleAssignmentsPropertyDescriptor : vlnListPropertyDescriptor { - private RoleAssignment Item { get { return (RoleAssignment) _Item;} } - public RoleAssignmentsPropertyDescriptor(RoleAssignments collection, int index):base(collection, index){;} + private RoleAssignment Item { get { return (RoleAssignment)_Item; } } + public RoleAssignmentsPropertyDescriptor(RoleAssignments collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is RoleAssignments) { // 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); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/RoleInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/RoleInfo.cs index 7422d971..af462424 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/RoleInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/RoleInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (RoleInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.RID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.RID.ToString())) + { + _AllByPrimaryKey[tmp.RID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.RID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (RoleInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = rid.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RID",true); + CanReadProperty("RID", true); return _RID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Name",true); + CanReadProperty("Name", true); return _Name; } } @@ -105,7 +109,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Title",true); + CanReadProperty("Title", true); return _Title; } } @@ -115,7 +119,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -125,7 +129,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } } @@ -138,7 +142,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RoleAssignmentCount",true); + CanReadProperty("RoleAssignmentCount", true); return _RoleAssignmentCount; } } @@ -149,7 +153,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RoleAssignments",true); + CanReadProperty("RoleAssignments", true); if (_RoleAssignmentCount < 0 || (_RoleAssignmentCount > 0 && _RoleAssignments == null)) _RoleAssignments = AssignmentInfoList.GetByRID(_RID); if (_RoleAssignmentCount < 0) @@ -159,7 +163,10 @@ namespace VEPROMS.CSLA.Library } internal void RefreshRoleAssignments() { - _RoleAssignmentCount = -1; // This will cause the data to be requeried + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(_RID.ToString())) + foreach (RoleInfo tmp in _AllByPrimaryKey[_RID.ToString()]) + tmp._RoleAssignmentCount = -1; // This will cause the data to be requeried } private int _RolePermissionCount = 0; /// @@ -170,7 +177,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RolePermissionCount",true); + CanReadProperty("RolePermissionCount", true); return _RolePermissionCount; } } @@ -181,7 +188,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RolePermissions",true); + CanReadProperty("RolePermissions", true); if (_RolePermissionCount < 0 || (_RolePermissionCount > 0 && _RolePermissions == null)) _RolePermissions = PermissionInfoList.GetByRID(_RID); if (_RolePermissionCount < 0) @@ -191,7 +198,10 @@ namespace VEPROMS.CSLA.Library } internal void RefreshRolePermissions() { - _RolePermissionCount = -1; // This will cause the data to be requeried + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(_RID.ToString())) + foreach (RoleInfo tmp in _AllByPrimaryKey[_RID.ToString()]) + tmp._RolePermissionCount = -1; // This will cause the data to be requeried } // TODO: Replace base RoleInfo.ToString function as necessary /// @@ -213,14 +223,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _RoleInfoUnique = 0; + private int _MyRoleInfoUnique; + public int MyRoleInfoUnique + { + get { return _MyRoleInfoUnique; } + } private RoleInfo() {/* require use of factory methods */ + _MyRoleInfoUnique = ++_RoleInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(RID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(RID.ToString())) return; + List listRoleInfo = _AllByPrimaryKey[RID.ToString()]; // Get the list of items + listRoleInfo.Remove(this); // Remove the item from the list + if (listRoleInfo.Count == 0) // If there are no items left in the list + _AllByPrimaryKey.Remove(RID.ToString()); // remove the list } public virtual Role Get() { @@ -228,9 +249,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(Role tmp) { - RoleInfo tmpInfo = GetExistingByPrimaryKey(tmp.RID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.RID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (RoleInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(Role tmp) { @@ -251,7 +274,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(rid)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -265,14 +288,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal internal RoleInfo(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoleInfo.Constructor", GetHashCode()); + _MyRoleInfoUnique = ++_RoleInfoUnique; + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoleInfo.Constructor", GetHashCode()); try { ReadData(dr); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RoleInfo.Constructor", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RoleInfo.Constructor", ex); throw new DbCslaException("RoleInfo.Constructor", ex); } } @@ -289,7 +313,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoleInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoleInfo.ReadData", GetHashCode()); try { _RID = dr.GetInt32("RID"); @@ -302,14 +326,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RoleInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RoleInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("RoleInfo.ReadData", ex); } } private void DataPortal_Fetch(PKCriteria criteria) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoleInfo.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoleInfo.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -337,7 +361,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RoleInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RoleInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("RoleInfo.DataPortal_Fetch", ex); } @@ -347,7 +371,7 @@ namespace VEPROMS.CSLA.Library #region extension RoleInfoExtension _RoleInfoExtension = new RoleInfoExtension(); [Serializable()] - partial class RoleInfoExtension : extensionBase {} + partial class RoleInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/RoleInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/RoleInfoList.cs index ba180935..5101de2c 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/RoleInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/RoleInfoList.cs @@ -96,7 +96,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoleInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoleInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -116,7 +116,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RoleInfoList.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RoleInfoList.DataPortal_Fetch", ex); throw new DbCslaException("RoleInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; @@ -177,8 +177,8 @@ namespace VEPROMS.CSLA.Library /// public partial class RoleInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private RoleInfo Item { get { return (RoleInfo) _Item;} } - public RoleInfoListPropertyDescriptor(RoleInfoList collection, int index):base(collection, index){;} + private RoleInfo Item { get { return (RoleInfo)_Item; } } + public RoleInfoListPropertyDescriptor(RoleInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -189,7 +189,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is RoleInfoList) { // Return department and department role separated by comma. - return ((RoleInfoList) value).Items.Count.ToString() + " Roles"; + return ((RoleInfoList)value).Items.Count.ToString() + " Roles"; } return base.ConvertTo(context, culture, value, destType); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/RolePermission.cs b/PROMS/VEPROMS.CSLA.Library/Generated/RolePermission.cs index 1af92685..379d7285 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/RolePermission.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/RolePermission.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("PID",true); + CanReadProperty("PID", true); if (_MyPermission != null) _PID = _MyPermission.PID; return _PID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyPermission",true); + CanReadProperty("MyPermission", true); if (_MyPermission == null && _PID != 0) _MyPermission = Permission.Get(_PID); return _MyPermission; } @@ -68,13 +68,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("PermLevel",true); + CanReadProperty("PermLevel", true); return _PermLevel; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("PermLevel",true); + CanWriteProperty("PermLevel", true); if (_PermLevel != value) { _PermLevel = value; @@ -91,13 +91,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("VersionType",true); + CanReadProperty("VersionType", true); return _VersionType; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("VersionType",true); + CanWriteProperty("VersionType", true); if (_VersionType != value) { _VersionType = value; @@ -114,13 +114,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("PermValue",true); + CanReadProperty("PermValue", true); return _PermValue; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("PermValue",true); + CanWriteProperty("PermValue", true); if (_PermValue != value) { _PermValue = value; @@ -137,13 +137,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("PermAD",true); + CanReadProperty("PermAD", true); return _PermAD; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("PermAD",true); + CanWriteProperty("PermAD", true); if (_PermAD != value) { _PermAD = value; @@ -157,13 +157,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("StartDate",true); + CanReadProperty("StartDate", true); return _StartDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("StartDate",true); + CanWriteProperty("StartDate", true); if (value == null) value = string.Empty; _StartDate = value; try @@ -187,13 +187,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("EndDate",true); + CanReadProperty("EndDate", true); return _EndDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("EndDate",true); + CanWriteProperty("EndDate", true); if (value == null) value = string.Empty; _EndDate = value; try @@ -217,13 +217,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -238,13 +238,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -258,13 +258,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UsrID",true); + CanWriteProperty("UsrID", true); if (value == null) value = string.Empty; if (_UsrID != value) { @@ -295,22 +295,22 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -457,9 +457,9 @@ namespace VEPROMS.CSLA.Library _StartDate = _RolePermissionExtension.DefaultStartDate; _DTS = _RolePermissionExtension.DefaultDTS; _UsrID = _RolePermissionExtension.DefaultUsrID; - _PermLevel = permLevel; - _VersionType = versionType; - _PermValue = permValue; + _PermLevel = permLevel; + _VersionType = versionType; + _PermValue = permValue; ValidationRules.CheckRules(); } internal RolePermission(SafeDataReader dr) @@ -471,7 +471,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RolePermission.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RolePermission.FetchDR", GetHashCode()); try { _PID = dr.GetInt32("PID"); @@ -488,7 +488,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) // FKItem Fetch { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RolePermission.FetchDR", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RolePermission.FetchDR", ex); throw new DbCslaException("RolePermission.Fetch", ex); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/RolePermissions.cs b/PROMS/VEPROMS.CSLA.Library/Generated/RolePermissions.cs index 28ba8b39..00e2aec8 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/RolePermissions.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/RolePermissions.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public RolePermission Add(int permLevel, int versionType, int permValue) // One to Many { - RolePermission permission = RolePermission.New(permLevel, versionType, permValue); - this.Add(permission); - return permission; + RolePermission permission = RolePermission.New(permLevel, versionType, permValue); + this.Add(permission); + return permission; } public void Remove(Permission myPermission) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(RolePermission rolePermission in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (RolePermission rolePermission in this) if ((hasBrokenRules = rolePermission.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(RIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RolePermissions.DataPortal_FetchRID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RolePermissions.DataPortal_FetchRID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("RolePermissions.DataPortal_FetchRID", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("RolePermissions.DataPortal_FetchRID", ex); throw new DbCslaException("RolePermissions.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class RolePermissionsPropertyDescriptor : vlnListPropertyDescriptor { - private RolePermission Item { get { return (RolePermission) _Item;} } - public RolePermissionsPropertyDescriptor(RolePermissions collection, int index):base(collection, index){;} + private RolePermission Item { get { return (RolePermission)_Item; } } + public RolePermissionsPropertyDescriptor(RolePermissions collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is RolePermissions) { // Return department and department role separated by comma. - return ((RolePermissions) value).Items.Count.ToString() + " Permissions"; + return ((RolePermissions)value).Items.Count.ToString() + " Permissions"; } return base.ConvertTo(context, culture, value, destType); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Transition.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Transition.cs index 96a35932..4dbaf6a4 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Transition.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Transition.cs @@ -47,21 +47,25 @@ namespace VEPROMS.CSLA.Library foreach (Transition tmp in _RefreshTransitions) { TransitionInfo.Refresh(tmp); - if(tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent); - if(tmp._MyItemRangeID != null) ItemInfo.Refresh(tmp._MyItemRangeID); - if(tmp._MyItemToID != null) ItemInfo.Refresh(tmp._MyItemToID); + if (tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent); + if (tmp._MyItemRangeID != null) ItemInfo.Refresh(tmp._MyItemRangeID); + if (tmp._MyItemToID != null) ItemInfo.Refresh(tmp._MyItemToID); } } #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (Transition tmp in _AllList) { - _AllByPrimaryKey[tmp.TransitionID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.TransitionID.ToString())) + { + _AllByPrimaryKey[tmp.TransitionID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.TransitionID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (Transition tmp in remove) @@ -71,7 +75,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = transitionID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -93,7 +97,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TransitionID",true); + CanReadProperty("TransitionID", true); return _TransitionID; } } @@ -103,7 +107,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FromID",true); + CanReadProperty("FromID", true); if (_MyContent != null) _FromID = _MyContent.ContentID; return _FromID; } @@ -114,14 +118,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _FromID != 0) _MyContent = Content.Get(_FromID); return _MyContent; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyContent",true); + CanWriteProperty("MyContent", true); if (_MyContent != value) { _MyContent = value; @@ -138,7 +142,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ToID",true); + CanReadProperty("ToID", true); if (_MyItemToID != null) _ToID = _MyItemToID.ItemID; return _ToID; } @@ -149,14 +153,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItemToID",true); + CanReadProperty("MyItemToID", true); if (_MyItemToID == null && _ToID != 0) _MyItemToID = Item.Get(_ToID); return _MyItemToID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyItemToID",true); + CanWriteProperty("MyItemToID", true); if (_MyItemToID != value) { _MyItemToID = value; @@ -170,7 +174,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RangeID",true); + CanReadProperty("RangeID", true); if (_MyItemRangeID != null) _RangeID = _MyItemRangeID.ItemID; return _RangeID; } @@ -181,14 +185,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItemRangeID",true); + CanReadProperty("MyItemRangeID", true); if (_MyItemRangeID == null && _RangeID != 0) _MyItemRangeID = Item.Get(_RangeID); return _MyItemRangeID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyItemRangeID",true); + CanWriteProperty("MyItemRangeID", true); if (_MyItemRangeID != value) { _MyItemRangeID = value; @@ -202,13 +206,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TranType",true); + CanReadProperty("TranType", true); return _TranType; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("TranType",true); + CanWriteProperty("TranType", true); if (_TranType != value) { _TranType = value; @@ -222,13 +226,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -243,13 +247,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -263,13 +267,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -288,7 +292,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TransitionZTransitionCount",true); + CanReadProperty("TransitionZTransitionCount", true); return _TransitionZTransitionCount; } } @@ -302,18 +306,18 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyZTransition",true); - if ( _MyZTransition == null) _MyZTransition = ZTransition.New(this); + CanReadProperty("MyZTransition", true); + if (_MyZTransition == null) _MyZTransition = ZTransition.New(this); return _MyZTransition; } } public override bool IsDirty { - get { return base.IsDirty || (_MyZTransition == null? false : _MyZTransition.IsDirty) || (_MyContent == null? false : _MyContent.IsDirty) || (_MyItemRangeID == null? false : _MyItemRangeID.IsDirty) || (_MyItemToID == null? false : _MyItemToID.IsDirty); } + get { return base.IsDirty || (_MyZTransition == null ? false : _MyZTransition.IsDirty) || (_MyContent == null ? false : _MyContent.IsDirty) || (_MyItemRangeID == null ? false : _MyItemRangeID.IsDirty) || (_MyItemToID == null ? false : _MyItemToID.IsDirty); } } public override bool IsValid { - get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyZTransition == null? true : _MyZTransition.IsValid) && (_MyContent == null? true : _MyContent.IsValid) && (_MyItemRangeID == null? true : _MyItemRangeID.IsValid) && (_MyItemToID == null? true : _MyItemToID.IsValid); } + get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyZTransition == null ? true : _MyZTransition.IsValid) && (_MyContent == null ? true : _MyContent.IsValid) && (_MyItemRangeID == null ? true : _MyItemRangeID.IsValid) && (_MyItemToID == null ? true : _MyItemToID.IsValid); } } // TODO: Replace base Transition.ToString function as necessary /// @@ -336,25 +340,26 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_MyZTransition != null && (hasBrokenRules = _MyZTransition.HasBrokenRules) != null) return hasBrokenRules; - if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules; - if (_MyItemToID != null && (hasBrokenRules = _MyItemToID.HasBrokenRules) != null) return hasBrokenRules; - if (_MyItemRangeID != null && (hasBrokenRules = _MyItemRangeID.HasBrokenRules) != null) return hasBrokenRules; + if (_MyZTransition != null && (hasBrokenRules = _MyZTransition.HasBrokenRules) != null) return hasBrokenRules; + if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules; + if (_MyItemToID != null && (hasBrokenRules = _MyItemToID.HasBrokenRules) != null) return hasBrokenRules; + if (_MyItemRangeID != null && (hasBrokenRules = _MyItemRangeID.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -497,14 +502,25 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _TransitionUnique = 0; + private int _MyTransitionUnique; + public int MyTransitionUnique + { + get { return _MyTransitionUnique; } + } protected Transition() {/* require use of factory methods */ + _MyTransitionUnique = ++_TransitionUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(TransitionID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(TransitionID.ToString())) return; + List listTransition = _AllByPrimaryKey[TransitionID.ToString()]; // Get the list of items + listTransition.Remove(this); // Remove the item from the list + if (listTransition.Count == 0) //If there are no items left in the list + _AllByPrimaryKey.Remove(TransitionID.ToString()); // remove the list } public static Transition New() { @@ -590,7 +606,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(transitionID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -670,7 +686,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.ReadData", GetHashCode()); try { _TransitionID = dr.GetInt32("TransitionID"); @@ -687,14 +703,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Transition.ReadData", ex); } } private void DataPortal_Fetch(PKCriteria criteria) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -725,7 +741,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Transition.DataPortal_Fetch", ex); } @@ -746,13 +762,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Transition.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -761,9 +777,9 @@ namespace VEPROMS.CSLA.Library if (!this.IsDirty) return; try { - if(_MyContent != null) _MyContent.Update(); - if(_MyItemRangeID != null) _MyItemRangeID.Update(); - if(_MyItemToID != null) _MyItemToID.Update(); + if (_MyContent != null) _MyContent.Update(); + if (_MyItemRangeID != null) _MyItemRangeID.Update(); + if (_MyItemToID != null) _MyItemToID.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; using (SqlCommand cm = cn.CreateCommand()) { @@ -793,11 +809,11 @@ namespace VEPROMS.CSLA.Library MarkOld(); // update child objects if (_MyZTransition != null) _MyZTransition.Update(this); - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.SQLInsert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.SQLInsert", GetHashCode()); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Transition.SQLInsert", ex); } @@ -805,7 +821,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] public static byte[] Add(SqlConnection cn, ref int transitionID, Content myContent, Item myItemToID, Item myItemRangeID, int tranType, string config, DateTime dts, string userID) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.Add", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.Add", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -836,7 +852,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.Add", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.Add", ex); throw new DbCslaException("Transition.Add", ex); } } @@ -844,7 +860,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -858,7 +874,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -867,12 +883,12 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.SQLUpdate", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.SQLUpdate", GetHashCode()); try { - if(_MyContent != null) _MyContent.Update(); - if(_MyItemRangeID != null) _MyItemRangeID.Update(); - if(_MyItemToID != null) _MyItemToID.Update(); + if (_MyContent != null) _MyContent.Update(); + if (_MyItemRangeID != null) _MyItemRangeID.Update(); + if (_MyItemToID != null) _MyItemToID.Update(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; if (base.IsDirty) { @@ -906,7 +922,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -928,7 +944,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] public static byte[] Update(SqlConnection cn, ref int transitionID, Content myContent, Item myItemToID, Item myItemRangeID, int tranType, string config, DateTime dts, string userID, ref byte[] lastChanged) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -957,7 +973,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.Update", ex); throw new DbCslaException("Transition.Update", ex); } } @@ -969,7 +985,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] private void DataPortal_Delete(PKCriteria criteria) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.DataPortal_Delete", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.DataPortal_Delete", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -985,7 +1001,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Transition.DataPortal_Delete", ex); } @@ -993,7 +1009,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] public static void Remove(SqlConnection cn, int transitionID) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.Remove", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.Remove", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -1008,7 +1024,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.Remove", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.Remove", ex); throw new DbCslaException("Transition.Remove", ex); } } @@ -1042,7 +1058,7 @@ namespace VEPROMS.CSLA.Library } protected override void DataPortal_Execute() { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Transition.DataPortal_Execute", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Transition.DataPortal_Execute", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1060,7 +1076,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("Transition.DataPortal_Execute", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("Transition.DataPortal_Execute", ex); throw new DbCslaException("Transition.DataPortal_Execute", ex); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/TransitionInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/TransitionInfo.cs index b8d49709..c8471df5 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/TransitionInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/TransitionInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (TransitionInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.TransitionID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.TransitionID.ToString())) + { + _AllByPrimaryKey[tmp.TransitionID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.TransitionID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (TransitionInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = transitionID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TransitionID",true); + CanReadProperty("TransitionID", true); return _TransitionID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FromID",true); + CanReadProperty("FromID", true); if (_MyContent != null) _FromID = _MyContent.ContentID; return _FromID; } @@ -106,7 +110,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _FromID != 0) _MyContent = ContentInfo.Get(_FromID); return _MyContent; } @@ -120,7 +124,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ToID",true); + CanReadProperty("ToID", true); if (_MyItemToID != null) _ToID = _MyItemToID.ItemID; return _ToID; } @@ -131,7 +135,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItemToID",true); + CanReadProperty("MyItemToID", true); if (_MyItemToID == null && _ToID != 0) _MyItemToID = ItemInfo.Get(_ToID); return _MyItemToID; } @@ -142,7 +146,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("RangeID",true); + CanReadProperty("RangeID", true); if (_MyItemRangeID != null) _RangeID = _MyItemRangeID.ItemID; return _RangeID; } @@ -153,7 +157,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyItemRangeID",true); + CanReadProperty("MyItemRangeID", true); if (_MyItemRangeID == null && _RangeID != 0) _MyItemRangeID = ItemInfo.Get(_RangeID); return _MyItemRangeID; } @@ -164,7 +168,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TranType",true); + CanReadProperty("TranType", true); return _TranType; } } @@ -174,7 +178,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } } @@ -184,7 +188,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -194,7 +198,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } } @@ -207,7 +211,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TransitionZTransitionCount",true); + CanReadProperty("TransitionZTransitionCount", true); return _TransitionZTransitionCount; } } @@ -218,7 +222,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyZTransition",true); + CanReadProperty("MyZTransition", true); if (_TransitionZTransitionCount > 0 && _MyZTransition == null) _MyZTransition = ZTransitionInfo.Get(_TransitionID); return _MyZTransition; @@ -244,14 +248,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _TransitionInfoUnique = 0; + private int _MyTransitionInfoUnique; + public int MyTransitionInfoUnique + { + get { return _MyTransitionInfoUnique; } + } private TransitionInfo() {/* require use of factory methods */ + _MyTransitionInfoUnique = ++_TransitionInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(TransitionID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(TransitionID.ToString())) return; + List listTransitionInfo = _AllByPrimaryKey[TransitionID.ToString()]; // Get the list of items + listTransitionInfo.Remove(this); // Remove the item from the list + if (listTransitionInfo.Count == 0) // If there are no items left in the list + _AllByPrimaryKey.Remove(TransitionID.ToString()); // remove the list } public virtual Transition Get() { @@ -259,9 +274,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(Transition tmp) { - TransitionInfo tmpInfo = GetExistingByPrimaryKey(tmp.TransitionID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.TransitionID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (TransitionInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(Transition tmp) { @@ -269,23 +286,23 @@ namespace VEPROMS.CSLA.Library { MyContent.RefreshContentTransitions(); // Update List for old value _FromID = tmp.FromID; // Update the value - _MyContent = null; // Reset list so that the next line gets a new list - MyContent.RefreshContentTransitions(); // Update List for new value } + _MyContent = null; // Reset list so that the next line gets a new list + if (MyContent != null) MyContent.RefreshContentTransitions(); // Update List for new value if (_ToID != tmp.ToID) { MyItemToID.RefreshItemTransitions_ToID(); // Update List for old value _ToID = tmp.ToID; // Update the value - _MyItemToID = null; // Reset list so that the next line gets a new list - MyItemToID.RefreshItemTransitions_ToID(); // Update List for new value } + _MyItemToID = null; // Reset list so that the next line gets a new list + if (MyItemToID != null) MyItemToID.RefreshItemTransitions_ToID(); // Update List for new value if (_RangeID != tmp.RangeID) { MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for old value _RangeID = tmp.RangeID; // Update the value - _MyItemRangeID = null; // Reset list so that the next line gets a new list - MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for new value } + _MyItemRangeID = null; // Reset list so that the next line gets a new list + if (MyItemRangeID != null) MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for new value _TranType = tmp.TranType; _Config = tmp.Config; _DTS = tmp.DTS; @@ -299,9 +316,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(ContentTransition tmp) { - TransitionInfo tmpInfo = GetExistingByPrimaryKey(tmp.TransitionID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.TransitionID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (TransitionInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(ContentTransition tmp) { @@ -309,16 +328,16 @@ namespace VEPROMS.CSLA.Library { MyItemToID.RefreshItemTransitions_ToID(); // Update List for old value _ToID = tmp.ToID; // Update the value - _MyItemToID = null; // Reset list so that the next line gets a new list - MyItemToID.RefreshItemTransitions_ToID(); // Update List for new value } + _MyItemToID = null; // Reset list so that the next line gets a new list + if (MyItemToID != null) MyItemToID.RefreshItemTransitions_ToID(); // Update List for new value if (_RangeID != tmp.RangeID) { MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for old value _RangeID = tmp.RangeID; // Update the value - _MyItemRangeID = null; // Reset list so that the next line gets a new list - MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for new value } + _MyItemRangeID = null; // Reset list so that the next line gets a new list + if (MyItemRangeID != null) MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for new value _TranType = tmp.TranType; _Config = tmp.Config; _DTS = tmp.DTS; @@ -332,9 +351,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(ItemTransition_RangeID tmp) { - TransitionInfo tmpInfo = GetExistingByPrimaryKey(tmp.TransitionID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.TransitionID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (TransitionInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(ItemTransition_RangeID tmp) { @@ -342,16 +363,16 @@ namespace VEPROMS.CSLA.Library { MyContent.RefreshContentTransitions(); // Update List for old value _FromID = tmp.FromID; // Update the value - _MyContent = null; // Reset list so that the next line gets a new list - MyContent.RefreshContentTransitions(); // Update List for new value } + _MyContent = null; // Reset list so that the next line gets a new list + if (MyContent != null) MyContent.RefreshContentTransitions(); // Update List for new value if (_ToID != tmp.ToID) { MyItemToID.RefreshItemTransitions_ToID(); // Update List for old value _ToID = tmp.ToID; // Update the value - _MyItemToID = null; // Reset list so that the next line gets a new list - MyItemToID.RefreshItemTransitions_ToID(); // Update List for new value } + _MyItemToID = null; // Reset list so that the next line gets a new list + if (MyItemToID != null) MyItemToID.RefreshItemTransitions_ToID(); // Update List for new value _TranType = tmp.TranType; _Config = tmp.Config; _DTS = tmp.DTS; @@ -365,9 +386,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(ItemTransition_ToID tmp) { - TransitionInfo tmpInfo = GetExistingByPrimaryKey(tmp.TransitionID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.TransitionID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (TransitionInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(ItemTransition_ToID tmp) { @@ -375,16 +398,16 @@ namespace VEPROMS.CSLA.Library { MyContent.RefreshContentTransitions(); // Update List for old value _FromID = tmp.FromID; // Update the value - _MyContent = null; // Reset list so that the next line gets a new list - MyContent.RefreshContentTransitions(); // Update List for new value } + _MyContent = null; // Reset list so that the next line gets a new list + if (MyContent != null) MyContent.RefreshContentTransitions(); // Update List for new value if (_RangeID != tmp.RangeID) { MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for old value _RangeID = tmp.RangeID; // Update the value - _MyItemRangeID = null; // Reset list so that the next line gets a new list - MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for new value } + _MyItemRangeID = null; // Reset list so that the next line gets a new list + if (MyItemRangeID != null) MyItemRangeID.RefreshItemTransitions_RangeID(); // Update List for new value _TranType = tmp.TranType; _Config = tmp.Config; _DTS = tmp.DTS; @@ -406,7 +429,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(transitionID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -420,14 +443,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal internal TransitionInfo(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] TransitionInfo.Constructor", GetHashCode()); + _MyTransitionInfoUnique = ++_TransitionInfoUnique; + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] TransitionInfo.Constructor", GetHashCode()); try { ReadData(dr); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("TransitionInfo.Constructor", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("TransitionInfo.Constructor", ex); throw new DbCslaException("TransitionInfo.Constructor", ex); } } @@ -444,7 +468,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] TransitionInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] TransitionInfo.ReadData", GetHashCode()); try { _TransitionID = dr.GetInt32("TransitionID"); @@ -459,14 +483,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("TransitionInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("TransitionInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("TransitionInfo.ReadData", ex); } } private void DataPortal_Fetch(PKCriteria criteria) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] TransitionInfo.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] TransitionInfo.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -494,7 +518,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("TransitionInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("TransitionInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("TransitionInfo.DataPortal_Fetch", ex); } @@ -504,7 +528,7 @@ namespace VEPROMS.CSLA.Library #region extension TransitionInfoExtension _TransitionInfoExtension = new TransitionInfoExtension(); [Serializable()] - partial class TransitionInfoExtension : extensionBase {} + partial class TransitionInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/TransitionInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/TransitionInfoList.cs index c1e61270..0ee8f648 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/TransitionInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/TransitionInfoList.cs @@ -138,7 +138,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] TransitionInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] TransitionInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -158,7 +158,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("TransitionInfoList.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("TransitionInfoList.DataPortal_Fetch", ex); throw new DbCslaException("TransitionInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; @@ -180,7 +180,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(FromIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] TransitionInfoList.DataPortal_FetchFromID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] TransitionInfoList.DataPortal_FetchFromID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -201,7 +201,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("TransitionInfoList.DataPortal_FetchFromID", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("TransitionInfoList.DataPortal_FetchFromID", ex); throw new DbCslaException("TransitionInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; @@ -223,7 +223,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(RangeIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] TransitionInfoList.DataPortal_FetchRangeID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] TransitionInfoList.DataPortal_FetchRangeID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -244,7 +244,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("TransitionInfoList.DataPortal_FetchRangeID", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("TransitionInfoList.DataPortal_FetchRangeID", ex); throw new DbCslaException("TransitionInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; @@ -266,7 +266,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(ToIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] TransitionInfoList.DataPortal_FetchToID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] TransitionInfoList.DataPortal_FetchToID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -287,7 +287,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("TransitionInfoList.DataPortal_FetchToID", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("TransitionInfoList.DataPortal_FetchToID", ex); throw new DbCslaException("TransitionInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; @@ -348,8 +348,8 @@ namespace VEPROMS.CSLA.Library /// public partial class TransitionInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private TransitionInfo Item { get { return (TransitionInfo) _Item;} } - public TransitionInfoListPropertyDescriptor(TransitionInfoList collection, int index):base(collection, index){;} + private TransitionInfo Item { get { return (TransitionInfo)_Item; } } + public TransitionInfoListPropertyDescriptor(TransitionInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -360,7 +360,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is TransitionInfoList) { // Return department and department role separated by comma. - return ((TransitionInfoList) value).Items.Count.ToString() + " Transitions"; + return ((TransitionInfoList)value).Items.Count.ToString() + " Transitions"; } return base.ConvertTo(context, culture, value, destType); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/User.cs b/PROMS/VEPROMS.CSLA.Library/Generated/User.cs index 62be73c1..d6a634fe 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/User.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/User.cs @@ -41,7 +41,7 @@ namespace VEPROMS.CSLA.Library { foreach (UserMembership tmp in _UserMemberships) { - if(tmp.IsDirty)refreshUserMemberships.Add(tmp); + if (tmp.IsDirty) refreshUserMemberships.Add(tmp); } } } @@ -65,13 +65,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (User tmp in _AllList) { - _AllByPrimaryKey[tmp.UID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.UID.ToString())) + { + _AllByPrimaryKey[tmp.UID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.UID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (User tmp in remove) @@ -81,7 +85,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = uid.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -103,7 +107,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UID",true); + CanReadProperty("UID", true); return _UID; } } @@ -113,13 +117,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserID",true); + CanWriteProperty("UserID", true); if (value == null) value = string.Empty; if (_UserID != value) { @@ -134,13 +138,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FirstName",true); + CanReadProperty("FirstName", true); return _FirstName; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("FirstName",true); + CanWriteProperty("FirstName", true); if (value == null) value = string.Empty; if (_FirstName != value) { @@ -155,13 +159,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MiddleName",true); + CanReadProperty("MiddleName", true); return _MiddleName; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MiddleName",true); + CanWriteProperty("MiddleName", true); if (value == null) value = string.Empty; if (_MiddleName != value) { @@ -176,13 +180,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("LastName",true); + CanReadProperty("LastName", true); return _LastName; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("LastName",true); + CanWriteProperty("LastName", true); if (value == null) value = string.Empty; if (_LastName != value) { @@ -197,13 +201,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Suffix",true); + CanReadProperty("Suffix", true); return _Suffix; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Suffix",true); + CanWriteProperty("Suffix", true); if (value == null) value = string.Empty; if (_Suffix != value) { @@ -218,13 +222,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("CourtesyTitle",true); + CanReadProperty("CourtesyTitle", true); return _CourtesyTitle; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("CourtesyTitle",true); + CanWriteProperty("CourtesyTitle", true); if (value == null) value = string.Empty; if (_CourtesyTitle != value) { @@ -239,13 +243,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("PhoneNumber",true); + CanReadProperty("PhoneNumber", true); return _PhoneNumber; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("PhoneNumber",true); + CanWriteProperty("PhoneNumber", true); if (value == null) value = string.Empty; if (_PhoneNumber != value) { @@ -260,13 +264,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("CFGName",true); + CanReadProperty("CFGName", true); return _CFGName; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("CFGName",true); + CanWriteProperty("CFGName", true); if (value == null) value = string.Empty; if (_CFGName != value) { @@ -281,13 +285,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserLogin",true); + CanReadProperty("UserLogin", true); return _UserLogin; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserLogin",true); + CanWriteProperty("UserLogin", true); if (value == null) value = string.Empty; if (_UserLogin != value) { @@ -302,13 +306,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserName",true); + CanReadProperty("UserName", true); return _UserName; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UserName",true); + CanWriteProperty("UserName", true); if (value == null) value = string.Empty; if (_UserName != value) { @@ -323,13 +327,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -344,13 +348,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -364,13 +368,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UsrID",true); + CanWriteProperty("UsrID", true); if (value == null) value = string.Empty; if (_UsrID != value) { @@ -389,7 +393,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserMembershipCount",true); + CanReadProperty("UserMembershipCount", true); return _UserMembershipCount; } } @@ -403,21 +407,21 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserMemberships",true); - if(_UserMembershipCount > 0 && _UserMemberships == null) + CanReadProperty("UserMemberships", true); + if (_UserMembershipCount > 0 && _UserMemberships == null) _UserMemberships = UserMemberships.GetByUID(UID); - else if(_UserMemberships == null) + else if (_UserMemberships == null) _UserMemberships = UserMemberships.New(); return _UserMemberships; } } public override bool IsDirty { - get { return base.IsDirty || (_UserMemberships == null? false : _UserMemberships.IsDirty); } + get { return base.IsDirty || (_UserMemberships == null ? false : _UserMemberships.IsDirty); } } public override bool IsValid { - get { return (IsNew && !IsDirty ? true : base.IsValid) && (_UserMemberships == null? true : _UserMemberships.IsValid); } + get { return (IsNew && !IsDirty ? true : base.IsValid) && (_UserMemberships == null ? true : _UserMemberships.IsValid); } } // TODO: Replace base User.ToString function as necessary /// @@ -440,22 +444,23 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; - if (_UserMemberships != null && (hasBrokenRules = _UserMemberships.HasBrokenRules) != null) return hasBrokenRules; + if (_UserMemberships != null && (hasBrokenRules = _UserMemberships.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -612,14 +617,25 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _UserUnique = 0; + private int _MyUserUnique; + public int MyUserUnique + { + get { return _MyUserUnique; } + } protected User() {/* require use of factory methods */ + _MyUserUnique = ++_UserUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(UID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(UID.ToString())) return; + List listUser = _AllByPrimaryKey[UID.ToString()]; // Get the list of items + listUser.Remove(this); // Remove the item from the list + if (listUser.Count == 0) //If there are no items left in the list + _AllByPrimaryKey.Remove(UID.ToString()); // remove the list } public static User New() { @@ -709,7 +725,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(uid)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -789,7 +805,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] User.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] User.ReadData", GetHashCode()); try { _UID = dr.GetInt32("UID"); @@ -812,14 +828,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("User.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("User.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("User.ReadData", ex); } } private void DataPortal_Fetch(PKCriteria criteria) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] User.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] User.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -850,7 +866,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("User.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("User.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("User.DataPortal_Fetch", ex); } @@ -871,13 +887,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("User.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("User.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("User.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] User.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] User.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -921,11 +937,11 @@ namespace VEPROMS.CSLA.Library MarkOld(); // update child objects if (_UserMemberships != null) _UserMemberships.Update(this); - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] User.SQLInsert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] User.SQLInsert", GetHashCode()); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("User.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("User.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("User.SQLInsert", ex); } @@ -933,7 +949,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] public static byte[] Add(SqlConnection cn, ref int uid, string userID, string firstName, string middleName, string lastName, string suffix, string courtesyTitle, string phoneNumber, string cFGName, string userLogin, string userName, string config, DateTime dts, string usrID) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] User.Add", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] User.Add", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -970,7 +986,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("User.Add", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("User.Add", ex); throw new DbCslaException("User.Add", ex); } } @@ -978,7 +994,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] User.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] User.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -992,7 +1008,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("User.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("User.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -1001,7 +1017,7 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] User.SQLUpdate", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] User.SQLUpdate", GetHashCode()); try { SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; @@ -1043,7 +1059,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("User.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("User.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -1065,7 +1081,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] public static byte[] Update(SqlConnection cn, ref int uid, string userID, string firstName, string middleName, string lastName, string suffix, string courtesyTitle, string phoneNumber, string cFGName, string userLogin, string userName, string config, DateTime dts, string usrID, ref byte[] lastChanged) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] User.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] User.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -1100,7 +1116,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("User.Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("User.Update", ex); throw new DbCslaException("User.Update", ex); } } @@ -1112,7 +1128,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] private void DataPortal_Delete(PKCriteria criteria) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] User.DataPortal_Delete", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] User.DataPortal_Delete", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1128,7 +1144,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("User.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("User.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("User.DataPortal_Delete", ex); } @@ -1136,7 +1152,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] public static void Remove(SqlConnection cn, int uid) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] User.Remove", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] User.Remove", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -1151,7 +1167,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("User.Remove", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("User.Remove", ex); throw new DbCslaException("User.Remove", ex); } } @@ -1185,7 +1201,7 @@ namespace VEPROMS.CSLA.Library } protected override void DataPortal_Execute() { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] User.DataPortal_Execute", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] User.DataPortal_Execute", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -1203,7 +1219,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("User.DataPortal_Execute", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("User.DataPortal_Execute", ex); throw new DbCslaException("User.DataPortal_Execute", ex); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/UserInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/UserInfo.cs index 4ba52b22..9959debd 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/UserInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/UserInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (UserInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.UID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.UID.ToString())) + { + _AllByPrimaryKey[tmp.UID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.UID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (UserInfo tmp in remove) @@ -57,7 +61,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = uid.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UID",true); + CanReadProperty("UID", true); return _UID; } } @@ -95,7 +99,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserID",true); + CanReadProperty("UserID", true); return _UserID; } } @@ -105,7 +109,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("FirstName",true); + CanReadProperty("FirstName", true); return _FirstName; } } @@ -115,7 +119,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MiddleName",true); + CanReadProperty("MiddleName", true); return _MiddleName; } } @@ -125,7 +129,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("LastName",true); + CanReadProperty("LastName", true); return _LastName; } } @@ -135,7 +139,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Suffix",true); + CanReadProperty("Suffix", true); return _Suffix; } } @@ -145,7 +149,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("CourtesyTitle",true); + CanReadProperty("CourtesyTitle", true); return _CourtesyTitle; } } @@ -155,7 +159,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("PhoneNumber",true); + CanReadProperty("PhoneNumber", true); return _PhoneNumber; } } @@ -165,7 +169,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("CFGName",true); + CanReadProperty("CFGName", true); return _CFGName; } } @@ -175,7 +179,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserLogin",true); + CanReadProperty("UserLogin", true); return _UserLogin; } } @@ -185,7 +189,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserName",true); + CanReadProperty("UserName", true); return _UserName; } } @@ -195,7 +199,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } } @@ -205,7 +209,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } } @@ -215,7 +219,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } } @@ -228,7 +232,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserMembershipCount",true); + CanReadProperty("UserMembershipCount", true); return _UserMembershipCount; } } @@ -239,7 +243,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UserMemberships",true); + CanReadProperty("UserMemberships", true); if (_UserMembershipCount < 0 || (_UserMembershipCount > 0 && _UserMemberships == null)) _UserMemberships = MembershipInfoList.GetByUID(_UID); if (_UserMembershipCount < 0) @@ -249,7 +253,10 @@ namespace VEPROMS.CSLA.Library } internal void RefreshUserMemberships() { - _UserMembershipCount = -1; // This will cause the data to be requeried + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(_UID.ToString())) + foreach (UserInfo tmp in _AllByPrimaryKey[_UID.ToString()]) + tmp._UserMembershipCount = -1; // This will cause the data to be requeried } // TODO: Replace base UserInfo.ToString function as necessary /// @@ -271,14 +278,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _UserInfoUnique = 0; + private int _MyUserInfoUnique; + public int MyUserInfoUnique + { + get { return _MyUserInfoUnique; } + } private UserInfo() {/* require use of factory methods */ + _MyUserInfoUnique = ++_UserInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(UID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(UID.ToString())) return; + List listUserInfo = _AllByPrimaryKey[UID.ToString()]; // Get the list of items + listUserInfo.Remove(this); // Remove the item from the list + if (listUserInfo.Count == 0) // If there are no items left in the list + _AllByPrimaryKey.Remove(UID.ToString()); // remove the list } public virtual User Get() { @@ -286,9 +304,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(User tmp) { - UserInfo tmpInfo = GetExistingByPrimaryKey(tmp.UID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.UID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (UserInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(User tmp) { @@ -318,7 +338,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(uid)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -332,14 +352,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal internal UserInfo(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] UserInfo.Constructor", GetHashCode()); + _MyUserInfoUnique = ++_UserInfoUnique; + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] UserInfo.Constructor", GetHashCode()); try { ReadData(dr); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("UserInfo.Constructor", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("UserInfo.Constructor", ex); throw new DbCslaException("UserInfo.Constructor", ex); } } @@ -356,7 +377,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] UserInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] UserInfo.ReadData", GetHashCode()); try { _UID = dr.GetInt32("UID"); @@ -377,14 +398,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("UserInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("UserInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("UserInfo.ReadData", ex); } } private void DataPortal_Fetch(PKCriteria criteria) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] UserInfo.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] UserInfo.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -412,7 +433,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("UserInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("UserInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("UserInfo.DataPortal_Fetch", ex); } @@ -422,7 +443,7 @@ namespace VEPROMS.CSLA.Library #region extension UserInfoExtension _UserInfoExtension = new UserInfoExtension(); [Serializable()] - partial class UserInfoExtension : extensionBase {} + partial class UserInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/UserInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/UserInfoList.cs index a72e7450..fb63966c 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/UserInfoList.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/UserInfoList.cs @@ -96,7 +96,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch() { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] UserInfoList.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] UserInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -116,7 +116,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("UserInfoList.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("UserInfoList.DataPortal_Fetch", ex); throw new DbCslaException("UserInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; @@ -177,8 +177,8 @@ namespace VEPROMS.CSLA.Library /// public partial class UserInfoListPropertyDescriptor : vlnListPropertyDescriptor { - private UserInfo Item { get { return (UserInfo) _Item;} } - public UserInfoListPropertyDescriptor(UserInfoList collection, int index):base(collection, index){;} + private UserInfo Item { get { return (UserInfo)_Item; } } + public UserInfoListPropertyDescriptor(UserInfoList collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -189,7 +189,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is UserInfoList) { // Return department and department role separated by comma. - return ((UserInfoList) value).Items.Count.ToString() + " Users"; + return ((UserInfoList)value).Items.Count.ToString() + " Users"; } return base.ConvertTo(context, culture, value, destType); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/UserMembership.cs b/PROMS/VEPROMS.CSLA.Library/Generated/UserMembership.cs index cdc905ef..3071fc6d 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/UserMembership.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/UserMembership.cs @@ -42,7 +42,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UGID",true); + CanReadProperty("UGID", true); if (_MyMembership != null) _UGID = _MyMembership.UGID; return _UGID; } @@ -54,7 +54,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyMembership",true); + CanReadProperty("MyMembership", true); if (_MyMembership == null && _UGID != 0) _MyMembership = Membership.Get(_UGID); return _MyMembership; } @@ -65,7 +65,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("GID",true); + CanReadProperty("GID", true); if (_MyGroup != null) _GID = _MyGroup.GID; return _GID; } @@ -76,14 +76,14 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyGroup",true); + CanReadProperty("MyGroup", true); if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID); return _MyGroup; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("MyGroup",true); + CanWriteProperty("MyGroup", true); if (_MyGroup != value) { _MyGroup = value; @@ -97,13 +97,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("StartDate",true); + CanReadProperty("StartDate", true); return _StartDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("StartDate",true); + CanWriteProperty("StartDate", true); if (value == null) value = string.Empty; _StartDate = value; try @@ -127,13 +127,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("EndDate",true); + CanReadProperty("EndDate", true); return _EndDate; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("EndDate",true); + CanWriteProperty("EndDate", true); if (value == null) value = string.Empty; _EndDate = value; try @@ -157,13 +157,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Config",true); + CanReadProperty("Config", true); return _Config; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Config",true); + CanWriteProperty("Config", true); if (value == null) value = string.Empty; if (_Config != value) { @@ -178,13 +178,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("DTS",true); + CanReadProperty("DTS", true); return _DTS; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("DTS",true); + CanWriteProperty("DTS", true); if (_DTS != value) { _DTS = value; @@ -198,13 +198,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("UsrID",true); + CanReadProperty("UsrID", true); return _UsrID; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("UsrID",true); + CanWriteProperty("UsrID", true); if (value == null) value = string.Empty; if (_UsrID != value) { @@ -220,7 +220,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Group_GroupName",true); + CanReadProperty("Group_GroupName", true); return _Group_GroupName; } } @@ -230,7 +230,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Group_GroupType",true); + CanReadProperty("Group_GroupType", true); return _Group_GroupType; } } @@ -240,7 +240,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Group_Config",true); + CanReadProperty("Group_Config", true); return _Group_Config; } } @@ -250,7 +250,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Group_DTS",true); + CanReadProperty("Group_DTS", true); return _Group_DTS; } } @@ -260,7 +260,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Group_UsrID",true); + CanReadProperty("Group_UsrID", true); return _Group_UsrID; } } @@ -293,23 +293,23 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { get { - if(_CheckingBrokenRules)return null; + if (_CheckingBrokenRules) return null; if (BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; - IVEHasBrokenRules hasBrokenRules = null; - if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules; - return hasBrokenRules; + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + if (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -458,7 +458,7 @@ namespace VEPROMS.CSLA.Library _StartDate = _UserMembershipExtension.DefaultStartDate; _DTS = _UserMembershipExtension.DefaultDTS; _UsrID = _UserMembershipExtension.DefaultUsrID; - _MyGroup = myGroup; + _MyGroup = myGroup; ValidationRules.CheckRules(); } internal UserMembership(SafeDataReader dr) @@ -470,7 +470,7 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal private void Fetch(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] UserMembership.FetchDR", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] UserMembership.FetchDR", GetHashCode()); try { _UGID = dr.GetInt32("UGID"); @@ -489,7 +489,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) // FKItem Fetch { - if(_MyLog.IsErrorEnabled)_MyLog.Error("UserMembership.FetchDR", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("UserMembership.FetchDR", ex); throw new DbCslaException("UserMembership.Fetch", ex); } MarkOld(); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/UserMemberships.cs b/PROMS/VEPROMS.CSLA.Library/Generated/UserMemberships.cs index 1c6cd007..3b80a2b0 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/UserMemberships.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/UserMemberships.cs @@ -59,9 +59,9 @@ namespace VEPROMS.CSLA.Library } public UserMembership Add(Group myGroup) // One to Many { - UserMembership membership = UserMembership.New(myGroup); - this.Add(membership); - return membership; + UserMembership membership = UserMembership.New(myGroup); + this.Add(membership); + return membership; } public void Remove(Membership myMembership) { @@ -94,8 +94,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules=null; - foreach(UserMembership userMembership in this) + IVEHasBrokenRules hasBrokenRules = null; + foreach (UserMembership userMembership in this) if ((hasBrokenRules = userMembership.HasBrokenRules) != null) return hasBrokenRules; return hasBrokenRules; } @@ -104,8 +104,8 @@ namespace VEPROMS.CSLA.Library { get { - IVEHasBrokenRules hasBrokenRules = HasBrokenRules; - return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); } } #endregion @@ -165,7 +165,7 @@ namespace VEPROMS.CSLA.Library private void DataPortal_Fetch(UIDCriteria criteria) { this.RaiseListChangedEvents = false; - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] UserMemberships.DataPortal_FetchUID", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] UserMemberships.DataPortal_FetchUID", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -184,7 +184,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("UserMemberships.DataPortal_FetchUID", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("UserMemberships.DataPortal_FetchUID", ex); throw new DbCslaException("UserMemberships.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; @@ -269,8 +269,8 @@ namespace VEPROMS.CSLA.Library /// public partial class UserMembershipsPropertyDescriptor : vlnListPropertyDescriptor { - private UserMembership Item { get { return (UserMembership) _Item;} } - public UserMembershipsPropertyDescriptor(UserMemberships collection, int index):base(collection, index){;} + private UserMembership Item { get { return (UserMembership)_Item; } } + public UserMembershipsPropertyDescriptor(UserMemberships collection, int index) : base(collection, index) { ;} } #endregion #region Converter @@ -281,7 +281,7 @@ namespace VEPROMS.CSLA.Library if (destType == typeof(string) && value is UserMemberships) { // Return department and department role separated by comma. - return ((UserMemberships) value).Items.Count.ToString() + " Memberships"; + return ((UserMemberships)value).Items.Count.ToString() + " Memberships"; } return base.ConvertTo(context, culture, value, destType); } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ZContent.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ZContent.cs index 21d53593..bf974422 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ZContent.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ZContent.cs @@ -52,13 +52,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (ZContent tmp in _AllList) { - _AllByPrimaryKey[tmp.ContentID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString())) + { + _AllByPrimaryKey[tmp.ContentID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (ZContent tmp in remove) @@ -68,7 +72,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = contentID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentID",true); + CanReadProperty("ContentID", true); if (_MyContent != null) _ContentID = _MyContent.ContentID; return _ContentID; } @@ -97,7 +101,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID); return _MyContent; } @@ -108,13 +112,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("OldStepSequence",true); + CanReadProperty("OldStepSequence", true); return _OldStepSequence; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("OldStepSequence",true); + CanWriteProperty("OldStepSequence", true); if (value == null) value = string.Empty; if (_OldStepSequence != value) { @@ -149,21 +153,22 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -248,14 +253,25 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _ZContentUnique = 0; + private int _MyZContentUnique; + public int MyZContentUnique + { + get { return _MyZContentUnique; } + } protected ZContent() {/* require use of factory methods */ + _MyZContentUnique = ++_ZContentUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(ContentID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString())) return; + List listZContent = _AllByPrimaryKey[ContentID.ToString()]; // Get the list of items + listZContent.Remove(this); // Remove the item from the list + if (listZContent.Count == 0) //If there are no items left in the list + _AllByPrimaryKey.Remove(ContentID.ToString()); // remove the list } public static ZContent New() { @@ -311,7 +327,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(contentID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -389,7 +405,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZContent.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContent.ReadData", GetHashCode()); try { _ContentID = dr.GetInt32("ContentID"); @@ -399,14 +415,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZContent.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContent.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ZContent.ReadData", ex); } } private void DataPortal_Fetch(PKCriteria criteria) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZContent.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContent.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -434,7 +450,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZContent.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContent.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ZContent.DataPortal_Fetch", ex); } @@ -455,13 +471,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZContent.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContent.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ZContent.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZContent.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContent.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -489,11 +505,11 @@ namespace VEPROMS.CSLA.Library } MarkOld(); // update child objects - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZContent.SQLInsert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContent.SQLInsert", GetHashCode()); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZContent.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContent.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ZContent.SQLInsert", ex); } @@ -501,7 +517,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] public static byte[] Add(SqlConnection cn, Content myContent, string oldStepSequence) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZContent.Add", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContent.Add", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -523,7 +539,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZContent.Add", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContent.Add", ex); throw new DbCslaException("ZContent.Add", ex); } } @@ -531,7 +547,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZContent.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContent.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -545,7 +561,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZContent.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContent.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -554,7 +570,7 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZContent.SQLUpdate", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContent.SQLUpdate", GetHashCode()); try { SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; @@ -583,7 +599,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZContent.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContent.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -593,18 +609,18 @@ namespace VEPROMS.CSLA.Library if (!this.IsDirty) return; if (base.IsDirty) { - SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; - if (IsNew) - _LastChanged = ZContent.Add(cn, content, _OldStepSequence); - else - _LastChanged = ZContent.Update(cn, content, _OldStepSequence, ref _LastChanged); - MarkOld(); + SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; + if (IsNew) + _LastChanged = ZContent.Add(cn, content, _OldStepSequence); + else + _LastChanged = ZContent.Update(cn, content, _OldStepSequence, ref _LastChanged); + MarkOld(); } } [Transactional(TransactionalTypes.TransactionScope)] public static byte[] Update(SqlConnection cn, Content myContent, string oldStepSequence, ref byte[] lastChanged) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZContent.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContent.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -627,7 +643,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZContent.Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContent.Update", ex); throw new DbCslaException("ZContent.Update", ex); } } @@ -639,7 +655,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] private void DataPortal_Delete(PKCriteria criteria) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZContent.DataPortal_Delete", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContent.DataPortal_Delete", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -655,7 +671,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZContent.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContent.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ZContent.DataPortal_Delete", ex); } @@ -663,7 +679,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] public static void Remove(SqlConnection cn, int contentID) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZContent.Remove", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContent.Remove", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -678,7 +694,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZContent.Remove", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContent.Remove", ex); throw new DbCslaException("ZContent.Remove", ex); } } @@ -712,7 +728,7 @@ namespace VEPROMS.CSLA.Library } protected override void DataPortal_Execute() { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZContent.DataPortal_Execute", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContent.DataPortal_Execute", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -730,7 +746,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZContent.DataPortal_Execute", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContent.DataPortal_Execute", ex); throw new DbCslaException("ZContent.DataPortal_Execute", ex); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ZContentInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ZContentInfo.cs index 98935f09..d24533e6 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ZContentInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ZContentInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (ZContentInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.ContentID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.ContentID.ToString())) + { + _AllByPrimaryKey[tmp.ContentID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (ZContentInfo tmp in remove) @@ -53,7 +57,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = contentID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -81,7 +85,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("ContentID",true); + CanReadProperty("ContentID", true); if (_MyContent != null) _ContentID = _MyContent.ContentID; return _ContentID; } @@ -93,7 +97,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyContent",true); + CanReadProperty("MyContent", true); if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID); return _MyContent; } @@ -104,7 +108,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("OldStepSequence",true); + CanReadProperty("OldStepSequence", true); return _OldStepSequence; } } @@ -128,14 +132,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _ZContentInfoUnique = 0; + private int _MyZContentInfoUnique; + public int MyZContentInfoUnique + { + get { return _MyZContentInfoUnique; } + } private ZContentInfo() {/* require use of factory methods */ + _MyZContentInfoUnique = ++_ZContentInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(ContentID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(ContentID.ToString())) return; + List listZContentInfo = _AllByPrimaryKey[ContentID.ToString()]; // Get the list of items + listZContentInfo.Remove(this); // Remove the item from the list + if (listZContentInfo.Count == 0) // If there are no items left in the list + _AllByPrimaryKey.Remove(ContentID.ToString()); // remove the list } public virtual ZContent Get() { @@ -143,9 +158,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(ZContent tmp) { - ZContentInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.ContentID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (ZContentInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(ZContent tmp) { @@ -164,7 +181,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(contentID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") { @@ -181,14 +198,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal internal ZContentInfo(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZContentInfo.Constructor", GetHashCode()); + _MyZContentInfoUnique = ++_ZContentInfoUnique; + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContentInfo.Constructor", GetHashCode()); try { ReadData(dr); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZContentInfo.Constructor", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContentInfo.Constructor", ex); throw new DbCslaException("ZContentInfo.Constructor", ex); } } @@ -205,7 +223,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZContentInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContentInfo.ReadData", GetHashCode()); try { _ContentID = dr.GetInt32("ContentID"); @@ -213,14 +231,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZContentInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContentInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ZContentInfo.ReadData", ex); } } private void DataPortal_Fetch(PKCriteria criteria) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZContentInfo.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContentInfo.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -248,7 +266,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZContentInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContentInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ZContentInfo.DataPortal_Fetch", ex); } @@ -258,7 +276,7 @@ namespace VEPROMS.CSLA.Library #region extension ZContentInfoExtension _ZContentInfoExtension = new ZContentInfoExtension(); [Serializable()] - partial class ZContentInfoExtension : extensionBase {} + partial class ZContentInfoExtension : extensionBase { } [Serializable()] class extensionBase { diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ZTransition.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ZTransition.cs index 365ea14a..291f42cc 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ZTransition.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ZTransition.cs @@ -52,13 +52,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (ZTransition tmp in _AllList) { - _AllByPrimaryKey[tmp.TransitionID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.TransitionID.ToString())) + { + _AllByPrimaryKey[tmp.TransitionID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.TransitionID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (ZTransition tmp in remove) @@ -68,7 +72,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = transitionID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -85,7 +89,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TransitionID",true); + CanReadProperty("TransitionID", true); if (_MyTransition != null) _TransitionID = _MyTransition.TransitionID; return _TransitionID; } @@ -97,7 +101,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyTransition",true); + CanReadProperty("MyTransition", true); if (_MyTransition == null && _TransitionID != 0) _MyTransition = Transition.Get(_TransitionID); return _MyTransition; } @@ -108,13 +112,13 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Oldto",true); + CanReadProperty("Oldto", true); return _Oldto; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] set { - CanWriteProperty("Oldto",true); + CanWriteProperty("Oldto", true); if (value == null) value = string.Empty; if (_Oldto != value) { @@ -149,21 +153,22 @@ namespace VEPROMS.CSLA.Library #endregion #region ValidationRules [NonSerialized] - private bool _CheckingBrokenRules=false; + private bool _CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules { - get { - if(_CheckingBrokenRules)return null; + get + { + if (_CheckingBrokenRules) return null; if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; try { - _CheckingBrokenRules=true; + _CheckingBrokenRules = true; IVEHasBrokenRules hasBrokenRules = null; return hasBrokenRules; } finally { - _CheckingBrokenRules=false; + _CheckingBrokenRules = false; } } } @@ -248,14 +253,25 @@ namespace VEPROMS.CSLA.Library #region Factory Methods public int CurrentEditLevel { get { return EditLevel; } } + private static int _ZTransitionUnique = 0; + private int _MyZTransitionUnique; + public int MyZTransitionUnique + { + get { return _MyZTransitionUnique; } + } protected ZTransition() {/* require use of factory methods */ + _MyZTransitionUnique = ++_ZTransitionUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(TransitionID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(TransitionID.ToString())) return; + List listZTransition = _AllByPrimaryKey[TransitionID.ToString()]; // Get the list of items + listZTransition.Remove(this); // Remove the item from the list + if (listZTransition.Count == 0) //If there are no items left in the list + _AllByPrimaryKey.Remove(TransitionID.ToString()); // remove the list } public static ZTransition New() { @@ -311,7 +327,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(transitionID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") tmp = null; return tmp; @@ -389,7 +405,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZTransition.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransition.ReadData", GetHashCode()); try { _TransitionID = dr.GetInt32("TransitionID"); @@ -399,14 +415,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZTransition.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransition.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ZTransition.ReadData", ex); } } private void DataPortal_Fetch(PKCriteria criteria) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZTransition.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransition.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -434,7 +450,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZTransition.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransition.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ZTransition.DataPortal_Fetch", ex); } @@ -455,13 +471,13 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZTransition.DataPortal_Insert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransition.DataPortal_Insert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ZTransition.DataPortal_Insert", ex); } finally { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZTransition.DataPortal_Insert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransition.DataPortal_Insert", GetHashCode()); } } [Transactional(TransactionalTypes.TransactionScope)] @@ -489,11 +505,11 @@ namespace VEPROMS.CSLA.Library } MarkOld(); // update child objects - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZTransition.SQLInsert", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransition.SQLInsert", GetHashCode()); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZTransition.SQLInsert", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransition.SQLInsert", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ZTransition.SQLInsert", ex); } @@ -501,7 +517,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] public static byte[] Add(SqlConnection cn, Transition myTransition, string oldto) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZTransition.Add", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransition.Add", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -523,7 +539,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZTransition.Add", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransition.Add", ex); throw new DbCslaException("ZTransition.Add", ex); } } @@ -531,7 +547,7 @@ namespace VEPROMS.CSLA.Library protected override void DataPortal_Update() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZTransition.DataPortal_Update", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransition.DataPortal_Update", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -545,7 +561,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZTransition.DataPortal_Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransition.DataPortal_Update", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -554,7 +570,7 @@ namespace VEPROMS.CSLA.Library internal void SQLUpdate() { if (!IsDirty) return; // If not dirty - nothing to do - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZTransition.SQLUpdate", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransition.SQLUpdate", GetHashCode()); try { SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; @@ -583,7 +599,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZTransition.SQLUpdate", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransition.SQLUpdate", ex); _ErrorMessage = ex.Message; if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; } @@ -593,18 +609,18 @@ namespace VEPROMS.CSLA.Library if (!this.IsDirty) return; if (base.IsDirty) { - SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; - if (IsNew) - _LastChanged = ZTransition.Add(cn, transition, _Oldto); - else - _LastChanged = ZTransition.Update(cn, transition, _Oldto, ref _LastChanged); - MarkOld(); + SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; + if (IsNew) + _LastChanged = ZTransition.Add(cn, transition, _Oldto); + else + _LastChanged = ZTransition.Update(cn, transition, _Oldto, ref _LastChanged); + MarkOld(); } } [Transactional(TransactionalTypes.TransactionScope)] public static byte[] Update(SqlConnection cn, Transition myTransition, string oldto, ref byte[] lastChanged) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZTransition.Update", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransition.Update", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -627,7 +643,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZTransition.Update", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransition.Update", ex); throw new DbCslaException("ZTransition.Update", ex); } } @@ -639,7 +655,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] private void DataPortal_Delete(PKCriteria criteria) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZTransition.DataPortal_Delete", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransition.DataPortal_Delete", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -655,7 +671,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZTransition.DataPortal_Delete", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransition.DataPortal_Delete", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ZTransition.DataPortal_Delete", ex); } @@ -663,7 +679,7 @@ namespace VEPROMS.CSLA.Library [Transactional(TransactionalTypes.TransactionScope)] public static void Remove(SqlConnection cn, int transitionID) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZTransition.Remove", 0); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransition.Remove", 0); try { using (SqlCommand cm = cn.CreateCommand()) @@ -678,7 +694,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZTransition.Remove", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransition.Remove", ex); throw new DbCslaException("ZTransition.Remove", ex); } } @@ -712,7 +728,7 @@ namespace VEPROMS.CSLA.Library } protected override void DataPortal_Execute() { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZTransition.DataPortal_Execute", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransition.DataPortal_Execute", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -730,7 +746,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZTransition.DataPortal_Execute", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransition.DataPortal_Execute", ex); throw new DbCslaException("ZTransition.DataPortal_Execute", ex); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ZTransitionInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ZTransitionInfo.cs index 8258ebb5..1774bb86 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ZTransitionInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ZTransitionInfo.cs @@ -37,13 +37,17 @@ namespace VEPROMS.CSLA.Library #endregion #region Collection protected static List _AllList = new List(); - private static Dictionary _AllByPrimaryKey = new Dictionary(); + private static Dictionary> _AllByPrimaryKey = new Dictionary>(); private static void ConvertListToDictionary() { List remove = new List(); foreach (ZTransitionInfo tmp in _AllList) { - _AllByPrimaryKey[tmp.TransitionID.ToString()]=tmp; // Primary Key + if (!_AllByPrimaryKey.ContainsKey(tmp.TransitionID.ToString())) + { + _AllByPrimaryKey[tmp.TransitionID.ToString()] = new List(); // Add new list for PrimaryKey + } + _AllByPrimaryKey[tmp.TransitionID.ToString()].Add(tmp); // Add to Primary Key list remove.Add(tmp); } foreach (ZTransitionInfo tmp in remove) @@ -53,7 +57,7 @@ namespace VEPROMS.CSLA.Library { ConvertListToDictionary(); string key = transitionID.ToString(); - if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key]; + if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key][0]; return null; } #endregion @@ -81,7 +85,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("TransitionID",true); + CanReadProperty("TransitionID", true); if (_MyTransition != null) _TransitionID = _MyTransition.TransitionID; return _TransitionID; } @@ -93,7 +97,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("MyTransition",true); + CanReadProperty("MyTransition", true); if (_MyTransition == null && _TransitionID != 0) _MyTransition = TransitionInfo.Get(_TransitionID); return _MyTransition; } @@ -104,7 +108,7 @@ namespace VEPROMS.CSLA.Library [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get { - CanReadProperty("Oldto",true); + CanReadProperty("Oldto", true); return _Oldto; } } @@ -128,14 +132,25 @@ namespace VEPROMS.CSLA.Library } #endregion #region Factory Methods + private static int _ZTransitionInfoUnique = 0; + private int _MyZTransitionInfoUnique; + public int MyZTransitionInfoUnique + { + get { return _MyZTransitionInfoUnique; } + } private ZTransitionInfo() {/* require use of factory methods */ + _MyZTransitionInfoUnique = ++_ZTransitionInfoUnique; _AllList.Add(this); } public void Dispose() { _AllList.Remove(this); - _AllByPrimaryKey.Remove(TransitionID.ToString()); + if (!_AllByPrimaryKey.ContainsKey(TransitionID.ToString())) return; + List listZTransitionInfo = _AllByPrimaryKey[TransitionID.ToString()]; // Get the list of items + listZTransitionInfo.Remove(this); // Remove the item from the list + if (listZTransitionInfo.Count == 0) // If there are no items left in the list + _AllByPrimaryKey.Remove(TransitionID.ToString()); // remove the list } public virtual ZTransition Get() { @@ -143,9 +158,11 @@ namespace VEPROMS.CSLA.Library } public static void Refresh(ZTransition tmp) { - ZTransitionInfo tmpInfo = GetExistingByPrimaryKey(tmp.TransitionID); - if (tmpInfo == null) return; - tmpInfo.RefreshFields(tmp); + string key = tmp.TransitionID.ToString(); + ConvertListToDictionary(); + if (_AllByPrimaryKey.ContainsKey(key)) + foreach (ZTransitionInfo tmpInfo in _AllByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); } private void RefreshFields(ZTransition tmp) { @@ -164,7 +181,7 @@ namespace VEPROMS.CSLA.Library if (tmp == null) { tmp = DataPortal.Fetch(new PKCriteria(transitionID)); - _AllList.Add(tmp); + if (!_AllList.Contains(tmp)) _AllList.Add(tmp); } if (tmp.ErrorMessage == "No Record Found") { @@ -181,14 +198,15 @@ namespace VEPROMS.CSLA.Library #region Data Access Portal internal ZTransitionInfo(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZTransitionInfo.Constructor", GetHashCode()); + _MyZTransitionInfoUnique = ++_ZTransitionInfoUnique; + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransitionInfo.Constructor", GetHashCode()); try { ReadData(dr); } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZTransitionInfo.Constructor", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransitionInfo.Constructor", ex); throw new DbCslaException("ZTransitionInfo.Constructor", ex); } } @@ -205,7 +223,7 @@ namespace VEPROMS.CSLA.Library } private void ReadData(SafeDataReader dr) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZTransitionInfo.ReadData", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransitionInfo.ReadData", GetHashCode()); try { _TransitionID = dr.GetInt32("TransitionID"); @@ -213,14 +231,14 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZTransitionInfo.ReadData", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransitionInfo.ReadData", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ZTransitionInfo.ReadData", ex); } } private void DataPortal_Fetch(PKCriteria criteria) { - if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ZTransitionInfo.DataPortal_Fetch", GetHashCode()); + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransitionInfo.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) @@ -248,7 +266,7 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if(_MyLog.IsErrorEnabled)_MyLog.Error("ZTransitionInfo.DataPortal_Fetch", ex); + if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransitionInfo.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("ZTransitionInfo.DataPortal_Fetch", ex); } @@ -258,7 +276,7 @@ namespace VEPROMS.CSLA.Library #region extension ZTransitionInfoExtension _ZTransitionInfoExtension = new ZTransitionInfoExtension(); [Serializable()] - partial class ZTransitionInfoExtension : extensionBase {} + partial class ZTransitionInfoExtension : extensionBase { } [Serializable()] class extensionBase {