CSLA - E & F
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;
|
||||||
@@ -57,6 +55,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<Entry> _CacheList = new List<Entry>();
|
private static List<Entry> _CacheList = new List<Entry>();
|
||||||
protected static void AddToCache(Entry entry)
|
protected static void AddToCache(Entry entry)
|
||||||
{
|
{
|
||||||
@@ -66,6 +65,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(entry)) _CacheList.Remove(entry); // In RemoveFromCache
|
while (_CacheList.Contains(entry)) _CacheList.Remove(entry); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<Entry>> _CacheByPrimaryKey = new Dictionary<string, List<Entry>>();
|
private static Dictionary<string, List<Entry>> _CacheByPrimaryKey = new Dictionary<string, List<Entry>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -91,10 +91,7 @@ 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 int _ContentID;
|
private int _ContentID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int ContentID
|
public int ContentID
|
||||||
@@ -199,7 +196,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));
|
return base.IsDirty || (_MyDocument != null && _MyDocument.IsDirtyList(list));
|
||||||
}
|
}
|
||||||
public override bool IsValid
|
public override bool IsValid
|
||||||
{
|
{
|
||||||
@@ -208,28 +205,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));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_MyDocument == null || _MyDocument.IsValidList(list));
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base Entry.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current Entry</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check Entry.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check Entry.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 Entry</returns>
|
/// <returns>A Unique ID for the current Entry</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyEntryUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyEntryUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
@@ -258,8 +243,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()
|
||||||
@@ -288,29 +273,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(ContentID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DocID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DocID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
|
||||||
_EntryExtension.AddAuthorizationRules(AuthorizationRules);
|
_EntryExtension.AddAuthorizationRules(AuthorizationRules);
|
||||||
}
|
}
|
||||||
protected override void AddInstanceAuthorizationRules()
|
protected override void AddInstanceAuthorizationRules()
|
||||||
@@ -318,42 +285,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//CSLATODO: Who can read/write which fields
|
//CSLATODO: Who can read/write which fields
|
||||||
_EntryExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
_EntryExtension.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 _EntryUnique = 0;
|
private static int _EntryUnique = 0;
|
||||||
protected static int EntryUnique
|
protected static int EntryUnique => ++_EntryUnique;
|
||||||
{ get { return ++_EntryUnique; } }
|
private readonly int _MyEntryUnique = EntryUnique;
|
||||||
private int _MyEntryUnique = EntryUnique;
|
// Absolutely Unique ID - Editable
|
||||||
public int MyEntryUnique // Absolutely Unique ID - Editable
|
public int MyEntryUnique => _MyEntryUnique;
|
||||||
{ get { return _MyEntryUnique; } }
|
|
||||||
protected Entry()
|
protected Entry()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -362,15 +301,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; } }
|
|
||||||
~Entry()
|
~Entry()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -395,8 +330,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Entry New()
|
public static Entry New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Entry");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<Entry>();
|
return DataPortal.Create<Entry>();
|
||||||
@@ -464,8 +397,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Entry Get(int contentID)
|
public static Entry Get(int contentID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a Entry");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Entry tmp = GetCachedByPrimaryKey(contentID);
|
Entry tmp = GetCachedByPrimaryKey(contentID);
|
||||||
@@ -491,14 +422,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dr.Read()) return new Entry(dr);
|
if (dr.Read()) return new Entry(dr);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
internal Entry(SafeDataReader dr)
|
internal Entry(SafeDataReader dr) => ReadData(dr);
|
||||||
{
|
|
||||||
ReadData(dr);
|
|
||||||
}
|
|
||||||
public static void Delete(int contentID)
|
public static void Delete(int contentID)
|
||||||
{
|
{
|
||||||
if (!CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Entry");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataPortal.Delete(new PKCriteria(contentID));
|
DataPortal.Delete(new PKCriteria(contentID));
|
||||||
@@ -510,12 +436,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public override Entry Save()
|
public override Entry Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Entry");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Entry");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a Entry");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -535,13 +455,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _ContentID;
|
private readonly int _ContentID;
|
||||||
public int ContentID
|
public int ContentID => _ContentID;
|
||||||
{ get { return _ContentID; } }
|
public PKCriteria(int contentID) => _ContentID = contentID;
|
||||||
public PKCriteria(int contentID)
|
|
||||||
{
|
|
||||||
_ContentID = contentID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 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()]
|
||||||
@@ -637,30 +553,35 @@ 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();
|
||||||
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 = "addEntry";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@ContentID", ContentID);
|
cm.CommandText = "addEntry";
|
||||||
cm.Parameters.AddWithValue("@DocID", DocID);
|
// Input All Fields - Except Calculated Columns
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@ContentID", ContentID);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
cm.Parameters.AddWithValue("@DocID", DocID);
|
||||||
// Output Calculated Columns
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
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();
|
||||||
// update child objects
|
// update child objects
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.SQLInsert", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.SQLInsert", GetHashCode());
|
||||||
@@ -689,8 +610,10 @@ 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_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();
|
||||||
@@ -734,31 +657,36 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.SQLUpdate", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_MyDocument != null) _MyDocument.Update();
|
_MyDocument?.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 = "updateEntry";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@ContentID", ContentID);
|
cm.CommandText = "updateEntry";
|
||||||
cm.Parameters.AddWithValue("@DocID", DocID);
|
// All Fields including Calculated Fields
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@ContentID", ContentID);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
cm.Parameters.AddWithValue("@DocID", DocID);
|
||||||
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
|
||||||
}
|
}
|
||||||
@@ -771,14 +699,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
internal void Update(Content content)
|
internal void Update(Content content)
|
||||||
{
|
{
|
||||||
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 = Entry.Add(cn, content, MyDocument, _DTS, _UserID);
|
if (IsNew)
|
||||||
else
|
_LastChanged = Entry.Add(cn, content, MyDocument, _DTS, _UserID);
|
||||||
_LastChanged = Entry.Update(cn, content.ContentID, _DocID, _DTS, _UserID, ref _LastChanged);
|
else
|
||||||
|
_LastChanged = Entry.Update(cn, content.ContentID, _DocID, _DTS, _UserID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
// B2018-126 & B2018-133: Refresh for library document usage change (note that original checkin had a null check for
|
// B2018-126 & B2018-133: Refresh for library document usage change (note that original checkin had a null check for
|
||||||
// _MyDocument.DocumentEntries that was causing a sql Distributed Transaction Coordinator error - this was removed
|
// _MyDocument.DocumentEntries that was causing a sql Distributed Transaction Coordinator error - this was removed
|
||||||
@@ -808,8 +739,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();
|
||||||
@@ -824,10 +757,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(_ContentID));
|
||||||
{
|
|
||||||
DataPortal_Delete(new PKCriteria(_ContentID));
|
|
||||||
}
|
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
private void DataPortal_Delete(PKCriteria criteria)
|
private void DataPortal_Delete(PKCriteria criteria)
|
||||||
{
|
{
|
||||||
@@ -894,16 +824,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ExistsCommand : CommandBase
|
private class ExistsCommand : CommandBase
|
||||||
{
|
{
|
||||||
private int _ContentID;
|
private readonly int _ContentID;
|
||||||
private bool _exists;
|
private bool _exists;
|
||||||
public bool Exists
|
public bool Exists => _exists;
|
||||||
{
|
public ExistsCommand(int contentID) => _ContentID = contentID;
|
||||||
get { return _exists; }
|
|
||||||
}
|
|
||||||
public ExistsCommand(int contentID)
|
|
||||||
{
|
|
||||||
_ContentID = contentID;
|
|
||||||
}
|
|
||||||
protected override void DataPortal_Execute()
|
protected override void DataPortal_Execute()
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.DataPortal_Execute", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Entry.DataPortal_Execute", GetHashCode());
|
||||||
@@ -933,7 +857,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
EntryExtension _EntryExtension = new EntryExtension();
|
readonly EntryExtension _EntryExtension = new EntryExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class EntryExtension : extensionBase
|
partial class EntryExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -942,14 +866,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)
|
||||||
{
|
{
|
||||||
@@ -978,57 +896,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 Entry)
|
if (destType == typeof(string) && value is Entry entry)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((Entry)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 EntryExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class Entry
|
|
||||||
// {
|
|
||||||
// partial class EntryExtension : 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;
|
||||||
@@ -37,10 +35,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (IsDirty)
|
if (IsDirty)
|
||||||
refreshEntryAudits.Add(this);
|
refreshEntryAudits.Add(this);
|
||||||
}
|
}
|
||||||
private void ClearRefreshList()
|
private void ClearRefreshList() => _RefreshEntryAudits = new List<EntryAudit>();
|
||||||
{
|
|
||||||
_RefreshEntryAudits = new List<EntryAudit>();
|
|
||||||
}
|
|
||||||
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<EntryAudit> _CacheList = new List<EntryAudit>();
|
private static List<EntryAudit> _CacheList = new List<EntryAudit>();
|
||||||
protected static void AddToCache(EntryAudit entryAudit)
|
protected static void AddToCache(EntryAudit entryAudit)
|
||||||
{
|
{
|
||||||
@@ -65,6 +61,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(entryAudit)) _CacheList.Remove(entryAudit); // In RemoveFromCache
|
while (_CacheList.Contains(entryAudit)) _CacheList.Remove(entryAudit); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<EntryAudit>> _CacheByPrimaryKey = new Dictionary<string, List<EntryAudit>>();
|
private static Dictionary<string, List<EntryAudit>> _CacheByPrimaryKey = new Dictionary<string, List<EntryAudit>>();
|
||||||
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
|
||||||
@@ -200,40 +191,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 EntryAudit.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current EntryAudit</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check EntryAudit.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check EntryAudit.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 EntryAudit</returns>
|
/// <returns>A Unique ID for the current EntryAudit</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyEntryAuditUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyEntryAuditUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
@@ -261,8 +226,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()
|
||||||
@@ -281,33 +246,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_EntryAuditExtension.AddInstanceValidationRules(ValidationRules);
|
_EntryAuditExtension.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(ContentID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DocID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DeleteStatus, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ContentID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DocID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DeleteStatus, "<Role(s)>");
|
|
||||||
_EntryAuditExtension.AddAuthorizationRules(AuthorizationRules);
|
_EntryAuditExtension.AddAuthorizationRules(AuthorizationRules);
|
||||||
}
|
}
|
||||||
protected override void AddInstanceAuthorizationRules()
|
protected override void AddInstanceAuthorizationRules()
|
||||||
@@ -315,42 +258,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//CSLATODO: Who can read/write which fields
|
//CSLATODO: Who can read/write which fields
|
||||||
_EntryAuditExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
_EntryAuditExtension.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 _EntryAuditUnique = 0;
|
private static int _EntryAuditUnique = 0;
|
||||||
protected static int EntryAuditUnique
|
protected static int EntryAuditUnique => ++_EntryAuditUnique;
|
||||||
{ get { return ++_EntryAuditUnique; } }
|
private readonly int _MyEntryAuditUnique = EntryAuditUnique;
|
||||||
private int _MyEntryAuditUnique = EntryAuditUnique;
|
// Absolutely Unique ID - Editable
|
||||||
public int MyEntryAuditUnique // Absolutely Unique ID - Editable
|
public int MyEntryAuditUnique => _MyEntryAuditUnique;
|
||||||
{ get { return _MyEntryAuditUnique; } }
|
|
||||||
protected EntryAudit()
|
protected EntryAudit()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -359,15 +274,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; } }
|
|
||||||
~EntryAudit()
|
~EntryAudit()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -392,8 +303,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static EntryAudit New()
|
public static EntryAudit New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a EntryAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<EntryAudit>();
|
return DataPortal.Create<EntryAudit>();
|
||||||
@@ -431,8 +340,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static EntryAudit Get(long auditID)
|
public static EntryAudit Get(long auditID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a EntryAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
EntryAudit tmp = GetCachedByPrimaryKey(auditID);
|
EntryAudit tmp = GetCachedByPrimaryKey(auditID);
|
||||||
@@ -464,8 +371,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
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 EntryAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataPortal.Delete(new PKCriteria(auditID));
|
DataPortal.Delete(new PKCriteria(auditID));
|
||||||
@@ -477,12 +382,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public override EntryAudit Save()
|
public override EntryAudit Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a EntryAudit");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a EntryAudit");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a EntryAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -502,13 +401,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()]
|
||||||
@@ -604,30 +499,35 @@ 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 = "addEntryAudit";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@ContentID", _ContentID);
|
cm.CommandText = "addEntryAudit";
|
||||||
cm.Parameters.AddWithValue("@DocID", _DocID);
|
// Input All Fields - Except Calculated Columns
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@ContentID", _ContentID);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
cm.Parameters.AddWithValue("@DocID", _DocID);
|
||||||
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
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}] EntryAudit.SQLInsert", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.SQLInsert", GetHashCode());
|
||||||
@@ -657,8 +557,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
cm.Parameters.AddWithValue("@UserID", userID);
|
cm.Parameters.AddWithValue("@UserID", userID);
|
||||||
cm.Parameters.AddWithValue("@DeleteStatus", deleteStatus);
|
cm.Parameters.AddWithValue("@DeleteStatus", deleteStatus);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt);
|
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt)
|
||||||
param_AuditID.Direction = ParameterDirection.Output;
|
{
|
||||||
|
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();
|
||||||
@@ -703,27 +605,30 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.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 = "updateEntryAudit";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@AuditID", _AuditID);
|
cm.CommandText = "updateEntryAudit";
|
||||||
cm.Parameters.AddWithValue("@ContentID", _ContentID);
|
// All Fields including Calculated Fields
|
||||||
cm.Parameters.AddWithValue("@DocID", _DocID);
|
cm.Parameters.AddWithValue("@AuditID", _AuditID);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@ContentID", _ContentID);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
cm.Parameters.AddWithValue("@DocID", _DocID);
|
||||||
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
// 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
|
||||||
}
|
}
|
||||||
@@ -736,14 +641,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)
|
{
|
||||||
EntryAudit.Add(cn, ref _AuditID, _ContentID, _DocID, _DTS, _UserID, _DeleteStatus);
|
if (IsNew)
|
||||||
else
|
EntryAudit.Add(cn, ref _AuditID, _ContentID, _DocID, _DTS, _UserID, _DeleteStatus);
|
||||||
EntryAudit.Update(cn, ref _AuditID, _ContentID, _DocID, _DTS, _UserID, _DeleteStatus);
|
else
|
||||||
|
EntryAudit.Update(cn, ref _AuditID, _ContentID, _DocID, _DTS, _UserID, _DeleteStatus);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -834,7 +742,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
EntryAuditExtension _EntryAuditExtension = new EntryAuditExtension();
|
readonly EntryAuditExtension _EntryAuditExtension = new EntryAuditExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class EntryAuditExtension : extensionBase
|
partial class EntryAuditExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -871,49 +779,14 @@ 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 EntryAudit)
|
if (destType == typeof(string) && value is EntryAudit audit)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((EntryAudit)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 EntryAuditExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class EntryAudit
|
|
||||||
// {
|
|
||||||
// partial class EntryAuditExtension : 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 EntryAuditInfo : ReadOnlyBase<EntryAuditInfo>, IDisposable
|
public partial class EntryAuditInfo : ReadOnlyBase<EntryAuditInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public event EntryAuditInfoEvent Changed;
|
public event EntryAuditInfoEvent 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<EntryAuditInfo> _CacheList = new List<EntryAuditInfo>();
|
private static List<EntryAuditInfo> _CacheList = new List<EntryAuditInfo>();
|
||||||
protected static void AddToCache(EntryAuditInfo entryAuditInfo)
|
protected static void AddToCache(EntryAuditInfo entryAuditInfo)
|
||||||
{
|
{
|
||||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(entryAuditInfo)) _CacheList.Remove(entryAuditInfo); // In RemoveFromCache
|
while (_CacheList.Contains(entryAuditInfo)) _CacheList.Remove(entryAuditInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<EntryAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<EntryAuditInfo>>();
|
private static Dictionary<string, List<EntryAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<EntryAuditInfo>>();
|
||||||
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 EntryAudit _Editable;
|
protected EntryAudit _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
|
||||||
@@ -144,32 +128,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _DeleteStatus;
|
return _DeleteStatus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base EntryAuditInfo.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current EntryAuditInfo</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check EntryAuditInfo.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check EntryAuditInfo.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 EntryAuditInfo</returns>
|
/// <returns>A Unique ID for the current EntryAuditInfo</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyEntryAuditInfoUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyEntryAuditInfoUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _EntryAuditInfoUnique = 0;
|
private static int _EntryAuditInfoUnique = 0;
|
||||||
private static int EntryAuditInfoUnique
|
private static int EntryAuditInfoUnique => ++_EntryAuditInfoUnique;
|
||||||
{ get { return ++_EntryAuditInfoUnique; } }
|
private readonly int _MyEntryAuditInfoUnique = EntryAuditInfoUnique;
|
||||||
private int _MyEntryAuditInfoUnique = EntryAuditInfoUnique;
|
// Absolutely Unique ID - Info
|
||||||
public int MyEntryAuditInfoUnique // Absolutely Unique ID - Info
|
public int MyEntryAuditInfoUnique => _MyEntryAuditInfoUnique;
|
||||||
{ get { return _MyEntryAuditInfoUnique; } }
|
|
||||||
protected EntryAuditInfo()
|
protected EntryAuditInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -178,15 +149,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; } }
|
|
||||||
~EntryAuditInfo()
|
~EntryAuditInfo()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -203,10 +170,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (listEntryAuditInfo.Count == 0) // If there are no items left in the list
|
if (listEntryAuditInfo.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 EntryAudit Get()
|
public virtual EntryAudit Get() => _Editable = EntryAudit.Get(_AuditID);
|
||||||
{
|
|
||||||
return _Editable = EntryAudit.Get(_AuditID);
|
|
||||||
}
|
|
||||||
public static void Refresh(EntryAudit tmp)
|
public static void Refresh(EntryAudit tmp)
|
||||||
{
|
{
|
||||||
string key = tmp.AuditID.ToString();
|
string key = tmp.AuditID.ToString();
|
||||||
@@ -227,8 +191,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static EntryAuditInfo Get(long auditID)
|
public static EntryAuditInfo Get(long auditID)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a EntryAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
EntryAuditInfo tmp = GetCachedByPrimaryKey(auditID);
|
EntryAuditInfo tmp = GetCachedByPrimaryKey(auditID);
|
||||||
@@ -267,13 +229,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)
|
||||||
{
|
{
|
||||||
@@ -333,7 +291,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
EntryAuditInfoExtension _EntryAuditInfoExtension = new EntryAuditInfoExtension();
|
readonly EntryAuditInfoExtension _EntryAuditInfoExtension = new EntryAuditInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class EntryAuditInfoExtension : extensionBase { }
|
partial class EntryAuditInfoExtension : extensionBase { }
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
@@ -349,10 +307,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 EntryAuditInfo)
|
if (destType == typeof(string) && value is EntryAuditInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((EntryAuditInfo)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<EntryAuditInfo> Items
|
internal new IList<EntryAuditInfo> Items => base.Items;
|
||||||
{ get { return base.Items; } }
|
public void AddEvents()
|
||||||
public void AddEvents()
|
|
||||||
{
|
{
|
||||||
foreach (EntryAuditInfo tmp in this)
|
foreach (EntryAuditInfo 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
|
~EntryAuditInfoList()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~EntryAuditInfoList()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -97,26 +90,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on EntryAuditInfoList.Get", ex);
|
throw new DbCslaException("Error on EntryAuditInfoList.Get", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset the list of all EntryAuditInfo.
|
/// Reset the list of all EntryAuditInfo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Reset()
|
public static void Reset() => _EntryAuditInfoList = null;
|
||||||
{
|
private EntryAuditInfoList()
|
||||||
_EntryAuditInfoList = null;
|
|
||||||
}
|
|
||||||
// CSLATODO: Add alternative gets -
|
|
||||||
//public static EntryAuditInfoList Get(<criteria>)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// return DataPortal.Fetch<EntryAuditInfoList>(new FilteredCriteria(<criteria>));
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// throw new DbCslaException("Error on EntryAuditInfoList.Get", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
private EntryAuditInfoList()
|
|
||||||
{ /* 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 EntryAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class EntryAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private EntryAuditInfo Item { get { return (EntryAuditInfo)_Item; } }
|
|
||||||
public EntryAuditInfoListPropertyDescriptor(EntryAuditInfoList collection, int index) : base(collection, index) { ;}
|
public EntryAuditInfoListPropertyDescriptor(EntryAuditInfoList 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 EntryAuditInfoList)
|
if (destType == typeof(string) && value is EntryAuditInfoList list)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((EntryAuditInfoList)value).Items.Count.ToString() + " EntryAudits";
|
return $"{list.Items.Count} EntryAudits";
|
||||||
}
|
}
|
||||||
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 EntryInfo : ReadOnlyBase<EntryInfo>, IDisposable
|
public partial class EntryInfo : ReadOnlyBase<EntryInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public event EntryInfoEvent Changed;
|
public event EntryInfoEvent 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<EntryInfo> _CacheList = new List<EntryInfo>();
|
private static List<EntryInfo> _CacheList = new List<EntryInfo>();
|
||||||
protected static void AddToCache(EntryInfo entryInfo)
|
protected static void AddToCache(EntryInfo entryInfo)
|
||||||
{
|
{
|
||||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(entryInfo)) _CacheList.Remove(entryInfo); // In RemoveFromCache
|
while (_CacheList.Contains(entryInfo)) _CacheList.Remove(entryInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<EntryInfo>> _CacheByPrimaryKey = new Dictionary<string, List<EntryInfo>>();
|
private static Dictionary<string, List<EntryInfo>> _CacheByPrimaryKey = new Dictionary<string, List<EntryInfo>>();
|
||||||
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 Entry _Editable;
|
protected Entry _Editable;
|
||||||
private IVEHasBrokenRules HasBrokenRules
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
IVEHasBrokenRules hasBrokenRules = null;
|
|
||||||
if (_Editable != null)
|
|
||||||
hasBrokenRules = _Editable.HasBrokenRules;
|
|
||||||
return hasBrokenRules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private int _ContentID;
|
private int _ContentID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int ContentID
|
public int ContentID
|
||||||
@@ -149,32 +133,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _UserID;
|
return _UserID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base EntryInfo.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current EntryInfo</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check EntryInfo.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check EntryInfo.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 EntryInfo</returns>
|
/// <returns>A Unique ID for the current EntryInfo</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyEntryInfoUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyEntryInfoUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _EntryInfoUnique = 0;
|
private static int _EntryInfoUnique = 0;
|
||||||
private static int EntryInfoUnique
|
private static int EntryInfoUnique => ++_EntryInfoUnique;
|
||||||
{ get { return ++_EntryInfoUnique; } }
|
private readonly int _MyEntryInfoUnique = EntryInfoUnique;
|
||||||
private int _MyEntryInfoUnique = EntryInfoUnique;
|
// Absolutely Unique ID - Info
|
||||||
public int MyEntryInfoUnique // Absolutely Unique ID - Info
|
public int MyEntryInfoUnique => _MyEntryInfoUnique;
|
||||||
{ get { return _MyEntryInfoUnique; } }
|
|
||||||
protected EntryInfo()
|
protected EntryInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -183,15 +154,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; } }
|
|
||||||
~EntryInfo()
|
~EntryInfo()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -208,10 +175,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (listEntryInfo.Count == 0) // If there are no items left in the list
|
if (listEntryInfo.Count == 0) // If there are no items left in the list
|
||||||
_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
|
_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
|
||||||
}
|
}
|
||||||
public virtual Entry Get()
|
public virtual Entry Get() => _Editable = Entry.Get(_ContentID);
|
||||||
{
|
|
||||||
return _Editable = Entry.Get(_ContentID);
|
|
||||||
}
|
|
||||||
public static void Refresh(Entry tmp)
|
public static void Refresh(Entry tmp)
|
||||||
{
|
{
|
||||||
string key = tmp.ContentID.ToString();
|
string key = tmp.ContentID.ToString();
|
||||||
@@ -224,11 +188,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_DocID != tmp.DocID)
|
if (_DocID != tmp.DocID)
|
||||||
{
|
{
|
||||||
if (MyDocument != null) MyDocument.RefreshDocumentEntries(); // Update List for old value
|
MyDocument?.RefreshDocumentEntries(); // Update List for old value
|
||||||
_DocID = tmp.DocID; // Update the value
|
_DocID = tmp.DocID; // Update the value
|
||||||
}
|
}
|
||||||
_MyDocument = null; // Reset list so that the next line gets a new list
|
_MyDocument = null; // Reset list so that the next line gets a new list
|
||||||
if (MyDocument != null) MyDocument.RefreshDocumentEntries(); // Update List for new value
|
MyDocument?.RefreshDocumentEntries(); // Update List for new value
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
_UserID = tmp.UserID;
|
_UserID = tmp.UserID;
|
||||||
_EntryInfoExtension.Refresh(this);
|
_EntryInfoExtension.Refresh(this);
|
||||||
@@ -251,8 +215,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static EntryInfo Get(int contentID)
|
public static EntryInfo Get(int contentID)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a Entry");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
EntryInfo tmp = GetCachedByPrimaryKey(contentID);
|
EntryInfo tmp = GetCachedByPrimaryKey(contentID);
|
||||||
@@ -291,13 +253,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _ContentID;
|
private readonly int _ContentID;
|
||||||
public int ContentID
|
public int ContentID => _ContentID;
|
||||||
{ get { return _ContentID; } }
|
public PKCriteria(int contentID) => _ContentID = contentID;
|
||||||
public PKCriteria(int contentID)
|
|
||||||
{
|
|
||||||
_ContentID = contentID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void ReadData(SafeDataReader dr)
|
private void ReadData(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
@@ -355,7 +313,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
EntryInfoExtension _EntryInfoExtension = new EntryInfoExtension();
|
readonly EntryInfoExtension _EntryInfoExtension = new EntryInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class EntryInfoExtension : extensionBase { }
|
partial class EntryInfoExtension : extensionBase { }
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
@@ -371,10 +329,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 EntryInfo)
|
if (destType == typeof(string) && value is EntryInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((EntryInfo)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<EntryInfo> Items
|
internal new IList<EntryInfo> Items => base.Items;
|
||||||
{ get { return base.Items; } }
|
public void AddEvents()
|
||||||
public void AddEvents()
|
|
||||||
{
|
{
|
||||||
foreach (EntryInfo tmp in this)
|
foreach (EntryInfo 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
|
~EntryInfoList()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~EntryInfoList()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -104,18 +97,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
_EntryInfoList = null;
|
_EntryInfoList = null;
|
||||||
}
|
}
|
||||||
// CSLATODO: Add alternative gets -
|
|
||||||
//public static EntryInfoList Get(<criteria>)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// return DataPortal.Fetch<EntryInfoList>(new FilteredCriteria(<criteria>));
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// throw new DbCslaException("Error on EntryInfoList.Get", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
public static EntryInfoList GetByContentID(int contentID)
|
public static EntryInfoList GetByContentID(int contentID)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -180,11 +161,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; }
|
||||||
@@ -224,11 +202,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[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; }
|
||||||
@@ -265,41 +240,30 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
this.RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ICustomTypeDescriptor impl
|
#region ICustomTypeDescriptor impl
|
||||||
public String GetClassName()
|
public String GetClassName() => TypeDescriptor.GetClassName(this, true);
|
||||||
{ return TypeDescriptor.GetClassName(this, true); }
|
public AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true);
|
||||||
public AttributeCollection GetAttributes()
|
public String GetComponentName() => TypeDescriptor.GetComponentName(this, true);
|
||||||
{ return TypeDescriptor.GetAttributes(this, true); }
|
public TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true);
|
||||||
public String GetComponentName()
|
public EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
|
||||||
{ return TypeDescriptor.GetComponentName(this, true); }
|
public PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true);
|
||||||
public TypeConverter GetConverter()
|
public object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true);
|
||||||
{ return TypeDescriptor.GetConverter(this, true); }
|
public EventDescriptorCollection GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(this, attributes, true);
|
||||||
public EventDescriptor GetDefaultEvent()
|
public EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true);
|
||||||
{ return TypeDescriptor.GetDefaultEvent(this, true); }
|
public object GetPropertyOwner(PropertyDescriptor pd) => this;
|
||||||
public PropertyDescriptor GetDefaultProperty()
|
/// <summary>
|
||||||
{ return TypeDescriptor.GetDefaultProperty(this, true); }
|
/// Called to get the properties of this type. Returns properties with certain
|
||||||
public object GetEditor(Type editorBaseType)
|
/// attributes. this restriction is not implemented here.
|
||||||
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
|
/// </summary>
|
||||||
public EventDescriptorCollection GetEvents(Attribute[] attributes)
|
/// <param name="attributes"></param>
|
||||||
{ return TypeDescriptor.GetEvents(this, attributes, true); }
|
/// <returns></returns>
|
||||||
public EventDescriptorCollection GetEvents()
|
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
||||||
{ return TypeDescriptor.GetEvents(this, true); }
|
/// <summary>
|
||||||
public object GetPropertyOwner(PropertyDescriptor pd)
|
/// Called to get the properties of this type.
|
||||||
{ return this; }
|
/// </summary>
|
||||||
/// <summary>
|
/// <returns></returns>
|
||||||
/// Called to get the properties of this type. Returns properties with certain
|
public PropertyDescriptorCollection GetProperties()
|
||||||
/// attributes. this restriction is not implemented here.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="attributes"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
|
|
||||||
{ return GetProperties(); }
|
|
||||||
/// <summary>
|
|
||||||
/// Called to get the properties of this type.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PropertyDescriptorCollection GetProperties()
|
|
||||||
{
|
{
|
||||||
// Create a collection object to hold property descriptors
|
// Create a collection object to hold property descriptors
|
||||||
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
||||||
@@ -321,7 +285,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class EntryInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class EntryInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private EntryInfo Item { get { return (EntryInfo)_Item; } }
|
|
||||||
public EntryInfoListPropertyDescriptor(EntryInfoList collection, int index) : base(collection, index) { ;}
|
public EntryInfoListPropertyDescriptor(EntryInfoList collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -330,10 +293,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 EntryInfoList)
|
if (destType == typeof(string) && value is EntryInfoList list)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((EntryInfoList)value).Items.Count.ToString() + " Entries";
|
return $"{list.Items.Count} Entries";
|
||||||
}
|
}
|
||||||
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;
|
||||||
@@ -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<Figure> _CacheList = new List<Figure>();
|
private static List<Figure> _CacheList = new List<Figure>();
|
||||||
protected static void AddToCache(Figure figure)
|
protected static void AddToCache(Figure figure)
|
||||||
{
|
{
|
||||||
@@ -67,7 +66,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(figure)) _CacheList.Remove(figure); // In RemoveFromCache
|
while (_CacheList.Contains(figure)) _CacheList.Remove(figure); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<Figure>> _CacheByPrimaryKey = new Dictionary<string, List<Figure>>();
|
private static Dictionary<string, List<Figure>> _CacheByPrimaryKey = new Dictionary<string, List<Figure>>();
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<Figure>> _CacheByROFstID_ImageID = new Dictionary<string, List<Figure>>();
|
private static Dictionary<string, List<Figure>> _CacheByROFstID_ImageID = new Dictionary<string, List<Figure>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -102,15 +103,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 _nextFigureID = -1;
|
private static int _nextFigureID = -1;
|
||||||
public static int NextFigureID
|
public static int NextFigureID => _nextFigureID--;
|
||||||
{
|
|
||||||
get { return _nextFigureID--; }
|
|
||||||
}
|
|
||||||
private int _FigureID;
|
private int _FigureID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int FigureID
|
public int FigureID
|
||||||
@@ -252,37 +247,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 || (_MyROFst == null ? false : _MyROFst.IsDirtyList(list)) || (_MyROImage == null ? false : _MyROImage.IsDirtyList(list));
|
return base.IsDirty || (_MyROFst != null && _MyROFst.IsDirtyList(list)) || (_MyROImage != null && _MyROImage.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)) && (_MyROImage == null ? true : _MyROImage.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_MyROFst == null || _MyROFst.IsValidList(list)) && (_MyROImage == null || _MyROImage.IsValidList(list));
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base Figure.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current Figure</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check Figure.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check Figure.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 Figure</returns>
|
/// <returns>A Unique ID for the current Figure</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyFigureUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyFigureUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
@@ -312,8 +292,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()
|
||||||
@@ -355,33 +335,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(FigureID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ROFstID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ImageID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ROFstID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ImageID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
|
||||||
_FigureExtension.AddAuthorizationRules(AuthorizationRules);
|
_FigureExtension.AddAuthorizationRules(AuthorizationRules);
|
||||||
}
|
}
|
||||||
protected override void AddInstanceAuthorizationRules()
|
protected override void AddInstanceAuthorizationRules()
|
||||||
@@ -389,42 +347,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//CSLATODO: Who can read/write which fields
|
//CSLATODO: Who can read/write which fields
|
||||||
_FigureExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
_FigureExtension.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 _FigureUnique = 0;
|
private static int _FigureUnique = 0;
|
||||||
protected static int FigureUnique
|
protected static int FigureUnique => ++_FigureUnique;
|
||||||
{ get { return ++_FigureUnique; } }
|
private readonly int _MyFigureUnique = FigureUnique;
|
||||||
private int _MyFigureUnique = FigureUnique;
|
// Absolutely Unique ID - Editable
|
||||||
public int MyFigureUnique // Absolutely Unique ID - Editable
|
public int MyFigureUnique => _MyFigureUnique;
|
||||||
{ get { return _MyFigureUnique; } }
|
|
||||||
protected Figure()
|
protected Figure()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -433,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; } }
|
|
||||||
~Figure()
|
~Figure()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -478,8 +404,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Figure New()
|
public static Figure New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Figure");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<Figure>();
|
return DataPortal.Create<Figure>();
|
||||||
@@ -548,8 +472,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Figure Get(int figureID)
|
public static Figure Get(int figureID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a Figure");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Figure tmp = GetCachedByPrimaryKey(figureID);
|
Figure tmp = GetCachedByPrimaryKey(figureID);
|
||||||
@@ -572,8 +494,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Figure GetByROFstID_ImageID(int rOFstID, int imageID)
|
public static Figure GetByROFstID_ImageID(int rOFstID, int imageID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a Figure");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Figure tmp = GetCachedByROFstID_ImageID(rOFstID, imageID);
|
Figure tmp = GetCachedByROFstID_ImageID(rOFstID, imageID);
|
||||||
@@ -599,14 +519,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dr.Read()) return new Figure(dr);
|
if (dr.Read()) return new Figure(dr);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
internal Figure(SafeDataReader dr)
|
internal Figure(SafeDataReader dr) => ReadData(dr);
|
||||||
{
|
|
||||||
ReadData(dr);
|
|
||||||
}
|
|
||||||
public static void Delete(int figureID)
|
public static void Delete(int figureID)
|
||||||
{
|
{
|
||||||
if (!CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Figure");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataPortal.Delete(new PKCriteria(figureID));
|
DataPortal.Delete(new PKCriteria(figureID));
|
||||||
@@ -618,12 +533,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public override Figure Save()
|
public override Figure Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Figure");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Figure");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a Figure");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -643,23 +552,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _FigureID;
|
private readonly int _FigureID;
|
||||||
public int FigureID
|
public int FigureID => _FigureID;
|
||||||
{ get { return _FigureID; } }
|
public PKCriteria(int figureID) => _FigureID = figureID;
|
||||||
public PKCriteria(int figureID)
|
|
||||||
{
|
|
||||||
_FigureID = figureID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ROFstID_ImageIDCriteria
|
private class ROFstID_ImageIDCriteria
|
||||||
{
|
{
|
||||||
private int _ROFstID;
|
private readonly int _ROFstID;
|
||||||
public int ROFstID
|
public int ROFstID => _ROFstID;
|
||||||
{ get { return _ROFstID; } }
|
private readonly int _ImageID;
|
||||||
private int _ImageID;
|
public int ImageID => _ImageID;
|
||||||
public int ImageID
|
|
||||||
{ get { return _ImageID; } }
|
|
||||||
public ROFstID_ImageIDCriteria(int rOFstID, int imageID)
|
public ROFstID_ImageIDCriteria(int rOFstID, int imageID)
|
||||||
{
|
{
|
||||||
_ROFstID = rOFstID;
|
_ROFstID = rOFstID;
|
||||||
@@ -799,36 +702,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 (_MyROFst != null) _MyROFst.Update();
|
_MyROFst?.Update();
|
||||||
if (_MyROImage != null) _MyROImage.Update();
|
_MyROImage?.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 = "addFigure";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@ROFstID", ROFstID);
|
cm.CommandText = "addFigure";
|
||||||
cm.Parameters.AddWithValue("@ImageID", ImageID);
|
// Input All Fields - Except Calculated Columns
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@ROFstID", ROFstID);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@ImageID", ImageID);
|
||||||
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_FigureID = new SqlParameter("@newFigureID", SqlDbType.Int);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
param_FigureID.Direction = ParameterDirection.Output;
|
// Output Calculated Columns
|
||||||
cm.Parameters.Add(param_FigureID);
|
SqlParameter param_FigureID = new SqlParameter("@newFigureID", 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_FigureID);
|
||||||
cm.ExecuteNonQuery();
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
// Save all values being returned from the Procedure
|
{
|
||||||
_FigureID = (int)cm.Parameters["@newFigureID"].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
|
||||||
|
_FigureID = (int)cm.Parameters["@newFigureID"].Value;
|
||||||
|
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
// update child objects
|
// update child objects
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Figure.SQLInsert", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Figure.SQLInsert", GetHashCode());
|
||||||
@@ -858,11 +768,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_FigureID = new SqlParameter("@newFigureID", SqlDbType.Int);
|
SqlParameter param_FigureID = new SqlParameter("@newFigureID", SqlDbType.Int)
|
||||||
param_FigureID.Direction = ParameterDirection.Output;
|
{
|
||||||
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
cm.Parameters.Add(param_FigureID);
|
cm.Parameters.Add(param_FigureID);
|
||||||
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();
|
||||||
@@ -907,34 +821,39 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Figure.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Figure.SQLUpdate", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_MyROFst != null) _MyROFst.Update();
|
_MyROFst?.Update();
|
||||||
if (_MyROImage != null) _MyROImage.Update();
|
_MyROImage?.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 = "updateFigure";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@FigureID", _FigureID);
|
cm.CommandText = "updateFigure";
|
||||||
cm.Parameters.AddWithValue("@ROFstID", ROFstID);
|
// All Fields including Calculated Fields
|
||||||
cm.Parameters.AddWithValue("@ImageID", ImageID);
|
cm.Parameters.AddWithValue("@FigureID", _FigureID);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@ROFstID", ROFstID);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@ImageID", ImageID);
|
||||||
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
|
||||||
}
|
}
|
||||||
@@ -947,14 +866,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 = Figure.Add(cn, ref _FigureID, _MyROFst, _MyROImage, _Config, _DTS, _UserID);
|
if (IsNew)
|
||||||
else
|
_LastChanged = Figure.Add(cn, ref _FigureID, _MyROFst, _MyROImage, _Config, _DTS, _UserID);
|
||||||
_LastChanged = Figure.Update(cn, ref _FigureID, _ROFstID, _ImageID, _Config, _DTS, _UserID, ref _LastChanged);
|
else
|
||||||
|
_LastChanged = Figure.Update(cn, ref _FigureID, _ROFstID, _ImageID, _Config, _DTS, _UserID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -978,8 +900,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();
|
||||||
@@ -1064,16 +988,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ExistsCommand : CommandBase
|
private class ExistsCommand : CommandBase
|
||||||
{
|
{
|
||||||
private int _FigureID;
|
private readonly int _FigureID;
|
||||||
private bool _exists;
|
private bool _exists;
|
||||||
public bool Exists
|
public bool Exists => _exists;
|
||||||
{
|
public ExistsCommand(int figureID) => _FigureID = figureID;
|
||||||
get { return _exists; }
|
|
||||||
}
|
|
||||||
public ExistsCommand(int figureID)
|
|
||||||
{
|
|
||||||
_FigureID = figureID;
|
|
||||||
}
|
|
||||||
protected override void DataPortal_Execute()
|
protected override void DataPortal_Execute()
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Figure.DataPortal_Execute", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Figure.DataPortal_Execute", GetHashCode());
|
||||||
@@ -1103,7 +1021,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
FigureExtension _FigureExtension = new FigureExtension();
|
readonly FigureExtension _FigureExtension = new FigureExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class FigureExtension : extensionBase
|
partial class FigureExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -1112,14 +1030,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)
|
||||||
{
|
{
|
||||||
@@ -1148,57 +1060,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 Figure)
|
if (destType == typeof(string) && value is Figure figure)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((Figure)value).ToString();
|
return figure.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 FigureExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class Figure
|
|
||||||
// {
|
|
||||||
// partial class FigureExtension : 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 FigureInfo : ReadOnlyBase<FigureInfo>, IDisposable
|
public partial class FigureInfo : ReadOnlyBase<FigureInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public event FigureInfoEvent Changed;
|
public event FigureInfoEvent 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<FigureInfo> _CacheList = new List<FigureInfo>();
|
private static List<FigureInfo> _CacheList = new List<FigureInfo>();
|
||||||
protected static void AddToCache(FigureInfo figureInfo)
|
protected static void AddToCache(FigureInfo figureInfo)
|
||||||
{
|
{
|
||||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(figureInfo)) _CacheList.Remove(figureInfo); // In RemoveFromCache
|
while (_CacheList.Contains(figureInfo)) _CacheList.Remove(figureInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<FigureInfo>> _CacheByPrimaryKey = new Dictionary<string, List<FigureInfo>>();
|
private static Dictionary<string, List<FigureInfo>> _CacheByPrimaryKey = new Dictionary<string, List<FigureInfo>>();
|
||||||
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 Figure _Editable;
|
protected Figure _Editable;
|
||||||
private IVEHasBrokenRules HasBrokenRules
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
IVEHasBrokenRules hasBrokenRules = null;
|
|
||||||
if (_Editable != null)
|
|
||||||
hasBrokenRules = _Editable.HasBrokenRules;
|
|
||||||
return hasBrokenRules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private int _FigureID;
|
private int _FigureID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int FigureID
|
public int FigureID
|
||||||
@@ -166,32 +150,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _UserID;
|
return _UserID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base FigureInfo.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current FigureInfo</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check FigureInfo.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check FigureInfo.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 FigureInfo</returns>
|
/// <returns>A Unique ID for the current FigureInfo</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyFigureInfoUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyFigureInfoUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _FigureInfoUnique = 0;
|
private static int _FigureInfoUnique = 0;
|
||||||
private static int FigureInfoUnique
|
private static int FigureInfoUnique => ++_FigureInfoUnique;
|
||||||
{ get { return ++_FigureInfoUnique; } }
|
private readonly int _MyFigureInfoUnique = FigureInfoUnique;
|
||||||
private int _MyFigureInfoUnique = FigureInfoUnique;
|
// Absolutely Unique ID - Info
|
||||||
public int MyFigureInfoUnique // Absolutely Unique ID - Info
|
public int MyFigureInfoUnique => _MyFigureInfoUnique;
|
||||||
{ get { return _MyFigureInfoUnique; } }
|
|
||||||
protected FigureInfo()
|
protected FigureInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -200,15 +171,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; } }
|
|
||||||
~FigureInfo()
|
~FigureInfo()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -225,10 +192,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (listFigureInfo.Count == 0) // If there are no items left in the list
|
if (listFigureInfo.Count == 0) // If there are no items left in the list
|
||||||
_CacheByPrimaryKey.Remove(FigureID.ToString()); // remove the list
|
_CacheByPrimaryKey.Remove(FigureID.ToString()); // remove the list
|
||||||
}
|
}
|
||||||
public virtual Figure Get()
|
public virtual Figure Get() => _Editable = Figure.Get(_FigureID);
|
||||||
{
|
|
||||||
return _Editable = Figure.Get(_FigureID);
|
|
||||||
}
|
|
||||||
public static void Refresh(Figure tmp)
|
public static void Refresh(Figure tmp)
|
||||||
{
|
{
|
||||||
string key = tmp.FigureID.ToString();
|
string key = tmp.FigureID.ToString();
|
||||||
@@ -241,18 +205,18 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_ROFstID != tmp.ROFstID)
|
if (_ROFstID != tmp.ROFstID)
|
||||||
{
|
{
|
||||||
if (MyROFst != null) MyROFst.RefreshROFstFigures(); // Update List for old value
|
MyROFst?.RefreshROFstFigures(); // Update List for old value
|
||||||
_ROFstID = tmp.ROFstID; // Update the value
|
_ROFstID = tmp.ROFstID; // Update the value
|
||||||
}
|
}
|
||||||
_MyROFst = null; // Reset list so that the next line gets a new list
|
_MyROFst = null; // Reset list so that the next line gets a new list
|
||||||
if (MyROFst != null) MyROFst.RefreshROFstFigures(); // Update List for new value
|
MyROFst?.RefreshROFstFigures(); // Update List for new value
|
||||||
if (_ImageID != tmp.ImageID)
|
if (_ImageID != tmp.ImageID)
|
||||||
{
|
{
|
||||||
if (MyROImage != null) MyROImage.RefreshROImageFigures(); // Update List for old value
|
MyROImage?.RefreshROImageFigures(); // Update List for old value
|
||||||
_ImageID = tmp.ImageID; // Update the value
|
_ImageID = tmp.ImageID; // Update the value
|
||||||
}
|
}
|
||||||
_MyROImage = null; // Reset list so that the next line gets a new list
|
_MyROImage = null; // Reset list so that the next line gets a new list
|
||||||
if (MyROImage != null) MyROImage.RefreshROImageFigures(); // Update List for new value
|
MyROImage?.RefreshROImageFigures(); // Update List for new value
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
_UserID = tmp.UserID;
|
_UserID = tmp.UserID;
|
||||||
@@ -271,11 +235,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_ImageID != tmp.ImageID)
|
if (_ImageID != tmp.ImageID)
|
||||||
{
|
{
|
||||||
if (MyROImage != null) MyROImage.RefreshROImageFigures(); // Update List for old value
|
MyROImage?.RefreshROImageFigures(); // Update List for old value
|
||||||
_ImageID = tmp.ImageID; // Update the value
|
_ImageID = tmp.ImageID; // Update the value
|
||||||
}
|
}
|
||||||
_MyROImage = null; // Reset list so that the next line gets a new list
|
_MyROImage = null; // Reset list so that the next line gets a new list
|
||||||
if (MyROImage != null) MyROImage.RefreshROImageFigures(); // Update List for new value
|
MyROImage?.RefreshROImageFigures(); // Update List for new value
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
_UserID = tmp.UserID;
|
_UserID = tmp.UserID;
|
||||||
@@ -294,11 +258,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_ROFstID != tmp.ROFstID)
|
if (_ROFstID != tmp.ROFstID)
|
||||||
{
|
{
|
||||||
if (MyROFst != null) MyROFst.RefreshROFstFigures(); // Update List for old value
|
MyROFst?.RefreshROFstFigures(); // Update List for old value
|
||||||
_ROFstID = tmp.ROFstID; // Update the value
|
_ROFstID = tmp.ROFstID; // Update the value
|
||||||
}
|
}
|
||||||
_MyROFst = null; // Reset list so that the next line gets a new list
|
_MyROFst = null; // Reset list so that the next line gets a new list
|
||||||
if (MyROFst != null) MyROFst.RefreshROFstFigures(); // Update List for new value
|
MyROFst?.RefreshROFstFigures(); // Update List for new value
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
_UserID = tmp.UserID;
|
_UserID = tmp.UserID;
|
||||||
@@ -307,8 +271,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static FigureInfo Get(int figureID)
|
public static FigureInfo Get(int figureID)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a Figure");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FigureInfo tmp = GetCachedByPrimaryKey(figureID);
|
FigureInfo tmp = GetCachedByPrimaryKey(figureID);
|
||||||
@@ -347,13 +309,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _FigureID;
|
private readonly int _FigureID;
|
||||||
public int FigureID
|
public int FigureID => _FigureID;
|
||||||
{ get { return _FigureID; } }
|
public PKCriteria(int figureID) => _FigureID = figureID;
|
||||||
public PKCriteria(int figureID)
|
|
||||||
{
|
|
||||||
_FigureID = figureID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private string _ROImage_FileName = string.Empty;
|
private string _ROImage_FileName = string.Empty;
|
||||||
public string ROImage_FileName
|
public string ROImage_FileName
|
||||||
@@ -427,7 +385,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
FigureInfoExtension _FigureInfoExtension = new FigureInfoExtension();
|
readonly FigureInfoExtension _FigureInfoExtension = new FigureInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class FigureInfoExtension : extensionBase { }
|
partial class FigureInfoExtension : extensionBase { }
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
@@ -443,10 +401,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 FigureInfo)
|
if (destType == typeof(string) && value is FigureInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((FigureInfo)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<FigureInfo> Items
|
internal new IList<FigureInfo> Items => base.Items;
|
||||||
{ get { return base.Items; } }
|
public void AddEvents()
|
||||||
public void AddEvents()
|
|
||||||
{
|
{
|
||||||
foreach (FigureInfo tmp in this)
|
foreach (FigureInfo 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
|
~FigureInfoList()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~FigureInfoList()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -97,26 +90,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on FigureInfoList.Get", ex);
|
throw new DbCslaException("Error on FigureInfoList.Get", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset the list of all FigureInfo.
|
/// Reset the list of all FigureInfo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Reset()
|
public static void Reset() => _FigureInfoList = null;
|
||||||
{
|
public static FigureInfoList GetByROFstID(int rOFstID)
|
||||||
_FigureInfoList = null;
|
|
||||||
}
|
|
||||||
// CSLATODO: Add alternative gets -
|
|
||||||
//public static FigureInfoList Get(<criteria>)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// return DataPortal.Fetch<FigureInfoList>(new FilteredCriteria(<criteria>));
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// throw new DbCslaException("Error on FigureInfoList.Get", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
public static FigureInfoList GetByROFstID(int rOFstID)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -180,11 +158,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ROFstIDCriteria
|
private class ROFstIDCriteria
|
||||||
{
|
{
|
||||||
public ROFstIDCriteria(int rOFstID)
|
public ROFstIDCriteria(int rOFstID) => _ROFstID = rOFstID;
|
||||||
{
|
private int _ROFstID;
|
||||||
_ROFstID = rOFstID;
|
|
||||||
}
|
|
||||||
private int _ROFstID;
|
|
||||||
public int ROFstID
|
public int ROFstID
|
||||||
{
|
{
|
||||||
get { return _ROFstID; }
|
get { return _ROFstID; }
|
||||||
@@ -224,11 +199,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ImageIDCriteria
|
private class ImageIDCriteria
|
||||||
{
|
{
|
||||||
public ImageIDCriteria(int imageID)
|
public ImageIDCriteria(int imageID) => _ImageID = imageID;
|
||||||
{
|
private int _ImageID;
|
||||||
_ImageID = imageID;
|
|
||||||
}
|
|
||||||
private int _ImageID;
|
|
||||||
public int ImageID
|
public int ImageID
|
||||||
{
|
{
|
||||||
get { return _ImageID; }
|
get { return _ImageID; }
|
||||||
@@ -265,41 +237,30 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
this.RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ICustomTypeDescriptor impl
|
#region ICustomTypeDescriptor impl
|
||||||
public String GetClassName()
|
public String GetClassName() => TypeDescriptor.GetClassName(this, true);
|
||||||
{ return TypeDescriptor.GetClassName(this, true); }
|
public AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true);
|
||||||
public AttributeCollection GetAttributes()
|
public String GetComponentName() => TypeDescriptor.GetComponentName(this, true);
|
||||||
{ return TypeDescriptor.GetAttributes(this, true); }
|
public TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true);
|
||||||
public String GetComponentName()
|
public EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
|
||||||
{ return TypeDescriptor.GetComponentName(this, true); }
|
public PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true);
|
||||||
public TypeConverter GetConverter()
|
public object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true);
|
||||||
{ return TypeDescriptor.GetConverter(this, true); }
|
public EventDescriptorCollection GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(this, attributes, true);
|
||||||
public EventDescriptor GetDefaultEvent()
|
public EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true);
|
||||||
{ return TypeDescriptor.GetDefaultEvent(this, true); }
|
public object GetPropertyOwner(PropertyDescriptor pd) => this;
|
||||||
public PropertyDescriptor GetDefaultProperty()
|
/// <summary>
|
||||||
{ return TypeDescriptor.GetDefaultProperty(this, true); }
|
/// Called to get the properties of this type. Returns properties with certain
|
||||||
public object GetEditor(Type editorBaseType)
|
/// attributes. this restriction is not implemented here.
|
||||||
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
|
/// </summary>
|
||||||
public EventDescriptorCollection GetEvents(Attribute[] attributes)
|
/// <param name="attributes"></param>
|
||||||
{ return TypeDescriptor.GetEvents(this, attributes, true); }
|
/// <returns></returns>
|
||||||
public EventDescriptorCollection GetEvents()
|
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
||||||
{ return TypeDescriptor.GetEvents(this, true); }
|
/// <summary>
|
||||||
public object GetPropertyOwner(PropertyDescriptor pd)
|
/// Called to get the properties of this type.
|
||||||
{ return this; }
|
/// </summary>
|
||||||
/// <summary>
|
/// <returns></returns>
|
||||||
/// Called to get the properties of this type. Returns properties with certain
|
public PropertyDescriptorCollection GetProperties()
|
||||||
/// attributes. this restriction is not implemented here.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="attributes"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
|
|
||||||
{ return GetProperties(); }
|
|
||||||
/// <summary>
|
|
||||||
/// Called to get the properties of this type.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PropertyDescriptorCollection GetProperties()
|
|
||||||
{
|
{
|
||||||
// Create a collection object to hold property descriptors
|
// Create a collection object to hold property descriptors
|
||||||
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
||||||
@@ -321,7 +282,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class FigureInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class FigureInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private FigureInfo Item { get { return (FigureInfo)_Item; } }
|
|
||||||
public FigureInfoListPropertyDescriptor(FigureInfoList collection, int index) : base(collection, index) { ;}
|
public FigureInfoListPropertyDescriptor(FigureInfoList collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -330,10 +290,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 FigureInfoList)
|
if (destType == typeof(string) && value is FigureInfoList list)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((FigureInfoList)value).Items.Count.ToString() + " Figures";
|
return $"{list.Items.Count} Figures";
|
||||||
}
|
}
|
||||||
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;
|
||||||
@@ -91,6 +89,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<Folder> _CacheList = new List<Folder>();
|
private static List<Folder> _CacheList = new List<Folder>();
|
||||||
protected static void AddToCache(Folder folder)
|
protected static void AddToCache(Folder folder)
|
||||||
{
|
{
|
||||||
@@ -100,7 +99,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(folder)) _CacheList.Remove(folder); // In RemoveFromCache
|
while (_CacheList.Contains(folder)) _CacheList.Remove(folder); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<Folder>> _CacheByPrimaryKey = new Dictionary<string, List<Folder>>();
|
private static Dictionary<string, List<Folder>> _CacheByPrimaryKey = new Dictionary<string, List<Folder>>();
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<Folder>> _CacheByParentID_Name = new Dictionary<string, List<Folder>>();
|
private static Dictionary<string, List<Folder>> _CacheByParentID_Name = new Dictionary<string, List<Folder>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -135,15 +136,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 _nextFolderID = -1;
|
private static int _nextFolderID = -1;
|
||||||
public static int NextFolderID
|
public static int NextFolderID => _nextFolderID--;
|
||||||
{
|
|
||||||
get { return _nextFolderID--; }
|
|
||||||
}
|
|
||||||
private int _FolderID;
|
private int _FolderID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int FolderID
|
public int FolderID
|
||||||
@@ -407,10 +402,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _FolderAssignments;
|
return _FolderAssignments;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Reset_FolderAssignments()
|
public void Reset_FolderAssignments() => _FolderAssignmentCount = -1;
|
||||||
{
|
|
||||||
_FolderAssignmentCount = -1;
|
|
||||||
}
|
|
||||||
private int _FolderDocVersionCount = 0;
|
private int _FolderDocVersionCount = 0;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Count of FolderDocVersions for this Folder
|
/// Count of FolderDocVersions for this Folder
|
||||||
@@ -442,10 +434,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _FolderDocVersions;
|
return _FolderDocVersions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Reset_FolderDocVersions()
|
public void Reset_FolderDocVersions() => _FolderDocVersionCount = -1;
|
||||||
{
|
|
||||||
_FolderDocVersionCount = -1;
|
|
||||||
}
|
|
||||||
private int _ChildFolderCount = 0;
|
private int _ChildFolderCount = 0;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Count of ChildFolders for this Folder
|
/// Count of ChildFolders for this Folder
|
||||||
@@ -477,10 +466,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _ChildFolders;
|
return _ChildFolders;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Reset_ChildFolders()
|
public void Reset_ChildFolders() => _ChildFolderCount = -1;
|
||||||
{
|
|
||||||
_ChildFolderCount = -1;
|
|
||||||
}
|
|
||||||
public override bool IsDirty
|
public override bool IsDirty
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -495,37 +481,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 || (_FolderAssignments == null ? false : _FolderAssignments.IsDirtyList(list)) || (_FolderDocVersions == null ? false : _FolderDocVersions.IsDirtyList(list)) || (_ChildFolders == null ? false : _ChildFolders.IsDirtyList(list)) || (_MyConnection == null ? false : _MyConnection.IsDirtyList(list)) || (_MyFormat == null ? false : _MyFormat.IsDirtyList(list));
|
return base.IsDirty || (_FolderAssignments != null && _FolderAssignments.IsDirtyList(list)) || (_FolderDocVersions != null && _FolderDocVersions.IsDirtyList(list)) || (_ChildFolders != null && _ChildFolders.IsDirtyList(list)) || (_MyConnection != null && _MyConnection.IsDirtyList(list)) || (_MyFormat != null && _MyFormat.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) && (_FolderAssignments == null ? true : _FolderAssignments.IsValidList(list)) && (_FolderDocVersions == null ? true : _FolderDocVersions.IsValidList(list)) && (_ChildFolders == null ? true : _ChildFolders.IsValidList(list)) && (_MyConnection == null ? true : _MyConnection.IsValidList(list)) && (_MyFormat == null ? true : _MyFormat.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_FolderAssignments == null || _FolderAssignments.IsValidList(list)) && (_FolderDocVersions == null || _FolderDocVersions.IsValidList(list)) && (_ChildFolders == null || _ChildFolders.IsValidList(list)) && (_MyConnection == null || _MyConnection.IsValidList(list)) && (_MyFormat == null || _MyFormat.IsValidList(list));
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base Folder.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current Folder</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check Folder.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check Folder.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 Folder</returns>
|
/// <returns>A Unique ID for the current Folder</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyFolderUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyFolderUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
@@ -558,8 +529,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()
|
||||||
@@ -604,43 +575,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(FolderID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ParentID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DBID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ShortName, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(FormatID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ManualOrder, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ParentID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DBID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ShortName, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(FormatID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ManualOrder, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
|
|
||||||
_FolderExtension.AddAuthorizationRules(AuthorizationRules);
|
_FolderExtension.AddAuthorizationRules(AuthorizationRules);
|
||||||
}
|
}
|
||||||
protected override void AddInstanceAuthorizationRules()
|
protected override void AddInstanceAuthorizationRules()
|
||||||
@@ -648,57 +587,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//CSLATODO: Who can read/write which fields
|
//CSLATODO: Who can read/write which fields
|
||||||
_FolderExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
_FolderExtension.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 += _FolderAssignmentCount;
|
|
||||||
usedByCount += _FolderDocVersionCount;
|
|
||||||
usedByCount += _ChildFolderCount;
|
|
||||||
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 _FolderUnique = 0;
|
private static int _FolderUnique = 0;
|
||||||
protected static int FolderUnique
|
protected static int FolderUnique => ++_FolderUnique;
|
||||||
{ get { return ++_FolderUnique; } }
|
private readonly int _MyFolderUnique = FolderUnique;
|
||||||
private int _MyFolderUnique = FolderUnique;
|
// Absolutely Unique ID - Editable
|
||||||
public int MyFolderUnique // Absolutely Unique ID - Editable
|
public int MyFolderUnique => _MyFolderUnique;
|
||||||
{ get { return _MyFolderUnique; } }
|
|
||||||
protected Folder()
|
protected Folder()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -707,15 +603,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; } }
|
|
||||||
~Folder()
|
~Folder()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -752,8 +644,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Folder New()
|
public static Folder New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Folder");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<Folder>();
|
return DataPortal.Create<Folder>();
|
||||||
@@ -860,8 +750,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Folder Get(int folderID)
|
public static Folder Get(int folderID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a Folder");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Folder tmp = GetCachedByPrimaryKey(folderID);
|
Folder tmp = GetCachedByPrimaryKey(folderID);
|
||||||
@@ -884,8 +772,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Folder GetByParentID_Name(int parentID, string name)
|
public static Folder GetByParentID_Name(int parentID, string name)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a Folder");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Folder tmp = GetCachedByParentID_Name(parentID, name);
|
Folder tmp = GetCachedByParentID_Name(parentID, name);
|
||||||
@@ -911,15 +797,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dr.Read()) return new Folder(dr, parent);
|
if (dr.Read()) return new Folder(dr, parent);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
internal Folder(SafeDataReader dr)
|
internal Folder(SafeDataReader dr) => ReadData(dr);
|
||||||
{
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
ReadData(dr);
|
|
||||||
}
|
|
||||||
private Folder(SafeDataReader dr, Folder parent)
|
private Folder(SafeDataReader dr, Folder parent)
|
||||||
{
|
{
|
||||||
ReadData(dr);
|
ReadData(dr);
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
internal Folder(SafeDataReader dr, int parentID)
|
internal Folder(SafeDataReader dr, int parentID)
|
||||||
{
|
{
|
||||||
ReadData(dr);
|
ReadData(dr);
|
||||||
@@ -927,8 +812,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static void Delete(int folderID)
|
public static void Delete(int folderID)
|
||||||
{
|
{
|
||||||
if (!CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Folder");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// B2019-060: On delete, remove the folder from cache:
|
// B2019-060: On delete, remove the folder from cache:
|
||||||
@@ -943,12 +826,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public override Folder Save()
|
public override Folder Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Folder");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Folder");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a Folder");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -968,23 +845,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _FolderID;
|
private readonly int _FolderID;
|
||||||
public int FolderID
|
public int FolderID => _FolderID;
|
||||||
{ get { return _FolderID; } }
|
public PKCriteria(int folderID) => _FolderID = folderID;
|
||||||
public PKCriteria(int folderID)
|
|
||||||
{
|
|
||||||
_FolderID = folderID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ParentID_NameCriteria
|
private class ParentID_NameCriteria
|
||||||
{
|
{
|
||||||
private int _ParentID;
|
private readonly int _ParentID;
|
||||||
public int ParentID
|
public int ParentID => _ParentID;
|
||||||
{ get { return _ParentID; } }
|
private readonly string _Name;
|
||||||
private string _Name;
|
public string Name => _Name;
|
||||||
public string Name
|
|
||||||
{ get { return _Name; } }
|
|
||||||
public ParentID_NameCriteria(int parentID, string name)
|
public ParentID_NameCriteria(int parentID, string name)
|
||||||
{
|
{
|
||||||
_ParentID = parentID;
|
_ParentID = parentID;
|
||||||
@@ -1140,46 +1011,53 @@ 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 (_MyConnection != null) _MyConnection.Update();
|
_MyConnection?.Update();
|
||||||
if (_MyFormat != null) _MyFormat.Update();
|
_MyFormat?.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 = "addFolder";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@ParentID", ParentID);
|
cm.CommandText = "addFolder";
|
||||||
cm.Parameters.AddWithValue("@DBID", DBID);
|
// Input All Fields - Except Calculated Columns
|
||||||
cm.Parameters.AddWithValue("@Name", _Name);
|
cm.Parameters.AddWithValue("@ParentID", ParentID);
|
||||||
cm.Parameters.AddWithValue("@Title", _Title);
|
cm.Parameters.AddWithValue("@DBID", DBID);
|
||||||
cm.Parameters.AddWithValue("@ShortName", _ShortName);
|
cm.Parameters.AddWithValue("@Name", _Name);
|
||||||
cm.Parameters.AddWithValue("@FormatID", FormatID);
|
cm.Parameters.AddWithValue("@Title", _Title);
|
||||||
cm.Parameters.AddWithValue("@ManualOrder", _ManualOrder);
|
cm.Parameters.AddWithValue("@ShortName", _ShortName);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@FormatID", FormatID);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@ManualOrder", _ManualOrder);
|
||||||
cm.Parameters.AddWithValue("@UsrID", _UsrID);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
// Output Calculated Columns
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
SqlParameter param_FolderID = new SqlParameter("@newFolderID", SqlDbType.Int);
|
cm.Parameters.AddWithValue("@UsrID", _UsrID);
|
||||||
param_FolderID.Direction = ParameterDirection.Output;
|
// Output Calculated Columns
|
||||||
cm.Parameters.Add(param_FolderID);
|
SqlParameter param_FolderID = new SqlParameter("@newFolderID", 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_FolderID);
|
||||||
cm.ExecuteNonQuery();
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
// Save all values being returned from the Procedure
|
{
|
||||||
_FolderID = (int)cm.Parameters["@newFolderID"].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
|
||||||
|
_FolderID = (int)cm.Parameters["@newFolderID"].Value;
|
||||||
|
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
// update child objects
|
// update child objects
|
||||||
if (_FolderAssignments != null) _FolderAssignments.Update(this);
|
_FolderAssignments?.Update(this);
|
||||||
if (_FolderDocVersions != null) _FolderDocVersions.Update(this);
|
_FolderDocVersions?.Update(this);
|
||||||
if (_ChildFolders != null) _ChildFolders.Update(this);
|
_ChildFolders?.Update(this);
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.SQLInsert", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.SQLInsert", GetHashCode());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -1212,11 +1090,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("@UsrID", usrID);
|
cm.Parameters.AddWithValue("@UsrID", usrID);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_FolderID = new SqlParameter("@newFolderID", SqlDbType.Int);
|
SqlParameter param_FolderID = new SqlParameter("@newFolderID", SqlDbType.Int)
|
||||||
param_FolderID.Direction = ParameterDirection.Output;
|
{
|
||||||
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
cm.Parameters.Add(param_FolderID);
|
cm.Parameters.Add(param_FolderID);
|
||||||
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();
|
||||||
@@ -1263,44 +1145,49 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.SQLUpdate", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_MyConnection != null) _MyConnection.Update();
|
_MyConnection?.Update();
|
||||||
if (_MyFormat != null) _MyFormat.Update();
|
_MyFormat?.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 = "updateFolder";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@FolderID", _FolderID);
|
cm.CommandText = "updateFolder";
|
||||||
cm.Parameters.AddWithValue("@ParentID", ParentID);
|
// All Fields including Calculated Fields
|
||||||
cm.Parameters.AddWithValue("@DBID", DBID);
|
cm.Parameters.AddWithValue("@FolderID", _FolderID);
|
||||||
cm.Parameters.AddWithValue("@Name", _Name);
|
cm.Parameters.AddWithValue("@ParentID", ParentID);
|
||||||
cm.Parameters.AddWithValue("@Title", _Title);
|
cm.Parameters.AddWithValue("@DBID", DBID);
|
||||||
cm.Parameters.AddWithValue("@ShortName", _ShortName);
|
cm.Parameters.AddWithValue("@Name", _Name);
|
||||||
cm.Parameters.AddWithValue("@FormatID", FormatID);
|
cm.Parameters.AddWithValue("@Title", _Title);
|
||||||
cm.Parameters.AddWithValue("@ManualOrder", _ManualOrder);
|
cm.Parameters.AddWithValue("@ShortName", _ShortName);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@FormatID", FormatID);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@ManualOrder", _ManualOrder);
|
||||||
cm.Parameters.AddWithValue("@UsrID", _UsrID);
|
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("@UsrID", _UsrID);
|
||||||
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 (_FolderAssignments != null) _FolderAssignments.Update(this);
|
_FolderAssignments?.Update(this);
|
||||||
if (_FolderDocVersions != null) _FolderDocVersions.Update(this);
|
_FolderDocVersions?.Update(this);
|
||||||
if (_ChildFolders != null) _ChildFolders.Update(this);
|
_ChildFolders?.Update(this);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -1313,28 +1200,35 @@ 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 = Folder.Add(cn, ref _FolderID, _MyParent, _MyConnection, _Name, _Title, _ShortName, _MyFormat, _ManualOrder, _Config, _DTS, _UsrID);
|
if (IsNew)
|
||||||
else
|
_LastChanged = Folder.Add(cn, ref _FolderID, _MyParent, _MyConnection, _Name, _Title, _ShortName, _MyFormat, _ManualOrder, _Config, _DTS, _UsrID);
|
||||||
_LastChanged = Folder.Update(cn, ref _FolderID, _ParentID, _DBID, _Name, _Title, _ShortName, _FormatID, _ManualOrder, _Config, _DTS, _UsrID, ref _LastChanged);
|
else
|
||||||
|
_LastChanged = Folder.Update(cn, ref _FolderID, _ParentID, _DBID, _Name, _Title, _ShortName, _FormatID, _ManualOrder, _Config, _DTS, _UsrID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
if (_FolderAssignments != null) _FolderAssignments.Update(this);
|
_FolderAssignments?.Update(this);
|
||||||
if (_FolderDocVersions != null) _FolderDocVersions.Update(this);
|
_FolderDocVersions?.Update(this);
|
||||||
if (_ChildFolders != null) _ChildFolders.Update(this);
|
_ChildFolders?.Update(this);
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
internal void DeleteSelf(Folder folder)
|
internal void DeleteSelf(Folder folder)
|
||||||
{
|
{
|
||||||
// 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"])
|
||||||
Folder.Remove(cn, _FolderID);
|
{
|
||||||
|
Folder.Remove(cn, _FolderID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkNew();
|
MarkNew();
|
||||||
}
|
}
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
@@ -1362,8 +1256,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
cm.Parameters.AddWithValue("@UsrID", usrID);
|
cm.Parameters.AddWithValue("@UsrID", usrID);
|
||||||
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
{
|
||||||
|
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();
|
||||||
@@ -1378,10 +1274,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(_FolderID));
|
||||||
{
|
|
||||||
DataPortal_Delete(new PKCriteria(_FolderID));
|
|
||||||
}
|
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
private void DataPortal_Delete(PKCriteria criteria)
|
private void DataPortal_Delete(PKCriteria criteria)
|
||||||
{
|
{
|
||||||
@@ -1473,16 +1366,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ExistsCommand : CommandBase
|
private class ExistsCommand : CommandBase
|
||||||
{
|
{
|
||||||
private int _FolderID;
|
private readonly int _FolderID;
|
||||||
private bool _exists;
|
private bool _exists;
|
||||||
public bool Exists
|
public bool Exists => _exists;
|
||||||
{
|
public ExistsCommand(int folderID) => _FolderID = folderID;
|
||||||
get { return _exists; }
|
|
||||||
}
|
|
||||||
public ExistsCommand(int folderID)
|
|
||||||
{
|
|
||||||
_FolderID = folderID;
|
|
||||||
}
|
|
||||||
protected override void DataPortal_Execute()
|
protected override void DataPortal_Execute()
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.DataPortal_Execute", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.DataPortal_Execute", GetHashCode());
|
||||||
@@ -1512,7 +1399,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
FolderExtension _FolderExtension = new FolderExtension();
|
readonly FolderExtension _FolderExtension = new FolderExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class FolderExtension : extensionBase
|
partial class FolderExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -1521,22 +1408,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
class extensionBase
|
class extensionBase
|
||||||
{
|
{
|
||||||
// Default Values
|
// Default Values
|
||||||
public virtual int DefaultParentID
|
public virtual int DefaultParentID => 1;
|
||||||
{
|
public virtual int DefaultDBID => 1;
|
||||||
get { return 1; }
|
public virtual DateTime DefaultDTS => DateTime.Now;
|
||||||
}
|
public virtual string DefaultUsrID => Volian.Base.Library.VlnSettings.UserID;
|
||||||
public virtual int DefaultDBID
|
|
||||||
{
|
|
||||||
get { return 1; }
|
|
||||||
}
|
|
||||||
public virtual DateTime DefaultDTS
|
|
||||||
{
|
|
||||||
get { return DateTime.Now; }
|
|
||||||
}
|
|
||||||
public virtual string DefaultUsrID
|
|
||||||
{
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -1565,65 +1440,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 Folder)
|
if (destType == typeof(string) && value is Folder folder)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((Folder)value).ToString();
|
return folder.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 FolderExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class Folder
|
|
||||||
// {
|
|
||||||
// partial class FolderExtension : extensionBase
|
|
||||||
// {
|
|
||||||
// // CSLATODO: Override automatic defaults
|
|
||||||
// public virtual int DefaultParentID
|
|
||||||
// {
|
|
||||||
// get { return 1; }
|
|
||||||
// }
|
|
||||||
// public virtual int DefaultDBID
|
|
||||||
// {
|
|
||||||
// get { return 1; }
|
|
||||||
// }
|
|
||||||
// public virtual DateTime DefaultDTS
|
|
||||||
// {
|
|
||||||
// get { return DateTime.Now; }
|
|
||||||
// }
|
|
||||||
// public virtual string DefaultUsrID
|
|
||||||
// {
|
|
||||||
// get { return Environment.UserName.ToUpper(); }
|
|
||||||
// }
|
|
||||||
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddRule(
|
|
||||||
// Csla.Validation.CommonRules.StringMaxLength,
|
|
||||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddInstanceRule(/* Instance Validation Rule */);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
@@ -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 _AID;
|
private int _AID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int AID
|
public int AID
|
||||||
@@ -298,19 +292,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 FolderAssignment</returns>
|
/// <returns>A Unique ID for the current FolderAssignment</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyFolderAssignmentUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyFolderAssignmentUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
// CSLATODO: Replace base FolderAssignment.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current FolderAssignment</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
public override bool IsDirty
|
public override bool IsDirty
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -325,18 +307,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 || (_MyGroup == null ? false : _MyGroup.IsDirtyList(list)) || (_MyRole == null ? false : _MyRole.IsDirtyList(list));
|
return base.IsDirty || (_MyGroup != null && _MyGroup.IsDirtyList(list)) || (_MyRole != null && _MyRole.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) && (_MyGroup == null ? true : _MyGroup.IsValidList(list)) && (_MyRole == null ? true : _MyRole.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_MyGroup == null || _MyGroup.IsValidList(list)) && (_MyRole == null || _MyRole.IsValidList(list));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
@@ -367,8 +346,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()
|
||||||
@@ -430,80 +409,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(AID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(GID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(GID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(RID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(RID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UsrID, "<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 _FolderAssignmentUnique = 0;
|
private static int _FolderAssignmentUnique = 0;
|
||||||
private static int FolderAssignmentUnique
|
private static int FolderAssignmentUnique => ++_FolderAssignmentUnique;
|
||||||
{ get { return ++_FolderAssignmentUnique; } }
|
private readonly int _MyFolderAssignmentUnique = FolderAssignmentUnique;
|
||||||
private int _MyFolderAssignmentUnique = FolderAssignmentUnique;
|
// Absolutely Unique ID - Editable FK
|
||||||
public int MyFolderAssignmentUnique // Absolutely Unique ID - Editable FK
|
public int MyFolderAssignmentUnique => _MyFolderAssignmentUnique;
|
||||||
{ get { return _MyFolderAssignmentUnique; } }
|
internal static FolderAssignment New(Group myGroup, Role myRole) => new FolderAssignment(myGroup, myRole);
|
||||||
internal static FolderAssignment New(Group myGroup, Role myRole)
|
internal static FolderAssignment Get(SafeDataReader dr) => new FolderAssignment(dr);
|
||||||
{
|
|
||||||
return new FolderAssignment(myGroup, myRole);
|
|
||||||
}
|
|
||||||
internal static FolderAssignment Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new FolderAssignment(dr);
|
|
||||||
}
|
|
||||||
public FolderAssignment()
|
public FolderAssignment()
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
@@ -534,15 +454,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; } }
|
|
||||||
~FolderAssignment()
|
~FolderAssignment()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -588,33 +504,43 @@ namespace VEPROMS.CSLA.Library
|
|||||||
internal void Insert(Folder myFolder)
|
internal void Insert(Folder myFolder)
|
||||||
{
|
{
|
||||||
// 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 = Assignment.Add(cn, ref _AID, _MyGroup, _MyRole, myFolder, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID);
|
{
|
||||||
|
_LastChanged = Assignment.Add(cn, ref _AID, _MyGroup, _MyRole, myFolder, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
internal void Update(Folder myFolder)
|
internal void Update(Folder myFolder)
|
||||||
{
|
{
|
||||||
// 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 = Assignment.Update(cn, ref _AID, _GID, _RID, myFolder.FolderID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged);
|
{
|
||||||
|
_LastChanged = Assignment.Update(cn, ref _AID, _GID, _RID, myFolder.FolderID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
internal void DeleteSelf(Folder myFolder)
|
internal void DeleteSelf(Folder myFolder)
|
||||||
{
|
{
|
||||||
// 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"])
|
||||||
Assignment.Remove(cn, _AID);
|
{
|
||||||
|
Assignment.Remove(cn, _AID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkNew();
|
MarkNew();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
FolderAssignmentExtension _FolderAssignmentExtension = new FolderAssignmentExtension();
|
readonly FolderAssignmentExtension _FolderAssignmentExtension = new FolderAssignmentExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class FolderAssignmentExtension : extensionBase
|
partial class FolderAssignmentExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -623,18 +549,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
class extensionBase
|
class extensionBase
|
||||||
{
|
{
|
||||||
// Default Values
|
// Default Values
|
||||||
public virtual string DefaultStartDate
|
public virtual string DefaultStartDate => DateTime.Now.ToShortDateString();
|
||||||
{
|
public virtual DateTime DefaultDTS => DateTime.Now;
|
||||||
get { return DateTime.Now.ToShortDateString(); }
|
public virtual string DefaultUsrID => Volian.Base.Library.VlnSettings.UserID;
|
||||||
}
|
|
||||||
public virtual DateTime DefaultDTS
|
|
||||||
{
|
|
||||||
get { return DateTime.Now; }
|
|
||||||
}
|
|
||||||
public virtual string DefaultUsrID
|
|
||||||
{
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -663,61 +580,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 FolderAssignment)
|
if (destType == typeof(string) && value is FolderAssignment assignment)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((FolderAssignment)value).ToString();
|
return assignment.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 FolderAssignmentExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class FolderAssignment
|
|
||||||
// {
|
|
||||||
// partial class FolderAssignmentExtension : extensionBase
|
|
||||||
// {
|
|
||||||
// // CSLATODO: Override automatic defaults
|
|
||||||
// public virtual SmartDate DefaultStartDate
|
|
||||||
// {
|
|
||||||
// get { return DateTime.Now.ToShortDateString(); }
|
|
||||||
// }
|
|
||||||
// public virtual DateTime DefaultDTS
|
|
||||||
// {
|
|
||||||
// get { return DateTime.Now; }
|
|
||||||
// }
|
|
||||||
// public virtual string DefaultUsrID
|
|
||||||
// {
|
|
||||||
// get { return Environment.UserName.ToUpper(); }
|
|
||||||
// }
|
|
||||||
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddRule(
|
|
||||||
// Csla.Validation.CommonRules.StringMaxLength,
|
|
||||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddInstanceRule(/* Instance Validation Rule */);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
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 FolderAssignment this[Assignment myAssignment]
|
||||||
}
|
|
||||||
// One To Many
|
|
||||||
public FolderAssignment this[Assignment myAssignment]
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -47,11 +42,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public new System.Collections.Generic.IList<FolderAssignment> Items
|
public new System.Collections.Generic.IList<FolderAssignment> Items => base.Items;
|
||||||
{
|
public FolderAssignment GetItem(Assignment myAssignment)
|
||||||
get { return base.Items; }
|
|
||||||
}
|
|
||||||
public FolderAssignment GetItem(Assignment myAssignment)
|
|
||||||
{
|
{
|
||||||
foreach (FolderAssignment assignment in this)
|
foreach (FolderAssignment assignment in this)
|
||||||
if (assignment.AID == myAssignment.AID)
|
if (assignment.AID == myAssignment.AID)
|
||||||
@@ -61,7 +53,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public FolderAssignment Add(Group myGroup, Role myRole) // One to Many
|
public FolderAssignment Add(Group myGroup, Role myRole) // One to Many
|
||||||
{
|
{
|
||||||
FolderAssignment assignment = FolderAssignment.New(myGroup, myRole);
|
FolderAssignment assignment = FolderAssignment.New(myGroup, myRole);
|
||||||
this.Add(assignment);
|
Add(assignment);
|
||||||
return assignment;
|
return assignment;
|
||||||
}
|
}
|
||||||
public void Remove(Assignment myAssignment)
|
public void Remove(Assignment myAssignment)
|
||||||
@@ -103,11 +95,8 @@ 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>()); }
|
|
||||||
}
|
|
||||||
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
|
||||||
@@ -137,7 +126,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
||||||
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
|
return hasBrokenRules?.BrokenRules;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -161,11 +150,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on FolderAssignments.GetByFolderID", ex);
|
throw new DbCslaException("Error on FolderAssignments.GetByFolderID", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private FolderAssignments()
|
private FolderAssignments() => MarkAsChild();
|
||||||
{
|
internal FolderAssignments(SafeDataReader dr)
|
||||||
MarkAsChild();
|
|
||||||
}
|
|
||||||
internal FolderAssignments(SafeDataReader dr)
|
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
Fetch(dr);
|
Fetch(dr);
|
||||||
@@ -174,16 +160,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
|
~FolderAssignments()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~FolderAssignments()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -198,10 +180,10 @@ 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(FolderAssignment.Get(dr));
|
Add(FolderAssignment.Get(dr));
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class FolderIDCriteria
|
private class FolderIDCriteria
|
||||||
@@ -219,7 +201,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}] FolderAssignments.DataPortal_FetchFolderID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderAssignments.DataPortal_FetchFolderID", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -233,7 +215,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 FolderAssignment(dr));
|
while (dr.Read()) Add(new FolderAssignment(dr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,11 +225,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderAssignments.DataPortal_FetchFolderID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderAssignments.DataPortal_FetchFolderID", ex);
|
||||||
throw new DbCslaException("FolderAssignments.DataPortal_Fetch", ex);
|
throw new DbCslaException("FolderAssignments.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
internal void Update(Folder folder)
|
internal void Update(Folder folder)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// update (thus deleting) any deleted child objects
|
// update (thus deleting) any deleted child objects
|
||||||
@@ -266,49 +248,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
|
||||||
FolderAssignmentsPropertyDescriptor pd = new FolderAssignmentsPropertyDescriptor(this, i);
|
FolderAssignmentsPropertyDescriptor pd = new FolderAssignmentsPropertyDescriptor(this, i);
|
||||||
@@ -325,7 +296,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class FolderAssignmentsPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class FolderAssignmentsPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private FolderAssignment Item { get { return (FolderAssignment)_Item; } }
|
|
||||||
public FolderAssignmentsPropertyDescriptor(FolderAssignments collection, int index) : base(collection, index) { ;}
|
public FolderAssignmentsPropertyDescriptor(FolderAssignments collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -334,10 +304,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 FolderAssignments)
|
if (destType == typeof(string) && value is FolderAssignments assignments)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((FolderAssignments)value).Items.Count.ToString() + " Assignments";
|
return $"{assignments.Items.Count} Assignments";
|
||||||
}
|
}
|
||||||
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 _VersionID;
|
private int _VersionID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int VersionID
|
public int VersionID
|
||||||
@@ -239,35 +233,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 FolderDocVersion</returns>
|
/// <returns>A Unique ID for the current FolderDocVersion</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyFolderDocVersionUnique; // Absolutely Unique ID
|
||||||
{
|
public override bool IsDirty => base.IsDirty;
|
||||||
return MyFolderDocVersionUnique; // 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 FolderDocVersion.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 FolderDocVersion</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]
|
||||||
@@ -297,8 +269,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()
|
||||||
@@ -321,84 +293,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(VersionID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(VersionType, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(VersionType, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(FormatID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(FormatID, "<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 _FolderDocVersionUnique = 0;
|
private static int _FolderDocVersionUnique = 0;
|
||||||
private static int FolderDocVersionUnique
|
private static int FolderDocVersionUnique => ++_FolderDocVersionUnique;
|
||||||
{ get { return ++_FolderDocVersionUnique; } }
|
private readonly int _MyFolderDocVersionUnique = FolderDocVersionUnique;
|
||||||
private int _MyFolderDocVersionUnique = FolderDocVersionUnique;
|
// Absolutely Unique ID - Editable FK
|
||||||
public int MyFolderDocVersionUnique // Absolutely Unique ID - Editable FK
|
public int MyFolderDocVersionUnique => _MyFolderDocVersionUnique;
|
||||||
{ get { return _MyFolderDocVersionUnique; } }
|
internal static FolderDocVersion New(string name) => new FolderDocVersion(name);
|
||||||
internal static FolderDocVersion New(string name)
|
internal static FolderDocVersion Get(SafeDataReader dr) => new FolderDocVersion(dr);
|
||||||
{
|
|
||||||
return new FolderDocVersion(name);
|
|
||||||
}
|
|
||||||
internal static FolderDocVersion Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new FolderDocVersion(dr);
|
|
||||||
}
|
|
||||||
public FolderDocVersion()
|
public FolderDocVersion()
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
@@ -428,15 +338,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; } }
|
|
||||||
~FolderDocVersion()
|
~FolderDocVersion()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -475,33 +381,43 @@ namespace VEPROMS.CSLA.Library
|
|||||||
internal void Insert(Folder myFolder)
|
internal void Insert(Folder myFolder)
|
||||||
{
|
{
|
||||||
// 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 = DocVersion.Add(cn, ref _VersionID, myFolder, _VersionType, _Name, _Title, _MyItem, _MyFormat, _Config, _DTS, _UserID);
|
{
|
||||||
|
_LastChanged = DocVersion.Add(cn, ref _VersionID, myFolder, _VersionType, _Name, _Title, _MyItem, _MyFormat, _Config, _DTS, _UserID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
internal void Update(Folder myFolder)
|
internal void Update(Folder myFolder)
|
||||||
{
|
{
|
||||||
// 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 = DocVersion.Update(cn, ref _VersionID, myFolder.FolderID, _VersionType, _Name, _Title, _ItemID, _FormatID, _Config, _DTS, _UserID, ref _LastChanged);
|
{
|
||||||
|
_LastChanged = DocVersion.Update(cn, ref _VersionID, myFolder.FolderID, _VersionType, _Name, _Title, _ItemID, _FormatID, _Config, _DTS, _UserID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
internal void DeleteSelf(Folder myFolder)
|
internal void DeleteSelf(Folder myFolder)
|
||||||
{
|
{
|
||||||
// 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"])
|
||||||
DocVersion.Remove(cn, _VersionID);
|
{
|
||||||
|
DocVersion.Remove(cn, _VersionID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkNew();
|
MarkNew();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
FolderDocVersionExtension _FolderDocVersionExtension = new FolderDocVersionExtension();
|
readonly FolderDocVersionExtension _FolderDocVersionExtension = new FolderDocVersionExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class FolderDocVersionExtension : extensionBase
|
partial class FolderDocVersionExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -510,18 +426,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)
|
||||||
{
|
{
|
||||||
@@ -550,61 +457,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 FolderDocVersion)
|
if (destType == typeof(string) && value is FolderDocVersion version)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((FolderDocVersion)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 FolderDocVersionExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class FolderDocVersion
|
|
||||||
// {
|
|
||||||
// partial class FolderDocVersionExtension : 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 */);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
@@ -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 FolderDocVersion this[DocVersion myDocVersion]
|
||||||
}
|
|
||||||
// One To Many
|
|
||||||
public FolderDocVersion this[DocVersion myDocVersion]
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -47,11 +42,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public new System.Collections.Generic.IList<FolderDocVersion> Items
|
public new System.Collections.Generic.IList<FolderDocVersion> Items => base.Items;
|
||||||
{
|
public FolderDocVersion GetItem(DocVersion myDocVersion)
|
||||||
get { return base.Items; }
|
|
||||||
}
|
|
||||||
public FolderDocVersion GetItem(DocVersion myDocVersion)
|
|
||||||
{
|
{
|
||||||
foreach (FolderDocVersion docVersion in this)
|
foreach (FolderDocVersion docVersion in this)
|
||||||
if (docVersion.VersionID == myDocVersion.VersionID)
|
if (docVersion.VersionID == myDocVersion.VersionID)
|
||||||
@@ -61,7 +53,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public FolderDocVersion Add(string name) // One to Many
|
public FolderDocVersion Add(string name) // One to Many
|
||||||
{
|
{
|
||||||
FolderDocVersion docVersion = FolderDocVersion.New(name);
|
FolderDocVersion docVersion = FolderDocVersion.New(name);
|
||||||
this.Add(docVersion);
|
Add(docVersion);
|
||||||
return docVersion;
|
return docVersion;
|
||||||
}
|
}
|
||||||
public void Remove(DocVersion myDocVersion)
|
public void Remove(DocVersion myDocVersion)
|
||||||
@@ -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 (FolderDocVersion 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 (FolderDocVersion 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 FolderDocVersions New()
|
internal static FolderDocVersions New() => new FolderDocVersions();
|
||||||
{
|
internal static FolderDocVersions Get(SafeDataReader dr) => new FolderDocVersions(dr);
|
||||||
return new FolderDocVersions();
|
public static FolderDocVersions GetByFolderID(int folderID)
|
||||||
}
|
|
||||||
internal static FolderDocVersions Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new FolderDocVersions(dr);
|
|
||||||
}
|
|
||||||
public static FolderDocVersions GetByFolderID(int folderID)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -161,11 +144,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on FolderDocVersions.GetByFolderID", ex);
|
throw new DbCslaException("Error on FolderDocVersions.GetByFolderID", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private FolderDocVersions()
|
private FolderDocVersions() => MarkAsChild();
|
||||||
{
|
internal FolderDocVersions(SafeDataReader dr)
|
||||||
MarkAsChild();
|
|
||||||
}
|
|
||||||
internal FolderDocVersions(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
|
~FolderDocVersions()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~FolderDocVersions()
|
|
||||||
{
|
{
|
||||||
_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(FolderDocVersion.Get(dr));
|
Add(FolderDocVersion.Get(dr));
|
||||||
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; }
|
||||||
@@ -219,7 +192,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}] FolderDocVersions.DataPortal_FetchFolderID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderDocVersions.DataPortal_FetchFolderID", 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 FolderDocVersion(dr));
|
while (dr.Read()) Add(new FolderDocVersion(dr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,11 +216,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderDocVersions.DataPortal_FetchFolderID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("FolderDocVersions.DataPortal_FetchFolderID", ex);
|
||||||
throw new DbCslaException("FolderDocVersions.DataPortal_Fetch", ex);
|
throw new DbCslaException("FolderDocVersions.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
internal void Update(Folder folder)
|
internal void Update(Folder folder)
|
||||||
{
|
{
|
||||||
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
|
||||||
FolderDocVersionsPropertyDescriptor pd = new FolderDocVersionsPropertyDescriptor(this, i);
|
FolderDocVersionsPropertyDescriptor pd = new FolderDocVersionsPropertyDescriptor(this, i);
|
||||||
@@ -334,10 +296,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 FolderDocVersions)
|
if (destType == typeof(string) && value is FolderDocVersions versions)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((FolderDocVersions)value).Items.Count.ToString() + " DocVersions";
|
return $"{versions.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;
|
||||||
namespace VEPROMS.CSLA.Library
|
namespace VEPROMS.CSLA.Library
|
||||||
@@ -28,14 +26,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public partial class FolderInfo : ReadOnlyBase<FolderInfo>, IDisposable
|
public partial class FolderInfo : ReadOnlyBase<FolderInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public event FolderInfoEvent Changed;
|
public event FolderInfoEvent 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<FolderInfo> _CacheList = new List<FolderInfo>();
|
private static List<FolderInfo> _CacheList = new List<FolderInfo>();
|
||||||
protected static void AddToCache(FolderInfo folderInfo)
|
protected static void AddToCache(FolderInfo folderInfo)
|
||||||
{
|
{
|
||||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(folderInfo)) _CacheList.Remove(folderInfo); // In RemoveFromCache
|
while (_CacheList.Contains(folderInfo)) _CacheList.Remove(folderInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<FolderInfo>> _CacheByPrimaryKey = new Dictionary<string, List<FolderInfo>>();
|
private static Dictionary<string, List<FolderInfo>> _CacheByPrimaryKey = new Dictionary<string, List<FolderInfo>>();
|
||||||
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 Folder _Editable;
|
protected Folder _Editable;
|
||||||
private IVEHasBrokenRules HasBrokenRules
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
IVEHasBrokenRules hasBrokenRules = null;
|
|
||||||
if (_Editable != null)
|
|
||||||
hasBrokenRules = _Editable.HasBrokenRules;
|
|
||||||
return hasBrokenRules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private int _FolderID;
|
private int _FolderID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int FolderID
|
public int FolderID
|
||||||
@@ -330,32 +314,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
foreach (FolderInfo tmp in _CacheByPrimaryKey[_FolderID.ToString()])
|
foreach (FolderInfo tmp in _CacheByPrimaryKey[_FolderID.ToString()])
|
||||||
tmp._ChildFolderCount = -1; // This will cause the data to be requeried
|
tmp._ChildFolderCount = -1; // This will cause the data to be requeried
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base FolderInfo.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current FolderInfo</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check FolderInfo.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check FolderInfo.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 FolderInfo</returns>
|
/// <returns>A Unique ID for the current FolderInfo</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyFolderInfoUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyFolderInfoUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _FolderInfoUnique = 0;
|
private static int _FolderInfoUnique = 0;
|
||||||
private static int FolderInfoUnique
|
private static int FolderInfoUnique => ++_FolderInfoUnique;
|
||||||
{ get { return ++_FolderInfoUnique; } }
|
private readonly int _MyFolderInfoUnique = FolderInfoUnique;
|
||||||
private int _MyFolderInfoUnique = FolderInfoUnique;
|
// Absolutely Unique ID - Info
|
||||||
public int MyFolderInfoUnique // Absolutely Unique ID - Info
|
public int MyFolderInfoUnique => _MyFolderInfoUnique;
|
||||||
{ get { return _MyFolderInfoUnique; } }
|
|
||||||
protected FolderInfo()
|
protected FolderInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -364,15 +335,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; } }
|
|
||||||
~FolderInfo()
|
~FolderInfo()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -389,10 +356,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (listFolderInfo.Count == 0) // If there are no items left in the list
|
if (listFolderInfo.Count == 0) // If there are no items left in the list
|
||||||
_CacheByPrimaryKey.Remove(FolderID.ToString()); // remove the list
|
_CacheByPrimaryKey.Remove(FolderID.ToString()); // remove the list
|
||||||
}
|
}
|
||||||
public virtual Folder Get()
|
public virtual Folder Get() => _Editable = Folder.Get(_FolderID);
|
||||||
{
|
|
||||||
return _Editable = Folder.Get(_FolderID);
|
|
||||||
}
|
|
||||||
public static void Refresh(Folder tmp)
|
public static void Refresh(Folder tmp)
|
||||||
{
|
{
|
||||||
string key = tmp.FolderID.ToString();
|
string key = tmp.FolderID.ToString();
|
||||||
@@ -405,28 +369,28 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_ParentID != tmp.ParentID)
|
if (_ParentID != tmp.ParentID)
|
||||||
{
|
{
|
||||||
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for old value
|
MyParent?.RefreshChildFolders(); // Update List for old value
|
||||||
_ParentID = tmp.ParentID; // Update the value
|
_ParentID = tmp.ParentID; // Update the value
|
||||||
}
|
}
|
||||||
_MyParent = null; // Reset list so that the next line gets a new list
|
_MyParent = null; // Reset list so that the next line gets a new list
|
||||||
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for new value
|
MyParent?.RefreshChildFolders(); // Update List for new value
|
||||||
if (_DBID != tmp.DBID)
|
if (_DBID != tmp.DBID)
|
||||||
{
|
{
|
||||||
if (MyConnection != null) MyConnection.RefreshConnectionFolders(); // Update List for old value
|
MyConnection?.RefreshConnectionFolders(); // Update List for old value
|
||||||
_DBID = tmp.DBID; // Update the value
|
_DBID = tmp.DBID; // Update the value
|
||||||
}
|
}
|
||||||
_MyConnection = null; // Reset list so that the next line gets a new list
|
_MyConnection = null; // Reset list so that the next line gets a new list
|
||||||
if (MyConnection != null) MyConnection.RefreshConnectionFolders(); // Update List for new value
|
MyConnection?.RefreshConnectionFolders(); // Update List for new value
|
||||||
_Name = tmp.Name;
|
_Name = tmp.Name;
|
||||||
_Title = tmp.Title;
|
_Title = tmp.Title;
|
||||||
_ShortName = tmp.ShortName;
|
_ShortName = tmp.ShortName;
|
||||||
if (_FormatID != tmp.FormatID)
|
if (_FormatID != tmp.FormatID)
|
||||||
{
|
{
|
||||||
if (MyFormat != null) MyFormat.RefreshFormatFolders(); // Update List for old value
|
MyFormat?.RefreshFormatFolders(); // Update List for old value
|
||||||
_FormatID = tmp.FormatID; // Update the value
|
_FormatID = tmp.FormatID; // Update the value
|
||||||
}
|
}
|
||||||
_MyFormat = null; // Reset list so that the next line gets a new list
|
_MyFormat = null; // Reset list so that the next line gets a new list
|
||||||
if (MyFormat != null) MyFormat.RefreshFormatFolders(); // Update List for new value
|
MyFormat?.RefreshFormatFolders(); // Update List for new value
|
||||||
_ManualOrder = tmp.ManualOrder;
|
_ManualOrder = tmp.ManualOrder;
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
@@ -446,21 +410,21 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_ParentID != tmp.ParentID)
|
if (_ParentID != tmp.ParentID)
|
||||||
{
|
{
|
||||||
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for old value
|
MyParent?.RefreshChildFolders(); // Update List for old value
|
||||||
_ParentID = tmp.ParentID; // Update the value
|
_ParentID = tmp.ParentID; // Update the value
|
||||||
}
|
}
|
||||||
_MyParent = null; // Reset list so that the next line gets a new list
|
_MyParent = null; // Reset list so that the next line gets a new list
|
||||||
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for new value
|
MyParent?.RefreshChildFolders(); // Update List for new value
|
||||||
_Name = tmp.Name;
|
_Name = tmp.Name;
|
||||||
_Title = tmp.Title;
|
_Title = tmp.Title;
|
||||||
_ShortName = tmp.ShortName;
|
_ShortName = tmp.ShortName;
|
||||||
if (_FormatID != tmp.FormatID)
|
if (_FormatID != tmp.FormatID)
|
||||||
{
|
{
|
||||||
if (MyFormat != null) MyFormat.RefreshFormatFolders(); // Update List for old value
|
MyFormat?.RefreshFormatFolders(); // Update List for old value
|
||||||
_FormatID = tmp.FormatID; // Update the value
|
_FormatID = tmp.FormatID; // Update the value
|
||||||
}
|
}
|
||||||
_MyFormat = null; // Reset list so that the next line gets a new list
|
_MyFormat = null; // Reset list so that the next line gets a new list
|
||||||
if (MyFormat != null) MyFormat.RefreshFormatFolders(); // Update List for new value
|
MyFormat?.RefreshFormatFolders(); // Update List for new value
|
||||||
_ManualOrder = tmp.ManualOrder;
|
_ManualOrder = tmp.ManualOrder;
|
||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
@@ -480,18 +444,18 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_ParentID != tmp.ParentID)
|
if (_ParentID != tmp.ParentID)
|
||||||
{
|
{
|
||||||
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for old value
|
MyParent?.RefreshChildFolders(); // Update List for old value
|
||||||
_ParentID = tmp.ParentID; // Update the value
|
_ParentID = tmp.ParentID; // Update the value
|
||||||
}
|
}
|
||||||
_MyParent = null; // Reset list so that the next line gets a new list
|
_MyParent = null; // Reset list so that the next line gets a new list
|
||||||
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for new value
|
MyParent?.RefreshChildFolders(); // Update List for new value
|
||||||
if (_DBID != tmp.DBID)
|
if (_DBID != tmp.DBID)
|
||||||
{
|
{
|
||||||
if (MyConnection != null) MyConnection.RefreshConnectionFolders(); // Update List for old value
|
MyConnection?.RefreshConnectionFolders(); // Update List for old value
|
||||||
_DBID = tmp.DBID; // Update the value
|
_DBID = tmp.DBID; // Update the value
|
||||||
}
|
}
|
||||||
_MyConnection = null; // Reset list so that the next line gets a new list
|
_MyConnection = null; // Reset list so that the next line gets a new list
|
||||||
if (MyConnection != null) MyConnection.RefreshConnectionFolders(); // Update List for new value
|
MyConnection?.RefreshConnectionFolders(); // Update List for new value
|
||||||
_Name = tmp.Name;
|
_Name = tmp.Name;
|
||||||
_Title = tmp.Title;
|
_Title = tmp.Title;
|
||||||
_ShortName = tmp.ShortName;
|
_ShortName = tmp.ShortName;
|
||||||
@@ -513,8 +477,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
|
|
||||||
public static FolderInfo Get(int folderID)
|
public static FolderInfo Get(int folderID)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a Folder");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FolderInfo tmp = GetCachedByPrimaryKey(folderID);
|
FolderInfo tmp = GetCachedByPrimaryKey(folderID);
|
||||||
@@ -553,13 +515,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _FolderID;
|
private readonly int _FolderID;
|
||||||
public int FolderID
|
public int FolderID => _FolderID;
|
||||||
{ get { return _FolderID; } }
|
public PKCriteria(int folderID) => _FolderID = folderID;
|
||||||
public PKCriteria(int folderID)
|
|
||||||
{
|
|
||||||
_FolderID = folderID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void ReadData(SafeDataReader dr)
|
private void ReadData(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
@@ -627,7 +585,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
FolderInfoExtension _FolderInfoExtension = new FolderInfoExtension();
|
readonly FolderInfoExtension _FolderInfoExtension = new FolderInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class FolderInfoExtension : extensionBase { }
|
partial class FolderInfoExtension : extensionBase { }
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
@@ -643,10 +601,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 FolderInfo)
|
if (destType == typeof(string) && value is FolderInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((FolderInfo)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<FolderInfo> Items
|
internal new IList<FolderInfo> Items => base.Items;
|
||||||
{ get { return base.Items; } }
|
public void AddEvents()
|
||||||
public void AddEvents()
|
|
||||||
{
|
{
|
||||||
foreach (FolderInfo tmp in this)
|
foreach (FolderInfo 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
|
~FolderInfoList()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~FolderInfoList()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -97,26 +90,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on FolderInfoList.Get", ex);
|
throw new DbCslaException("Error on FolderInfoList.Get", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset the list of all FolderInfo.
|
/// Reset the list of all FolderInfo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Reset()
|
public static void Reset() => _FolderInfoList = null;
|
||||||
{
|
public static FolderInfoList GetChildren(int parentID)
|
||||||
_FolderInfoList = null;
|
|
||||||
}
|
|
||||||
// CSLATODO: Add alternative gets -
|
|
||||||
//public static FolderInfoList Get(<criteria>)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// return DataPortal.Fetch<FolderInfoList>(new FilteredCriteria(<criteria>));
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// throw new DbCslaException("Error on FolderInfoList.Get", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
public static FolderInfoList GetChildren(int parentID)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -194,11 +172,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ParentIDCriteria
|
private class ParentIDCriteria
|
||||||
{
|
{
|
||||||
public ParentIDCriteria(int parentID)
|
public ParentIDCriteria(int parentID) => _ParentID = parentID;
|
||||||
{
|
private int _ParentID;
|
||||||
_ParentID = parentID;
|
|
||||||
}
|
|
||||||
private int _ParentID;
|
|
||||||
public int ParentID
|
public int ParentID
|
||||||
{
|
{
|
||||||
get { return _ParentID; }
|
get { return _ParentID; }
|
||||||
@@ -238,11 +213,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class DBIDCriteria
|
private class DBIDCriteria
|
||||||
{
|
{
|
||||||
public DBIDCriteria(int dbid)
|
public DBIDCriteria(int dbid) => _DBID = dbid;
|
||||||
{
|
private int _DBID;
|
||||||
_DBID = dbid;
|
|
||||||
}
|
|
||||||
private int _DBID;
|
|
||||||
public int DBID
|
public int DBID
|
||||||
{
|
{
|
||||||
get { return _DBID; }
|
get { return _DBID; }
|
||||||
@@ -282,11 +254,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[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; }
|
||||||
@@ -323,41 +292,30 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
this.RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ICustomTypeDescriptor impl
|
#region ICustomTypeDescriptor impl
|
||||||
public String GetClassName()
|
public string GetClassName() => TypeDescriptor.GetClassName(this, true);
|
||||||
{ return TypeDescriptor.GetClassName(this, true); }
|
public AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true);
|
||||||
public AttributeCollection GetAttributes()
|
public string GetComponentName() => TypeDescriptor.GetComponentName(this, true);
|
||||||
{ return TypeDescriptor.GetAttributes(this, true); }
|
public TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true);
|
||||||
public String GetComponentName()
|
public EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
|
||||||
{ return TypeDescriptor.GetComponentName(this, true); }
|
public PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true);
|
||||||
public TypeConverter GetConverter()
|
public object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true);
|
||||||
{ return TypeDescriptor.GetConverter(this, true); }
|
public EventDescriptorCollection GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(this, attributes, true);
|
||||||
public EventDescriptor GetDefaultEvent()
|
public EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true);
|
||||||
{ return TypeDescriptor.GetDefaultEvent(this, true); }
|
public object GetPropertyOwner(PropertyDescriptor pd) => this;
|
||||||
public PropertyDescriptor GetDefaultProperty()
|
/// <summary>
|
||||||
{ return TypeDescriptor.GetDefaultProperty(this, true); }
|
/// Called to get the properties of this type. Returns properties with certain
|
||||||
public object GetEditor(Type editorBaseType)
|
/// attributes. this restriction is not implemented here.
|
||||||
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
|
/// </summary>
|
||||||
public EventDescriptorCollection GetEvents(Attribute[] attributes)
|
/// <param name="attributes"></param>
|
||||||
{ return TypeDescriptor.GetEvents(this, attributes, true); }
|
/// <returns></returns>
|
||||||
public EventDescriptorCollection GetEvents()
|
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
||||||
{ return TypeDescriptor.GetEvents(this, true); }
|
/// <summary>
|
||||||
public object GetPropertyOwner(PropertyDescriptor pd)
|
/// Called to get the properties of this type.
|
||||||
{ return this; }
|
/// </summary>
|
||||||
/// <summary>
|
/// <returns></returns>
|
||||||
/// Called to get the properties of this type. Returns properties with certain
|
public PropertyDescriptorCollection GetProperties()
|
||||||
/// attributes. this restriction is not implemented here.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="attributes"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
|
|
||||||
{ return GetProperties(); }
|
|
||||||
/// <summary>
|
|
||||||
/// Called to get the properties of this type.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PropertyDescriptorCollection GetProperties()
|
|
||||||
{
|
{
|
||||||
// Create a collection object to hold property descriptors
|
// Create a collection object to hold property descriptors
|
||||||
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
||||||
@@ -379,7 +337,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class FolderInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class FolderInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private FolderInfo Item { get { return (FolderInfo)_Item; } }
|
|
||||||
public FolderInfoListPropertyDescriptor(FolderInfoList collection, int index) : base(collection, index) { ;}
|
public FolderInfoListPropertyDescriptor(FolderInfoList collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -388,10 +345,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 FolderInfoList)
|
if (destType == typeof(string) && value is FolderInfoList list)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((FolderInfoList)value).Items.Count.ToString() + " Folders";
|
return $"{list.Items.Count} Folders";
|
||||||
}
|
}
|
||||||
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;
|
||||||
@@ -102,6 +100,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<Format> _CacheList = new List<Format>();
|
private static List<Format> _CacheList = new List<Format>();
|
||||||
protected static void AddToCache(Format format)
|
protected static void AddToCache(Format format)
|
||||||
{
|
{
|
||||||
@@ -111,7 +110,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(format)) _CacheList.Remove(format); // In RemoveFromCache
|
while (_CacheList.Contains(format)) _CacheList.Remove(format); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<Format>> _CacheByPrimaryKey = new Dictionary<string, List<Format>>();
|
private static Dictionary<string, List<Format>> _CacheByPrimaryKey = new Dictionary<string, List<Format>>();
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<Format>> _CacheByParentID_Name = new Dictionary<string, List<Format>>();
|
private static Dictionary<string, List<Format>> _CacheByParentID_Name = new Dictionary<string, List<Format>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -154,15 +155,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 _nextFormatID = -1;
|
private static int _nextFormatID = -1;
|
||||||
public static int NextFormatID
|
public static int NextFormatID => _nextFormatID--;
|
||||||
{
|
|
||||||
get { return _nextFormatID--; }
|
|
||||||
}
|
|
||||||
private int _FormatID;
|
private int _FormatID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int FormatID
|
public int FormatID
|
||||||
@@ -367,10 +362,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _FormatContents;
|
return _FormatContents;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Reset_FormatContents()
|
public void Reset_FormatContents() => _FormatContentCount = -1;
|
||||||
{
|
|
||||||
_FormatContentCount = -1;
|
|
||||||
}
|
|
||||||
private int _FormatDocVersionCount = 0;
|
private int _FormatDocVersionCount = 0;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Count of FormatDocVersions for this Format
|
/// Count of FormatDocVersions for this Format
|
||||||
@@ -402,10 +394,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _FormatDocVersions;
|
return _FormatDocVersions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Reset_FormatDocVersions()
|
public void Reset_FormatDocVersions() => _FormatDocVersionCount = -1;
|
||||||
{
|
|
||||||
_FormatDocVersionCount = -1;
|
|
||||||
}
|
|
||||||
private int _FormatFolderCount = 0;
|
private int _FormatFolderCount = 0;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Count of FormatFolders for this Format
|
/// Count of FormatFolders for this Format
|
||||||
@@ -472,10 +461,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _ChildFormats;
|
return _ChildFormats;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Reset_ChildFormats()
|
public void Reset_ChildFormats() => _ChildFormatCount = -1;
|
||||||
{
|
|
||||||
_ChildFormatCount = -1;
|
|
||||||
}
|
|
||||||
public override bool IsDirty
|
public override bool IsDirty
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -490,37 +476,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 || (_FormatContents == null ? false : _FormatContents.IsDirtyList(list)) || (_FormatDocVersions == null ? false : _FormatDocVersions.IsDirtyList(list)) || (_FormatFolders == null ? false : _FormatFolders.IsDirtyList(list)) || (_ChildFormats == null ? false : _ChildFormats.IsDirtyList(list));
|
return base.IsDirty || (_FormatContents != null && _FormatContents.IsDirtyList(list)) || (_FormatDocVersions != null && _FormatDocVersions.IsDirtyList(list)) || (_FormatFolders != null && _FormatFolders.IsDirtyList(list)) || (_ChildFormats != null && _ChildFormats.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) && (_FormatContents == null ? true : _FormatContents.IsValidList(list)) && (_FormatDocVersions == null ? true : _FormatDocVersions.IsValidList(list)) && (_FormatFolders == null ? true : _FormatFolders.IsValidList(list)) && (_ChildFormats == null ? true : _ChildFormats.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_FormatContents == null || _FormatContents.IsValidList(list)) && (_FormatDocVersions == null || _FormatDocVersions.IsValidList(list)) && (_FormatFolders == null || _FormatFolders.IsValidList(list)) && (_ChildFormats == null || _ChildFormats.IsValidList(list));
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base Format.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current Format</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check Format.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check Format.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 Format</returns>
|
/// <returns>A Unique ID for the current Format</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyFormatUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyFormatUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
@@ -552,8 +523,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()
|
||||||
@@ -566,8 +537,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
ValidationRules.AddRule(
|
ValidationRules.AddRule(
|
||||||
Csla.Validation.CommonRules.StringMaxLength,
|
Csla.Validation.CommonRules.StringMaxLength,
|
||||||
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Description", 250));
|
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Description", 250));
|
||||||
//ValidationRules.AddRule(
|
|
||||||
// Csla.Validation.CommonRules.StringRequired, "Data");
|
|
||||||
ValidationRules.AddRule(
|
ValidationRules.AddRule(
|
||||||
Csla.Validation.CommonRules.StringMaxLength,
|
Csla.Validation.CommonRules.StringMaxLength,
|
||||||
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Data", 1073741823));
|
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Data", 1073741823));
|
||||||
@@ -591,37 +560,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_FormatExtension.AddInstanceValidationRules(ValidationRules);
|
_FormatExtension.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(FormatID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ParentID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Description, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Data, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(GenMac, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ParentID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Description, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Data, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(GenMac, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
|
||||||
_FormatExtension.AddAuthorizationRules(AuthorizationRules);
|
_FormatExtension.AddAuthorizationRules(AuthorizationRules);
|
||||||
}
|
}
|
||||||
protected override void AddInstanceAuthorizationRules()
|
protected override void AddInstanceAuthorizationRules()
|
||||||
@@ -629,58 +572,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//CSLATODO: Who can read/write which fields
|
//CSLATODO: Who can read/write which fields
|
||||||
_FormatExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
_FormatExtension.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 += _FormatContentCount;
|
|
||||||
usedByCount += _FormatDocVersionCount;
|
|
||||||
usedByCount += _FormatFolderCount;
|
|
||||||
usedByCount += _ChildFormatCount;
|
|
||||||
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 _FormatUnique = 0;
|
private static int _FormatUnique = 0;
|
||||||
protected static int FormatUnique
|
protected static int FormatUnique => ++_FormatUnique;
|
||||||
{ get { return ++_FormatUnique; } }
|
private readonly int _MyFormatUnique = FormatUnique;
|
||||||
private int _MyFormatUnique = FormatUnique;
|
// Absolutely Unique ID - Editable
|
||||||
public int MyFormatUnique // Absolutely Unique ID - Editable
|
public int MyFormatUnique => _MyFormatUnique;
|
||||||
{ get { return _MyFormatUnique; } }
|
|
||||||
protected Format()
|
protected Format()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -689,15 +588,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; } }
|
|
||||||
~Format()
|
~Format()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -734,8 +629,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Format New()
|
public static Format New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Format");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<Format>();
|
return DataPortal.Create<Format>();
|
||||||
@@ -811,8 +704,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Format Get(int formatID)
|
public static Format Get(int formatID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a Format");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Format tmp = GetCachedByPrimaryKey(formatID);
|
Format tmp = GetCachedByPrimaryKey(formatID);
|
||||||
@@ -835,8 +726,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Format GetByParentID_Name(int parentID, string name)
|
public static Format GetByParentID_Name(int parentID, string name)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a Format");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Format tmp = GetCachedByParentID_Name(parentID, name);
|
Format tmp = GetCachedByParentID_Name(parentID, name);
|
||||||
@@ -862,15 +751,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dr.Read()) return new Format(dr, parent);
|
if (dr.Read()) return new Format(dr, parent);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
internal Format(SafeDataReader dr)
|
internal Format(SafeDataReader dr) => ReadData(dr);
|
||||||
{
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
ReadData(dr);
|
|
||||||
}
|
|
||||||
private Format(SafeDataReader dr, Format parent)
|
private Format(SafeDataReader dr, Format parent)
|
||||||
{
|
{
|
||||||
ReadData(dr);
|
ReadData(dr);
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
internal Format(SafeDataReader dr, int parentID)
|
internal Format(SafeDataReader dr, int parentID)
|
||||||
{
|
{
|
||||||
ReadData(dr);
|
ReadData(dr);
|
||||||
@@ -878,8 +766,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static void Delete(int formatID)
|
public static void Delete(int formatID)
|
||||||
{
|
{
|
||||||
if (!CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Format");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataPortal.Delete(new PKCriteria(formatID));
|
DataPortal.Delete(new PKCriteria(formatID));
|
||||||
@@ -891,12 +777,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public override Format Save()
|
public override Format Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Format");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Format");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a Format");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -916,23 +796,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _FormatID;
|
private readonly int _FormatID;
|
||||||
public int FormatID
|
public int FormatID => _FormatID;
|
||||||
{ get { return _FormatID; } }
|
public PKCriteria(int formatID) => _FormatID = formatID;
|
||||||
public PKCriteria(int formatID)
|
|
||||||
{
|
|
||||||
_FormatID = formatID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ParentID_NameCriteria
|
private class ParentID_NameCriteria
|
||||||
{
|
{
|
||||||
private int _ParentID;
|
private readonly int _ParentID;
|
||||||
public int ParentID
|
public int ParentID => _ParentID;
|
||||||
{ get { return _ParentID; } }
|
private readonly string _Name;
|
||||||
private string _Name;
|
public string Name => _Name;
|
||||||
public string Name
|
|
||||||
{ get { return _Name; } }
|
|
||||||
public ParentID_NameCriteria(int parentID, string name)
|
public ParentID_NameCriteria(int parentID, string name)
|
||||||
{
|
{
|
||||||
_ParentID = parentID;
|
_ParentID = parentID;
|
||||||
@@ -1104,43 +978,50 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
internal void SQLInsert()
|
internal void SQLInsert()
|
||||||
{
|
{
|
||||||
if (!this.IsDirty) return;
|
if (!IsDirty) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
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 = "addFormat";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@ParentID", ParentID);
|
cm.CommandText = "addFormat";
|
||||||
cm.Parameters.AddWithValue("@Name", _Name);
|
// Input All Fields - Except Calculated Columns
|
||||||
cm.Parameters.AddWithValue("@Description", _Description);
|
cm.Parameters.AddWithValue("@ParentID", ParentID);
|
||||||
cm.Parameters.AddWithValue("@Data", _Data);
|
cm.Parameters.AddWithValue("@Name", _Name);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@Description", _Description);
|
||||||
cm.Parameters.AddWithValue("@GenMac", _GenMac);
|
cm.Parameters.AddWithValue("@Data", _Data);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
cm.Parameters.AddWithValue("@GenMac", _GenMac);
|
||||||
// Output Calculated Columns
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
SqlParameter param_FormatID = new SqlParameter("@newFormatID", SqlDbType.Int);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
param_FormatID.Direction = ParameterDirection.Output;
|
// Output Calculated Columns
|
||||||
cm.Parameters.Add(param_FormatID);
|
SqlParameter param_FormatID = new SqlParameter("@newFormatID", 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_FormatID);
|
||||||
cm.ExecuteNonQuery();
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
// Save all values being returned from the Procedure
|
{
|
||||||
_FormatID = (int)cm.Parameters["@newFormatID"].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
|
||||||
|
_FormatID = (int)cm.Parameters["@newFormatID"].Value;
|
||||||
|
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
// update child objects
|
// update child objects
|
||||||
if (_FormatFolders != null) _FormatFolders.Update(this);
|
_FormatFolders?.Update(this);
|
||||||
if (_FormatContents != null) _FormatContents.Update(this);
|
_FormatContents?.Update(this);
|
||||||
if (_FormatDocVersions != null) _FormatDocVersions.Update(this);
|
_FormatDocVersions?.Update(this);
|
||||||
if (_ChildFormats != null) _ChildFormats.Update(this);
|
_ChildFormats?.Update(this);
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.SQLInsert", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.SQLInsert", GetHashCode());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -1171,11 +1052,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_FormatID = new SqlParameter("@newFormatID", SqlDbType.Int);
|
SqlParameter param_FormatID = new SqlParameter("@newFormatID", SqlDbType.Int)
|
||||||
param_FormatID.Direction = ParameterDirection.Output;
|
{
|
||||||
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
cm.Parameters.Add(param_FormatID);
|
cm.Parameters.Add(param_FormatID);
|
||||||
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();
|
||||||
@@ -1220,41 +1105,46 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.SQLUpdate", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
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 = "updateFormat";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@FormatID", _FormatID);
|
cm.CommandText = "updateFormat";
|
||||||
cm.Parameters.AddWithValue("@ParentID", ParentID);
|
// All Fields including Calculated Fields
|
||||||
cm.Parameters.AddWithValue("@Name", _Name);
|
cm.Parameters.AddWithValue("@FormatID", _FormatID);
|
||||||
cm.Parameters.AddWithValue("@Description", _Description);
|
cm.Parameters.AddWithValue("@ParentID", ParentID);
|
||||||
cm.Parameters.AddWithValue("@Data", _Data);
|
cm.Parameters.AddWithValue("@Name", _Name);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@Description", _Description);
|
||||||
cm.Parameters.AddWithValue("@GenMac", _GenMac);
|
cm.Parameters.AddWithValue("@Data", _Data);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
cm.Parameters.AddWithValue("@GenMac", _GenMac);
|
||||||
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 (_FormatFolders != null) _FormatFolders.Update(this);
|
_FormatFolders?.Update(this);
|
||||||
if (_FormatContents != null) _FormatContents.Update(this);
|
_FormatContents?.Update(this);
|
||||||
if (_FormatDocVersions != null) _FormatDocVersions.Update(this);
|
_FormatDocVersions?.Update(this);
|
||||||
if (_ChildFormats != null) _ChildFormats.Update(this);
|
_ChildFormats?.Update(this);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -1265,29 +1155,36 @@ 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 = Format.Add(cn, ref _FormatID, _MyParent, _Name, _Description, _Data, _Config, _GenMac, _DTS, _UserID);
|
if (IsNew)
|
||||||
else
|
_LastChanged = Format.Add(cn, ref _FormatID, _MyParent, _Name, _Description, _Data, _Config, _GenMac, _DTS, _UserID);
|
||||||
_LastChanged = Format.Update(cn, ref _FormatID, _ParentID, _Name, _Description, _Data, _Config, _GenMac, _DTS, _UserID, ref _LastChanged);
|
else
|
||||||
|
_LastChanged = Format.Update(cn, ref _FormatID, _ParentID, _Name, _Description, _Data, _Config, _GenMac, _DTS, _UserID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
if (_FormatFolders != null) _FormatFolders.Update(this);
|
_FormatFolders?.Update(this);
|
||||||
if (_FormatContents != null) _FormatContents.Update(this);
|
_FormatContents?.Update(this);
|
||||||
if (_FormatDocVersions != null) _FormatDocVersions.Update(this);
|
_FormatDocVersions?.Update(this);
|
||||||
if (_ChildFormats != null) _ChildFormats.Update(this);
|
_ChildFormats?.Update(this);
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
internal void DeleteSelf(Format format)
|
internal void DeleteSelf(Format format)
|
||||||
{
|
{
|
||||||
// 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"])
|
||||||
Format.Remove(cn, _FormatID);
|
{
|
||||||
|
Format.Remove(cn, _FormatID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkNew();
|
MarkNew();
|
||||||
}
|
}
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
@@ -1313,8 +1210,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();
|
||||||
@@ -1399,16 +1298,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ExistsCommand : CommandBase
|
private class ExistsCommand : CommandBase
|
||||||
{
|
{
|
||||||
private int _FormatID;
|
private readonly int _FormatID;
|
||||||
private bool _exists;
|
private bool _exists;
|
||||||
public bool Exists
|
public bool Exists => _exists;
|
||||||
{
|
public ExistsCommand(int formatID) => _FormatID = formatID;
|
||||||
get { return _exists; }
|
|
||||||
}
|
|
||||||
public ExistsCommand(int formatID)
|
|
||||||
{
|
|
||||||
_FormatID = formatID;
|
|
||||||
}
|
|
||||||
protected override void DataPortal_Execute()
|
protected override void DataPortal_Execute()
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.DataPortal_Execute", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.DataPortal_Execute", GetHashCode());
|
||||||
@@ -1438,7 +1331,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
FormatExtension _FormatExtension = new FormatExtension();
|
readonly FormatExtension _FormatExtension = new FormatExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class FormatExtension : extensionBase
|
partial class FormatExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -1447,18 +1340,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
class extensionBase
|
class extensionBase
|
||||||
{
|
{
|
||||||
// Default Values
|
// Default Values
|
||||||
public virtual int DefaultParentID
|
public virtual int DefaultParentID => 1;
|
||||||
{
|
public virtual DateTime DefaultDTS => DateTime.Now;
|
||||||
get { return 1; }
|
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)
|
||||||
{
|
{
|
||||||
@@ -1487,61 +1371,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 Format)
|
if (destType == typeof(string) && value is Format format)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((Format)value).ToString();
|
return format.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 FormatExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class Format
|
|
||||||
// {
|
|
||||||
// partial class FormatExtension : extensionBase
|
|
||||||
// {
|
|
||||||
// // CSLATODO: Override automatic defaults
|
|
||||||
// public virtual int DefaultParentID
|
|
||||||
// {
|
|
||||||
// get { return 1; }
|
|
||||||
// }
|
|
||||||
// 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 _ContentID;
|
private int _ContentID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int ContentID
|
public int ContentID
|
||||||
@@ -182,10 +176,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 FormatContent</returns>
|
/// <returns>A Unique ID for the current FormatContent</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyFormatContentUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyFormatContentUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
// CSLATODO: Replace base FormatContent.ToString function as necessary
|
// CSLATODO: Replace base FormatContent.ToString function as necessary
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides Base ToString
|
/// Overrides Base ToString
|
||||||
@@ -195,22 +186,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//{
|
//{
|
||||||
// return base.ToString();
|
// return base.ToString();
|
||||||
//}
|
//}
|
||||||
public override bool IsDirty
|
public override bool IsDirty => base.IsDirty;
|
||||||
{
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
get { return base.IsDirty; }
|
public bool IsDirtyList(List<object> list) => base.IsDirty;
|
||||||
}
|
public override bool IsValid => (IsNew && !IsDirty) || base.IsValid;
|
||||||
public bool IsDirtyList(List<object> list)
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
{
|
public bool IsValidList(List<object> list) => (IsNew && !IsDirty) || base.IsValid;
|
||||||
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]
|
||||||
@@ -239,7 +220,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()
|
||||||
@@ -260,80 +241,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(Number, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Number, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Text, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Text, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Type, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Type, "<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 _FormatContentUnique = 0;
|
private static int _FormatContentUnique = 0;
|
||||||
private static int FormatContentUnique
|
private static int FormatContentUnique => ++_FormatContentUnique;
|
||||||
{ get { return ++_FormatContentUnique; } }
|
private readonly int _MyFormatContentUnique = FormatContentUnique;
|
||||||
private int _MyFormatContentUnique = FormatContentUnique;
|
// Absolutely Unique ID - Editable FK
|
||||||
public int MyFormatContentUnique // Absolutely Unique ID - Editable FK
|
public int MyFormatContentUnique => _MyFormatContentUnique;
|
||||||
{ get { return _MyFormatContentUnique; } }
|
internal static FormatContent New() => new FormatContent();
|
||||||
internal static FormatContent New()
|
internal static FormatContent Get(SafeDataReader dr) => new FormatContent(dr);
|
||||||
{
|
|
||||||
return new FormatContent();
|
|
||||||
}
|
|
||||||
internal static FormatContent Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new FormatContent(dr);
|
|
||||||
}
|
|
||||||
public FormatContent()
|
public FormatContent()
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
@@ -351,15 +274,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; } }
|
|
||||||
~FormatContent()
|
~FormatContent()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -397,32 +316,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 = Content.Add(cn, ref _ContentID, _Number, _Text, _Type, myFormat, _Config, _DTS, _UserID);
|
{
|
||||||
|
_LastChanged = Content.Add(cn, ref _ContentID, _Number, _Text, _Type, myFormat, _Config, _DTS, _UserID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
internal void Update(Format myFormat)
|
internal void Update(Format myFormat)
|
||||||
{
|
{
|
||||||
// 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 = Content.Update(cn, ref _ContentID, _Number, _Text, _Type, myFormat != null ? (int?)myFormat.FormatID : (int?)null, _Config, _DTS, _UserID, ref _LastChanged);
|
{
|
||||||
|
_LastChanged = Content.Update(cn, ref _ContentID, _Number, _Text, _Type, myFormat != null ? (int?)myFormat.FormatID : (int?)null, _Config, _DTS, _UserID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
internal void DeleteSelf(Format myFormat)
|
internal void DeleteSelf(Format myFormat)
|
||||||
{
|
{
|
||||||
// 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"])
|
||||||
Content.Remove(cn, _ContentID);
|
{
|
||||||
|
Content.Remove(cn, _ContentID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkNew();
|
MarkNew();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
FormatContentExtension _FormatContentExtension = new FormatContentExtension();
|
readonly FormatContentExtension _FormatContentExtension = new FormatContentExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class FormatContentExtension : extensionBase
|
partial class FormatContentExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -431,14 +360,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)
|
||||||
{
|
{
|
||||||
@@ -467,57 +390,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 FormatContent)
|
if (destType == typeof(string) && value is FormatContent content)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((FormatContent)value).ToString();
|
return content.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 FormatContentExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class FormatContent
|
|
||||||
// {
|
|
||||||
// partial class FormatContentExtension : 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 FormatContent this[Content myContent]
|
||||||
}
|
|
||||||
// One To Many
|
|
||||||
public FormatContent this[Content myContent]
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -47,11 +42,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public new System.Collections.Generic.IList<FormatContent> Items
|
public new System.Collections.Generic.IList<FormatContent> Items => base.Items;
|
||||||
{
|
public FormatContent GetItem(Content myContent)
|
||||||
get { return base.Items; }
|
|
||||||
}
|
|
||||||
public FormatContent GetItem(Content myContent)
|
|
||||||
{
|
{
|
||||||
foreach (FormatContent content in this)
|
foreach (FormatContent content in this)
|
||||||
if (content.ContentID == myContent.ContentID)
|
if (content.ContentID == myContent.ContentID)
|
||||||
@@ -61,7 +53,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public FormatContent Add() // One to Many
|
public FormatContent Add() // One to Many
|
||||||
{
|
{
|
||||||
FormatContent content = FormatContent.New();
|
FormatContent content = FormatContent.New();
|
||||||
this.Add(content);
|
Add(content);
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
public void Remove(Content myContent)
|
public void Remove(Content myContent)
|
||||||
@@ -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 (FormatContent 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 (FormatContent 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 FormatContents New()
|
internal static FormatContents New() => new FormatContents();
|
||||||
{
|
internal static FormatContents Get(SafeDataReader dr) => new FormatContents(dr);
|
||||||
return new FormatContents();
|
public static FormatContents GetByFormatID(int formatID)
|
||||||
}
|
|
||||||
internal static FormatContents Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new FormatContents(dr);
|
|
||||||
}
|
|
||||||
public static FormatContents GetByFormatID(int formatID)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -161,11 +144,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on FormatContents.GetByFormatID", ex);
|
throw new DbCslaException("Error on FormatContents.GetByFormatID", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private FormatContents()
|
private FormatContents() => MarkAsChild();
|
||||||
{
|
internal FormatContents(SafeDataReader dr)
|
||||||
MarkAsChild();
|
|
||||||
}
|
|
||||||
internal FormatContents(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
|
~FormatContents()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~FormatContents()
|
|
||||||
{
|
{
|
||||||
_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(FormatContent.Get(dr));
|
Add(FormatContent.Get(dr));
|
||||||
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; }
|
||||||
@@ -219,7 +192,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}] FormatContents.DataPortal_FetchFormatID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatContents.DataPortal_FetchFormatID", 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 FormatContent(dr));
|
while (dr.Read()) Add(new FormatContent(dr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,11 +216,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatContents.DataPortal_FetchFormatID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatContents.DataPortal_FetchFormatID", ex);
|
||||||
throw new DbCslaException("FormatContents.DataPortal_Fetch", ex);
|
throw new DbCslaException("FormatContents.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
internal void Update(Format format)
|
internal void Update(Format format)
|
||||||
{
|
{
|
||||||
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
|
||||||
FormatContentsPropertyDescriptor pd = new FormatContentsPropertyDescriptor(this, i);
|
FormatContentsPropertyDescriptor pd = new FormatContentsPropertyDescriptor(this, i);
|
||||||
@@ -325,7 +287,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class FormatContentsPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class FormatContentsPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private FormatContent Item { get { return (FormatContent)_Item; } }
|
|
||||||
public FormatContentsPropertyDescriptor(FormatContents collection, int index) : base(collection, index) { ;}
|
public FormatContentsPropertyDescriptor(FormatContents collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -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 FormatContents)
|
if (destType == typeof(string) && value is FormatContents contents)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((FormatContents)value).Items.Count.ToString() + " Contents";
|
return $"{contents.Items.Count} Contents";
|
||||||
}
|
}
|
||||||
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 _VersionID;
|
private int _VersionID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int VersionID
|
public int VersionID
|
||||||
@@ -329,10 +323,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 FormatDocVersion</returns>
|
/// <returns>A Unique ID for the current FormatDocVersion</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyFormatDocVersionUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyFormatDocVersionUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
// CSLATODO: Replace base FormatDocVersion.ToString function as necessary
|
// CSLATODO: Replace base FormatDocVersion.ToString function as necessary
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides Base ToString
|
/// Overrides Base ToString
|
||||||
@@ -356,18 +347,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 || (_MyFolder == null ? false : _MyFolder.IsDirtyList(list));
|
return base.IsDirty || (_MyFolder != null && _MyFolder.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) && (_MyFolder == null ? true : _MyFolder.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_MyFolder == null || _MyFolder.IsValidList(list));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
@@ -398,8 +386,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()
|
||||||
@@ -432,84 +420,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(VersionID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(FolderID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(VersionType, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(VersionType, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ItemID, "<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 _FormatDocVersionUnique = 0;
|
private static int _FormatDocVersionUnique = 0;
|
||||||
private static int FormatDocVersionUnique
|
private static int FormatDocVersionUnique => ++_FormatDocVersionUnique;
|
||||||
{ get { return ++_FormatDocVersionUnique; } }
|
private readonly int _MyFormatDocVersionUnique = FormatDocVersionUnique;
|
||||||
private int _MyFormatDocVersionUnique = FormatDocVersionUnique;
|
// Absolutely Unique ID - Editable FK
|
||||||
public int MyFormatDocVersionUnique // Absolutely Unique ID - Editable FK
|
public int MyFormatDocVersionUnique => _MyFormatDocVersionUnique;
|
||||||
{ get { return _MyFormatDocVersionUnique; } }
|
internal static FormatDocVersion New(Folder myFolder, string name) => new FormatDocVersion(myFolder, name);
|
||||||
internal static FormatDocVersion New(Folder myFolder, string name)
|
internal static FormatDocVersion Get(SafeDataReader dr) => new FormatDocVersion(dr);
|
||||||
{
|
|
||||||
return new FormatDocVersion(myFolder, name);
|
|
||||||
}
|
|
||||||
internal static FormatDocVersion Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new FormatDocVersion(dr);
|
|
||||||
}
|
|
||||||
public FormatDocVersion()
|
public FormatDocVersion()
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
@@ -540,15 +466,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; } }
|
|
||||||
~FormatDocVersion()
|
~FormatDocVersion()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -597,33 +519,43 @@ namespace VEPROMS.CSLA.Library
|
|||||||
internal void Insert(Format myFormat)
|
internal void Insert(Format myFormat)
|
||||||
{
|
{
|
||||||
// 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 = DocVersion.Add(cn, ref _VersionID, _MyFolder, _VersionType, _Name, _Title, _MyItem, myFormat, _Config, _DTS, _UserID);
|
{
|
||||||
|
_LastChanged = DocVersion.Add(cn, ref _VersionID, _MyFolder, _VersionType, _Name, _Title, _MyItem, myFormat, _Config, _DTS, _UserID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
internal void Update(Format myFormat)
|
internal void Update(Format myFormat)
|
||||||
{
|
{
|
||||||
// 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 = DocVersion.Update(cn, ref _VersionID, _FolderID, _VersionType, _Name, _Title, _ItemID, myFormat != null ? (int?)myFormat.FormatID : (int?)null, _Config, _DTS, _UserID, ref _LastChanged);
|
{
|
||||||
|
_LastChanged = DocVersion.Update(cn, ref _VersionID, _FolderID, _VersionType, _Name, _Title, _ItemID, myFormat != null ? (int?)myFormat.FormatID : (int?)null, _Config, _DTS, _UserID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
internal void DeleteSelf(Format myFormat)
|
internal void DeleteSelf(Format myFormat)
|
||||||
{
|
{
|
||||||
// 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"])
|
||||||
DocVersion.Remove(cn, _VersionID);
|
{
|
||||||
|
DocVersion.Remove(cn, _VersionID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkNew();
|
MarkNew();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
FormatDocVersionExtension _FormatDocVersionExtension = new FormatDocVersionExtension();
|
readonly FormatDocVersionExtension _FormatDocVersionExtension = new FormatDocVersionExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class FormatDocVersionExtension : extensionBase
|
partial class FormatDocVersionExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -632,18 +564,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)
|
||||||
{
|
{
|
||||||
@@ -672,61 +595,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 FormatDocVersion)
|
if (destType == typeof(string) && value is FormatDocVersion version)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((FormatDocVersion)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 FormatDocVersionExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class FormatDocVersion
|
|
||||||
// {
|
|
||||||
// partial class FormatDocVersionExtension : 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 */);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
@@ -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 FormatDocVersion this[DocVersion myDocVersion]
|
||||||
}
|
|
||||||
// One To Many
|
|
||||||
public FormatDocVersion this[DocVersion myDocVersion]
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -47,11 +42,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public new System.Collections.Generic.IList<FormatDocVersion> Items
|
public new System.Collections.Generic.IList<FormatDocVersion> Items => base.Items;
|
||||||
{
|
public FormatDocVersion GetItem(DocVersion myDocVersion)
|
||||||
get { return base.Items; }
|
|
||||||
}
|
|
||||||
public FormatDocVersion GetItem(DocVersion myDocVersion)
|
|
||||||
{
|
{
|
||||||
foreach (FormatDocVersion docVersion in this)
|
foreach (FormatDocVersion docVersion in this)
|
||||||
if (docVersion.VersionID == myDocVersion.VersionID)
|
if (docVersion.VersionID == myDocVersion.VersionID)
|
||||||
@@ -61,7 +53,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public FormatDocVersion Add(Folder myFolder, string name) // One to Many
|
public FormatDocVersion Add(Folder myFolder, string name) // One to Many
|
||||||
{
|
{
|
||||||
FormatDocVersion docVersion = FormatDocVersion.New(myFolder, name);
|
FormatDocVersion docVersion = FormatDocVersion.New(myFolder, name);
|
||||||
this.Add(docVersion);
|
Add(docVersion);
|
||||||
return docVersion;
|
return docVersion;
|
||||||
}
|
}
|
||||||
public void Remove(DocVersion myDocVersion)
|
public void Remove(DocVersion myDocVersion)
|
||||||
@@ -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 (FormatDocVersion 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 (FormatDocVersion 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 FormatDocVersions New()
|
internal static FormatDocVersions New() => new FormatDocVersions();
|
||||||
{
|
internal static FormatDocVersions Get(SafeDataReader dr) => new FormatDocVersions(dr);
|
||||||
return new FormatDocVersions();
|
public static FormatDocVersions GetByFormatID(int formatID)
|
||||||
}
|
|
||||||
internal static FormatDocVersions Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new FormatDocVersions(dr);
|
|
||||||
}
|
|
||||||
public static FormatDocVersions GetByFormatID(int formatID)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -161,11 +144,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on FormatDocVersions.GetByFormatID", ex);
|
throw new DbCslaException("Error on FormatDocVersions.GetByFormatID", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private FormatDocVersions()
|
private FormatDocVersions() => MarkAsChild();
|
||||||
{
|
internal FormatDocVersions(SafeDataReader dr)
|
||||||
MarkAsChild();
|
|
||||||
}
|
|
||||||
internal FormatDocVersions(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
|
~FormatDocVersions()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~FormatDocVersions()
|
|
||||||
{
|
{
|
||||||
_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(FormatDocVersion.Get(dr));
|
Add(FormatDocVersion.Get(dr));
|
||||||
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; }
|
||||||
@@ -219,7 +192,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}] FormatDocVersions.DataPortal_FetchFormatID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatDocVersions.DataPortal_FetchFormatID", 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 FormatDocVersion(dr));
|
while (dr.Read()) Add(new FormatDocVersion(dr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,11 +216,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatDocVersions.DataPortal_FetchFormatID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatDocVersions.DataPortal_FetchFormatID", ex);
|
||||||
throw new DbCslaException("FormatDocVersions.DataPortal_Fetch", ex);
|
throw new DbCslaException("FormatDocVersions.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
internal void Update(Format format)
|
internal void Update(Format format)
|
||||||
{
|
{
|
||||||
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
|
||||||
FormatDocVersionsPropertyDescriptor pd = new FormatDocVersionsPropertyDescriptor(this, i);
|
FormatDocVersionsPropertyDescriptor pd = new FormatDocVersionsPropertyDescriptor(this, i);
|
||||||
@@ -325,7 +287,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class FormatDocVersionsPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class FormatDocVersionsPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private FormatDocVersion Item { get { return (FormatDocVersion)_Item; } }
|
|
||||||
public FormatDocVersionsPropertyDescriptor(FormatDocVersions collection, int index) : base(collection, index) { ;}
|
public FormatDocVersionsPropertyDescriptor(FormatDocVersions collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -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 FormatDocVersions)
|
if (destType == typeof(string) && value is FormatDocVersions versions)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((FormatDocVersions)value).Items.Count.ToString() + " DocVersions";
|
return $"{versions.Items.Count} DocVersions";
|
||||||
}
|
}
|
||||||
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 _FolderID;
|
private int _FolderID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int FolderID
|
public int FolderID
|
||||||
@@ -321,19 +315,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 FormatFolder</returns>
|
/// <returns>A Unique ID for the current FormatFolder</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyFormatFolderUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyFormatFolderUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
// CSLATODO: Replace base FormatFolder.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current FormatFolder</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
public override bool IsDirty
|
public override bool IsDirty
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -348,18 +330,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 || (_MyFolder == null ? false : _MyFolder.IsDirtyList(list)) || (_MyConnection == null ? false : _MyConnection.IsDirtyList(list));
|
return base.IsDirty || (_MyFolder != null && _MyFolder.IsDirtyList(list)) || (_MyConnection != null && _MyConnection.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) && (_MyFolder == null ? true : _MyFolder.IsValidList(list)) && (_MyConnection == null ? true : _MyConnection.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_MyFolder == null || _MyFolder.IsValidList(list)) && (_MyConnection == null || _MyConnection.IsValidList(list));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
@@ -390,8 +369,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()
|
||||||
@@ -439,86 +418,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(FolderID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ParentID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ParentID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DBID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DBID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ShortName, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ShortName, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ManualOrder, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ManualOrder, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UsrID, "<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 _FormatFolderUnique = 0;
|
private static int _FormatFolderUnique = 0;
|
||||||
private static int FormatFolderUnique
|
private static int FormatFolderUnique => ++_FormatFolderUnique;
|
||||||
{ get { return ++_FormatFolderUnique; } }
|
private readonly int _MyFormatFolderUnique = FormatFolderUnique;
|
||||||
private int _MyFormatFolderUnique = FormatFolderUnique;
|
// Absolutely Unique ID - Editable FK
|
||||||
public int MyFormatFolderUnique // Absolutely Unique ID - Editable FK
|
public int MyFormatFolderUnique => _MyFormatFolderUnique;
|
||||||
{ get { return _MyFormatFolderUnique; } }
|
internal static FormatFolder New(Folder myParent, string name, string shortName) => new FormatFolder(myParent, name, shortName);
|
||||||
internal static FormatFolder New(Folder myParent, string name, string shortName)
|
internal static FormatFolder Get(SafeDataReader dr) => new FormatFolder(dr);
|
||||||
{
|
|
||||||
return new FormatFolder(myParent, name, shortName);
|
|
||||||
}
|
|
||||||
internal static FormatFolder Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new FormatFolder(dr);
|
|
||||||
}
|
|
||||||
public FormatFolder()
|
public FormatFolder()
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
@@ -552,15 +467,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; } }
|
|
||||||
~FormatFolder()
|
~FormatFolder()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -607,33 +518,43 @@ namespace VEPROMS.CSLA.Library
|
|||||||
internal void Insert(Format myFormat)
|
internal void Insert(Format myFormat)
|
||||||
{
|
{
|
||||||
// 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 = Folder.Add(cn, ref _FolderID, Folder.Get(_ParentID), _MyConnection, _Name, _Title, _ShortName, myFormat, _ManualOrder, _Config, _DTS, _UsrID);
|
{
|
||||||
|
_LastChanged = Folder.Add(cn, ref _FolderID, Folder.Get(_ParentID), _MyConnection, _Name, _Title, _ShortName, myFormat, _ManualOrder, _Config, _DTS, _UsrID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
internal void Update(Format myFormat)
|
internal void Update(Format myFormat)
|
||||||
{
|
{
|
||||||
// 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 = Folder.Update(cn, ref _FolderID, _ParentID, _DBID, _Name, _Title, _ShortName, myFormat != null ? (int?)myFormat.FormatID : (int?)null, _ManualOrder, _Config, _DTS, _UsrID, ref _LastChanged);
|
{
|
||||||
|
_LastChanged = Folder.Update(cn, ref _FolderID, _ParentID, _DBID, _Name, _Title, _ShortName, myFormat != null ? (int?)myFormat.FormatID : (int?)null, _ManualOrder, _Config, _DTS, _UsrID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
internal void DeleteSelf(Format myFormat)
|
internal void DeleteSelf(Format myFormat)
|
||||||
{
|
{
|
||||||
// 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"])
|
||||||
Folder.Remove(cn, _FolderID);
|
{
|
||||||
|
Folder.Remove(cn, _FolderID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkNew();
|
MarkNew();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
FormatFolderExtension _FormatFolderExtension = new FormatFolderExtension();
|
readonly FormatFolderExtension _FormatFolderExtension = new FormatFolderExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class FormatFolderExtension : extensionBase
|
partial class FormatFolderExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -642,22 +563,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
class extensionBase
|
class extensionBase
|
||||||
{
|
{
|
||||||
// Default Values
|
// Default Values
|
||||||
public virtual int DefaultParentID
|
public virtual int DefaultParentID => 1;
|
||||||
{
|
public virtual int DefaultDBID => 1;
|
||||||
get { return 1; }
|
public virtual DateTime DefaultDTS => DateTime.Now;
|
||||||
}
|
public virtual string DefaultUsrID => Volian.Base.Library.VlnSettings.UserID;
|
||||||
public virtual int DefaultDBID
|
|
||||||
{
|
|
||||||
get { return 1; }
|
|
||||||
}
|
|
||||||
public virtual DateTime DefaultDTS
|
|
||||||
{
|
|
||||||
get { return DateTime.Now; }
|
|
||||||
}
|
|
||||||
public virtual string DefaultUsrID
|
|
||||||
{
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -686,65 +595,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 FormatFolder)
|
if (destType == typeof(string) && value is FormatFolder folder)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((FormatFolder)value).ToString();
|
return folder.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 FormatFolderExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class FormatFolder
|
|
||||||
// {
|
|
||||||
// partial class FormatFolderExtension : extensionBase
|
|
||||||
// {
|
|
||||||
// // CSLATODO: Override automatic defaults
|
|
||||||
// public virtual int DefaultParentID
|
|
||||||
// {
|
|
||||||
// get { return 1; }
|
|
||||||
// }
|
|
||||||
// public virtual int DefaultDBID
|
|
||||||
// {
|
|
||||||
// get { return 1; }
|
|
||||||
// }
|
|
||||||
// public virtual DateTime DefaultDTS
|
|
||||||
// {
|
|
||||||
// get { return DateTime.Now; }
|
|
||||||
// }
|
|
||||||
// public virtual string DefaultUsrID
|
|
||||||
// {
|
|
||||||
// get { return Environment.UserName.ToUpper(); }
|
|
||||||
// }
|
|
||||||
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
|
||||||
// {
|
|
||||||
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
|
|
||||||
// }
|
|
||||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddRule(
|
|
||||||
// Csla.Validation.CommonRules.StringMaxLength,
|
|
||||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
|
||||||
// }
|
|
||||||
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
|
|
||||||
// {
|
|
||||||
// rules.AddInstanceRule(/* Instance Validation Rule */);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
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 FormatFolder this[Folder myFolder]
|
||||||
}
|
|
||||||
// One To Many
|
|
||||||
public FormatFolder this[Folder myFolder]
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -47,11 +42,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public new System.Collections.Generic.IList<FormatFolder> Items
|
public new System.Collections.Generic.IList<FormatFolder> Items => base.Items;
|
||||||
{
|
public FormatFolder GetItem(Folder myFolder)
|
||||||
get { return base.Items; }
|
|
||||||
}
|
|
||||||
public FormatFolder GetItem(Folder myFolder)
|
|
||||||
{
|
{
|
||||||
foreach (FormatFolder folder in this)
|
foreach (FormatFolder folder in this)
|
||||||
if (folder.FolderID == myFolder.FolderID)
|
if (folder.FolderID == myFolder.FolderID)
|
||||||
@@ -61,7 +53,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public FormatFolder Add(Folder myParent, string name, string shortName) // One to Many
|
public FormatFolder Add(Folder myParent, string name, string shortName) // One to Many
|
||||||
{
|
{
|
||||||
FormatFolder folder = FormatFolder.New(myParent, name, shortName);
|
FormatFolder folder = FormatFolder.New(myParent, name, shortName);
|
||||||
this.Add(folder);
|
Add(folder);
|
||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
public void Remove(Folder myFolder)
|
public void Remove(Folder myFolder)
|
||||||
@@ -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 (FormatFolder 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 (FormatFolder 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 FormatFolders New()
|
internal static FormatFolders New() => new FormatFolders();
|
||||||
{
|
internal static FormatFolders Get(SafeDataReader dr) => new FormatFolders(dr);
|
||||||
return new FormatFolders();
|
public static FormatFolders GetByFormatID(int formatID)
|
||||||
}
|
|
||||||
internal static FormatFolders Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new FormatFolders(dr);
|
|
||||||
}
|
|
||||||
public static FormatFolders GetByFormatID(int formatID)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -161,11 +144,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on FormatFolders.GetByFormatID", ex);
|
throw new DbCslaException("Error on FormatFolders.GetByFormatID", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private FormatFolders()
|
private FormatFolders() => MarkAsChild();
|
||||||
{
|
internal FormatFolders(SafeDataReader dr)
|
||||||
MarkAsChild();
|
|
||||||
}
|
|
||||||
internal FormatFolders(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
|
~FormatFolders()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~FormatFolders()
|
|
||||||
{
|
{
|
||||||
_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(FormatFolder.Get(dr));
|
Add(FormatFolder.Get(dr));
|
||||||
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; }
|
||||||
@@ -219,7 +192,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}] FormatFolders.DataPortal_FetchFormatID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatFolders.DataPortal_FetchFormatID", 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 FormatFolder(dr));
|
while (dr.Read()) Add(new FormatFolder(dr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,11 +216,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatFolders.DataPortal_FetchFormatID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatFolders.DataPortal_FetchFormatID", ex);
|
||||||
throw new DbCslaException("FormatFolders.DataPortal_Fetch", ex);
|
throw new DbCslaException("FormatFolders.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
internal void Update(Format format)
|
internal void Update(Format format)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// update (thus deleting) any deleted child objects
|
// update (thus deleting) any deleted child objects
|
||||||
@@ -266,49 +239,39 @@ 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()
|
||||||
public TypeConverter GetConverter()
|
|
||||||
{ return TypeDescriptor.GetConverter(this, true); }
|
|
||||||
public EventDescriptor GetDefaultEvent()
|
|
||||||
{ return TypeDescriptor.GetDefaultEvent(this, true); }
|
|
||||||
public PropertyDescriptor GetDefaultProperty()
|
|
||||||
{ return TypeDescriptor.GetDefaultProperty(this, true); }
|
{ return TypeDescriptor.GetDefaultProperty(this, true); }
|
||||||
public object GetEditor(Type editorBaseType)
|
public object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true);
|
||||||
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
|
public EventDescriptorCollection GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(this, attributes, true);
|
||||||
public EventDescriptorCollection GetEvents(Attribute[] attributes)
|
public EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true);
|
||||||
{ return TypeDescriptor.GetEvents(this, attributes, true); }
|
public object GetPropertyOwner(PropertyDescriptor pd) => this;
|
||||||
public EventDescriptorCollection GetEvents()
|
/// <summary>
|
||||||
{ return TypeDescriptor.GetEvents(this, true); }
|
/// Called to get the properties of this type. Returns properties with certain
|
||||||
public object GetPropertyOwner(PropertyDescriptor pd)
|
/// attributes. this restriction is not implemented here.
|
||||||
{ return this; }
|
/// </summary>
|
||||||
/// <summary>
|
/// <param name="attributes"></param>
|
||||||
/// Called to get the properties of this type. Returns properties with certain
|
/// <returns></returns>
|
||||||
/// attributes. this restriction is not implemented here.
|
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
||||||
/// </summary>
|
/// <summary>
|
||||||
/// <param name="attributes"></param>
|
/// Called to get the properties of this type.
|
||||||
/// <returns></returns>
|
/// </summary>
|
||||||
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
|
/// <returns></returns>
|
||||||
{ return GetProperties(); }
|
public PropertyDescriptorCollection 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
|
||||||
FormatFoldersPropertyDescriptor pd = new FormatFoldersPropertyDescriptor(this, i);
|
FormatFoldersPropertyDescriptor pd = new FormatFoldersPropertyDescriptor(this, i);
|
||||||
@@ -325,7 +288,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class FormatFoldersPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class FormatFoldersPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private FormatFolder Item { get { return (FormatFolder)_Item; } }
|
|
||||||
public FormatFoldersPropertyDescriptor(FormatFolders collection, int index) : base(collection, index) { ;}
|
public FormatFoldersPropertyDescriptor(FormatFolders collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -334,10 +296,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 FormatFolders)
|
if (destType == typeof(string) && value is FormatFolders folders)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((FormatFolders)value).Items.Count.ToString() + " Folders";
|
return $"{folders.Items.Count} Folders";
|
||||||
}
|
}
|
||||||
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 FormatInfo : ReadOnlyBase<FormatInfo>, IDisposable
|
public partial class FormatInfo : ReadOnlyBase<FormatInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public event FormatInfoEvent Changed;
|
public event FormatInfoEvent 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<FormatInfo> _CacheList = new List<FormatInfo>();
|
private static List<FormatInfo> _CacheList = new List<FormatInfo>();
|
||||||
protected static void AddToCache(FormatInfo formatInfo)
|
protected static void AddToCache(FormatInfo formatInfo)
|
||||||
{
|
{
|
||||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(formatInfo)) _CacheList.Remove(formatInfo); // In RemoveFromCache
|
while (_CacheList.Contains(formatInfo)) _CacheList.Remove(formatInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<FormatInfo>> _CacheByPrimaryKey = new Dictionary<string, List<FormatInfo>>();
|
private static Dictionary<string, List<FormatInfo>> _CacheByPrimaryKey = new Dictionary<string, List<FormatInfo>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -81,21 +78,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 Format _Editable;
|
protected Format _Editable;
|
||||||
private IVEHasBrokenRules HasBrokenRules
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
IVEHasBrokenRules hasBrokenRules = null;
|
|
||||||
if (_Editable != null)
|
|
||||||
hasBrokenRules = _Editable.HasBrokenRules;
|
|
||||||
return hasBrokenRules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private int _FormatID;
|
private int _FormatID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int FormatID
|
public int FormatID
|
||||||
@@ -342,32 +326,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
foreach (FormatInfo tmp in _CacheByPrimaryKey[_FormatID.ToString()])
|
foreach (FormatInfo tmp in _CacheByPrimaryKey[_FormatID.ToString()])
|
||||||
tmp._ChildFormatCount = -1; // This will cause the data to be requeried
|
tmp._ChildFormatCount = -1; // This will cause the data to be requeried
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base FormatInfo.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current FormatInfo</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check FormatInfo.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check FormatInfo.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 FormatInfo</returns>
|
/// <returns>A Unique ID for the current FormatInfo</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyFormatInfoUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyFormatInfoUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _FormatInfoUnique = 0;
|
private static int _FormatInfoUnique = 0;
|
||||||
private static int FormatInfoUnique
|
private static int FormatInfoUnique => ++_FormatInfoUnique;
|
||||||
{ get { return ++_FormatInfoUnique; } }
|
private readonly int _MyFormatInfoUnique = FormatInfoUnique;
|
||||||
private int _MyFormatInfoUnique = FormatInfoUnique;
|
// Absolutely Unique ID - Info
|
||||||
public int MyFormatInfoUnique // Absolutely Unique ID - Info
|
public int MyFormatInfoUnique => _MyFormatInfoUnique;
|
||||||
{ get { return _MyFormatInfoUnique; } }
|
|
||||||
protected FormatInfo()
|
protected FormatInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -376,15 +347,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; } }
|
|
||||||
~FormatInfo()
|
~FormatInfo()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -417,11 +384,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_ParentID != tmp.ParentID)
|
if (_ParentID != tmp.ParentID)
|
||||||
{
|
{
|
||||||
if (MyParent != null) MyParent.RefreshChildFormats(); // Update List for old value
|
MyParent?.RefreshChildFormats(); // Update List for old value
|
||||||
_ParentID = tmp.ParentID; // Update the value
|
_ParentID = tmp.ParentID; // Update the value
|
||||||
}
|
}
|
||||||
_MyParent = null; // Reset list so that the next line gets a new list
|
_MyParent = null; // Reset list so that the next line gets a new list
|
||||||
if (MyParent != null) MyParent.RefreshChildFormats(); // Update List for new value
|
MyParent?.RefreshChildFormats(); // Update List for new value
|
||||||
_Name = tmp.Name;
|
_Name = tmp.Name;
|
||||||
_Description = tmp.Description;
|
_Description = tmp.Description;
|
||||||
_Data = tmp.Data;
|
_Data = tmp.Data;
|
||||||
@@ -434,8 +401,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static FormatInfo Get(int formatID)
|
public static FormatInfo Get(int formatID)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a Format");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FormatInfo tmp = GetCachedByPrimaryKey(formatID);
|
FormatInfo tmp = GetCachedByPrimaryKey(formatID);
|
||||||
@@ -474,13 +439,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _FormatID;
|
private readonly int _FormatID;
|
||||||
public int FormatID
|
public int FormatID => _FormatID;
|
||||||
{ get { return _FormatID; } }
|
public PKCriteria(int formatID) => _FormatID = formatID;
|
||||||
public PKCriteria(int formatID)
|
|
||||||
{
|
|
||||||
_FormatID = formatID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public static string _Failed = null;
|
public static string _Failed = null;
|
||||||
public static string Failed
|
public static string Failed
|
||||||
@@ -564,7 +525,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
FormatInfoExtension _FormatInfoExtension = new FormatInfoExtension();
|
readonly FormatInfoExtension _FormatInfoExtension = new FormatInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class FormatInfoExtension : extensionBase { }
|
partial class FormatInfoExtension : extensionBase { }
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
@@ -580,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 FormatInfo)
|
if (destType == typeof(string) && value is FormatInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((FormatInfo)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<FormatInfo> Items
|
internal new IList<FormatInfo> Items => base.Items;
|
||||||
{ get { return base.Items; } }
|
public void AddEvents()
|
||||||
public void AddEvents()
|
|
||||||
{
|
{
|
||||||
foreach (FormatInfo tmp in this)
|
foreach (FormatInfo 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
|
~FormatInfoList()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~FormatInfoList()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -105,18 +98,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_FormatInfoList = null;
|
_FormatInfoList = null;
|
||||||
_SortedFormatInfoList = null;
|
_SortedFormatInfoList = null;
|
||||||
}
|
}
|
||||||
// CSLATODO: Add alternative gets -
|
|
||||||
//public static FormatInfoList Get(<criteria>)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// return DataPortal.Fetch<FormatInfoList>(new FilteredCriteria(<criteria>));
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// throw new DbCslaException("Error on FormatInfoList.Get", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
public static FormatInfoList GetChildren(int parentID)
|
public static FormatInfoList GetChildren(int parentID)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -137,7 +118,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}] FormatInfoList.DataPortal_Fetch", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfoList.DataPortal_Fetch", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -151,7 +132,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 FormatInfo(dr));
|
while (dr.Read()) Add(new FormatInfo(dr));
|
||||||
IsReadOnly = true;
|
IsReadOnly = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,16 +151,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
System.Windows.Forms.MessageBox.Show(sbMsg.ToString(), "Update Stored Procedures", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
|
System.Windows.Forms.MessageBox.Show(sbMsg.ToString(), "Update Stored Procedures", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
|
||||||
throw new DbCslaException("FormatInfoList.DataPortal_Fetch", ex);
|
throw new DbCslaException("FormatInfoList.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ParentIDCriteria
|
private class ParentIDCriteria
|
||||||
{
|
{
|
||||||
public ParentIDCriteria(int parentID)
|
public ParentIDCriteria(int parentID) => _ParentID = parentID;
|
||||||
{
|
private int _ParentID;
|
||||||
_ParentID = parentID;
|
|
||||||
}
|
|
||||||
private int _ParentID;
|
|
||||||
public int ParentID
|
public int ParentID
|
||||||
{
|
{
|
||||||
get { return _ParentID; }
|
get { return _ParentID; }
|
||||||
@@ -188,7 +166,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
private void DataPortal_Fetch(ParentIDCriteria criteria)
|
private void DataPortal_Fetch(ParentIDCriteria criteria)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfoList.DataPortal_FetchParentID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfoList.DataPortal_FetchParentID", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -203,7 +181,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 FormatInfo(dr));
|
while (dr.Read()) Add(new FormatInfo(dr));
|
||||||
IsReadOnly = true;
|
IsReadOnly = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,48 +192,37 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatInfoList.DataPortal_FetchParentID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatInfoList.DataPortal_FetchParentID", ex);
|
||||||
throw new DbCslaException("FormatInfoList.DataPortal_Fetch", ex);
|
throw new DbCslaException("FormatInfoList.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
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
|
||||||
FormatInfoListPropertyDescriptor pd = new FormatInfoListPropertyDescriptor(this, i);
|
FormatInfoListPropertyDescriptor pd = new FormatInfoListPropertyDescriptor(this, i);
|
||||||
@@ -272,7 +239,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class FormatInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class FormatInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private FormatInfo Item { get { return (FormatInfo)_Item; } }
|
|
||||||
public FormatInfoListPropertyDescriptor(FormatInfoList collection, int index) : base(collection, index) { ;}
|
public FormatInfoListPropertyDescriptor(FormatInfoList collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -281,10 +247,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 FormatInfoList)
|
if (destType == typeof(string) && value is FormatInfoList list)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((FormatInfoList)value).Items.Count.ToString() + " Formats";
|
return $"{list.Items.Count} Formats";
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user