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