CSLA - G
This commit is contained in:
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Csla.Validation;
|
using Csla.Validation;
|
||||||
@@ -37,10 +35,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (IsDirty)
|
if (IsDirty)
|
||||||
refreshGrids.Add(this);
|
refreshGrids.Add(this);
|
||||||
}
|
}
|
||||||
private void ClearRefreshList()
|
private void ClearRefreshList() => _RefreshGrids = new List<Grid>();
|
||||||
{
|
|
||||||
_RefreshGrids = new List<Grid>();
|
|
||||||
}
|
|
||||||
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<Grid> _CacheList = new List<Grid>();
|
private static List<Grid> _CacheList = new List<Grid>();
|
||||||
protected static void AddToCache(Grid grid)
|
protected static void AddToCache(Grid grid)
|
||||||
{
|
{
|
||||||
@@ -65,6 +61,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(grid)) _CacheList.Remove(grid); // In RemoveFromCache
|
while (_CacheList.Contains(grid)) _CacheList.Remove(grid); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<Grid>> _CacheByPrimaryKey = new Dictionary<string, List<Grid>>();
|
private static Dictionary<string, List<Grid>> _CacheByPrimaryKey = new Dictionary<string, List<Grid>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -90,10 +87,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
|
||||||
@@ -192,40 +186,18 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private byte[] _LastChanged = new byte[8];//timestamp
|
private byte[] _LastChanged = new byte[8];//timestamp
|
||||||
public override bool IsDirty
|
public override bool IsDirty => 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;
|
|
||||||
}
|
|
||||||
// CSLATODO: Replace base Grid.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current Grid</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check Grid.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check Grid.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 Grid</returns>
|
/// <returns>A Unique ID for the current Grid</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyGridUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyGridUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
@@ -253,8 +225,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,31 +253,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_GridExtension.AddInstanceValidationRules(ValidationRules);
|
_GridExtension.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(ContentID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Data, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Data, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
|
||||||
_GridExtension.AddAuthorizationRules(AuthorizationRules);
|
_GridExtension.AddAuthorizationRules(AuthorizationRules);
|
||||||
}
|
}
|
||||||
protected override void AddInstanceAuthorizationRules()
|
protected override void AddInstanceAuthorizationRules()
|
||||||
@@ -313,42 +265,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//CSLATODO: Who can read/write which fields
|
//CSLATODO: Who can read/write which fields
|
||||||
_GridExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
_GridExtension.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 _GridUnique = 0;
|
private static int _GridUnique = 0;
|
||||||
protected static int GridUnique
|
protected static int GridUnique => ++_GridUnique;
|
||||||
{ get { return ++_GridUnique; } }
|
private readonly int _MyGridUnique = GridUnique;
|
||||||
private int _MyGridUnique = GridUnique;
|
// Absolutely Unique ID - Editable
|
||||||
public int MyGridUnique // Absolutely Unique ID - Editable
|
public int MyGridUnique => _MyGridUnique;
|
||||||
{ get { return _MyGridUnique; } }
|
|
||||||
protected Grid()
|
protected Grid()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -357,15 +281,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static int _CountCreated = 0;
|
private static int _CountCreated = 0;
|
||||||
private static int _CountDisposed = 0;
|
private static int _CountDisposed = 0;
|
||||||
private static int _CountFinalized = 0;
|
private static int _CountFinalized = 0;
|
||||||
private static int IncrementCountCreated
|
private static int IncrementCountCreated => ++_CountCreated;
|
||||||
{ get { return ++_CountCreated; } }
|
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||||
private int _CountWhenCreated = IncrementCountCreated;
|
public static int CountCreated => _CountCreated;
|
||||||
public static int CountCreated
|
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||||
{ get { return _CountCreated; } }
|
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||||
public static int CountNotDisposed
|
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~Grid()
|
~Grid()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -390,8 +310,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Grid New()
|
public static Grid New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Grid");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<Grid>();
|
return DataPortal.Create<Grid>();
|
||||||
@@ -468,8 +386,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Grid Get(int contentID)
|
public static Grid Get(int contentID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a Grid");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Grid tmp = GetCachedByPrimaryKey(contentID);
|
Grid tmp = GetCachedByPrimaryKey(contentID);
|
||||||
@@ -495,14 +411,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dr.Read()) return new Grid(dr);
|
if (dr.Read()) return new Grid(dr);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
internal Grid(SafeDataReader dr)
|
internal Grid(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 Grid");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataPortal.Delete(new PKCriteria(contentID));
|
DataPortal.Delete(new PKCriteria(contentID));
|
||||||
@@ -514,12 +425,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public override Grid Save()
|
public override Grid Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Grid");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Grid");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a Grid");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -539,13 +444,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()]
|
||||||
@@ -642,30 +543,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 = "addGrid";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@ContentID", ContentID);
|
cm.CommandText = "addGrid";
|
||||||
cm.Parameters.AddWithValue("@Data", _Data);
|
// Input All Fields - Except Calculated Columns
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@ContentID", ContentID);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@Data", _Data);
|
||||||
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_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}] Grid.SQLInsert", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Grid.SQLInsert", GetHashCode());
|
||||||
@@ -695,8 +601,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();
|
||||||
@@ -740,31 +648,36 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Grid.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Grid.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 = "updateGrid";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@ContentID", ContentID);
|
cm.CommandText = "updateGrid";
|
||||||
cm.Parameters.AddWithValue("@Data", _Data);
|
// All Fields including Calculated Fields
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@ContentID", ContentID);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@Data", _Data);
|
||||||
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
|
||||||
}
|
}
|
||||||
@@ -777,14 +690,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 = Grid.Add(cn, content, _Data, _Config, _DTS, _UserID);
|
if (IsNew)
|
||||||
else
|
_LastChanged = Grid.Add(cn, content, _Data, _Config, _DTS, _UserID);
|
||||||
_LastChanged = Grid.Update(cn, content.ContentID, _Data, _Config, _DTS, _UserID, ref _LastChanged);
|
else
|
||||||
|
_LastChanged = Grid.Update(cn, content.ContentID, _Data, _Config, _DTS, _UserID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -807,8 +723,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();
|
||||||
@@ -893,16 +811,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}] Grid.DataPortal_Execute", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Grid.DataPortal_Execute", GetHashCode());
|
||||||
@@ -932,7 +844,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
GridExtension _GridExtension = new GridExtension();
|
readonly GridExtension _GridExtension = new GridExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class GridExtension : extensionBase
|
partial class GridExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -941,14 +853,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)
|
||||||
{
|
{
|
||||||
@@ -977,57 +883,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 Grid)
|
if (destType == typeof(string) && value is Grid mygrid)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((Grid)value).ToString();
|
return mygrid.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 GridExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class Grid
|
|
||||||
// {
|
|
||||||
// partial class GridExtension : 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;
|
||||||
@@ -56,6 +54,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<GridAudit> _CacheList = new List<GridAudit>();
|
private static List<GridAudit> _CacheList = new List<GridAudit>();
|
||||||
protected static void AddToCache(GridAudit gridAudit)
|
protected static void AddToCache(GridAudit gridAudit)
|
||||||
{
|
{
|
||||||
@@ -65,6 +64,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(gridAudit)) _CacheList.Remove(gridAudit); // In RemoveFromCache
|
while (_CacheList.Contains(gridAudit)) _CacheList.Remove(gridAudit); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<GridAudit>> _CacheByPrimaryKey = new Dictionary<string, List<GridAudit>>();
|
private static Dictionary<string, List<GridAudit>> _CacheByPrimaryKey = new Dictionary<string, List<GridAudit>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -90,15 +90,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
|
||||||
@@ -238,40 +232,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 GridAudit.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current GridAudit</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check GridAudit.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check GridAudit.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 GridAudit</returns>
|
/// <returns>A Unique ID for the current GridAudit</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyGridAuditUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyGridAuditUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
@@ -299,8 +267,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()
|
||||||
@@ -327,37 +295,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_GridAuditExtension.AddInstanceValidationRules(ValidationRules);
|
_GridAuditExtension.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(Data, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DeleteStatus, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(ContentAuditID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ContentID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Data, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DeleteStatus, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(ContentAuditID, "<Role(s)>");
|
|
||||||
_GridAuditExtension.AddAuthorizationRules(AuthorizationRules);
|
_GridAuditExtension.AddAuthorizationRules(AuthorizationRules);
|
||||||
}
|
}
|
||||||
protected override void AddInstanceAuthorizationRules()
|
protected override void AddInstanceAuthorizationRules()
|
||||||
@@ -365,42 +307,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//CSLATODO: Who can read/write which fields
|
//CSLATODO: Who can read/write which fields
|
||||||
_GridAuditExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
_GridAuditExtension.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 _GridAuditUnique = 0;
|
private static int _GridAuditUnique = 0;
|
||||||
protected static int GridAuditUnique
|
protected static int GridAuditUnique => ++_GridAuditUnique;
|
||||||
{ get { return ++_GridAuditUnique; } }
|
private readonly int _MyGridAuditUnique = GridAuditUnique;
|
||||||
private int _MyGridAuditUnique = GridAuditUnique;
|
// Absolutely Unique ID - Editable
|
||||||
public int MyGridAuditUnique // Absolutely Unique ID - Editable
|
public int MyGridAuditUnique => _MyGridAuditUnique;
|
||||||
{ get { return _MyGridAuditUnique; } }
|
|
||||||
protected GridAudit()
|
protected GridAudit()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -409,15 +323,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; } }
|
|
||||||
~GridAudit()
|
~GridAudit()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -442,8 +352,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static GridAudit New()
|
public static GridAudit New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a GridAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<GridAudit>();
|
return DataPortal.Create<GridAudit>();
|
||||||
@@ -520,8 +428,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static GridAudit Get(long auditID)
|
public static GridAudit Get(long auditID)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a GridAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GridAudit tmp = GetCachedByPrimaryKey(auditID);
|
GridAudit tmp = GetCachedByPrimaryKey(auditID);
|
||||||
@@ -547,14 +453,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dr.Read()) return new GridAudit(dr);
|
if (dr.Read()) return new GridAudit(dr);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
internal GridAudit(SafeDataReader dr)
|
internal GridAudit(SafeDataReader dr) => ReadData(dr);
|
||||||
{
|
|
||||||
ReadData(dr);
|
|
||||||
}
|
|
||||||
public static void Delete(long auditID)
|
public static void Delete(long auditID)
|
||||||
{
|
{
|
||||||
if (!CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a GridAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataPortal.Delete(new PKCriteria(auditID));
|
DataPortal.Delete(new PKCriteria(auditID));
|
||||||
@@ -566,12 +467,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public override GridAudit Save()
|
public override GridAudit Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a GridAudit");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a GridAudit");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a GridAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -591,13 +486,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()]
|
||||||
@@ -695,32 +586,37 @@ 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 = "addGridAudit";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@ContentID", _ContentID);
|
cm.CommandText = "addGridAudit";
|
||||||
cm.Parameters.AddWithValue("@Data", _Data);
|
// Input All Fields - Except Calculated Columns
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@ContentID", _ContentID);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@Data", _Data);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
cm.Parameters.AddWithValue("@ContentAuditID", _ContentAuditID);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
|
||||||
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt);
|
cm.Parameters.AddWithValue("@ContentAuditID", _ContentAuditID);
|
||||||
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}] GridAudit.SQLInsert", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAudit.SQLInsert", GetHashCode());
|
||||||
@@ -752,8 +648,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
cm.Parameters.AddWithValue("@DeleteStatus", deleteStatus);
|
cm.Parameters.AddWithValue("@DeleteStatus", deleteStatus);
|
||||||
cm.Parameters.AddWithValue("@ContentAuditID", contentAuditID);
|
cm.Parameters.AddWithValue("@ContentAuditID", contentAuditID);
|
||||||
// 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();
|
||||||
@@ -798,29 +696,32 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAudit.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAudit.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 = "updateGridAudit";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@AuditID", _AuditID);
|
cm.CommandText = "updateGridAudit";
|
||||||
cm.Parameters.AddWithValue("@ContentID", _ContentID);
|
// All Fields including Calculated Fields
|
||||||
cm.Parameters.AddWithValue("@Data", _Data);
|
cm.Parameters.AddWithValue("@AuditID", _AuditID);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@ContentID", _ContentID);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@Data", _Data);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
cm.Parameters.AddWithValue("@ContentAuditID", _ContentAuditID);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
// Output Calculated Columns
|
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
|
||||||
// CSLATODO: Define any additional output parameters
|
cm.Parameters.AddWithValue("@ContentAuditID", _ContentAuditID);
|
||||||
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
|
||||||
}
|
}
|
||||||
@@ -833,14 +734,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)
|
{
|
||||||
GridAudit.Add(cn, ref _AuditID, _ContentID, _Data, _Config, _DTS, _UserID, _DeleteStatus, _ContentAuditID);
|
if (IsNew)
|
||||||
else
|
GridAudit.Add(cn, ref _AuditID, _ContentID, _Data, _Config, _DTS, _UserID, _DeleteStatus, _ContentAuditID);
|
||||||
GridAudit.Update(cn, ref _AuditID, _ContentID, _Data, _Config, _DTS, _UserID, _DeleteStatus, _ContentAuditID);
|
else
|
||||||
|
GridAudit.Update(cn, ref _AuditID, _ContentID, _Data, _Config, _DTS, _UserID, _DeleteStatus, _ContentAuditID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -948,16 +852,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ExistsCommand : CommandBase
|
private class ExistsCommand : CommandBase
|
||||||
{
|
{
|
||||||
private long _AuditID;
|
private readonly long _AuditID;
|
||||||
private bool _exists;
|
private bool _exists;
|
||||||
public bool Exists
|
public bool Exists => _exists;
|
||||||
{
|
public ExistsCommand(long auditID) => _AuditID = auditID;
|
||||||
get { return _exists; }
|
|
||||||
}
|
|
||||||
public ExistsCommand(long auditID)
|
|
||||||
{
|
|
||||||
_AuditID = auditID;
|
|
||||||
}
|
|
||||||
protected override void DataPortal_Execute()
|
protected override void DataPortal_Execute()
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAudit.DataPortal_Execute", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAudit.DataPortal_Execute", GetHashCode());
|
||||||
@@ -987,7 +885,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
GridAuditExtension _GridAuditExtension = new GridAuditExtension();
|
readonly GridAuditExtension _GridAuditExtension = new GridAuditExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class GridAuditExtension : extensionBase
|
partial class GridAuditExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -996,10 +894,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
class extensionBase
|
class extensionBase
|
||||||
{
|
{
|
||||||
// Default Values
|
// Default Values
|
||||||
public virtual long DefaultContentAuditID
|
public virtual long DefaultContentAuditID => 0;
|
||||||
{
|
|
||||||
get { return 0; }
|
|
||||||
}
|
|
||||||
// Authorization Rules
|
// Authorization Rules
|
||||||
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
||||||
{
|
{
|
||||||
@@ -1028,53 +923,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 GridAudit)
|
if (destType == typeof(string) && value is GridAudit audit)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((GridAudit)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 GridAuditExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class GridAudit
|
|
||||||
// {
|
|
||||||
// partial class GridAuditExtension : extensionBase
|
|
||||||
// {
|
|
||||||
// // CSLATODO: Override automatic defaults
|
|
||||||
// public virtual long DefaultContentAuditID
|
|
||||||
// {
|
|
||||||
// get { return 0; }
|
|
||||||
// }
|
|
||||||
// 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 GridAuditInfo : ReadOnlyBase<GridAuditInfo>, IDisposable
|
public partial class GridAuditInfo : ReadOnlyBase<GridAuditInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public event GridAuditInfoEvent Changed;
|
public event GridAuditInfoEvent 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<GridAuditInfo> _CacheList = new List<GridAuditInfo>();
|
private static List<GridAuditInfo> _CacheList = new List<GridAuditInfo>();
|
||||||
protected static void AddToCache(GridAuditInfo gridAuditInfo)
|
protected static void AddToCache(GridAuditInfo gridAuditInfo)
|
||||||
{
|
{
|
||||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(gridAuditInfo)) _CacheList.Remove(gridAuditInfo); // In RemoveFromCache
|
while (_CacheList.Contains(gridAuditInfo)) _CacheList.Remove(gridAuditInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<GridAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<GridAuditInfo>>();
|
private static Dictionary<string, List<GridAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<GridAuditInfo>>();
|
||||||
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 GridAudit _Editable;
|
protected GridAudit _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
|
||||||
@@ -162,32 +146,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _ContentAuditID;
|
return _ContentAuditID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base GridAuditInfo.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current GridAuditInfo</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check GridAuditInfo.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check GridAuditInfo.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 GridAuditInfo</returns>
|
/// <returns>A Unique ID for the current GridAuditInfo</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyGridAuditInfoUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyGridAuditInfoUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _GridAuditInfoUnique = 0;
|
private static int _GridAuditInfoUnique = 0;
|
||||||
private static int GridAuditInfoUnique
|
private static int GridAuditInfoUnique => ++_GridAuditInfoUnique;
|
||||||
{ get { return ++_GridAuditInfoUnique; } }
|
private readonly int _MyGridAuditInfoUnique = GridAuditInfoUnique;
|
||||||
private int _MyGridAuditInfoUnique = GridAuditInfoUnique;
|
// Absolutely Unique ID - Info
|
||||||
public int MyGridAuditInfoUnique // Absolutely Unique ID - Info
|
public int MyGridAuditInfoUnique => _MyGridAuditInfoUnique;
|
||||||
{ get { return _MyGridAuditInfoUnique; } }
|
|
||||||
protected GridAuditInfo()
|
protected GridAuditInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -196,15 +167,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; } }
|
|
||||||
~GridAuditInfo()
|
~GridAuditInfo()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -221,10 +188,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (listGridAuditInfo.Count == 0) // If there are no items left in the list
|
if (listGridAuditInfo.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 GridAudit Get()
|
public virtual GridAudit Get() => _Editable = GridAudit.Get(_AuditID);
|
||||||
{
|
|
||||||
return _Editable = GridAudit.Get(_AuditID);
|
|
||||||
}
|
|
||||||
public static void Refresh(GridAudit tmp)
|
public static void Refresh(GridAudit tmp)
|
||||||
{
|
{
|
||||||
string key = tmp.AuditID.ToString();
|
string key = tmp.AuditID.ToString();
|
||||||
@@ -247,8 +211,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static GridAuditInfo Get(long auditID)
|
public static GridAuditInfo Get(long auditID)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a GridAudit");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GridAuditInfo tmp = GetCachedByPrimaryKey(auditID);
|
GridAuditInfo tmp = GetCachedByPrimaryKey(auditID);
|
||||||
@@ -287,13 +249,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)
|
||||||
{
|
{
|
||||||
@@ -355,7 +313,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
GridAuditInfoExtension _GridAuditInfoExtension = new GridAuditInfoExtension();
|
readonly GridAuditInfoExtension _GridAuditInfoExtension = new GridAuditInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class GridAuditInfoExtension : extensionBase { }
|
partial class GridAuditInfoExtension : 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 GridAuditInfo)
|
if (destType == typeof(string) && value is GridAuditInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((GridAuditInfo)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<GridAuditInfo> Items
|
internal new IList<GridAuditInfo> Items => base.Items;
|
||||||
{ get { return base.Items; } }
|
public void AddEvents()
|
||||||
public void AddEvents()
|
|
||||||
{
|
{
|
||||||
foreach (GridAuditInfo tmp in this)
|
foreach (GridAuditInfo 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
|
~GridAuditInfoList()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~GridAuditInfoList()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -97,32 +90,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on GridAuditInfoList.Get", ex);
|
throw new DbCslaException("Error on GridAuditInfoList.Get", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset the list of all GridAuditInfo.
|
/// Reset the list of all GridAuditInfo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Reset()
|
public static void Reset() => _GridAuditInfoList = null;
|
||||||
{
|
private GridAuditInfoList()
|
||||||
_GridAuditInfoList = null;
|
|
||||||
}
|
|
||||||
// CSLATODO: Add alternative gets -
|
|
||||||
//public static GridAuditInfoList Get(<criteria>)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// return DataPortal.Fetch<GridAuditInfoList>(new FilteredCriteria(<criteria>));
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// throw new DbCslaException("Error on GridAuditInfoList.Get", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
private GridAuditInfoList()
|
|
||||||
{ /* require use of factory methods */ }
|
{ /* require use of factory methods */ }
|
||||||
#endregion
|
#endregion
|
||||||
#region Data Access Portal
|
#region Data Access Portal
|
||||||
private void DataPortal_Fetch()
|
private void DataPortal_Fetch()
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAuditInfoList.DataPortal_Fetch", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAuditInfoList.DataPortal_Fetch", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -136,7 +114,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||||
{
|
{
|
||||||
IsReadOnly = false;
|
IsReadOnly = false;
|
||||||
while (dr.Read()) this.Add(new GridAuditInfo(dr));
|
while (dr.Read()) Add(new GridAuditInfo(dr));
|
||||||
IsReadOnly = true;
|
IsReadOnly = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,48 +125,38 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("GridAuditInfoList.DataPortal_Fetch", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("GridAuditInfoList.DataPortal_Fetch", ex);
|
||||||
throw new DbCslaException("GridAuditInfoList.DataPortal_Fetch", ex);
|
throw new DbCslaException("GridAuditInfoList.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()
|
||||||
{ return TypeDescriptor.GetAttributes(this, true); }
|
|
||||||
public String GetComponentName()
|
|
||||||
{ return TypeDescriptor.GetComponentName(this, true); }
|
{ return TypeDescriptor.GetComponentName(this, true); }
|
||||||
public TypeConverter GetConverter()
|
public TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true);
|
||||||
{ return TypeDescriptor.GetConverter(this, true); }
|
public EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
|
||||||
public EventDescriptor GetDefaultEvent()
|
public PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true);
|
||||||
{ return TypeDescriptor.GetDefaultEvent(this, true); }
|
public object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true);
|
||||||
public PropertyDescriptor GetDefaultProperty()
|
public EventDescriptorCollection GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(this, attributes, true);
|
||||||
{ return TypeDescriptor.GetDefaultProperty(this, true); }
|
public EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true);
|
||||||
public object GetEditor(Type editorBaseType)
|
public object GetPropertyOwner(PropertyDescriptor pd) => this;
|
||||||
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
|
/// <summary>
|
||||||
public EventDescriptorCollection GetEvents(Attribute[] attributes)
|
/// Called to get the properties of this type. Returns properties with certain
|
||||||
{ return TypeDescriptor.GetEvents(this, attributes, true); }
|
/// attributes. this restriction is not implemented here.
|
||||||
public EventDescriptorCollection GetEvents()
|
/// </summary>
|
||||||
{ return TypeDescriptor.GetEvents(this, true); }
|
/// <param name="attributes"></param>
|
||||||
public object GetPropertyOwner(PropertyDescriptor pd)
|
/// <returns></returns>
|
||||||
{ return this; }
|
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called to get the properties of this type. Returns properties with certain
|
/// Called to get the properties of this type.
|
||||||
/// attributes. this restriction is not implemented here.
|
/// </summary>
|
||||||
/// </summary>
|
/// <returns></returns>
|
||||||
/// <param name="attributes"></param>
|
public PropertyDescriptorCollection GetProperties()
|
||||||
/// <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
|
||||||
GridAuditInfoListPropertyDescriptor pd = new GridAuditInfoListPropertyDescriptor(this, i);
|
GridAuditInfoListPropertyDescriptor pd = new GridAuditInfoListPropertyDescriptor(this, i);
|
||||||
@@ -205,7 +173,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class GridAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class GridAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private GridAuditInfo Item { get { return (GridAuditInfo)_Item; } }
|
|
||||||
public GridAuditInfoListPropertyDescriptor(GridAuditInfoList collection, int index) : base(collection, index) { ;}
|
public GridAuditInfoListPropertyDescriptor(GridAuditInfoList collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -214,10 +181,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 GridAuditInfoList)
|
if (destType == typeof(string) && value is GridAuditInfoList list)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((GridAuditInfoList)value).Items.Count.ToString() + " GridAudits";
|
return $"{list.Items.Count} GridAudits";
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -30,14 +28,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public partial class GridInfo : ReadOnlyBase<GridInfo>, IDisposable
|
public partial class GridInfo : ReadOnlyBase<GridInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public event GridInfoEvent Changed;
|
public event GridInfoEvent 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<GridInfo> _CacheList = new List<GridInfo>();
|
private static List<GridInfo> _CacheList = new List<GridInfo>();
|
||||||
protected static void AddToCache(GridInfo gridInfo)
|
protected static void AddToCache(GridInfo gridInfo)
|
||||||
{
|
{
|
||||||
@@ -47,6 +43,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(gridInfo)) _CacheList.Remove(gridInfo); // In RemoveFromCache
|
while (_CacheList.Contains(gridInfo)) _CacheList.Remove(gridInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<GridInfo>> _CacheByPrimaryKey = new Dictionary<string, List<GridInfo>>();
|
private static Dictionary<string, List<GridInfo>> _CacheByPrimaryKey = new Dictionary<string, List<GridInfo>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -92,21 +89,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 Grid _Editable;
|
protected Grid _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
|
||||||
@@ -165,32 +149,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _UserID;
|
return _UserID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base GridInfo.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current GridInfo</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check GridInfo.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check GridInfo.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 GridInfo</returns>
|
/// <returns>A Unique ID for the current GridInfo</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyGridInfoUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyGridInfoUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _GridInfoUnique = 0;
|
private static int _GridInfoUnique = 0;
|
||||||
private static int GridInfoUnique
|
private static int GridInfoUnique => ++_GridInfoUnique;
|
||||||
{ get { return ++_GridInfoUnique; } }
|
private readonly int _MyGridInfoUnique = GridInfoUnique;
|
||||||
private int _MyGridInfoUnique = GridInfoUnique;
|
// Absolutely Unique ID - Info
|
||||||
public int MyGridInfoUnique // Absolutely Unique ID - Info
|
public int MyGridInfoUnique => _MyGridInfoUnique;
|
||||||
{ get { return _MyGridInfoUnique; } }
|
|
||||||
protected GridInfo()
|
protected GridInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -199,15 +170,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; } }
|
|
||||||
~GridInfo()
|
~GridInfo()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -224,10 +191,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (listGridInfo.Count == 0) // If there are no items left in the list
|
if (listGridInfo.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 Grid Get()
|
public virtual Grid Get() => _Editable = Grid.Get(_ContentID);
|
||||||
{
|
|
||||||
return _Editable = Grid.Get(_ContentID);
|
|
||||||
}
|
|
||||||
public static void Refresh(Grid tmp)
|
public static void Refresh(Grid tmp)
|
||||||
{
|
{
|
||||||
string key = tmp.ContentID.ToString();
|
string key = tmp.ContentID.ToString();
|
||||||
@@ -247,8 +211,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static GridInfo Get(int contentID)
|
public static GridInfo Get(int contentID)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a Grid");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GridInfo tmp = GetCachedByPrimaryKey(contentID);
|
GridInfo tmp = GetCachedByPrimaryKey(contentID);
|
||||||
@@ -287,13 +249,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)
|
||||||
{
|
{
|
||||||
@@ -352,7 +310,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
GridInfoExtension _GridInfoExtension = new GridInfoExtension();
|
readonly GridInfoExtension _GridInfoExtension = new GridInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class GridInfoExtension : extensionBase { }
|
partial class GridInfoExtension : extensionBase { }
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
@@ -368,10 +326,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 GridInfo)
|
if (destType == typeof(string) && value is GridInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((GridInfo)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;
|
||||||
using Csla.Validation;
|
using Csla.Validation;
|
||||||
@@ -82,6 +80,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<Group> _CacheList = new List<Group>();
|
private static List<Group> _CacheList = new List<Group>();
|
||||||
protected static void AddToCache(Group group)
|
protected static void AddToCache(Group group)
|
||||||
{
|
{
|
||||||
@@ -91,7 +90,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(group)) _CacheList.Remove(group); // In RemoveFromCache
|
while (_CacheList.Contains(group)) _CacheList.Remove(group); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<Group>> _CacheByPrimaryKey = new Dictionary<string, List<Group>>();
|
private static Dictionary<string, List<Group>> _CacheByPrimaryKey = new Dictionary<string, List<Group>>();
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<Group>> _CacheByGroupName = new Dictionary<string, List<Group>>();
|
private static Dictionary<string, List<Group>> _CacheByGroupName = new Dictionary<string, List<Group>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -126,15 +127,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 _nextGID = -1;
|
private static int _nextGID = -1;
|
||||||
public static int NextGID
|
public static int NextGID => _nextGID--;
|
||||||
{
|
|
||||||
get { return _nextGID--; }
|
|
||||||
}
|
|
||||||
private int _GID;
|
private int _GID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int GID
|
public int GID
|
||||||
@@ -270,10 +265,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _GroupAssignments;
|
return _GroupAssignments;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Reset_GroupAssignments()
|
public void Reset_GroupAssignments() => _GroupAssignmentCount = -1;
|
||||||
{
|
|
||||||
_GroupAssignmentCount = -1;
|
|
||||||
}
|
|
||||||
private int _GroupMembershipCount = 0;
|
private int _GroupMembershipCount = 0;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Count of GroupMemberships for this Group
|
/// Count of GroupMemberships for this Group
|
||||||
@@ -305,10 +297,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _GroupMemberships;
|
return _GroupMemberships;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Reset_GroupMemberships()
|
public void Reset_GroupMemberships() => _GroupMembershipCount = -1;
|
||||||
{
|
|
||||||
_GroupMembershipCount = -1;
|
|
||||||
}
|
|
||||||
public override bool IsDirty
|
public override bool IsDirty
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -323,37 +312,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 || (_GroupAssignments == null ? false : _GroupAssignments.IsDirtyList(list)) || (_GroupMemberships == null ? false : _GroupMemberships.IsDirtyList(list));
|
return base.IsDirty || (_GroupAssignments != null && _GroupAssignments.IsDirtyList(list)) || (_GroupMemberships != null && _GroupMemberships.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) && (_GroupAssignments == null ? true : _GroupAssignments.IsValidList(list)) && (_GroupMemberships == null ? true : _GroupMemberships.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_GroupAssignments == null || _GroupAssignments.IsValidList(list)) && (_GroupMemberships == null || _GroupMemberships.IsValidList(list));
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base Group.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current Group</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check Group.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check Group.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 Group</returns>
|
/// <returns>A Unique ID for the current Group</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyGroupUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyGroupUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
@@ -383,8 +357,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()
|
||||||
@@ -411,33 +385,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_GroupExtension.AddInstanceValidationRules(ValidationRules);
|
_GroupExtension.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(GID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(GroupName, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(GroupType, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(GroupName, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(GroupType, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
|
|
||||||
_GroupExtension.AddAuthorizationRules(AuthorizationRules);
|
_GroupExtension.AddAuthorizationRules(AuthorizationRules);
|
||||||
}
|
}
|
||||||
protected override void AddInstanceAuthorizationRules()
|
protected override void AddInstanceAuthorizationRules()
|
||||||
@@ -445,56 +397,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//CSLATODO: Who can read/write which fields
|
//CSLATODO: Who can read/write which fields
|
||||||
_GroupExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
_GroupExtension.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 += _GroupAssignmentCount;
|
|
||||||
usedByCount += _GroupMembershipCount;
|
|
||||||
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 _GroupUnique = 0;
|
private static int _GroupUnique = 0;
|
||||||
protected static int GroupUnique
|
protected static int GroupUnique => ++_GroupUnique;
|
||||||
{ get { return ++_GroupUnique; } }
|
private readonly int _MyGroupUnique = GroupUnique;
|
||||||
private int _MyGroupUnique = GroupUnique;
|
// Absolutely Unique ID - Editable
|
||||||
public int MyGroupUnique // Absolutely Unique ID - Editable
|
public int MyGroupUnique => _MyGroupUnique;
|
||||||
{ get { return _MyGroupUnique; } }
|
|
||||||
protected Group()
|
protected Group()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -503,15 +413,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; } }
|
|
||||||
~Group()
|
~Group()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -548,8 +454,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Group New()
|
public static Group New()
|
||||||
{
|
{
|
||||||
if (!CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Group");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return DataPortal.Create<Group>();
|
return DataPortal.Create<Group>();
|
||||||
@@ -617,8 +521,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Group Get(int gid)
|
public static Group Get(int gid)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a Group");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Group tmp = GetCachedByPrimaryKey(gid);
|
Group tmp = GetCachedByPrimaryKey(gid);
|
||||||
@@ -641,8 +543,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static Group GetByGroupName(string groupName)
|
public static Group GetByGroupName(string groupName)
|
||||||
{
|
{
|
||||||
if (!CanGetObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to view a Group");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Group tmp = GetCachedByGroupName(groupName);
|
Group tmp = GetCachedByGroupName(groupName);
|
||||||
@@ -668,14 +568,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dr.Read()) return new Group(dr);
|
if (dr.Read()) return new Group(dr);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
internal Group(SafeDataReader dr)
|
internal Group(SafeDataReader dr) => ReadData(dr);
|
||||||
{
|
|
||||||
ReadData(dr);
|
|
||||||
}
|
|
||||||
public static void Delete(int gid)
|
public static void Delete(int gid)
|
||||||
{
|
{
|
||||||
if (!CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Group");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataPortal.Delete(new PKCriteria(gid));
|
DataPortal.Delete(new PKCriteria(gid));
|
||||||
@@ -687,12 +582,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public override Group Save()
|
public override Group Save()
|
||||||
{
|
{
|
||||||
if (IsDeleted && !CanDeleteObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Group");
|
|
||||||
else if (IsNew && !CanAddObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to add a Group");
|
|
||||||
else if (!CanEditObject())
|
|
||||||
throw new System.Security.SecurityException("User not authorized to update a Group");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildRefreshList();
|
BuildRefreshList();
|
||||||
@@ -712,24 +601,16 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _GID;
|
private readonly int _GID;
|
||||||
public int GID
|
public int GID => _GID;
|
||||||
{ get { return _GID; } }
|
public PKCriteria(int gid) => _GID = gid;
|
||||||
public PKCriteria(int gid)
|
|
||||||
{
|
|
||||||
_GID = gid;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class GroupNameCriteria
|
private class GroupNameCriteria
|
||||||
{
|
{
|
||||||
private string _GroupName;
|
private readonly string _GroupName;
|
||||||
public string GroupName
|
public string GroupName => _GroupName;
|
||||||
{ get { return _GroupName; } }
|
public GroupNameCriteria(string groupName) => _GroupName = groupName;
|
||||||
public GroupNameCriteria(string groupName)
|
|
||||||
{
|
|
||||||
_GroupName = groupName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 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()]
|
||||||
@@ -871,38 +752,45 @@ 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 = "addGroup";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// Input All Fields - Except Calculated Columns
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@GroupName", _GroupName);
|
cm.CommandText = "addGroup";
|
||||||
cm.Parameters.AddWithValue("@GroupType", _GroupType);
|
// Input All Fields - Except Calculated Columns
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@GroupName", _GroupName);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@GroupType", _GroupType);
|
||||||
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_GID = new SqlParameter("@newGID", SqlDbType.Int);
|
cm.Parameters.AddWithValue("@UsrID", _UsrID);
|
||||||
param_GID.Direction = ParameterDirection.Output;
|
// Output Calculated Columns
|
||||||
cm.Parameters.Add(param_GID);
|
SqlParameter param_GID = new SqlParameter("@newGID", 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_GID);
|
||||||
cm.ExecuteNonQuery();
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||||
// Save all values being returned from the Procedure
|
{
|
||||||
_GID = (int)cm.Parameters["@newGID"].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
|
||||||
|
_GID = (int)cm.Parameters["@newGID"].Value;
|
||||||
|
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
// update child objects
|
// update child objects
|
||||||
if (_GroupAssignments != null) _GroupAssignments.Update(this);
|
_GroupAssignments?.Update(this);
|
||||||
if (_GroupMemberships != null) _GroupMemberships.Update(this);
|
_GroupMemberships?.Update(this);
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.SQLInsert", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.SQLInsert", GetHashCode());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -930,11 +818,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_GID = new SqlParameter("@newGID", SqlDbType.Int);
|
SqlParameter param_GID = new SqlParameter("@newGID", SqlDbType.Int)
|
||||||
param_GID.Direction = ParameterDirection.Output;
|
{
|
||||||
|
Direction = ParameterDirection.Output
|
||||||
|
};
|
||||||
cm.Parameters.Add(param_GID);
|
cm.Parameters.Add(param_GID);
|
||||||
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();
|
||||||
@@ -979,36 +871,41 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.SQLUpdate", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.SQLUpdate", GetHashCode());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
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 = "updateGroup";
|
cm.CommandType = CommandType.StoredProcedure;
|
||||||
// All Fields including Calculated Fields
|
cm.CommandTimeout = Database.SQLTimeout;
|
||||||
cm.Parameters.AddWithValue("@GID", _GID);
|
cm.CommandText = "updateGroup";
|
||||||
cm.Parameters.AddWithValue("@GroupName", _GroupName);
|
// All Fields including Calculated Fields
|
||||||
cm.Parameters.AddWithValue("@GroupType", _GroupType);
|
cm.Parameters.AddWithValue("@GID", _GID);
|
||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@GroupName", _GroupName);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
cm.Parameters.AddWithValue("@GroupType", _GroupType);
|
||||||
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 (_GroupAssignments != null) _GroupAssignments.Update(this);
|
_GroupAssignments?.Update(this);
|
||||||
if (_GroupMemberships != null) _GroupMemberships.Update(this);
|
_GroupMemberships?.Update(this);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -1019,18 +916,21 @@ 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 = Group.Add(cn, ref _GID, _GroupName, _GroupType, _Config, _DTS, _UsrID);
|
if (IsNew)
|
||||||
else
|
_LastChanged = Group.Add(cn, ref _GID, _GroupName, _GroupType, _Config, _DTS, _UsrID);
|
||||||
_LastChanged = Group.Update(cn, ref _GID, _GroupName, _GroupType, _Config, _DTS, _UsrID, ref _LastChanged);
|
else
|
||||||
|
_LastChanged = Group.Update(cn, ref _GID, _GroupName, _GroupType, _Config, _DTS, _UsrID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
if (_GroupAssignments != null) _GroupAssignments.Update(this);
|
_GroupAssignments?.Update(this);
|
||||||
if (_GroupMemberships != null) _GroupMemberships.Update(this);
|
_GroupMemberships?.Update(this);
|
||||||
}
|
}
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
public static byte[] Update(SqlConnection cn, ref int gid, string groupName, int? groupType, string config, DateTime dts, string usrID, ref byte[] lastChanged)
|
public static byte[] Update(SqlConnection cn, ref int gid, string groupName, int? groupType, string config, DateTime dts, string usrID, ref byte[] lastChanged)
|
||||||
@@ -1052,8 +952,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();
|
||||||
@@ -1138,16 +1040,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class ExistsCommand : CommandBase
|
private class ExistsCommand : CommandBase
|
||||||
{
|
{
|
||||||
private int _GID;
|
private readonly int _GID;
|
||||||
private bool _exists;
|
private bool _exists;
|
||||||
public bool Exists
|
public bool Exists => _exists;
|
||||||
{
|
public ExistsCommand(int gid) => _GID = gid;
|
||||||
get { return _exists; }
|
|
||||||
}
|
|
||||||
public ExistsCommand(int gid)
|
|
||||||
{
|
|
||||||
_GID = gid;
|
|
||||||
}
|
|
||||||
protected override void DataPortal_Execute()
|
protected override void DataPortal_Execute()
|
||||||
{
|
{
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.DataPortal_Execute", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Group.DataPortal_Execute", GetHashCode());
|
||||||
@@ -1177,7 +1073,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
GroupExtension _GroupExtension = new GroupExtension();
|
readonly GroupExtension _GroupExtension = new GroupExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class GroupExtension : extensionBase
|
partial class GroupExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -1186,14 +1082,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 DefaultUsrID => Volian.Base.Library.VlnSettings.UserID;
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -1222,57 +1112,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 Group)
|
if (destType == typeof(string) && value is Group group)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((Group)value).ToString();
|
return group.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 GroupExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class Group
|
|
||||||
// {
|
|
||||||
// partial class GroupExtension : extensionBase
|
|
||||||
// {
|
|
||||||
// // CSLATODO: Override automatic defaults
|
|
||||||
// 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
|
||||||
@@ -343,19 +337,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 GroupAssignment</returns>
|
/// <returns>A Unique ID for the current GroupAssignment</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyGroupAssignmentUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyGroupAssignmentUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
// CSLATODO: Replace base GroupAssignment.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current GroupAssignment</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
public override bool IsDirty
|
public override bool IsDirty
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -370,18 +352,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 || (_MyRole == null ? false : _MyRole.IsDirtyList(list)) || (_MyFolder == null ? false : _MyFolder.IsDirtyList(list));
|
return base.IsDirty || (_MyRole != null && _MyRole.IsDirtyList(list)) || (_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) && (_MyRole == null ? true : _MyRole.IsValidList(list)) && (_MyFolder == null ? true : _MyFolder.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_MyRole == null || _MyRole.IsValidList(list)) && (_MyFolder == null || _MyFolder.IsValidList(list));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
@@ -413,7 +392,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()
|
||||||
@@ -475,80 +454,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
|
//CSLATODO: Who can read/write which fields
|
||||||
//AuthorizationRules.AllowRead(AID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(RID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(RID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(FolderID, "<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 _GroupAssignmentUnique = 0;
|
private static int _GroupAssignmentUnique = 0;
|
||||||
private static int GroupAssignmentUnique
|
private static int GroupAssignmentUnique => ++_GroupAssignmentUnique;
|
||||||
{ get { return ++_GroupAssignmentUnique; } }
|
private readonly int _MyGroupAssignmentUnique = GroupAssignmentUnique;
|
||||||
private int _MyGroupAssignmentUnique = GroupAssignmentUnique;
|
// Absolutely Unique ID - Editable FK
|
||||||
public int MyGroupAssignmentUnique // Absolutely Unique ID - Editable FK
|
public int MyGroupAssignmentUnique => _MyGroupAssignmentUnique;
|
||||||
{ get { return _MyGroupAssignmentUnique; } }
|
internal static GroupAssignment New(Role myRole, Folder myFolder) => new GroupAssignment(myRole, myFolder);
|
||||||
internal static GroupAssignment New(Role myRole, Folder myFolder)
|
internal static GroupAssignment Get(SafeDataReader dr) => new GroupAssignment(dr);
|
||||||
{
|
|
||||||
return new GroupAssignment(myRole, myFolder);
|
|
||||||
}
|
|
||||||
internal static GroupAssignment Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new GroupAssignment(dr);
|
|
||||||
}
|
|
||||||
public GroupAssignment()
|
public GroupAssignment()
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
@@ -579,15 +500,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; } }
|
|
||||||
~GroupAssignment()
|
~GroupAssignment()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -639,32 +556,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 = 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(Group myGroup)
|
internal void Update(Group myGroup)
|
||||||
{
|
{
|
||||||
// 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 = Assignment.Update(cn, ref _AID, myGroup.GID, _RID, _FolderID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged);
|
{
|
||||||
|
_LastChanged = Assignment.Update(cn, ref _AID, myGroup.GID, _RID, _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(Group myGroup)
|
internal void DeleteSelf(Group myGroup)
|
||||||
{
|
{
|
||||||
// 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"])
|
||||||
Assignment.Remove(cn, _AID);
|
{
|
||||||
|
Assignment.Remove(cn, _AID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkNew();
|
MarkNew();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
GroupAssignmentExtension _GroupAssignmentExtension = new GroupAssignmentExtension();
|
readonly GroupAssignmentExtension _GroupAssignmentExtension = new GroupAssignmentExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class GroupAssignmentExtension : extensionBase
|
partial class GroupAssignmentExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -673,18 +600,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)
|
||||||
{
|
{
|
||||||
@@ -713,61 +631,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 GroupAssignment)
|
if (destType == typeof(string) && value is GroupAssignment assignment)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((GroupAssignment)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 GroupAssignmentExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class GroupAssignment
|
|
||||||
// {
|
|
||||||
// partial class GroupAssignmentExtension : 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 GroupAssignment this[Assignment myAssignment]
|
||||||
}
|
|
||||||
// One To Many
|
|
||||||
public GroupAssignment this[Assignment myAssignment]
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -47,11 +42,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public new System.Collections.Generic.IList<GroupAssignment> Items
|
public new System.Collections.Generic.IList<GroupAssignment> Items => base.Items;
|
||||||
{
|
public GroupAssignment GetItem(Assignment myAssignment)
|
||||||
get { return base.Items; }
|
|
||||||
}
|
|
||||||
public GroupAssignment GetItem(Assignment myAssignment)
|
|
||||||
{
|
{
|
||||||
foreach (GroupAssignment assignment in this)
|
foreach (GroupAssignment assignment in this)
|
||||||
if (assignment.AID == myAssignment.AID)
|
if (assignment.AID == myAssignment.AID)
|
||||||
@@ -61,7 +53,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public GroupAssignment Add(Role myRole, Folder myFolder) // One to Many
|
public GroupAssignment Add(Role myRole, Folder myFolder) // One to Many
|
||||||
{
|
{
|
||||||
GroupAssignment assignment = GroupAssignment.New(myRole, myFolder);
|
GroupAssignment assignment = GroupAssignment.New(myRole, myFolder);
|
||||||
this.Add(assignment);
|
Add(assignment);
|
||||||
return assignment;
|
return assignment;
|
||||||
}
|
}
|
||||||
public void Remove(Assignment myAssignment)
|
public void Remove(Assignment myAssignment)
|
||||||
@@ -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 (GroupAssignment 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 (GroupAssignment 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 GroupAssignments New()
|
internal static GroupAssignments New() => new GroupAssignments();
|
||||||
{
|
internal static GroupAssignments Get(SafeDataReader dr) => new GroupAssignments(dr);
|
||||||
return new GroupAssignments();
|
public static GroupAssignments GetByGID(int gid)
|
||||||
}
|
|
||||||
internal static GroupAssignments Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new GroupAssignments(dr);
|
|
||||||
}
|
|
||||||
public static GroupAssignments GetByGID(int gid)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -161,11 +144,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on GroupAssignments.GetByGID", ex);
|
throw new DbCslaException("Error on GroupAssignments.GetByGID", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private GroupAssignments()
|
private GroupAssignments() => MarkAsChild();
|
||||||
{
|
internal GroupAssignments(SafeDataReader dr)
|
||||||
MarkAsChild();
|
|
||||||
}
|
|
||||||
internal GroupAssignments(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
|
~GroupAssignments()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~GroupAssignments()
|
|
||||||
{
|
{
|
||||||
_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(GroupAssignment.Get(dr));
|
Add(GroupAssignment.Get(dr));
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class GIDCriteria
|
private class GIDCriteria
|
||||||
{
|
{
|
||||||
public GIDCriteria(int gid)
|
public GIDCriteria(int gid) => _GID = gid;
|
||||||
{
|
private int _GID;
|
||||||
_GID = gid;
|
|
||||||
}
|
|
||||||
private int _GID;
|
|
||||||
public int GID
|
public int GID
|
||||||
{
|
{
|
||||||
get { return _GID; }
|
get { return _GID; }
|
||||||
@@ -219,7 +192,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
private void DataPortal_Fetch(GIDCriteria criteria)
|
private void DataPortal_Fetch(GIDCriteria criteria)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupAssignments.DataPortal_FetchGID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupAssignments.DataPortal_FetchGID", 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 GroupAssignment(dr));
|
while (dr.Read()) Add(new GroupAssignment(dr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,11 +216,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupAssignments.DataPortal_FetchGID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupAssignments.DataPortal_FetchGID", ex);
|
||||||
throw new DbCslaException("GroupAssignments.DataPortal_Fetch", ex);
|
throw new DbCslaException("GroupAssignments.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
internal void Update(Group group)
|
internal void Update(Group group)
|
||||||
{
|
{
|
||||||
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
|
||||||
GroupAssignmentsPropertyDescriptor pd = new GroupAssignmentsPropertyDescriptor(this, i);
|
GroupAssignmentsPropertyDescriptor pd = new GroupAssignmentsPropertyDescriptor(this, i);
|
||||||
@@ -325,7 +287,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class GroupAssignmentsPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class GroupAssignmentsPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private GroupAssignment Item { get { return (GroupAssignment)_Item; } }
|
|
||||||
public GroupAssignmentsPropertyDescriptor(GroupAssignments collection, int index) : base(collection, index) { ;}
|
public GroupAssignmentsPropertyDescriptor(GroupAssignments collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -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 GroupAssignments)
|
if (destType == typeof(string) && value is GroupAssignments assignments)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((GroupAssignments)value).Items.Count.ToString() + " Assignments";
|
return $"{assignments.Items.Count} Assignments";
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Csla;
|
using Csla;
|
||||||
using Csla.Data;
|
using Csla.Data;
|
||||||
using System.Configuration;
|
|
||||||
using System.IO;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
namespace VEPROMS.CSLA.Library
|
namespace VEPROMS.CSLA.Library
|
||||||
@@ -28,14 +26,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public partial class GroupInfo : ReadOnlyBase<GroupInfo>, IDisposable
|
public partial class GroupInfo : ReadOnlyBase<GroupInfo>, IDisposable
|
||||||
{
|
{
|
||||||
public event GroupInfoEvent Changed;
|
public event GroupInfoEvent 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<GroupInfo> _CacheList = new List<GroupInfo>();
|
private static List<GroupInfo> _CacheList = new List<GroupInfo>();
|
||||||
protected static void AddToCache(GroupInfo groupInfo)
|
protected static void AddToCache(GroupInfo groupInfo)
|
||||||
{
|
{
|
||||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
while (_CacheList.Contains(groupInfo)) _CacheList.Remove(groupInfo); // In RemoveFromCache
|
while (_CacheList.Contains(groupInfo)) _CacheList.Remove(groupInfo); // In RemoveFromCache
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
private static Dictionary<string, List<GroupInfo>> _CacheByPrimaryKey = new Dictionary<string, List<GroupInfo>>();
|
private static Dictionary<string, List<GroupInfo>> _CacheByPrimaryKey = new Dictionary<string, List<GroupInfo>>();
|
||||||
private static void ConvertListToDictionary()
|
private static void ConvertListToDictionary()
|
||||||
{
|
{
|
||||||
@@ -79,16 +76,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
get { return _ErrorMessage; }
|
get { return _ErrorMessage; }
|
||||||
}
|
}
|
||||||
protected Group _Editable;
|
protected Group _Editable;
|
||||||
private IVEHasBrokenRules HasBrokenRules
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
IVEHasBrokenRules hasBrokenRules = null;
|
|
||||||
if (_Editable != null)
|
|
||||||
hasBrokenRules = _Editable.HasBrokenRules;
|
|
||||||
return hasBrokenRules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private int _GID;
|
private int _GID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int GID
|
public int GID
|
||||||
@@ -216,32 +203,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
foreach (GroupInfo tmp in _CacheByPrimaryKey[_GID.ToString()])
|
foreach (GroupInfo tmp in _CacheByPrimaryKey[_GID.ToString()])
|
||||||
tmp._GroupMembershipCount = -1; // This will cause the data to be requeried
|
tmp._GroupMembershipCount = -1; // This will cause the data to be requeried
|
||||||
}
|
}
|
||||||
// CSLATODO: Replace base GroupInfo.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current GroupInfo</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
// CSLATODO: Check GroupInfo.GetIdValue to assure that the ID returned is unique
|
// CSLATODO: Check GroupInfo.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 GroupInfo</returns>
|
/// <returns>A Unique ID for the current GroupInfo</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyGroupInfoUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyGroupInfoUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Factory Methods
|
#region Factory Methods
|
||||||
private static int _GroupInfoUnique = 0;
|
private static int _GroupInfoUnique = 0;
|
||||||
private static int GroupInfoUnique
|
private static int GroupInfoUnique => ++_GroupInfoUnique;
|
||||||
{ get { return ++_GroupInfoUnique; } }
|
private readonly int _MyGroupInfoUnique = GroupInfoUnique;
|
||||||
private int _MyGroupInfoUnique = GroupInfoUnique;
|
// Absolutely Unique ID - Info
|
||||||
public int MyGroupInfoUnique // Absolutely Unique ID - Info
|
public int MyGroupInfoUnique => _MyGroupInfoUnique;
|
||||||
{ get { return _MyGroupInfoUnique; } }
|
|
||||||
protected GroupInfo()
|
protected GroupInfo()
|
||||||
{/* require use of factory methods */
|
{/* require use of factory methods */
|
||||||
AddToCache(this);
|
AddToCache(this);
|
||||||
@@ -250,15 +224,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; } }
|
|
||||||
~GroupInfo()
|
~GroupInfo()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -275,10 +245,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (listGroupInfo.Count == 0) // If there are no items left in the list
|
if (listGroupInfo.Count == 0) // If there are no items left in the list
|
||||||
_CacheByPrimaryKey.Remove(GID.ToString()); // remove the list
|
_CacheByPrimaryKey.Remove(GID.ToString()); // remove the list
|
||||||
}
|
}
|
||||||
public virtual Group Get()
|
public virtual Group Get() => _Editable = Group.Get(_GID);
|
||||||
{
|
|
||||||
return _Editable = Group.Get(_GID);
|
|
||||||
}
|
|
||||||
public static void Refresh(Group tmp)
|
public static void Refresh(Group tmp)
|
||||||
{
|
{
|
||||||
string key = tmp.GID.ToString();
|
string key = tmp.GID.ToString();
|
||||||
@@ -299,8 +266,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static GroupInfo Get(int gid)
|
public static GroupInfo Get(int gid)
|
||||||
{
|
{
|
||||||
//if (!CanGetObject())
|
|
||||||
// throw new System.Security.SecurityException("User not authorized to view a Group");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GroupInfo tmp = GetCachedByPrimaryKey(gid);
|
GroupInfo tmp = GetCachedByPrimaryKey(gid);
|
||||||
@@ -339,13 +304,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[Serializable()]
|
[Serializable()]
|
||||||
protected class PKCriteria
|
protected class PKCriteria
|
||||||
{
|
{
|
||||||
private int _GID;
|
private readonly int _GID;
|
||||||
public int GID
|
public int GID => _GID;
|
||||||
{ get { return _GID; } }
|
public PKCriteria(int gid) => _GID = gid;
|
||||||
public PKCriteria(int gid)
|
|
||||||
{
|
|
||||||
_GID = gid;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void ReadData(SafeDataReader dr)
|
private void ReadData(SafeDataReader dr)
|
||||||
{
|
{
|
||||||
@@ -407,7 +368,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#endregion
|
#endregion
|
||||||
// Standard Refresh
|
// Standard Refresh
|
||||||
#region extension
|
#region extension
|
||||||
GroupInfoExtension _GroupInfoExtension = new GroupInfoExtension();
|
readonly GroupInfoExtension _GroupInfoExtension = new GroupInfoExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class GroupInfoExtension : extensionBase { }
|
partial class GroupInfoExtension : extensionBase { }
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
@@ -423,10 +384,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 GroupInfo)
|
if (destType == typeof(string) && value is GroupInfo info)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((GroupInfo)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<GroupInfo> Items
|
internal new IList<GroupInfo> Items => base.Items;
|
||||||
{ get { return base.Items; } }
|
public void AddEvents()
|
||||||
public void AddEvents()
|
|
||||||
{
|
{
|
||||||
foreach (GroupInfo tmp in this)
|
foreach (GroupInfo 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
|
~GroupInfoList()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~GroupInfoList()
|
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
}
|
}
|
||||||
@@ -97,26 +90,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on GroupInfoList.Get", ex);
|
throw new DbCslaException("Error on GroupInfoList.Get", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset the list of all GroupInfo.
|
/// Reset the list of all GroupInfo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Reset()
|
public static void Reset() => _GroupInfoList = null;
|
||||||
{
|
private GroupInfoList()
|
||||||
_GroupInfoList = null;
|
|
||||||
}
|
|
||||||
// CSLATODO: Add alternative gets -
|
|
||||||
//public static GroupInfoList Get(<criteria>)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// return DataPortal.Fetch<GroupInfoList>(new FilteredCriteria(<criteria>));
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// throw new DbCslaException("Error on GroupInfoList.Get", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
private GroupInfoList()
|
|
||||||
{ /* 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 GroupInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class GroupInfoListPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private GroupInfo Item { get { return (GroupInfo)_Item; } }
|
|
||||||
public GroupInfoListPropertyDescriptor(GroupInfoList collection, int index) : base(collection, index) { ;}
|
public GroupInfoListPropertyDescriptor(GroupInfoList collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -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 GroupInfoList)
|
if (destType == typeof(string) && value is GroupInfoList list)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((GroupInfoList)value).Items.Count.ToString() + " Groups";
|
return $"{list.Items.Count} Groups";
|
||||||
}
|
}
|
||||||
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 _UGID;
|
private int _UGID;
|
||||||
[System.ComponentModel.DataObjectField(true, true)]
|
[System.ComponentModel.DataObjectField(true, true)]
|
||||||
public int UGID
|
public int UGID
|
||||||
@@ -323,19 +317,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 GroupMembership</returns>
|
/// <returns>A Unique ID for the current GroupMembership</returns>
|
||||||
protected override object GetIdValue()
|
protected override object GetIdValue() => MyGroupMembershipUnique; // Absolutely Unique ID
|
||||||
{
|
|
||||||
return MyGroupMembershipUnique; // Absolutely Unique ID
|
|
||||||
}
|
|
||||||
// CSLATODO: Replace base GroupMembership.ToString function as necessary
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides Base ToString
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string representation of current GroupMembership</returns>
|
|
||||||
//public override string ToString()
|
|
||||||
//{
|
|
||||||
// return base.ToString();
|
|
||||||
//}
|
|
||||||
public override bool IsDirty
|
public override bool IsDirty
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -350,7 +332,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 || (_MyUser == null ? false : _MyUser.IsDirtyList(list));
|
return base.IsDirty || (_MyUser != null && _MyUser.IsDirtyList(list));
|
||||||
}
|
}
|
||||||
public override bool IsValid
|
public override bool IsValid
|
||||||
{
|
{
|
||||||
@@ -359,9 +341,9 @@ 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) && (_MyUser == null ? true : _MyUser.IsValidList(list));
|
return ((IsNew && !IsDirty) || base.IsValid) && (_MyUser == null || _MyUser.IsValidList(list));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ValidationRules
|
#region ValidationRules
|
||||||
@@ -391,8 +373,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()
|
||||||
@@ -447,80 +429,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
|
//CSLATODO: Who can read/write which fields
|
||||||
//AuthorizationRules.AllowRead(UGID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(UID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(UID, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
|
|
||||||
//AuthorizationRules.AllowWrite(EndDate, "<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 _GroupMembershipUnique = 0;
|
private static int _GroupMembershipUnique = 0;
|
||||||
private static int GroupMembershipUnique
|
private static int GroupMembershipUnique => ++_GroupMembershipUnique;
|
||||||
{ get { return ++_GroupMembershipUnique; } }
|
private readonly int _MyGroupMembershipUnique = GroupMembershipUnique;
|
||||||
private int _MyGroupMembershipUnique = GroupMembershipUnique;
|
// Absolutely Unique ID - Editable FK
|
||||||
public int MyGroupMembershipUnique // Absolutely Unique ID - Editable FK
|
public int MyGroupMembershipUnique => _MyGroupMembershipUnique;
|
||||||
{ get { return _MyGroupMembershipUnique; } }
|
internal static GroupMembership New(User myUser) => new GroupMembership(myUser);
|
||||||
internal static GroupMembership New(User myUser)
|
internal static GroupMembership Get(SafeDataReader dr) => new GroupMembership(dr);
|
||||||
{
|
|
||||||
return new GroupMembership(myUser);
|
|
||||||
}
|
|
||||||
internal static GroupMembership Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new GroupMembership(dr);
|
|
||||||
}
|
|
||||||
public GroupMembership()
|
public GroupMembership()
|
||||||
{
|
{
|
||||||
MarkAsChild();
|
MarkAsChild();
|
||||||
@@ -550,15 +474,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; } }
|
|
||||||
~GroupMembership()
|
~GroupMembership()
|
||||||
{
|
{
|
||||||
_CountFinalized++;
|
_CountFinalized++;
|
||||||
@@ -608,33 +528,43 @@ namespace VEPROMS.CSLA.Library
|
|||||||
internal void Insert(Group myGroup)
|
internal void Insert(Group myGroup)
|
||||||
{
|
{
|
||||||
// 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 = Membership.Add(cn, ref _UGID, _MyUser, myGroup, new SmartDate(_StartDate), new SmartDate(_EndDate), _Config, _DTS, _UsrID);
|
{
|
||||||
|
_LastChanged = Membership.Add(cn, ref _UGID, _MyUser, myGroup, new SmartDate(_StartDate), new SmartDate(_EndDate), _Config, _DTS, _UsrID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
internal void Update(Group myGroup)
|
internal void Update(Group myGroup)
|
||||||
{
|
{
|
||||||
// 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 = Membership.Update(cn, ref _UGID, _UID, myGroup.GID, new SmartDate(_StartDate), new SmartDate(_EndDate), _Config, _DTS, _UsrID, ref _LastChanged);
|
{
|
||||||
|
_LastChanged = Membership.Update(cn, ref _UGID, _UID, myGroup.GID, new SmartDate(_StartDate), new SmartDate(_EndDate), _Config, _DTS, _UsrID, ref _LastChanged);
|
||||||
|
}
|
||||||
|
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
|
||||||
internal void DeleteSelf(Group myGroup)
|
internal void DeleteSelf(Group myGroup)
|
||||||
{
|
{
|
||||||
// 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"])
|
||||||
Membership.Remove(cn, _UGID);
|
{
|
||||||
|
Membership.Remove(cn, _UGID);
|
||||||
|
}
|
||||||
|
|
||||||
MarkNew();
|
MarkNew();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
// Standard Default Code
|
// Standard Default Code
|
||||||
#region extension
|
#region extension
|
||||||
GroupMembershipExtension _GroupMembershipExtension = new GroupMembershipExtension();
|
readonly GroupMembershipExtension _GroupMembershipExtension = new GroupMembershipExtension();
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
partial class GroupMembershipExtension : extensionBase
|
partial class GroupMembershipExtension : extensionBase
|
||||||
{
|
{
|
||||||
@@ -643,18 +573,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)
|
||||||
{
|
{
|
||||||
@@ -683,61 +604,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 GroupMembership)
|
if (destType == typeof(string) && value is GroupMembership membership)
|
||||||
{
|
{
|
||||||
// Return the ToString value
|
// Return the ToString value
|
||||||
return ((GroupMembership)value).ToString();
|
return membership.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 GroupMembershipExt.cs
|
|
||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using System.Text;
|
|
||||||
//using Csla;
|
|
||||||
|
|
||||||
//namespace VEPROMS.CSLA.Library
|
|
||||||
//{
|
|
||||||
// public partial class GroupMembership
|
|
||||||
// {
|
|
||||||
// partial class GroupMembershipExtension : 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 GroupMembership this[Membership myMembership]
|
||||||
}
|
|
||||||
// One To Many
|
|
||||||
public GroupMembership this[Membership myMembership]
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -47,11 +42,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public new System.Collections.Generic.IList<GroupMembership> Items
|
public new System.Collections.Generic.IList<GroupMembership> Items => base.Items;
|
||||||
{
|
public GroupMembership GetItem(Membership myMembership)
|
||||||
get { return base.Items; }
|
|
||||||
}
|
|
||||||
public GroupMembership GetItem(Membership myMembership)
|
|
||||||
{
|
{
|
||||||
foreach (GroupMembership membership in this)
|
foreach (GroupMembership membership in this)
|
||||||
if (membership.UGID == myMembership.UGID)
|
if (membership.UGID == myMembership.UGID)
|
||||||
@@ -61,7 +53,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public GroupMembership Add(User myUser) // One to Many
|
public GroupMembership Add(User myUser) // One to Many
|
||||||
{
|
{
|
||||||
GroupMembership membership = GroupMembership.New(myUser);
|
GroupMembership membership = GroupMembership.New(myUser);
|
||||||
this.Add(membership);
|
Add(membership);
|
||||||
return membership;
|
return membership;
|
||||||
}
|
}
|
||||||
public void Remove(Membership myMembership)
|
public void Remove(Membership myMembership)
|
||||||
@@ -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 (GroupMembership 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 (GroupMembership 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 GroupMemberships New()
|
internal static GroupMemberships New() => new GroupMemberships();
|
||||||
{
|
internal static GroupMemberships Get(SafeDataReader dr) => new GroupMemberships(dr);
|
||||||
return new GroupMemberships();
|
public static GroupMemberships GetByGID(int gid)
|
||||||
}
|
|
||||||
internal static GroupMemberships Get(SafeDataReader dr)
|
|
||||||
{
|
|
||||||
return new GroupMemberships(dr);
|
|
||||||
}
|
|
||||||
public static GroupMemberships GetByGID(int gid)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -161,11 +144,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on GroupMemberships.GetByGID", ex);
|
throw new DbCslaException("Error on GroupMemberships.GetByGID", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private GroupMemberships()
|
private GroupMemberships() => MarkAsChild();
|
||||||
{
|
internal GroupMemberships(SafeDataReader dr)
|
||||||
MarkAsChild();
|
|
||||||
}
|
|
||||||
internal GroupMemberships(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
|
~GroupMemberships()
|
||||||
{ get { return _CountCreated - _CountDisposed; } }
|
|
||||||
public static int CountNotFinalized
|
|
||||||
{ get { return _CountCreated - _CountFinalized; } }
|
|
||||||
~GroupMemberships()
|
|
||||||
{
|
{
|
||||||
_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(GroupMembership.Get(dr));
|
Add(GroupMembership.Get(dr));
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
private class GIDCriteria
|
private class GIDCriteria
|
||||||
{
|
{
|
||||||
public GIDCriteria(int gid)
|
public GIDCriteria(int gid) => _GID = gid;
|
||||||
{
|
private int _GID;
|
||||||
_GID = gid;
|
|
||||||
}
|
|
||||||
private int _GID;
|
|
||||||
public int GID
|
public int GID
|
||||||
{
|
{
|
||||||
get { return _GID; }
|
get { return _GID; }
|
||||||
@@ -219,7 +192,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
private void DataPortal_Fetch(GIDCriteria criteria)
|
private void DataPortal_Fetch(GIDCriteria criteria)
|
||||||
{
|
{
|
||||||
this.RaiseListChangedEvents = false;
|
RaiseListChangedEvents = false;
|
||||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupMemberships.DataPortal_FetchGID", GetHashCode());
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupMemberships.DataPortal_FetchGID", 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 GroupMembership(dr));
|
while (dr.Read()) Add(new GroupMembership(dr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,11 +216,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupMemberships.DataPortal_FetchGID", ex);
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupMemberships.DataPortal_FetchGID", ex);
|
||||||
throw new DbCslaException("GroupMemberships.DataPortal_Fetch", ex);
|
throw new DbCslaException("GroupMemberships.DataPortal_Fetch", ex);
|
||||||
}
|
}
|
||||||
this.RaiseListChangedEvents = true;
|
RaiseListChangedEvents = true;
|
||||||
}
|
}
|
||||||
internal void Update(Group group)
|
internal void Update(Group group)
|
||||||
{
|
{
|
||||||
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
|
||||||
GroupMembershipsPropertyDescriptor pd = new GroupMembershipsPropertyDescriptor(this, i);
|
GroupMembershipsPropertyDescriptor pd = new GroupMembershipsPropertyDescriptor(this, i);
|
||||||
@@ -325,7 +287,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class GroupMembershipsPropertyDescriptor : vlnListPropertyDescriptor
|
public partial class GroupMembershipsPropertyDescriptor : vlnListPropertyDescriptor
|
||||||
{
|
{
|
||||||
private GroupMembership Item { get { return (GroupMembership)_Item; } }
|
|
||||||
public GroupMembershipsPropertyDescriptor(GroupMemberships collection, int index) : base(collection, index) { ;}
|
public GroupMembershipsPropertyDescriptor(GroupMemberships collection, int index) : base(collection, index) { ;}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -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 GroupMemberships)
|
if (destType == typeof(string) && value is GroupMemberships memberships)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((GroupMemberships)value).Items.Count.ToString() + " Memberships";
|
return $"{memberships.Items.Count} Memberships";
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user