CSLA - Generated - Batch - As
This commit is contained in:
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Csla.Validation;
|
using Csla.Validation;
|
||||||
@@ -37,11 +35,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (IsDirty)
|
if (IsDirty)
|
||||||
refreshAnnotations.Add(this);
|
refreshAnnotations.Add(this);
|
||||||
}
|
}
|
||||||
private void ClearRefreshList()
|
private void ClearRefreshList() => _RefreshAnnotations = new List<Annotation>();
|
||||||
{
|
private void BuildRefreshList()
|
||||||
_RefreshAnnotations = new List<Annotation>();
|
|
||||||
}
|
|
||||||
private void BuildRefreshList()
|
|
||||||
{
|
{
|
||||||
ClearRefreshList();
|
ClearRefreshList();
|
||||||
AddToRefreshList(_RefreshAnnotations);
|
AddToRefreshList(_RefreshAnnotations);
|
||||||
@@ -56,9 +51,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
ClearRefreshList();
|
ClearRefreshList();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Collection
|
#region Collection
|
||||||
private static List<Annotation> _CacheList = new List<Annotation>();
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
|
private static List<Annotation> _CacheList = new List<Annotation>();
|
||||||
protected static void AddToCache(Annotation annotation)
|
protected static void AddToCache(Annotation annotation)
|
||||||
{
|
{
|
||||||
if (!_CacheList.Contains(annotation)) _CacheList.Add(annotation); // In AddToCache
|
if (!_CacheList.Contains(annotation)) _CacheList.Add(annotation); // In AddToCache
|
||||||
@@ -67,7 +63,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(annotation)) _CacheList.Remove(annotation); // In RemoveFromCache
|
while (_CacheList.Contains(annotation)) _CacheList.Remove(annotation); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
private static Dictionary<string, List<Annotation>> _CacheByPrimaryKey = new Dictionary<string, List<Annotation>>();
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
|
private static Dictionary<string, List<Annotation>> _CacheByPrimaryKey = new Dictionary<string, List<Annotation>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
while (_CacheList.Count > 0) // Move Annotation(s) from temporary _CacheList to _CacheByPrimaryKey
|
while (_CacheList.Count > 0) // Move Annotation(s) from temporary _CacheList to _CacheByPrimaryKey
|
||||||
@@ -92,16 +89,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
#region Business Methods
|
#region Business Methods
|
||||||
private string _ErrorMessage = string.Empty;
|
private string _ErrorMessage = string.Empty;
|
||||||
public string ErrorMessage
|
public string ErrorMessage => _ErrorMessage;
|
||||||
{
|
private static int _nextAnnotationID = -1;
|
||||||
get { return _ErrorMessage; }
|
public static int NextAnnotationID => _nextAnnotationID--;
|
||||||
}
|
private int _AnnotationID;
|
||||||
private static int _nextAnnotationID = -1;
|
|
||||||
public static int NextAnnotationID
|
|
||||||
{
|
|
||||||
get { return _nextAnnotationID--; }
|
|
||||||
}
|
|
||||||
private int _AnnotationID;
|
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int AnnotationID
|
public int AnnotationID
|
||||||
{
|
{
|
||||||
@@ -280,40 +271,25 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (base.IsDirty || list.Contains(this))
|
if (base.IsDirty || list.Contains(this))
|
||||||
return base.IsDirty;
|
return base.IsDirty;
|
||||||
list.Add(this);
|
list.Add(this);
|
||||||
return base.IsDirty || (_MyAnnotationType == null ? false : _MyAnnotationType.IsDirtyList(list)) || (_MyItem == null ? false : _MyItem.IsDirtyList(list));
|
return base.IsDirty || (_MyAnnotationType != null && _MyAnnotationType.IsDirtyList(list)) || (_MyItem != null && _MyItem.IsDirtyList(list));
|
||||||
}
|
}
|
||||||
public override bool IsValid
|
public override bool IsValid => IsValidList(new List<object>());
|
||||||
{
|
public bool IsValidList(List<object> list)
|
||||||
get { return IsValidList(new List<object>()); }
|
|
||||||
}
|
|
||||||
public bool IsValidList(List<object> list)
|
|
||||||
{
|
{
|
||||||
if(list.Contains(this))
|
if(list.Contains(this))
|
||||||
return (IsNew && !IsDirty) ? true : base.IsValid;
|
return (IsNew && !IsDirty) || base.IsValid;
|
||||||
list.Add(this);
|
list.Add(this);
|
||||||
return ((IsNew && !IsDirty) ? true : base.IsValid) && (_MyAnnotationType == null ? true : _MyAnnotationType.IsValidList(list)) && (_MyItem == null ? true : _MyItem.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_MyAnnotationType == null || _MyAnnotationType.IsValidList(list)) && (_MyItem == null || _MyItem.IsValidList(list));
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base Annotation.ToString function as necessary
|
// CSLATODO: Check Annotation.GetIdValue to assure that the ID returned is unique
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides Base ToString
|
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A string representation of current Annotation</returns>
|
/// <returns>A Unique ID for the current Annotation</returns>
|
||||||
//public override string ToString()
|
protected override object GetIdValue() => MyAnnotationUnique; // Absolutely Unique ID
|
||||||
//{
|
#endregion
|
||||||
// return base.ToString();
|
#region ValidationRules
|
||||||
//}
|
[NonSerialized]
|
||||||
// CSLATODO: Check Annotation.GetIdValue to assure that the ID returned is unique
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A Unique ID for the current Annotation</returns>
|
|
||||||
protected override object GetIdValue()
|
|
||||||
{
|
|
||||||
return MyAnnotationUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
#region ValidationRules
|
|
||||||
[NonSerialized]
|
|
||||||
private bool _CheckingBrokenRules = false;
|
private bool _CheckingBrokenRules = false;
|
||||||
public IVEHasBrokenRules HasBrokenRules
|
public IVEHasBrokenRules HasBrokenRules
|
||||||
{
|
{
|
||||||
@@ -340,8 +316,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
||||||
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
|
if (Equals(hasBrokenRules)) return BrokenRulesCollection;
|
||||||
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
|
return (hasBrokenRules?.BrokenRules);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override void AddBusinessRules()
|
protected override void AddBusinessRules()
|
||||||
@@ -362,16 +338,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
ValidationRules.AddRule(
|
ValidationRules.AddRule(
|
||||||
Csla.Validation.CommonRules.StringMaxLength,
|
Csla.Validation.CommonRules.StringMaxLength,
|
||||||
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
|
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
|
||||||
//ValidationRules.AddDependantProperty("x", "y");
|
|
||||||
_AnnotationExtension.AddValidationRules(ValidationRules);
|
_AnnotationExtension.AddValidationRules(ValidationRules);
|
||||||
// CSLATODO: Add other validation rules
|
|
||||||
}
|
}
|
||||||
protected override void AddInstanceBusinessRules()
|
protected override void AddInstanceBusinessRules() => _AnnotationExtension.AddInstanceValidationRules(ValidationRules);
|
||||||
{
|
private static bool MyItemRequired(Annotation target, Csla.Validation.RuleArgs e)
|
||||||
_AnnotationExtension.AddInstanceValidationRules(ValidationRules);
|
|
||||||
// CSLATODO: Add other validation rules
|
|
||||||
}
|
|
||||||
private static bool MyItemRequired(Annotation target, Csla.Validation.RuleArgs e)
|
|
||||||
{
|
{
|
||||||
if (target._ItemID == 0 && target._MyItem == null) // Required field missing
|
if (target._ItemID == 0 && target._MyItem == null) // Required field missing
|
||||||
{
|
{
|
||||||
@@ -389,98 +359,26 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Sample data comparison validation rule
|
|
||||||
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
|
|
||||||
//{
|
|
||||||
// if (_started > _ended)
|
|
||||||
// {
|
|
||||||
// e.Description = "Start date can't be after end date";
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// return true;
|
|
||||||
//}
|
|
||||||
#endregion
|
|
||||||
#region Authorization Rules
|
|
||||||
protected override void AddAuthorizationRules()
|
|
||||||
{
|
|
||||||
//CSLATODO: Who can read/write which fields
|
|
||||||
//AuthorizationRules.AllowRead(AnnotationID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(TypeID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(RtfText, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(SearchText, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(TypeID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(RtfText, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(SearchText, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
|
||||||
_AnnotationExtension.AddAuthorizationRules(AuthorizationRules);
|
|
||||||
}
|
|
||||||
protected override void AddInstanceAuthorizationRules()
|
|
||||||
{
|
|
||||||
//CSLATODO: Who can read/write which fields
|
|
||||||
_AnnotationExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
|
||||||
}
|
|
||||||
public static bool CanAddObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: Can Add Authorization
|
|
||||||
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CanGetObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanGet Authorization
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CanDeleteObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanDelete Authorization
|
|
||||||
//bool result = false;
|
|
||||||
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
|
|
||||||
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
|
|
||||||
//return result;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CanEditObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanEdit Authorization
|
|
||||||
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
public int CurrentEditLevel
|
|
||||||
{ get { return EditLevel; } }
|
|
||||||
private static int _AnnotationUnique = 0;
|
private static int _AnnotationUnique = 0;
|
||||||
protected static int AnnotationUnique
|
protected static int AnnotationUnique => ++_AnnotationUnique;
|
||||||
{ get { return ++_AnnotationUnique; } }
|
private readonly int _MyAnnotationUnique = AnnotationUnique;
|
||||||
private int _MyAnnotationUnique = AnnotationUnique;
|
// Absolutely Unique ID - Editable
|
||||||
public int MyAnnotationUnique // Absolutely Unique ID - Editable
|
public int MyAnnotationUnique => _MyAnnotationUnique;
|
||||||
{ get { return _MyAnnotationUnique; } }
|
|
||||||
protected Annotation()
|
protected Annotation()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
}
|
}
|
||||||
private bool _Disposed = false;
|
private bool _Disposed = false;
|
||||||
private static int _CountCreated = 0;
|
private static readonly int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
public static int CountCreated => _CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountCreated
|
~Annotation()
|
||||||
{ get { return _CountCreated; } }
|
|
||||||
public static int CountNotDisposed
|
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~Annotation()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -504,8 +402,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Annotation New()
|
public static Annotation New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Annotation");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<Annotation>();
|
return DataPortal.Create<Annotation>();
|
||||||
@@ -578,8 +474,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Annotation Get(int annotationID)
|
public static Annotation Get(int annotationID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a Annotation");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Annotation tmp = GetCachedByPrimaryKey(annotationID);
|
Annotation tmp = GetCachedByPrimaryKey(annotationID);
|
||||||
@@ -599,37 +493,29 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
throw new DbCslaException("Error on Annotation.Get", ex);
|
throw new DbCslaException("Error on Annotation.Get", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static Annotation Get(SafeDataReader dr)
|
public static Annotation Get(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
if (dr.Read()) return new Annotation(dr);
|
if (dr.Read()) return new Annotation(dr);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
internal Annotation(SafeDataReader dr)
|
internal Annotation(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
ReadData(dr);
|
ReadData(dr);
|
||||||
}
|
}
|
||||||
public static void Delete(int annotationID)
|
public static void Delete(int annotationID)
|
||||||
{
|
{
|
||||||
if (!CanDeleteObject())
|
try
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Annotation");
|
{
|
||||||
try
|
DataPortal.Delete(new PKCriteria(annotationID));
|
||||||
{
|
}
|
||||||
DataPortal.Delete(new PKCriteria(annotationID));
|
catch (Exception ex)
|
||||||
}
|
{
|
||||||
catch (Exception ex)
|
throw new DbCslaException("Error on Annotation.Delete", ex);
|
||||||
{
|
}
|
||||||
throw new DbCslaException("Error on Annotation.Delete", ex);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
public override Annotation Save()
|
public override Annotation Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Annotation");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Annotation");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a Annotation");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -650,14 +536,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _AnnotationID;
|
private readonly int _AnnotationID;
|
||||||
public int AnnotationID
|
public int AnnotationID => _AnnotationID;
|
||||||
{ get { return _AnnotationID; } }
|
public PKCriteria(int annotationID) => _AnnotationID = annotationID;
|
||||||
public PKCriteria(int annotationID)
|
}
|
||||||
{
|
|
||||||
_AnnotationID = annotationID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
|
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
|
||||||
[RunLocal()]
|
[RunLocal()]
|
||||||
private new void DataPortal_Create()
|
private new void DataPortal_Create()
|
||||||
@@ -756,43 +638,50 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
internal void SQLInsert()
|
internal void SQLInsert()
|
||||||
{
|
{
|
||||||
if (!this.IsDirty) return;
|
if (!IsDirty) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_MyAnnotationType != null) _MyAnnotationType.Update();
|
_MyAnnotationType?.Update();
|
||||||
if (_MyItem != null) _MyItem.Update();
|
_MyItem?.Update();
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
using (SqlCommand cm = cn.CreateCommand())
|
{
|
||||||
{
|
using (SqlCommand cm = cn.CreateCommand())
|
||||||
cm.CommandType = CommandType.StoredProcedure;
|
{
|
||||||
cm.CommandTimeout = Database.SQLTimeout;
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
cm.CommandText = "addAnnotation";
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandText = "addAnnotation";
|
||||||
cm.Parameters.AddWithValue("@ItemID", ItemID);
|
// Input All Fields - Except Calculated Columns
|
||||||
cm.Parameters.AddWithValue("@TypeID", TypeID);
|
cm.Parameters.AddWithValue("@ItemID", ItemID);
|
||||||
cm.Parameters.AddWithValue("@RtfText", _RtfText);
|
cm.Parameters.AddWithValue("@TypeID", TypeID);
|
||||||
cm.Parameters.AddWithValue("@SearchText", _SearchText);
|
cm.Parameters.AddWithValue("@RtfText", _RtfText);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@SearchText", _SearchText);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
SqlParameter param_AnnotationID = new SqlParameter("@newAnnotationID", SqlDbType.Int);
|
// Output Calculated Columns
|
||||||
param_AnnotationID.Direction = ParameterDirection.Output;
|
SqlParameter param_AnnotationID = new SqlParameter("@newAnnotationID", SqlDbType.Int)
|
||||||
cm.Parameters.Add(param_AnnotationID);
|
{
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
Direction = ParameterDirection.Output
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
};
|
||||||
cm.Parameters.Add(param_LastChanged);
|
cm.Parameters.Add(param_AnnotationID);
|
||||||
// CSLATODO: Define any additional output parameters
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
cm.ExecuteNonQuery();
|
{
|
||||||
// Save all values being returned from the Procedure
|
Direction = ParameterDirection.Output
|
||||||
_AnnotationID = (int)cm.Parameters["@newAnnotationID"].Value;
|
};
|
||||||
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
cm.Parameters.Add(param_LastChanged);
|
||||||
}
|
// CSLATODO: Define any additional output parameters
|
||||||
MarkOld();
|
cm.ExecuteNonQuery();
|
||||||
// update child objects
|
// Save all values being returned from the Procedure
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.SQLInsert", GetHashCode());
|
_AnnotationID = (int)cm.Parameters["@newAnnotationID"].Value;
|
||||||
}
|
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||||
catch (Exception ex)
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MarkOld();
|
||||||
|
// update child objects
|
||||||
|
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;
|
_ErrorMessage = ex.Message;
|
||||||
@@ -818,13 +707,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
cm.Parameters.AddWithValue("@Config", config);
|
cm.Parameters.AddWithValue("@Config", config);
|
||||||
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
||||||
cm.Parameters.AddWithValue("@UserID", userID);
|
cm.Parameters.AddWithValue("@UserID", userID);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_AnnotationID = new SqlParameter("@newAnnotationID", SqlDbType.Int);
|
SqlParameter param_AnnotationID = new SqlParameter("@newAnnotationID", SqlDbType.Int)
|
||||||
param_AnnotationID.Direction = ParameterDirection.Output;
|
{
|
||||||
cm.Parameters.Add(param_AnnotationID);
|
Direction = ParameterDirection.Output
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
};
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
cm.Parameters.Add(param_AnnotationID);
|
||||||
cm.Parameters.Add(param_LastChanged);
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
|
{
|
||||||
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
|
cm.Parameters.Add(param_LastChanged);
|
||||||
// CSLATODO: Define any additional output parameters
|
// CSLATODO: Define any additional output parameters
|
||||||
cm.ExecuteNonQuery();
|
cm.ExecuteNonQuery();
|
||||||
// Save all values being returned from the Procedure
|
// Save all values being returned from the Procedure
|
||||||
@@ -867,41 +760,46 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (!IsDirty) return; // If not dirty - nothing to do
|
if (!IsDirty) return; // If not dirty - nothing to do
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.SQLUpdate", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_MyAnnotationType != null) _MyAnnotationType.Update();
|
_MyAnnotationType?.Update();
|
||||||
if (_MyItem != null) _MyItem.Update();
|
_MyItem?.Update();
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
if (base.IsDirty)
|
{
|
||||||
{
|
if (base.IsDirty)
|
||||||
using (SqlCommand cm = cn.CreateCommand())
|
{
|
||||||
{
|
using (SqlCommand cm = cn.CreateCommand())
|
||||||
cm.CommandType = CommandType.StoredProcedure;
|
{
|
||||||
cm.CommandTimeout = Database.SQLTimeout;
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
cm.CommandText = "updateAnnotation";
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandText = "updateAnnotation";
|
||||||
cm.Parameters.AddWithValue("@AnnotationID", _AnnotationID);
|
// All Fields including Calculated Fields
|
||||||
cm.Parameters.AddWithValue("@ItemID", ItemID);
|
cm.Parameters.AddWithValue("@AnnotationID", _AnnotationID);
|
||||||
cm.Parameters.AddWithValue("@TypeID", TypeID);
|
cm.Parameters.AddWithValue("@ItemID", ItemID);
|
||||||
cm.Parameters.AddWithValue("@RtfText", _RtfText);
|
cm.Parameters.AddWithValue("@TypeID", TypeID);
|
||||||
cm.Parameters.AddWithValue("@SearchText", _SearchText);
|
cm.Parameters.AddWithValue("@RtfText", _RtfText);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@SearchText", _SearchText);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
// Output Calculated Columns
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
cm.Parameters.Add(param_LastChanged);
|
{
|
||||||
// CSLATODO: Define any additional output parameters
|
Direction = ParameterDirection.Output
|
||||||
cm.ExecuteNonQuery();
|
};
|
||||||
// Save all values being returned from the Procedure
|
cm.Parameters.Add(param_LastChanged);
|
||||||
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
// CSLATODO: Define any additional output parameters
|
||||||
}
|
cm.ExecuteNonQuery();
|
||||||
}
|
// Save all values being returned from the Procedure
|
||||||
MarkOld();
|
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||||
// use the open connection to update child objects
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
}
|
||||||
|
|
||||||
|
MarkOld();
|
||||||
|
// use the open connection to update child objects
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.SQLUpdate", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.SQLUpdate", ex);
|
||||||
_ErrorMessage = ex.Message;
|
_ErrorMessage = ex.Message;
|
||||||
@@ -910,17 +808,20 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
internal void Update()
|
internal void Update()
|
||||||
{
|
{
|
||||||
if (!this.IsDirty) return;
|
if (!IsDirty) return;
|
||||||
if (base.IsDirty)
|
if (base.IsDirty)
|
||||||
{
|
{
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
if (IsNew)
|
{
|
||||||
_LastChanged = Annotation.Add(cn, ref _AnnotationID, _MyItem, _MyAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID);
|
if (IsNew)
|
||||||
else
|
_LastChanged = Annotation.Add(cn, ref _AnnotationID, _MyItem, _MyAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID);
|
||||||
_LastChanged = Annotation.Update(cn, ref _AnnotationID, _ItemID, _TypeID, _RtfText, _SearchText, _Config, _DTS, _UserID, ref _LastChanged);
|
else
|
||||||
MarkOld();
|
_LastChanged = Annotation.Update(cn, ref _AnnotationID, _ItemID, _TypeID, _RtfText, _SearchText, _Config, _DTS, _UserID, ref _LastChanged);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
MarkOld();
|
||||||
|
}
|
||||||
|
}
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
public static byte[] Update(SqlConnection cn, ref int annotationID, int itemID, int typeID, string rtfText, string searchText, string config, DateTime dts, string userID, ref byte[] lastChanged)
|
public static byte[] Update(SqlConnection cn, ref int annotationID, int itemID, int typeID, string rtfText, string searchText, string config, DateTime dts, string userID, ref byte[] lastChanged)
|
||||||
{
|
{
|
||||||
@@ -942,10 +843,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
||||||
cm.Parameters.AddWithValue("@UserID", userID);
|
cm.Parameters.AddWithValue("@UserID", userID);
|
||||||
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
{
|
||||||
cm.Parameters.Add(param_LastChanged);
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
|
cm.Parameters.Add(param_LastChanged);
|
||||||
// CSLATODO: Define any additional output parameters
|
// CSLATODO: Define any additional output parameters
|
||||||
cm.ExecuteNonQuery();
|
cm.ExecuteNonQuery();
|
||||||
// Save all values being returned from the Procedure
|
// Save all values being returned from the Procedure
|
||||||
@@ -1029,17 +932,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ExistsCommand : CommandBase
|
private class ExistsCommand : CommandBase
|
||||||
{
|
{
|
||||||
private int _AnnotationID;
|
private readonly int _AnnotationID;
|
||||||
private bool _exists;
|
private bool _exists;
|
||||||
public bool Exists
|
public bool Exists => _exists;
|
||||||
{
|
public ExistsCommand(int annotationID) => _AnnotationID = annotationID;
|
||||||
get { return _exists; }
|
protected override void DataPortal_Execute()
|
||||||
}
|
|
||||||
public ExistsCommand(int annotationID)
|
|
||||||
{
|
|
||||||
_AnnotationID = annotationID;
|
|
||||||
}
|
|
||||||
protected override void DataPortal_Execute()
|
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.DataPortal_Execute", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.DataPortal_Execute", GetHashCode());
|
||||||
try
|
try
|
||||||
@@ -1065,10 +962,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
AnnotationExtension _AnnotationExtension = new AnnotationExtension();
|
readonly AnnotationExtension _AnnotationExtension = new AnnotationExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class AnnotationExtension : extensionBase
|
partial class AnnotationExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -1076,17 +973,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
class extensionBase
|
class extensionBase
|
||||||
{
|
{
|
||||||
// Default Values
|
// Default Values
|
||||||
public virtual DateTime DefaultDTS
|
public virtual DateTime DefaultDTS => DateTime.Now;
|
||||||
{
|
public virtual string DefaultUserID => Volian.Base.Library.VlnSettings.UserID;
|
||||||
get { return DateTime.Now; }
|
// Authorization Rules
|
||||||
}
|
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
||||||
public virtual string DefaultUserID
|
|
||||||
{
|
|
||||||
get { return Volian.Base.Library.VlnSettings.UserID; }
|
|
||||||
}
|
|
||||||
// Authorization Rules
|
|
||||||
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
{
|
{
|
||||||
// Needs to be overriden to add new authorization rules
|
// Needs to be overriden to add new authorization rules
|
||||||
}
|
}
|
||||||
@@ -1113,57 +1004,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is Annotation)
|
if (destType == typeof(string) && value is Annotation ann)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((Annotation)value).ToString();
|
return ann.ToString();
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
} // Namespace
|
} // Namespace
|
||||||
|
|
||||||
|
|
||||||
//// The following is a sample Extension File. You can use it to create AnnotationExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class Annotation
|
|
||||||
// {
|
|
||||||
// partial class AnnotationExtension : extensionBase
|
|
||||||
// {
|
|
||||||
// // CSLATODO: Override automatic defaults
|
|
||||||
// public virtual DateTime DefaultDTS
|
|
||||||
// {
|
|
||||||
// get { return DateTime.Now; }
|
|
||||||
// }
|
|
||||||
// public virtual string DefaultUserID
|
|
||||||
// {
|
|
||||||
// get { return Environment.UserName.ToUpper(); }
|
|
||||||
// }
|
|
||||||
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddRule(
|
|
||||||
// Csla.Validation.CommonRules.StringMaxLength,
|
|
||||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddInstanceRule(/* Instance Validation Rule */);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Csla.Validation;
|
using Csla.Validation;
|
||||||
@@ -54,9 +52,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
ClearRefreshList();
|
ClearRefreshList();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Collection
|
#region Collection
|
||||||
private static List<AnnotationAudit> _CacheList = new List<AnnotationAudit>();
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
|
private static List<AnnotationAudit> _CacheList = new List<AnnotationAudit>();
|
||||||
protected static void AddToCache(AnnotationAudit annotationAudit)
|
protected static void AddToCache(AnnotationAudit annotationAudit)
|
||||||
{
|
{
|
||||||
if (!_CacheList.Contains(annotationAudit)) _CacheList.Add(annotationAudit); // In AddToCache
|
if (!_CacheList.Contains(annotationAudit)) _CacheList.Add(annotationAudit); // In AddToCache
|
||||||
@@ -65,7 +64,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(annotationAudit)) _CacheList.Remove(annotationAudit); // In RemoveFromCache
|
while (_CacheList.Contains(annotationAudit)) _CacheList.Remove(annotationAudit); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
private static Dictionary<string, List<AnnotationAudit>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationAudit>>();
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
|
private static Dictionary<string, List<AnnotationAudit>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationAudit>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
while (_CacheList.Count > 0) // Move AnnotationAudit(s) from temporary _CacheList to _CacheByPrimaryKey
|
while (_CacheList.Count > 0) // Move AnnotationAudit(s) from temporary _CacheList to _CacheByPrimaryKey
|
||||||
@@ -90,16 +90,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
#region Business Methods
|
#region Business Methods
|
||||||
private string _ErrorMessage = string.Empty;
|
private string _ErrorMessage = string.Empty;
|
||||||
public string ErrorMessage
|
public string ErrorMessage => _ErrorMessage;
|
||||||
{
|
private static int _nextAuditID = -1;
|
||||||
get { return _ErrorMessage; }
|
public static int NextAuditID => _nextAuditID--;
|
||||||
}
|
private long _AuditID;
|
||||||
private static int _nextAuditID = -1;
|
|
||||||
public static int NextAuditID
|
|
||||||
{
|
|
||||||
get { return _nextAuditID--; }
|
|
||||||
}
|
|
||||||
private long _AuditID;
|
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public long AuditID
|
public long AuditID
|
||||||
{
|
{
|
||||||
@@ -275,43 +269,18 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override bool IsDirty
|
public override bool IsDirty => base.IsDirty;
|
||||||
{
|
public override bool IsValid => (IsNew && !IsDirty) || base.IsValid;
|
||||||
get { return base.IsDirty; }
|
|
||||||
}
|
// CSLATODO: Check AnnotationAudit.GetIdValue to assure that the ID returned is unique
|
||||||
public bool IsDirtyList(List<object> list)
|
/// <summary>
|
||||||
{
|
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||||
return base.IsDirty;
|
/// </summary>
|
||||||
}
|
/// <returns>A Unique ID for the current AnnotationAudit</returns>
|
||||||
public override bool IsValid
|
protected override object GetIdValue() => MyAnnotationAuditUnique; // Absolutely Unique ID
|
||||||
{
|
#endregion
|
||||||
get { return (IsNew && !IsDirty) ? true : base.IsValid; }
|
#region ValidationRules
|
||||||
}
|
[NonSerialized]
|
||||||
public bool IsValidList(List<object> list)
|
|
||||||
{
|
|
||||||
return (IsNew && !IsDirty) ? true : base.IsValid;
|
|
||||||
}
|
|
||||||
// CSLATODO: Replace base AnnotationAudit.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current AnnotationAudit</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check AnnotationAudit.GetIdValue to assure that the ID returned is unique
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A Unique ID for the current AnnotationAudit</returns>
|
|
||||||
protected override object GetIdValue()
|
|
||||||
{
|
|
||||||
return MyAnnotationAuditUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
#region ValidationRules
|
|
||||||
[NonSerialized]
|
|
||||||
private bool _CheckingBrokenRules = false;
|
private bool _CheckingBrokenRules = false;
|
||||||
public IVEHasBrokenRules HasBrokenRules
|
public IVEHasBrokenRules HasBrokenRules
|
||||||
{
|
{
|
||||||
@@ -336,8 +305,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
||||||
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
|
if (Equals(hasBrokenRules)) return BrokenRulesCollection;
|
||||||
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
|
return hasBrokenRules?.BrokenRules;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override void AddBusinessRules()
|
protected override void AddBusinessRules()
|
||||||
@@ -356,93 +325,15 @@ namespace VEPROMS.CSLA.Library
|
|||||||
ValidationRules.AddRule(
|
ValidationRules.AddRule(
|
||||||
Csla.Validation.CommonRules.StringMaxLength,
|
Csla.Validation.CommonRules.StringMaxLength,
|
||||||
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 200));
|
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 200));
|
||||||
//ValidationRules.AddDependantProperty("x", "y");
|
|
||||||
_AnnotationAuditExtension.AddValidationRules(ValidationRules);
|
_AnnotationAuditExtension.AddValidationRules(ValidationRules);
|
||||||
// CSLATODO: Add other validation rules
|
|
||||||
}
|
|
||||||
protected override void AddInstanceBusinessRules()
|
|
||||||
{
|
|
||||||
_AnnotationAuditExtension.AddInstanceValidationRules(ValidationRules);
|
|
||||||
// CSLATODO: Add other validation rules
|
|
||||||
}
|
|
||||||
// Sample data comparison validation rule
|
|
||||||
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
|
|
||||||
//{
|
|
||||||
// if (_started > _ended)
|
|
||||||
// {
|
|
||||||
// e.Description = "Start date can't be after end date";
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// return true;
|
|
||||||
//}
|
|
||||||
#endregion
|
|
||||||
#region Authorization Rules
|
|
||||||
protected override void AddAuthorizationRules()
|
|
||||||
{
|
|
||||||
//CSLATODO: Who can read/write which fields
|
|
||||||
//AuthorizationRules.AllowRead(AuditID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(AnnotationID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(TypeID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(RtfText, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(SearchText, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DeleteStatus, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(AnnotationID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(TypeID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(RtfText, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(SearchText, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DeleteStatus, "<Role(s)>");
|
|
||||||
_AnnotationAuditExtension.AddAuthorizationRules(AuthorizationRules);
|
|
||||||
}
|
|
||||||
protected override void AddInstanceAuthorizationRules()
|
|
||||||
{
|
|
||||||
//CSLATODO: Who can read/write which fields
|
|
||||||
_AnnotationAuditExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
|
||||||
}
|
|
||||||
public static bool CanAddObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: Can Add Authorization
|
|
||||||
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CanGetObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanGet Authorization
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CanDeleteObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanDelete Authorization
|
|
||||||
//bool result = false;
|
|
||||||
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
|
|
||||||
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
|
|
||||||
//return result;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CanEditObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanEdit Authorization
|
|
||||||
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
public int CurrentEditLevel
|
|
||||||
{ get { return EditLevel; } }
|
|
||||||
private static int _AnnotationAuditUnique = 0;
|
private static int _AnnotationAuditUnique = 0;
|
||||||
protected static int AnnotationAuditUnique
|
protected static int AnnotationAuditUnique => ++_AnnotationAuditUnique;
|
||||||
{ get { return ++_AnnotationAuditUnique; } }
|
private readonly int _MyAnnotationAuditUnique = AnnotationAuditUnique;
|
||||||
private int _MyAnnotationAuditUnique = AnnotationAuditUnique;
|
// Absolutely Unique ID - Editable
|
||||||
public int MyAnnotationAuditUnique // Absolutely Unique ID - Editable
|
public int MyAnnotationAuditUnique => _MyAnnotationAuditUnique;
|
||||||
{ get { return _MyAnnotationAuditUnique; } }
|
|
||||||
protected AnnotationAudit()
|
protected AnnotationAudit()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -451,16 +342,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static int _CountCreated = 0;
|
private static int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
private static int IncrementCountCreated => ++_CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountCreated => _CountCreated;
|
||||||
public static int CountCreated
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
{ get { return _CountCreated; } }
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountNotDisposed
|
~AnnotationAudit()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~AnnotationAudit()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -484,8 +371,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static AnnotationAudit New()
|
public static AnnotationAudit New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a AnnotationAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<AnnotationAudit>();
|
return DataPortal.Create<AnnotationAudit>();
|
||||||
@@ -531,15 +416,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
tmp._ErrorMessage = "Failed Validation:";
|
tmp._ErrorMessage = "Failed Validation:";
|
||||||
foreach (Csla.Validation.BrokenRule br in brc)
|
foreach (Csla.Validation.BrokenRule br in brc)
|
||||||
{
|
{
|
||||||
tmp._ErrorMessage += "\r\n\tFailure: " + br.RuleName;
|
tmp._ErrorMessage += $"\r\n\tFailure: {br.RuleName}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
public static AnnotationAudit Get(long auditID)
|
public static AnnotationAudit Get(long auditID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a AnnotationAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AnnotationAudit tmp = GetCachedByPrimaryKey(auditID);
|
AnnotationAudit tmp = GetCachedByPrimaryKey(auditID);
|
||||||
@@ -559,20 +442,15 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
throw new DbCslaException("Error on AnnotationAudit.Get", ex);
|
throw new DbCslaException("Error on AnnotationAudit.Get", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static AnnotationAudit Get(SafeDataReader dr)
|
public static AnnotationAudit Get(SafeDataReader dr)
|
||||||
|
{
|
||||||
|
if (dr.Read()) return new AnnotationAudit(dr);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
internal AnnotationAudit(SafeDataReader dr) => ReadData(dr);
|
||||||
|
public static void Delete(long auditID)
|
||||||
{
|
{
|
||||||
if (dr.Read()) return new AnnotationAudit(dr);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
internal AnnotationAudit(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
ReadData(dr);
|
|
||||||
}
|
|
||||||
public static void Delete(long auditID)
|
|
||||||
{
|
|
||||||
if (!CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a AnnotationAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataPortal.Delete(new PKCriteria(auditID));
|
DataPortal.Delete(new PKCriteria(auditID));
|
||||||
@@ -584,12 +462,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public override AnnotationAudit Save()
|
public override AnnotationAudit Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a AnnotationAudit");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a AnnotationAudit");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a AnnotationAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -609,14 +481,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private long _AuditID;
|
private readonly long _AuditID;
|
||||||
public long AuditID
|
public long AuditID => _AuditID;
|
||||||
{ get { return _AuditID; } }
|
public PKCriteria(long auditID) => _AuditID = auditID;
|
||||||
public PKCriteria(long auditID)
|
}
|
||||||
{
|
|
||||||
_AuditID = auditID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
|
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
|
||||||
[RunLocal()]
|
[RunLocal()]
|
||||||
private new void DataPortal_Create()
|
private new void DataPortal_Create()
|
||||||
@@ -715,39 +583,44 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
internal void SQLInsert()
|
internal void SQLInsert()
|
||||||
{
|
{
|
||||||
if (!this.IsDirty) return;
|
if (!IsDirty) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
using (SqlCommand cm = cn.CreateCommand())
|
{
|
||||||
{
|
using (SqlCommand cm = cn.CreateCommand())
|
||||||
cm.CommandType = CommandType.StoredProcedure;
|
{
|
||||||
cm.CommandTimeout = Database.SQLTimeout;
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
cm.CommandText = "addAnnotationAudit";
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandText = "addAnnotationAudit";
|
||||||
cm.Parameters.AddWithValue("@AnnotationID", _AnnotationID);
|
// Input All Fields - Except Calculated Columns
|
||||||
cm.Parameters.AddWithValue("@ItemID", _ItemID);
|
cm.Parameters.AddWithValue("@AnnotationID", _AnnotationID);
|
||||||
cm.Parameters.AddWithValue("@TypeID", _TypeID);
|
cm.Parameters.AddWithValue("@ItemID", _ItemID);
|
||||||
cm.Parameters.AddWithValue("@RtfText", _RtfText);
|
cm.Parameters.AddWithValue("@TypeID", _TypeID);
|
||||||
cm.Parameters.AddWithValue("@SearchText", _SearchText);
|
cm.Parameters.AddWithValue("@RtfText", _RtfText);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@SearchText", _SearchText);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
|
||||||
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt);
|
// Output Calculated Columns
|
||||||
param_AuditID.Direction = ParameterDirection.Output;
|
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt)
|
||||||
cm.Parameters.Add(param_AuditID);
|
{
|
||||||
// CSLATODO: Define any additional output parameters
|
Direction = ParameterDirection.Output
|
||||||
cm.ExecuteNonQuery();
|
};
|
||||||
// Save all values being returned from the Procedure
|
cm.Parameters.Add(param_AuditID);
|
||||||
_AuditID = (long)cm.Parameters["@newAuditID"].Value;
|
// CSLATODO: Define any additional output parameters
|
||||||
}
|
cm.ExecuteNonQuery();
|
||||||
MarkOld();
|
// Save all values being returned from the Procedure
|
||||||
// update child objects
|
_AuditID = (long)cm.Parameters["@newAuditID"].Value;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAudit.SQLInsert", GetHashCode());
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
|
MarkOld();
|
||||||
|
// update child objects
|
||||||
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAudit.SQLInsert", GetHashCode());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAudit.SQLInsert", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAudit.SQLInsert", ex);
|
||||||
_ErrorMessage = ex.Message;
|
_ErrorMessage = ex.Message;
|
||||||
@@ -775,10 +648,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
||||||
cm.Parameters.AddWithValue("@UserID", userID);
|
cm.Parameters.AddWithValue("@UserID", userID);
|
||||||
cm.Parameters.AddWithValue("@DeleteStatus", deleteStatus);
|
cm.Parameters.AddWithValue("@DeleteStatus", deleteStatus);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt);
|
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt)
|
||||||
param_AuditID.Direction = ParameterDirection.Output;
|
{
|
||||||
cm.Parameters.Add(param_AuditID);
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
|
cm.Parameters.Add(param_AuditID);
|
||||||
// CSLATODO: Define any additional output parameters
|
// CSLATODO: Define any additional output parameters
|
||||||
cm.ExecuteNonQuery();
|
cm.ExecuteNonQuery();
|
||||||
// Save all values being returned from the Procedure
|
// Save all values being returned from the Procedure
|
||||||
@@ -821,36 +696,39 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (!IsDirty) return; // If not dirty - nothing to do
|
if (!IsDirty) return; // If not dirty - nothing to do
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAudit.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAudit.SQLUpdate", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
if (base.IsDirty)
|
{
|
||||||
{
|
if (base.IsDirty)
|
||||||
using (SqlCommand cm = cn.CreateCommand())
|
{
|
||||||
{
|
using (SqlCommand cm = cn.CreateCommand())
|
||||||
cm.CommandType = CommandType.StoredProcedure;
|
{
|
||||||
cm.CommandTimeout = Database.SQLTimeout;
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
cm.CommandText = "updateAnnotationAudit";
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandText = "updateAnnotationAudit";
|
||||||
cm.Parameters.AddWithValue("@AuditID", _AuditID);
|
// All Fields including Calculated Fields
|
||||||
cm.Parameters.AddWithValue("@AnnotationID", _AnnotationID);
|
cm.Parameters.AddWithValue("@AuditID", _AuditID);
|
||||||
cm.Parameters.AddWithValue("@ItemID", _ItemID);
|
cm.Parameters.AddWithValue("@AnnotationID", _AnnotationID);
|
||||||
cm.Parameters.AddWithValue("@TypeID", _TypeID);
|
cm.Parameters.AddWithValue("@ItemID", _ItemID);
|
||||||
cm.Parameters.AddWithValue("@RtfText", _RtfText);
|
cm.Parameters.AddWithValue("@TypeID", _TypeID);
|
||||||
cm.Parameters.AddWithValue("@SearchText", _SearchText);
|
cm.Parameters.AddWithValue("@RtfText", _RtfText);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@SearchText", _SearchText);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
|
||||||
// CSLATODO: Define any additional output parameters
|
// Output Calculated Columns
|
||||||
cm.ExecuteNonQuery();
|
// CSLATODO: Define any additional output parameters
|
||||||
// Save all values being returned from the Procedure
|
cm.ExecuteNonQuery();
|
||||||
}
|
// Save all values being returned from the Procedure
|
||||||
}
|
}
|
||||||
MarkOld();
|
}
|
||||||
// use the open connection to update child objects
|
}
|
||||||
}
|
|
||||||
catch (Exception ex)
|
MarkOld();
|
||||||
|
// use the open connection to update child objects
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAudit.SQLUpdate", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAudit.SQLUpdate", ex);
|
||||||
_ErrorMessage = ex.Message;
|
_ErrorMessage = ex.Message;
|
||||||
@@ -859,17 +737,20 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
internal void Update()
|
internal void Update()
|
||||||
{
|
{
|
||||||
if (!this.IsDirty) return;
|
if (!IsDirty) return;
|
||||||
if (base.IsDirty)
|
if (base.IsDirty)
|
||||||
{
|
{
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
if (IsNew)
|
{
|
||||||
AnnotationAudit.Add(cn, ref _AuditID, _AnnotationID, _ItemID, _TypeID, _RtfText, _SearchText, _Config, _DTS, _UserID, _DeleteStatus);
|
if (IsNew)
|
||||||
else
|
AnnotationAudit.Add(cn, ref _AuditID, _AnnotationID, _ItemID, _TypeID, _RtfText, _SearchText, _Config, _DTS, _UserID, _DeleteStatus);
|
||||||
AnnotationAudit.Update(cn, ref _AuditID, _AnnotationID, _ItemID, _TypeID, _RtfText, _SearchText, _Config, _DTS, _UserID, _DeleteStatus);
|
else
|
||||||
MarkOld();
|
AnnotationAudit.Update(cn, ref _AuditID, _AnnotationID, _ItemID, _TypeID, _RtfText, _SearchText, _Config, _DTS, _UserID, _DeleteStatus);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
MarkOld();
|
||||||
|
}
|
||||||
|
}
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
public static void Update(SqlConnection cn, ref long auditID, int annotationID, int itemID, int typeID, string rtfText, string searchText, string config, DateTime dts, string userID, int deleteStatus)
|
public static void Update(SqlConnection cn, ref long auditID, int annotationID, int itemID, int typeID, string rtfText, string searchText, string config, DateTime dts, string userID, int deleteStatus)
|
||||||
{
|
{
|
||||||
@@ -976,17 +857,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ExistsCommand : CommandBase
|
private class ExistsCommand : CommandBase
|
||||||
{
|
{
|
||||||
private long _AuditID;
|
private readonly long _AuditID;
|
||||||
private bool _exists;
|
private bool _exists;
|
||||||
public bool Exists
|
public bool Exists => _exists;
|
||||||
{
|
public ExistsCommand(long auditID) => _AuditID = auditID;
|
||||||
get { return _exists; }
|
protected override void DataPortal_Execute()
|
||||||
}
|
|
||||||
public ExistsCommand(long auditID)
|
|
||||||
{
|
|
||||||
_AuditID = auditID;
|
|
||||||
}
|
|
||||||
protected override void DataPortal_Execute()
|
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAudit.DataPortal_Execute", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAudit.DataPortal_Execute", GetHashCode());
|
||||||
try
|
try
|
||||||
@@ -1012,10 +887,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
AnnotationAuditExtension _AnnotationAuditExtension = new AnnotationAuditExtension();
|
readonly AnnotationAuditExtension _AnnotationAuditExtension = new AnnotationAuditExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class AnnotationAuditExtension : extensionBase
|
partial class AnnotationAuditExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -1052,49 +927,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is AnnotationAudit)
|
if (destType == typeof(string) && value is AnnotationAudit audit)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((AnnotationAudit)value).ToString();
|
return audit.ToString();
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
} // Namespace
|
} // Namespace
|
||||||
|
|
||||||
|
|
||||||
//// The following is a sample Extension File. You can use it to create AnnotationAuditExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class AnnotationAudit
|
|
||||||
// {
|
|
||||||
// partial class AnnotationAuditExtension : extensionBase
|
|
||||||
// {
|
|
||||||
// // CSLATODO: Override automatic defaults
|
|
||||||
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddRule(
|
|
||||||
// Csla.Validation.CommonRules.StringMaxLength,
|
|
||||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddInstanceRule(/* Instance Validation Rule */);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
namespace VEPROMS.CSLA.Library
|
namespace VEPROMS.CSLA.Library
|
||||||
@@ -28,15 +26,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public partial class AnnotationAuditInfo : ReadOnlyBase<AnnotationAuditInfo>, IDisposable
|
public partial class AnnotationAuditInfo : ReadOnlyBase<AnnotationAuditInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public event AnnotationAuditInfoEvent Changed;
|
public event AnnotationAuditInfoEvent Changed;
|
||||||
private void OnChange()
|
private void OnChange() => Changed?.Invoke(this);
|
||||||
{
|
#region Log4Net
|
||||||
if (Changed != null) Changed(this);
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
}
|
#endregion
|
||||||
#region Log4Net
|
#region Collection
|
||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
#endregion
|
private static List<AnnotationAuditInfo> _CacheList = new List<AnnotationAuditInfo>();
|
||||||
#region Collection
|
|
||||||
private static List<AnnotationAuditInfo> _CacheList = new List<AnnotationAuditInfo>();
|
|
||||||
protected static void AddToCache(AnnotationAuditInfo annotationAuditInfo)
|
protected static void AddToCache(AnnotationAuditInfo annotationAuditInfo)
|
||||||
{
|
{
|
||||||
if (!_CacheList.Contains(annotationAuditInfo)) _CacheList.Add(annotationAuditInfo); // In AddToCache
|
if (!_CacheList.Contains(annotationAuditInfo)) _CacheList.Add(annotationAuditInfo); // In AddToCache
|
||||||
@@ -45,7 +41,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(annotationAuditInfo)) _CacheList.Remove(annotationAuditInfo); // In RemoveFromCache
|
while (_CacheList.Contains(annotationAuditInfo)) _CacheList.Remove(annotationAuditInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
private static Dictionary<string, List<AnnotationAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationAuditInfo>>();
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
|
private static Dictionary<string, List<AnnotationAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationAuditInfo>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
while (_CacheList.Count > 0) // Move AnnotationAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
|
while (_CacheList.Count > 0) // Move AnnotationAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
|
||||||
@@ -74,21 +71,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
#region Business Methods
|
#region Business Methods
|
||||||
private string _ErrorMessage = string.Empty;
|
private string _ErrorMessage = string.Empty;
|
||||||
public string ErrorMessage
|
public string ErrorMessage => _ErrorMessage;
|
||||||
{
|
protected AnnotationAudit _Editable;
|
||||||
get { return _ErrorMessage; }
|
|
||||||
}
|
|
||||||
protected AnnotationAudit _Editable;
|
|
||||||
private IVEHasBrokenRules HasBrokenRules
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
IVEHasBrokenRules hasBrokenRules = null;
|
|
||||||
if (_Editable != null)
|
|
||||||
hasBrokenRules = _Editable.HasBrokenRules;
|
|
||||||
return hasBrokenRules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private long _AuditID;
|
private long _AuditID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public long AuditID
|
public long AuditID
|
||||||
@@ -180,50 +164,33 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _DeleteStatus;
|
return _DeleteStatus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base AnnotationAuditInfo.ToString function as necessary
|
// CSLATODO: Check AnnotationAuditInfo.GetIdValue to assure that the ID returned is unique
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides Base ToString
|
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A string representation of current AnnotationAuditInfo</returns>
|
/// <returns>A Unique ID for the current AnnotationAuditInfo</returns>
|
||||||
//public override string ToString()
|
protected override object GetIdValue() => MyAnnotationAuditInfoUnique; // Absolutely Unique ID
|
||||||
//{
|
#endregion
|
||||||
// return base.ToString();
|
#region Factory Methods
|
||||||
//}
|
|
||||||
// CSLATODO: Check AnnotationAuditInfo.GetIdValue to assure that the ID returned is unique
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A Unique ID for the current AnnotationAuditInfo</returns>
|
|
||||||
protected override object GetIdValue()
|
|
||||||
{
|
|
||||||
return MyAnnotationAuditInfoUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
#region Factory Methods
|
|
||||||
private static int _AnnotationAuditInfoUnique = 0;
|
private static int _AnnotationAuditInfoUnique = 0;
|
||||||
private static int AnnotationAuditInfoUnique
|
private static int AnnotationAuditInfoUnique => ++_AnnotationAuditInfoUnique;
|
||||||
{ get { return ++_AnnotationAuditInfoUnique; } }
|
private readonly int _MyAnnotationAuditInfoUnique = AnnotationAuditInfoUnique;
|
||||||
private int _MyAnnotationAuditInfoUnique = AnnotationAuditInfoUnique;
|
// Absolutely Unique ID - Info
|
||||||
public int MyAnnotationAuditInfoUnique // Absolutely Unique ID - Info
|
public int MyAnnotationAuditInfoUnique => _MyAnnotationAuditInfoUnique;
|
||||||
{ get { return _MyAnnotationAuditInfoUnique; } }
|
|
||||||
protected AnnotationAuditInfo()
|
protected AnnotationAuditInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
}
|
}
|
||||||
private bool _Disposed = false;
|
private bool _Disposed = false;
|
||||||
private static int _CountCreated = 0;
|
private static int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
private static int IncrementCountCreated => ++_CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountCreated => _CountCreated;
|
||||||
public static int CountCreated
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
{ get { return _CountCreated; } }
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountNotDisposed
|
~AnnotationAuditInfo()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~AnnotationAuditInfo()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -267,8 +234,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static AnnotationAuditInfo Get(long auditID)
|
public static AnnotationAuditInfo Get(long auditID)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a AnnotationAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AnnotationAuditInfo tmp = GetCachedByPrimaryKey(auditID);
|
AnnotationAuditInfo tmp = GetCachedByPrimaryKey(auditID);
|
||||||
@@ -307,14 +272,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private long _AuditID;
|
private readonly long _AuditID;
|
||||||
public long AuditID
|
public long AuditID => _AuditID;
|
||||||
{ get { return _AuditID; } }
|
public PKCriteria(long auditID) => _AuditID = auditID;
|
||||||
public PKCriteria(long auditID)
|
}
|
||||||
{
|
|
||||||
_AuditID = auditID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ReadData(SafeDataReader dr)
|
private void ReadData(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfo.ReadData", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfo.ReadData", GetHashCode());
|
||||||
@@ -374,10 +335,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("AnnotationAuditInfo.DataPortal_Fetch", ex);
|
throw new DbCslaException("AnnotationAuditInfo.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
AnnotationAuditInfoExtension _AnnotationAuditInfoExtension = new AnnotationAuditInfoExtension();
|
readonly AnnotationAuditInfoExtension _AnnotationAuditInfoExtension = new AnnotationAuditInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class AnnotationAuditInfoExtension : extensionBase { }
|
partial class AnnotationAuditInfoExtension : extensionBase { }
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
@@ -393,10 +354,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is AnnotationAuditInfo)
|
if (destType == typeof(string) && value is AnnotationAuditInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((AnnotationAuditInfo)value).ToString();
|
return info.ToString();
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
namespace VEPROMS.CSLA.Library
|
namespace VEPROMS.CSLA.Library
|
||||||
@@ -28,11 +26,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
#region Log4Net
|
#region Log4Net
|
||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
#endregion
|
#endregion
|
||||||
#region Business Methods
|
#region Business Methods
|
||||||
internal new IList<AnnotationAuditInfo> Items
|
internal new IList<AnnotationAuditInfo> Items => base.Items;
|
||||||
{ get { return base.Items; } }
|
public void AddEvents()
|
||||||
public void AddEvents()
|
|
||||||
{
|
{
|
||||||
foreach (AnnotationAuditInfo tmp in this)
|
foreach (AnnotationAuditInfo tmp in this)
|
||||||
{
|
{
|
||||||
@@ -51,16 +48,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static int _CountCreated = 0;
|
private static int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
private static int IncrementCountCreated => ++_CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountCreated => _CountCreated;
|
||||||
public static int CountCreated
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
{ get { return _CountCreated; } }
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountNotDisposed
|
~AnnotationAuditInfoList()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~AnnotationAuditInfoList()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -97,25 +90,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on AnnotationAuditInfoList.Get", ex);
|
throw new DbCslaException("Error on AnnotationAuditInfoList.Get", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Reset the list of all AnnotationAuditInfo.
|
|
||||||
/// </summary>
|
|
||||||
public static void Reset()
|
|
||||||
{
|
|
||||||
_AnnotationAuditInfoList = null;
|
|
||||||
}
|
|
||||||
// CSLATODO: Add alternative gets -
|
|
||||||
//public static AnnotationAuditInfoList Get(<criteria>)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// return DataPortal.Fetch<AnnotationAuditInfoList>(new FilteredCriteria(<criteria>));
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// throw new DbCslaException("Error on AnnotationAuditInfoList.Get", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
private AnnotationAuditInfoList()
|
private AnnotationAuditInfoList()
|
||||||
{ /* require use of factory methods */ }
|
{ /* require use of factory methods */ }
|
||||||
#endregion
|
#endregion
|
||||||
@@ -149,41 +123,30 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
this.RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ICustomTypeDescriptor impl
|
#region ICustomTypeDescriptor impl
|
||||||
public String GetClassName()
|
public String GetClassName() => TypeDescriptor.GetClassName(this, true);
|
||||||
{ return TypeDescriptor.GetClassName(this, true); }
|
public AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true);
|
||||||
public AttributeCollection GetAttributes()
|
public String GetComponentName() => TypeDescriptor.GetComponentName(this, true);
|
||||||
{ return TypeDescriptor.GetAttributes(this, true); }
|
public TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true);
|
||||||
public String GetComponentName()
|
public EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
|
||||||
{ return TypeDescriptor.GetComponentName(this, true); }
|
public PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true);
|
||||||
public TypeConverter GetConverter()
|
public object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true);
|
||||||
{ return TypeDescriptor.GetConverter(this, true); }
|
public EventDescriptorCollection GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(this, attributes, true);
|
||||||
public EventDescriptor GetDefaultEvent()
|
public EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true);
|
||||||
{ return TypeDescriptor.GetDefaultEvent(this, true); }
|
public object GetPropertyOwner(PropertyDescriptor pd) => this;
|
||||||
public PropertyDescriptor GetDefaultProperty()
|
/// <summary>
|
||||||
{ return TypeDescriptor.GetDefaultProperty(this, true); }
|
/// Called to get the properties of this type. Returns properties with certain
|
||||||
public object GetEditor(Type editorBaseType)
|
/// attributes. this restriction is not implemented here.
|
||||||
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
|
/// </summary>
|
||||||
public EventDescriptorCollection GetEvents(Attribute[] attributes)
|
/// <param name="attributes"></param>
|
||||||
{ return TypeDescriptor.GetEvents(this, attributes, true); }
|
/// <returns></returns>
|
||||||
public EventDescriptorCollection GetEvents()
|
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
||||||
{ return TypeDescriptor.GetEvents(this, true); }
|
/// <summary>
|
||||||
public object GetPropertyOwner(PropertyDescriptor pd)
|
/// Called to get the properties of this type.
|
||||||
{ return this; }
|
/// </summary>
|
||||||
/// <summary>
|
/// <returns></returns>
|
||||||
/// Called to get the properties of this type. Returns properties with certain
|
public PropertyDescriptorCollection GetProperties()
|
||||||
/// attributes. this restriction is not implemented here.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="attributes"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
|
|
||||||
{ return GetProperties(); }
|
|
||||||
/// <summary>
|
|
||||||
/// Called to get the properties of this type.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PropertyDescriptorCollection GetProperties()
|
|
||||||
{
|
{
|
||||||
// Create a collection object to hold property descriptors
|
// Create a collection object to hold property descriptors
|
||||||
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
||||||
@@ -205,8 +168,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class AnnotationAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class AnnotationAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private AnnotationAuditInfo Item { get { return (AnnotationAuditInfo)_Item; } }
|
public AnnotationAuditInfoListPropertyDescriptor(AnnotationAuditInfoList collection, int index) : base(collection, index) { ;}
|
||||||
public AnnotationAuditInfoListPropertyDescriptor(AnnotationAuditInfoList collection, int index) : base(collection, index) { ;}
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Converter
|
#region Converter
|
||||||
@@ -214,10 +176,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is AnnotationAuditInfoList)
|
if (destType == typeof(string) && value is AnnotationAuditInfoList list)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((AnnotationAuditInfoList)value).Items.Count.ToString() + " AnnotationAudits";
|
return $"{list.Items.Count} AnnotationAudits";
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
namespace VEPROMS.CSLA.Library
|
namespace VEPROMS.CSLA.Library
|
||||||
@@ -28,28 +26,21 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public partial class AnnotationInfo : ReadOnlyBase<AnnotationInfo>, IDisposable
|
public partial class AnnotationInfo : ReadOnlyBase<AnnotationInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public static event AnnotationInfoEvent InfoChanged;
|
public static event AnnotationInfoEvent InfoChanged;
|
||||||
internal void OnInfoChanged(AnnotationInfo annotationInfo)
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping paramater for CSLA support")]
|
||||||
{
|
internal void OnInfoChanged(AnnotationInfo annotationInfo) => InfoChanged?.Invoke(this);
|
||||||
if (InfoChanged != null)
|
internal static void StaticOnInfoChanged() => InfoChanged?.Invoke(null);
|
||||||
InfoChanged(this);
|
public event AnnotationInfoEvent Changed;
|
||||||
}
|
|
||||||
internal static void StaticOnInfoChanged()
|
|
||||||
{
|
|
||||||
if (InfoChanged != null)
|
|
||||||
InfoChanged(null);
|
|
||||||
}
|
|
||||||
public event AnnotationInfoEvent Changed;
|
|
||||||
private void OnChange()
|
private void OnChange()
|
||||||
{
|
{
|
||||||
if (Changed != null)
|
Changed?.Invoke(this);
|
||||||
Changed(this);
|
OnInfoChanged(this);
|
||||||
OnInfoChanged(this);
|
|
||||||
}
|
}
|
||||||
#region Log4Net
|
#region Log4Net
|
||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
#endregion
|
#endregion
|
||||||
#region Collection
|
#region Collection
|
||||||
private static List<AnnotationInfo> _CacheList = new List<AnnotationInfo>();
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
|
private static List<AnnotationInfo> _CacheList = new List<AnnotationInfo>();
|
||||||
protected static void AddToCache(AnnotationInfo annotationInfo)
|
protected static void AddToCache(AnnotationInfo annotationInfo)
|
||||||
{
|
{
|
||||||
if (!_CacheList.Contains(annotationInfo)) _CacheList.Add(annotationInfo); // In AddToCache
|
if (!_CacheList.Contains(annotationInfo)) _CacheList.Add(annotationInfo); // In AddToCache
|
||||||
@@ -58,7 +49,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(annotationInfo)) _CacheList.Remove(annotationInfo); // In RemoveFromCache
|
while (_CacheList.Contains(annotationInfo)) _CacheList.Remove(annotationInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
private static Dictionary<string, List<AnnotationInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationInfo>>();
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
|
private static Dictionary<string, List<AnnotationInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationInfo>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
while (_CacheList.Count > 0) // Move AnnotationInfo(s) from temporary _CacheList to _CacheByPrimaryKey
|
while (_CacheList.Count > 0) // Move AnnotationInfo(s) from temporary _CacheList to _CacheByPrimaryKey
|
||||||
@@ -87,21 +79,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
#region Business Methods
|
#region Business Methods
|
||||||
private string _ErrorMessage = string.Empty;
|
private string _ErrorMessage = string.Empty;
|
||||||
public string ErrorMessage
|
public string ErrorMessage => _ErrorMessage;
|
||||||
{
|
protected Annotation _Editable;
|
||||||
get { return _ErrorMessage; }
|
|
||||||
}
|
|
||||||
protected Annotation _Editable;
|
|
||||||
private IVEHasBrokenRules HasBrokenRules
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
IVEHasBrokenRules hasBrokenRules = null;
|
|
||||||
if (_Editable != null)
|
|
||||||
hasBrokenRules = _Editable.HasBrokenRules;
|
|
||||||
return hasBrokenRules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private int _AnnotationID;
|
private int _AnnotationID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int AnnotationID
|
public int AnnotationID
|
||||||
@@ -197,32 +176,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _UserID;
|
return _UserID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base AnnotationInfo.ToString function as necessary
|
// CSLATODO: Check AnnotationInfo.GetIdValue to assure that the ID returned is unique
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides Base ToString
|
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A string representation of current AnnotationInfo</returns>
|
/// <returns>A Unique ID for the current AnnotationInfo</returns>
|
||||||
//public override string ToString()
|
protected override object GetIdValue() => MyAnnotationInfoUnique; // Absolutely Unique ID
|
||||||
//{
|
#endregion
|
||||||
// return base.ToString();
|
#region Factory Methods
|
||||||
//}
|
private static int _AnnotationInfoUnique = 0;
|
||||||
// CSLATODO: Check AnnotationInfo.GetIdValue to assure that the ID returned is unique
|
private static int AnnotationInfoUnique => ++_AnnotationInfoUnique;
|
||||||
/// <summary>
|
private readonly int _MyAnnotationInfoUnique = AnnotationInfoUnique;
|
||||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
// Absolutely Unique ID - Info
|
||||||
/// </summary>
|
public int MyAnnotationInfoUnique => _MyAnnotationInfoUnique;
|
||||||
/// <returns>A Unique ID for the current AnnotationInfo</returns>
|
|
||||||
protected override object GetIdValue()
|
|
||||||
{
|
|
||||||
return MyAnnotationInfoUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
#region Factory Methods
|
|
||||||
private static int _AnnotationInfoUnique = 0;
|
|
||||||
private static int AnnotationInfoUnique
|
|
||||||
{ get { return ++_AnnotationInfoUnique; } }
|
|
||||||
private int _MyAnnotationInfoUnique = AnnotationInfoUnique;
|
|
||||||
public int MyAnnotationInfoUnique // Absolutely Unique ID - Info
|
|
||||||
{ get { return _MyAnnotationInfoUnique; } }
|
|
||||||
protected AnnotationInfo()
|
protected AnnotationInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -231,16 +197,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static int _CountCreated = 0;
|
private static int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
private static int IncrementCountCreated => ++_CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountCreated => _CountCreated;
|
||||||
public static int CountCreated
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
{ get { return _CountCreated; } }
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountNotDisposed
|
~AnnotationInfo()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~AnnotationInfo()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -256,11 +218,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (listAnnotationInfo.Count == 0) // If there are no items left in the list
|
if (listAnnotationInfo.Count == 0) // If there are no items left in the list
|
||||||
_CacheByPrimaryKey.Remove(AnnotationID.ToString()); // remove the list
|
_CacheByPrimaryKey.Remove(AnnotationID.ToString()); // remove the list
|
||||||
}
|
}
|
||||||
public virtual Annotation Get()
|
public virtual Annotation Get() => _Editable = Annotation.Get(_AnnotationID);
|
||||||
{
|
public static void Refresh(Annotation tmp)
|
||||||
return _Editable = Annotation.Get(_AnnotationID);
|
|
||||||
}
|
|
||||||
public static void Refresh(Annotation tmp)
|
|
||||||
{
|
{
|
||||||
string key = tmp.AnnotationID.ToString();
|
string key = tmp.AnnotationID.ToString();
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
@@ -272,18 +231,18 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_ItemID != tmp.ItemID)
|
if (_ItemID != tmp.ItemID)
|
||||||
{
|
{
|
||||||
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for old value
|
MyItem?.RefreshItemAnnotations(); // Update List for old value
|
||||||
_ItemID = tmp.ItemID; // Update the value
|
_ItemID = tmp.ItemID; // Update the value
|
||||||
}
|
}
|
||||||
_MyItem = null; // Reset list so that the next line gets a new list
|
_MyItem = null; // Reset list so that the next line gets a new list
|
||||||
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for new value
|
MyItem?.RefreshItemAnnotations(); // Update List for new value
|
||||||
if (_TypeID != tmp.TypeID)
|
if (_TypeID != tmp.TypeID)
|
||||||
{
|
{
|
||||||
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old value
|
MyAnnotationType?.RefreshAnnotationTypeAnnotations(); // Update List for old value
|
||||||
_TypeID = tmp.TypeID; // Update the value
|
_TypeID = tmp.TypeID; // Update the value
|
||||||
}
|
}
|
||||||
_MyAnnotationType = null; // Reset list so that the next line gets a new list
|
_MyAnnotationType = null; // Reset list so that the next line gets a new list
|
||||||
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for new value
|
MyAnnotationType?.RefreshAnnotationTypeAnnotations(); // Update List for new value
|
||||||
_RtfText = tmp.RtfText;
|
_RtfText = tmp.RtfText;
|
||||||
_SearchText = tmp.SearchText;
|
_SearchText = tmp.SearchText;
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
@@ -304,11 +263,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_ItemID != tmp.ItemID)
|
if (_ItemID != tmp.ItemID)
|
||||||
{
|
{
|
||||||
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for old value
|
MyItem?.RefreshItemAnnotations(); // Update List for old value
|
||||||
_ItemID = tmp.ItemID; // Update the value
|
_ItemID = tmp.ItemID; // Update the value
|
||||||
}
|
}
|
||||||
_MyItem = null; // Reset list so that the next line gets a new list
|
_MyItem = null; // Reset list so that the next line gets a new list
|
||||||
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for new value
|
MyItem?.RefreshItemAnnotations(); // Update List for new value
|
||||||
_RtfText = tmp.RtfText;
|
_RtfText = tmp.RtfText;
|
||||||
_SearchText = tmp.SearchText;
|
_SearchText = tmp.SearchText;
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
@@ -329,11 +288,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_TypeID != tmp.TypeID)
|
if (_TypeID != tmp.TypeID)
|
||||||
{
|
{
|
||||||
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old value
|
MyAnnotationType?.RefreshAnnotationTypeAnnotations(); // Update List for old value
|
||||||
_TypeID = tmp.TypeID; // Update the value
|
_TypeID = tmp.TypeID; // Update the value
|
||||||
}
|
}
|
||||||
_MyAnnotationType = null; // Reset list so that the next line gets a new list
|
_MyAnnotationType = null; // Reset list so that the next line gets a new list
|
||||||
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for new value
|
MyAnnotationType?.RefreshAnnotationTypeAnnotations(); // Update List for new value
|
||||||
_RtfText = tmp.RtfText;
|
_RtfText = tmp.RtfText;
|
||||||
_SearchText = tmp.SearchText;
|
_SearchText = tmp.SearchText;
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
@@ -344,8 +303,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static AnnotationInfo Get(int annotationID)
|
public static AnnotationInfo Get(int annotationID)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a Annotation");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AnnotationInfo tmp = GetCachedByPrimaryKey(annotationID);
|
AnnotationInfo tmp = GetCachedByPrimaryKey(annotationID);
|
||||||
@@ -384,14 +341,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _AnnotationID;
|
private readonly int _AnnotationID;
|
||||||
public int AnnotationID
|
public int AnnotationID => _AnnotationID;
|
||||||
{ get { return _AnnotationID; } }
|
public PKCriteria(int annotationID) => _AnnotationID = annotationID;
|
||||||
public PKCriteria(int annotationID)
|
}
|
||||||
{
|
|
||||||
_AnnotationID = annotationID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ReadData(SafeDataReader dr)
|
private void ReadData(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.ReadData", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.ReadData", GetHashCode());
|
||||||
@@ -449,10 +402,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("AnnotationInfo.DataPortal_Fetch", ex);
|
throw new DbCslaException("AnnotationInfo.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
AnnotationInfoExtension _AnnotationInfoExtension = new AnnotationInfoExtension();
|
readonly AnnotationInfoExtension _AnnotationInfoExtension = new AnnotationInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class AnnotationInfoExtension : extensionBase { }
|
partial class AnnotationInfoExtension : extensionBase { }
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
@@ -468,10 +421,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is AnnotationInfo)
|
if (destType == typeof(string) && value is AnnotationInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((AnnotationInfo)value).ToString();
|
return info.ToString();
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
namespace VEPROMS.CSLA.Library
|
namespace VEPROMS.CSLA.Library
|
||||||
@@ -28,11 +26,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
#region Log4Net
|
#region Log4Net
|
||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
#endregion
|
#endregion
|
||||||
#region Business Methods
|
#region Business Methods
|
||||||
internal new IList<AnnotationInfo> Items
|
internal new IList<AnnotationInfo> Items => base.Items;
|
||||||
{ get { return base.Items; } }
|
public void AddEvents()
|
||||||
public void AddEvents()
|
|
||||||
{
|
{
|
||||||
foreach (AnnotationInfo tmp in this)
|
foreach (AnnotationInfo tmp in this)
|
||||||
{
|
{
|
||||||
@@ -51,16 +48,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static int _CountCreated = 0;
|
private static int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
private static int IncrementCountCreated => ++_CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountCreated => _CountCreated;
|
||||||
public static int CountCreated
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
{ get { return _CountCreated; } }
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountNotDisposed
|
~AnnotationInfoList()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~AnnotationInfoList()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -97,25 +90,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on AnnotationInfoList.Get", ex);
|
throw new DbCslaException("Error on AnnotationInfoList.Get", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Reset the list of all AnnotationInfo.
|
|
||||||
/// </summary>
|
|
||||||
public static void Reset()
|
|
||||||
{
|
|
||||||
_AnnotationInfoList = null;
|
|
||||||
}
|
|
||||||
// CSLATODO: Add alternative gets -
|
|
||||||
//public static AnnotationInfoList Get(<criteria>)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// return DataPortal.Fetch<AnnotationInfoList>(new FilteredCriteria(<criteria>));
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// throw new DbCslaException("Error on AnnotationInfoList.Get", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
public static AnnotationInfoList GetByTypeID(int typeID)
|
public static AnnotationInfoList GetByTypeID(int typeID)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -139,8 +113,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
tmp.AddEvents();
|
tmp.AddEvents();
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
return new AnnotationInfoList();// B2017-246 If an exception return an empty list
|
return new AnnotationInfoList();// B2017-246 If an exception return an empty list
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,11 +154,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class TypeIDCriteria
|
private class TypeIDCriteria
|
||||||
{
|
{
|
||||||
public TypeIDCriteria(int typeID)
|
public TypeIDCriteria(int typeID) => _TypeID = typeID;
|
||||||
{
|
private int _TypeID;
|
||||||
_TypeID = typeID;
|
|
||||||
}
|
|
||||||
private int _TypeID;
|
|
||||||
public int TypeID
|
public int TypeID
|
||||||
{
|
{
|
||||||
get { return _TypeID; }
|
get { return _TypeID; }
|
||||||
@@ -224,11 +195,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ItemIDCriteria
|
private class ItemIDCriteria
|
||||||
{
|
{
|
||||||
public ItemIDCriteria(int itemID)
|
public ItemIDCriteria(int itemID) => _ItemID = itemID;
|
||||||
{
|
private int _ItemID;
|
||||||
_ItemID = itemID;
|
|
||||||
}
|
|
||||||
private int _ItemID;
|
|
||||||
public int ItemID
|
public int ItemID
|
||||||
{
|
{
|
||||||
get { return _ItemID; }
|
get { return _ItemID; }
|
||||||
@@ -265,41 +233,30 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
this.RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ICustomTypeDescriptor impl
|
#region ICustomTypeDescriptor impl
|
||||||
public String GetClassName()
|
public String GetClassName() => TypeDescriptor.GetClassName(this, true);
|
||||||
{ return TypeDescriptor.GetClassName(this, true); }
|
public AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true);
|
||||||
public AttributeCollection GetAttributes()
|
public String GetComponentName() => TypeDescriptor.GetComponentName(this, true);
|
||||||
{ return TypeDescriptor.GetAttributes(this, true); }
|
public TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true);
|
||||||
public String GetComponentName()
|
public EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
|
||||||
{ return TypeDescriptor.GetComponentName(this, true); }
|
public PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true);
|
||||||
public TypeConverter GetConverter()
|
public object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true);
|
||||||
{ return TypeDescriptor.GetConverter(this, true); }
|
public EventDescriptorCollection GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(this, attributes, true);
|
||||||
public EventDescriptor GetDefaultEvent()
|
public EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true);
|
||||||
{ return TypeDescriptor.GetDefaultEvent(this, true); }
|
public object GetPropertyOwner(PropertyDescriptor pd) => this;
|
||||||
public PropertyDescriptor GetDefaultProperty()
|
/// <summary>
|
||||||
{ return TypeDescriptor.GetDefaultProperty(this, true); }
|
/// Called to get the properties of this type. Returns properties with certain
|
||||||
public object GetEditor(Type editorBaseType)
|
/// attributes. this restriction is not implemented here.
|
||||||
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
|
/// </summary>
|
||||||
public EventDescriptorCollection GetEvents(Attribute[] attributes)
|
/// <param name="attributes"></param>
|
||||||
{ return TypeDescriptor.GetEvents(this, attributes, true); }
|
/// <returns></returns>
|
||||||
public EventDescriptorCollection GetEvents()
|
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
||||||
{ return TypeDescriptor.GetEvents(this, true); }
|
/// <summary>
|
||||||
public object GetPropertyOwner(PropertyDescriptor pd)
|
/// Called to get the properties of this type.
|
||||||
{ return this; }
|
/// </summary>
|
||||||
/// <summary>
|
/// <returns></returns>
|
||||||
/// Called to get the properties of this type. Returns properties with certain
|
public PropertyDescriptorCollection GetProperties()
|
||||||
/// attributes. this restriction is not implemented here.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="attributes"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
|
|
||||||
{ return GetProperties(); }
|
|
||||||
/// <summary>
|
|
||||||
/// Called to get the properties of this type.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PropertyDescriptorCollection GetProperties()
|
|
||||||
{
|
{
|
||||||
// Create a collection object to hold property descriptors
|
// Create a collection object to hold property descriptors
|
||||||
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
||||||
@@ -321,7 +278,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class AnnotationInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class AnnotationInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private AnnotationInfo Item { get { return (AnnotationInfo)_Item; } }
|
|
||||||
public AnnotationInfoListPropertyDescriptor(AnnotationInfoList collection, int index) : base(collection, index) { ;}
|
public AnnotationInfoListPropertyDescriptor(AnnotationInfoList collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -330,10 +286,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is AnnotationInfoList)
|
if (destType == typeof(string) && value is AnnotationInfoList list)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((AnnotationInfoList)value).Items.Count.ToString() + " Annotations";
|
return $"{list.Items.Count} Annotations";
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Csla.Validation;
|
using Csla.Validation;
|
||||||
@@ -69,9 +67,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
ClearRefreshList();
|
ClearRefreshList();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Collection
|
#region Collection
|
||||||
private static List<AnnotationType> _CacheList = new List<AnnotationType>();
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
|
private static List<AnnotationType> _CacheList = new List<AnnotationType>();
|
||||||
protected static void AddToCache(AnnotationType annotationType)
|
protected static void AddToCache(AnnotationType annotationType)
|
||||||
{
|
{
|
||||||
if (!_CacheList.Contains(annotationType)) _CacheList.Add(annotationType); // In AddToCache
|
if (!_CacheList.Contains(annotationType)) _CacheList.Add(annotationType); // In AddToCache
|
||||||
@@ -80,8 +79,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(annotationType)) _CacheList.Remove(annotationType); // In RemoveFromCache
|
while (_CacheList.Contains(annotationType)) _CacheList.Remove(annotationType); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
private static Dictionary<string, List<AnnotationType>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationType>>();
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<AnnotationType>> _CacheByName = new Dictionary<string, List<AnnotationType>>();
|
private static Dictionary<string, List<AnnotationType>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationType>>();
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
|
private static Dictionary<string, List<AnnotationType>> _CacheByName = new Dictionary<string, List<AnnotationType>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
while (_CacheList.Count > 0) // Move AnnotationType(s) from temporary _CacheList to _CacheByPrimaryKey
|
while (_CacheList.Count > 0) // Move AnnotationType(s) from temporary _CacheList to _CacheByPrimaryKey
|
||||||
@@ -115,16 +116,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
#region Business Methods
|
#region Business Methods
|
||||||
private string _ErrorMessage = string.Empty;
|
private string _ErrorMessage = string.Empty;
|
||||||
public string ErrorMessage
|
public string ErrorMessage => _ErrorMessage;
|
||||||
{
|
private static int _nextTypeID = -1;
|
||||||
get { return _ErrorMessage; }
|
public static int NextTypeID => _nextTypeID--;
|
||||||
}
|
private int _TypeID;
|
||||||
private static int _nextTypeID = -1;
|
|
||||||
public static int NextTypeID
|
|
||||||
{
|
|
||||||
get { return _nextTypeID--; }
|
|
||||||
}
|
|
||||||
private int _TypeID;
|
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int TypeID
|
public int TypeID
|
||||||
{
|
{
|
||||||
@@ -262,10 +257,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _AnnotationTypeAnnotations;
|
return _AnnotationTypeAnnotations;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Reset_AnnotationTypeAnnotations()
|
|
||||||
{
|
|
||||||
_AnnotationTypeAnnotationCount = -1;
|
|
||||||
}
|
|
||||||
public override bool IsDirty
|
public override bool IsDirty
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -280,40 +271,25 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (base.IsDirty || list.Contains(this))
|
if (base.IsDirty || list.Contains(this))
|
||||||
return base.IsDirty;
|
return base.IsDirty;
|
||||||
list.Add(this);
|
list.Add(this);
|
||||||
return base.IsDirty || (_AnnotationTypeAnnotations == null ? false : _AnnotationTypeAnnotations.IsDirtyList(list));
|
return base.IsDirty || (_AnnotationTypeAnnotations != null && _AnnotationTypeAnnotations.IsDirtyList(list));
|
||||||
}
|
}
|
||||||
public override bool IsValid
|
public override bool IsValid => IsValidList(new List<object>());
|
||||||
{
|
public bool IsValidList(List<object> list)
|
||||||
get { return IsValidList(new List<object>()); }
|
|
||||||
}
|
|
||||||
public bool IsValidList(List<object> list)
|
|
||||||
{
|
{
|
||||||
if(list.Contains(this))
|
if(list.Contains(this))
|
||||||
return (IsNew && !IsDirty) ? true : base.IsValid;
|
return (IsNew && !IsDirty) || base.IsValid;
|
||||||
list.Add(this);
|
list.Add(this);
|
||||||
return ((IsNew && !IsDirty) ? true : base.IsValid) && (_AnnotationTypeAnnotations == null ? true : _AnnotationTypeAnnotations.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_AnnotationTypeAnnotations == null || _AnnotationTypeAnnotations.IsValidList(list));
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base AnnotationType.ToString function as necessary
|
// CSLATODO: Check AnnotationType.GetIdValue to assure that the ID returned is unique
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides Base ToString
|
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A string representation of current AnnotationType</returns>
|
/// <returns>A Unique ID for the current AnnotationType</returns>
|
||||||
//public override string ToString()
|
protected override object GetIdValue() => MyAnnotationTypeUnique; // Absolutely Unique ID
|
||||||
//{
|
#endregion
|
||||||
// return base.ToString();
|
#region ValidationRules
|
||||||
//}
|
[NonSerialized]
|
||||||
// CSLATODO: Check AnnotationType.GetIdValue to assure that the ID returned is unique
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A Unique ID for the current AnnotationType</returns>
|
|
||||||
protected override object GetIdValue()
|
|
||||||
{
|
|
||||||
return MyAnnotationTypeUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
#region ValidationRules
|
|
||||||
[NonSerialized]
|
|
||||||
private bool _CheckingBrokenRules = false;
|
private bool _CheckingBrokenRules = false;
|
||||||
public IVEHasBrokenRules HasBrokenRules
|
public IVEHasBrokenRules HasBrokenRules
|
||||||
{
|
{
|
||||||
@@ -339,8 +315,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
||||||
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
|
if (Equals(hasBrokenRules)) return BrokenRulesCollection;
|
||||||
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
|
return (hasBrokenRules?.BrokenRules);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override void AddBusinessRules()
|
protected override void AddBusinessRules()
|
||||||
@@ -362,92 +338,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_AnnotationTypeExtension.AddValidationRules(ValidationRules);
|
_AnnotationTypeExtension.AddValidationRules(ValidationRules);
|
||||||
// CSLATODO: Add other validation rules
|
// CSLATODO: Add other validation rules
|
||||||
}
|
}
|
||||||
protected override void AddInstanceBusinessRules()
|
#endregion
|
||||||
{
|
#region Factory Methods
|
||||||
_AnnotationTypeExtension.AddInstanceValidationRules(ValidationRules);
|
public int CurrentEditLevel => EditLevel;
|
||||||
// CSLATODO: Add other validation rules
|
private static int _AnnotationTypeUnique = 0;
|
||||||
}
|
protected static int AnnotationTypeUnique => ++_AnnotationTypeUnique;
|
||||||
// Sample data comparison validation rule
|
private readonly int _MyAnnotationTypeUnique = AnnotationTypeUnique;
|
||||||
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
|
// Absolutely Unique ID - Editable
|
||||||
//{
|
public int MyAnnotationTypeUnique => _MyAnnotationTypeUnique;
|
||||||
// if (_started > _ended)
|
|
||||||
// {
|
|
||||||
// e.Description = "Start date can't be after end date";
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// return true;
|
|
||||||
//}
|
|
||||||
#endregion
|
|
||||||
#region Authorization Rules
|
|
||||||
protected override void AddAuthorizationRules()
|
|
||||||
{
|
|
||||||
//CSLATODO: Who can read/write which fields
|
|
||||||
//AuthorizationRules.AllowRead(TypeID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
|
||||||
_AnnotationTypeExtension.AddAuthorizationRules(AuthorizationRules);
|
|
||||||
}
|
|
||||||
protected override void AddInstanceAuthorizationRules()
|
|
||||||
{
|
|
||||||
//CSLATODO: Who can read/write which fields
|
|
||||||
_AnnotationTypeExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
|
||||||
}
|
|
||||||
public static bool CanAddObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: Can Add Authorization
|
|
||||||
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CanGetObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanGet Authorization
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CanDeleteObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanDelete Authorization
|
|
||||||
//bool result = false;
|
|
||||||
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
|
|
||||||
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
|
|
||||||
//return result;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// determines if related records (Foreign Keys) will keep this Item from being deleted
|
|
||||||
/// </summary>
|
|
||||||
public bool CanDelete
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// Check to make sure that there are not any related records
|
|
||||||
int usedByCount = 0;
|
|
||||||
usedByCount += _AnnotationTypeAnnotationCount;
|
|
||||||
return (usedByCount == 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static bool CanEditObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanEdit Authorization
|
|
||||||
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
#region Factory Methods
|
|
||||||
public int CurrentEditLevel
|
|
||||||
{ get { return EditLevel; } }
|
|
||||||
private static int _AnnotationTypeUnique = 0;
|
|
||||||
protected static int AnnotationTypeUnique
|
|
||||||
{ get { return ++_AnnotationTypeUnique; } }
|
|
||||||
private int _MyAnnotationTypeUnique = AnnotationTypeUnique;
|
|
||||||
public int MyAnnotationTypeUnique // Absolutely Unique ID - Editable
|
|
||||||
{ get { return _MyAnnotationTypeUnique; } }
|
|
||||||
protected AnnotationType()
|
protected AnnotationType()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -456,16 +354,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static int _CountCreated = 0;
|
private static int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
private static int IncrementCountCreated => ++_CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountCreated => _CountCreated;
|
||||||
public static int CountCreated
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
{ get { return _CountCreated; } }
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountNotDisposed
|
~AnnotationType()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~AnnotationType()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -501,8 +395,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static AnnotationType New()
|
public static AnnotationType New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a AnnotationType");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<AnnotationType>();
|
return DataPortal.Create<AnnotationType>();
|
||||||
@@ -568,8 +460,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static AnnotationType Get(int typeID)
|
public static AnnotationType Get(int typeID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a AnnotationType");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AnnotationType tmp = GetCachedByPrimaryKey(typeID);
|
AnnotationType tmp = GetCachedByPrimaryKey(typeID);
|
||||||
@@ -592,8 +482,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static AnnotationType GetByName(string name)
|
public static AnnotationType GetByName(string name)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a AnnotationType");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AnnotationType tmp = GetCachedByName(name);
|
AnnotationType tmp = GetCachedByName(name);
|
||||||
@@ -618,8 +506,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
// doesn't exist, create it (fix B2016-083)
|
// doesn't exist, create it (fix B2016-083)
|
||||||
public static AnnotationType GetByNameOrCreate(string name)
|
public static AnnotationType GetByNameOrCreate(string name)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a AnnotationType");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AnnotationType tmp = GetCachedByName(name);
|
AnnotationType tmp = GetCachedByName(name);
|
||||||
@@ -655,8 +541,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static void Delete(int typeID)
|
public static void Delete(int typeID)
|
||||||
{
|
{
|
||||||
if (!CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a AnnotationType");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataPortal.Delete(new PKCriteria(typeID));
|
DataPortal.Delete(new PKCriteria(typeID));
|
||||||
@@ -668,12 +552,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public override AnnotationType Save()
|
public override AnnotationType Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a AnnotationType");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a AnnotationType");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a AnnotationType");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -693,25 +571,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _TypeID;
|
private readonly int _TypeID;
|
||||||
public int TypeID
|
public int TypeID => _TypeID;
|
||||||
{ get { return _TypeID; } }
|
public PKCriteria(int typeID) => _TypeID = typeID;
|
||||||
public PKCriteria(int typeID)
|
}
|
||||||
{
|
|
||||||
_TypeID = typeID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class NameCriteria
|
private class NameCriteria
|
||||||
{
|
{
|
||||||
private string _Name;
|
private readonly string _Name;
|
||||||
public string Name
|
public string Name => _Name;
|
||||||
{ get { return _Name; } }
|
public NameCriteria(string name) => _Name = name;
|
||||||
public NameCriteria(string name)
|
}
|
||||||
{
|
|
||||||
_Name = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
|
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
|
||||||
[RunLocal()]
|
[RunLocal()]
|
||||||
private new void DataPortal_Create()
|
private new void DataPortal_Create()
|
||||||
@@ -849,39 +719,46 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
internal void SQLInsert()
|
internal void SQLInsert()
|
||||||
{
|
{
|
||||||
if (!this.IsDirty) return;
|
if (!IsDirty) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
using (SqlCommand cm = cn.CreateCommand())
|
{
|
||||||
{
|
using (SqlCommand cm = cn.CreateCommand())
|
||||||
cm.CommandType = CommandType.StoredProcedure;
|
{
|
||||||
cm.CommandTimeout = Database.SQLTimeout;
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
cm.CommandText = "addAnnotationType";
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandText = "addAnnotationType";
|
||||||
cm.Parameters.AddWithValue("@Name", _Name);
|
// Input All Fields - Except Calculated Columns
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@Name", _Name);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
SqlParameter param_TypeID = new SqlParameter("@newTypeID", SqlDbType.Int);
|
// Output Calculated Columns
|
||||||
param_TypeID.Direction = ParameterDirection.Output;
|
SqlParameter param_TypeID = new SqlParameter("@newTypeID", SqlDbType.Int)
|
||||||
cm.Parameters.Add(param_TypeID);
|
{
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
Direction = ParameterDirection.Output
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
};
|
||||||
cm.Parameters.Add(param_LastChanged);
|
cm.Parameters.Add(param_TypeID);
|
||||||
// CSLATODO: Define any additional output parameters
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
cm.ExecuteNonQuery();
|
{
|
||||||
// Save all values being returned from the Procedure
|
Direction = ParameterDirection.Output
|
||||||
_TypeID = (int)cm.Parameters["@newTypeID"].Value;
|
};
|
||||||
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
cm.Parameters.Add(param_LastChanged);
|
||||||
}
|
// CSLATODO: Define any additional output parameters
|
||||||
MarkOld();
|
cm.ExecuteNonQuery();
|
||||||
// update child objects
|
// Save all values being returned from the Procedure
|
||||||
if (_AnnotationTypeAnnotations != null) _AnnotationTypeAnnotations.Update(this);
|
_TypeID = (int)cm.Parameters["@newTypeID"].Value;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.SQLInsert", GetHashCode());
|
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
}
|
||||||
|
|
||||||
|
MarkOld();
|
||||||
|
// update child objects
|
||||||
|
_AnnotationTypeAnnotations?.Update(this);
|
||||||
|
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;
|
_ErrorMessage = ex.Message;
|
||||||
@@ -904,13 +781,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
cm.Parameters.AddWithValue("@Config", config);
|
cm.Parameters.AddWithValue("@Config", config);
|
||||||
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
||||||
cm.Parameters.AddWithValue("@UserID", userID);
|
cm.Parameters.AddWithValue("@UserID", userID);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_TypeID = new SqlParameter("@newTypeID", SqlDbType.Int);
|
SqlParameter param_TypeID = new SqlParameter("@newTypeID", SqlDbType.Int)
|
||||||
param_TypeID.Direction = ParameterDirection.Output;
|
{
|
||||||
cm.Parameters.Add(param_TypeID);
|
Direction = ParameterDirection.Output
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
};
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
cm.Parameters.Add(param_TypeID);
|
||||||
cm.Parameters.Add(param_LastChanged);
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
|
{
|
||||||
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
|
cm.Parameters.Add(param_LastChanged);
|
||||||
// CSLATODO: Define any additional output parameters
|
// CSLATODO: Define any additional output parameters
|
||||||
cm.ExecuteNonQuery();
|
cm.ExecuteNonQuery();
|
||||||
// Save all values being returned from the Procedure
|
// Save all values being returned from the Procedure
|
||||||
@@ -953,37 +834,42 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (!IsDirty) return; // If not dirty - nothing to do
|
if (!IsDirty) return; // If not dirty - nothing to do
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.SQLUpdate", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
if (base.IsDirty)
|
{
|
||||||
{
|
if (base.IsDirty)
|
||||||
using (SqlCommand cm = cn.CreateCommand())
|
{
|
||||||
{
|
using (SqlCommand cm = cn.CreateCommand())
|
||||||
cm.CommandType = CommandType.StoredProcedure;
|
{
|
||||||
cm.CommandTimeout = Database.SQLTimeout;
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
cm.CommandText = "updateAnnotationType";
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandText = "updateAnnotationType";
|
||||||
cm.Parameters.AddWithValue("@TypeID", _TypeID);
|
// All Fields including Calculated Fields
|
||||||
cm.Parameters.AddWithValue("@Name", _Name);
|
cm.Parameters.AddWithValue("@TypeID", _TypeID);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@Name", _Name);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
// Output Calculated Columns
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
cm.Parameters.Add(param_LastChanged);
|
{
|
||||||
// CSLATODO: Define any additional output parameters
|
Direction = ParameterDirection.Output
|
||||||
cm.ExecuteNonQuery();
|
};
|
||||||
// Save all values being returned from the Procedure
|
cm.Parameters.Add(param_LastChanged);
|
||||||
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
// CSLATODO: Define any additional output parameters
|
||||||
}
|
cm.ExecuteNonQuery();
|
||||||
}
|
// Save all values being returned from the Procedure
|
||||||
MarkOld();
|
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||||
// use the open connection to update child objects
|
}
|
||||||
if (_AnnotationTypeAnnotations != null) _AnnotationTypeAnnotations.Update(this);
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
|
MarkOld();
|
||||||
|
// use the open connection to update child objects
|
||||||
|
_AnnotationTypeAnnotations?.Update(this);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.SQLUpdate", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationType.SQLUpdate", ex);
|
||||||
_ErrorMessage = ex.Message;
|
_ErrorMessage = ex.Message;
|
||||||
@@ -992,17 +878,20 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
internal void Update()
|
internal void Update()
|
||||||
{
|
{
|
||||||
if (!this.IsDirty) return;
|
if (!IsDirty) return;
|
||||||
if (base.IsDirty)
|
if (base.IsDirty)
|
||||||
{
|
{
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
if (IsNew)
|
{
|
||||||
_LastChanged = AnnotationType.Add(cn, ref _TypeID, _Name, _Config, _DTS, _UserID);
|
if (IsNew)
|
||||||
else
|
_LastChanged = AnnotationType.Add(cn, ref _TypeID, _Name, _Config, _DTS, _UserID);
|
||||||
_LastChanged = AnnotationType.Update(cn, ref _TypeID, _Name, _Config, _DTS, _UserID, ref _LastChanged);
|
else
|
||||||
MarkOld();
|
_LastChanged = AnnotationType.Update(cn, ref _TypeID, _Name, _Config, _DTS, _UserID, ref _LastChanged);
|
||||||
}
|
}
|
||||||
if (_AnnotationTypeAnnotations != null) _AnnotationTypeAnnotations.Update(this);
|
|
||||||
|
MarkOld();
|
||||||
|
}
|
||||||
|
_AnnotationTypeAnnotations?.Update(this);
|
||||||
}
|
}
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
public static byte[] Update(SqlConnection cn, ref int typeID, string name, string config, DateTime dts, string userID, ref byte[] lastChanged)
|
public static byte[] Update(SqlConnection cn, ref int typeID, string name, string config, DateTime dts, string userID, ref byte[] lastChanged)
|
||||||
@@ -1022,10 +911,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
||||||
cm.Parameters.AddWithValue("@UserID", userID);
|
cm.Parameters.AddWithValue("@UserID", userID);
|
||||||
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
{
|
||||||
cm.Parameters.Add(param_LastChanged);
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
|
cm.Parameters.Add(param_LastChanged);
|
||||||
// CSLATODO: Define any additional output parameters
|
// CSLATODO: Define any additional output parameters
|
||||||
cm.ExecuteNonQuery();
|
cm.ExecuteNonQuery();
|
||||||
// Save all values being returned from the Procedure
|
// Save all values being returned from the Procedure
|
||||||
@@ -1038,12 +929,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("AnnotationType.Update", ex);
|
throw new DbCslaException("AnnotationType.Update", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
protected override void DataPortal_DeleteSelf()
|
protected override void DataPortal_DeleteSelf() => DataPortal_Delete(new PKCriteria(_TypeID));
|
||||||
{
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
DataPortal_Delete(new PKCriteria(_TypeID));
|
|
||||||
}
|
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
|
||||||
private void DataPortal_Delete(PKCriteria criteria)
|
private void DataPortal_Delete(PKCriteria criteria)
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Delete", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Delete", GetHashCode());
|
||||||
@@ -1109,17 +997,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ExistsCommand : CommandBase
|
private class ExistsCommand : CommandBase
|
||||||
{
|
{
|
||||||
private int _TypeID;
|
private readonly int _TypeID;
|
||||||
private bool _exists;
|
private bool _exists;
|
||||||
public bool Exists
|
public bool Exists => _exists;
|
||||||
{
|
public ExistsCommand(int typeID) => _TypeID = typeID;
|
||||||
get { return _exists; }
|
protected override void DataPortal_Execute()
|
||||||
}
|
|
||||||
public ExistsCommand(int typeID)
|
|
||||||
{
|
|
||||||
_TypeID = typeID;
|
|
||||||
}
|
|
||||||
protected override void DataPortal_Execute()
|
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Execute", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.DataPortal_Execute", GetHashCode());
|
||||||
try
|
try
|
||||||
@@ -1145,10 +1027,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
AnnotationTypeExtension _AnnotationTypeExtension = new AnnotationTypeExtension();
|
readonly AnnotationTypeExtension _AnnotationTypeExtension = new AnnotationTypeExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class AnnotationTypeExtension : extensionBase
|
partial class AnnotationTypeExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -1156,17 +1038,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
class extensionBase
|
class extensionBase
|
||||||
{
|
{
|
||||||
// Default Values
|
// Default Values
|
||||||
public virtual DateTime DefaultDTS
|
public virtual DateTime DefaultDTS => DateTime.Now;
|
||||||
{
|
public virtual string DefaultUserID => Volian.Base.Library.VlnSettings.UserID;
|
||||||
get { return DateTime.Now; }
|
// Authorization Rules
|
||||||
}
|
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
||||||
public virtual string DefaultUserID
|
|
||||||
{
|
|
||||||
get { return Volian.Base.Library.VlnSettings.UserID; }
|
|
||||||
}
|
|
||||||
// Authorization Rules
|
|
||||||
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
{
|
{
|
||||||
// Needs to be overriden to add new authorization rules
|
// Needs to be overriden to add new authorization rules
|
||||||
}
|
}
|
||||||
@@ -1193,57 +1069,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is AnnotationType)
|
if (destType == typeof(string) && value is AnnotationType type)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((AnnotationType)value).ToString();
|
return type.ToString();
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
} // Namespace
|
} // Namespace
|
||||||
|
|
||||||
|
|
||||||
//// The following is a sample Extension File. You can use it to create AnnotationTypeExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class AnnotationType
|
|
||||||
// {
|
|
||||||
// partial class AnnotationTypeExtension : extensionBase
|
|
||||||
// {
|
|
||||||
// // CSLATODO: Override automatic defaults
|
|
||||||
// public virtual DateTime DefaultDTS
|
|
||||||
// {
|
|
||||||
// get { return DateTime.Now; }
|
|
||||||
// }
|
|
||||||
// public virtual string DefaultUserID
|
|
||||||
// {
|
|
||||||
// get { return Environment.UserName.ToUpper(); }
|
|
||||||
// }
|
|
||||||
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddRule(
|
|
||||||
// Csla.Validation.CommonRules.StringMaxLength,
|
|
||||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddInstanceRule(/* Instance Validation Rule */);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
@@ -9,12 +9,9 @@
|
|||||||
// ========================================================================
|
// ========================================================================
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Data;
|
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Csla.Validation;
|
using Csla.Validation;
|
||||||
@@ -31,12 +28,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
#endregion
|
#endregion
|
||||||
#region Business Methods
|
#region Business Methods
|
||||||
private string _ErrorMessage = string.Empty;
|
private readonly string _ErrorMessage = string.Empty;
|
||||||
public string ErrorMessage
|
public string ErrorMessage => _ErrorMessage;
|
||||||
{
|
private int _AnnotationID;
|
||||||
get { return _ErrorMessage; }
|
|
||||||
}
|
|
||||||
private int _AnnotationID;
|
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int AnnotationID
|
public int AnnotationID
|
||||||
{
|
{
|
||||||
@@ -219,25 +213,22 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _Item_UserID;
|
return _Item_UserID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CSLATODO: Check AnnotationTypeAnnotation.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check AnnotationTypeAnnotation.GetIdValue to assure that the ID returned is unique
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A Unique ID for the current AnnotationTypeAnnotation</returns>
|
/// <returns>A Unique ID for the current AnnotationTypeAnnotation</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyAnnotationTypeAnnotationUnique; // Absolutely Unique ID
|
||||||
{
|
// CSLATODO: Replace base AnnotationTypeAnnotation.ToString function as necessary
|
||||||
return MyAnnotationTypeAnnotationUnique; // Absolutely Unique ID
|
/// <summary>
|
||||||
}
|
/// Overrides Base ToString
|
||||||
// CSLATODO: Replace base AnnotationTypeAnnotation.ToString function as necessary
|
/// </summary>
|
||||||
/// <summary>
|
/// <returns>A string representation of current AnnotationTypeAnnotation</returns>
|
||||||
/// Overrides Base ToString
|
//public override string ToString()
|
||||||
/// </summary>
|
//{
|
||||||
/// <returns>A string representation of current AnnotationTypeAnnotation</returns>
|
// return base.ToString();
|
||||||
//public override string ToString()
|
//}
|
||||||
//{
|
public override bool IsDirty
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
public override bool IsDirty
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -251,18 +242,15 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (base.IsDirty || list.Contains(this))
|
if (base.IsDirty || list.Contains(this))
|
||||||
return base.IsDirty;
|
return base.IsDirty;
|
||||||
list.Add(this);
|
list.Add(this);
|
||||||
return base.IsDirty || (_MyItem == null ? false : _MyItem.IsDirtyList(list));
|
return base.IsDirty || (_MyItem != null && _MyItem.IsDirtyList(list));
|
||||||
}
|
}
|
||||||
public override bool IsValid
|
public override bool IsValid => IsValidList(new List<object>());
|
||||||
{
|
public bool IsValidList(List<object> list)
|
||||||
get { return IsValidList(new List<object>()); }
|
|
||||||
}
|
|
||||||
public bool IsValidList(List<object> list)
|
|
||||||
{
|
{
|
||||||
if(list.Contains(this))
|
if(list.Contains(this))
|
||||||
return (IsNew && !IsDirty) ? true : base.IsValid;
|
return (IsNew && !IsDirty) || base.IsValid;
|
||||||
list.Add(this);
|
list.Add(this);
|
||||||
return ((IsNew && !IsDirty) ? true : base.IsValid) && (_MyItem == null ? true : _MyItem.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_MyItem == null || _MyItem.IsValidList(list));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
@@ -292,8 +280,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
||||||
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
|
if (Equals(hasBrokenRules)) return BrokenRulesCollection;
|
||||||
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
|
return (hasBrokenRules?.BrokenRules);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override void AddBusinessRules()
|
protected override void AddBusinessRules()
|
||||||
@@ -324,81 +312,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Sample data comparison validation rule
|
#endregion
|
||||||
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
|
#region Factory Methods
|
||||||
//{
|
public int CurrentEditLevel => EditLevel;
|
||||||
// if (_started > _ended)
|
private static int _AnnotationTypeAnnotationUnique = 0;
|
||||||
// {
|
private static int AnnotationTypeAnnotationUnique => ++_AnnotationTypeAnnotationUnique;
|
||||||
// e.Description = "Start date can't be after end date";
|
private readonly int _MyAnnotationTypeAnnotationUnique = AnnotationTypeAnnotationUnique;
|
||||||
// return false;
|
// Absolutely Unique ID - Editable FK
|
||||||
// }
|
public int MyAnnotationTypeAnnotationUnique => _MyAnnotationTypeAnnotationUnique;
|
||||||
// else
|
internal static AnnotationTypeAnnotation New(Item myItem) => new AnnotationTypeAnnotation(myItem);
|
||||||
// return true;
|
internal static AnnotationTypeAnnotation Get(SafeDataReader dr) => new AnnotationTypeAnnotation(dr);
|
||||||
//}
|
public AnnotationTypeAnnotation()
|
||||||
#endregion
|
|
||||||
#region Authorization Rules
|
|
||||||
protected override void AddAuthorizationRules()
|
|
||||||
{
|
|
||||||
//CSLATODO: Who can read/write which fields
|
|
||||||
//AuthorizationRules.AllowRead(AnnotationID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(RtfText, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(RtfText, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(SearchText, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(SearchText, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
|
||||||
}
|
|
||||||
public static bool CanAddObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: Can Add Authorization
|
|
||||||
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CanGetObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanGet Authorization
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CanDeleteObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanDelete Authorization
|
|
||||||
//bool result = false;
|
|
||||||
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
|
|
||||||
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
|
|
||||||
//return result;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CanEditObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanEdit Authorization
|
|
||||||
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
#region Factory Methods
|
|
||||||
public int CurrentEditLevel
|
|
||||||
{ get { return EditLevel; } }
|
|
||||||
private static int _AnnotationTypeAnnotationUnique = 0;
|
|
||||||
private static int AnnotationTypeAnnotationUnique
|
|
||||||
{ get { return ++_AnnotationTypeAnnotationUnique; } }
|
|
||||||
private int _MyAnnotationTypeAnnotationUnique = AnnotationTypeAnnotationUnique;
|
|
||||||
public int MyAnnotationTypeAnnotationUnique // Absolutely Unique ID - Editable FK
|
|
||||||
{ get { return _MyAnnotationTypeAnnotationUnique; } }
|
|
||||||
internal static AnnotationTypeAnnotation New(Item myItem)
|
|
||||||
{
|
|
||||||
return new AnnotationTypeAnnotation(myItem);
|
|
||||||
}
|
|
||||||
internal static AnnotationTypeAnnotation Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new AnnotationTypeAnnotation(dr);
|
|
||||||
}
|
|
||||||
public AnnotationTypeAnnotation()
|
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
_AnnotationID = Annotation.NextAnnotationID;
|
_AnnotationID = Annotation.NextAnnotationID;
|
||||||
@@ -425,16 +349,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static int _CountCreated = 0;
|
private static int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
private static int IncrementCountCreated => ++_CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountCreated => _CountCreated;
|
||||||
public static int CountCreated
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
{ get { return _CountCreated; } }
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountNotDisposed
|
~AnnotationTypeAnnotation()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~AnnotationTypeAnnotation()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -472,35 +392,45 @@ namespace VEPROMS.CSLA.Library
|
|||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
internal void Insert(AnnotationType myAnnotationType)
|
internal void Insert(AnnotationType myAnnotationType)
|
||||||
{
|
{
|
||||||
// if we're not dirty then don't update the database
|
// if we're not dirty then don't update the database
|
||||||
if (!this.IsDirty) return;
|
if (!IsDirty) return;
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
_LastChanged = Annotation.Add(cn, ref _AnnotationID, _MyItem, myAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID);
|
{
|
||||||
MarkOld();
|
_LastChanged = Annotation.Add(cn, ref _AnnotationID, _MyItem, myAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID);
|
||||||
}
|
}
|
||||||
internal void Update(AnnotationType myAnnotationType)
|
|
||||||
{
|
MarkOld();
|
||||||
// if we're not dirty then don't update the database
|
}
|
||||||
if (!this.IsDirty) return;
|
internal void Update(AnnotationType myAnnotationType)
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
{
|
||||||
_LastChanged = Annotation.Update(cn, ref _AnnotationID, _ItemID, myAnnotationType.TypeID, _RtfText, _SearchText, _Config, _DTS, _UserID, ref _LastChanged);
|
// if we're not dirty then don't update the database
|
||||||
MarkOld();
|
if (!IsDirty) return;
|
||||||
}
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
internal void DeleteSelf(AnnotationType myAnnotationType)
|
{
|
||||||
{
|
_LastChanged = Annotation.Update(cn, ref _AnnotationID, _ItemID, myAnnotationType.TypeID, _RtfText, _SearchText, _Config, _DTS, _UserID, ref _LastChanged);
|
||||||
// if we're not dirty then don't update the database
|
}
|
||||||
if (!this.IsDirty) return;
|
|
||||||
// if we're new then don't update the database
|
MarkOld();
|
||||||
if (this.IsNew) return;
|
}
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping paramater for CSLA support")]
|
||||||
Annotation.Remove(cn, _AnnotationID);
|
internal void DeleteSelf(AnnotationType myAnnotationType)
|
||||||
MarkNew();
|
{
|
||||||
}
|
// if we're not dirty then don't update the database
|
||||||
#endregion
|
if (!IsDirty) return;
|
||||||
// Standard Default Code
|
// if we're new then don't update the database
|
||||||
#region extension
|
if (IsNew) return;
|
||||||
AnnotationTypeAnnotationExtension _AnnotationTypeAnnotationExtension = new AnnotationTypeAnnotationExtension();
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
|
{
|
||||||
|
Annotation.Remove(cn, _AnnotationID);
|
||||||
|
}
|
||||||
|
|
||||||
|
MarkNew();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
// Standard Default Code
|
||||||
|
#region extension
|
||||||
|
readonly AnnotationTypeAnnotationExtension _AnnotationTypeAnnotationExtension = new AnnotationTypeAnnotationExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class AnnotationTypeAnnotationExtension : extensionBase
|
partial class AnnotationTypeAnnotationExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -508,17 +438,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
class extensionBase
|
class extensionBase
|
||||||
{
|
{
|
||||||
// Default Values
|
// Default Values
|
||||||
public virtual DateTime DefaultDTS
|
public virtual DateTime DefaultDTS => DateTime.Now;
|
||||||
{
|
public virtual string DefaultUserID => Volian.Base.Library.VlnSettings.UserID;
|
||||||
get { return DateTime.Now; }
|
// Authorization Rules
|
||||||
}
|
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
||||||
public virtual string DefaultUserID
|
|
||||||
{
|
|
||||||
get { return Volian.Base.Library.VlnSettings.UserID; }
|
|
||||||
}
|
|
||||||
// Authorization Rules
|
|
||||||
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
{
|
{
|
||||||
// Needs to be overriden to add new authorization rules
|
// Needs to be overriden to add new authorization rules
|
||||||
}
|
}
|
||||||
@@ -545,57 +469,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is AnnotationTypeAnnotation)
|
if (destType == typeof(string) && value is AnnotationTypeAnnotation ann)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((AnnotationTypeAnnotation)value).ToString();
|
return ann.ToString();
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
} // Namespace
|
} // Namespace
|
||||||
|
|
||||||
|
|
||||||
//// The following is a sample Extension File. You can use it to create AnnotationTypeAnnotationExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class AnnotationTypeAnnotation
|
|
||||||
// {
|
|
||||||
// partial class AnnotationTypeAnnotationExtension : extensionBase
|
|
||||||
// {
|
|
||||||
// // CSLATODO: Override automatic defaults
|
|
||||||
// public virtual DateTime DefaultDTS
|
|
||||||
// {
|
|
||||||
// get { return DateTime.Now; }
|
|
||||||
// }
|
|
||||||
// public virtual string DefaultUserID
|
|
||||||
// {
|
|
||||||
// get { return Environment.UserName.ToUpper(); }
|
|
||||||
// }
|
|
||||||
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddRule(
|
|
||||||
// Csla.Validation.CommonRules.StringMaxLength,
|
|
||||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddInstanceRule(/* Instance Validation Rule */);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Csla.Validation;
|
using Csla.Validation;
|
||||||
@@ -31,13 +29,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
#endregion
|
#endregion
|
||||||
#region Business Methods
|
#region Business Methods
|
||||||
private string _ErrorMessage = string.Empty;
|
private readonly string _ErrorMessage = string.Empty;
|
||||||
public string ErrorMessage
|
public string ErrorMessage => _ErrorMessage;
|
||||||
{
|
// One To Many
|
||||||
get { return _ErrorMessage; }
|
public AnnotationTypeAnnotation this[Annotation myAnnotation]
|
||||||
}
|
|
||||||
// One To Many
|
|
||||||
public AnnotationTypeAnnotation this[Annotation myAnnotation]
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -47,11 +42,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public new System.Collections.Generic.IList<AnnotationTypeAnnotation> Items
|
public new System.Collections.Generic.IList<AnnotationTypeAnnotation> Items => base.Items;
|
||||||
{
|
public AnnotationTypeAnnotation GetItem(Annotation myAnnotation)
|
||||||
get { return base.Items; }
|
|
||||||
}
|
|
||||||
public AnnotationTypeAnnotation GetItem(Annotation myAnnotation)
|
|
||||||
{
|
{
|
||||||
foreach (AnnotationTypeAnnotation annotation in this)
|
foreach (AnnotationTypeAnnotation annotation in this)
|
||||||
if (annotation.AnnotationID == myAnnotation.AnnotationID)
|
if (annotation.AnnotationID == myAnnotation.AnnotationID)
|
||||||
@@ -61,7 +53,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public AnnotationTypeAnnotation Add(Item myItem) // One to Many
|
public AnnotationTypeAnnotation Add(Item myItem) // One to Many
|
||||||
{
|
{
|
||||||
AnnotationTypeAnnotation annotation = AnnotationTypeAnnotation.New(myItem);
|
AnnotationTypeAnnotation annotation = AnnotationTypeAnnotation.New(myItem);
|
||||||
this.Add(annotation);
|
Add(annotation);
|
||||||
return annotation;
|
return annotation;
|
||||||
}
|
}
|
||||||
public void Remove(Annotation myAnnotation)
|
public void Remove(Annotation myAnnotation)
|
||||||
@@ -103,10 +95,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public override bool IsValid
|
|
||||||
{
|
|
||||||
get { return IsValidList(new List<object>()); }
|
|
||||||
}
|
|
||||||
public bool IsValidList(List<object> list)
|
public bool IsValidList(List<object> list)
|
||||||
{
|
{
|
||||||
// run through all the child objects
|
// run through all the child objects
|
||||||
@@ -137,20 +125,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
||||||
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
|
return (hasBrokenRules?.BrokenRules);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
internal static AnnotationTypeAnnotations New()
|
internal static AnnotationTypeAnnotations New() => new AnnotationTypeAnnotations();
|
||||||
{
|
internal static AnnotationTypeAnnotations Get(SafeDataReader dr) => new AnnotationTypeAnnotations(dr);
|
||||||
return new AnnotationTypeAnnotations();
|
public static AnnotationTypeAnnotations GetByTypeID(int typeID)
|
||||||
}
|
|
||||||
internal static AnnotationTypeAnnotations Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new AnnotationTypeAnnotations(dr);
|
|
||||||
}
|
|
||||||
public static AnnotationTypeAnnotations GetByTypeID(int typeID)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -161,11 +143,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on AnnotationTypeAnnotations.GetByTypeID", ex);
|
throw new DbCslaException("Error on AnnotationTypeAnnotations.GetByTypeID", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private AnnotationTypeAnnotations()
|
private AnnotationTypeAnnotations() => MarkAsChild();
|
||||||
{
|
internal AnnotationTypeAnnotations(SafeDataReader dr)
|
||||||
MarkAsChild();
|
|
||||||
}
|
|
||||||
internal AnnotationTypeAnnotations(SafeDataReader dr)
|
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
Fetch(dr);
|
Fetch(dr);
|
||||||
@@ -174,16 +153,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static int _CountCreated = 0;
|
private static int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
private static int IncrementCountCreated => ++_CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountCreated => _CountCreated;
|
||||||
public static int CountCreated
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
{ get { return _CountCreated; } }
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountNotDisposed
|
~AnnotationTypeAnnotations()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~AnnotationTypeAnnotations()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -198,19 +173,16 @@ namespace VEPROMS.CSLA.Library
|
|||||||
// called to load data from the database
|
// called to load data from the database
|
||||||
private void Fetch(SafeDataReader dr)
|
private void Fetch(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
while (dr.Read())
|
while (dr.Read())
|
||||||
this.Add(AnnotationTypeAnnotation.Get(dr));
|
Add(AnnotationTypeAnnotation.Get(dr));
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class TypeIDCriteria
|
private class TypeIDCriteria
|
||||||
{
|
{
|
||||||
public TypeIDCriteria(int typeID)
|
public TypeIDCriteria(int typeID) => _TypeID = typeID;
|
||||||
{
|
private int _TypeID;
|
||||||
_TypeID = typeID;
|
|
||||||
}
|
|
||||||
private int _TypeID;
|
|
||||||
public int TypeID
|
public int TypeID
|
||||||
{
|
{
|
||||||
get { return _TypeID; }
|
get { return _TypeID; }
|
||||||
@@ -219,7 +191,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
private void DataPortal_Fetch(TypeIDCriteria criteria)
|
private void DataPortal_Fetch(TypeIDCriteria criteria)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeAnnotations.DataPortal_FetchTypeID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeAnnotations.DataPortal_FetchTypeID", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -233,7 +205,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
cm.CommandTimeout = Database.DefaultTimeout;
|
cm.CommandTimeout = Database.DefaultTimeout;
|
||||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||||
{
|
{
|
||||||
while (dr.Read()) this.Add(new AnnotationTypeAnnotation(dr));
|
while (dr.Read()) Add(new AnnotationTypeAnnotation(dr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,11 +215,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeAnnotations.DataPortal_FetchTypeID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeAnnotations.DataPortal_FetchTypeID", ex);
|
||||||
throw new DbCslaException("AnnotationTypeAnnotations.DataPortal_Fetch", ex);
|
throw new DbCslaException("AnnotationTypeAnnotations.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
internal void Update(AnnotationType annotationType)
|
internal void Update(AnnotationType annotationType)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// update (thus deleting) any deleted child objects
|
// update (thus deleting) any deleted child objects
|
||||||
@@ -266,49 +238,38 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ICustomTypeDescriptor impl
|
#region ICustomTypeDescriptor impl
|
||||||
public String GetClassName()
|
public String GetClassName() => TypeDescriptor.GetClassName(this, true);
|
||||||
{ return TypeDescriptor.GetClassName(this, true); }
|
public AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true);
|
||||||
public AttributeCollection GetAttributes()
|
public String GetComponentName() => TypeDescriptor.GetComponentName(this, true);
|
||||||
{ return TypeDescriptor.GetAttributes(this, true); }
|
public TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true);
|
||||||
public String GetComponentName()
|
public EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
|
||||||
{ return TypeDescriptor.GetComponentName(this, true); }
|
public PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true);
|
||||||
public TypeConverter GetConverter()
|
public object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true);
|
||||||
{ return TypeDescriptor.GetConverter(this, true); }
|
public EventDescriptorCollection GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(this, attributes, true);
|
||||||
public EventDescriptor GetDefaultEvent()
|
public EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true);
|
||||||
{ return TypeDescriptor.GetDefaultEvent(this, true); }
|
public object GetPropertyOwner(PropertyDescriptor pd) => this;
|
||||||
public PropertyDescriptor GetDefaultProperty()
|
/// <summary>
|
||||||
{ return TypeDescriptor.GetDefaultProperty(this, true); }
|
/// Called to get the properties of this type. Returns properties with certain
|
||||||
public object GetEditor(Type editorBaseType)
|
/// attributes. this restriction is not implemented here.
|
||||||
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
|
/// </summary>
|
||||||
public EventDescriptorCollection GetEvents(Attribute[] attributes)
|
/// <param name="attributes"></param>
|
||||||
{ return TypeDescriptor.GetEvents(this, attributes, true); }
|
/// <returns></returns>
|
||||||
public EventDescriptorCollection GetEvents()
|
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
||||||
{ return TypeDescriptor.GetEvents(this, true); }
|
/// <summary>
|
||||||
public object GetPropertyOwner(PropertyDescriptor pd)
|
/// Called to get the properties of this type.
|
||||||
{ return this; }
|
/// </summary>
|
||||||
/// <summary>
|
/// <returns></returns>
|
||||||
/// Called to get the properties of this type. Returns properties with certain
|
public PropertyDescriptorCollection GetProperties()
|
||||||
/// attributes. this restriction is not implemented here.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="attributes"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
|
|
||||||
{ return GetProperties(); }
|
|
||||||
/// <summary>
|
|
||||||
/// Called to get the properties of this type.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PropertyDescriptorCollection GetProperties()
|
|
||||||
{
|
{
|
||||||
// Create a collection object to hold property descriptors
|
// Create a collection object to hold property descriptors
|
||||||
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
||||||
// Iterate the list
|
// Iterate the list
|
||||||
for (int i = 0; i < this.Items.Count; i++)
|
for (int i = 0; i < Items.Count; i++)
|
||||||
{
|
{
|
||||||
// Create a property descriptor for the item and add to the property descriptor collection
|
// Create a property descriptor for the item and add to the property descriptor collection
|
||||||
AnnotationTypeAnnotationsPropertyDescriptor pd = new AnnotationTypeAnnotationsPropertyDescriptor(this, i);
|
AnnotationTypeAnnotationsPropertyDescriptor pd = new AnnotationTypeAnnotationsPropertyDescriptor(this, i);
|
||||||
@@ -325,7 +286,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class AnnotationTypeAnnotationsPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class AnnotationTypeAnnotationsPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private AnnotationTypeAnnotation Item { get { return (AnnotationTypeAnnotation)_Item; } }
|
|
||||||
public AnnotationTypeAnnotationsPropertyDescriptor(AnnotationTypeAnnotations collection, int index) : base(collection, index) { ;}
|
public AnnotationTypeAnnotationsPropertyDescriptor(AnnotationTypeAnnotations collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -334,10 +294,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is AnnotationTypeAnnotations)
|
if (destType == typeof(string) && value is AnnotationTypeAnnotations ann)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((AnnotationTypeAnnotations)value).Items.Count.ToString() + " Annotations";
|
return $"{ann.Items.Count} Annotations";
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -30,15 +28,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public partial class AnnotationTypeInfo : ReadOnlyBase<AnnotationTypeInfo>, IDisposable
|
public partial class AnnotationTypeInfo : ReadOnlyBase<AnnotationTypeInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public event AnnotationTypeInfoEvent Changed;
|
public event AnnotationTypeInfoEvent Changed;
|
||||||
private void OnChange()
|
private void OnChange() => Changed?.Invoke(this);
|
||||||
{
|
#region Log4Net
|
||||||
if (Changed != null) Changed(this);
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
}
|
#endregion
|
||||||
#region Log4Net
|
#region Collection
|
||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
#endregion
|
private static List<AnnotationTypeInfo> _CacheList = new List<AnnotationTypeInfo>();
|
||||||
#region Collection
|
|
||||||
private static List<AnnotationTypeInfo> _CacheList = new List<AnnotationTypeInfo>();
|
|
||||||
protected static void AddToCache(AnnotationTypeInfo annotationTypeInfo)
|
protected static void AddToCache(AnnotationTypeInfo annotationTypeInfo)
|
||||||
{
|
{
|
||||||
if (!_CacheList.Contains(annotationTypeInfo)) _CacheList.Add(annotationTypeInfo); // In AddToCache
|
if (!_CacheList.Contains(annotationTypeInfo)) _CacheList.Add(annotationTypeInfo); // In AddToCache
|
||||||
@@ -47,7 +43,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(annotationTypeInfo)) _CacheList.Remove(annotationTypeInfo); // In RemoveFromCache
|
while (_CacheList.Contains(annotationTypeInfo)) _CacheList.Remove(annotationTypeInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
private static Dictionary<string, List<AnnotationTypeInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationTypeInfo>>();
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
|
private static Dictionary<string, List<AnnotationTypeInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationTypeInfo>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
while (_CacheList.Count > 0) // Move AnnotationTypeInfo(s) from temporary _CacheList to _CacheByPrimaryKey
|
while (_CacheList.Count > 0) // Move AnnotationTypeInfo(s) from temporary _CacheList to _CacheByPrimaryKey
|
||||||
@@ -76,21 +73,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
#region Business Methods
|
#region Business Methods
|
||||||
private string _ErrorMessage = string.Empty;
|
private string _ErrorMessage = string.Empty;
|
||||||
public string ErrorMessage
|
public string ErrorMessage => _ErrorMessage;
|
||||||
{
|
protected AnnotationType _Editable;
|
||||||
get { return _ErrorMessage; }
|
|
||||||
}
|
|
||||||
protected AnnotationType _Editable;
|
|
||||||
private IVEHasBrokenRules HasBrokenRules
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
IVEHasBrokenRules hasBrokenRules = null;
|
|
||||||
if (_Editable != null)
|
|
||||||
hasBrokenRules = _Editable.HasBrokenRules;
|
|
||||||
return hasBrokenRules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private int _TypeID;
|
private int _TypeID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int TypeID
|
public int TypeID
|
||||||
@@ -186,32 +170,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
foreach (AnnotationTypeInfo tmp in _CacheByPrimaryKey[_TypeID.ToString()])
|
foreach (AnnotationTypeInfo tmp in _CacheByPrimaryKey[_TypeID.ToString()])
|
||||||
tmp._AnnotationTypeAnnotationCount = -1; // This will cause the data to be requeried
|
tmp._AnnotationTypeAnnotationCount = -1; // This will cause the data to be requeried
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base AnnotationTypeInfo.ToString function as necessary
|
// CSLATODO: Check AnnotationTypeInfo.GetIdValue to assure that the ID returned is unique
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides Base ToString
|
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A string representation of current AnnotationTypeInfo</returns>
|
/// <returns>A Unique ID for the current AnnotationTypeInfo</returns>
|
||||||
//public override string ToString()
|
protected override object GetIdValue() => MyAnnotationTypeInfoUnique; // Absolutely Unique ID
|
||||||
//{
|
#endregion
|
||||||
// return base.ToString();
|
#region Factory Methods
|
||||||
//}
|
private static int _AnnotationTypeInfoUnique = 0;
|
||||||
// CSLATODO: Check AnnotationTypeInfo.GetIdValue to assure that the ID returned is unique
|
private static int AnnotationTypeInfoUnique => ++_AnnotationTypeInfoUnique;
|
||||||
/// <summary>
|
private readonly int _MyAnnotationTypeInfoUnique = AnnotationTypeInfoUnique;
|
||||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
// Absolutely Unique ID - Info
|
||||||
/// </summary>
|
public int MyAnnotationTypeInfoUnique => _MyAnnotationTypeInfoUnique;
|
||||||
/// <returns>A Unique ID for the current AnnotationTypeInfo</returns>
|
|
||||||
protected override object GetIdValue()
|
|
||||||
{
|
|
||||||
return MyAnnotationTypeInfoUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
#region Factory Methods
|
|
||||||
private static int _AnnotationTypeInfoUnique = 0;
|
|
||||||
private static int AnnotationTypeInfoUnique
|
|
||||||
{ get { return ++_AnnotationTypeInfoUnique; } }
|
|
||||||
private int _MyAnnotationTypeInfoUnique = AnnotationTypeInfoUnique;
|
|
||||||
public int MyAnnotationTypeInfoUnique // Absolutely Unique ID - Info
|
|
||||||
{ get { return _MyAnnotationTypeInfoUnique; } }
|
|
||||||
protected AnnotationTypeInfo()
|
protected AnnotationTypeInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -220,16 +191,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static int _CountCreated = 0;
|
private static int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
private static int IncrementCountCreated => ++_CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountCreated => _CountCreated;
|
||||||
public static int CountCreated
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
{ get { return _CountCreated; } }
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountNotDisposed
|
~AnnotationTypeInfo()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~AnnotationTypeInfo()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -245,11 +212,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (listAnnotationTypeInfo.Count == 0) // If there are no items left in the list
|
if (listAnnotationTypeInfo.Count == 0) // If there are no items left in the list
|
||||||
_CacheByPrimaryKey.Remove(TypeID.ToString()); // remove the list
|
_CacheByPrimaryKey.Remove(TypeID.ToString()); // remove the list
|
||||||
}
|
}
|
||||||
public virtual AnnotationType Get()
|
public virtual AnnotationType Get() => _Editable = AnnotationType.Get(_TypeID);
|
||||||
{
|
public static void Refresh(AnnotationType tmp)
|
||||||
return _Editable = AnnotationType.Get(_TypeID);
|
|
||||||
}
|
|
||||||
public static void Refresh(AnnotationType tmp)
|
|
||||||
{
|
{
|
||||||
string key = tmp.TypeID.ToString();
|
string key = tmp.TypeID.ToString();
|
||||||
ConvertListToDictionary();
|
ConvertListToDictionary();
|
||||||
@@ -268,8 +232,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static AnnotationTypeInfo Get(int typeID)
|
public static AnnotationTypeInfo Get(int typeID)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a AnnotationType");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AnnotationTypeInfo tmp = GetCachedByPrimaryKey(typeID);
|
AnnotationTypeInfo tmp = GetCachedByPrimaryKey(typeID);
|
||||||
@@ -308,14 +270,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _TypeID;
|
private readonly int _TypeID;
|
||||||
public int TypeID
|
public int TypeID => _TypeID;
|
||||||
{ get { return _TypeID; } }
|
public PKCriteria(int typeID) => _TypeID = typeID;
|
||||||
public PKCriteria(int typeID)
|
}
|
||||||
{
|
|
||||||
_TypeID = typeID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ReadData(SafeDataReader dr)
|
private void ReadData(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.ReadData", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.ReadData", GetHashCode());
|
||||||
@@ -373,10 +331,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("AnnotationTypeInfo.DataPortal_Fetch", ex);
|
throw new DbCslaException("AnnotationTypeInfo.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
AnnotationTypeInfoExtension _AnnotationTypeInfoExtension = new AnnotationTypeInfoExtension();
|
readonly AnnotationTypeInfoExtension _AnnotationTypeInfoExtension = new AnnotationTypeInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class AnnotationTypeInfoExtension : extensionBase { }
|
partial class AnnotationTypeInfoExtension : extensionBase { }
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
@@ -392,10 +350,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is AnnotationTypeInfo)
|
if (destType == typeof(string) && value is AnnotationTypeInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((AnnotationTypeInfo)value).ToString();
|
return info.ToString();
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
namespace VEPROMS.CSLA.Library
|
namespace VEPROMS.CSLA.Library
|
||||||
@@ -27,19 +25,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[TypeConverter(typeof(AnnotationTypeInfoListConverter))]
|
[TypeConverter(typeof(AnnotationTypeInfoListConverter))]
|
||||||
public partial class AnnotationTypeInfoList : ReadOnlyListBase<AnnotationTypeInfoList, AnnotationTypeInfo>, ICustomTypeDescriptor, IDisposable
|
public partial class AnnotationTypeInfoList : ReadOnlyListBase<AnnotationTypeInfoList, AnnotationTypeInfo>, ICustomTypeDescriptor, IDisposable
|
||||||
{
|
{
|
||||||
public static event AnnotationTypeInfoListEvent ListChanged;
|
public new static event AnnotationTypeInfoListEvent ListChanged;
|
||||||
private static void OnListChanged()
|
private static void OnListChanged() => ListChanged?.Invoke();
|
||||||
{
|
#region Log4Net
|
||||||
if (ListChanged != null)
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
ListChanged();
|
#endregion
|
||||||
}
|
#region Business Methods
|
||||||
#region Log4Net
|
internal new IList<AnnotationTypeInfo> Items => base.Items;
|
||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
public void AddEvents()
|
||||||
#endregion
|
|
||||||
#region Business Methods
|
|
||||||
internal new IList<AnnotationTypeInfo> Items
|
|
||||||
{ get { return base.Items; } }
|
|
||||||
public void AddEvents()
|
|
||||||
{
|
{
|
||||||
foreach (AnnotationTypeInfo tmp in this)
|
foreach (AnnotationTypeInfo tmp in this)
|
||||||
{
|
{
|
||||||
@@ -58,16 +51,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static int _CountCreated = 0;
|
private static int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
private static int IncrementCountCreated => ++_CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountCreated => _CountCreated;
|
||||||
public static int CountCreated
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
{ get { return _CountCreated; } }
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountNotDisposed
|
~AnnotationTypeInfoList()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~AnnotationTypeInfoList()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -105,26 +94,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on AnnotationTypeInfoList.Get", ex);
|
throw new DbCslaException("Error on AnnotationTypeInfoList.Get", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset the list of all AnnotationTypeInfo.
|
/// Reset the list of all AnnotationTypeInfo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Reset()
|
public static void Reset() => _AnnotationTypeInfoList = null;
|
||||||
{
|
private AnnotationTypeInfoList()
|
||||||
_AnnotationTypeInfoList = null;
|
|
||||||
}
|
|
||||||
// CSLATODO: Add alternative gets -
|
|
||||||
//public static AnnotationTypeInfoList Get(<criteria>)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// return DataPortal.Fetch<AnnotationTypeInfoList>(new FilteredCriteria(<criteria>));
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// throw new DbCslaException("Error on AnnotationTypeInfoList.Get", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
private AnnotationTypeInfoList()
|
|
||||||
{ /* require use of factory methods */ }
|
{ /* require use of factory methods */ }
|
||||||
#endregion
|
#endregion
|
||||||
#region Data Access Portal
|
#region Data Access Portal
|
||||||
@@ -157,41 +131,30 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
this.RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ICustomTypeDescriptor impl
|
#region ICustomTypeDescriptor impl
|
||||||
public String GetClassName()
|
public String GetClassName() => TypeDescriptor.GetClassName(this, true);
|
||||||
{ return TypeDescriptor.GetClassName(this, true); }
|
public AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true);
|
||||||
public AttributeCollection GetAttributes()
|
public String GetComponentName() => TypeDescriptor.GetComponentName(this, true);
|
||||||
{ return TypeDescriptor.GetAttributes(this, true); }
|
public TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true);
|
||||||
public String GetComponentName()
|
public EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
|
||||||
{ return TypeDescriptor.GetComponentName(this, true); }
|
public PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true);
|
||||||
public TypeConverter GetConverter()
|
public object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true);
|
||||||
{ return TypeDescriptor.GetConverter(this, true); }
|
public EventDescriptorCollection GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(this, attributes, true);
|
||||||
public EventDescriptor GetDefaultEvent()
|
public EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true);
|
||||||
{ return TypeDescriptor.GetDefaultEvent(this, true); }
|
public object GetPropertyOwner(PropertyDescriptor pd) => this;
|
||||||
public PropertyDescriptor GetDefaultProperty()
|
/// <summary>
|
||||||
{ return TypeDescriptor.GetDefaultProperty(this, true); }
|
/// Called to get the properties of this type. Returns properties with certain
|
||||||
public object GetEditor(Type editorBaseType)
|
/// attributes. this restriction is not implemented here.
|
||||||
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
|
/// </summary>
|
||||||
public EventDescriptorCollection GetEvents(Attribute[] attributes)
|
/// <param name="attributes"></param>
|
||||||
{ return TypeDescriptor.GetEvents(this, attributes, true); }
|
/// <returns></returns>
|
||||||
public EventDescriptorCollection GetEvents()
|
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
||||||
{ return TypeDescriptor.GetEvents(this, true); }
|
/// <summary>
|
||||||
public object GetPropertyOwner(PropertyDescriptor pd)
|
/// Called to get the properties of this type.
|
||||||
{ return this; }
|
/// </summary>
|
||||||
/// <summary>
|
/// <returns></returns>
|
||||||
/// Called to get the properties of this type. Returns properties with certain
|
public PropertyDescriptorCollection GetProperties()
|
||||||
/// attributes. this restriction is not implemented here.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="attributes"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
|
|
||||||
{ return GetProperties(); }
|
|
||||||
/// <summary>
|
|
||||||
/// Called to get the properties of this type.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PropertyDescriptorCollection GetProperties()
|
|
||||||
{
|
{
|
||||||
// Create a collection object to hold property descriptors
|
// Create a collection object to hold property descriptors
|
||||||
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
||||||
@@ -213,7 +176,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class AnnotationTypeInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class AnnotationTypeInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private AnnotationTypeInfo Item { get { return (AnnotationTypeInfo)_Item; } }
|
|
||||||
public AnnotationTypeInfoListPropertyDescriptor(AnnotationTypeInfoList collection, int index) : base(collection, index) { ;}
|
public AnnotationTypeInfoListPropertyDescriptor(AnnotationTypeInfoList collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -222,10 +184,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is AnnotationTypeInfoList)
|
if (destType == typeof(string) && value is AnnotationTypeInfoList list)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((AnnotationTypeInfoList)value).Items.Count.ToString() + " AnnotationTypes";
|
return list.Items.Count.ToString() + " AnnotationTypes";
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Csla.Validation;
|
using Csla.Validation;
|
||||||
@@ -57,9 +55,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
ClearRefreshList();
|
ClearRefreshList();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Collection
|
#region Collection
|
||||||
private static List<Assignment> _CacheList = new List<Assignment>();
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
|
private static List<Assignment> _CacheList = new List<Assignment>();
|
||||||
protected static void AddToCache(Assignment assignment)
|
protected static void AddToCache(Assignment assignment)
|
||||||
{
|
{
|
||||||
if (!_CacheList.Contains(assignment)) _CacheList.Add(assignment); // In AddToCache
|
if (!_CacheList.Contains(assignment)) _CacheList.Add(assignment); // In AddToCache
|
||||||
@@ -68,7 +67,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(assignment)) _CacheList.Remove(assignment); // In RemoveFromCache
|
while (_CacheList.Contains(assignment)) _CacheList.Remove(assignment); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
private static Dictionary<string, List<Assignment>> _CacheByPrimaryKey = new Dictionary<string, List<Assignment>>();
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
|
private static Dictionary<string, List<Assignment>> _CacheByPrimaryKey = new Dictionary<string, List<Assignment>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
while (_CacheList.Count > 0) // Move Assignment(s) from temporary _CacheList to _CacheByPrimaryKey
|
while (_CacheList.Count > 0) // Move Assignment(s) from temporary _CacheList to _CacheByPrimaryKey
|
||||||
@@ -93,16 +93,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
#region Business Methods
|
#region Business Methods
|
||||||
private string _ErrorMessage = string.Empty;
|
private string _ErrorMessage = string.Empty;
|
||||||
public string ErrorMessage
|
public string ErrorMessage => _ErrorMessage;
|
||||||
{
|
private static int _nextAID = -1;
|
||||||
get { return _ErrorMessage; }
|
public static int NextAID => _nextAID--;
|
||||||
}
|
private int _AID;
|
||||||
private static int _nextAID = -1;
|
|
||||||
public static int NextAID
|
|
||||||
{
|
|
||||||
get { return _nextAID--; }
|
|
||||||
}
|
|
||||||
private int _AID;
|
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int AID
|
public int AID
|
||||||
{
|
{
|
||||||
@@ -310,40 +304,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (base.IsDirty || list.Contains(this))
|
if (base.IsDirty || list.Contains(this))
|
||||||
return base.IsDirty;
|
return base.IsDirty;
|
||||||
list.Add(this);
|
list.Add(this);
|
||||||
return base.IsDirty || (_MyFolder == null ? false : _MyFolder.IsDirtyList(list)) || (_MyGroup == null ? false : _MyGroup.IsDirtyList(list)) || (_MyRole == null ? false : _MyRole.IsDirtyList(list));
|
return base.IsDirty || (_MyFolder != null && _MyFolder.IsDirtyList(list)) || (_MyGroup != null && _MyGroup.IsDirtyList(list)) || (_MyRole != null && _MyRole.IsDirtyList(list));
|
||||||
}
|
}
|
||||||
public override bool IsValid
|
// CSLATODO: Check Assignment.GetIdValue to assure that the ID returned is unique
|
||||||
{
|
/// <summary>
|
||||||
get { return IsValidList(new List<object>()); }
|
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||||
}
|
/// </summary>
|
||||||
public bool IsValidList(List<object> list)
|
/// <returns>A Unique ID for the current Assignment</returns>
|
||||||
{
|
protected override object GetIdValue() => MyAssignmentUnique; // Absolutely Unique ID
|
||||||
if(list.Contains(this))
|
#endregion
|
||||||
return (IsNew && !IsDirty) ? true : base.IsValid;
|
#region ValidationRules
|
||||||
list.Add(this);
|
[NonSerialized]
|
||||||
return ((IsNew && !IsDirty) ? true : base.IsValid) && (_MyFolder == null ? true : _MyFolder.IsValidList(list)) && (_MyGroup == null ? true : _MyGroup.IsValidList(list)) && (_MyRole == null ? true : _MyRole.IsValidList(list));
|
|
||||||
}
|
|
||||||
// CSLATODO: Replace base Assignment.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current Assignment</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check Assignment.GetIdValue to assure that the ID returned is unique
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A Unique ID for the current Assignment</returns>
|
|
||||||
protected override object GetIdValue()
|
|
||||||
{
|
|
||||||
return MyAssignmentUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
#region ValidationRules
|
|
||||||
[NonSerialized]
|
|
||||||
private bool _CheckingBrokenRules = false;
|
private bool _CheckingBrokenRules = false;
|
||||||
public IVEHasBrokenRules HasBrokenRules
|
public IVEHasBrokenRules HasBrokenRules
|
||||||
{
|
{
|
||||||
@@ -371,8 +342,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
||||||
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
|
if (Equals(hasBrokenRules)) return BrokenRulesCollection;
|
||||||
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
|
return hasBrokenRules?.BrokenRules;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override void AddBusinessRules()
|
protected override void AddBusinessRules()
|
||||||
@@ -389,16 +360,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
ValidationRules.AddRule(
|
ValidationRules.AddRule(
|
||||||
Csla.Validation.CommonRules.StringMaxLength,
|
Csla.Validation.CommonRules.StringMaxLength,
|
||||||
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
|
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
|
||||||
//ValidationRules.AddDependantProperty("x", "y");
|
|
||||||
_AssignmentExtension.AddValidationRules(ValidationRules);
|
_AssignmentExtension.AddValidationRules(ValidationRules);
|
||||||
// CSLATODO: Add other validation rules
|
// CSLATODO: Add other validation rules
|
||||||
}
|
}
|
||||||
protected override void AddInstanceBusinessRules()
|
protected override void AddInstanceBusinessRules() => _AssignmentExtension.AddInstanceValidationRules(ValidationRules);
|
||||||
{
|
private static bool StartDateValid(Assignment target, Csla.Validation.RuleArgs e)
|
||||||
_AssignmentExtension.AddInstanceValidationRules(ValidationRules);
|
|
||||||
// CSLATODO: Add other validation rules
|
|
||||||
}
|
|
||||||
private static bool StartDateValid(Assignment target, Csla.Validation.RuleArgs e)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -451,80 +417,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Sample data comparison validation rule
|
#endregion
|
||||||
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
|
#region Factory Methods
|
||||||
//{
|
public int CurrentEditLevel => EditLevel;
|
||||||
// if (_started > _ended)
|
private static int _AssignmentUnique = 0;
|
||||||
// {
|
protected static int AssignmentUnique => ++_AssignmentUnique;
|
||||||
// e.Description = "Start date can't be after end date";
|
private readonly int _MyAssignmentUnique = AssignmentUnique;
|
||||||
// return false;
|
// Absolutely Unique ID - Editable
|
||||||
// }
|
public int MyAssignmentUnique => _MyAssignmentUnique;
|
||||||
// else
|
|
||||||
// return true;
|
|
||||||
//}
|
|
||||||
#endregion
|
|
||||||
#region Authorization Rules
|
|
||||||
protected override void AddAuthorizationRules()
|
|
||||||
{
|
|
||||||
//CSLATODO: Who can read/write which fields
|
|
||||||
//AuthorizationRules.AllowRead(AID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(GID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(RID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(GID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(RID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(FolderID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
|
|
||||||
_AssignmentExtension.AddAuthorizationRules(AuthorizationRules);
|
|
||||||
}
|
|
||||||
protected override void AddInstanceAuthorizationRules()
|
|
||||||
{
|
|
||||||
//CSLATODO: Who can read/write which fields
|
|
||||||
_AssignmentExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
|
||||||
}
|
|
||||||
public static bool CanAddObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: Can Add Authorization
|
|
||||||
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CanGetObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanGet Authorization
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CanDeleteObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanDelete Authorization
|
|
||||||
//bool result = false;
|
|
||||||
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
|
|
||||||
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
|
|
||||||
//return result;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CanEditObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanEdit Authorization
|
|
||||||
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
#region Factory Methods
|
|
||||||
public int CurrentEditLevel
|
|
||||||
{ get { return EditLevel; } }
|
|
||||||
private static int _AssignmentUnique = 0;
|
|
||||||
protected static int AssignmentUnique
|
|
||||||
{ get { return ++_AssignmentUnique; } }
|
|
||||||
private int _MyAssignmentUnique = AssignmentUnique;
|
|
||||||
public int MyAssignmentUnique // Absolutely Unique ID - Editable
|
|
||||||
{ get { return _MyAssignmentUnique; } }
|
|
||||||
protected Assignment()
|
protected Assignment()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -533,16 +433,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static int _CountCreated = 0;
|
private static int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
private static int IncrementCountCreated => ++_CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountCreated => _CountCreated;
|
||||||
public static int CountCreated
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
{ get { return _CountCreated; } }
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountNotDisposed
|
~Assignment()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~Assignment()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -566,8 +462,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Assignment New()
|
public static Assignment New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Assignment");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<Assignment>();
|
return DataPortal.Create<Assignment>();
|
||||||
@@ -640,8 +534,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Assignment Get(int aid)
|
public static Assignment Get(int aid)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a Assignment");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Assignment tmp = GetCachedByPrimaryKey(aid);
|
Assignment tmp = GetCachedByPrimaryKey(aid);
|
||||||
@@ -667,14 +559,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dr.Read()) return new Assignment(dr);
|
if (dr.Read()) return new Assignment(dr);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
internal Assignment(SafeDataReader dr)
|
internal Assignment(SafeDataReader dr) => ReadData(dr);
|
||||||
|
public static void Delete(int aid)
|
||||||
{
|
{
|
||||||
ReadData(dr);
|
|
||||||
}
|
|
||||||
public static void Delete(int aid)
|
|
||||||
{
|
|
||||||
if (!CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Assignment");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataPortal.Delete(new PKCriteria(aid));
|
DataPortal.Delete(new PKCriteria(aid));
|
||||||
@@ -686,12 +573,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public override Assignment Save()
|
public override Assignment Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Assignment");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Assignment");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a Assignment");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -711,14 +592,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _AID;
|
private readonly int _AID;
|
||||||
public int AID
|
public int AID => _AID;
|
||||||
{ get { return _AID; } }
|
public PKCriteria(int aid) => _AID = aid;
|
||||||
public PKCriteria(int aid)
|
}
|
||||||
{
|
|
||||||
_AID = aid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
|
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
|
||||||
[RunLocal()]
|
[RunLocal()]
|
||||||
private new void DataPortal_Create()
|
private new void DataPortal_Create()
|
||||||
@@ -818,44 +695,51 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
internal void SQLInsert()
|
internal void SQLInsert()
|
||||||
{
|
{
|
||||||
if (!this.IsDirty) return;
|
if (!IsDirty) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_MyFolder != null) _MyFolder.Update();
|
_MyFolder?.Update();
|
||||||
if (_MyGroup != null) _MyGroup.Update();
|
_MyGroup?.Update();
|
||||||
if (_MyRole != null) _MyRole.Update();
|
_MyRole?.Update();
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
using (SqlCommand cm = cn.CreateCommand())
|
{
|
||||||
{
|
using (SqlCommand cm = cn.CreateCommand())
|
||||||
cm.CommandType = CommandType.StoredProcedure;
|
{
|
||||||
cm.CommandTimeout = Database.SQLTimeout;
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
cm.CommandText = "addAssignment";
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandText = "addAssignment";
|
||||||
cm.Parameters.AddWithValue("@GID", GID);
|
// Input All Fields - Except Calculated Columns
|
||||||
cm.Parameters.AddWithValue("@RID", RID);
|
cm.Parameters.AddWithValue("@GID", GID);
|
||||||
cm.Parameters.AddWithValue("@FolderID", FolderID);
|
cm.Parameters.AddWithValue("@RID", RID);
|
||||||
cm.Parameters.AddWithValue("@StartDate", new SmartDate(_StartDate).DBValue);
|
cm.Parameters.AddWithValue("@FolderID", FolderID);
|
||||||
cm.Parameters.AddWithValue("@EndDate", new SmartDate(_EndDate).DBValue);
|
cm.Parameters.AddWithValue("@StartDate", new SmartDate(_StartDate).DBValue);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@EndDate", new SmartDate(_EndDate).DBValue);
|
||||||
cm.Parameters.AddWithValue("@UsrID", _UsrID);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@UsrID", _UsrID);
|
||||||
SqlParameter param_AID = new SqlParameter("@newAID", SqlDbType.Int);
|
// Output Calculated Columns
|
||||||
param_AID.Direction = ParameterDirection.Output;
|
SqlParameter param_AID = new SqlParameter("@newAID", SqlDbType.Int)
|
||||||
cm.Parameters.Add(param_AID);
|
{
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
Direction = ParameterDirection.Output
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
};
|
||||||
cm.Parameters.Add(param_LastChanged);
|
cm.Parameters.Add(param_AID);
|
||||||
// CSLATODO: Define any additional output parameters
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
cm.ExecuteNonQuery();
|
{
|
||||||
// Save all values being returned from the Procedure
|
Direction = ParameterDirection.Output
|
||||||
_AID = (int)cm.Parameters["@newAID"].Value;
|
};
|
||||||
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
cm.Parameters.Add(param_LastChanged);
|
||||||
}
|
// CSLATODO: Define any additional output parameters
|
||||||
MarkOld();
|
cm.ExecuteNonQuery();
|
||||||
// update child objects
|
// Save all values being returned from the Procedure
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.SQLInsert", GetHashCode());
|
_AID = (int)cm.Parameters["@newAID"].Value;
|
||||||
}
|
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||||
catch (Exception ex)
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MarkOld();
|
||||||
|
// update child objects
|
||||||
|
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;
|
_ErrorMessage = ex.Message;
|
||||||
@@ -881,13 +765,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
cm.Parameters.AddWithValue("@EndDate", endDate.DBValue);
|
cm.Parameters.AddWithValue("@EndDate", endDate.DBValue);
|
||||||
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
||||||
cm.Parameters.AddWithValue("@UsrID", usrID);
|
cm.Parameters.AddWithValue("@UsrID", usrID);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_AID = new SqlParameter("@newAID", SqlDbType.Int);
|
SqlParameter param_AID = new SqlParameter("@newAID", SqlDbType.Int)
|
||||||
param_AID.Direction = ParameterDirection.Output;
|
{
|
||||||
cm.Parameters.Add(param_AID);
|
Direction = ParameterDirection.Output
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
};
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
cm.Parameters.Add(param_AID);
|
||||||
cm.Parameters.Add(param_LastChanged);
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
|
{
|
||||||
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
|
cm.Parameters.Add(param_LastChanged);
|
||||||
// CSLATODO: Define any additional output parameters
|
// CSLATODO: Define any additional output parameters
|
||||||
cm.ExecuteNonQuery();
|
cm.ExecuteNonQuery();
|
||||||
// Save all values being returned from the Procedure
|
// Save all values being returned from the Procedure
|
||||||
@@ -930,42 +818,47 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (!IsDirty) return; // If not dirty - nothing to do
|
if (!IsDirty) return; // If not dirty - nothing to do
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.SQLUpdate", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_MyFolder != null) _MyFolder.Update();
|
_MyFolder?.Update();
|
||||||
if (_MyGroup != null) _MyGroup.Update();
|
_MyGroup?.Update();
|
||||||
if (_MyRole != null) _MyRole.Update();
|
_MyRole?.Update();
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
if (base.IsDirty)
|
{
|
||||||
{
|
if (base.IsDirty)
|
||||||
using (SqlCommand cm = cn.CreateCommand())
|
{
|
||||||
{
|
using (SqlCommand cm = cn.CreateCommand())
|
||||||
cm.CommandType = CommandType.StoredProcedure;
|
{
|
||||||
cm.CommandTimeout = Database.SQLTimeout;
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
cm.CommandText = "updateAssignment";
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandText = "updateAssignment";
|
||||||
cm.Parameters.AddWithValue("@AID", _AID);
|
// All Fields including Calculated Fields
|
||||||
cm.Parameters.AddWithValue("@GID", GID);
|
cm.Parameters.AddWithValue("@AID", _AID);
|
||||||
cm.Parameters.AddWithValue("@RID", RID);
|
cm.Parameters.AddWithValue("@GID", GID);
|
||||||
cm.Parameters.AddWithValue("@FolderID", FolderID);
|
cm.Parameters.AddWithValue("@RID", RID);
|
||||||
cm.Parameters.AddWithValue("@StartDate", new SmartDate(_StartDate).DBValue);
|
cm.Parameters.AddWithValue("@FolderID", FolderID);
|
||||||
cm.Parameters.AddWithValue("@EndDate", new SmartDate(_EndDate).DBValue);
|
cm.Parameters.AddWithValue("@StartDate", new SmartDate(_StartDate).DBValue);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@EndDate", new SmartDate(_EndDate).DBValue);
|
||||||
cm.Parameters.AddWithValue("@UsrID", _UsrID);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
|
cm.Parameters.AddWithValue("@UsrID", _UsrID);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
// Output Calculated Columns
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
cm.Parameters.Add(param_LastChanged);
|
{
|
||||||
// CSLATODO: Define any additional output parameters
|
Direction = ParameterDirection.Output
|
||||||
cm.ExecuteNonQuery();
|
};
|
||||||
// Save all values being returned from the Procedure
|
cm.Parameters.Add(param_LastChanged);
|
||||||
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
// CSLATODO: Define any additional output parameters
|
||||||
}
|
cm.ExecuteNonQuery();
|
||||||
}
|
// Save all values being returned from the Procedure
|
||||||
MarkOld();
|
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||||
// use the open connection to update child objects
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
}
|
||||||
|
|
||||||
|
MarkOld();
|
||||||
|
// use the open connection to update child objects
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.SQLUpdate", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("Assignment.SQLUpdate", ex);
|
||||||
_ErrorMessage = ex.Message;
|
_ErrorMessage = ex.Message;
|
||||||
@@ -974,17 +867,20 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
internal void Update()
|
internal void Update()
|
||||||
{
|
{
|
||||||
if (!this.IsDirty) return;
|
if (!IsDirty) return;
|
||||||
if (base.IsDirty)
|
if (base.IsDirty)
|
||||||
{
|
{
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
if (IsNew)
|
{
|
||||||
_LastChanged = Assignment.Add(cn, ref _AID, _MyGroup, _MyRole, _MyFolder, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID);
|
if (IsNew)
|
||||||
else
|
_LastChanged = Assignment.Add(cn, ref _AID, _MyGroup, _MyRole, _MyFolder, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID);
|
||||||
_LastChanged = Assignment.Update(cn, ref _AID, _GID, _RID, _FolderID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged);
|
else
|
||||||
MarkOld();
|
_LastChanged = Assignment.Update(cn, ref _AID, _GID, _RID, _FolderID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
MarkOld();
|
||||||
|
}
|
||||||
|
}
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
public static byte[] Update(SqlConnection cn, ref int aid, int gid, int rid, int folderID, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID, ref byte[] lastChanged)
|
public static byte[] Update(SqlConnection cn, ref int aid, int gid, int rid, int folderID, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID, ref byte[] lastChanged)
|
||||||
{
|
{
|
||||||
@@ -1006,10 +902,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
||||||
cm.Parameters.AddWithValue("@UsrID", usrID);
|
cm.Parameters.AddWithValue("@UsrID", usrID);
|
||||||
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
{
|
||||||
cm.Parameters.Add(param_LastChanged);
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
|
cm.Parameters.Add(param_LastChanged);
|
||||||
// CSLATODO: Define any additional output parameters
|
// CSLATODO: Define any additional output parameters
|
||||||
cm.ExecuteNonQuery();
|
cm.ExecuteNonQuery();
|
||||||
// Save all values being returned from the Procedure
|
// Save all values being returned from the Procedure
|
||||||
@@ -1022,12 +920,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Assignment.Update", ex);
|
throw new DbCslaException("Assignment.Update", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
protected override void DataPortal_DeleteSelf()
|
protected override void DataPortal_DeleteSelf() => DataPortal_Delete(new PKCriteria(_AID));
|
||||||
{
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
DataPortal_Delete(new PKCriteria(_AID));
|
|
||||||
}
|
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
|
||||||
private void DataPortal_Delete(PKCriteria criteria)
|
private void DataPortal_Delete(PKCriteria criteria)
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.DataPortal_Delete", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.DataPortal_Delete", GetHashCode());
|
||||||
@@ -1093,17 +988,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ExistsCommand : CommandBase
|
private class ExistsCommand : CommandBase
|
||||||
{
|
{
|
||||||
private int _AID;
|
private readonly int _AID;
|
||||||
private bool _exists;
|
private bool _exists;
|
||||||
public bool Exists
|
public bool Exists => _exists;
|
||||||
{
|
public ExistsCommand(int aid) => _AID = aid;
|
||||||
get { return _exists; }
|
protected override void DataPortal_Execute()
|
||||||
}
|
|
||||||
public ExistsCommand(int aid)
|
|
||||||
{
|
|
||||||
_AID = aid;
|
|
||||||
}
|
|
||||||
protected override void DataPortal_Execute()
|
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.DataPortal_Execute", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Assignment.DataPortal_Execute", GetHashCode());
|
||||||
try
|
try
|
||||||
@@ -1129,10 +1018,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
AssignmentExtension _AssignmentExtension = new AssignmentExtension();
|
readonly AssignmentExtension _AssignmentExtension = new AssignmentExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class AssignmentExtension : extensionBase
|
partial class AssignmentExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -1140,21 +1029,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
class extensionBase
|
class extensionBase
|
||||||
{
|
{
|
||||||
// Default Values
|
// Default Values
|
||||||
public virtual string DefaultStartDate
|
public virtual string DefaultStartDate => DateTime.Now.ToShortDateString();
|
||||||
{
|
public virtual DateTime DefaultDTS => DateTime.Now;
|
||||||
get { return DateTime.Now.ToShortDateString(); }
|
public virtual string DefaultUsrID => Volian.Base.Library.VlnSettings.UserID;
|
||||||
}
|
// Authorization Rules
|
||||||
public virtual DateTime DefaultDTS
|
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
||||||
{
|
|
||||||
get { return DateTime.Now; }
|
|
||||||
}
|
|
||||||
public virtual string DefaultUsrID
|
|
||||||
{
|
|
||||||
get { return Volian.Base.Library.VlnSettings.UserID; }
|
|
||||||
}
|
|
||||||
// Authorization Rules
|
|
||||||
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
{
|
{
|
||||||
// Needs to be overriden to add new authorization rules
|
// Needs to be overriden to add new authorization rules
|
||||||
}
|
}
|
||||||
@@ -1181,61 +1061,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is Assignment)
|
if (destType == typeof(string) && value is Assignment assignmnt)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((Assignment)value).ToString();
|
return assignmnt.ToString();
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
} // Namespace
|
} // Namespace
|
||||||
|
|
||||||
|
|
||||||
//// The following is a sample Extension File. You can use it to create AssignmentExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class Assignment
|
|
||||||
// {
|
|
||||||
// partial class AssignmentExtension : extensionBase
|
|
||||||
// {
|
|
||||||
// // CSLATODO: Override automatic defaults
|
|
||||||
// public virtual SmartDate DefaultStartDate
|
|
||||||
// {
|
|
||||||
// get { return DateTime.Now.ToShortDateString(); }
|
|
||||||
// }
|
|
||||||
// public virtual DateTime DefaultDTS
|
|
||||||
// {
|
|
||||||
// get { return DateTime.Now; }
|
|
||||||
// }
|
|
||||||
// public virtual string DefaultUsrID
|
|
||||||
// {
|
|
||||||
// get { return Environment.UserName.ToUpper(); }
|
|
||||||
// }
|
|
||||||
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddRule(
|
|
||||||
// Csla.Validation.CommonRules.StringMaxLength,
|
|
||||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddInstanceRule(/* Instance Validation Rule */);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
namespace VEPROMS.CSLA.Library
|
namespace VEPROMS.CSLA.Library
|
||||||
@@ -28,14 +26,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public partial class AssignmentInfo : ReadOnlyBase<AssignmentInfo>, IDisposable
|
public partial class AssignmentInfo : ReadOnlyBase<AssignmentInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public event AssignmentInfoEvent Changed;
|
public event AssignmentInfoEvent Changed;
|
||||||
private void OnChange()
|
private void OnChange() => Changed?.Invoke(this);
|
||||||
{
|
|
||||||
if (Changed != null) Changed(this);
|
|
||||||
}
|
|
||||||
#region Log4Net
|
#region Log4Net
|
||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
#endregion
|
#endregion
|
||||||
#region Collection
|
#region Collection
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static List<AssignmentInfo> _CacheList = new List<AssignmentInfo>();
|
private static List<AssignmentInfo> _CacheList = new List<AssignmentInfo>();
|
||||||
protected static void AddToCache(AssignmentInfo assignmentInfo)
|
protected static void AddToCache(AssignmentInfo assignmentInfo)
|
||||||
{
|
{
|
||||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(assignmentInfo)) _CacheList.Remove(assignmentInfo); // In RemoveFromCache
|
while (_CacheList.Contains(assignmentInfo)) _CacheList.Remove(assignmentInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<AssignmentInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AssignmentInfo>>();
|
private static Dictionary<string, List<AssignmentInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AssignmentInfo>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -74,21 +71,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
#region Business Methods
|
#region Business Methods
|
||||||
private string _ErrorMessage = string.Empty;
|
private string _ErrorMessage = string.Empty;
|
||||||
public string ErrorMessage
|
public string ErrorMessage => _ErrorMessage;
|
||||||
{
|
|
||||||
get { return _ErrorMessage; }
|
|
||||||
}
|
|
||||||
protected Assignment _Editable;
|
protected Assignment _Editable;
|
||||||
private IVEHasBrokenRules HasBrokenRules
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
IVEHasBrokenRules hasBrokenRules = null;
|
|
||||||
if (_Editable != null)
|
|
||||||
hasBrokenRules = _Editable.HasBrokenRules;
|
|
||||||
return hasBrokenRules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private int _AID;
|
private int _AID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int AID
|
public int AID
|
||||||
@@ -195,15 +179,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _UsrID;
|
return _UsrID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base AssignmentInfo.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current AssignmentInfo</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check AssignmentInfo.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check AssignmentInfo.GetIdValue to assure that the ID returned is unique
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||||
@@ -216,11 +191,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _AssignmentInfoUnique = 0;
|
private static int _AssignmentInfoUnique = 0;
|
||||||
private static int AssignmentInfoUnique
|
private static int AssignmentInfoUnique => ++_AssignmentInfoUnique;
|
||||||
{ get { return ++_AssignmentInfoUnique; } }
|
private readonly int _MyAssignmentInfoUnique = AssignmentInfoUnique;
|
||||||
private int _MyAssignmentInfoUnique = AssignmentInfoUnique;
|
// Absolutely Unique ID - Info
|
||||||
public int MyAssignmentInfoUnique // Absolutely Unique ID - Info
|
public int MyAssignmentInfoUnique => _MyAssignmentInfoUnique;
|
||||||
{ get { return _MyAssignmentInfoUnique; } }
|
|
||||||
protected AssignmentInfo()
|
protected AssignmentInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -229,15 +203,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static int _CountCreated = 0;
|
private static int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
private static int IncrementCountCreated => ++_CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountCreated => _CountCreated;
|
||||||
public static int CountCreated
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
{ get { return _CountCreated; } }
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountNotDisposed
|
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~AssignmentInfo()
|
~AssignmentInfo()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -254,10 +224,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (listAssignmentInfo.Count == 0) // If there are no items left in the list
|
if (listAssignmentInfo.Count == 0) // If there are no items left in the list
|
||||||
_CacheByPrimaryKey.Remove(AID.ToString()); // remove the list
|
_CacheByPrimaryKey.Remove(AID.ToString()); // remove the list
|
||||||
}
|
}
|
||||||
public virtual Assignment Get()
|
public virtual Assignment Get() => _Editable = Assignment.Get(_AID);
|
||||||
{
|
|
||||||
return _Editable = Assignment.Get(_AID);
|
|
||||||
}
|
|
||||||
public static void Refresh(Assignment tmp)
|
public static void Refresh(Assignment tmp)
|
||||||
{
|
{
|
||||||
string key = tmp.AID.ToString();
|
string key = tmp.AID.ToString();
|
||||||
@@ -270,25 +237,25 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_GID != tmp.GID)
|
if (_GID != tmp.GID)
|
||||||
{
|
{
|
||||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for old value
|
MyGroup?.RefreshGroupAssignments(); // Update List for old value
|
||||||
_GID = tmp.GID; // Update the value
|
_GID = tmp.GID; // Update the value
|
||||||
}
|
}
|
||||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
|
MyGroup?.RefreshGroupAssignments(); // Update List for new value
|
||||||
if (_RID != tmp.RID)
|
if (_RID != tmp.RID)
|
||||||
{
|
{
|
||||||
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for old value
|
MyRole?.RefreshRoleAssignments(); // Update List for old value
|
||||||
_RID = tmp.RID; // Update the value
|
_RID = tmp.RID; // Update the value
|
||||||
}
|
}
|
||||||
_MyRole = null; // Reset list so that the next line gets a new list
|
_MyRole = null; // Reset list so that the next line gets a new list
|
||||||
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
|
MyRole?.RefreshRoleAssignments(); // Update List for new value
|
||||||
if (_FolderID != tmp.FolderID)
|
if (_FolderID != tmp.FolderID)
|
||||||
{
|
{
|
||||||
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for old value
|
MyFolder?.RefreshFolderAssignments(); // Update List for old value
|
||||||
_FolderID = tmp.FolderID; // Update the value
|
_FolderID = tmp.FolderID; // Update the value
|
||||||
}
|
}
|
||||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||||
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for new value
|
MyFolder?.RefreshFolderAssignments(); // Update List for new value
|
||||||
_StartDate = tmp.StartDate;
|
_StartDate = tmp.StartDate;
|
||||||
_EndDate = tmp.EndDate;
|
_EndDate = tmp.EndDate;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
@@ -308,18 +275,18 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_GID != tmp.GID)
|
if (_GID != tmp.GID)
|
||||||
{
|
{
|
||||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for old value
|
MyGroup?.RefreshGroupAssignments(); // Update List for old value
|
||||||
_GID = tmp.GID; // Update the value
|
_GID = tmp.GID; // Update the value
|
||||||
}
|
}
|
||||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
|
MyGroup?.RefreshGroupAssignments(); // Update List for new value
|
||||||
if (_RID != tmp.RID)
|
if (_RID != tmp.RID)
|
||||||
{
|
{
|
||||||
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for old value
|
MyRole?.RefreshRoleAssignments(); // Update List for old value
|
||||||
_RID = tmp.RID; // Update the value
|
_RID = tmp.RID; // Update the value
|
||||||
}
|
}
|
||||||
_MyRole = null; // Reset list so that the next line gets a new list
|
_MyRole = null; // Reset list so that the next line gets a new list
|
||||||
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
|
MyRole?.RefreshRoleAssignments(); // Update List for new value
|
||||||
_StartDate = tmp.StartDate;
|
_StartDate = tmp.StartDate;
|
||||||
_EndDate = tmp.EndDate;
|
_EndDate = tmp.EndDate;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
@@ -339,18 +306,18 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_RID != tmp.RID)
|
if (_RID != tmp.RID)
|
||||||
{
|
{
|
||||||
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for old value
|
MyRole?.RefreshRoleAssignments(); // Update List for old value
|
||||||
_RID = tmp.RID; // Update the value
|
_RID = tmp.RID; // Update the value
|
||||||
}
|
}
|
||||||
_MyRole = null; // Reset list so that the next line gets a new list
|
_MyRole = null; // Reset list so that the next line gets a new list
|
||||||
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
|
MyRole?.RefreshRoleAssignments(); // Update List for new value
|
||||||
if (_FolderID != tmp.FolderID)
|
if (_FolderID != tmp.FolderID)
|
||||||
{
|
{
|
||||||
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for old value
|
MyFolder?.RefreshFolderAssignments(); // Update List for old value
|
||||||
_FolderID = tmp.FolderID; // Update the value
|
_FolderID = tmp.FolderID; // Update the value
|
||||||
}
|
}
|
||||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||||
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for new value
|
MyFolder?.RefreshFolderAssignments(); // Update List for new value
|
||||||
_StartDate = tmp.StartDate;
|
_StartDate = tmp.StartDate;
|
||||||
_EndDate = tmp.EndDate;
|
_EndDate = tmp.EndDate;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
@@ -370,18 +337,18 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_GID != tmp.GID)
|
if (_GID != tmp.GID)
|
||||||
{
|
{
|
||||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for old value
|
MyGroup?.RefreshGroupAssignments(); // Update List for old value
|
||||||
_GID = tmp.GID; // Update the value
|
_GID = tmp.GID; // Update the value
|
||||||
}
|
}
|
||||||
_MyGroup = null; // Reset list so that the next line gets a new list
|
_MyGroup = null; // Reset list so that the next line gets a new list
|
||||||
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
|
MyGroup?.RefreshGroupAssignments(); // Update List for new value
|
||||||
if (_FolderID != tmp.FolderID)
|
if (_FolderID != tmp.FolderID)
|
||||||
{
|
{
|
||||||
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for old value
|
MyFolder?.RefreshFolderAssignments(); // Update List for old value
|
||||||
_FolderID = tmp.FolderID; // Update the value
|
_FolderID = tmp.FolderID; // Update the value
|
||||||
}
|
}
|
||||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||||
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for new value
|
MyFolder?.RefreshFolderAssignments(); // Update List for new value
|
||||||
_StartDate = tmp.StartDate;
|
_StartDate = tmp.StartDate;
|
||||||
_EndDate = tmp.EndDate;
|
_EndDate = tmp.EndDate;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
@@ -391,8 +358,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static AssignmentInfo Get(int aid)
|
public static AssignmentInfo Get(int aid)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a Assignment");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AssignmentInfo tmp = GetCachedByPrimaryKey(aid);
|
AssignmentInfo tmp = GetCachedByPrimaryKey(aid);
|
||||||
@@ -431,13 +396,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _AID;
|
private readonly int _AID;
|
||||||
public int AID
|
public int AID => _AID;
|
||||||
{ get { return _AID; } }
|
public PKCriteria(int aid) => _AID = aid;
|
||||||
public PKCriteria(int aid)
|
|
||||||
{
|
|
||||||
_AID = aid;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void ReadData(SafeDataReader dr)
|
private void ReadData(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
@@ -499,7 +460,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
AssignmentInfoExtension _AssignmentInfoExtension = new AssignmentInfoExtension();
|
readonly AssignmentInfoExtension _AssignmentInfoExtension = new AssignmentInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class AssignmentInfoExtension : extensionBase { }
|
partial class AssignmentInfoExtension : extensionBase { }
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
@@ -515,10 +476,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is AssignmentInfo)
|
if (destType == typeof(string) && value is AssignmentInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((AssignmentInfo)value).ToString();
|
return info.ToString();
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
namespace VEPROMS.CSLA.Library
|
namespace VEPROMS.CSLA.Library
|
||||||
@@ -28,11 +26,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
#region Log4Net
|
#region Log4Net
|
||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
#endregion
|
#endregion
|
||||||
#region Business Methods
|
#region Business Methods
|
||||||
internal new IList<AssignmentInfo> Items
|
internal new IList<AssignmentInfo> Items => base.Items;
|
||||||
{ get { return base.Items; } }
|
public void AddEvents()
|
||||||
public void AddEvents()
|
|
||||||
{
|
{
|
||||||
foreach (AssignmentInfo tmp in this)
|
foreach (AssignmentInfo tmp in this)
|
||||||
{
|
{
|
||||||
@@ -51,16 +48,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static int _CountCreated = 0;
|
private static int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
private static int IncrementCountCreated => ++_CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountCreated => _CountCreated;
|
||||||
public static int CountCreated
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
{ get { return _CountCreated; } }
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountNotDisposed
|
~AssignmentInfoList()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~AssignmentInfoList()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -97,25 +90,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on AssignmentInfoList.Get", ex);
|
throw new DbCslaException("Error on AssignmentInfoList.Get", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Reset the list of all AssignmentInfo.
|
|
||||||
/// </summary>
|
|
||||||
public static void Reset()
|
|
||||||
{
|
|
||||||
_AssignmentInfoList = null;
|
|
||||||
}
|
|
||||||
// CSLATODO: Add alternative gets -
|
|
||||||
//public static AssignmentInfoList Get(<criteria>)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// return DataPortal.Fetch<AssignmentInfoList>(new FilteredCriteria(<criteria>));
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// throw new DbCslaException("Error on AssignmentInfoList.Get", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
public static AssignmentInfoList GetByFolderID(int folderID)
|
public static AssignmentInfoList GetByFolderID(int folderID)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -194,11 +168,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class FolderIDCriteria
|
private class FolderIDCriteria
|
||||||
{
|
{
|
||||||
public FolderIDCriteria(int folderID)
|
public FolderIDCriteria(int folderID) => _FolderID = folderID;
|
||||||
{
|
private int _FolderID;
|
||||||
_FolderID = folderID;
|
|
||||||
}
|
|
||||||
private int _FolderID;
|
|
||||||
public int FolderID
|
public int FolderID
|
||||||
{
|
{
|
||||||
get { return _FolderID; }
|
get { return _FolderID; }
|
||||||
@@ -238,11 +209,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class GIDCriteria
|
private class GIDCriteria
|
||||||
{
|
{
|
||||||
public GIDCriteria(int gid)
|
public GIDCriteria(int gid) => _GID = gid;
|
||||||
{
|
private int _GID;
|
||||||
_GID = gid;
|
|
||||||
}
|
|
||||||
private int _GID;
|
|
||||||
public int GID
|
public int GID
|
||||||
{
|
{
|
||||||
get { return _GID; }
|
get { return _GID; }
|
||||||
@@ -282,11 +250,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class RIDCriteria
|
private class RIDCriteria
|
||||||
{
|
{
|
||||||
public RIDCriteria(int rid)
|
public RIDCriteria(int rid) => _RID = rid;
|
||||||
{
|
private int _RID;
|
||||||
_RID = rid;
|
|
||||||
}
|
|
||||||
private int _RID;
|
|
||||||
public int RID
|
public int RID
|
||||||
{
|
{
|
||||||
get { return _RID; }
|
get { return _RID; }
|
||||||
@@ -323,41 +288,30 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
this.RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ICustomTypeDescriptor impl
|
#region ICustomTypeDescriptor impl
|
||||||
public String GetClassName()
|
public String GetClassName() => TypeDescriptor.GetClassName(this, true);
|
||||||
{ return TypeDescriptor.GetClassName(this, true); }
|
public AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true);
|
||||||
public AttributeCollection GetAttributes()
|
public String GetComponentName() => TypeDescriptor.GetComponentName(this, true);
|
||||||
{ return TypeDescriptor.GetAttributes(this, true); }
|
public TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true);
|
||||||
public String GetComponentName()
|
public EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
|
||||||
{ return TypeDescriptor.GetComponentName(this, true); }
|
public PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true);
|
||||||
public TypeConverter GetConverter()
|
public object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true);
|
||||||
{ return TypeDescriptor.GetConverter(this, true); }
|
public EventDescriptorCollection GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(this, attributes, true);
|
||||||
public EventDescriptor GetDefaultEvent()
|
public EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true);
|
||||||
{ return TypeDescriptor.GetDefaultEvent(this, true); }
|
public object GetPropertyOwner(PropertyDescriptor pd) => this;
|
||||||
public PropertyDescriptor GetDefaultProperty()
|
/// <summary>
|
||||||
{ return TypeDescriptor.GetDefaultProperty(this, true); }
|
/// Called to get the properties of this type. Returns properties with certain
|
||||||
public object GetEditor(Type editorBaseType)
|
/// attributes. this restriction is not implemented here.
|
||||||
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
|
/// </summary>
|
||||||
public EventDescriptorCollection GetEvents(Attribute[] attributes)
|
/// <param name="attributes"></param>
|
||||||
{ return TypeDescriptor.GetEvents(this, attributes, true); }
|
/// <returns></returns>
|
||||||
public EventDescriptorCollection GetEvents()
|
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
||||||
{ return TypeDescriptor.GetEvents(this, true); }
|
/// <summary>
|
||||||
public object GetPropertyOwner(PropertyDescriptor pd)
|
/// Called to get the properties of this type.
|
||||||
{ return this; }
|
/// </summary>
|
||||||
/// <summary>
|
/// <returns></returns>
|
||||||
/// Called to get the properties of this type. Returns properties with certain
|
public PropertyDescriptorCollection GetProperties()
|
||||||
/// attributes. this restriction is not implemented here.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="attributes"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
|
|
||||||
{ return GetProperties(); }
|
|
||||||
/// <summary>
|
|
||||||
/// Called to get the properties of this type.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PropertyDescriptorCollection GetProperties()
|
|
||||||
{
|
{
|
||||||
// Create a collection object to hold property descriptors
|
// Create a collection object to hold property descriptors
|
||||||
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
||||||
@@ -379,7 +333,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class AssignmentInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class AssignmentInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private AssignmentInfo Item { get { return (AssignmentInfo)_Item; } }
|
|
||||||
public AssignmentInfoListPropertyDescriptor(AssignmentInfoList collection, int index) : base(collection, index) { ;}
|
public AssignmentInfoListPropertyDescriptor(AssignmentInfoList collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -388,10 +341,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is AssignmentInfoList)
|
if (destType == typeof(string) && value is AssignmentInfoList list)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((AssignmentInfoList)value).Items.Count.ToString() + " Assignments";
|
return $"{list.Items.Count} Assignments";
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Csla.Validation;
|
using Csla.Validation;
|
||||||
@@ -37,10 +35,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (IsDirty)
|
if (IsDirty)
|
||||||
refreshAssociations.Add(this);
|
refreshAssociations.Add(this);
|
||||||
}
|
}
|
||||||
private void ClearRefreshList()
|
private void ClearRefreshList() => _RefreshAssociations = new List<Association>();
|
||||||
{
|
|
||||||
_RefreshAssociations = new List<Association>();
|
|
||||||
}
|
|
||||||
private void BuildRefreshList()
|
private void BuildRefreshList()
|
||||||
{
|
{
|
||||||
ClearRefreshList();
|
ClearRefreshList();
|
||||||
@@ -58,6 +53,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Collection
|
#region Collection
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static List<Association> _CacheList = new List<Association>();
|
private static List<Association> _CacheList = new List<Association>();
|
||||||
protected static void AddToCache(Association association)
|
protected static void AddToCache(Association association)
|
||||||
{
|
{
|
||||||
@@ -67,7 +63,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(association)) _CacheList.Remove(association); // In RemoveFromCache
|
while (_CacheList.Contains(association)) _CacheList.Remove(association); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<Association>> _CacheByPrimaryKey = new Dictionary<string, List<Association>>();
|
private static Dictionary<string, List<Association>> _CacheByPrimaryKey = new Dictionary<string, List<Association>>();
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<Association>> _CacheByVersionID_ROFstID = new Dictionary<string, List<Association>>();
|
private static Dictionary<string, List<Association>> _CacheByVersionID_ROFstID = new Dictionary<string, List<Association>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -102,15 +100,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
#region Business Methods
|
#region Business Methods
|
||||||
private string _ErrorMessage = string.Empty;
|
private string _ErrorMessage = string.Empty;
|
||||||
public string ErrorMessage
|
public string ErrorMessage => _ErrorMessage;
|
||||||
{
|
|
||||||
get { return _ErrorMessage; }
|
|
||||||
}
|
|
||||||
private static int _nextAssociationID = -1;
|
private static int _nextAssociationID = -1;
|
||||||
public static int NextAssociationID
|
public static int NextAssociationID => _nextAssociationID--;
|
||||||
{
|
|
||||||
get { return _nextAssociationID--; }
|
|
||||||
}
|
|
||||||
private int _AssociationID;
|
private int _AssociationID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int AssociationID
|
public int AssociationID
|
||||||
@@ -254,37 +246,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (base.IsDirty || list.Contains(this))
|
if (base.IsDirty || list.Contains(this))
|
||||||
return base.IsDirty;
|
return base.IsDirty;
|
||||||
list.Add(this);
|
list.Add(this);
|
||||||
return base.IsDirty || (_MyDocVersion == null ? false : _MyDocVersion.IsDirtyList(list)) || (_MyROFst == null ? false : _MyROFst.IsDirtyList(list));
|
return base.IsDirty || (_MyDocVersion != null && _MyDocVersion.IsDirtyList(list)) || (_MyROFst != null && _MyROFst.IsDirtyList(list));
|
||||||
}
|
}
|
||||||
public override bool IsValid
|
|
||||||
{
|
|
||||||
get { return IsValidList(new List<object>()); }
|
|
||||||
}
|
|
||||||
public bool IsValidList(List<object> list)
|
|
||||||
{
|
|
||||||
if (list.Contains(this))
|
|
||||||
return (IsNew && !IsDirty) ? true : base.IsValid;
|
|
||||||
list.Add(this);
|
|
||||||
return ((IsNew && !IsDirty) ? true : base.IsValid) && (_MyDocVersion == null ? true : _MyDocVersion.IsValidList(list)) && (_MyROFst == null ? true : _MyROFst.IsValidList(list));
|
|
||||||
}
|
|
||||||
// CSLATODO: Replace base Association.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current Association</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check Association.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check Association.GetIdValue to assure that the ID returned is unique
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A Unique ID for the current Association</returns>
|
/// <returns>A Unique ID for the current Association</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyAssociationUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyAssociationUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
@@ -314,8 +283,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
||||||
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
|
if (Equals(hasBrokenRules)) return BrokenRulesCollection;
|
||||||
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
|
return (hasBrokenRules?.BrokenRules);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override void AddBusinessRules()
|
protected override void AddBusinessRules()
|
||||||
@@ -330,15 +299,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
ValidationRules.AddRule(
|
ValidationRules.AddRule(
|
||||||
Csla.Validation.CommonRules.StringMaxLength,
|
Csla.Validation.CommonRules.StringMaxLength,
|
||||||
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
|
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
|
||||||
//ValidationRules.AddDependantProperty("x", "y");
|
|
||||||
_AssociationExtension.AddValidationRules(ValidationRules);
|
_AssociationExtension.AddValidationRules(ValidationRules);
|
||||||
// CSLATODO: Add other validation rules
|
// CSLATODO: Add other validation rules
|
||||||
}
|
}
|
||||||
protected override void AddInstanceBusinessRules()
|
protected override void AddInstanceBusinessRules() => _AssociationExtension.AddInstanceValidationRules(ValidationRules);
|
||||||
{
|
|
||||||
_AssociationExtension.AddInstanceValidationRules(ValidationRules);
|
|
||||||
// CSLATODO: Add other validation rules
|
|
||||||
}
|
|
||||||
private static bool MyDocVersionRequired(Association target, Csla.Validation.RuleArgs e)
|
private static bool MyDocVersionRequired(Association target, Csla.Validation.RuleArgs e)
|
||||||
{
|
{
|
||||||
if (target._VersionID == 0 && target._MyDocVersion == null) // Required field missing
|
if (target._VersionID == 0 && target._MyDocVersion == null) // Required field missing
|
||||||
@@ -357,76 +321,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Sample data comparison validation rule
|
|
||||||
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
|
|
||||||
//{
|
|
||||||
// if (_started > _ended)
|
|
||||||
// {
|
|
||||||
// e.Description = "Start date can't be after end date";
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// return true;
|
|
||||||
//}
|
|
||||||
#endregion
|
|
||||||
#region Authorization Rules
|
|
||||||
protected override void AddAuthorizationRules()
|
|
||||||
{
|
|
||||||
//CSLATODO: Who can read/write which fields
|
|
||||||
//AuthorizationRules.AllowRead(AssociationID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(VersionID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ROFstID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(VersionID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ROFstID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
|
||||||
_AssociationExtension.AddAuthorizationRules(AuthorizationRules);
|
|
||||||
}
|
|
||||||
protected override void AddInstanceAuthorizationRules()
|
|
||||||
{
|
|
||||||
//CSLATODO: Who can read/write which fields
|
|
||||||
_AssociationExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
|
||||||
}
|
|
||||||
public static bool CanAddObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: Can Add Authorization
|
|
||||||
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CanGetObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanGet Authorization
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CanDeleteObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanDelete Authorization
|
|
||||||
//bool result = false;
|
|
||||||
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
|
|
||||||
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
|
|
||||||
//return result;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CanEditObject()
|
|
||||||
{
|
|
||||||
// CSLATODO: CanEdit Authorization
|
|
||||||
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
public int CurrentEditLevel
|
public int CurrentEditLevel => EditLevel;
|
||||||
{ get { return EditLevel; } }
|
|
||||||
private static int _AssociationUnique = 0;
|
private static int _AssociationUnique = 0;
|
||||||
protected static int AssociationUnique
|
protected static int AssociationUnique => ++_AssociationUnique;
|
||||||
{ get { return ++_AssociationUnique; } }
|
private readonly int _MyAssociationUnique = AssociationUnique;
|
||||||
private int _MyAssociationUnique = AssociationUnique;
|
// Absolutely Unique ID - Editable
|
||||||
public int MyAssociationUnique // Absolutely Unique ID - Editable
|
public int MyAssociationUnique => _MyAssociationUnique;
|
||||||
{ get { return _MyAssociationUnique; } }
|
|
||||||
protected Association()
|
protected Association()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -435,15 +337,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static int _CountCreated = 0;
|
private static int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
private static int IncrementCountCreated => ++_CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountCreated => _CountCreated;
|
||||||
public static int CountCreated
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
{ get { return _CountCreated; } }
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountNotDisposed
|
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~Association()
|
~Association()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -480,8 +378,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Association New()
|
public static Association New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Association");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<Association>();
|
return DataPortal.Create<Association>();
|
||||||
@@ -519,7 +415,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
tmp._ErrorMessage = "Failed Validation:";
|
tmp._ErrorMessage = "Failed Validation:";
|
||||||
foreach (Csla.Validation.BrokenRule br in brc)
|
foreach (Csla.Validation.BrokenRule br in brc)
|
||||||
{
|
{
|
||||||
tmp._ErrorMessage += "\r\n\tFailure: " + br.RuleName;
|
tmp._ErrorMessage += $"\r\n\tFailure: {br.RuleName}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
@@ -550,8 +446,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Association Get(int associationID)
|
public static Association Get(int associationID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a Association");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Association tmp = GetCachedByPrimaryKey(associationID);
|
Association tmp = GetCachedByPrimaryKey(associationID);
|
||||||
@@ -574,8 +468,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Association GetByVersionID_ROFstID(int versionID, int rOFstID)
|
public static Association GetByVersionID_ROFstID(int versionID, int rOFstID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a Association");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Association tmp = GetCachedByVersionID_ROFstID(versionID, rOFstID);
|
Association tmp = GetCachedByVersionID_ROFstID(versionID, rOFstID);
|
||||||
@@ -601,14 +493,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dr.Read()) return new Association(dr);
|
if (dr.Read()) return new Association(dr);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
internal Association(SafeDataReader dr)
|
internal Association(SafeDataReader dr) => ReadData(dr);
|
||||||
{
|
|
||||||
ReadData(dr);
|
|
||||||
}
|
|
||||||
public static void Delete(int associationID)
|
public static void Delete(int associationID)
|
||||||
{
|
{
|
||||||
if (!CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Association");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataPortal.Delete(new PKCriteria(associationID));
|
DataPortal.Delete(new PKCriteria(associationID));
|
||||||
@@ -620,12 +507,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public override Association Save()
|
public override Association Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Association");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Association");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a Association");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -645,23 +526,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _AssociationID;
|
private readonly int _AssociationID;
|
||||||
public int AssociationID
|
public int AssociationID => _AssociationID;
|
||||||
{ get { return _AssociationID; } }
|
public PKCriteria(int associationID) => _AssociationID = associationID;
|
||||||
public PKCriteria(int associationID)
|
|
||||||
{
|
|
||||||
_AssociationID = associationID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class VersionID_ROFstIDCriteria
|
private class VersionID_ROFstIDCriteria
|
||||||
{
|
{
|
||||||
private int _VersionID;
|
private readonly int _VersionID;
|
||||||
public int VersionID
|
public int VersionID => _VersionID;
|
||||||
{ get { return _VersionID; } }
|
private readonly int _ROFstID;
|
||||||
private int _ROFstID;
|
public int ROFstID => _ROFstID;
|
||||||
public int ROFstID
|
|
||||||
{ get { return _ROFstID; } }
|
|
||||||
public VersionID_ROFstIDCriteria(int versionID, int rOFstID)
|
public VersionID_ROFstIDCriteria(int versionID, int rOFstID)
|
||||||
{
|
{
|
||||||
_VersionID = versionID;
|
_VersionID = versionID;
|
||||||
@@ -801,36 +676,43 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
internal void SQLInsert()
|
internal void SQLInsert()
|
||||||
{
|
{
|
||||||
if (!this.IsDirty) return;
|
if (!IsDirty) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_MyDocVersion != null) _MyDocVersion.Update();
|
_MyDocVersion?.Update();
|
||||||
if (_MyROFst != null) _MyROFst.Update();
|
_MyROFst?.Update();
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
using (SqlCommand cm = cn.CreateCommand())
|
|
||||||
{
|
{
|
||||||
cm.CommandType = CommandType.StoredProcedure;
|
using (SqlCommand cm = cn.CreateCommand())
|
||||||
cm.CommandTimeout = Database.SQLTimeout;
|
{
|
||||||
cm.CommandText = "addAssociation";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@VersionID", VersionID);
|
cm.CommandText = "addAssociation";
|
||||||
cm.Parameters.AddWithValue("@ROFstID", ROFstID);
|
// Input All Fields - Except Calculated Columns
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@VersionID", VersionID);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@ROFstID", ROFstID);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
// Output Calculated Columns
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
SqlParameter param_AssociationID = new SqlParameter("@newAssociationID", SqlDbType.Int);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
param_AssociationID.Direction = ParameterDirection.Output;
|
// Output Calculated Columns
|
||||||
cm.Parameters.Add(param_AssociationID);
|
SqlParameter param_AssociationID = new SqlParameter("@newAssociationID", SqlDbType.Int)
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
{
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
Direction = ParameterDirection.Output
|
||||||
cm.Parameters.Add(param_LastChanged);
|
};
|
||||||
// CSLATODO: Define any additional output parameters
|
cm.Parameters.Add(param_AssociationID);
|
||||||
cm.ExecuteNonQuery();
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
// Save all values being returned from the Procedure
|
{
|
||||||
_AssociationID = (int)cm.Parameters["@newAssociationID"].Value;
|
Direction = ParameterDirection.Output
|
||||||
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
};
|
||||||
|
cm.Parameters.Add(param_LastChanged);
|
||||||
|
// CSLATODO: Define any additional output parameters
|
||||||
|
cm.ExecuteNonQuery();
|
||||||
|
// Save all values being returned from the Procedure
|
||||||
|
_AssociationID = (int)cm.Parameters["@newAssociationID"].Value;
|
||||||
|
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
// update child objects
|
// update child objects
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Association.SQLInsert", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Association.SQLInsert", GetHashCode());
|
||||||
@@ -860,11 +742,15 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
||||||
cm.Parameters.AddWithValue("@UserID", userID);
|
cm.Parameters.AddWithValue("@UserID", userID);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_AssociationID = new SqlParameter("@newAssociationID", SqlDbType.Int);
|
SqlParameter param_AssociationID = new SqlParameter("@newAssociationID", SqlDbType.Int)
|
||||||
param_AssociationID.Direction = ParameterDirection.Output;
|
{
|
||||||
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
cm.Parameters.Add(param_AssociationID);
|
cm.Parameters.Add(param_AssociationID);
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
{
|
||||||
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
cm.Parameters.Add(param_LastChanged);
|
cm.Parameters.Add(param_LastChanged);
|
||||||
// CSLATODO: Define any additional output parameters
|
// CSLATODO: Define any additional output parameters
|
||||||
cm.ExecuteNonQuery();
|
cm.ExecuteNonQuery();
|
||||||
@@ -909,34 +795,39 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Association.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Association.SQLUpdate", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_MyDocVersion != null) _MyDocVersion.Update();
|
_MyDocVersion?.Update();
|
||||||
if (_MyROFst != null) _MyROFst.Update();
|
_MyROFst?.Update();
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
if (base.IsDirty)
|
|
||||||
{
|
{
|
||||||
using (SqlCommand cm = cn.CreateCommand())
|
if (base.IsDirty)
|
||||||
{
|
{
|
||||||
cm.CommandType = CommandType.StoredProcedure;
|
using (SqlCommand cm = cn.CreateCommand())
|
||||||
cm.CommandTimeout = Database.SQLTimeout;
|
{
|
||||||
cm.CommandText = "updateAssociation";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@AssociationID", _AssociationID);
|
cm.CommandText = "updateAssociation";
|
||||||
cm.Parameters.AddWithValue("@VersionID", VersionID);
|
// All Fields including Calculated Fields
|
||||||
cm.Parameters.AddWithValue("@ROFstID", ROFstID);
|
cm.Parameters.AddWithValue("@AssociationID", _AssociationID);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@VersionID", VersionID);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@ROFstID", ROFstID);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
// Output Calculated Columns
|
||||||
cm.Parameters.Add(param_LastChanged);
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
// CSLATODO: Define any additional output parameters
|
{
|
||||||
cm.ExecuteNonQuery();
|
Direction = ParameterDirection.Output
|
||||||
// Save all values being returned from the Procedure
|
};
|
||||||
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
cm.Parameters.Add(param_LastChanged);
|
||||||
|
// CSLATODO: Define any additional output parameters
|
||||||
|
cm.ExecuteNonQuery();
|
||||||
|
// Save all values being returned from the Procedure
|
||||||
|
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
// use the open connection to update child objects
|
// use the open connection to update child objects
|
||||||
}
|
}
|
||||||
@@ -949,14 +840,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
internal void Update()
|
internal void Update()
|
||||||
{
|
{
|
||||||
if (!this.IsDirty) return;
|
if (!IsDirty) return;
|
||||||
if (base.IsDirty)
|
if (base.IsDirty)
|
||||||
{
|
{
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
if (IsNew)
|
{
|
||||||
_LastChanged = Association.Add(cn, ref _AssociationID, _MyDocVersion, _MyROFst, _Config, _DTS, _UserID);
|
if (IsNew)
|
||||||
else
|
_LastChanged = Association.Add(cn, ref _AssociationID, _MyDocVersion, _MyROFst, _Config, _DTS, _UserID);
|
||||||
_LastChanged = Association.Update(cn, ref _AssociationID, _VersionID, _ROFstID, _Config, _DTS, _UserID, ref _LastChanged);
|
else
|
||||||
|
_LastChanged = Association.Update(cn, ref _AssociationID, _VersionID, _ROFstID, _Config, _DTS, _UserID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -980,8 +874,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
cm.Parameters.AddWithValue("@UserID", userID);
|
cm.Parameters.AddWithValue("@UserID", userID);
|
||||||
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
{
|
||||||
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
cm.Parameters.Add(param_LastChanged);
|
cm.Parameters.Add(param_LastChanged);
|
||||||
// CSLATODO: Define any additional output parameters
|
// CSLATODO: Define any additional output parameters
|
||||||
cm.ExecuteNonQuery();
|
cm.ExecuteNonQuery();
|
||||||
@@ -996,10 +892,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
protected override void DataPortal_DeleteSelf()
|
protected override void DataPortal_DeleteSelf() => DataPortal_Delete(new PKCriteria(_AssociationID));
|
||||||
{
|
|
||||||
DataPortal_Delete(new PKCriteria(_AssociationID));
|
|
||||||
}
|
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
private void DataPortal_Delete(PKCriteria criteria)
|
private void DataPortal_Delete(PKCriteria criteria)
|
||||||
{
|
{
|
||||||
@@ -1066,16 +959,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ExistsCommand : CommandBase
|
private class ExistsCommand : CommandBase
|
||||||
{
|
{
|
||||||
private int _AssociationID;
|
private readonly int _AssociationID;
|
||||||
private bool _exists;
|
private bool _exists;
|
||||||
public bool Exists
|
public bool Exists => _exists;
|
||||||
{
|
public ExistsCommand(int associationID) => _AssociationID = associationID;
|
||||||
get { return _exists; }
|
|
||||||
}
|
|
||||||
public ExistsCommand(int associationID)
|
|
||||||
{
|
|
||||||
_AssociationID = associationID;
|
|
||||||
}
|
|
||||||
protected override void DataPortal_Execute()
|
protected override void DataPortal_Execute()
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Association.DataPortal_Execute", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Association.DataPortal_Execute", GetHashCode());
|
||||||
@@ -1105,7 +992,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
AssociationExtension _AssociationExtension = new AssociationExtension();
|
readonly AssociationExtension _AssociationExtension = new AssociationExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class AssociationExtension : extensionBase
|
partial class AssociationExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -1114,14 +1001,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
class extensionBase
|
class extensionBase
|
||||||
{
|
{
|
||||||
// Default Values
|
// Default Values
|
||||||
public virtual DateTime DefaultDTS
|
public virtual DateTime DefaultDTS => DateTime.Now;
|
||||||
{
|
public virtual string DefaultUserID => Volian.Base.Library.VlnSettings.UserID;
|
||||||
get { return DateTime.Now; }
|
|
||||||
}
|
|
||||||
public virtual string DefaultUserID
|
|
||||||
{
|
|
||||||
get { return Volian.Base.Library.VlnSettings.UserID; }
|
|
||||||
}
|
|
||||||
// Authorization Rules
|
// Authorization Rules
|
||||||
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
||||||
{
|
{
|
||||||
@@ -1150,10 +1031,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is Association)
|
if (destType == typeof(string) && value is Association assn)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((Association)value).ToString();
|
return assn.ToString();
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
@@ -1161,46 +1042,3 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
} // Namespace
|
} // Namespace
|
||||||
|
|
||||||
|
|
||||||
//// The following is a sample Extension File. You can use it to create AssociationExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class Association
|
|
||||||
// {
|
|
||||||
// partial class AssociationExtension : extensionBase
|
|
||||||
// {
|
|
||||||
// // CSLATODO: Override automatic defaults
|
|
||||||
// public virtual DateTime DefaultDTS
|
|
||||||
// {
|
|
||||||
// get { return DateTime.Now; }
|
|
||||||
// }
|
|
||||||
// public virtual string DefaultUserID
|
|
||||||
// {
|
|
||||||
// get { return Environment.UserName.ToUpper(); }
|
|
||||||
// }
|
|
||||||
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddRule(
|
|
||||||
// Csla.Validation.CommonRules.StringMaxLength,
|
|
||||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddInstanceRule(/* Instance Validation Rule */);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
namespace VEPROMS.CSLA.Library
|
namespace VEPROMS.CSLA.Library
|
||||||
@@ -28,14 +26,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public partial class AssociationInfo : ReadOnlyBase<AssociationInfo>, IDisposable
|
public partial class AssociationInfo : ReadOnlyBase<AssociationInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public event AssociationInfoEvent Changed;
|
public event AssociationInfoEvent Changed;
|
||||||
private void OnChange()
|
private void OnChange() => Changed?.Invoke(this);
|
||||||
{
|
|
||||||
if (Changed != null) Changed(this);
|
|
||||||
}
|
|
||||||
#region Log4Net
|
#region Log4Net
|
||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
#endregion
|
#endregion
|
||||||
#region Collection
|
#region Collection
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static List<AssociationInfo> _CacheList = new List<AssociationInfo>();
|
private static List<AssociationInfo> _CacheList = new List<AssociationInfo>();
|
||||||
protected static void AddToCache(AssociationInfo associationInfo)
|
protected static void AddToCache(AssociationInfo associationInfo)
|
||||||
{
|
{
|
||||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(associationInfo)) _CacheList.Remove(associationInfo); // In RemoveFromCache
|
while (_CacheList.Contains(associationInfo)) _CacheList.Remove(associationInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<AssociationInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AssociationInfo>>();
|
private static Dictionary<string, List<AssociationInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AssociationInfo>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -74,21 +71,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
#region Business Methods
|
#region Business Methods
|
||||||
private string _ErrorMessage = string.Empty;
|
private string _ErrorMessage = string.Empty;
|
||||||
public string ErrorMessage
|
public string ErrorMessage => _ErrorMessage;
|
||||||
{
|
|
||||||
get { return _ErrorMessage; }
|
|
||||||
}
|
|
||||||
protected Association _Editable;
|
protected Association _Editable;
|
||||||
private IVEHasBrokenRules HasBrokenRules
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
IVEHasBrokenRules hasBrokenRules = null;
|
|
||||||
if (_Editable != null)
|
|
||||||
hasBrokenRules = _Editable.HasBrokenRules;
|
|
||||||
return hasBrokenRules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private int _AssociationID;
|
private int _AssociationID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int AssociationID
|
public int AssociationID
|
||||||
@@ -167,32 +151,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _UserID;
|
return _UserID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base AssociationInfo.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current AssociationInfo</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check AssociationInfo.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check AssociationInfo.GetIdValue to assure that the ID returned is unique
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A Unique ID for the current AssociationInfo</returns>
|
/// <returns>A Unique ID for the current AssociationInfo</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyAssociationInfoUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyAssociationInfoUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _AssociationInfoUnique = 0;
|
private static int _AssociationInfoUnique = 0;
|
||||||
private static int AssociationInfoUnique
|
private static int AssociationInfoUnique => ++_AssociationInfoUnique;
|
||||||
{ get { return ++_AssociationInfoUnique; } }
|
private readonly int _MyAssociationInfoUnique = AssociationInfoUnique;
|
||||||
private int _MyAssociationInfoUnique = AssociationInfoUnique;
|
// Absolutely Unique ID - Info
|
||||||
public int MyAssociationInfoUnique // Absolutely Unique ID - Info
|
public int MyAssociationInfoUnique => _MyAssociationInfoUnique;
|
||||||
{ get { return _MyAssociationInfoUnique; } }
|
|
||||||
protected AssociationInfo()
|
protected AssociationInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -201,15 +172,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static int _CountCreated = 0;
|
private static int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
private static int IncrementCountCreated => ++_CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountCreated => _CountCreated;
|
||||||
public static int CountCreated
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
{ get { return _CountCreated; } }
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountNotDisposed
|
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~AssociationInfo()
|
~AssociationInfo()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -226,10 +193,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (listAssociationInfo.Count == 0) // If there are no items left in the list
|
if (listAssociationInfo.Count == 0) // If there are no items left in the list
|
||||||
_CacheByPrimaryKey.Remove(AssociationID.ToString()); // remove the list
|
_CacheByPrimaryKey.Remove(AssociationID.ToString()); // remove the list
|
||||||
}
|
}
|
||||||
public virtual Association Get()
|
public virtual Association Get() => _Editable = Association.Get(_AssociationID);
|
||||||
{
|
|
||||||
return _Editable = Association.Get(_AssociationID);
|
|
||||||
}
|
|
||||||
public static void Refresh(Association tmp)
|
public static void Refresh(Association tmp)
|
||||||
{
|
{
|
||||||
string key = tmp.AssociationID.ToString();
|
string key = tmp.AssociationID.ToString();
|
||||||
@@ -242,18 +206,18 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_VersionID != tmp.VersionID)
|
if (_VersionID != tmp.VersionID)
|
||||||
{
|
{
|
||||||
if (MyDocVersion != null) MyDocVersion.RefreshDocVersionAssociations(); // Update List for old value
|
MyDocVersion?.RefreshDocVersionAssociations(); // Update List for old value
|
||||||
_VersionID = tmp.VersionID; // Update the value
|
_VersionID = tmp.VersionID; // Update the value
|
||||||
}
|
}
|
||||||
_MyDocVersion = null; // Reset list so that the next line gets a new list
|
_MyDocVersion = null; // Reset list so that the next line gets a new list
|
||||||
if (MyDocVersion != null) MyDocVersion.RefreshDocVersionAssociations(); // Update List for new value
|
MyDocVersion?.RefreshDocVersionAssociations(); // Update List for new value
|
||||||
if (_ROFstID != tmp.ROFstID)
|
if (_ROFstID != tmp.ROFstID)
|
||||||
{
|
{
|
||||||
if (MyROFst != null) MyROFst.RefreshROFstAssociations(); // Update List for old value
|
MyROFst?.RefreshROFstAssociations(); // Update List for old value
|
||||||
_ROFstID = tmp.ROFstID; // Update the value
|
_ROFstID = tmp.ROFstID; // Update the value
|
||||||
}
|
}
|
||||||
_MyROFst = null; // Reset list so that the next line gets a new list
|
_MyROFst = null; // Reset list so that the next line gets a new list
|
||||||
if (MyROFst != null) MyROFst.RefreshROFstAssociations(); // Update List for new value
|
MyROFst?.RefreshROFstAssociations(); // Update List for new value
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
_UserID = tmp.UserID;
|
_UserID = tmp.UserID;
|
||||||
@@ -272,11 +236,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_ROFstID != tmp.ROFstID)
|
if (_ROFstID != tmp.ROFstID)
|
||||||
{
|
{
|
||||||
if (MyROFst != null) MyROFst.RefreshROFstAssociations(); // Update List for old value
|
MyROFst?.RefreshROFstAssociations(); // Update List for old value
|
||||||
_ROFstID = tmp.ROFstID; // Update the value
|
_ROFstID = tmp.ROFstID; // Update the value
|
||||||
}
|
}
|
||||||
_MyROFst = null; // Reset list so that the next line gets a new list
|
_MyROFst = null; // Reset list so that the next line gets a new list
|
||||||
if (MyROFst != null) MyROFst.RefreshROFstAssociations(); // Update List for new value
|
MyROFst?.RefreshROFstAssociations(); // Update List for new value
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
_UserID = tmp.UserID;
|
_UserID = tmp.UserID;
|
||||||
@@ -295,11 +259,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_VersionID != tmp.VersionID)
|
if (_VersionID != tmp.VersionID)
|
||||||
{
|
{
|
||||||
if (MyDocVersion != null) MyDocVersion.RefreshDocVersionAssociations(); // Update List for old value
|
MyDocVersion?.RefreshDocVersionAssociations(); // Update List for old value
|
||||||
_VersionID = tmp.VersionID; // Update the value
|
_VersionID = tmp.VersionID; // Update the value
|
||||||
}
|
}
|
||||||
_MyDocVersion = null; // Reset list so that the next line gets a new list
|
_MyDocVersion = null; // Reset list so that the next line gets a new list
|
||||||
if (MyDocVersion != null) MyDocVersion.RefreshDocVersionAssociations(); // Update List for new value
|
MyDocVersion?.RefreshDocVersionAssociations(); // Update List for new value
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
_UserID = tmp.UserID;
|
_UserID = tmp.UserID;
|
||||||
@@ -308,8 +272,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static AssociationInfo Get(int associationID)
|
public static AssociationInfo Get(int associationID)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a Association");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AssociationInfo tmp = GetCachedByPrimaryKey(associationID);
|
AssociationInfo tmp = GetCachedByPrimaryKey(associationID);
|
||||||
@@ -348,13 +310,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _AssociationID;
|
private readonly int _AssociationID;
|
||||||
public int AssociationID
|
public int AssociationID => _AssociationID;
|
||||||
{ get { return _AssociationID; } }
|
public PKCriteria(int associationID) => _AssociationID = associationID;
|
||||||
public PKCriteria(int associationID)
|
|
||||||
{
|
|
||||||
_AssociationID = associationID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void ReadData(SafeDataReader dr)
|
private void ReadData(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
@@ -414,7 +372,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
AssociationInfoExtension _AssociationInfoExtension = new AssociationInfoExtension();
|
readonly AssociationInfoExtension _AssociationInfoExtension = new AssociationInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class AssociationInfoExtension : extensionBase { }
|
partial class AssociationInfoExtension : extensionBase { }
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
@@ -430,10 +388,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is AssociationInfo)
|
if (destType == typeof(string) && value is AssociationInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((AssociationInfo)value).ToString();
|
return info.ToString();
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
namespace VEPROMS.CSLA.Library
|
namespace VEPROMS.CSLA.Library
|
||||||
@@ -28,11 +26,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
#region Log4Net
|
#region Log4Net
|
||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
#endregion
|
#endregion
|
||||||
#region Business Methods
|
#region Business Methods
|
||||||
internal new IList<AssociationInfo> Items
|
internal new IList<AssociationInfo> Items => base.Items;
|
||||||
{ get { return base.Items; } }
|
public void AddEvents()
|
||||||
public void AddEvents()
|
|
||||||
{
|
{
|
||||||
foreach (AssociationInfo tmp in this)
|
foreach (AssociationInfo tmp in this)
|
||||||
{
|
{
|
||||||
@@ -51,16 +48,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static int _CountCreated = 0;
|
private static int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
private static int IncrementCountCreated => ++_CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountCreated => _CountCreated;
|
||||||
public static int CountCreated
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
{ get { return _CountCreated; } }
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountNotDisposed
|
~AssociationInfoList()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~AssociationInfoList()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -104,18 +97,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
_AssociationInfoList = null;
|
_AssociationInfoList = null;
|
||||||
}
|
}
|
||||||
// CSLATODO: Add alternative gets -
|
|
||||||
//public static AssociationInfoList Get(<criteria>)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// return DataPortal.Fetch<AssociationInfoList>(new FilteredCriteria(<criteria>));
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// throw new DbCslaException("Error on AssociationInfoList.Get", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
public static AssociationInfoList GetByVersionID(int versionID)
|
public static AssociationInfoList GetByVersionID(int versionID)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -180,11 +162,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class VersionIDCriteria
|
private class VersionIDCriteria
|
||||||
{
|
{
|
||||||
public VersionIDCriteria(int versionID)
|
public VersionIDCriteria(int versionID) => _VersionID = versionID;
|
||||||
{
|
private int _VersionID;
|
||||||
_VersionID = versionID;
|
|
||||||
}
|
|
||||||
private int _VersionID;
|
|
||||||
public int VersionID
|
public int VersionID
|
||||||
{
|
{
|
||||||
get { return _VersionID; }
|
get { return _VersionID; }
|
||||||
@@ -224,11 +203,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ROFstIDCriteria
|
private class ROFstIDCriteria
|
||||||
{
|
{
|
||||||
public ROFstIDCriteria(int rOFstID)
|
public ROFstIDCriteria(int rOFstID) => _ROFstID = rOFstID;
|
||||||
{
|
private int _ROFstID;
|
||||||
_ROFstID = rOFstID;
|
|
||||||
}
|
|
||||||
private int _ROFstID;
|
|
||||||
public int ROFstID
|
public int ROFstID
|
||||||
{
|
{
|
||||||
get { return _ROFstID; }
|
get { return _ROFstID; }
|
||||||
@@ -265,41 +241,31 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
this.RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ICustomTypeDescriptor impl
|
#region ICustomTypeDescriptor impl
|
||||||
public String GetClassName()
|
public String GetClassName() => TypeDescriptor.GetClassName(this, true);
|
||||||
{ return TypeDescriptor.GetClassName(this, true); }
|
public AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true);
|
||||||
public AttributeCollection GetAttributes()
|
public String GetComponentName() => TypeDescriptor.GetComponentName(this, true);
|
||||||
{ return TypeDescriptor.GetAttributes(this, true); }
|
public TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true);
|
||||||
public String GetComponentName()
|
public EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
|
||||||
{ return TypeDescriptor.GetComponentName(this, true); }
|
public PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true);
|
||||||
public TypeConverter GetConverter()
|
public object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true);
|
||||||
{ return TypeDescriptor.GetConverter(this, true); }
|
public EventDescriptorCollection GetEvents(Attribute[] attributes)
|
||||||
public EventDescriptor GetDefaultEvent()
|
|
||||||
{ return TypeDescriptor.GetDefaultEvent(this, true); }
|
|
||||||
public PropertyDescriptor GetDefaultProperty()
|
|
||||||
{ return TypeDescriptor.GetDefaultProperty(this, true); }
|
|
||||||
public object GetEditor(Type editorBaseType)
|
|
||||||
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
|
|
||||||
public EventDescriptorCollection GetEvents(Attribute[] attributes)
|
|
||||||
{ return TypeDescriptor.GetEvents(this, attributes, true); }
|
{ return TypeDescriptor.GetEvents(this, attributes, true); }
|
||||||
public EventDescriptorCollection GetEvents()
|
public EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true);
|
||||||
{ return TypeDescriptor.GetEvents(this, true); }
|
public object GetPropertyOwner(PropertyDescriptor pd) => this;
|
||||||
public object GetPropertyOwner(PropertyDescriptor pd)
|
/// <summary>
|
||||||
{ return this; }
|
/// Called to get the properties of this type. Returns properties with certain
|
||||||
/// <summary>
|
/// attributes. this restriction is not implemented here.
|
||||||
/// Called to get the properties of this type. Returns properties with certain
|
/// </summary>
|
||||||
/// attributes. this restriction is not implemented here.
|
/// <param name="attributes"></param>
|
||||||
/// </summary>
|
/// <returns></returns>
|
||||||
/// <param name="attributes"></param>
|
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
||||||
/// <returns></returns>
|
/// <summary>
|
||||||
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
|
/// Called to get the properties of this type.
|
||||||
{ return GetProperties(); }
|
/// </summary>
|
||||||
/// <summary>
|
/// <returns></returns>
|
||||||
/// Called to get the properties of this type.
|
public PropertyDescriptorCollection GetProperties()
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PropertyDescriptorCollection GetProperties()
|
|
||||||
{
|
{
|
||||||
// Create a collection object to hold property descriptors
|
// Create a collection object to hold property descriptors
|
||||||
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
||||||
@@ -321,7 +287,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class AssociationInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class AssociationInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private AssociationInfo Item { get { return (AssociationInfo)_Item; } }
|
|
||||||
public AssociationInfoListPropertyDescriptor(AssociationInfoList collection, int index) : base(collection, index) { ;}
|
public AssociationInfoListPropertyDescriptor(AssociationInfoList collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -330,10 +295,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is AssociationInfoList)
|
if (destType == typeof(string) && value is AssociationInfoList list)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((AssociationInfoList)value).Items.Count.ToString() + " Associations";
|
return $"{list.Items.Count} Associations";
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user