CLSA - Ds
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;
|
||||||
@@ -58,6 +56,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<DROUsage> _CacheList = new List<DROUsage>();
|
private static List<DROUsage> _CacheList = new List<DROUsage>();
|
||||||
protected static void AddToCache(DROUsage dROUsage)
|
protected static void AddToCache(DROUsage dROUsage)
|
||||||
{
|
{
|
||||||
@@ -67,6 +66,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(dROUsage)) _CacheList.Remove(dROUsage); // In RemoveFromCache
|
while (_CacheList.Contains(dROUsage)) _CacheList.Remove(dROUsage); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<DROUsage>> _CacheByPrimaryKey = new Dictionary<string, List<DROUsage>>();
|
private static Dictionary<string, List<DROUsage>> _CacheByPrimaryKey = new Dictionary<string, List<DROUsage>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -92,15 +92,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 _nextDROUsageID = -1;
|
private static int _nextDROUsageID = -1;
|
||||||
public static int NextDROUsageID
|
public static int NextDROUsageID => _nextDROUsageID--;
|
||||||
{
|
|
||||||
get { return _nextDROUsageID--; }
|
|
||||||
}
|
|
||||||
private int _DROUsageID;
|
private int _DROUsageID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int DROUsageID
|
public int DROUsageID
|
||||||
@@ -261,7 +255,7 @@ 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 || (_MyDocument == null ? false : _MyDocument.IsDirtyList(list)) || (_MyRODb == null ? false : _MyRODb.IsDirtyList(list));
|
return base.IsDirty || (_MyDocument != null && _MyDocument.IsDirtyList(list)) || (_MyRODb != null && _MyRODb.IsDirtyList(list));
|
||||||
}
|
}
|
||||||
public override bool IsValid
|
public override bool IsValid
|
||||||
{
|
{
|
||||||
@@ -270,28 +264,16 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public bool IsValidList(List<object> list)
|
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) && (_MyDocument == null ? true : _MyDocument.IsValidList(list)) && (_MyRODb == null ? true : _MyRODb.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_MyDocument == null || _MyDocument.IsValidList(list)) && (_MyRODb == null || _MyRODb.IsValidList(list));
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base DROUsage.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current DROUsage</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check DROUsage.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check DROUsage.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 DROUsage</returns>
|
/// <returns>A Unique ID for the current DROUsage</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyDROUsageUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyDROUsageUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
@@ -321,8 +303,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()
|
||||||
@@ -369,35 +351,11 @@ 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
|
#endregion
|
||||||
#region Authorization Rules
|
#region Authorization Rules
|
||||||
protected override void AddAuthorizationRules()
|
protected override void AddAuthorizationRules()
|
||||||
{
|
{
|
||||||
//CSLATODO: Who can read/write which fields
|
//CSLATODO: Who can read/write which fields
|
||||||
//AuthorizationRules.AllowRead(DROUsageID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DocID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ROID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(RODbID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DocID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ROID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(RODbID, "<Role(s)>");
|
|
||||||
_DROUsageExtension.AddAuthorizationRules(AuthorizationRules);
|
_DROUsageExtension.AddAuthorizationRules(AuthorizationRules);
|
||||||
}
|
}
|
||||||
protected override void AddInstanceAuthorizationRules()
|
protected override void AddInstanceAuthorizationRules()
|
||||||
@@ -405,42 +363,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//CSLATODO: Who can read/write which fields
|
//CSLATODO: Who can read/write which fields
|
||||||
_DROUsageExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
_DROUsageExtension.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 _DROUsageUnique = 0;
|
private static int _DROUsageUnique = 0;
|
||||||
protected static int DROUsageUnique
|
protected static int DROUsageUnique => ++_DROUsageUnique;
|
||||||
{ get { return ++_DROUsageUnique; } }
|
private readonly int _MyDROUsageUnique = DROUsageUnique;
|
||||||
private int _MyDROUsageUnique = DROUsageUnique;
|
// Absolutely Unique ID - Editable
|
||||||
public int MyDROUsageUnique // Absolutely Unique ID - Editable
|
public int MyDROUsageUnique => _MyDROUsageUnique;
|
||||||
{ get { return _MyDROUsageUnique; } }
|
|
||||||
protected DROUsage()
|
protected DROUsage()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -449,15 +379,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; } }
|
|
||||||
~DROUsage()
|
~DROUsage()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -482,8 +408,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static DROUsage New()
|
public static DROUsage New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a DROUsage");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<DROUsage>();
|
return DataPortal.Create<DROUsage>();
|
||||||
@@ -554,8 +478,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static DROUsage Get(int dROUsageID)
|
public static DROUsage Get(int dROUsageID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a DROUsage");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DROUsage tmp = GetCachedByPrimaryKey(dROUsageID);
|
DROUsage tmp = GetCachedByPrimaryKey(dROUsageID);
|
||||||
@@ -581,14 +503,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dr.Read()) return new DROUsage(dr);
|
if (dr.Read()) return new DROUsage(dr);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
internal DROUsage(SafeDataReader dr)
|
internal DROUsage(SafeDataReader dr) => ReadData(dr);
|
||||||
{
|
|
||||||
ReadData(dr);
|
|
||||||
}
|
|
||||||
public static void Delete(int dROUsageID)
|
public static void Delete(int dROUsageID)
|
||||||
{
|
{
|
||||||
if (!CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a DROUsage");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataPortal.Delete(new PKCriteria(dROUsageID));
|
DataPortal.Delete(new PKCriteria(dROUsageID));
|
||||||
@@ -600,12 +517,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public override DROUsage Save()
|
public override DROUsage Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a DROUsage");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a DROUsage");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a DROUsage");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -625,13 +536,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _DROUsageID;
|
private readonly int _DROUsageID;
|
||||||
public int DROUsageID
|
public int DROUsageID => _DROUsageID;
|
||||||
{ get { return _DROUsageID; } }
|
public PKCriteria(int dROUsageID) => _DROUsageID = dROUsageID;
|
||||||
public PKCriteria(int dROUsageID)
|
|
||||||
{
|
|
||||||
_DROUsageID = dROUsageID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 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()]
|
||||||
@@ -731,37 +638,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
|
||||||
{
|
{
|
||||||
if (_MyDocument != null) _MyDocument.Update();
|
_MyDocument?.Update();
|
||||||
if (_MyRODb != null) _MyRODb.Update();
|
_MyRODb?.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 = "addDROUsage";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@DocID", DocID);
|
cm.CommandText = "addDROUsage";
|
||||||
cm.Parameters.AddWithValue("@ROID", _ROID);
|
// Input All Fields - Except Calculated Columns
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@DocID", DocID);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@ROID", _ROID);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
cm.Parameters.AddWithValue("@RODbID", RODbID);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
SqlParameter param_DROUsageID = new SqlParameter("@newDROUsageID", SqlDbType.Int);
|
cm.Parameters.AddWithValue("@RODbID", RODbID);
|
||||||
param_DROUsageID.Direction = ParameterDirection.Output;
|
// Output Calculated Columns
|
||||||
cm.Parameters.Add(param_DROUsageID);
|
SqlParameter param_DROUsageID = new SqlParameter("@newDROUsageID", 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_DROUsageID);
|
||||||
cm.ExecuteNonQuery();
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
// Save all values being returned from the Procedure
|
{
|
||||||
_DROUsageID = (int)cm.Parameters["@newDROUsageID"].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
|
||||||
|
_DROUsageID = (int)cm.Parameters["@newDROUsageID"].Value;
|
||||||
|
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
// update child objects
|
// update child objects
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsage.SQLInsert", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsage.SQLInsert", GetHashCode());
|
||||||
@@ -792,11 +706,15 @@ namespace VEPROMS.CSLA.Library
|
|||||||
cm.Parameters.AddWithValue("@UserID", userID);
|
cm.Parameters.AddWithValue("@UserID", userID);
|
||||||
cm.Parameters.AddWithValue("@RODbID", myRODb.RODbID);
|
cm.Parameters.AddWithValue("@RODbID", myRODb.RODbID);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_DROUsageID = new SqlParameter("@newDROUsageID", SqlDbType.Int);
|
SqlParameter param_DROUsageID = new SqlParameter("@newDROUsageID", SqlDbType.Int)
|
||||||
param_DROUsageID.Direction = ParameterDirection.Output;
|
{
|
||||||
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
cm.Parameters.Add(param_DROUsageID);
|
cm.Parameters.Add(param_DROUsageID);
|
||||||
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();
|
||||||
@@ -841,35 +759,40 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsage.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsage.SQLUpdate", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_MyDocument != null) _MyDocument.Update();
|
_MyDocument?.Update();
|
||||||
if (_MyRODb != null) _MyRODb.Update();
|
_MyRODb?.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 = "updateDROUsage";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@DROUsageID", _DROUsageID);
|
cm.CommandText = "updateDROUsage";
|
||||||
cm.Parameters.AddWithValue("@DocID", DocID);
|
// All Fields including Calculated Fields
|
||||||
cm.Parameters.AddWithValue("@ROID", _ROID);
|
cm.Parameters.AddWithValue("@DROUsageID", _DROUsageID);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@DocID", DocID);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@ROID", _ROID);
|
||||||
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);
|
||||||
cm.Parameters.AddWithValue("@RODbID", RODbID);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
cm.Parameters.AddWithValue("@RODbID", RODbID);
|
||||||
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
|
||||||
}
|
}
|
||||||
@@ -882,14 +805,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 = DROUsage.Add(cn, ref _DROUsageID, _MyDocument, _ROID, _Config, _DTS, _UserID, _MyRODb);
|
if (IsNew)
|
||||||
else
|
_LastChanged = DROUsage.Add(cn, ref _DROUsageID, _MyDocument, _ROID, _Config, _DTS, _UserID, _MyRODb);
|
||||||
_LastChanged = DROUsage.Update(cn, ref _DROUsageID, _DocID, _ROID, _Config, _DTS, _UserID, ref _LastChanged, _RODbID);
|
else
|
||||||
|
_LastChanged = DROUsage.Update(cn, ref _DROUsageID, _DocID, _ROID, _Config, _DTS, _UserID, ref _LastChanged, _RODbID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -914,8 +840,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
||||||
cm.Parameters.AddWithValue("@RODbID", rODbID);
|
cm.Parameters.AddWithValue("@RODbID", rODbID);
|
||||||
// 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();
|
||||||
@@ -930,10 +858,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(_DROUsageID));
|
||||||
{
|
|
||||||
DataPortal_Delete(new PKCriteria(_DROUsageID));
|
|
||||||
}
|
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
private void DataPortal_Delete(PKCriteria criteria)
|
private void DataPortal_Delete(PKCriteria criteria)
|
||||||
{
|
{
|
||||||
@@ -1000,16 +925,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ExistsCommand : CommandBase
|
private class ExistsCommand : CommandBase
|
||||||
{
|
{
|
||||||
private int _DROUsageID;
|
private readonly int _DROUsageID;
|
||||||
private bool _exists;
|
private bool _exists;
|
||||||
public bool Exists
|
public bool Exists => _exists;
|
||||||
{
|
public ExistsCommand(int dROUsageID) => _DROUsageID = dROUsageID;
|
||||||
get { return _exists; }
|
|
||||||
}
|
|
||||||
public ExistsCommand(int dROUsageID)
|
|
||||||
{
|
|
||||||
_DROUsageID = dROUsageID;
|
|
||||||
}
|
|
||||||
protected override void DataPortal_Execute()
|
protected override void DataPortal_Execute()
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsage.DataPortal_Execute", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsage.DataPortal_Execute", GetHashCode());
|
||||||
@@ -1039,7 +958,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
DROUsageExtension _DROUsageExtension = new DROUsageExtension();
|
readonly DROUsageExtension _DROUsageExtension = new DROUsageExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class DROUsageExtension : extensionBase
|
partial class DROUsageExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -1048,18 +967,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
class extensionBase
|
class extensionBase
|
||||||
{
|
{
|
||||||
// Default Values
|
// Default Values
|
||||||
public virtual int DefaultDocID
|
public virtual int DefaultDocID => 0;
|
||||||
{
|
public virtual DateTime DefaultDTS => DateTime.Now;
|
||||||
get { return 0; }
|
public virtual string DefaultUserID => Volian.Base.Library.VlnSettings.UserID;
|
||||||
}
|
|
||||||
public virtual DateTime DefaultDTS
|
|
||||||
{
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -1088,61 +998,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 DROUsage)
|
if (destType == typeof(string) && value is DROUsage usage)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((DROUsage)value).ToString();
|
return usage.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 DROUsageExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class DROUsage
|
|
||||||
// {
|
|
||||||
// partial class DROUsageExtension : extensionBase
|
|
||||||
// {
|
|
||||||
// // CSLATODO: Override automatic defaults
|
|
||||||
// public virtual int DefaultDocID
|
|
||||||
// {
|
|
||||||
// get { return 0; }
|
|
||||||
// }
|
|
||||||
// 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 DROUsageInfo : ReadOnlyBase<DROUsageInfo>, IDisposable
|
public partial class DROUsageInfo : ReadOnlyBase<DROUsageInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public event DROUsageInfoEvent Changed;
|
public event DROUsageInfoEvent 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<DROUsageInfo> _CacheList = new List<DROUsageInfo>();
|
private static List<DROUsageInfo> _CacheList = new List<DROUsageInfo>();
|
||||||
protected static void AddToCache(DROUsageInfo dROUsageInfo)
|
protected static void AddToCache(DROUsageInfo dROUsageInfo)
|
||||||
{
|
{
|
||||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(dROUsageInfo)) _CacheList.Remove(dROUsageInfo); // In RemoveFromCache
|
while (_CacheList.Contains(dROUsageInfo)) _CacheList.Remove(dROUsageInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<DROUsageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DROUsageInfo>>();
|
private static Dictionary<string, List<DROUsageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DROUsageInfo>>();
|
||||||
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 DROUsage _Editable;
|
protected DROUsage _Editable;
|
||||||
private IVEHasBrokenRules HasBrokenRules
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
IVEHasBrokenRules hasBrokenRules = null;
|
|
||||||
if (_Editable != null)
|
|
||||||
hasBrokenRules = _Editable.HasBrokenRules;
|
|
||||||
return hasBrokenRules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private int _DROUsageID;
|
private int _DROUsageID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int DROUsageID
|
public int DROUsageID
|
||||||
@@ -175,32 +159,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _MyRODb;
|
return _MyRODb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base DROUsageInfo.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current DROUsageInfo</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check DROUsageInfo.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check DROUsageInfo.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 DROUsageInfo</returns>
|
/// <returns>A Unique ID for the current DROUsageInfo</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyDROUsageInfoUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyDROUsageInfoUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _DROUsageInfoUnique = 0;
|
private static int _DROUsageInfoUnique = 0;
|
||||||
private static int DROUsageInfoUnique
|
private static int DROUsageInfoUnique => ++_DROUsageInfoUnique;
|
||||||
{ get { return ++_DROUsageInfoUnique; } }
|
private readonly int _MyDROUsageInfoUnique = DROUsageInfoUnique;
|
||||||
private int _MyDROUsageInfoUnique = DROUsageInfoUnique;
|
// Absolutely Unique ID - Info
|
||||||
public int MyDROUsageInfoUnique // Absolutely Unique ID - Info
|
public int MyDROUsageInfoUnique => _MyDROUsageInfoUnique;
|
||||||
{ get { return _MyDROUsageInfoUnique; } }
|
|
||||||
protected DROUsageInfo()
|
protected DROUsageInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -209,15 +180,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; } }
|
|
||||||
~DROUsageInfo()
|
~DROUsageInfo()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -234,10 +201,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (listDROUsageInfo.Count == 0) // If there are no items left in the list
|
if (listDROUsageInfo.Count == 0) // If there are no items left in the list
|
||||||
_CacheByPrimaryKey.Remove(DROUsageID.ToString()); // remove the list
|
_CacheByPrimaryKey.Remove(DROUsageID.ToString()); // remove the list
|
||||||
}
|
}
|
||||||
public virtual DROUsage Get()
|
public virtual DROUsage Get() => _Editable = DROUsage.Get(_DROUsageID);
|
||||||
{
|
|
||||||
return _Editable = DROUsage.Get(_DROUsageID);
|
|
||||||
}
|
|
||||||
public static void Refresh(DROUsage tmp)
|
public static void Refresh(DROUsage tmp)
|
||||||
{
|
{
|
||||||
string key = tmp.DROUsageID.ToString();
|
string key = tmp.DROUsageID.ToString();
|
||||||
@@ -250,22 +214,22 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_DocID != tmp.DocID)
|
if (_DocID != tmp.DocID)
|
||||||
{
|
{
|
||||||
if (MyDocument != null) MyDocument.RefreshDocumentDROUsages(); // Update List for old value
|
MyDocument?.RefreshDocumentDROUsages(); // Update List for old value
|
||||||
_DocID = tmp.DocID; // Update the value
|
_DocID = tmp.DocID; // Update the value
|
||||||
}
|
}
|
||||||
_MyDocument = null; // Reset list so that the next line gets a new list
|
_MyDocument = null; // Reset list so that the next line gets a new list
|
||||||
if (MyDocument != null) MyDocument.RefreshDocumentDROUsages(); // Update List for new value
|
MyDocument?.RefreshDocumentDROUsages(); // Update List for new value
|
||||||
_ROID = tmp.ROID;
|
_ROID = tmp.ROID;
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
_UserID = tmp.UserID;
|
_UserID = tmp.UserID;
|
||||||
if (_RODbID != tmp.RODbID)
|
if (_RODbID != tmp.RODbID)
|
||||||
{
|
{
|
||||||
if (MyRODb != null) MyRODb.RefreshRODbDROUsages(); // Update List for old value
|
MyRODb?.RefreshRODbDROUsages(); // Update List for old value
|
||||||
_RODbID = tmp.RODbID; // Update the value
|
_RODbID = tmp.RODbID; // Update the value
|
||||||
}
|
}
|
||||||
_MyRODb = null; // Reset list so that the next line gets a new list
|
_MyRODb = null; // Reset list so that the next line gets a new list
|
||||||
if (MyRODb != null) MyRODb.RefreshRODbDROUsages(); // Update List for new value
|
MyRODb?.RefreshRODbDROUsages(); // Update List for new value
|
||||||
_DROUsageInfoExtension.Refresh(this);
|
_DROUsageInfoExtension.Refresh(this);
|
||||||
OnChange();// raise an event
|
OnChange();// raise an event
|
||||||
}
|
}
|
||||||
@@ -285,11 +249,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_UserID = tmp.UserID;
|
_UserID = tmp.UserID;
|
||||||
if (_RODbID != tmp.RODbID)
|
if (_RODbID != tmp.RODbID)
|
||||||
{
|
{
|
||||||
if (MyRODb != null) MyRODb.RefreshRODbDROUsages(); // Update List for old value
|
MyRODb?.RefreshRODbDROUsages(); // Update List for old value
|
||||||
_RODbID = tmp.RODbID; // Update the value
|
_RODbID = tmp.RODbID; // Update the value
|
||||||
}
|
}
|
||||||
_MyRODb = null; // Reset list so that the next line gets a new list
|
_MyRODb = null; // Reset list so that the next line gets a new list
|
||||||
if (MyRODb != null) MyRODb.RefreshRODbDROUsages(); // Update List for new value
|
MyRODb?.RefreshRODbDROUsages(); // Update List for new value
|
||||||
_DROUsageInfoExtension.Refresh(this);
|
_DROUsageInfoExtension.Refresh(this);
|
||||||
OnChange();// raise an event
|
OnChange();// raise an event
|
||||||
}
|
}
|
||||||
@@ -305,11 +269,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_DocID != tmp.DocID)
|
if (_DocID != tmp.DocID)
|
||||||
{
|
{
|
||||||
if (MyDocument != null) MyDocument.RefreshDocumentDROUsages(); // Update List for old value
|
MyDocument?.RefreshDocumentDROUsages(); // Update List for old value
|
||||||
_DocID = tmp.DocID; // Update the value
|
_DocID = tmp.DocID; // Update the value
|
||||||
}
|
}
|
||||||
_MyDocument = null; // Reset list so that the next line gets a new list
|
_MyDocument = null; // Reset list so that the next line gets a new list
|
||||||
if (MyDocument != null) MyDocument.RefreshDocumentDROUsages(); // Update List for new value
|
MyDocument?.RefreshDocumentDROUsages(); // Update List for new value
|
||||||
_ROID = tmp.ROID;
|
_ROID = tmp.ROID;
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
@@ -319,8 +283,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static DROUsageInfo Get(int dROUsageID)
|
public static DROUsageInfo Get(int dROUsageID)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a DROUsage");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DROUsageInfo tmp = GetCachedByPrimaryKey(dROUsageID);
|
DROUsageInfo tmp = GetCachedByPrimaryKey(dROUsageID);
|
||||||
@@ -359,13 +321,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _DROUsageID;
|
private readonly int _DROUsageID;
|
||||||
public int DROUsageID
|
public int DROUsageID => _DROUsageID;
|
||||||
{ get { return _DROUsageID; } }
|
public PKCriteria(int dROUsageID) => _DROUsageID = dROUsageID;
|
||||||
public PKCriteria(int dROUsageID)
|
|
||||||
{
|
|
||||||
_DROUsageID = dROUsageID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void ReadData(SafeDataReader dr)
|
private void ReadData(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
@@ -426,7 +384,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
DROUsageInfoExtension _DROUsageInfoExtension = new DROUsageInfoExtension();
|
readonly DROUsageInfoExtension _DROUsageInfoExtension = new DROUsageInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class DROUsageInfoExtension : extensionBase { }
|
partial class DROUsageInfoExtension : extensionBase { }
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
@@ -442,10 +400,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 DROUsageInfo)
|
if (destType == typeof(string) && value is DROUsageInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((DROUsageInfo)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<DROUsageInfo> Items
|
internal new IList<DROUsageInfo> Items => base.Items;
|
||||||
{ get { return base.Items; } }
|
public void AddEvents()
|
||||||
public void AddEvents()
|
|
||||||
{
|
{
|
||||||
foreach (DROUsageInfo tmp in this)
|
foreach (DROUsageInfo tmp in this)
|
||||||
{
|
{
|
||||||
@@ -44,23 +41,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
for (int i = 0; i < Count; i++)
|
for (int i = 0; i < Count; i++)
|
||||||
{
|
{
|
||||||
if (base[i] == sender)
|
if (base[i] == sender)
|
||||||
this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i));
|
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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
|
~DROUsageInfoList()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~DROUsageInfoList()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -97,26 +90,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on DROUsageInfoList.Get", ex);
|
throw new DbCslaException("Error on DROUsageInfoList.Get", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset the list of all DROUsageInfo.
|
/// Reset the list of all DROUsageInfo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Reset()
|
public static void Reset() => _DROUsageInfoList = null;
|
||||||
{
|
|
||||||
_DROUsageInfoList = null;
|
public static DROUsageInfoList GetByDocID(int docID)
|
||||||
}
|
|
||||||
// CSLATODO: Add alternative gets -
|
|
||||||
//public static DROUsageInfoList Get(<criteria>)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// return DataPortal.Fetch<DROUsageInfoList>(new FilteredCriteria(<criteria>));
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// throw new DbCslaException("Error on DROUsageInfoList.Get", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
public static DROUsageInfoList GetByDocID(int docID)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -150,7 +129,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#region Data Access Portal
|
#region Data Access Portal
|
||||||
private void DataPortal_Fetch()
|
private void DataPortal_Fetch()
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsageInfoList.DataPortal_Fetch", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsageInfoList.DataPortal_Fetch", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -164,7 +143,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||||
{
|
{
|
||||||
IsReadOnly = false;
|
IsReadOnly = false;
|
||||||
while (dr.Read()) this.Add(new DROUsageInfo(dr));
|
while (dr.Read()) Add(new DROUsageInfo(dr));
|
||||||
IsReadOnly = true;
|
IsReadOnly = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,16 +154,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("DROUsageInfoList.DataPortal_Fetch", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("DROUsageInfoList.DataPortal_Fetch", ex);
|
||||||
throw new DbCslaException("DROUsageInfoList.DataPortal_Fetch", ex);
|
throw new DbCslaException("DROUsageInfoList.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class DocIDCriteria
|
private class DocIDCriteria
|
||||||
{
|
{
|
||||||
public DocIDCriteria(int docID)
|
public DocIDCriteria(int docID) => _DocID = docID;
|
||||||
{
|
private int _DocID;
|
||||||
_DocID = docID;
|
|
||||||
}
|
|
||||||
private int _DocID;
|
|
||||||
public int DocID
|
public int DocID
|
||||||
{
|
{
|
||||||
get { return _DocID; }
|
get { return _DocID; }
|
||||||
@@ -193,7 +169,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
private void DataPortal_Fetch(DocIDCriteria criteria)
|
private void DataPortal_Fetch(DocIDCriteria criteria)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsageInfoList.DataPortal_FetchDocID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsageInfoList.DataPortal_FetchDocID", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -208,7 +184,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||||
{
|
{
|
||||||
IsReadOnly = false;
|
IsReadOnly = false;
|
||||||
while (dr.Read()) this.Add(new DROUsageInfo(dr));
|
while (dr.Read()) Add(new DROUsageInfo(dr));
|
||||||
IsReadOnly = true;
|
IsReadOnly = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,16 +195,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("DROUsageInfoList.DataPortal_FetchDocID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("DROUsageInfoList.DataPortal_FetchDocID", ex);
|
||||||
throw new DbCslaException("DROUsageInfoList.DataPortal_Fetch", ex);
|
throw new DbCslaException("DROUsageInfoList.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class RODbIDCriteria
|
private class RODbIDCriteria
|
||||||
{
|
{
|
||||||
public RODbIDCriteria(int rODbID)
|
public RODbIDCriteria(int rODbID) => _RODbID = rODbID;
|
||||||
{
|
private int _RODbID;
|
||||||
_RODbID = rODbID;
|
|
||||||
}
|
|
||||||
private int _RODbID;
|
|
||||||
public int RODbID
|
public int RODbID
|
||||||
{
|
{
|
||||||
get { return _RODbID; }
|
get { return _RODbID; }
|
||||||
@@ -237,7 +210,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
private void DataPortal_Fetch(RODbIDCriteria criteria)
|
private void DataPortal_Fetch(RODbIDCriteria criteria)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsageInfoList.DataPortal_FetchRODbID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsageInfoList.DataPortal_FetchRODbID", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -252,7 +225,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||||
{
|
{
|
||||||
IsReadOnly = false;
|
IsReadOnly = false;
|
||||||
while (dr.Read()) this.Add(new DROUsageInfo(dr));
|
while (dr.Read()) Add(new DROUsageInfo(dr));
|
||||||
IsReadOnly = true;
|
IsReadOnly = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -263,48 +236,37 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("DROUsageInfoList.DataPortal_FetchRODbID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("DROUsageInfoList.DataPortal_FetchRODbID", ex);
|
||||||
throw new DbCslaException("DROUsageInfoList.DataPortal_Fetch", ex);
|
throw new DbCslaException("DROUsageInfoList.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
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
|
||||||
DROUsageInfoListPropertyDescriptor pd = new DROUsageInfoListPropertyDescriptor(this, i);
|
DROUsageInfoListPropertyDescriptor pd = new DROUsageInfoListPropertyDescriptor(this, i);
|
||||||
@@ -321,7 +283,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class DROUsageInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class DROUsageInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private DROUsageInfo Item { get { return (DROUsageInfo)_Item; } }
|
|
||||||
public DROUsageInfoListPropertyDescriptor(DROUsageInfoList collection, int index) : base(collection, index) { ;}
|
public DROUsageInfoListPropertyDescriptor(DROUsageInfoList collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -330,10 +291,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 DROUsageInfoList)
|
if (destType == typeof(string) && value is DROUsageInfoList list)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((DROUsageInfoList)value).Items.Count.ToString() + " DROUsages";
|
return $"{list.Items.Count} DROUsages";
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ using Csla;
|
|||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@@ -35,79 +34,76 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static string _DBServer = null;
|
private static string _DBServer = null;
|
||||||
private static DateTime _RevDate=DateTime.MinValue;
|
private static DateTime _RevDate=DateTime.MinValue;
|
||||||
|
|
||||||
public static DateTime RevDate
|
public static DateTime RevDate
|
||||||
{
|
{
|
||||||
get { return Database._RevDate; }
|
get { return _RevDate; }
|
||||||
set { Database._RevDate = value; }
|
set { _RevDate = value; }
|
||||||
}
|
}
|
||||||
private static string _RevDescription= "Unknown";
|
private static string _RevDescription= "Unknown";
|
||||||
|
|
||||||
public static string RevDescription
|
public static string RevDescription
|
||||||
{
|
|
||||||
get { return Database._RevDescription; }
|
|
||||||
set { Database._RevDescription = value; }
|
|
||||||
}
|
|
||||||
public static string DBServer
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_DBServer == null)
|
|
||||||
{
|
{
|
||||||
string cnstr = null;
|
get { return _RevDescription; }
|
||||||
try
|
set { _RevDescription = value; }
|
||||||
|
}
|
||||||
|
public static string DBServer
|
||||||
|
{
|
||||||
|
get
|
||||||
{
|
{
|
||||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
if (_DBServer == null)
|
||||||
{
|
{
|
||||||
cnstr = cn.ConnectionString;
|
string cnstr = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (SqlCommand cmd = new SqlCommand("vesp_GetSQLCodeRevision", cn))
|
using (SqlConnection cn = VEPROMS_SqlConnection)
|
||||||
{
|
{
|
||||||
cmd.CommandType = CommandType.StoredProcedure;
|
cnstr = cn.ConnectionString;
|
||||||
cmd.CommandTimeout = 0;
|
try
|
||||||
SqlDataReader dr = cmd.ExecuteReader();
|
|
||||||
while (dr.Read())
|
|
||||||
{
|
{
|
||||||
_RevDate = dr.GetDateTime(0);
|
using (SqlCommand cmd = new SqlCommand("vesp_GetSQLCodeRevision", cn))
|
||||||
_RevDescription = dr.GetString(1);
|
{
|
||||||
|
cmd.CommandType = CommandType.StoredProcedure;
|
||||||
|
cmd.CommandTimeout = 0;
|
||||||
|
SqlDataReader dr = cmd.ExecuteReader();
|
||||||
|
while (dr.Read())
|
||||||
|
{
|
||||||
|
_RevDate = dr.GetDateTime(0);
|
||||||
|
_RevDescription = dr.GetString(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
_RevDate = DateTime.MinValue;
|
||||||
|
_RevDescription = "Unknown";
|
||||||
|
}
|
||||||
|
string server = "";
|
||||||
|
string db = "";
|
||||||
|
Match m = Regex.Match(cnstr, "Data Source=([^;]+)(;[^;]+)*;*Initial Catalog=([^;]+)(;[^;]+)*");
|
||||||
|
if (m.Success && m.Groups.Count > 4)
|
||||||
|
{
|
||||||
|
server = m.Groups[1].Value;
|
||||||
|
db = m.Groups[3].Value;
|
||||||
|
}
|
||||||
|
_DBServer = string.Format("{0} - {1} [SQL:{2:yyMM.ddHH}]", server, db, RevDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
_RevDate = DateTime.MinValue;
|
_DBServer = cnstr;
|
||||||
_RevDescription = "Unknown";
|
|
||||||
}
|
}
|
||||||
string server = "";
|
|
||||||
string db = "";
|
|
||||||
Match m = Regex.Match(cnstr, "Data Source=([^;]+)(;[^;]+)*;*Initial Catalog=([^;]+)(;[^;]+)*");
|
|
||||||
if (m.Success && m.Groups.Count > 4)
|
|
||||||
{
|
|
||||||
server = m.Groups[1].Value;
|
|
||||||
db = m.Groups[3].Value;
|
|
||||||
}
|
|
||||||
_DBServer = string.Format("{0} - {1} [SQL:{2:yyMM.ddHH}]", server, db, RevDate);
|
|
||||||
}
|
}
|
||||||
}
|
return _DBServer;
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
_DBServer = cnstr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _DBServer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private static int _DefaultTimeout = 600; // 600 seconds, i.e. 10 minutes
|
private static int _DefaultTimeout = 600; // 600 seconds, i.e. 10 minutes
|
||||||
public static int DefaultTimeout
|
public static int DefaultTimeout
|
||||||
{
|
{
|
||||||
get { return _DefaultTimeout; }
|
get { return _DefaultTimeout; }
|
||||||
set { _DefaultTimeout = value; }
|
set { _DefaultTimeout = value; }
|
||||||
}
|
}
|
||||||
public static int SQLTimeout
|
public static int SQLTimeout => _DefaultTimeout / 20;
|
||||||
{
|
public static void LogException(string s, Exception ex)
|
||||||
get { return _DefaultTimeout/20; }
|
|
||||||
}
|
|
||||||
public static void LogException(string s, Exception ex)
|
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Console.WriteLine("Error - {0}", s);
|
Console.WriteLine("Error - {0}", s);
|
||||||
@@ -122,7 +118,7 @@ public static string DBServer
|
|||||||
get { return _LoggingInfo; }
|
get { return _LoggingInfo; }
|
||||||
set { _LoggingInfo = value; }
|
set { _LoggingInfo = value; }
|
||||||
}
|
}
|
||||||
static System.Diagnostics.Process _CurrentProcess = System.Diagnostics.Process.GetCurrentProcess();
|
static readonly System.Diagnostics.Process _CurrentProcess = Process.GetCurrentProcess();
|
||||||
public static void LogInfo(string s, int hashCode)
|
public static void LogInfo(string s, int hashCode)
|
||||||
{
|
{
|
||||||
if (_LoggingInfo)
|
if (_LoggingInfo)
|
||||||
@@ -136,8 +132,8 @@ public static string DBServer
|
|||||||
private static string _ConnectionName = "VEPROMS";
|
private static string _ConnectionName = "VEPROMS";
|
||||||
public static string ConnectionName
|
public static string ConnectionName
|
||||||
{
|
{
|
||||||
get { return Database._ConnectionName; }
|
get { return _ConnectionName; }
|
||||||
set { Database._ConnectionName = value; _VEPROMS_Connection = null; /* Reset Connection */ }
|
set { _ConnectionName = value; _VEPROMS_Connection = null; /* Reset Connection */ }
|
||||||
}
|
}
|
||||||
private static bool _TrackDBUsage = false;
|
private static bool _TrackDBUsage = false;
|
||||||
public static bool TrackDBUsage
|
public static bool TrackDBUsage
|
||||||
@@ -145,7 +141,8 @@ public static string DBServer
|
|||||||
get { return _TrackDBUsage; }
|
get { return _TrackDBUsage; }
|
||||||
set { _TrackDBUsage = value; }
|
set { _TrackDBUsage = value; }
|
||||||
}
|
}
|
||||||
private static Dictionary<string, int> _Methods = new Dictionary<string, int>();
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
|
private static Dictionary<string, int> _Methods = new Dictionary<string, int>();
|
||||||
public static void ShowDBTracking(string fileName)
|
public static void ShowDBTracking(string fileName)
|
||||||
{
|
{
|
||||||
DebugDBTrack.Open(VlnSettings.TemporaryFolder + "\\" + fileName);
|
DebugDBTrack.Open(VlnSettings.TemporaryFolder + "\\" + fileName);
|
||||||
@@ -159,12 +156,7 @@ public static string DBServer
|
|||||||
{
|
{
|
||||||
if (TrackDBUsage)
|
if (TrackDBUsage)
|
||||||
{
|
{
|
||||||
string str = Volian.Base.Library.vlnStackTrace.CalledFromCSLA;
|
string str = vlnStackTrace.CalledFromCSLA;
|
||||||
//if (str.Contains("ItemAndChildren"))
|
|
||||||
//{
|
|
||||||
// ShowDictionary(Methods);
|
|
||||||
// Methods = new Dictionary<string, int>();
|
|
||||||
//}
|
|
||||||
if (!_Methods.ContainsKey(str))
|
if (!_Methods.ContainsKey(str))
|
||||||
_Methods.Add(str, 1);
|
_Methods.Add(str, 1);
|
||||||
else
|
else
|
||||||
@@ -177,7 +169,7 @@ public static string DBServer
|
|||||||
DateTime.Today.ToLongDateString();
|
DateTime.Today.ToLongDateString();
|
||||||
// If DBConnection.XML exists, use the connection string from DBConnection.XML
|
// If DBConnection.XML exists, use the connection string from DBConnection.XML
|
||||||
string cnOverride = System.Windows.Forms.Application.StartupPath + @"\DBConnection.XML";
|
string cnOverride = System.Windows.Forms.Application.StartupPath + @"\DBConnection.XML";
|
||||||
if (System.IO.File.Exists(cnOverride))
|
if (File.Exists(cnOverride))
|
||||||
{
|
{
|
||||||
System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
|
System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
|
||||||
xd.Load(cnOverride);
|
xd.Load(cnOverride);
|
||||||
@@ -209,12 +201,8 @@ public static string DBServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Otherwise get the value from the ConfigurationManager
|
// Otherwise get the value from the ConfigurationManager
|
||||||
ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings[ConnectionName];
|
ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings[ConnectionName] ?? throw new ApplicationException("Database.cs Could not find connection " + ConnectionName);
|
||||||
if (cs == null)
|
string constr = FixServer(cs.ConnectionString);
|
||||||
{
|
|
||||||
throw new ApplicationException("Database.cs Could not find connection " + ConnectionName);
|
|
||||||
}
|
|
||||||
string constr = FixServer(cs.ConnectionString);
|
|
||||||
if (constr.Contains("{MENU}"))
|
if (constr.Contains("{MENU}"))
|
||||||
{
|
{
|
||||||
constr = ChooseDatabase(constr);
|
constr = ChooseDatabase(constr);
|
||||||
@@ -240,10 +228,10 @@ public static string DBServer
|
|||||||
}
|
}
|
||||||
private static string FixServer(string connectionString)
|
private static string FixServer(string connectionString)
|
||||||
{
|
{
|
||||||
string serverName = Volian.Base.Library.VlnSettings.GetServer();
|
string serverName = VlnSettings.GetServer();
|
||||||
if (serverName != null && serverName != "")
|
if (serverName != null && serverName != "")
|
||||||
{
|
{
|
||||||
System.Text.RegularExpressions.Match mServer = System.Text.RegularExpressions.Regex.Match(connectionString, ".*Data Source=([^;]*).*");
|
System.Text.RegularExpressions.Match mServer = Regex.Match(connectionString, ".*Data Source=([^;]*).*");
|
||||||
if (mServer.Success)
|
if (mServer.Success)
|
||||||
{
|
{
|
||||||
connectionString = connectionString.Substring(0, mServer.Groups[1].Index) + serverName + connectionString.Substring(mServer.Groups[1].Index + mServer.Groups[1].Length);
|
connectionString = connectionString.Substring(0, mServer.Groups[1].Index) + serverName + connectionString.Substring(mServer.Groups[1].Index + mServer.Groups[1].Length);
|
||||||
@@ -254,24 +242,22 @@ public static string DBServer
|
|||||||
private static string _SelectedDatabase;
|
private static string _SelectedDatabase;
|
||||||
public static string SelectedDatabase
|
public static string SelectedDatabase
|
||||||
{
|
{
|
||||||
get { return Database._SelectedDatabase; }
|
get { return _SelectedDatabase; }
|
||||||
set { Database._SelectedDatabase = value; }
|
set { _SelectedDatabase = value; }
|
||||||
}
|
}
|
||||||
public static string ActiveDatabase
|
public static string ActiveDatabase
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
string activeDatabase = SelectedDatabase;
|
string activeDatabase = SelectedDatabase ?? Regex.Replace(VEPROMS_Connection, "^.*Initial Catalog=([^;]*);.*$", "$1", RegexOptions.IgnoreCase);
|
||||||
if(activeDatabase == null)
|
return activeDatabase;
|
||||||
activeDatabase = Regex.Replace(VEPROMS_Connection, "^.*Initial Catalog=([^;]*);.*$", "$1", RegexOptions.IgnoreCase);
|
|
||||||
return activeDatabase;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static string _LastDatabase="NoDefault";
|
private static string _LastDatabase="NoDefault";
|
||||||
public static string LastDatabase
|
public static string LastDatabase
|
||||||
{
|
{
|
||||||
get { return Database._LastDatabase; }
|
get { return _LastDatabase; }
|
||||||
set { Database._LastDatabase = value; }
|
set { _LastDatabase = value; }
|
||||||
}
|
}
|
||||||
private static string ChooseDatabase(string constr)
|
private static string ChooseDatabase(string constr)
|
||||||
{
|
{
|
||||||
@@ -300,95 +286,98 @@ public static string DBServer
|
|||||||
return constr.Replace("{MENU}", _SelectedDatabase);
|
return constr.Replace("{MENU}", _SelectedDatabase);
|
||||||
}
|
}
|
||||||
private static System.Windows.Forms.ContextMenuStrip BuildDatabaseMenu(string constr)
|
private static System.Windows.Forms.ContextMenuStrip BuildDatabaseMenu(string constr)
|
||||||
{
|
{
|
||||||
string tmp = constr.Replace("{MENU}", "master");
|
string tmp = constr.Replace("{MENU}", "master");
|
||||||
SqlConnection cn = new SqlConnection(tmp);
|
using (SqlConnection cn = new SqlConnection(tmp))
|
||||||
cn.Open();
|
{
|
||||||
// SqlDataAdapter da = new SqlDataAdapter("select name from sysdatabases where name like 'VEP%' order by name", cn);
|
cn.Open();
|
||||||
//SqlDataAdapter da = new SqlDataAdapter("select name, case when object_id('[' + name + ']..Items') is null then 'Not PROMS' when object_id('[' + name + ']..Revisions') is not null then 'Approval' when object_id('[' + name + ']..ContentAudits') is not null then 'Change Manager' else 'Original' end functionality from sysdatabases where name not in ('master','model','msdb','tempdb') order by name", cn);
|
using (SqlDataAdapter da = new SqlDataAdapter("select name, 'Approval' functionality from sysdatabases where name not in ('master','model','msdb','tempdb') order by name", cn))
|
||||||
SqlDataAdapter da = new SqlDataAdapter("select name, 'Approval' functionality from sysdatabases where name not in ('master','model','msdb','tempdb') order by name", cn);
|
{
|
||||||
da.SelectCommand.CommandTimeout = 300; // 300 sec timeout
|
da.SelectCommand.CommandTimeout = 300; // 300 sec timeout
|
||||||
DataSet ds = new DataSet();
|
DataSet ds = new DataSet();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
da.Fill(ds);
|
da.Fill(ds);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
System.Windows.Forms.MessageBox.Show(ex.GetType().Name, ex.Message);
|
System.Windows.Forms.MessageBox.Show(ex.GetType().Name, ex.Message);
|
||||||
throw(new Exception("Cannot Load Data List",ex));
|
throw (new Exception("Cannot Load Data List", ex));
|
||||||
}
|
}
|
||||||
cn.Close();
|
cn.Close();
|
||||||
System.Windows.Forms.ContextMenuStrip cms = new System.Windows.Forms.ContextMenuStrip();
|
System.Windows.Forms.ContextMenuStrip cms = new System.Windows.Forms.ContextMenuStrip();
|
||||||
cms.Items.Add("Choose Database");
|
cms.Items.Add("Choose Database");
|
||||||
System.Windows.Forms.ToolStripMenuItem tsmi = cms.Items[0] as System.Windows.Forms.ToolStripMenuItem;
|
System.Windows.Forms.ToolStripMenuItem tsmi = cms.Items[0] as System.Windows.Forms.ToolStripMenuItem;
|
||||||
tsmi.BackColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.ActiveCaption);// System.Drawing.Color.Pink;
|
tsmi.BackColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.ActiveCaption);// System.Drawing.Color.Pink;
|
||||||
tsmi.ForeColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.ActiveCaptionText);
|
tsmi.ForeColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.ActiveCaptionText);
|
||||||
tsmi.Font = new System.Drawing.Font(tsmi.Font, System.Drawing.FontStyle.Bold);
|
tsmi.Font = new System.Drawing.Font(tsmi.Font, System.Drawing.FontStyle.Bold);
|
||||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||||
{
|
{
|
||||||
if (dr["functionality"].ToString() == "Approval" && !dr["name"].ToString().EndsWith("_RO")) // don't display sql ro databases in list
|
if (dr["functionality"].ToString() == "Approval" && !dr["name"].ToString().EndsWith("_RO")) // don't display sql ro databases in list
|
||||||
cms.Items.Add(dr["name"].ToString(), null, new EventHandler(Database_Click));
|
cms.Items.Add(dr["name"].ToString(), null, new EventHandler(Database_Click));
|
||||||
}
|
}
|
||||||
return cms;
|
return cms;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void Database_Click(object sender, EventArgs e)
|
static void Database_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
System.Windows.Forms.ToolStripMenuItem tsmi = sender as System.Windows.Forms.ToolStripMenuItem;
|
if (sender is System.Windows.Forms.ToolStripMenuItem tsmi)
|
||||||
if (tsmi != null)
|
{
|
||||||
{
|
_SelectedDatabase = tsmi.Text;
|
||||||
_SelectedDatabase = tsmi.Text;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static SqlConnection VEPROMS_SqlConnection
|
public static SqlConnection VEPROMS_SqlConnection
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
string strConn = VEPROMS_Connection; // If failure - Fail (Don't try to catch)
|
string strConn = VEPROMS_Connection; // If failure - Fail (Don't try to catch)
|
||||||
// Attempt to make a connection
|
// Attempt to make a connection
|
||||||
|
|
||||||
|
//note - cannot use using here as it will close the connection and it needs to return it as open
|
||||||
SqlConnection cn = new SqlConnection(strConn);
|
SqlConnection cn = new SqlConnection(strConn);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cn.Open();
|
cn.Open();
|
||||||
return cn;
|
return cn;
|
||||||
}
|
}
|
||||||
catch (SqlException exsql)
|
catch (SqlException exsql)
|
||||||
{
|
{
|
||||||
const string strAttachError = "An attempt to attach an auto-named database for file ";
|
const string strAttachError = "An attempt to attach an auto-named database for file ";
|
||||||
if (exsql.Message.StartsWith(strAttachError))
|
if (exsql.Message.StartsWith(strAttachError))
|
||||||
{// Check to see if the file is missing
|
{// Check to see if the file is missing
|
||||||
string sFile = exsql.Message.Substring(strAttachError.Length);
|
string sFile = exsql.Message.Substring(strAttachError.Length);
|
||||||
sFile = sFile.Substring(0, sFile.IndexOf(" failed"));
|
sFile = sFile.Substring(0, sFile.IndexOf(" failed"));
|
||||||
// "An attempt to attach an auto-named database for file <mdf file> failed"
|
// "An attempt to attach an auto-named database for file <mdf file> failed"
|
||||||
if (strConn.ToLower().IndexOf("user instance=true") < 0)
|
if (strConn.ToLower().IndexOf("user instance=true") < 0)
|
||||||
{
|
{
|
||||||
throw new ApplicationException("Connection String missing attribute: User Instance=True");
|
throw new ApplicationException("Connection String missing attribute: User Instance=True");
|
||||||
}
|
}
|
||||||
if (System.IO.File.Exists(sFile))
|
if (File.Exists(sFile))
|
||||||
{
|
{
|
||||||
throw new ApplicationException("Database file " + sFile + " Cannot be opened\r\n", exsql);
|
throw new ApplicationException("Database file " + sFile + " Cannot be opened\r\n", exsql);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new FileNotFoundException("Database file " + sFile + " Not Found", exsql);
|
throw new FileNotFoundException("Database file " + sFile + " Not Found", exsql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Open a MesageBox so the user is given some feedback that the connection has failed.
|
//Open a MesageBox so the user is given some feedback that the connection has failed.
|
||||||
ReportInnermostException(exsql,strConn);
|
ReportInnermostException(exsql, strConn);
|
||||||
throw new ApplicationException("Failure on Connect", exsql);
|
throw new ApplicationException("Failure on Connect", exsql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)// Throw Application Exception on Failure
|
catch (Exception ex)// Throw Application Exception on Failure
|
||||||
{
|
{
|
||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection Error", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection Error", ex);
|
||||||
throw new ApplicationException("Failure on Connect", ex);
|
throw new ApplicationException("Failure on Connect", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Open a MessageBox with the exception type, the connection string and the exception message
|
/// Open a MessageBox with the exception type, the connection string and the exception message
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -400,15 +389,13 @@ public static string DBServer
|
|||||||
while (ex.InnerException != null)
|
while (ex.InnerException != null)
|
||||||
ex = ex.InnerException;
|
ex = ex.InnerException;
|
||||||
System.Windows.Forms.MessageBox.Show(string.Format("{0}\r\n\r\nConnection String ={1}", ex.Message,conn)
|
System.Windows.Forms.MessageBox.Show(string.Format("{0}\r\n\r\nConnection String ={1}", ex.Message,conn)
|
||||||
,"PROMS - " + ex.GetType().FullName, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
|
, $"PROMS - {ex.GetType().FullName}", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
|
||||||
System.Diagnostics.Process.GetCurrentProcess().Kill();
|
Process.GetCurrentProcess().Kill();
|
||||||
}
|
}
|
||||||
public static void PurgeData()
|
public static void PurgeData()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//SqlConnection cn = VEPROMS_SqlConnection;
|
|
||||||
//SqlCommand cmd = new SqlCommand("purgedata", cn);
|
|
||||||
using (SqlConnection cn = VEPROMS_SqlConnection)
|
using (SqlConnection cn = VEPROMS_SqlConnection)
|
||||||
{
|
{
|
||||||
using (SqlCommand cmd = new SqlCommand("purgedata", cn))
|
using (SqlCommand cmd = new SqlCommand("purgedata", cn))
|
||||||
@@ -458,8 +445,6 @@ public static string DBServer
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//SqlConnection cn = VEPROMS_SqlConnection;
|
|
||||||
//SqlCommand cmd = new SqlCommand("purgedata", cn);
|
|
||||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||||
{
|
{
|
||||||
using (SqlCommand cmd = new SqlCommand("purgedata", cn))
|
using (SqlCommand cmd = new SqlCommand("purgedata", cn))
|
||||||
@@ -483,11 +468,8 @@ public static string DBServer
|
|||||||
{
|
{
|
||||||
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);
|
||||||
private string _ErrorMessage = string.Empty;
|
private string _ErrorMessage = string.Empty;
|
||||||
public string ErrorMessage
|
public string ErrorMessage => _ErrorMessage;
|
||||||
{
|
private ProposedTransition _ProposedTransition;
|
||||||
get { return _ErrorMessage; }
|
|
||||||
}
|
|
||||||
private ProposedTransition _ProposedTransition;
|
|
||||||
public ProposedTransition ProposedTransition
|
public ProposedTransition ProposedTransition
|
||||||
{
|
{
|
||||||
get { return _ProposedTransition; }
|
get { return _ProposedTransition; }
|
||||||
@@ -508,10 +490,12 @@ public static string DBServer
|
|||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
public static ProposedTransition Execute(int fromID, int toID)
|
public static ProposedTransition Execute(int fromID, int toID)
|
||||||
{
|
{
|
||||||
CanTransitionBeCreatedCommand cmd = new CanTransitionBeCreatedCommand();
|
CanTransitionBeCreatedCommand cmd = new CanTransitionBeCreatedCommand
|
||||||
cmd.FromID = fromID;
|
{
|
||||||
cmd.ToID = toID;
|
FromID = fromID,
|
||||||
cmd = DataPortal.Execute<CanTransitionBeCreatedCommand>(cmd);
|
ToID = toID
|
||||||
|
};
|
||||||
|
cmd = DataPortal.Execute<CanTransitionBeCreatedCommand>(cmd);
|
||||||
return cmd.ProposedTransition;
|
return cmd.ProposedTransition;
|
||||||
}
|
}
|
||||||
private CanTransitionBeCreatedCommand()
|
private CanTransitionBeCreatedCommand()
|
||||||
@@ -536,8 +520,6 @@ public static string DBServer
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//SqlConnection cn = VEPROMS_SqlConnection;
|
|
||||||
//SqlCommand cmd = new SqlCommand("purgedata", cn);
|
|
||||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||||
{
|
{
|
||||||
using (SqlCommand cmd = new SqlCommand("vesp_CanTransitionBeCreated", cn))
|
using (SqlCommand cmd = new SqlCommand("vesp_CanTransitionBeCreated", cn))
|
||||||
@@ -571,16 +553,10 @@ public static string DBServer
|
|||||||
{
|
{
|
||||||
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);
|
||||||
private string _ErrorMessage = string.Empty;
|
private string _ErrorMessage = string.Empty;
|
||||||
public string ErrorMessage
|
public string ErrorMessage => _ErrorMessage;
|
||||||
{
|
private List<InvalidTransition> _InvalidTransitions;
|
||||||
get { return _ErrorMessage; }
|
public List<InvalidTransition> InvalidTransitions => _InvalidTransitions;
|
||||||
}
|
private int _ItemID;
|
||||||
private List<InvalidTransition> _InvalidTransitions;
|
|
||||||
public List<InvalidTransition> InvalidTransitions
|
|
||||||
{
|
|
||||||
get { return _InvalidTransitions; }
|
|
||||||
}
|
|
||||||
private int _ItemID;
|
|
||||||
public int ItemID
|
public int ItemID
|
||||||
{
|
{
|
||||||
get { return _ItemID; }
|
get { return _ItemID; }
|
||||||
@@ -595,10 +571,12 @@ public static string DBServer
|
|||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
public static List<InvalidTransition> Execute(int itemID, string newAppl)
|
public static List<InvalidTransition> Execute(int itemID, string newAppl)
|
||||||
{
|
{
|
||||||
WillTransitionsBeValidCommand cmd = new WillTransitionsBeValidCommand();
|
WillTransitionsBeValidCommand cmd = new WillTransitionsBeValidCommand
|
||||||
cmd.ItemID = itemID;
|
{
|
||||||
cmd.NewAppl = newAppl;
|
ItemID = itemID,
|
||||||
cmd = DataPortal.Execute<WillTransitionsBeValidCommand>(cmd);
|
NewAppl = newAppl
|
||||||
|
};
|
||||||
|
cmd = DataPortal.Execute<WillTransitionsBeValidCommand>(cmd);
|
||||||
return cmd.InvalidTransitions;
|
return cmd.InvalidTransitions;
|
||||||
}
|
}
|
||||||
private WillTransitionsBeValidCommand()
|
private WillTransitionsBeValidCommand()
|
||||||
@@ -626,8 +604,6 @@ public static string DBServer
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//SqlConnection cn = VEPROMS_SqlConnection;
|
|
||||||
//SqlCommand cmd = new SqlCommand("purgedata", cn);
|
|
||||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||||
{
|
{
|
||||||
using (SqlCommand cmd = new SqlCommand("vesp_WillTransitionsBeValid", cn))
|
using (SqlCommand cmd = new SqlCommand("vesp_WillTransitionsBeValid", cn))
|
||||||
|
|||||||
@@ -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)
|
||||||
refreshDetails.Add(this);
|
refreshDetails.Add(this);
|
||||||
}
|
}
|
||||||
private void ClearRefreshList()
|
private void ClearRefreshList() => _RefreshDetails = new List<Detail>();
|
||||||
{
|
|
||||||
_RefreshDetails = new List<Detail>();
|
|
||||||
}
|
|
||||||
private void BuildRefreshList()
|
private void BuildRefreshList()
|
||||||
{
|
{
|
||||||
ClearRefreshList();
|
ClearRefreshList();
|
||||||
@@ -57,6 +52,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<Detail> _CacheList = new List<Detail>();
|
private static List<Detail> _CacheList = new List<Detail>();
|
||||||
protected static void AddToCache(Detail detail)
|
protected static void AddToCache(Detail detail)
|
||||||
{
|
{
|
||||||
@@ -66,6 +62,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(detail)) _CacheList.Remove(detail); // In RemoveFromCache
|
while (_CacheList.Contains(detail)) _CacheList.Remove(detail); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<Detail>> _CacheByPrimaryKey = new Dictionary<string, List<Detail>>();
|
private static Dictionary<string, List<Detail>> _CacheByPrimaryKey = new Dictionary<string, List<Detail>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -91,15 +88,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 _nextDetailID = -1;
|
private static int _nextDetailID = -1;
|
||||||
public static int NextDetailID
|
public static int NextDetailID => _nextDetailID--;
|
||||||
{
|
|
||||||
get { return _nextDetailID--; }
|
|
||||||
}
|
|
||||||
private int _DetailID;
|
private int _DetailID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int DetailID
|
public int DetailID
|
||||||
@@ -248,37 +239,22 @@ 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 || (_MyContent == null ? false : _MyContent.IsDirtyList(list));
|
return base.IsDirty || (_MyContent != null && _MyContent.IsDirtyList(list));
|
||||||
}
|
|
||||||
public override bool IsValid
|
|
||||||
{
|
|
||||||
get { return IsValidList(new List<object>()); }
|
|
||||||
}
|
}
|
||||||
|
public override bool IsValid => IsValidList(new List<object>());
|
||||||
public bool IsValidList(List<object> list)
|
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) && (_MyContent == null ? true : _MyContent.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_MyContent == null || _MyContent.IsValidList(list));
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base Detail.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current Detail</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check Detail.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check Detail.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 Detail</returns>
|
/// <returns>A Unique ID for the current Detail</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyDetailUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyDetailUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
@@ -307,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()
|
||||||
@@ -345,35 +321,11 @@ 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
|
#endregion
|
||||||
#region Authorization Rules
|
#region Authorization Rules
|
||||||
protected override void AddAuthorizationRules()
|
protected override void AddAuthorizationRules()
|
||||||
{
|
{
|
||||||
//CSLATODO: Who can read/write which fields
|
//CSLATODO: Who can read/write which fields
|
||||||
//AuthorizationRules.AllowRead(DetailID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ItemType, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Text, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ContentID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ItemType, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Text, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
|
||||||
_DetailExtension.AddAuthorizationRules(AuthorizationRules);
|
_DetailExtension.AddAuthorizationRules(AuthorizationRules);
|
||||||
}
|
}
|
||||||
protected override void AddInstanceAuthorizationRules()
|
protected override void AddInstanceAuthorizationRules()
|
||||||
@@ -381,42 +333,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//CSLATODO: Who can read/write which fields
|
//CSLATODO: Who can read/write which fields
|
||||||
_DetailExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
_DetailExtension.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 _DetailUnique = 0;
|
private static int _DetailUnique = 0;
|
||||||
protected static int DetailUnique
|
protected static int DetailUnique => ++_DetailUnique;
|
||||||
{ get { return ++_DetailUnique; } }
|
private readonly int _MyDetailUnique = DetailUnique;
|
||||||
private int _MyDetailUnique = DetailUnique;
|
// Absolutely Unique ID - Editable
|
||||||
public int MyDetailUnique // Absolutely Unique ID - Editable
|
public int MyDetailUnique => _MyDetailUnique;
|
||||||
{ get { return _MyDetailUnique; } }
|
|
||||||
protected Detail()
|
protected Detail()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -425,15 +349,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; } }
|
|
||||||
~Detail()
|
~Detail()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -458,8 +378,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Detail New()
|
public static Detail New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Detail");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<Detail>();
|
return DataPortal.Create<Detail>();
|
||||||
@@ -531,8 +449,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Detail Get(int detailID)
|
public static Detail Get(int detailID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a Detail");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Detail tmp = GetCachedByPrimaryKey(detailID);
|
Detail tmp = GetCachedByPrimaryKey(detailID);
|
||||||
@@ -558,14 +474,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dr.Read()) return new Detail(dr);
|
if (dr.Read()) return new Detail(dr);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
internal Detail(SafeDataReader dr)
|
internal Detail(SafeDataReader dr) => ReadData(dr);
|
||||||
{
|
|
||||||
ReadData(dr);
|
|
||||||
}
|
|
||||||
public static void Delete(int detailID)
|
public static void Delete(int detailID)
|
||||||
{
|
{
|
||||||
if (!CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Detail");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataPortal.Delete(new PKCriteria(detailID));
|
DataPortal.Delete(new PKCriteria(detailID));
|
||||||
@@ -577,12 +488,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public override Detail Save()
|
public override Detail Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Detail");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Detail");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a Detail");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -602,13 +507,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _DetailID;
|
private readonly int _DetailID;
|
||||||
public int DetailID
|
public int DetailID => _DetailID;
|
||||||
{ get { return _DetailID; } }
|
public PKCriteria(int detailID) => _DetailID = detailID;
|
||||||
public PKCriteria(int detailID)
|
|
||||||
{
|
|
||||||
_DetailID = detailID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 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()]
|
||||||
@@ -707,36 +608,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 (_MyContent != null) _MyContent.Update();
|
_MyContent?.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 = "addDetail";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@ContentID", ContentID);
|
cm.CommandText = "addDetail";
|
||||||
cm.Parameters.AddWithValue("@ItemType", _ItemType);
|
// Input All Fields - Except Calculated Columns
|
||||||
cm.Parameters.AddWithValue("@Text", _Text);
|
cm.Parameters.AddWithValue("@ContentID", ContentID);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@ItemType", _ItemType);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@Text", _Text);
|
||||||
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_DetailID = new SqlParameter("@newDetailID", SqlDbType.Int);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
param_DetailID.Direction = ParameterDirection.Output;
|
// Output Calculated Columns
|
||||||
cm.Parameters.Add(param_DetailID);
|
SqlParameter param_DetailID = new SqlParameter("@newDetailID", 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_DetailID);
|
||||||
cm.ExecuteNonQuery();
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
// Save all values being returned from the Procedure
|
{
|
||||||
_DetailID = (int)cm.Parameters["@newDetailID"].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
|
||||||
|
_DetailID = (int)cm.Parameters["@newDetailID"].Value;
|
||||||
|
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
// update child objects
|
// update child objects
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.SQLInsert", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.SQLInsert", GetHashCode());
|
||||||
@@ -767,11 +675,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_DetailID = new SqlParameter("@newDetailID", SqlDbType.Int);
|
SqlParameter param_DetailID = new SqlParameter("@newDetailID", SqlDbType.Int)
|
||||||
param_DetailID.Direction = ParameterDirection.Output;
|
{
|
||||||
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
cm.Parameters.Add(param_DetailID);
|
cm.Parameters.Add(param_DetailID);
|
||||||
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();
|
||||||
@@ -816,34 +728,39 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.SQLUpdate", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_MyContent != null) _MyContent.Update();
|
_MyContent?.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 = "updateDetail";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@DetailID", _DetailID);
|
cm.CommandText = "updateDetail";
|
||||||
cm.Parameters.AddWithValue("@ContentID", ContentID);
|
// All Fields including Calculated Fields
|
||||||
cm.Parameters.AddWithValue("@ItemType", _ItemType);
|
cm.Parameters.AddWithValue("@DetailID", _DetailID);
|
||||||
cm.Parameters.AddWithValue("@Text", _Text);
|
cm.Parameters.AddWithValue("@ContentID", ContentID);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@ItemType", _ItemType);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@Text", _Text);
|
||||||
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
|
||||||
}
|
}
|
||||||
@@ -856,14 +773,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 = Detail.Add(cn, ref _DetailID, _MyContent, _ItemType, _Text, _Config, _DTS, _UserID);
|
if (IsNew)
|
||||||
else
|
_LastChanged = Detail.Add(cn, ref _DetailID, _MyContent, _ItemType, _Text, _Config, _DTS, _UserID);
|
||||||
_LastChanged = Detail.Update(cn, ref _DetailID, _ContentID, _ItemType, _Text, _Config, _DTS, _UserID, ref _LastChanged);
|
else
|
||||||
|
_LastChanged = Detail.Update(cn, ref _DetailID, _ContentID, _ItemType, _Text, _Config, _DTS, _UserID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -888,8 +808,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();
|
||||||
@@ -974,16 +896,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ExistsCommand : CommandBase
|
private class ExistsCommand : CommandBase
|
||||||
{
|
{
|
||||||
private int _DetailID;
|
private readonly int _DetailID;
|
||||||
private bool _exists;
|
private bool _exists;
|
||||||
public bool Exists
|
public bool Exists => _exists;
|
||||||
{
|
public ExistsCommand(int detailID) => _DetailID = detailID;
|
||||||
get { return _exists; }
|
|
||||||
}
|
|
||||||
public ExistsCommand(int detailID)
|
|
||||||
{
|
|
||||||
_DetailID = detailID;
|
|
||||||
}
|
|
||||||
protected override void DataPortal_Execute()
|
protected override void DataPortal_Execute()
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.DataPortal_Execute", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.DataPortal_Execute", GetHashCode());
|
||||||
@@ -1013,7 +929,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
DetailExtension _DetailExtension = new DetailExtension();
|
readonly DetailExtension _DetailExtension = new DetailExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class DetailExtension : extensionBase
|
partial class DetailExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -1022,14 +938,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)
|
||||||
{
|
{
|
||||||
@@ -1058,57 +968,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 Detail)
|
if (destType == typeof(string) && value is Detail detail)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((Detail)value).ToString();
|
return detail.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 DetailExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class Detail
|
|
||||||
// {
|
|
||||||
// partial class DetailExtension : 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 DetailInfo : ReadOnlyBase<DetailInfo>, IDisposable
|
public partial class DetailInfo : ReadOnlyBase<DetailInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public event DetailInfoEvent Changed;
|
public event DetailInfoEvent 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<DetailInfo> _CacheList = new List<DetailInfo>();
|
private static List<DetailInfo> _CacheList = new List<DetailInfo>();
|
||||||
protected static void AddToCache(DetailInfo detailInfo)
|
protected static void AddToCache(DetailInfo detailInfo)
|
||||||
{
|
{
|
||||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(detailInfo)) _CacheList.Remove(detailInfo); // In RemoveFromCache
|
while (_CacheList.Contains(detailInfo)) _CacheList.Remove(detailInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<DetailInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DetailInfo>>();
|
private static Dictionary<string, List<DetailInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DetailInfo>>();
|
||||||
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 Detail _Editable;
|
protected Detail _Editable;
|
||||||
private IVEHasBrokenRules HasBrokenRules
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
IVEHasBrokenRules hasBrokenRules = null;
|
|
||||||
if (_Editable != null)
|
|
||||||
hasBrokenRules = _Editable.HasBrokenRules;
|
|
||||||
return hasBrokenRules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private int _DetailID;
|
private int _DetailID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int DetailID
|
public int DetailID
|
||||||
@@ -164,32 +148,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _UserID;
|
return _UserID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base DetailInfo.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current DetailInfo</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check DetailInfo.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check DetailInfo.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 DetailInfo</returns>
|
/// <returns>A Unique ID for the current DetailInfo</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyDetailInfoUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyDetailInfoUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _DetailInfoUnique = 0;
|
private static int _DetailInfoUnique = 0;
|
||||||
private static int DetailInfoUnique
|
private static int DetailInfoUnique => ++_DetailInfoUnique;
|
||||||
{ get { return ++_DetailInfoUnique; } }
|
private readonly int _MyDetailInfoUnique = DetailInfoUnique;
|
||||||
private int _MyDetailInfoUnique = DetailInfoUnique;
|
// Absolutely Unique ID - Info
|
||||||
public int MyDetailInfoUnique // Absolutely Unique ID - Info
|
public int MyDetailInfoUnique => _MyDetailInfoUnique;
|
||||||
{ get { return _MyDetailInfoUnique; } }
|
|
||||||
protected DetailInfo()
|
protected DetailInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -198,15 +169,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; } }
|
|
||||||
~DetailInfo()
|
~DetailInfo()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -223,10 +190,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (listDetailInfo.Count == 0) // If there are no items left in the list
|
if (listDetailInfo.Count == 0) // If there are no items left in the list
|
||||||
_CacheByPrimaryKey.Remove(DetailID.ToString()); // remove the list
|
_CacheByPrimaryKey.Remove(DetailID.ToString()); // remove the list
|
||||||
}
|
}
|
||||||
public virtual Detail Get()
|
public virtual Detail Get() => _Editable = Detail.Get(_DetailID);
|
||||||
{
|
|
||||||
return _Editable = Detail.Get(_DetailID);
|
|
||||||
}
|
|
||||||
public static void Refresh(Detail tmp)
|
public static void Refresh(Detail tmp)
|
||||||
{
|
{
|
||||||
string key = tmp.DetailID.ToString();
|
string key = tmp.DetailID.ToString();
|
||||||
@@ -239,11 +203,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_ContentID != tmp.ContentID)
|
if (_ContentID != tmp.ContentID)
|
||||||
{
|
{
|
||||||
if (MyContent != null) MyContent.RefreshContentDetails(); // Update List for old value
|
MyContent?.RefreshContentDetails(); // Update List for old value
|
||||||
_ContentID = tmp.ContentID; // Update the value
|
_ContentID = tmp.ContentID; // Update the value
|
||||||
}
|
}
|
||||||
_MyContent = null; // Reset list so that the next line gets a new list
|
_MyContent = null; // Reset list so that the next line gets a new list
|
||||||
if (MyContent != null) MyContent.RefreshContentDetails(); // Update List for new value
|
MyContent?.RefreshContentDetails(); // Update List for new value
|
||||||
_ItemType = tmp.ItemType;
|
_ItemType = tmp.ItemType;
|
||||||
_Text = tmp.Text;
|
_Text = tmp.Text;
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
@@ -272,8 +236,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static DetailInfo Get(int detailID)
|
public static DetailInfo Get(int detailID)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a Detail");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DetailInfo tmp = GetCachedByPrimaryKey(detailID);
|
DetailInfo tmp = GetCachedByPrimaryKey(detailID);
|
||||||
@@ -312,13 +274,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _DetailID;
|
private readonly int _DetailID;
|
||||||
public int DetailID
|
public int DetailID => _DetailID;
|
||||||
{ get { return _DetailID; } }
|
public PKCriteria(int detailID) => _DetailID = detailID;
|
||||||
public PKCriteria(int detailID)
|
|
||||||
{
|
|
||||||
_DetailID = detailID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void ReadData(SafeDataReader dr)
|
private void ReadData(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
@@ -379,7 +337,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
DetailInfoExtension _DetailInfoExtension = new DetailInfoExtension();
|
readonly DetailInfoExtension _DetailInfoExtension = new DetailInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class DetailInfoExtension : extensionBase { }
|
partial class DetailInfoExtension : extensionBase { }
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
@@ -395,10 +353,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 DetailInfo)
|
if (destType == typeof(string) && value is DetailInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((DetailInfo)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<DetailInfo> Items
|
internal new IList<DetailInfo> Items => base.Items;
|
||||||
{ get { return base.Items; } }
|
public void AddEvents()
|
||||||
public void AddEvents()
|
|
||||||
{
|
{
|
||||||
foreach (DetailInfo tmp in this)
|
foreach (DetailInfo 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
|
~DetailInfoList()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~DetailInfoList()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -97,26 +90,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on DetailInfoList.Get", ex);
|
throw new DbCslaException("Error on DetailInfoList.Get", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset the list of all DetailInfo.
|
/// Reset the list of all DetailInfo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Reset()
|
public static void Reset() => _DetailInfoList = null;
|
||||||
{
|
|
||||||
_DetailInfoList = null;
|
public static DetailInfoList GetByContentID(int contentID)
|
||||||
}
|
|
||||||
// CSLATODO: Add alternative gets -
|
|
||||||
//public static DetailInfoList Get(<criteria>)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// return DataPortal.Fetch<DetailInfoList>(new FilteredCriteria(<criteria>));
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// throw new DbCslaException("Error on DetailInfoList.Get", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
public static DetailInfoList GetByContentID(int contentID)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -166,11 +145,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ContentIDCriteria
|
private class ContentIDCriteria
|
||||||
{
|
{
|
||||||
public ContentIDCriteria(int contentID)
|
public ContentIDCriteria(int contentID) => _ContentID = contentID;
|
||||||
{
|
private int _ContentID;
|
||||||
_ContentID = contentID;
|
|
||||||
}
|
|
||||||
private int _ContentID;
|
|
||||||
public int ContentID
|
public int ContentID
|
||||||
{
|
{
|
||||||
get { return _ContentID; }
|
get { return _ContentID; }
|
||||||
@@ -207,41 +183,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);
|
||||||
@@ -263,7 +228,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class DetailInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class DetailInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private DetailInfo Item { get { return (DetailInfo)_Item; } }
|
|
||||||
public DetailInfoListPropertyDescriptor(DetailInfoList collection, int index) : base(collection, index) { ;}
|
public DetailInfoListPropertyDescriptor(DetailInfoList collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -272,10 +236,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 DetailInfoList)
|
if (destType == typeof(string) && value is DetailInfoList list)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((DetailInfoList)value).Items.Count.ToString() + " Details";
|
return $"{list.Items.Count} Details";
|
||||||
}
|
}
|
||||||
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;
|
||||||
@@ -72,6 +70,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<DocVersion> _CacheList = new List<DocVersion>();
|
private static List<DocVersion> _CacheList = new List<DocVersion>();
|
||||||
protected static void AddToCache(DocVersion docVersion)
|
protected static void AddToCache(DocVersion docVersion)
|
||||||
{
|
{
|
||||||
@@ -81,6 +80,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(docVersion)) _CacheList.Remove(docVersion); // In RemoveFromCache
|
while (_CacheList.Contains(docVersion)) _CacheList.Remove(docVersion); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<DocVersion>> _CacheByPrimaryKey = new Dictionary<string, List<DocVersion>>();
|
private static Dictionary<string, List<DocVersion>> _CacheByPrimaryKey = new Dictionary<string, List<DocVersion>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -106,15 +106,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 _nextVersionID = -1;
|
private static int _nextVersionID = -1;
|
||||||
public static int NextVersionID
|
public static int NextVersionID => _nextVersionID--;
|
||||||
{
|
|
||||||
get { return _nextVersionID--; }
|
|
||||||
}
|
|
||||||
private int _VersionID;
|
private int _VersionID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int VersionID
|
public int VersionID
|
||||||
@@ -362,10 +356,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _DocVersionAssociations;
|
return _DocVersionAssociations;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Reset_DocVersionAssociations()
|
public void Reset_DocVersionAssociations() => _DocVersionAssociationCount = -1;
|
||||||
{
|
|
||||||
_DocVersionAssociationCount = -1;
|
|
||||||
}
|
|
||||||
public override bool IsDirty
|
public override bool IsDirty
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -380,37 +371,22 @@ 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 || (_DocVersionAssociations == null ? false : _DocVersionAssociations.IsDirtyList(list)) || (_MyFolder == null ? false : _MyFolder.IsDirtyList(list)) || (_MyFormat == null ? false : _MyFormat.IsDirtyList(list)) || (_MyItem == null ? false : _MyItem.IsDirtyList(list));
|
return base.IsDirty || (_DocVersionAssociations != null && _DocVersionAssociations.IsDirtyList(list)) || (_MyFolder != null && _MyFolder.IsDirtyList(list)) || (_MyFormat != null && _MyFormat.IsDirtyList(list)) || (_MyItem != null && _MyItem.IsDirtyList(list));
|
||||||
}
|
|
||||||
public override bool IsValid
|
|
||||||
{
|
|
||||||
get { return IsValidList(new List<object>()); }
|
|
||||||
}
|
}
|
||||||
|
public override bool IsValid => IsValidList(new List<object>());
|
||||||
public bool IsValidList(List<object> list)
|
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) && (_DocVersionAssociations == null ? true : _DocVersionAssociations.IsValidList(list)) && (_MyFolder == null ? true : _MyFolder.IsValidList(list)) && (_MyFormat == null ? true : _MyFormat.IsValidList(list)) && (_MyItem == null ? true : _MyItem.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_DocVersionAssociations == null || _DocVersionAssociations.IsValidList(list)) && (_MyFolder == null || _MyFolder.IsValidList(list)) && (_MyFormat == null || _MyFormat.IsValidList(list)) && (_MyItem == null || _MyItem.IsValidList(list));
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base DocVersion.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current DocVersion</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check DocVersion.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check DocVersion.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 DocVersion</returns>
|
/// <returns>A Unique ID for the current DocVersion</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyDocVersionUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyDocVersionUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
@@ -442,8 +418,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()
|
||||||
@@ -483,41 +459,10 @@ 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
|
#endregion
|
||||||
#region Authorization Rules
|
#region Authorization Rules
|
||||||
protected override void AddAuthorizationRules()
|
protected override void AddAuthorizationRules()
|
||||||
{
|
{
|
||||||
//CSLATODO: Who can read/write which fields
|
|
||||||
//AuthorizationRules.AllowRead(VersionID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(VersionType, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(FormatID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(FolderID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(VersionType, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(FormatID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
|
||||||
_DocVersionExtension.AddAuthorizationRules(AuthorizationRules);
|
_DocVersionExtension.AddAuthorizationRules(AuthorizationRules);
|
||||||
}
|
}
|
||||||
protected override void AddInstanceAuthorizationRules()
|
protected override void AddInstanceAuthorizationRules()
|
||||||
@@ -525,55 +470,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//CSLATODO: Who can read/write which fields
|
//CSLATODO: Who can read/write which fields
|
||||||
_DocVersionExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
_DocVersionExtension.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 += _DocVersionAssociationCount;
|
|
||||||
return (usedByCount == 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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 _DocVersionUnique = 0;
|
private static int _DocVersionUnique = 0;
|
||||||
protected static int DocVersionUnique
|
protected static int DocVersionUnique => ++_DocVersionUnique;
|
||||||
{ get { return ++_DocVersionUnique; } }
|
private readonly int _MyDocVersionUnique = DocVersionUnique;
|
||||||
private int _MyDocVersionUnique = DocVersionUnique;
|
// Absolutely Unique ID - Editable
|
||||||
public int MyDocVersionUnique // Absolutely Unique ID - Editable
|
public int MyDocVersionUnique => _MyDocVersionUnique;
|
||||||
{ get { return _MyDocVersionUnique; } }
|
|
||||||
protected DocVersion()
|
protected DocVersion()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -582,15 +486,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; } }
|
|
||||||
~DocVersion()
|
~DocVersion()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -615,8 +515,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static DocVersion New()
|
public static DocVersion New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a DocVersion");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<DocVersion>();
|
return DataPortal.Create<DocVersion>();
|
||||||
@@ -692,8 +590,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static DocVersion Get(int versionID)
|
public static DocVersion Get(int versionID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a DocVersion");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DocVersion tmp = GetCachedByPrimaryKey(versionID);
|
DocVersion tmp = GetCachedByPrimaryKey(versionID);
|
||||||
@@ -725,8 +621,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static void Delete(int versionID)
|
public static void Delete(int versionID)
|
||||||
{
|
{
|
||||||
if (!CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a DocVersion");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataPortal.Delete(new PKCriteria(versionID));
|
DataPortal.Delete(new PKCriteria(versionID));
|
||||||
@@ -738,12 +632,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public override DocVersion Save()
|
public override DocVersion Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a DocVersion");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a DocVersion");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a DocVersion");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -763,13 +651,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _VersionID;
|
private readonly int _VersionID;
|
||||||
public int VersionID
|
public int VersionID => _VersionID;
|
||||||
{ get { return _VersionID; } }
|
public PKCriteria(int versionID) => _VersionID = versionID;
|
||||||
public PKCriteria(int versionID)
|
|
||||||
{
|
|
||||||
_VersionID = versionID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 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()]
|
||||||
@@ -876,44 +760,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 (_MyFormat != null) _MyFormat.Update();
|
_MyFormat?.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())
|
|
||||||
{
|
{
|
||||||
cm.CommandType = CommandType.StoredProcedure;
|
using (SqlCommand cm = cn.CreateCommand())
|
||||||
cm.CommandTimeout = Database.SQLTimeout;
|
{
|
||||||
cm.CommandText = "addDocVersion";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@FolderID", FolderID);
|
cm.CommandText = "addDocVersion";
|
||||||
cm.Parameters.AddWithValue("@VersionType", _VersionType);
|
// Input All Fields - Except Calculated Columns
|
||||||
cm.Parameters.AddWithValue("@Name", _Name);
|
cm.Parameters.AddWithValue("@FolderID", FolderID);
|
||||||
cm.Parameters.AddWithValue("@Title", _Title);
|
cm.Parameters.AddWithValue("@VersionType", _VersionType);
|
||||||
cm.Parameters.AddWithValue("@ItemID", ItemID);
|
cm.Parameters.AddWithValue("@Name", _Name);
|
||||||
cm.Parameters.AddWithValue("@FormatID", FormatID);
|
cm.Parameters.AddWithValue("@Title", _Title);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@ItemID", ItemID);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@FormatID", FormatID);
|
||||||
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_VersionID = new SqlParameter("@newVersionID", SqlDbType.Int);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
param_VersionID.Direction = ParameterDirection.Output;
|
// Output Calculated Columns
|
||||||
cm.Parameters.Add(param_VersionID);
|
SqlParameter param_VersionID = new SqlParameter("@newVersionID", 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_VersionID);
|
||||||
cm.ExecuteNonQuery();
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
// Save all values being returned from the Procedure
|
{
|
||||||
_VersionID = (int)cm.Parameters["@newVersionID"].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
|
||||||
|
_VersionID = (int)cm.Parameters["@newVersionID"].Value;
|
||||||
|
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
// update child objects
|
// update child objects
|
||||||
if (_DocVersionAssociations != null) _DocVersionAssociations.Update(this);
|
_DocVersionAssociations?.Update(this);
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.SQLInsert", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.SQLInsert", GetHashCode());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -945,11 +836,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_VersionID = new SqlParameter("@newVersionID", SqlDbType.Int);
|
SqlParameter param_VersionID = new SqlParameter("@newVersionID", SqlDbType.Int)
|
||||||
param_VersionID.Direction = ParameterDirection.Output;
|
{
|
||||||
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
cm.Parameters.Add(param_VersionID);
|
cm.Parameters.Add(param_VersionID);
|
||||||
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();
|
||||||
@@ -994,42 +889,47 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.SQLUpdate", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_MyFolder != null) _MyFolder.Update();
|
_MyFolder?.Update();
|
||||||
if (_MyFormat != null) _MyFormat.Update();
|
_MyFormat?.Update();
|
||||||
if (_MyItem != null) _MyItem.Update();
|
_MyItem?.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 = "updateDocVersion";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@VersionID", _VersionID);
|
cm.CommandText = "updateDocVersion";
|
||||||
cm.Parameters.AddWithValue("@FolderID", FolderID);
|
// All Fields including Calculated Fields
|
||||||
cm.Parameters.AddWithValue("@VersionType", _VersionType);
|
cm.Parameters.AddWithValue("@VersionID", _VersionID);
|
||||||
cm.Parameters.AddWithValue("@Name", _Name);
|
cm.Parameters.AddWithValue("@FolderID", FolderID);
|
||||||
cm.Parameters.AddWithValue("@Title", _Title);
|
cm.Parameters.AddWithValue("@VersionType", _VersionType);
|
||||||
cm.Parameters.AddWithValue("@ItemID", ItemID);
|
cm.Parameters.AddWithValue("@Name", _Name);
|
||||||
cm.Parameters.AddWithValue("@FormatID", FormatID);
|
cm.Parameters.AddWithValue("@Title", _Title);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@ItemID", ItemID);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@FormatID", FormatID);
|
||||||
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
|
||||||
if (_DocVersionAssociations != null) _DocVersionAssociations.Update(this);
|
_DocVersionAssociations?.Update(this);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -1040,17 +940,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 = DocVersion.Add(cn, ref _VersionID, _MyFolder, _VersionType, _Name, _Title, _MyItem, _MyFormat, _Config, _DTS, _UserID);
|
if (IsNew)
|
||||||
else
|
_LastChanged = DocVersion.Add(cn, ref _VersionID, _MyFolder, _VersionType, _Name, _Title, _MyItem, _MyFormat, _Config, _DTS, _UserID);
|
||||||
_LastChanged = DocVersion.Update(cn, ref _VersionID, _FolderID, _VersionType, _Name, _Title, _ItemID, _FormatID, _Config, _DTS, _UserID, ref _LastChanged);
|
else
|
||||||
|
_LastChanged = DocVersion.Update(cn, ref _VersionID, _FolderID, _VersionType, _Name, _Title, _ItemID, _FormatID, _Config, _DTS, _UserID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
if (_DocVersionAssociations != null) _DocVersionAssociations.Update(this);
|
_DocVersionAssociations?.Update(this);
|
||||||
}
|
}
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
public static byte[] Update(SqlConnection cn, ref int versionID, int folderID, int versionType, string name, string title, int? itemID, int? formatID, string config, DateTime dts, string userID, ref byte[] lastChanged)
|
public static byte[] Update(SqlConnection cn, ref int versionID, int folderID, int versionType, string name, string title, int? itemID, int? formatID, string config, DateTime dts, string userID, ref byte[] lastChanged)
|
||||||
@@ -1076,8 +979,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();
|
||||||
@@ -1162,16 +1067,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ExistsCommand : CommandBase
|
private class ExistsCommand : CommandBase
|
||||||
{
|
{
|
||||||
private int _VersionID;
|
private readonly int _VersionID;
|
||||||
private bool _exists;
|
private bool _exists;
|
||||||
public bool Exists
|
public bool Exists => _exists;
|
||||||
{
|
public ExistsCommand(int versionID) => _VersionID = versionID;
|
||||||
get { return _exists; }
|
|
||||||
}
|
|
||||||
public ExistsCommand(int versionID)
|
|
||||||
{
|
|
||||||
_VersionID = versionID;
|
|
||||||
}
|
|
||||||
protected override void DataPortal_Execute()
|
protected override void DataPortal_Execute()
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.DataPortal_Execute", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersion.DataPortal_Execute", GetHashCode());
|
||||||
@@ -1201,7 +1100,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
DocVersionExtension _DocVersionExtension = new DocVersionExtension();
|
readonly DocVersionExtension _DocVersionExtension = new DocVersionExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class DocVersionExtension : extensionBase
|
partial class DocVersionExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -1210,18 +1109,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
class extensionBase
|
class extensionBase
|
||||||
{
|
{
|
||||||
// Default Values
|
// Default Values
|
||||||
public virtual int DefaultVersionType
|
public virtual int DefaultVersionType => 0;
|
||||||
{
|
public virtual DateTime DefaultDTS => DateTime.Now;
|
||||||
get { return 0; }
|
public virtual string DefaultUserID => Volian.Base.Library.VlnSettings.UserID;
|
||||||
}
|
|
||||||
public virtual DateTime DefaultDTS
|
|
||||||
{
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -1250,61 +1140,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 DocVersion)
|
if (destType == typeof(string) && value is DocVersion version)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((DocVersion)value).ToString();
|
return version.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 DocVersionExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class DocVersion
|
|
||||||
// {
|
|
||||||
// partial class DocVersionExtension : extensionBase
|
|
||||||
// {
|
|
||||||
// // CSLATODO: Override automatic defaults
|
|
||||||
// public virtual int DefaultVersionType
|
|
||||||
// {
|
|
||||||
// get { return 0; }
|
|
||||||
// }
|
|
||||||
// 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,11 +28,8 @@ 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;
|
||||||
{
|
|
||||||
get { return _ErrorMessage; }
|
|
||||||
}
|
|
||||||
private int _AssociationID;
|
private int _AssociationID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int AssociationID
|
public int AssociationID
|
||||||
@@ -145,15 +139,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private byte[] _LastChanged = new byte[8];//timestamp
|
private byte[] _LastChanged = new byte[8];//timestamp
|
||||||
private int _ROFst_RODbID;
|
|
||||||
public int ROFst_RODbID
|
|
||||||
{
|
|
||||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _ROFst_RODbID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private byte[] _ROFst_ROLookup;
|
private byte[] _ROFst_ROLookup;
|
||||||
public byte[] ROFst_ROLookup
|
public byte[] ROFst_ROLookup
|
||||||
{
|
{
|
||||||
@@ -163,7 +148,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _ROFst_ROLookup;
|
return _ROFst_ROLookup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private string _ROFst_Config = string.Empty;
|
private readonly string _ROFst_Config = string.Empty;
|
||||||
public string ROFst_Config
|
public string ROFst_Config
|
||||||
{
|
{
|
||||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||||
@@ -172,7 +157,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _ROFst_Config;
|
return _ROFst_Config;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private DateTime _ROFst_DTS = new DateTime();
|
private readonly DateTime _ROFst_DTS = new DateTime();
|
||||||
public DateTime ROFst_DTS
|
public DateTime ROFst_DTS
|
||||||
{
|
{
|
||||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||||
@@ -181,7 +166,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _ROFst_DTS;
|
return _ROFst_DTS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private string _ROFst_UserID = string.Empty;
|
private readonly string _ROFst_UserID = string.Empty;
|
||||||
public string ROFst_UserID
|
public string ROFst_UserID
|
||||||
{
|
{
|
||||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||||
@@ -195,10 +180,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// 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 DocVersionAssociation</returns>
|
/// <returns>A Unique ID for the current DocVersionAssociation</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyDocVersionAssociationUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyDocVersionAssociationUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
// CSLATODO: Replace base DocVersionAssociation.ToString function as necessary
|
// CSLATODO: Replace base DocVersionAssociation.ToString function as necessary
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides Base ToString
|
/// Overrides Base ToString
|
||||||
@@ -222,18 +204,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 || (_MyROFst == null ? false : _MyROFst.IsDirtyList(list));
|
return base.IsDirty || (_MyROFst != null && _MyROFst.IsDirtyList(list));
|
||||||
}
|
|
||||||
public override bool IsValid
|
|
||||||
{
|
|
||||||
get { return IsValidList(new List<object>()); }
|
|
||||||
}
|
}
|
||||||
|
public override bool IsValid => IsValidList(new List<object>());
|
||||||
public bool IsValidList(List<object> list)
|
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) && (_MyROFst == null ? true : _MyROFst.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_MyROFst == null || _MyROFst.IsValidList(list));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
@@ -264,7 +243,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
||||||
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
|
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
|
||||||
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
|
return hasBrokenRules?.BrokenRules;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override void AddBusinessRules()
|
protected override void AddBusinessRules()
|
||||||
@@ -289,76 +268,21 @@ 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
|
#endregion
|
||||||
#region Authorization Rules
|
#region Authorization Rules
|
||||||
protected override void AddAuthorizationRules()
|
protected override void AddAuthorizationRules()
|
||||||
{
|
{
|
||||||
//CSLATODO: Who can read/write which fields
|
|
||||||
//AuthorizationRules.AllowRead(AssociationID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ROFstID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ROFstID, "<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
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
public int CurrentEditLevel
|
public int CurrentEditLevel => EditLevel;
|
||||||
{ get { return EditLevel; } }
|
|
||||||
private static int _DocVersionAssociationUnique = 0;
|
private static int _DocVersionAssociationUnique = 0;
|
||||||
private static int DocVersionAssociationUnique
|
private static int DocVersionAssociationUnique => ++_DocVersionAssociationUnique;
|
||||||
{ get { return ++_DocVersionAssociationUnique; } }
|
private readonly int _MyDocVersionAssociationUnique = DocVersionAssociationUnique;
|
||||||
private int _MyDocVersionAssociationUnique = DocVersionAssociationUnique;
|
// Absolutely Unique ID - Editable FK
|
||||||
public int MyDocVersionAssociationUnique // Absolutely Unique ID - Editable FK
|
public int MyDocVersionAssociationUnique => _MyDocVersionAssociationUnique;
|
||||||
{ get { return _MyDocVersionAssociationUnique; } }
|
internal static DocVersionAssociation New(ROFst myROFst) => new DocVersionAssociation(myROFst);
|
||||||
internal static DocVersionAssociation New(ROFst myROFst)
|
internal static DocVersionAssociation Get(SafeDataReader dr) => new DocVersionAssociation(dr);
|
||||||
{
|
|
||||||
return new DocVersionAssociation(myROFst);
|
|
||||||
}
|
|
||||||
internal static DocVersionAssociation Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new DocVersionAssociation(dr);
|
|
||||||
}
|
|
||||||
public DocVersionAssociation()
|
public DocVersionAssociation()
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
@@ -386,15 +310,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; } }
|
|
||||||
~DocVersionAssociation()
|
~DocVersionAssociation()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -420,12 +340,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
|
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
|
||||||
// B2023-020: setting RO Database on new working draft crashes. Query 'getAssociationsByVersionID' had been modified
|
// B2023-020: setting RO Database on new working draft crashes. Query 'getAssociationsByVersionID' had been modified
|
||||||
// for memory improvements to not return the ROFst values, so don't Get the values. Comment out for now.
|
// for memory improvements to not return the ROFst values, so don't Get the values. Comment out for now.
|
||||||
//_ROFst_RODbID = dr.GetInt32("ROFst_RODbID");
|
|
||||||
//_ROFst_ROLookup = (byte[])dr.GetValue("ROFst_ROLookup");
|
|
||||||
_ROFst_ROLookup = null; // B2022-026 RO Memory reduction - use ROlookup of null to know if we loaded the RO.FST file
|
_ROFst_ROLookup = null; // B2022-026 RO Memory reduction - use ROlookup of null to know if we loaded the RO.FST file
|
||||||
//_ROFst_Config = dr.GetString("ROFst_Config");
|
|
||||||
//_ROFst_DTS = dr.GetDateTime("ROFst_DTS");
|
|
||||||
//_ROFst_UserID = dr.GetString("ROFst_UserID");
|
|
||||||
}
|
}
|
||||||
catch (Exception ex) // FKItem Fetch
|
catch (Exception ex) // FKItem Fetch
|
||||||
{
|
{
|
||||||
@@ -438,32 +353,42 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
// 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 (!this.IsDirty) return;
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
_LastChanged = Association.Add(cn, ref _AssociationID, myDocVersion, _MyROFst, _Config, _DTS, _UserID);
|
{
|
||||||
|
_LastChanged = Association.Add(cn, ref _AssociationID, myDocVersion, _MyROFst, _Config, _DTS, _UserID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
internal void Update(DocVersion myDocVersion)
|
internal void Update(DocVersion myDocVersion)
|
||||||
{
|
{
|
||||||
// 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 (!this.IsDirty) return;
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
_LastChanged = Association.Update(cn, ref _AssociationID, myDocVersion.VersionID, _ROFstID, _Config, _DTS, _UserID, ref _LastChanged);
|
{
|
||||||
|
_LastChanged = Association.Update(cn, ref _AssociationID, myDocVersion.VersionID, _ROFstID, _Config, _DTS, _UserID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
internal void DeleteSelf(DocVersion myDocVersion)
|
internal void DeleteSelf(DocVersion myDocVersion)
|
||||||
{
|
{
|
||||||
// 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 (!this.IsDirty) return;
|
||||||
// if we're new then don't update the database
|
// if we're new then don't update the database
|
||||||
if (this.IsNew) return;
|
if (this.IsNew) return;
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
Association.Remove(cn, _AssociationID);
|
{
|
||||||
|
Association.Remove(cn, _AssociationID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkNew();
|
MarkNew();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
DocVersionAssociationExtension _DocVersionAssociationExtension = new DocVersionAssociationExtension();
|
readonly DocVersionAssociationExtension _DocVersionAssociationExtension = new DocVersionAssociationExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class DocVersionAssociationExtension : extensionBase
|
partial class DocVersionAssociationExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -472,14 +397,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)
|
||||||
{
|
{
|
||||||
@@ -508,57 +427,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 DocVersionAssociation)
|
if (destType == typeof(string) && value is DocVersionAssociation association)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((DocVersionAssociation)value).ToString();
|
return association.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 DocVersionAssociationExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class DocVersionAssociation
|
|
||||||
// {
|
|
||||||
// partial class DocVersionAssociationExtension : 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 DocVersionAssociation this[Association myAssociation]
|
||||||
}
|
|
||||||
// One To Many
|
|
||||||
public DocVersionAssociation this[Association myAssociation]
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -47,11 +42,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public new System.Collections.Generic.IList<DocVersionAssociation> Items
|
public new System.Collections.Generic.IList<DocVersionAssociation> Items => base.Items;
|
||||||
{
|
public DocVersionAssociation GetItem(Association myAssociation)
|
||||||
get { return base.Items; }
|
|
||||||
}
|
|
||||||
public DocVersionAssociation GetItem(Association myAssociation)
|
|
||||||
{
|
{
|
||||||
foreach (DocVersionAssociation association in this)
|
foreach (DocVersionAssociation association in this)
|
||||||
if (association.AssociationID == myAssociation.AssociationID)
|
if (association.AssociationID == myAssociation.AssociationID)
|
||||||
@@ -63,7 +55,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (!Contains(myROFst))
|
if (!Contains(myROFst))
|
||||||
{
|
{
|
||||||
DocVersionAssociation association = DocVersionAssociation.New(myROFst);
|
DocVersionAssociation association = DocVersionAssociation.New(myROFst);
|
||||||
this.Add(association);
|
Add(association);
|
||||||
return association;
|
return association;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -113,18 +105,18 @@ namespace VEPROMS.CSLA.Library
|
|||||||
get { return IsValidList(new List<object>()); }
|
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
|
||||||
// and if any are invalid then the
|
// and if any are invalid then the
|
||||||
// collection is invalid
|
// collection is invalid
|
||||||
foreach (DocVersionAssociation child in this)
|
foreach (DocVersionAssociation child in this)
|
||||||
if (!child.IsValidList(list))
|
if (!child.IsValidList(list))
|
||||||
{
|
{
|
||||||
//Console.WriteLine("Valid {0} Child {1} - {2}", child.IsValid, child.GetType().Name,child.ToString());
|
//Console.WriteLine("Valid {0} Child {1} - {2}", child.IsValid, child.GetType().Name,child.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public bool Contains(ROFst myROFst)
|
public bool Contains(ROFst myROFst)
|
||||||
{
|
{
|
||||||
foreach (DocVersionAssociation association in this)
|
foreach (DocVersionAssociation association in this)
|
||||||
@@ -156,20 +148,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 DocVersionAssociations New()
|
internal static DocVersionAssociations New() => new DocVersionAssociations();
|
||||||
{
|
internal static DocVersionAssociations Get(SafeDataReader dr) => new DocVersionAssociations(dr);
|
||||||
return new DocVersionAssociations();
|
public static DocVersionAssociations GetByVersionID(int versionID)
|
||||||
}
|
|
||||||
internal static DocVersionAssociations Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new DocVersionAssociations(dr);
|
|
||||||
}
|
|
||||||
public static DocVersionAssociations GetByVersionID(int versionID)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -180,11 +166,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on DocVersionAssociations.GetByVersionID", ex);
|
throw new DbCslaException("Error on DocVersionAssociations.GetByVersionID", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private DocVersionAssociations()
|
private DocVersionAssociations() => MarkAsChild();
|
||||||
{
|
internal DocVersionAssociations(SafeDataReader dr)
|
||||||
MarkAsChild();
|
|
||||||
}
|
|
||||||
internal DocVersionAssociations(SafeDataReader dr)
|
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
Fetch(dr);
|
Fetch(dr);
|
||||||
@@ -193,16 +176,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
|
~DocVersionAssociations()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~DocVersionAssociations()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -217,19 +196,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(DocVersionAssociation.Get(dr));
|
Add(DocVersionAssociation.Get(dr));
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
[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; }
|
||||||
@@ -238,7 +214,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
private void DataPortal_Fetch(VersionIDCriteria criteria)
|
private void DataPortal_Fetch(VersionIDCriteria criteria)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionAssociations.DataPortal_FetchVersionID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionAssociations.DataPortal_FetchVersionID", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -252,7 +228,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 DocVersionAssociation(dr));
|
while (dr.Read()) Add(new DocVersionAssociation(dr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,11 +238,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionAssociations.DataPortal_FetchVersionID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionAssociations.DataPortal_FetchVersionID", ex);
|
||||||
throw new DbCslaException("DocVersionAssociations.DataPortal_Fetch", ex);
|
throw new DbCslaException("DocVersionAssociations.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
internal void Update(DocVersion docVersion)
|
internal void Update(DocVersion docVersion)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// update (thus deleting) any deleted child objects
|
// update (thus deleting) any deleted child objects
|
||||||
@@ -285,49 +261,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
|
||||||
DocVersionAssociationsPropertyDescriptor pd = new DocVersionAssociationsPropertyDescriptor(this, i);
|
DocVersionAssociationsPropertyDescriptor pd = new DocVersionAssociationsPropertyDescriptor(this, i);
|
||||||
@@ -344,7 +309,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class DocVersionAssociationsPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class DocVersionAssociationsPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private DocVersionAssociation Item { get { return (DocVersionAssociation)_Item; } }
|
|
||||||
public DocVersionAssociationsPropertyDescriptor(DocVersionAssociations collection, int index) : base(collection, index) { ;}
|
public DocVersionAssociationsPropertyDescriptor(DocVersionAssociations collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -353,10 +317,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 DocVersionAssociations)
|
if (destType == typeof(string) && value is DocVersionAssociations associations)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((DocVersionAssociations)value).Items.Count.ToString() + " Associations";
|
return $"{associations.Items.Count} Associations";
|
||||||
}
|
}
|
||||||
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,14 +26,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public partial class DocVersionInfo : ReadOnlyBase<DocVersionInfo>, IDisposable
|
public partial class DocVersionInfo : ReadOnlyBase<DocVersionInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public event DocVersionInfoEvent Changed;
|
public event DocVersionInfoEvent 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<DocVersionInfo> _CacheList = new List<DocVersionInfo>();
|
private static List<DocVersionInfo> _CacheList = new List<DocVersionInfo>();
|
||||||
protected static void AddToCache(DocVersionInfo docVersionInfo)
|
protected static void AddToCache(DocVersionInfo docVersionInfo)
|
||||||
{
|
{
|
||||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(docVersionInfo)) _CacheList.Remove(docVersionInfo); // In RemoveFromCache
|
while (_CacheList.Contains(docVersionInfo)) _CacheList.Remove(docVersionInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<DocVersionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocVersionInfo>>();
|
private static Dictionary<string, List<DocVersionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocVersionInfo>>();
|
||||||
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 DocVersion _Editable;
|
protected DocVersion _Editable;
|
||||||
private IVEHasBrokenRules HasBrokenRules
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
IVEHasBrokenRules hasBrokenRules = null;
|
|
||||||
if (_Editable != null)
|
|
||||||
hasBrokenRules = _Editable.HasBrokenRules;
|
|
||||||
return hasBrokenRules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private int _VersionID;
|
private int _VersionID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int VersionID
|
public int VersionID
|
||||||
@@ -252,32 +236,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
foreach (DocVersionInfo tmp in _CacheByPrimaryKey[_VersionID.ToString()])
|
foreach (DocVersionInfo tmp in _CacheByPrimaryKey[_VersionID.ToString()])
|
||||||
tmp._DocVersionAssociationCount = -1; // This will cause the data to be requeried
|
tmp._DocVersionAssociationCount = -1; // This will cause the data to be requeried
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base DocVersionInfo.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current DocVersionInfo</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check DocVersionInfo.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check DocVersionInfo.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 DocVersionInfo</returns>
|
/// <returns>A Unique ID for the current DocVersionInfo</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyDocVersionInfoUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyDocVersionInfoUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _DocVersionInfoUnique = 0;
|
private static int _DocVersionInfoUnique = 0;
|
||||||
private static int DocVersionInfoUnique
|
private static int DocVersionInfoUnique => ++_DocVersionInfoUnique;
|
||||||
{ get { return ++_DocVersionInfoUnique; } }
|
private readonly int _MyDocVersionInfoUnique = DocVersionInfoUnique;
|
||||||
private int _MyDocVersionInfoUnique = DocVersionInfoUnique;
|
// Absolutely Unique ID - Info
|
||||||
public int MyDocVersionInfoUnique // Absolutely Unique ID - Info
|
public int MyDocVersionInfoUnique => _MyDocVersionInfoUnique;
|
||||||
{ get { return _MyDocVersionInfoUnique; } }
|
|
||||||
protected DocVersionInfo()
|
protected DocVersionInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -286,15 +257,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; } }
|
|
||||||
~DocVersionInfo()
|
~DocVersionInfo()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -311,10 +278,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (listDocVersionInfo.Count == 0) // If there are no items left in the list
|
if (listDocVersionInfo.Count == 0) // If there are no items left in the list
|
||||||
_CacheByPrimaryKey.Remove(VersionID.ToString()); // remove the list
|
_CacheByPrimaryKey.Remove(VersionID.ToString()); // remove the list
|
||||||
}
|
}
|
||||||
public virtual DocVersion Get()
|
public virtual DocVersion Get() => _Editable = DocVersion.Get(_VersionID);
|
||||||
{
|
|
||||||
return _Editable = DocVersion.Get(_VersionID);
|
|
||||||
}
|
|
||||||
public static void Refresh(DocVersion tmp)
|
public static void Refresh(DocVersion tmp)
|
||||||
{
|
{
|
||||||
string key = tmp.VersionID.ToString();
|
string key = tmp.VersionID.ToString();
|
||||||
@@ -327,28 +291,28 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_FolderID != tmp.FolderID)
|
if (_FolderID != tmp.FolderID)
|
||||||
{
|
{
|
||||||
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for old value
|
MyFolder?.RefreshFolderDocVersions(); // Update List for old value
|
||||||
_FolderID = tmp.FolderID; // Update the value
|
_FolderID = tmp.FolderID; // Update the value
|
||||||
}
|
}
|
||||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||||
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for new value
|
MyFolder?.RefreshFolderDocVersions(); // Update List for new value
|
||||||
_VersionType = tmp.VersionType;
|
_VersionType = tmp.VersionType;
|
||||||
_Name = tmp.Name;
|
_Name = tmp.Name;
|
||||||
_Title = tmp.Title;
|
_Title = tmp.Title;
|
||||||
if (_ItemID != tmp.ItemID)
|
if (_ItemID != tmp.ItemID)
|
||||||
{
|
{
|
||||||
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for old value
|
MyItem?.RefreshItemDocVersions(); // Update List for old value
|
||||||
_ItemID = tmp.ItemID; // Update the value
|
_ItemID = tmp.ItemID; // Update the value
|
||||||
}
|
}
|
||||||
_MyItem = null; // Reset list so that the next line gets a new list
|
_MyItem = null; // Reset list so that the next line gets a new list
|
||||||
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for new value
|
MyItem?.RefreshItemDocVersions(); // Update List for new value
|
||||||
if (_FormatID != tmp.FormatID)
|
if (_FormatID != tmp.FormatID)
|
||||||
{
|
{
|
||||||
if (MyFormat != null) MyFormat.RefreshFormatDocVersions(); // Update List for old value
|
MyFormat?.RefreshFormatDocVersions(); // Update List for old value
|
||||||
_FormatID = tmp.FormatID; // Update the value
|
_FormatID = tmp.FormatID; // Update the value
|
||||||
}
|
}
|
||||||
_MyFormat = null; // Reset list so that the next line gets a new list
|
_MyFormat = null; // Reset list so that the next line gets a new list
|
||||||
if (MyFormat != null) MyFormat.RefreshFormatDocVersions(); // Update List for new value
|
MyFormat?.RefreshFormatDocVersions(); // Update List for new value
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
_UserID = tmp.UserID;
|
_UserID = tmp.UserID;
|
||||||
@@ -370,18 +334,18 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_Title = tmp.Title;
|
_Title = tmp.Title;
|
||||||
if (_ItemID != tmp.ItemID)
|
if (_ItemID != tmp.ItemID)
|
||||||
{
|
{
|
||||||
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for old value
|
MyItem?.RefreshItemDocVersions(); // Update List for old value
|
||||||
_ItemID = tmp.ItemID; // Update the value
|
_ItemID = tmp.ItemID; // Update the value
|
||||||
}
|
}
|
||||||
_MyItem = null; // Reset list so that the next line gets a new list
|
_MyItem = null; // Reset list so that the next line gets a new list
|
||||||
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for new value
|
MyItem?.RefreshItemDocVersions(); // Update List for new value
|
||||||
if (_FormatID != tmp.FormatID)
|
if (_FormatID != tmp.FormatID)
|
||||||
{
|
{
|
||||||
if (MyFormat != null) MyFormat.RefreshFormatDocVersions(); // Update List for old value
|
MyFormat?.RefreshFormatDocVersions(); // Update List for old value
|
||||||
_FormatID = tmp.FormatID; // Update the value
|
_FormatID = tmp.FormatID; // Update the value
|
||||||
}
|
}
|
||||||
_MyFormat = null; // Reset list so that the next line gets a new list
|
_MyFormat = null; // Reset list so that the next line gets a new list
|
||||||
if (MyFormat != null) MyFormat.RefreshFormatDocVersions(); // Update List for new value
|
MyFormat?.RefreshFormatDocVersions(); // Update List for new value
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
_UserID = tmp.UserID;
|
_UserID = tmp.UserID;
|
||||||
@@ -400,21 +364,21 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_FolderID != tmp.FolderID)
|
if (_FolderID != tmp.FolderID)
|
||||||
{
|
{
|
||||||
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for old value
|
MyFolder?.RefreshFolderDocVersions(); // Update List for old value
|
||||||
_FolderID = tmp.FolderID; // Update the value
|
_FolderID = tmp.FolderID; // Update the value
|
||||||
}
|
}
|
||||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||||
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for new value
|
MyFolder?.RefreshFolderDocVersions(); // Update List for new value
|
||||||
_VersionType = tmp.VersionType;
|
_VersionType = tmp.VersionType;
|
||||||
_Name = tmp.Name;
|
_Name = tmp.Name;
|
||||||
_Title = tmp.Title;
|
_Title = tmp.Title;
|
||||||
if (_ItemID != tmp.ItemID)
|
if (_ItemID != tmp.ItemID)
|
||||||
{
|
{
|
||||||
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for old value
|
MyItem?.RefreshItemDocVersions(); // Update List for old value
|
||||||
_ItemID = tmp.ItemID; // Update the value
|
_ItemID = tmp.ItemID; // Update the value
|
||||||
}
|
}
|
||||||
_MyItem = null; // Reset list so that the next line gets a new list
|
_MyItem = null; // Reset list so that the next line gets a new list
|
||||||
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for new value
|
MyItem?.RefreshItemDocVersions(); // Update List for new value
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
_UserID = tmp.UserID;
|
_UserID = tmp.UserID;
|
||||||
@@ -433,21 +397,21 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_FolderID != tmp.FolderID)
|
if (_FolderID != tmp.FolderID)
|
||||||
{
|
{
|
||||||
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for old value
|
MyFolder?.RefreshFolderDocVersions(); // Update List for old value
|
||||||
_FolderID = tmp.FolderID; // Update the value
|
_FolderID = tmp.FolderID; // Update the value
|
||||||
}
|
}
|
||||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||||
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for new value
|
MyFolder?.RefreshFolderDocVersions(); // Update List for new value
|
||||||
_VersionType = tmp.VersionType;
|
_VersionType = tmp.VersionType;
|
||||||
_Name = tmp.Name;
|
_Name = tmp.Name;
|
||||||
_Title = tmp.Title;
|
_Title = tmp.Title;
|
||||||
if (_FormatID != tmp.FormatID)
|
if (_FormatID != tmp.FormatID)
|
||||||
{
|
{
|
||||||
if (MyFormat != null) MyFormat.RefreshFormatDocVersions(); // Update List for old value
|
MyFormat?.RefreshFormatDocVersions(); // Update List for old value
|
||||||
_FormatID = tmp.FormatID; // Update the value
|
_FormatID = tmp.FormatID; // Update the value
|
||||||
}
|
}
|
||||||
_MyFormat = null; // Reset list so that the next line gets a new list
|
_MyFormat = null; // Reset list so that the next line gets a new list
|
||||||
if (MyFormat != null) MyFormat.RefreshFormatDocVersions(); // Update List for new value
|
MyFormat?.RefreshFormatDocVersions(); // Update List for new value
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
_UserID = tmp.UserID;
|
_UserID = tmp.UserID;
|
||||||
@@ -456,8 +420,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static DocVersionInfo Get(int versionID)
|
public static DocVersionInfo Get(int versionID)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a DocVersion");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DocVersionInfo tmp = GetCachedByPrimaryKey(versionID);
|
DocVersionInfo tmp = GetCachedByPrimaryKey(versionID);
|
||||||
@@ -496,13 +458,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _VersionID;
|
private readonly int _VersionID;
|
||||||
public int VersionID
|
public int VersionID => _VersionID;
|
||||||
{ get { return _VersionID; } }
|
public PKCriteria(int versionID) => _VersionID = versionID;
|
||||||
public PKCriteria(int versionID)
|
|
||||||
{
|
|
||||||
_VersionID = versionID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void ReadData(SafeDataReader dr)
|
private void ReadData(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
@@ -567,7 +525,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
DocVersionInfoExtension _DocVersionInfoExtension = new DocVersionInfoExtension();
|
readonly DocVersionInfoExtension _DocVersionInfoExtension = new DocVersionInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class DocVersionInfoExtension : extensionBase { }
|
partial class DocVersionInfoExtension : extensionBase { }
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
@@ -583,10 +541,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 DocVersionInfo)
|
if (destType == typeof(string) && value is DocVersionInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((DocVersionInfo)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<DocVersionInfo> Items
|
internal new IList<DocVersionInfo> Items => base.Items;
|
||||||
{ get { return base.Items; } }
|
public void AddEvents()
|
||||||
public void AddEvents()
|
|
||||||
{
|
{
|
||||||
foreach (DocVersionInfo tmp in this)
|
foreach (DocVersionInfo tmp in this)
|
||||||
{
|
{
|
||||||
@@ -44,23 +41,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
for (int i = 0; i < Count; i++)
|
for (int i = 0; i < Count; i++)
|
||||||
{
|
{
|
||||||
if (base[i] == sender)
|
if (base[i] == sender)
|
||||||
this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i));
|
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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
|
~DocVersionInfoList()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~DocVersionInfoList()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -104,18 +97,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
_DocVersionInfoList = null;
|
_DocVersionInfoList = null;
|
||||||
}
|
}
|
||||||
// CSLATODO: Add alternative gets -
|
|
||||||
//public static DocVersionInfoList Get(<criteria>)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// return DataPortal.Fetch<DocVersionInfoList>(new FilteredCriteria(<criteria>));
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// throw new DbCslaException("Error on DocVersionInfoList.Get", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
public static DocVersionInfoList GetByFolderID(int folderID)
|
public static DocVersionInfoList GetByFolderID(int folderID)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -164,7 +146,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#region Data Access Portal
|
#region Data Access Portal
|
||||||
private void DataPortal_Fetch()
|
private void DataPortal_Fetch()
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_Fetch", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_Fetch", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -178,7 +160,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||||
{
|
{
|
||||||
IsReadOnly = false;
|
IsReadOnly = false;
|
||||||
while (dr.Read()) this.Add(new DocVersionInfo(dr));
|
while (dr.Read()) Add(new DocVersionInfo(dr));
|
||||||
IsReadOnly = true;
|
IsReadOnly = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,16 +171,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfoList.DataPortal_Fetch", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfoList.DataPortal_Fetch", ex);
|
||||||
throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex);
|
throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
[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; }
|
||||||
@@ -207,7 +186,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
private void DataPortal_Fetch(FolderIDCriteria criteria)
|
private void DataPortal_Fetch(FolderIDCriteria criteria)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchFolderID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchFolderID", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -222,7 +201,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||||
{
|
{
|
||||||
IsReadOnly = false;
|
IsReadOnly = false;
|
||||||
while (dr.Read()) this.Add(new DocVersionInfo(dr));
|
while (dr.Read()) Add(new DocVersionInfo(dr));
|
||||||
IsReadOnly = true;
|
IsReadOnly = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -233,16 +212,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfoList.DataPortal_FetchFolderID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfoList.DataPortal_FetchFolderID", ex);
|
||||||
throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex);
|
throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class FormatIDCriteria
|
private class FormatIDCriteria
|
||||||
{
|
{
|
||||||
public FormatIDCriteria(int? formatID)
|
public FormatIDCriteria(int? formatID) => _FormatID = formatID;
|
||||||
{
|
private int? _FormatID;
|
||||||
_FormatID = formatID;
|
|
||||||
}
|
|
||||||
private int? _FormatID;
|
|
||||||
public int? FormatID
|
public int? FormatID
|
||||||
{
|
{
|
||||||
get { return _FormatID; }
|
get { return _FormatID; }
|
||||||
@@ -251,7 +227,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
private void DataPortal_Fetch(FormatIDCriteria criteria)
|
private void DataPortal_Fetch(FormatIDCriteria criteria)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchFormatID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchFormatID", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -266,7 +242,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||||
{
|
{
|
||||||
IsReadOnly = false;
|
IsReadOnly = false;
|
||||||
while (dr.Read()) this.Add(new DocVersionInfo(dr));
|
while (dr.Read()) Add(new DocVersionInfo(dr));
|
||||||
IsReadOnly = true;
|
IsReadOnly = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -277,16 +253,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfoList.DataPortal_FetchFormatID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfoList.DataPortal_FetchFormatID", ex);
|
||||||
throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex);
|
throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
[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; }
|
||||||
@@ -295,7 +268,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
private void DataPortal_Fetch(ItemIDCriteria criteria)
|
private void DataPortal_Fetch(ItemIDCriteria criteria)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchItemID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfoList.DataPortal_FetchItemID", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -310,7 +283,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||||
{
|
{
|
||||||
IsReadOnly = false;
|
IsReadOnly = false;
|
||||||
while (dr.Read()) this.Add(new DocVersionInfo(dr));
|
while (dr.Read()) Add(new DocVersionInfo(dr));
|
||||||
IsReadOnly = true;
|
IsReadOnly = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -321,48 +294,37 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfoList.DataPortal_FetchItemID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionInfoList.DataPortal_FetchItemID", ex);
|
||||||
throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex);
|
throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
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
|
||||||
DocVersionInfoListPropertyDescriptor pd = new DocVersionInfoListPropertyDescriptor(this, i);
|
DocVersionInfoListPropertyDescriptor pd = new DocVersionInfoListPropertyDescriptor(this, i);
|
||||||
@@ -379,7 +341,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class DocVersionInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class DocVersionInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private DocVersionInfo Item { get { return (DocVersionInfo)_Item; } }
|
|
||||||
public DocVersionInfoListPropertyDescriptor(DocVersionInfoList collection, int index) : base(collection, index) { ;}
|
public DocVersionInfoListPropertyDescriptor(DocVersionInfoList collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -388,10 +349,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 DocVersionInfoList)
|
if (destType == typeof(string) && value is DocVersionInfoList list)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((DocVersionInfoList)value).Items.Count.ToString() + " DocVersions";
|
return $"{list.Items.Count} DocVersions";
|
||||||
}
|
}
|
||||||
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;
|
||||||
@@ -95,6 +93,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<Document> _CacheList = new List<Document>();
|
private static List<Document> _CacheList = new List<Document>();
|
||||||
protected static void AddToCache(Document document)
|
protected static void AddToCache(Document document)
|
||||||
{
|
{
|
||||||
@@ -104,6 +103,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(document)) _CacheList.Remove(document); // In RemoveFromCache
|
while (_CacheList.Contains(document)) _CacheList.Remove(document); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<Document>> _CacheByPrimaryKey = new Dictionary<string, List<Document>>();
|
private static Dictionary<string, List<Document>> _CacheByPrimaryKey = new Dictionary<string, List<Document>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -129,15 +129,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 _nextDocID = -1;
|
private static int _nextDocID = -1;
|
||||||
public static int NextDocID
|
public static int NextDocID => _nextDocID--;
|
||||||
{
|
|
||||||
get { return _nextDocID--; }
|
|
||||||
}
|
|
||||||
private int _DocID;
|
private int _DocID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int DocID
|
public int DocID
|
||||||
@@ -354,10 +348,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _DocumentEntries;
|
return _DocumentEntries;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Reset_DocumentEntries()
|
public void Reset_DocumentEntries() => _DocumentEntryCount = -1;
|
||||||
{
|
|
||||||
_DocumentEntryCount = -1;
|
|
||||||
}
|
|
||||||
private int _DocumentPdfCount = 0;
|
private int _DocumentPdfCount = 0;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Count of DocumentPdfs for this Document
|
/// Count of DocumentPdfs for this Document
|
||||||
@@ -389,10 +380,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _DocumentPdfs;
|
return _DocumentPdfs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Reset_DocumentPdfs()
|
public void Reset_DocumentPdfs() => _DocumentPdfCount = -1;
|
||||||
{
|
|
||||||
_DocumentPdfCount = -1;
|
|
||||||
}
|
|
||||||
public override bool IsDirty
|
public override bool IsDirty
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -407,37 +395,22 @@ 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 || (_DocumentDROUsages == null ? false : _DocumentDROUsages.IsDirtyList(list)) || (_DocumentEntries == null ? false : _DocumentEntries.IsDirtyList(list)) || (_DocumentPdfs == null ? false : _DocumentPdfs.IsDirtyList(list));
|
return base.IsDirty || (_DocumentDROUsages != null && _DocumentDROUsages.IsDirtyList(list)) || (_DocumentEntries != null && _DocumentEntries.IsDirtyList(list)) || (_DocumentPdfs != null && _DocumentPdfs.IsDirtyList(list));
|
||||||
}
|
|
||||||
public override bool IsValid
|
|
||||||
{
|
|
||||||
get { return IsValidList(new List<object>()); }
|
|
||||||
}
|
}
|
||||||
|
public override bool IsValid => IsValidList(new List<object>());
|
||||||
public bool IsValidList(List<object> list)
|
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) && (_DocumentDROUsages == null ? true : _DocumentDROUsages.IsValidList(list)) && (_DocumentEntries == null ? true : _DocumentEntries.IsValidList(list)) && (_DocumentPdfs == null ? true : _DocumentPdfs.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_DocumentDROUsages == null || _DocumentDROUsages.IsValidList(list)) && (_DocumentEntries == null || _DocumentEntries.IsValidList(list)) && (_DocumentPdfs == null || _DocumentPdfs.IsValidList(list));
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base Document.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current Document</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check Document.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check Document.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 Document</returns>
|
/// <returns>A Unique ID for the current Document</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyDocumentUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyDocumentUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
@@ -468,8 +441,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()
|
||||||
@@ -502,37 +475,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_DocumentExtension.AddInstanceValidationRules(ValidationRules);
|
_DocumentExtension.AddInstanceValidationRules(ValidationRules);
|
||||||
// CSLATODO: Add other validation rules
|
// 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
|
#endregion
|
||||||
#region Authorization Rules
|
#region Authorization Rules
|
||||||
protected override void AddAuthorizationRules()
|
protected override void AddAuthorizationRules()
|
||||||
{
|
{
|
||||||
//CSLATODO: Who can read/write which fields
|
//CSLATODO: Who can read/write which fields
|
||||||
//AuthorizationRules.AllowRead(DocID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(LibTitle, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DocContent, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DocAscii, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(FileExtension, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(LibTitle, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DocContent, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DocAscii, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(FileExtension, "<Role(s)>");
|
|
||||||
_DocumentExtension.AddAuthorizationRules(AuthorizationRules);
|
_DocumentExtension.AddAuthorizationRules(AuthorizationRules);
|
||||||
}
|
}
|
||||||
protected override void AddInstanceAuthorizationRules()
|
protected override void AddInstanceAuthorizationRules()
|
||||||
@@ -540,57 +487,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//CSLATODO: Who can read/write which fields
|
//CSLATODO: Who can read/write which fields
|
||||||
_DocumentExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
_DocumentExtension.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 += _DocumentDROUsageCount;
|
|
||||||
usedByCount += _DocumentEntryCount;
|
|
||||||
usedByCount += _DocumentPdfCount;
|
|
||||||
return (usedByCount == 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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 _DocumentUnique = 0;
|
private static int _DocumentUnique = 0;
|
||||||
protected static int DocumentUnique
|
protected static int DocumentUnique => ++_DocumentUnique;
|
||||||
{ get { return ++_DocumentUnique; } }
|
private readonly int _MyDocumentUnique = DocumentUnique;
|
||||||
private int _MyDocumentUnique = DocumentUnique;
|
// Absolutely Unique ID - Editable
|
||||||
public int MyDocumentUnique // Absolutely Unique ID - Editable
|
public int MyDocumentUnique => _MyDocumentUnique;
|
||||||
{ get { return _MyDocumentUnique; } }
|
|
||||||
protected Document()
|
protected Document()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -599,15 +503,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; } }
|
|
||||||
~Document()
|
~Document()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -632,8 +532,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Document New()
|
public static Document New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Document");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<Document>();
|
return DataPortal.Create<Document>();
|
||||||
@@ -699,8 +597,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Document Get(int docID)
|
public static Document Get(int docID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a Document");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Document tmp = GetCachedByPrimaryKey(docID);
|
Document tmp = GetCachedByPrimaryKey(docID);
|
||||||
@@ -726,14 +622,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dr.Read()) return new Document(dr);
|
if (dr.Read()) return new Document(dr);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
internal Document(SafeDataReader dr)
|
internal Document(SafeDataReader dr) => ReadData(dr);
|
||||||
{
|
|
||||||
ReadData(dr);
|
|
||||||
}
|
|
||||||
public static void Delete(int docID)
|
public static void Delete(int docID)
|
||||||
{
|
{
|
||||||
if (!CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Document");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataPortal.Delete(new PKCriteria(docID));
|
DataPortal.Delete(new PKCriteria(docID));
|
||||||
@@ -745,12 +636,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public override Document Save()
|
public override Document Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Document");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Document");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a Document");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -770,13 +655,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _DocID;
|
private readonly int _DocID;
|
||||||
public int DocID
|
public int DocID => _DocID;
|
||||||
{ get { return _DocID; } }
|
public PKCriteria(int docID) => _DocID = docID;
|
||||||
public PKCriteria(int docID)
|
|
||||||
{
|
|
||||||
_DocID = docID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 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()]
|
||||||
@@ -889,41 +770,48 @@ 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())
|
|
||||||
{
|
{
|
||||||
cm.CommandType = CommandType.StoredProcedure;
|
using (SqlCommand cm = cn.CreateCommand())
|
||||||
cm.CommandTimeout = Database.SQLTimeout;
|
{
|
||||||
cm.CommandText = "addDocument";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@LibTitle", _LibTitle);
|
cm.CommandText = "addDocument";
|
||||||
cm.Parameters.AddWithValue("@DocContent", _DocContent);
|
// Input All Fields - Except Calculated Columns
|
||||||
cm.Parameters.AddWithValue("@DocAscii", _DocAscii);
|
cm.Parameters.AddWithValue("@LibTitle", _LibTitle);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@DocContent", _DocContent);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@DocAscii", _DocAscii);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
cm.Parameters.AddWithValue("@FileExtension", _FileExtension);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
SqlParameter param_DocID = new SqlParameter("@newDocID", SqlDbType.Int);
|
cm.Parameters.AddWithValue("@FileExtension", _FileExtension);
|
||||||
param_DocID.Direction = ParameterDirection.Output;
|
// Output Calculated Columns
|
||||||
cm.Parameters.Add(param_DocID);
|
SqlParameter param_DocID = new SqlParameter("@newDocID", 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_DocID);
|
||||||
cm.ExecuteNonQuery();
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
// Save all values being returned from the Procedure
|
{
|
||||||
_DocID = (int)cm.Parameters["@newDocID"].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
|
||||||
|
_DocID = (int)cm.Parameters["@newDocID"].Value;
|
||||||
|
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
// update child objects
|
// update child objects
|
||||||
if (_DocumentEntries != null) _DocumentEntries.Update(this);
|
_DocumentEntries?.Update(this);
|
||||||
if (_DocumentDROUsages != null) _DocumentDROUsages.Update(this);
|
_DocumentDROUsages?.Update(this);
|
||||||
if (_DocumentPdfs != null) _DocumentPdfs.Update(this);
|
_DocumentPdfs?.Update(this);
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.SQLInsert", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.SQLInsert", GetHashCode());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -953,11 +841,15 @@ namespace VEPROMS.CSLA.Library
|
|||||||
cm.Parameters.AddWithValue("@UserID", userID);
|
cm.Parameters.AddWithValue("@UserID", userID);
|
||||||
cm.Parameters.AddWithValue("@FileExtension", fileExtension);
|
cm.Parameters.AddWithValue("@FileExtension", fileExtension);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_DocID = new SqlParameter("@newDocID", SqlDbType.Int);
|
SqlParameter param_DocID = new SqlParameter("@newDocID", SqlDbType.Int)
|
||||||
param_DocID.Direction = ParameterDirection.Output;
|
{
|
||||||
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
cm.Parameters.Add(param_DocID);
|
cm.Parameters.Add(param_DocID);
|
||||||
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();
|
||||||
@@ -1002,39 +894,44 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.SQLUpdate", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
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 = "updateDocument";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@DocID", _DocID);
|
cm.CommandText = "updateDocument";
|
||||||
cm.Parameters.AddWithValue("@LibTitle", _LibTitle);
|
// All Fields including Calculated Fields
|
||||||
cm.Parameters.AddWithValue("@DocContent", _DocContent);
|
cm.Parameters.AddWithValue("@DocID", _DocID);
|
||||||
cm.Parameters.AddWithValue("@DocAscii", _DocAscii);
|
cm.Parameters.AddWithValue("@LibTitle", _LibTitle);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@DocContent", _DocContent);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@DocAscii", _DocAscii);
|
||||||
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);
|
||||||
cm.Parameters.AddWithValue("@FileExtension", _FileExtension);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
cm.Parameters.AddWithValue("@FileExtension", _FileExtension);
|
||||||
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
|
||||||
if (_DocumentEntries != null) _DocumentEntries.Update(this);
|
_DocumentEntries?.Update(this);
|
||||||
if (_DocumentDROUsages != null) _DocumentDROUsages.Update(this);
|
_DocumentDROUsages?.Update(this);
|
||||||
if (_DocumentPdfs != null) _DocumentPdfs.Update(this);
|
_DocumentPdfs?.Update(this);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -1045,19 +942,22 @@ 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 = Document.Add(cn, ref _DocID, _LibTitle, _DocContent, _DocAscii, _Config, _DTS, _UserID, _FileExtension);
|
if (IsNew)
|
||||||
else
|
_LastChanged = Document.Add(cn, ref _DocID, _LibTitle, _DocContent, _DocAscii, _Config, _DTS, _UserID, _FileExtension);
|
||||||
_LastChanged = Document.Update(cn, ref _DocID, _LibTitle, _DocContent, _DocAscii, _Config, _DTS, _UserID, ref _LastChanged, _FileExtension);
|
else
|
||||||
|
_LastChanged = Document.Update(cn, ref _DocID, _LibTitle, _DocContent, _DocAscii, _Config, _DTS, _UserID, ref _LastChanged, _FileExtension);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
if (_DocumentEntries != null) _DocumentEntries.Update(this);
|
_DocumentEntries?.Update(this);
|
||||||
if (_DocumentDROUsages != null) _DocumentDROUsages.Update(this);
|
_DocumentDROUsages?.Update(this);
|
||||||
if (_DocumentPdfs != null) _DocumentPdfs.Update(this);
|
_DocumentPdfs?.Update(this);
|
||||||
}
|
}
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
public static byte[] Update(SqlConnection cn, ref int docID, string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID, ref byte[] lastChanged, string fileExtension)
|
public static byte[] Update(SqlConnection cn, ref int docID, string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID, ref byte[] lastChanged, string fileExtension)
|
||||||
@@ -1081,8 +981,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
||||||
cm.Parameters.AddWithValue("@FileExtension", fileExtension);
|
cm.Parameters.AddWithValue("@FileExtension", fileExtension);
|
||||||
// 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();
|
||||||
@@ -1097,10 +999,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(_DocID));
|
||||||
{
|
|
||||||
DataPortal_Delete(new PKCriteria(_DocID));
|
|
||||||
}
|
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
private void DataPortal_Delete(PKCriteria criteria)
|
private void DataPortal_Delete(PKCriteria criteria)
|
||||||
{
|
{
|
||||||
@@ -1167,16 +1066,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ExistsCommand : CommandBase
|
private class ExistsCommand : CommandBase
|
||||||
{
|
{
|
||||||
private int _DocID;
|
private readonly int _DocID;
|
||||||
private bool _exists;
|
private bool _exists;
|
||||||
public bool Exists
|
public bool Exists => _exists;
|
||||||
{
|
public ExistsCommand(int docID) => _DocID = docID;
|
||||||
get { return _exists; }
|
|
||||||
}
|
|
||||||
public ExistsCommand(int docID)
|
|
||||||
{
|
|
||||||
_DocID = docID;
|
|
||||||
}
|
|
||||||
protected override void DataPortal_Execute()
|
protected override void DataPortal_Execute()
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.DataPortal_Execute", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.DataPortal_Execute", GetHashCode());
|
||||||
@@ -1206,7 +1099,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
DocumentExtension _DocumentExtension = new DocumentExtension();
|
readonly DocumentExtension _DocumentExtension = new DocumentExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class DocumentExtension : extensionBase
|
partial class DocumentExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -1215,18 +1108,9 @@ 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 DefaultFileExtension => ".Doc";
|
||||||
}
|
|
||||||
public virtual string DefaultUserID
|
|
||||||
{
|
|
||||||
get { return Volian.Base.Library.VlnSettings.UserID; }
|
|
||||||
}
|
|
||||||
public virtual string DefaultFileExtension
|
|
||||||
{
|
|
||||||
get { return ".Doc"; }
|
|
||||||
}
|
|
||||||
// Authorization Rules
|
// Authorization Rules
|
||||||
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
||||||
{
|
{
|
||||||
@@ -1255,61 +1139,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 Document)
|
if (destType == typeof(string) && value is Document doc)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((Document)value).ToString();
|
return doc.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 DocumentExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class Document
|
|
||||||
// {
|
|
||||||
// partial class DocumentExtension : extensionBase
|
|
||||||
// {
|
|
||||||
// // CSLATODO: Override automatic defaults
|
|
||||||
// public virtual DateTime DefaultDTS
|
|
||||||
// {
|
|
||||||
// get { return DateTime.Now; }
|
|
||||||
// }
|
|
||||||
// public virtual string DefaultUserID
|
|
||||||
// {
|
|
||||||
// get { return Environment.UserName.ToUpper(); }
|
|
||||||
// }
|
|
||||||
// public virtual string DefaultFileExtension
|
|
||||||
// {
|
|
||||||
// get { return ".Doc"; }
|
|
||||||
// }
|
|
||||||
// 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;
|
||||||
@@ -37,10 +35,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (IsDirty)
|
if (IsDirty)
|
||||||
refreshDocumentAudits.Add(this);
|
refreshDocumentAudits.Add(this);
|
||||||
}
|
}
|
||||||
private void ClearRefreshList()
|
private void ClearRefreshList() => _RefreshDocumentAudits = new List<DocumentAudit>();
|
||||||
{
|
|
||||||
_RefreshDocumentAudits = new List<DocumentAudit>();
|
|
||||||
}
|
|
||||||
private void BuildRefreshList()
|
private void BuildRefreshList()
|
||||||
{
|
{
|
||||||
ClearRefreshList();
|
ClearRefreshList();
|
||||||
@@ -56,6 +51,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<DocumentAudit> _CacheList = new List<DocumentAudit>();
|
private static List<DocumentAudit> _CacheList = new List<DocumentAudit>();
|
||||||
protected static void AddToCache(DocumentAudit documentAudit)
|
protected static void AddToCache(DocumentAudit documentAudit)
|
||||||
{
|
{
|
||||||
@@ -65,6 +61,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(documentAudit)) _CacheList.Remove(documentAudit); // In RemoveFromCache
|
while (_CacheList.Contains(documentAudit)) _CacheList.Remove(documentAudit); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<DocumentAudit>> _CacheByPrimaryKey = new Dictionary<string, List<DocumentAudit>>();
|
private static Dictionary<string, List<DocumentAudit>> _CacheByPrimaryKey = new Dictionary<string, List<DocumentAudit>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -90,15 +87,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 _nextAuditID = -1;
|
private static int _nextAuditID = -1;
|
||||||
public static int NextAuditID
|
public static int NextAuditID => _nextAuditID--;
|
||||||
{
|
|
||||||
get { return _nextAuditID--; }
|
|
||||||
}
|
|
||||||
private long _AuditID;
|
private long _AuditID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public long AuditID
|
public long AuditID
|
||||||
@@ -294,40 +285,14 @@ 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; }
|
|
||||||
}
|
|
||||||
public bool IsDirtyList(List<object> list)
|
|
||||||
{
|
|
||||||
return base.IsDirty;
|
|
||||||
}
|
|
||||||
public override bool IsValid
|
|
||||||
{
|
|
||||||
get { return (IsNew && !IsDirty) ? true : base.IsValid; }
|
|
||||||
}
|
|
||||||
public bool IsValidList(List<object> list)
|
|
||||||
{
|
|
||||||
return (IsNew && !IsDirty) ? true : base.IsValid;
|
|
||||||
}
|
|
||||||
// CSLATODO: Replace base DocumentAudit.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current DocumentAudit</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check DocumentAudit.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check DocumentAudit.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 DocumentAudit</returns>
|
/// <returns>A Unique ID for the current DocumentAudit</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyDocumentAuditUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyDocumentAuditUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
@@ -355,8 +320,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,43 +354,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_DocumentAuditExtension.AddInstanceValidationRules(ValidationRules);
|
_DocumentAuditExtension.AddInstanceValidationRules(ValidationRules);
|
||||||
// CSLATODO: Add other validation rules
|
// 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
|
#endregion
|
||||||
#region Authorization Rules
|
#region Authorization Rules
|
||||||
protected override void AddAuthorizationRules()
|
protected override void AddAuthorizationRules()
|
||||||
{
|
{
|
||||||
//CSLATODO: Who can read/write which fields
|
//CSLATODO: Who can read/write which fields
|
||||||
//AuthorizationRules.AllowRead(AuditID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DocID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(LibTitle, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DocContent, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DocAscii, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(FileExtension, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DocPdf, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DeleteStatus, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DocID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(LibTitle, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DocContent, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DocAscii, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(FileExtension, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DocPdf, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DeleteStatus, "<Role(s)>");
|
|
||||||
_DocumentAuditExtension.AddAuthorizationRules(AuthorizationRules);
|
_DocumentAuditExtension.AddAuthorizationRules(AuthorizationRules);
|
||||||
}
|
}
|
||||||
protected override void AddInstanceAuthorizationRules()
|
protected override void AddInstanceAuthorizationRules()
|
||||||
@@ -433,42 +366,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//CSLATODO: Who can read/write which fields
|
//CSLATODO: Who can read/write which fields
|
||||||
_DocumentAuditExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
_DocumentAuditExtension.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 _DocumentAuditUnique = 0;
|
private static int _DocumentAuditUnique = 0;
|
||||||
protected static int DocumentAuditUnique
|
protected static int DocumentAuditUnique => ++_DocumentAuditUnique;
|
||||||
{ get { return ++_DocumentAuditUnique; } }
|
private readonly int _MyDocumentAuditUnique = DocumentAuditUnique;
|
||||||
private int _MyDocumentAuditUnique = DocumentAuditUnique;
|
// Absolutely Unique ID - Editable
|
||||||
public int MyDocumentAuditUnique // Absolutely Unique ID - Editable
|
public int MyDocumentAuditUnique => _MyDocumentAuditUnique;
|
||||||
{ get { return _MyDocumentAuditUnique; } }
|
|
||||||
protected DocumentAudit()
|
protected DocumentAudit()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -477,15 +382,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; } }
|
|
||||||
~DocumentAudit()
|
~DocumentAudit()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -510,8 +411,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static DocumentAudit New()
|
public static DocumentAudit New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a DocumentAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<DocumentAudit>();
|
return DataPortal.Create<DocumentAudit>();
|
||||||
@@ -564,8 +463,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static DocumentAudit Get(long auditID)
|
public static DocumentAudit Get(long auditID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a DocumentAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DocumentAudit tmp = GetCachedByPrimaryKey(auditID);
|
DocumentAudit tmp = GetCachedByPrimaryKey(auditID);
|
||||||
@@ -591,14 +488,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dr.Read()) return new DocumentAudit(dr);
|
if (dr.Read()) return new DocumentAudit(dr);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
internal DocumentAudit(SafeDataReader dr)
|
internal DocumentAudit(SafeDataReader dr) => ReadData(dr);
|
||||||
{
|
|
||||||
ReadData(dr);
|
|
||||||
}
|
|
||||||
public static void Delete(long auditID)
|
public static void Delete(long auditID)
|
||||||
{
|
{
|
||||||
if (!CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a DocumentAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataPortal.Delete(new PKCriteria(auditID));
|
DataPortal.Delete(new PKCriteria(auditID));
|
||||||
@@ -610,12 +502,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public override DocumentAudit Save()
|
public override DocumentAudit Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a DocumentAudit");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a DocumentAudit");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a DocumentAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -635,13 +521,9 @@ 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()]
|
||||||
@@ -742,35 +624,40 @@ 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())
|
|
||||||
{
|
{
|
||||||
cm.CommandType = CommandType.StoredProcedure;
|
using (SqlCommand cm = cn.CreateCommand())
|
||||||
cm.CommandTimeout = Database.SQLTimeout;
|
{
|
||||||
cm.CommandText = "addDocumentAudit";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@DocID", _DocID);
|
cm.CommandText = "addDocumentAudit";
|
||||||
cm.Parameters.AddWithValue("@LibTitle", _LibTitle);
|
// Input All Fields - Except Calculated Columns
|
||||||
cm.Parameters.AddWithValue("@DocContent", _DocContent);
|
cm.Parameters.AddWithValue("@DocID", _DocID);
|
||||||
cm.Parameters.AddWithValue("@DocAscii", _DocAscii);
|
cm.Parameters.AddWithValue("@LibTitle", _LibTitle);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@DocContent", _DocContent);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@DocAscii", _DocAscii);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
cm.Parameters.AddWithValue("@FileExtension", _FileExtension);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
cm.Parameters.AddWithValue("@DocPdf", _DocPdf);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
|
cm.Parameters.AddWithValue("@FileExtension", _FileExtension);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@DocPdf", _DocPdf);
|
||||||
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt);
|
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
|
||||||
param_AuditID.Direction = ParameterDirection.Output;
|
// Output Calculated Columns
|
||||||
cm.Parameters.Add(param_AuditID);
|
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt)
|
||||||
// CSLATODO: Define any additional output parameters
|
{
|
||||||
cm.ExecuteNonQuery();
|
Direction = ParameterDirection.Output
|
||||||
// Save all values being returned from the Procedure
|
};
|
||||||
_AuditID = (long)cm.Parameters["@newAuditID"].Value;
|
cm.Parameters.Add(param_AuditID);
|
||||||
|
// CSLATODO: Define any additional output parameters
|
||||||
|
cm.ExecuteNonQuery();
|
||||||
|
// Save all values being returned from the Procedure
|
||||||
|
_AuditID = (long)cm.Parameters["@newAuditID"].Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
// update child objects
|
// update child objects
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAudit.SQLInsert", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAudit.SQLInsert", GetHashCode());
|
||||||
@@ -805,8 +692,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
cm.Parameters.AddWithValue("@DocPdf", docPdf);
|
cm.Parameters.AddWithValue("@DocPdf", docPdf);
|
||||||
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;
|
{
|
||||||
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
cm.Parameters.Add(param_AuditID);
|
cm.Parameters.Add(param_AuditID);
|
||||||
// CSLATODO: Define any additional output parameters
|
// CSLATODO: Define any additional output parameters
|
||||||
cm.ExecuteNonQuery();
|
cm.ExecuteNonQuery();
|
||||||
@@ -851,32 +740,35 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAudit.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAudit.SQLUpdate", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
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 = "updateDocumentAudit";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@AuditID", _AuditID);
|
cm.CommandText = "updateDocumentAudit";
|
||||||
cm.Parameters.AddWithValue("@DocID", _DocID);
|
// All Fields including Calculated Fields
|
||||||
cm.Parameters.AddWithValue("@LibTitle", _LibTitle);
|
cm.Parameters.AddWithValue("@AuditID", _AuditID);
|
||||||
cm.Parameters.AddWithValue("@DocContent", _DocContent);
|
cm.Parameters.AddWithValue("@DocID", _DocID);
|
||||||
cm.Parameters.AddWithValue("@DocAscii", _DocAscii);
|
cm.Parameters.AddWithValue("@LibTitle", _LibTitle);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@DocContent", _DocContent);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@DocAscii", _DocAscii);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
cm.Parameters.AddWithValue("@FileExtension", _FileExtension);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
cm.Parameters.AddWithValue("@DocPdf", _DocPdf);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
|
cm.Parameters.AddWithValue("@FileExtension", _FileExtension);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@DocPdf", _DocPdf);
|
||||||
// CSLATODO: Define any additional output parameters
|
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
|
||||||
cm.ExecuteNonQuery();
|
// Output Calculated Columns
|
||||||
// Save all values being returned from the Procedure
|
// CSLATODO: Define any additional output parameters
|
||||||
|
cm.ExecuteNonQuery();
|
||||||
|
// Save all values being returned from the Procedure
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
// use the open connection to update child objects
|
// use the open connection to update child objects
|
||||||
}
|
}
|
||||||
@@ -889,14 +781,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)
|
{
|
||||||
DocumentAudit.Add(cn, ref _AuditID, _DocID, _LibTitle, _DocContent, _DocAscii, _Config, _DTS, _UserID, _FileExtension, _DocPdf, _DeleteStatus);
|
if (IsNew)
|
||||||
else
|
DocumentAudit.Add(cn, ref _AuditID, _DocID, _LibTitle, _DocContent, _DocAscii, _Config, _DTS, _UserID, _FileExtension, _DocPdf, _DeleteStatus);
|
||||||
DocumentAudit.Update(cn, ref _AuditID, _DocID, _LibTitle, _DocContent, _DocAscii, _Config, _DTS, _UserID, _FileExtension, _DocPdf, _DeleteStatus);
|
else
|
||||||
|
DocumentAudit.Update(cn, ref _AuditID, _DocID, _LibTitle, _DocContent, _DocAscii, _Config, _DTS, _UserID, _FileExtension, _DocPdf, _DeleteStatus);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -937,10 +832,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(_AuditID));
|
||||||
{
|
|
||||||
DataPortal_Delete(new PKCriteria(_AuditID));
|
|
||||||
}
|
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
private void DataPortal_Delete(PKCriteria criteria)
|
private void DataPortal_Delete(PKCriteria criteria)
|
||||||
{
|
{
|
||||||
@@ -992,7 +884,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
DocumentAuditExtension _DocumentAuditExtension = new DocumentAuditExtension();
|
readonly DocumentAuditExtension _DocumentAuditExtension = new DocumentAuditExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class DocumentAuditExtension : extensionBase
|
partial class DocumentAuditExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -1029,49 +921,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 DocumentAudit)
|
if (destType == typeof(string) && value is DocumentAudit audit)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((DocumentAudit)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 DocumentAuditExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class DocumentAudit
|
|
||||||
// {
|
|
||||||
// partial class DocumentAuditExtension : 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,14 +26,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public partial class DocumentAuditInfo : ReadOnlyBase<DocumentAuditInfo>, IDisposable
|
public partial class DocumentAuditInfo : ReadOnlyBase<DocumentAuditInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public event DocumentAuditInfoEvent Changed;
|
public event DocumentAuditInfoEvent 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<DocumentAuditInfo> _CacheList = new List<DocumentAuditInfo>();
|
private static List<DocumentAuditInfo> _CacheList = new List<DocumentAuditInfo>();
|
||||||
protected static void AddToCache(DocumentAuditInfo documentAuditInfo)
|
protected static void AddToCache(DocumentAuditInfo documentAuditInfo)
|
||||||
{
|
{
|
||||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(documentAuditInfo)) _CacheList.Remove(documentAuditInfo); // In RemoveFromCache
|
while (_CacheList.Contains(documentAuditInfo)) _CacheList.Remove(documentAuditInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<DocumentAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocumentAuditInfo>>();
|
private static Dictionary<string, List<DocumentAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocumentAuditInfo>>();
|
||||||
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 DocumentAudit _Editable;
|
protected DocumentAudit _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,32 +164,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _DeleteStatus;
|
return _DeleteStatus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base DocumentAuditInfo.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current DocumentAuditInfo</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check DocumentAuditInfo.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check DocumentAuditInfo.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 DocumentAuditInfo</returns>
|
/// <returns>A Unique ID for the current DocumentAuditInfo</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyDocumentAuditInfoUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyDocumentAuditInfoUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _DocumentAuditInfoUnique = 0;
|
private static int _DocumentAuditInfoUnique = 0;
|
||||||
private static int DocumentAuditInfoUnique
|
private static int DocumentAuditInfoUnique => ++_DocumentAuditInfoUnique;
|
||||||
{ get { return ++_DocumentAuditInfoUnique; } }
|
private readonly int _MyDocumentAuditInfoUnique = DocumentAuditInfoUnique;
|
||||||
private int _MyDocumentAuditInfoUnique = DocumentAuditInfoUnique;
|
// Absolutely Unique ID - Info
|
||||||
public int MyDocumentAuditInfoUnique // Absolutely Unique ID - Info
|
public int MyDocumentAuditInfoUnique => _MyDocumentAuditInfoUnique;
|
||||||
{ get { return _MyDocumentAuditInfoUnique; } }
|
|
||||||
protected DocumentAuditInfo()
|
protected DocumentAuditInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -214,15 +185,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; } }
|
|
||||||
~DocumentAuditInfo()
|
~DocumentAuditInfo()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -239,10 +206,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (listDocumentAuditInfo.Count == 0) // If there are no items left in the list
|
if (listDocumentAuditInfo.Count == 0) // If there are no items left in the list
|
||||||
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
|
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
|
||||||
}
|
}
|
||||||
public virtual DocumentAudit Get()
|
public virtual DocumentAudit Get() => _Editable = DocumentAudit.Get(_AuditID);
|
||||||
{
|
|
||||||
return _Editable = DocumentAudit.Get(_AuditID);
|
|
||||||
}
|
|
||||||
public static void Refresh(DocumentAudit tmp)
|
public static void Refresh(DocumentAudit tmp)
|
||||||
{
|
{
|
||||||
string key = tmp.AuditID.ToString();
|
string key = tmp.AuditID.ToString();
|
||||||
@@ -267,8 +231,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static DocumentAuditInfo Get(long auditID)
|
public static DocumentAuditInfo Get(long auditID)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a DocumentAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DocumentAuditInfo tmp = GetCachedByPrimaryKey(auditID);
|
DocumentAuditInfo tmp = GetCachedByPrimaryKey(auditID);
|
||||||
@@ -307,13 +269,9 @@ 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)
|
||||||
{
|
{
|
||||||
@@ -377,7 +335,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
DocumentAuditInfoExtension _DocumentAuditInfoExtension = new DocumentAuditInfoExtension();
|
readonly DocumentAuditInfoExtension _DocumentAuditInfoExtension = new DocumentAuditInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class DocumentAuditInfoExtension : extensionBase { }
|
partial class DocumentAuditInfoExtension : extensionBase { }
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
@@ -393,10 +351,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 DocumentAuditInfo)
|
if (destType == typeof(string) && value is DocumentAuditInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((DocumentAuditInfo)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<DocumentAuditInfo> Items
|
internal new IList<DocumentAuditInfo> Items => base.Items;
|
||||||
{ get { return base.Items; } }
|
public void AddEvents()
|
||||||
public void AddEvents()
|
|
||||||
{
|
{
|
||||||
foreach (DocumentAuditInfo tmp in this)
|
foreach (DocumentAuditInfo 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
|
~DocumentAuditInfoList()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~DocumentAuditInfoList()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -97,26 +90,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on DocumentAuditInfoList.Get", ex);
|
throw new DbCslaException("Error on DocumentAuditInfoList.Get", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset the list of all DocumentAuditInfo.
|
/// Reset the list of all DocumentAuditInfo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Reset()
|
public static void Reset() => _DocumentAuditInfoList = null;
|
||||||
{
|
private DocumentAuditInfoList()
|
||||||
_DocumentAuditInfoList = null;
|
|
||||||
}
|
|
||||||
// CSLATODO: Add alternative gets -
|
|
||||||
//public static DocumentAuditInfoList Get(<criteria>)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// return DataPortal.Fetch<DocumentAuditInfoList>(new FilteredCriteria(<criteria>));
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// throw new DbCslaException("Error on DocumentAuditInfoList.Get", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
private DocumentAuditInfoList()
|
|
||||||
{ /* require use of factory methods */ }
|
{ /* require use of factory methods */ }
|
||||||
#endregion
|
#endregion
|
||||||
#region Data Access Portal
|
#region Data Access Portal
|
||||||
@@ -149,41 +127,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,7 +172,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class DocumentAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class DocumentAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private DocumentAuditInfo Item { get { return (DocumentAuditInfo)_Item; } }
|
|
||||||
public DocumentAuditInfoListPropertyDescriptor(DocumentAuditInfoList collection, int index) : base(collection, index) { ;}
|
public DocumentAuditInfoListPropertyDescriptor(DocumentAuditInfoList collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -214,10 +180,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 DocumentAuditInfoList)
|
if (destType == typeof(string) && value is DocumentAuditInfoList list)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((DocumentAuditInfoList)value).Items.Count.ToString() + " DocumentAudits";
|
return $"{list.Items.Count} DocumentAudits";
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,11 +28,8 @@ 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;
|
||||||
{
|
|
||||||
get { return _ErrorMessage; }
|
|
||||||
}
|
|
||||||
private int _DROUsageID;
|
private int _DROUsageID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int DROUsageID
|
public int DROUsageID
|
||||||
@@ -232,10 +226,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// 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 DocumentDROUsage</returns>
|
/// <returns>A Unique ID for the current DocumentDROUsage</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyDocumentDROUsageUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyDocumentDROUsageUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
// CSLATODO: Replace base DocumentDROUsage.ToString function as necessary
|
// CSLATODO: Replace base DocumentDROUsage.ToString function as necessary
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides Base ToString
|
/// Overrides Base ToString
|
||||||
@@ -259,18 +250,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 || (_MyRODb == null ? false : _MyRODb.IsDirtyList(list));
|
return base.IsDirty || (_MyRODb != null && _MyRODb.IsDirtyList(list));
|
||||||
}
|
|
||||||
public override bool IsValid
|
|
||||||
{
|
|
||||||
get { return IsValidList(new List<object>()); }
|
|
||||||
}
|
}
|
||||||
|
public override bool IsValid => IsValidList(new List<object>());
|
||||||
public bool IsValidList(List<object> list)
|
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) && (_MyRODb == null ? true : _MyRODb.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_MyRODb == null || _MyRODb.IsValidList(list));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
@@ -300,8 +288,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()
|
||||||
@@ -331,78 +319,22 @@ 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
|
#endregion
|
||||||
#region Authorization Rules
|
#region Authorization Rules
|
||||||
protected override void AddAuthorizationRules()
|
protected override void AddAuthorizationRules()
|
||||||
{
|
{
|
||||||
//CSLATODO: Who can read/write which fields
|
|
||||||
//AuthorizationRules.AllowRead(DROUsageID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ROID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ROID, "<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)>");
|
|
||||||
//AuthorizationRules.AllowRead(RODbID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(RODbID, "<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
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
public int CurrentEditLevel
|
public int CurrentEditLevel => EditLevel;
|
||||||
{ get { return EditLevel; } }
|
|
||||||
private static int _DocumentDROUsageUnique = 0;
|
private static int _DocumentDROUsageUnique = 0;
|
||||||
private static int DocumentDROUsageUnique
|
private static int DocumentDROUsageUnique => ++_DocumentDROUsageUnique;
|
||||||
{ get { return ++_DocumentDROUsageUnique; } }
|
private readonly int _MyDocumentDROUsageUnique = DocumentDROUsageUnique;
|
||||||
private int _MyDocumentDROUsageUnique = DocumentDROUsageUnique;
|
// Absolutely Unique ID - Editable FK
|
||||||
public int MyDocumentDROUsageUnique // Absolutely Unique ID - Editable FK
|
public int MyDocumentDROUsageUnique => _MyDocumentDROUsageUnique;
|
||||||
{ get { return _MyDocumentDROUsageUnique; } }
|
internal static DocumentDROUsage New(string roid, RODb myRODb) => new DocumentDROUsage(roid, myRODb);
|
||||||
internal static DocumentDROUsage New(string roid, RODb myRODb)
|
internal static DocumentDROUsage Get(SafeDataReader dr) => new DocumentDROUsage(dr);
|
||||||
{
|
|
||||||
return new DocumentDROUsage(roid, myRODb);
|
|
||||||
}
|
|
||||||
internal static DocumentDROUsage Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new DocumentDROUsage(dr);
|
|
||||||
}
|
|
||||||
public DocumentDROUsage()
|
public DocumentDROUsage()
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
@@ -431,15 +363,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; } }
|
|
||||||
~DocumentDROUsage()
|
~DocumentDROUsage()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -481,33 +409,43 @@ namespace VEPROMS.CSLA.Library
|
|||||||
internal void Insert(Document myDocument)
|
internal void Insert(Document myDocument)
|
||||||
{
|
{
|
||||||
// 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 = DROUsage.Add(cn, ref _DROUsageID, myDocument, _ROID, _Config, _DTS, _UserID, _MyRODb);
|
{
|
||||||
|
_LastChanged = DROUsage.Add(cn, ref _DROUsageID, myDocument, _ROID, _Config, _DTS, _UserID, _MyRODb);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
internal void Update(Document myDocument)
|
internal void Update(Document myDocument)
|
||||||
{
|
{
|
||||||
// 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 = DROUsage.Update(cn, ref _DROUsageID, myDocument.DocID, _ROID, _Config, _DTS, _UserID, ref _LastChanged, _RODbID);
|
{
|
||||||
|
_LastChanged = DROUsage.Update(cn, ref _DROUsageID, myDocument.DocID, _ROID, _Config, _DTS, _UserID, ref _LastChanged, _RODbID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
internal void DeleteSelf(Document myDocument)
|
internal void DeleteSelf(Document myDocument)
|
||||||
{
|
{
|
||||||
// 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;
|
||||||
// if we're new then don't update the database
|
// if we're new then don't update the database
|
||||||
if (this.IsNew) return;
|
if (IsNew) return;
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
DROUsage.Remove(cn, _DROUsageID);
|
{
|
||||||
|
DROUsage.Remove(cn, _DROUsageID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkNew();
|
MarkNew();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
DocumentDROUsageExtension _DocumentDROUsageExtension = new DocumentDROUsageExtension();
|
readonly DocumentDROUsageExtension _DocumentDROUsageExtension = new DocumentDROUsageExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class DocumentDROUsageExtension : extensionBase
|
partial class DocumentDROUsageExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -516,18 +454,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
class extensionBase
|
class extensionBase
|
||||||
{
|
{
|
||||||
// Default Values
|
// Default Values
|
||||||
public virtual int DefaultDocID
|
public virtual int DefaultDocID => 0;
|
||||||
{
|
public virtual DateTime DefaultDTS => DateTime.Now;
|
||||||
get { return 0; }
|
public virtual string DefaultUserID => Volian.Base.Library.VlnSettings.UserID;
|
||||||
}
|
|
||||||
public virtual DateTime DefaultDTS
|
|
||||||
{
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -556,61 +485,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 DocumentDROUsage)
|
if (destType == typeof(string) && value is DocumentDROUsage usage)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((DocumentDROUsage)value).ToString();
|
return usage.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 DocumentDROUsageExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class DocumentDROUsage
|
|
||||||
// {
|
|
||||||
// partial class DocumentDROUsageExtension : extensionBase
|
|
||||||
// {
|
|
||||||
// // CSLATODO: Override automatic defaults
|
|
||||||
// public virtual int DefaultDocID
|
|
||||||
// {
|
|
||||||
// get { return 0; }
|
|
||||||
// }
|
|
||||||
// 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 DocumentDROUsage this[DROUsage myDROUsage]
|
||||||
}
|
|
||||||
// One To Many
|
|
||||||
public DocumentDROUsage this[DROUsage myDROUsage]
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -47,11 +42,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public new System.Collections.Generic.IList<DocumentDROUsage> Items
|
public new System.Collections.Generic.IList<DocumentDROUsage> Items => base.Items;
|
||||||
{
|
public DocumentDROUsage GetItem(DROUsage myDROUsage)
|
||||||
get { return base.Items; }
|
|
||||||
}
|
|
||||||
public DocumentDROUsage GetItem(DROUsage myDROUsage)
|
|
||||||
{
|
{
|
||||||
foreach (DocumentDROUsage dROUsage in this)
|
foreach (DocumentDROUsage dROUsage in this)
|
||||||
if (dROUsage.DROUsageID == myDROUsage.DROUsageID)
|
if (dROUsage.DROUsageID == myDROUsage.DROUsageID)
|
||||||
@@ -61,7 +53,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public DocumentDROUsage Add(string roid, RODb myRODb) // One to Many
|
public DocumentDROUsage Add(string roid, RODb myRODb) // One to Many
|
||||||
{
|
{
|
||||||
DocumentDROUsage dROUsage = DocumentDROUsage.New(roid, myRODb);
|
DocumentDROUsage dROUsage = DocumentDROUsage.New(roid, myRODb);
|
||||||
this.Add(dROUsage);
|
Add(dROUsage);
|
||||||
return dROUsage;
|
return dROUsage;
|
||||||
}
|
}
|
||||||
public void Remove(DROUsage myDROUsage)
|
public void Remove(DROUsage myDROUsage)
|
||||||
@@ -103,23 +95,20 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public override bool IsValid
|
public override bool IsValid => IsValidList(new List<object>());
|
||||||
|
public bool IsValidList(List<object> list)
|
||||||
{
|
{
|
||||||
get { return IsValidList(new List<object>()); }
|
// run through all the child objects
|
||||||
}
|
// and if any are invalid then the
|
||||||
public bool IsValidList(List<object> list)
|
// collection is invalid
|
||||||
{
|
foreach (DocumentDROUsage child in this)
|
||||||
// run through all the child objects
|
if (!child.IsValidList(list))
|
||||||
// and if any are invalid then the
|
{
|
||||||
// collection is invalid
|
//Console.WriteLine("Valid {0} Child {1} - {2}", child.IsValid, child.GetType().Name,child.ToString());
|
||||||
foreach (DocumentDROUsage child in this)
|
return false;
|
||||||
if (!child.IsValidList(list))
|
}
|
||||||
{
|
return true;
|
||||||
//Console.WriteLine("Valid {0} Child {1} - {2}", child.IsValid, child.GetType().Name,child.ToString());
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
public IVEHasBrokenRules HasBrokenRules
|
public IVEHasBrokenRules HasBrokenRules
|
||||||
@@ -137,20 +126,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 DocumentDROUsages New()
|
internal static DocumentDROUsages New() => new DocumentDROUsages();
|
||||||
{
|
internal static DocumentDROUsages Get(SafeDataReader dr) => new DocumentDROUsages(dr);
|
||||||
return new DocumentDROUsages();
|
public static DocumentDROUsages GetByDocID(int docID)
|
||||||
}
|
|
||||||
internal static DocumentDROUsages Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new DocumentDROUsages(dr);
|
|
||||||
}
|
|
||||||
public static DocumentDROUsages GetByDocID(int docID)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -161,11 +144,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on DocumentDROUsages.GetByDocID", ex);
|
throw new DbCslaException("Error on DocumentDROUsages.GetByDocID", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private DocumentDROUsages()
|
private DocumentDROUsages() => MarkAsChild();
|
||||||
{
|
internal DocumentDROUsages(SafeDataReader dr)
|
||||||
MarkAsChild();
|
|
||||||
}
|
|
||||||
internal DocumentDROUsages(SafeDataReader dr)
|
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
Fetch(dr);
|
Fetch(dr);
|
||||||
@@ -174,16 +154,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
|
~DocumentDROUsages()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~DocumentDROUsages()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -198,19 +174,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(DocumentDROUsage.Get(dr));
|
Add(DocumentDROUsage.Get(dr));
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class DocIDCriteria
|
private class DocIDCriteria
|
||||||
{
|
{
|
||||||
public DocIDCriteria(int docID)
|
public DocIDCriteria(int docID) => _DocID = docID;
|
||||||
{
|
private int _DocID;
|
||||||
_DocID = docID;
|
|
||||||
}
|
|
||||||
private int _DocID;
|
|
||||||
public int DocID
|
public int DocID
|
||||||
{
|
{
|
||||||
get { return _DocID; }
|
get { return _DocID; }
|
||||||
@@ -219,7 +192,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
private void DataPortal_Fetch(DocIDCriteria criteria)
|
private void DataPortal_Fetch(DocIDCriteria criteria)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentDROUsages.DataPortal_FetchDocID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentDROUsages.DataPortal_FetchDocID", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -233,7 +206,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 DocumentDROUsage(dr));
|
while (dr.Read()) Add(new DocumentDROUsage(dr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,11 +216,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentDROUsages.DataPortal_FetchDocID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentDROUsages.DataPortal_FetchDocID", ex);
|
||||||
throw new DbCslaException("DocumentDROUsages.DataPortal_Fetch", ex);
|
throw new DbCslaException("DocumentDROUsages.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
internal void Update(Document document)
|
internal void Update(Document document)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// update (thus deleting) any deleted child objects
|
// update (thus deleting) any deleted child objects
|
||||||
@@ -266,49 +239,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
|
||||||
DocumentDROUsagesPropertyDescriptor pd = new DocumentDROUsagesPropertyDescriptor(this, i);
|
DocumentDROUsagesPropertyDescriptor pd = new DocumentDROUsagesPropertyDescriptor(this, i);
|
||||||
@@ -325,7 +287,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class DocumentDROUsagesPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class DocumentDROUsagesPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private DocumentDROUsage Item { get { return (DocumentDROUsage)_Item; } }
|
|
||||||
public DocumentDROUsagesPropertyDescriptor(DocumentDROUsages collection, int index) : base(collection, index) { ;}
|
public DocumentDROUsagesPropertyDescriptor(DocumentDROUsages collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -334,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 DocumentDROUsages)
|
if (destType == typeof(string) && value is DocumentDROUsages usages)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((DocumentDROUsages)value).Items.Count.ToString() + " DROUsages";
|
return $"{usages.Items.Count} DROUsages";
|
||||||
}
|
}
|
||||||
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;
|
||||||
@@ -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 DocumentEntry this[Entry myEntry]
|
||||||
}
|
|
||||||
// One To Many
|
|
||||||
public DocumentEntry this[Entry myEntry]
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -47,11 +42,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public new System.Collections.Generic.IList<DocumentEntry> Items
|
public new System.Collections.Generic.IList<DocumentEntry> Items => base.Items;
|
||||||
{
|
public DocumentEntry GetItem(Entry myEntry)
|
||||||
get { return base.Items; }
|
|
||||||
}
|
|
||||||
public DocumentEntry GetItem(Entry myEntry)
|
|
||||||
{
|
{
|
||||||
foreach (DocumentEntry entry in this)
|
foreach (DocumentEntry entry in this)
|
||||||
if (entry.ContentID == myEntry.ContentID)
|
if (entry.ContentID == myEntry.ContentID)
|
||||||
@@ -61,7 +53,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public DocumentEntry Add(Entry myEntry) // One to Many
|
public DocumentEntry Add(Entry myEntry) // One to Many
|
||||||
{
|
{
|
||||||
DocumentEntry entry = DocumentEntry.New(myEntry);
|
DocumentEntry entry = DocumentEntry.New(myEntry);
|
||||||
this.Add(entry);
|
Add(entry);
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
public void Remove(Entry myEntry)
|
public void Remove(Entry myEntry)
|
||||||
@@ -103,23 +95,20 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public override bool IsValid
|
public override bool IsValid => IsValidList(new List<object>());
|
||||||
|
public bool IsValidList(List<object> list)
|
||||||
{
|
{
|
||||||
get { return IsValidList(new List<object>()); }
|
// run through all the child objects
|
||||||
}
|
// and if any are invalid then the
|
||||||
public bool IsValidList(List<object> list)
|
// collection is invalid
|
||||||
{
|
foreach (DocumentEntry child in this)
|
||||||
// run through all the child objects
|
if (!child.IsValidList(list))
|
||||||
// and if any are invalid then the
|
{
|
||||||
// collection is invalid
|
//Console.WriteLine("Valid {0} Child {1} - {2}", child.IsValid, child.GetType().Name,child.ToString());
|
||||||
foreach (DocumentEntry child in this)
|
return false;
|
||||||
if (!child.IsValidList(list))
|
}
|
||||||
{
|
return true;
|
||||||
//Console.WriteLine("Valid {0} Child {1} - {2}", child.IsValid, child.GetType().Name,child.ToString());
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
public IVEHasBrokenRules HasBrokenRules
|
public IVEHasBrokenRules HasBrokenRules
|
||||||
@@ -137,20 +126,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 DocumentEntries New()
|
internal static DocumentEntries New() => new DocumentEntries();
|
||||||
{
|
internal static DocumentEntries Get(SafeDataReader dr) => new DocumentEntries(dr);
|
||||||
return new DocumentEntries();
|
public static DocumentEntries GetByDocID(int docID)
|
||||||
}
|
|
||||||
internal static DocumentEntries Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new DocumentEntries(dr);
|
|
||||||
}
|
|
||||||
public static DocumentEntries GetByDocID(int docID)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -161,11 +144,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on DocumentEntries.GetByDocID", ex);
|
throw new DbCslaException("Error on DocumentEntries.GetByDocID", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private DocumentEntries()
|
private DocumentEntries() => MarkAsChild();
|
||||||
{
|
internal DocumentEntries(SafeDataReader dr)
|
||||||
MarkAsChild();
|
|
||||||
}
|
|
||||||
internal DocumentEntries(SafeDataReader dr)
|
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
Fetch(dr);
|
Fetch(dr);
|
||||||
@@ -174,16 +154,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
|
~DocumentEntries()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~DocumentEntries()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -198,19 +174,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(DocumentEntry.Get(dr));
|
Add(DocumentEntry.Get(dr));
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class DocIDCriteria
|
private class DocIDCriteria
|
||||||
{
|
{
|
||||||
public DocIDCriteria(int docID)
|
public DocIDCriteria(int docID) => _DocID = docID;
|
||||||
{
|
private int _DocID;
|
||||||
_DocID = docID;
|
|
||||||
}
|
|
||||||
private int _DocID;
|
|
||||||
public int DocID
|
public int DocID
|
||||||
{
|
{
|
||||||
get { return _DocID; }
|
get { return _DocID; }
|
||||||
@@ -219,7 +192,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
private void DataPortal_Fetch(DocIDCriteria criteria)
|
private void DataPortal_Fetch(DocIDCriteria criteria)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentEntries.DataPortal_FetchDocID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentEntries.DataPortal_FetchDocID", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -233,7 +206,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 DocumentEntry(dr));
|
while (dr.Read()) Add(new DocumentEntry(dr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,11 +216,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentEntries.DataPortal_FetchDocID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentEntries.DataPortal_FetchDocID", ex);
|
||||||
throw new DbCslaException("DocumentEntries.DataPortal_Fetch", ex);
|
throw new DbCslaException("DocumentEntries.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
internal void Update(Document document)
|
internal void Update(Document document)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// update (thus deleting) any deleted child objects
|
// update (thus deleting) any deleted child objects
|
||||||
@@ -266,49 +239,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
|
||||||
DocumentEntriesPropertyDescriptor pd = new DocumentEntriesPropertyDescriptor(this, i);
|
DocumentEntriesPropertyDescriptor pd = new DocumentEntriesPropertyDescriptor(this, i);
|
||||||
@@ -325,7 +287,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class DocumentEntriesPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class DocumentEntriesPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private DocumentEntry Item { get { return (DocumentEntry)_Item; } }
|
|
||||||
public DocumentEntriesPropertyDescriptor(DocumentEntries collection, int index) : base(collection, index) { ;}
|
public DocumentEntriesPropertyDescriptor(DocumentEntries collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -334,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 DocumentEntries)
|
if (destType == typeof(string) && value is DocumentEntries entries)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((DocumentEntries)value).Items.Count.ToString() + " Entries";
|
return $"{entries.Items.Count} Entries";
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,11 +28,8 @@ 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;
|
||||||
{
|
|
||||||
get { return _ErrorMessage; }
|
|
||||||
}
|
|
||||||
private int _ContentID;
|
private int _ContentID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int ContentID
|
public int ContentID
|
||||||
@@ -170,35 +164,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// 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 DocumentEntry</returns>
|
/// <returns>A Unique ID for the current DocumentEntry</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyDocumentEntryUnique; // Absolutely Unique ID
|
||||||
{
|
public override bool IsDirty => base.IsDirty;
|
||||||
return MyDocumentEntryUnique; // Absolutely Unique ID
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
}
|
public bool IsDirtyList(List<object> list) => base.IsDirty;
|
||||||
// CSLATODO: Replace base DocumentEntry.ToString function as necessary
|
public override bool IsValid => (IsNew && !IsDirty) || base.IsValid;
|
||||||
/// <summary>
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
/// Overrides Base ToString
|
public bool IsValidList(List<object> list) => (IsNew && !IsDirty) || base.IsValid;
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current DocumentEntry</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
public override bool IsDirty
|
|
||||||
{
|
|
||||||
get { return base.IsDirty; }
|
|
||||||
}
|
|
||||||
public bool IsDirtyList(List<object> list)
|
|
||||||
{
|
|
||||||
return base.IsDirty;
|
|
||||||
}
|
|
||||||
public override bool IsValid
|
|
||||||
{
|
|
||||||
get { return (IsNew && !IsDirty) ? true : base.IsValid; }
|
|
||||||
}
|
|
||||||
public bool IsValidList(List<object> list)
|
|
||||||
{
|
|
||||||
return (IsNew && !IsDirty) ? true : base.IsValid;
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
@@ -226,8 +198,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()
|
||||||
@@ -239,72 +211,22 @@ namespace VEPROMS.CSLA.Library
|
|||||||
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
|
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
|
||||||
// CSLATODO: Add other validation rules
|
// 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
|
#endregion
|
||||||
#region Authorization Rules
|
#region Authorization Rules
|
||||||
protected override void AddAuthorizationRules()
|
protected override void AddAuthorizationRules()
|
||||||
{
|
{
|
||||||
//CSLATODO: Who can read/write which fields
|
|
||||||
//AuthorizationRules.AllowRead(ContentID, "<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
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
public int CurrentEditLevel
|
public int CurrentEditLevel => EditLevel;
|
||||||
{ get { return EditLevel; } }
|
|
||||||
private static int _DocumentEntryUnique = 0;
|
private static int _DocumentEntryUnique = 0;
|
||||||
private static int DocumentEntryUnique
|
private static int DocumentEntryUnique => ++_DocumentEntryUnique;
|
||||||
{ get { return ++_DocumentEntryUnique; } }
|
private readonly int _MyDocumentEntryUnique = DocumentEntryUnique;
|
||||||
private int _MyDocumentEntryUnique = DocumentEntryUnique;
|
// Absolutely Unique ID - Editable FK
|
||||||
public int MyDocumentEntryUnique // Absolutely Unique ID - Editable FK
|
public int MyDocumentEntryUnique => _MyDocumentEntryUnique;
|
||||||
{ get { return _MyDocumentEntryUnique; } }
|
internal static DocumentEntry New(Entry myEntry) => new DocumentEntry(myEntry);
|
||||||
internal static DocumentEntry New(Entry myEntry)
|
internal static DocumentEntry Get(SafeDataReader dr) => new DocumentEntry(dr);
|
||||||
{
|
|
||||||
return new DocumentEntry(myEntry);
|
|
||||||
}
|
|
||||||
internal static DocumentEntry Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new DocumentEntry(dr);
|
|
||||||
}
|
|
||||||
public DocumentEntry()
|
public DocumentEntry()
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
@@ -331,15 +253,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; } }
|
|
||||||
~DocumentEntry()
|
~DocumentEntry()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -379,33 +297,43 @@ namespace VEPROMS.CSLA.Library
|
|||||||
internal void Insert(Document myDocument)
|
internal void Insert(Document myDocument)
|
||||||
{
|
{
|
||||||
// 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 = Entry.Add(cn, _MyEntry.MyContent, myDocument, _DTS, _UserID);
|
{
|
||||||
|
_LastChanged = Entry.Add(cn, _MyEntry.MyContent, myDocument, _DTS, _UserID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
internal void Update(Document myDocument)
|
internal void Update(Document myDocument)
|
||||||
{
|
{
|
||||||
// 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 = Entry.Update(cn, _ContentID, myDocument.DocID, _DTS, _UserID, ref _LastChanged);
|
{
|
||||||
|
_LastChanged = Entry.Update(cn, _ContentID, myDocument.DocID, _DTS, _UserID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
internal void DeleteSelf(Document myDocument)
|
internal void DeleteSelf(Document myDocument)
|
||||||
{
|
{
|
||||||
// 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;
|
||||||
// if we're new then don't update the database
|
// if we're new then don't update the database
|
||||||
if (this.IsNew) return;
|
if (IsNew) return;
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
Entry.Remove(cn, _ContentID);
|
{
|
||||||
|
Entry.Remove(cn, _ContentID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkNew();
|
MarkNew();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
DocumentEntryExtension _DocumentEntryExtension = new DocumentEntryExtension();
|
readonly DocumentEntryExtension _DocumentEntryExtension = new DocumentEntryExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class DocumentEntryExtension : extensionBase
|
partial class DocumentEntryExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -414,14 +342,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)
|
||||||
{
|
{
|
||||||
@@ -450,57 +372,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 DocumentEntry)
|
if (destType == typeof(string) && value is DocumentEntry entry)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((DocumentEntry)value).ToString();
|
return entry.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 DocumentEntryExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class DocumentEntry
|
|
||||||
// {
|
|
||||||
// partial class DocumentEntryExtension : 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 DocumentInfo : ReadOnlyBase<DocumentInfo>, IDisposable
|
public partial class DocumentInfo : ReadOnlyBase<DocumentInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public event DocumentInfoEvent Changed;
|
public event DocumentInfoEvent 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<DocumentInfo> _CacheList = new List<DocumentInfo>();
|
private static List<DocumentInfo> _CacheList = new List<DocumentInfo>();
|
||||||
protected static void AddToCache(DocumentInfo documentInfo)
|
protected static void AddToCache(DocumentInfo documentInfo)
|
||||||
{
|
{
|
||||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(documentInfo)) _CacheList.Remove(documentInfo); // In RemoveFromCache
|
while (_CacheList.Contains(documentInfo)) _CacheList.Remove(documentInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<DocumentInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocumentInfo>>();
|
private static Dictionary<string, List<DocumentInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocumentInfo>>();
|
||||||
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 Document _Editable;
|
protected Document _Editable;
|
||||||
private IVEHasBrokenRules HasBrokenRules
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
IVEHasBrokenRules hasBrokenRules = null;
|
|
||||||
if (_Editable != null)
|
|
||||||
hasBrokenRules = _Editable.HasBrokenRules;
|
|
||||||
return hasBrokenRules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private int _DocID;
|
private int _DocID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int DocID
|
public int DocID
|
||||||
@@ -276,32 +260,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
foreach (DocumentInfo tmp in _CacheByPrimaryKey[_DocID.ToString()])
|
foreach (DocumentInfo tmp in _CacheByPrimaryKey[_DocID.ToString()])
|
||||||
tmp._DocumentPdfCount = -1; // This will cause the data to be requeried
|
tmp._DocumentPdfCount = -1; // This will cause the data to be requeried
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base DocumentInfo.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current DocumentInfo</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check DocumentInfo.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check DocumentInfo.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 DocumentInfo</returns>
|
/// <returns>A Unique ID for the current DocumentInfo</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyDocumentInfoUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyDocumentInfoUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _DocumentInfoUnique = 0;
|
private static int _DocumentInfoUnique = 0;
|
||||||
private static int DocumentInfoUnique
|
private static int DocumentInfoUnique => ++_DocumentInfoUnique;
|
||||||
{ get { return ++_DocumentInfoUnique; } }
|
private readonly int _MyDocumentInfoUnique = DocumentInfoUnique;
|
||||||
private int _MyDocumentInfoUnique = DocumentInfoUnique;
|
// Absolutely Unique ID - Info
|
||||||
public int MyDocumentInfoUnique // Absolutely Unique ID - Info
|
public int MyDocumentInfoUnique => _MyDocumentInfoUnique;
|
||||||
{ get { return _MyDocumentInfoUnique; } }
|
|
||||||
protected DocumentInfo()
|
protected DocumentInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -310,15 +281,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; } }
|
|
||||||
~DocumentInfo()
|
~DocumentInfo()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -335,10 +302,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (listDocumentInfo.Count == 0) // If there are no items left in the list
|
if (listDocumentInfo.Count == 0) // If there are no items left in the list
|
||||||
_CacheByPrimaryKey.Remove(DocID.ToString()); // remove the list
|
_CacheByPrimaryKey.Remove(DocID.ToString()); // remove the list
|
||||||
}
|
}
|
||||||
public virtual Document Get()
|
public virtual Document Get() => _Editable = Document.Get(_DocID);
|
||||||
{
|
|
||||||
return _Editable = Document.Get(_DocID);
|
|
||||||
}
|
|
||||||
public static void Refresh(Document tmp)
|
public static void Refresh(Document tmp)
|
||||||
{
|
{
|
||||||
string key = tmp.DocID.ToString();
|
string key = tmp.DocID.ToString();
|
||||||
@@ -361,8 +325,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static DocumentInfo Get(int docID)
|
public static DocumentInfo Get(int docID)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a Document");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DocumentInfo tmp = GetCachedByPrimaryKey(docID);
|
DocumentInfo tmp = GetCachedByPrimaryKey(docID);
|
||||||
@@ -401,13 +363,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _DocID;
|
private readonly int _DocID;
|
||||||
public int DocID
|
public int DocID => _DocID;
|
||||||
{ get { return _DocID; } }
|
public PKCriteria(int docID) => _DocID = docID;
|
||||||
public PKCriteria(int docID)
|
|
||||||
{
|
|
||||||
_DocID = docID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void ReadData(SafeDataReader dr)
|
private void ReadData(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
@@ -472,7 +430,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
DocumentInfoExtension _DocumentInfoExtension = new DocumentInfoExtension();
|
readonly DocumentInfoExtension _DocumentInfoExtension = new DocumentInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class DocumentInfoExtension : extensionBase { }
|
partial class DocumentInfoExtension : extensionBase { }
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
@@ -488,10 +446,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 DocumentInfo)
|
if (destType == typeof(string) && value is DocumentInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((DocumentInfo)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<DocumentInfo> Items
|
internal new IList<DocumentInfo> Items => base.Items;
|
||||||
{ get { return base.Items; } }
|
public void AddEvents()
|
||||||
public void AddEvents()
|
|
||||||
{
|
{
|
||||||
foreach (DocumentInfo tmp in this)
|
foreach (DocumentInfo tmp in this)
|
||||||
{
|
{
|
||||||
@@ -44,23 +41,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
for (int i = 0; i < Count; i++)
|
for (int i = 0; i < Count; i++)
|
||||||
{
|
{
|
||||||
if (base[i] == sender)
|
if (base[i] == sender)
|
||||||
this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i));
|
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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
|
~DocumentInfoList()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~DocumentInfoList()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -97,32 +90,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on DocumentInfoList.Get", ex);
|
throw new DbCslaException("Error on DocumentInfoList.Get", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset the list of all DocumentInfo.
|
/// Reset the list of all DocumentInfo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Reset()
|
public static void Reset() => _DocumentInfoList = null;
|
||||||
{
|
private DocumentInfoList()
|
||||||
_DocumentInfoList = null;
|
|
||||||
}
|
|
||||||
// CSLATODO: Add alternative gets -
|
|
||||||
//public static DocumentInfoList Get(<criteria>)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// return DataPortal.Fetch<DocumentInfoList>(new FilteredCriteria(<criteria>));
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// throw new DbCslaException("Error on DocumentInfoList.Get", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
private DocumentInfoList()
|
|
||||||
{ /* require use of factory methods */ }
|
{ /* require use of factory methods */ }
|
||||||
#endregion
|
#endregion
|
||||||
#region Data Access Portal
|
#region Data Access Portal
|
||||||
private void DataPortal_Fetch()
|
private void DataPortal_Fetch()
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfoList.DataPortal_Fetch", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfoList.DataPortal_Fetch", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -136,7 +114,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||||
{
|
{
|
||||||
IsReadOnly = false;
|
IsReadOnly = false;
|
||||||
while (dr.Read()) this.Add(new DocumentInfo(dr));
|
while (dr.Read()) Add(new DocumentInfo(dr));
|
||||||
IsReadOnly = true;
|
IsReadOnly = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,48 +125,37 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfoList.DataPortal_Fetch", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfoList.DataPortal_Fetch", ex);
|
||||||
throw new DbCslaException("DocumentInfoList.DataPortal_Fetch", ex);
|
throw new DbCslaException("DocumentInfoList.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
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
|
||||||
DocumentInfoListPropertyDescriptor pd = new DocumentInfoListPropertyDescriptor(this, i);
|
DocumentInfoListPropertyDescriptor pd = new DocumentInfoListPropertyDescriptor(this, i);
|
||||||
@@ -205,7 +172,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class DocumentInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class DocumentInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private DocumentInfo Item { get { return (DocumentInfo)_Item; } }
|
|
||||||
public DocumentInfoListPropertyDescriptor(DocumentInfoList collection, int index) : base(collection, index) { ;}
|
public DocumentInfoListPropertyDescriptor(DocumentInfoList collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -214,10 +180,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 DocumentInfoList)
|
if (destType == typeof(string) && value is DocumentInfoList list)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((DocumentInfoList)value).Items.Count.ToString() + " Documents";
|
return $"{list.Items.Count} Documents";
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,11 +28,8 @@ 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;
|
||||||
{
|
|
||||||
get { return _ErrorMessage; }
|
|
||||||
}
|
|
||||||
private int _DebugStatus;
|
private int _DebugStatus;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// > 0 for Debug
|
/// > 0 for Debug
|
||||||
@@ -171,35 +165,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// 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 DocumentPdf</returns>
|
/// <returns>A Unique ID for the current DocumentPdf</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyDocumentPdfUnique; // Absolutely Unique ID
|
||||||
{
|
public override bool IsDirty => base.IsDirty;
|
||||||
return MyDocumentPdfUnique; // Absolutely Unique ID
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
}
|
public bool IsDirtyList(List<object> list) => base.IsDirty;
|
||||||
// CSLATODO: Replace base DocumentPdf.ToString function as necessary
|
public override bool IsValid => (IsNew && !IsDirty) || base.IsValid;
|
||||||
/// <summary>
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
/// Overrides Base ToString
|
public bool IsValidList(List<object> list) => (IsNew && !IsDirty) || base.IsValid;
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current DocumentPdf</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
public override bool IsDirty
|
|
||||||
{
|
|
||||||
get { return base.IsDirty; }
|
|
||||||
}
|
|
||||||
public bool IsDirtyList(List<object> list)
|
|
||||||
{
|
|
||||||
return base.IsDirty;
|
|
||||||
}
|
|
||||||
public override bool IsValid
|
|
||||||
{
|
|
||||||
get { return (IsNew && !IsDirty) ? true : base.IsValid; }
|
|
||||||
}
|
|
||||||
public bool IsValidList(List<object> list)
|
|
||||||
{
|
|
||||||
return (IsNew && !IsDirty) ? true : base.IsValid;
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
@@ -227,8 +199,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()
|
||||||
@@ -240,80 +212,21 @@ namespace VEPROMS.CSLA.Library
|
|||||||
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
|
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
|
||||||
// CSLATODO: Add other validation rules
|
// 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
|
#endregion
|
||||||
#region Authorization Rules
|
#region Authorization Rules
|
||||||
protected override void AddAuthorizationRules()
|
protected override void AddAuthorizationRules()
|
||||||
{
|
{
|
||||||
//CSLATODO: Who can read/write which fields
|
|
||||||
//AuthorizationRules.AllowRead(DebugStatus, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(TopRow, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(PageLength, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(LeftMargin, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(PageWidth, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(PageCount, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(PageCount, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DocPdf, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DocPdf, "<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
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
public int CurrentEditLevel
|
public int CurrentEditLevel => EditLevel;
|
||||||
{ get { return EditLevel; } }
|
|
||||||
private static int _DocumentPdfUnique = 0;
|
private static int _DocumentPdfUnique = 0;
|
||||||
private static int DocumentPdfUnique
|
private static int DocumentPdfUnique => ++_DocumentPdfUnique;
|
||||||
{ get { return ++_DocumentPdfUnique; } }
|
private readonly int _MyDocumentPdfUnique = DocumentPdfUnique;
|
||||||
private int _MyDocumentPdfUnique = DocumentPdfUnique;
|
// Absolutely Unique ID - Editable FK
|
||||||
public int MyDocumentPdfUnique // Absolutely Unique ID - Editable FK
|
public int MyDocumentPdfUnique => _MyDocumentPdfUnique;
|
||||||
{ get { return _MyDocumentPdfUnique; } }
|
internal static DocumentPdf New(int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth, double pageCount) => new DocumentPdf(debugStatus, topRow, pageLength, leftMargin, pageWidth, pageCount);
|
||||||
internal static DocumentPdf New(int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth, double pageCount)
|
internal static DocumentPdf Get(SafeDataReader dr) => new DocumentPdf(dr);
|
||||||
{
|
|
||||||
return new DocumentPdf(debugStatus, topRow, pageLength, leftMargin, pageWidth, pageCount);
|
|
||||||
}
|
|
||||||
internal static DocumentPdf Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new DocumentPdf(dr);
|
|
||||||
}
|
|
||||||
public DocumentPdf()
|
public DocumentPdf()
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
@@ -345,15 +258,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; } }
|
|
||||||
~DocumentPdf()
|
~DocumentPdf()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -392,33 +301,42 @@ namespace VEPROMS.CSLA.Library
|
|||||||
internal void Insert(Document myDocument)
|
internal void Insert(Document myDocument)
|
||||||
{
|
{
|
||||||
// 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 = Pdf.Add(cn, myDocument, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth, _PageCount, _DocPdf, _DTS, _UserID);
|
{
|
||||||
|
_LastChanged = Pdf.Add(cn, myDocument, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth, _PageCount, _DocPdf, _DTS, _UserID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
internal void Update(Document myDocument)
|
internal void Update(Document myDocument)
|
||||||
{
|
{
|
||||||
// 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 = Pdf.Update(cn, myDocument.DocID, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth, _PageCount, _DocPdf, _DTS, _UserID, ref _LastChanged);
|
{
|
||||||
|
_LastChanged = Pdf.Update(cn, myDocument.DocID, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth, _PageCount, _DocPdf, _DTS, _UserID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
internal void DeleteSelf(Document myDocument)
|
internal void DeleteSelf(Document myDocument)
|
||||||
{
|
{
|
||||||
// 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;
|
||||||
// if we're new then don't update the database
|
// if we're new then don't update the database
|
||||||
if (this.IsNew) return;
|
if (IsNew) return;
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||||
Pdf.Remove(cn, myDocument.DocID, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth);
|
{
|
||||||
|
Pdf.Remove(cn, myDocument.DocID, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth);
|
||||||
|
}
|
||||||
|
|
||||||
MarkNew();
|
MarkNew();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
DocumentPdfExtension _DocumentPdfExtension = new DocumentPdfExtension();
|
readonly DocumentPdfExtension _DocumentPdfExtension = new DocumentPdfExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class DocumentPdfExtension : extensionBase
|
partial class DocumentPdfExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -427,14 +345,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)
|
||||||
{
|
{
|
||||||
@@ -463,57 +375,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 DocumentPdf)
|
if (destType == typeof(string) && value is DocumentPdf docpdf)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((DocumentPdf)value).ToString();
|
return docpdf.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 DocumentPdfExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class DocumentPdf
|
|
||||||
// {
|
|
||||||
// partial class DocumentPdfExtension : 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 DocumentPdf this[int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth]
|
||||||
}
|
|
||||||
// One To Many
|
|
||||||
public DocumentPdf this[int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth]
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -47,11 +42,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public new System.Collections.Generic.IList<DocumentPdf> Items
|
public new System.Collections.Generic.IList<DocumentPdf> Items => base.Items;
|
||||||
{
|
public DocumentPdf GetItem(int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth)
|
||||||
get { return base.Items; }
|
|
||||||
}
|
|
||||||
public DocumentPdf GetItem(int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth)
|
|
||||||
{
|
{
|
||||||
foreach (DocumentPdf pdf in this)
|
foreach (DocumentPdf pdf in this)
|
||||||
if (pdf.DebugStatus == debugStatus && pdf.TopRow == topRow && pdf.PageLength == pageLength && pdf.LeftMargin == leftMargin && pdf.PageWidth == pageWidth)
|
if (pdf.DebugStatus == debugStatus && pdf.TopRow == topRow && pdf.PageLength == pageLength && pdf.LeftMargin == leftMargin && pdf.PageWidth == pageWidth)
|
||||||
@@ -63,7 +55,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (!Contains(debugStatus, topRow, pageLength, leftMargin, pageWidth))
|
if (!Contains(debugStatus, topRow, pageLength, leftMargin, pageWidth))
|
||||||
{
|
{
|
||||||
DocumentPdf pdf = DocumentPdf.New(debugStatus, topRow, pageLength, leftMargin, pageWidth, pageCount);
|
DocumentPdf pdf = DocumentPdf.New(debugStatus, topRow, pageLength, leftMargin, pageWidth, pageCount);
|
||||||
this.Add(pdf);
|
Add(pdf);
|
||||||
return pdf;
|
return pdf;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -108,23 +100,20 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public override bool IsValid
|
public override bool IsValid => IsValidList(new List<object>());
|
||||||
|
public bool IsValidList(List<object> list)
|
||||||
{
|
{
|
||||||
get { return IsValidList(new List<object>()); }
|
// run through all the child objects
|
||||||
}
|
// and if any are invalid then the
|
||||||
public bool IsValidList(List<object> list)
|
// collection is invalid
|
||||||
{
|
foreach (DocumentPdf child in this)
|
||||||
// run through all the child objects
|
if (!child.IsValidList(list))
|
||||||
// and if any are invalid then the
|
{
|
||||||
// collection is invalid
|
//Console.WriteLine("Valid {0} Child {1} - {2}", child.IsValid, child.GetType().Name,child.ToString());
|
||||||
foreach (DocumentPdf child in this)
|
return false;
|
||||||
if (!child.IsValidList(list))
|
}
|
||||||
{
|
return true;
|
||||||
//Console.WriteLine("Valid {0} Child {1} - {2}", child.IsValid, child.GetType().Name,child.ToString());
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
public IVEHasBrokenRules HasBrokenRules
|
public IVEHasBrokenRules HasBrokenRules
|
||||||
@@ -142,20 +131,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 DocumentPdfs New()
|
internal static DocumentPdfs New() => new DocumentPdfs();
|
||||||
{
|
internal static DocumentPdfs Get(SafeDataReader dr) => new DocumentPdfs(dr);
|
||||||
return new DocumentPdfs();
|
public static DocumentPdfs GetByDocID(int docID)
|
||||||
}
|
|
||||||
internal static DocumentPdfs Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new DocumentPdfs(dr);
|
|
||||||
}
|
|
||||||
public static DocumentPdfs GetByDocID(int docID)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -166,11 +149,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on DocumentPdfs.GetByDocID", ex);
|
throw new DbCslaException("Error on DocumentPdfs.GetByDocID", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private DocumentPdfs()
|
private DocumentPdfs() => MarkAsChild();
|
||||||
{
|
internal DocumentPdfs(SafeDataReader dr)
|
||||||
MarkAsChild();
|
|
||||||
}
|
|
||||||
internal DocumentPdfs(SafeDataReader dr)
|
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
Fetch(dr);
|
Fetch(dr);
|
||||||
@@ -179,16 +159,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
|
~DocumentPdfs()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~DocumentPdfs()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -203,19 +179,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(DocumentPdf.Get(dr));
|
Add(DocumentPdf.Get(dr));
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class DocIDCriteria
|
private class DocIDCriteria
|
||||||
{
|
{
|
||||||
public DocIDCriteria(int docID)
|
public DocIDCriteria(int docID) => _DocID = docID;
|
||||||
{
|
private int _DocID;
|
||||||
_DocID = docID;
|
|
||||||
}
|
|
||||||
private int _DocID;
|
|
||||||
public int DocID
|
public int DocID
|
||||||
{
|
{
|
||||||
get { return _DocID; }
|
get { return _DocID; }
|
||||||
@@ -224,7 +197,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
private void DataPortal_Fetch(DocIDCriteria criteria)
|
private void DataPortal_Fetch(DocIDCriteria criteria)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentPdfs.DataPortal_FetchDocID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentPdfs.DataPortal_FetchDocID", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -238,7 +211,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 DocumentPdf(dr));
|
while (dr.Read()) Add(new DocumentPdf(dr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,11 +221,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentPdfs.DataPortal_FetchDocID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentPdfs.DataPortal_FetchDocID", ex);
|
||||||
throw new DbCslaException("DocumentPdfs.DataPortal_Fetch", ex);
|
throw new DbCslaException("DocumentPdfs.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
internal void Update(Document document)
|
internal void Update(Document document)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// update (thus deleting) any deleted child objects
|
// update (thus deleting) any deleted child objects
|
||||||
@@ -271,49 +244,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
|
||||||
DocumentPdfsPropertyDescriptor pd = new DocumentPdfsPropertyDescriptor(this, i);
|
DocumentPdfsPropertyDescriptor pd = new DocumentPdfsPropertyDescriptor(this, i);
|
||||||
@@ -330,7 +292,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class DocumentPdfsPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class DocumentPdfsPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private DocumentPdf Item { get { return (DocumentPdf)_Item; } }
|
|
||||||
public DocumentPdfsPropertyDescriptor(DocumentPdfs collection, int index) : base(collection, index) { ;}
|
public DocumentPdfsPropertyDescriptor(DocumentPdfs collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -339,10 +300,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 DocumentPdfs)
|
if (destType == typeof(string) && value is DocumentPdfs pdfs)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((DocumentPdfs)value).Items.Count.ToString() + " Pdfs";
|
return $"{pdfs.Items.Count} Pdfs";
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user