CSLA - R - Group 1

This commit is contained in:
2026-09-11 16:03:51 -04:00
parent d9f8f6cb37
commit d238d6aed2
33 changed files with 2101 additions and 4829 deletions
+131 -284
View File
@@ -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;
@@ -85,7 +83,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<ROFst> _CacheList = new List<ROFst>();
protected static void AddToCache(ROFst rOFst)
{
@@ -100,7 +98,9 @@ namespace VEPROMS.CSLA.Library
{
while (_CacheList.Contains(rOFst)) _CacheList.Remove(rOFst); // In RemoveFromCache
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, List<ROFst>> _CacheByPrimaryKey = new Dictionary<string, List<ROFst>>();
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, List<ROFst>> _CacheByRODbID_DTS = new Dictionary<string, List<ROFst>>();
private static void ConvertListToDictionary()
{
@@ -129,7 +129,7 @@ namespace VEPROMS.CSLA.Library
protected static ROFst GetCachedByRODbID_DTS(int rODbID, DateTime dts)
{
ConvertListToDictionary();
string key = rODbID.ToString() + "_" + dts.ToString();
string key = $"{rODbID}_{dts}";
if (_CacheByRODbID_DTS.ContainsKey(key)) return _CacheByRODbID_DTS[key][0];
return null;
}
@@ -139,15 +139,9 @@ namespace VEPROMS.CSLA.Library
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
public string ErrorMessage => _ErrorMessage;
private static int _nextROFstID = -1;
public static int NextROFstID
{
get { return _nextROFstID--; }
}
public static int NextROFstID => _nextROFstID--;
private int _ROFstID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROFstID
@@ -302,10 +296,7 @@ namespace VEPROMS.CSLA.Library
return _ROFstAssociations;
}
}
public void Reset_ROFstAssociations()
{
_ROFstAssociationCount = -1;
}
public void Reset_ROFstAssociations() => _ROFstAssociationCount = -1;
private int _ROFstFigureCount = 0;
/// <summary>
/// Count of ROFstFigures for this ROFst
@@ -337,10 +328,7 @@ namespace VEPROMS.CSLA.Library
return _ROFstFigures;
}
}
public void Reset_ROFstFigures()
{
_ROFstFigureCount = -1;
}
public void Reset_ROFstFigures() => _ROFstFigureCount = -1;
public override bool IsDirty
{
get
@@ -355,37 +343,22 @@ namespace VEPROMS.CSLA.Library
if (base.IsDirty || list.Contains(this))
return base.IsDirty;
list.Add(this);
return base.IsDirty || (_ROFstAssociations == null ? false : _ROFstAssociations.IsDirtyList(list)) || (_ROFstFigures == null ? false : _ROFstFigures.IsDirtyList(list)) || (_MyRODb == null ? false : _MyRODb.IsDirtyList(list));
}
public override bool IsValid
{
get { return IsValidList(new List<object>()); }
return base.IsDirty || (_ROFstAssociations != null && _ROFstAssociations.IsDirtyList(list)) || (_ROFstFigures != null && _ROFstFigures.IsDirtyList(list)) || (_MyRODb != null && _MyRODb.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) && (_ROFstAssociations == null ? true : _ROFstAssociations.IsValidList(list)) && (_ROFstFigures == null ? true : _ROFstFigures.IsValidList(list)) && (_MyRODb == null ? true : _MyRODb.IsValidList(list));
return ((IsNew && !IsDirty) || base.IsValid) && (_ROFstAssociations == null || _ROFstAssociations.IsValidList(list)) && (_ROFstFigures == null || _ROFstFigures.IsValidList(list)) && (_MyRODb == null || _MyRODb.IsValidList(list));
}
// CSLATODO: Replace base ROFst.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROFst</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check ROFst.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 ROFst</returns>
protected override object GetIdValue()
{
return MyROFstUnique; // Absolutely Unique ID
}
protected override object GetIdValue() => MyROFstUnique; // Absolutely Unique ID
#endregion
#region ValidationRules
[NonSerialized]
@@ -416,8 +389,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()
@@ -449,33 +422,11 @@ 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(ROFstID, "<Role(s)>");
//AuthorizationRules.AllowRead(RODbID, "<Role(s)>");
//AuthorizationRules.AllowRead(ROLookup, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RODbID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ROLookup, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
_ROFstExtension.AddAuthorizationRules(AuthorizationRules);
}
protected override void AddInstanceAuthorizationRules()
@@ -483,56 +434,14 @@ namespace VEPROMS.CSLA.Library
//CSLATODO: Who can read/write which fields
_ROFstExtension.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 += _ROFstAssociationCount;
usedByCount += _ROFstFigureCount;
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 _ROFstUnique = 0;
protected static int ROFstUnique
{ get { return ++_ROFstUnique; } }
private int _MyROFstUnique = ROFstUnique;
public int MyROFstUnique // Absolutely Unique ID - Editable
{ get { return _MyROFstUnique; } }
protected static int ROFstUnique => ++_ROFstUnique;
private readonly int _MyROFstUnique = ROFstUnique;
// Absolutely Unique ID - Editable
public int MyROFstUnique => _MyROFstUnique;
protected ROFst()
{/* require use of factory methods */
AddToCache(this);
@@ -541,15 +450,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;
~ROFst()
{
_CountFinalized++;
@@ -588,8 +493,6 @@ namespace VEPROMS.CSLA.Library
public static ROFst New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a ROFst");
try
{
return DataPortal.Create<ROFst>();
@@ -640,7 +543,7 @@ namespace VEPROMS.CSLA.Library
if (tmp.ROLookup != null && tmp.ROFstID > 0)
{
//Force Load the new Lookup Data
var RofstLookup = new ROFSTLookup(tmp.ROFstID);
_ = new ROFSTLookup(tmp.ROFstID);
tmp.ROLookup = null;
}
}
@@ -667,7 +570,7 @@ namespace VEPROMS.CSLA.Library
// B2022-026 RO Memory reduction
//Force Load the new Lookup Data
var RofstLookup = new ROFSTLookup(tmp.ROFstID);
_ = new ROFSTLookup(tmp.ROFstID);
tmp.ROLookup = null;
}
else
@@ -685,8 +588,6 @@ namespace VEPROMS.CSLA.Library
public static ROFst Get(int rOFstID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a ROFst");
try
{
ROFst tmp = GetCachedByPrimaryKey(rOFstID);
@@ -712,8 +613,6 @@ namespace VEPROMS.CSLA.Library
public static ROFst GetByRODbID_DTS(int rODbID, DateTime dts)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a ROFst");
try
{
ROFst tmp = GetCachedByRODbID_DTS(rODbID, dts);
@@ -739,14 +638,9 @@ namespace VEPROMS.CSLA.Library
if (dr.Read()) return new ROFst(dr);
return null;
}
internal ROFst(SafeDataReader dr)
{
ReadData(dr);
}
internal ROFst(SafeDataReader dr) => ReadData(dr);
public static void Delete(int rOFstID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a ROFst");
try
{
DataPortal.Delete(new PKCriteria(rOFstID));
@@ -758,12 +652,6 @@ namespace VEPROMS.CSLA.Library
}
public override ROFst Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a ROFst");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a ROFst");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a ROFst");
try
{
BuildRefreshList();
@@ -784,23 +672,17 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteria
{
private int _ROFstID;
public int ROFstID
{ get { return _ROFstID; } }
public PKCriteria(int rOFstID)
{
_ROFstID = rOFstID;
}
private readonly int _ROFstID;
public int ROFstID => _ROFstID;
public PKCriteria(int rOFstID) => _ROFstID = rOFstID;
}
[Serializable()]
private class RODbID_DTSCriteria
{
private int _RODbID;
public int RODbID
{ get { return _RODbID; } }
private DateTime _DTS;
public DateTime DTS
{ get { return _DTS; } }
private readonly int _RODbID;
public int RODbID => _RODbID;
private readonly DateTime _DTS;
public DateTime DTS => _DTS;
public RODbID_DTSCriteria(int rODbID, DateTime dts)
{
_RODbID = rODbID;
@@ -954,45 +836,52 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)]
internal void SQLInsert()
{
if (!this.IsDirty) return;
if (!IsDirty) return;
try
{
if (_MyRODb != null) _MyRODb.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand())
_MyRODb?.Update();
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandTimeout = Database.SQLTimeout;
cm.CommandText = "addROFst";
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandTimeout = Database.SQLTimeout;
cm.CommandText = "addROFst";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@RODbID", RODbID);
cm.Parameters.AddWithValue("@ROLookup", _ROLookup);
cm.Parameters.AddWithValue("@Config", _Config);
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@RODbID", RODbID);
cm.Parameters.AddWithValue("@ROLookup", _ROLookup);
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_ROFstID = new SqlParameter("@newROFstID", SqlDbType.Int);
param_ROFstID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_ROFstID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// Output Calculated Columns
SqlParameter param_ROFstID = new SqlParameter("@newROFstID", SqlDbType.Int)
{
Direction = ParameterDirection.Output
};
cm.Parameters.Add(param_ROFstID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
{
Direction = ParameterDirection.Output
};
cm.Parameters.Add(param_LastChanged);
cm.ExecuteNonQuery();
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_ROFstID = (int)cm.Parameters["@newROFstID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
// Save all values being returned from the Procedure
_ROFstID = (int)cm.Parameters["@newROFstID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
// Clear Out Any Rofst Binary (Bytes[]) - B2022-026 RO Memory reduction
_ROLookup = null;
// Clear Out Any Rofst Binary (Bytes[]) - B2022-026 RO Memory reduction
_ROLookup = null;
}
}
MarkOld();
// update child objects
if (_ROFstAssociations != null) _ROFstAssociations.Update(this);
if (_ROFstFigures != null) _ROFstFigures.Update(this);
_ROFstAssociations?.Update(this);
_ROFstFigures?.Update(this);
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFst.SQLInsert", GetHashCode());
}
catch (Exception ex)
@@ -1023,11 +912,15 @@ namespace VEPROMS.CSLA.Library
cm.Parameters.AddWithValue("@UserID", userID);
// Output Calculated Columns
SqlParameter param_ROFstID = new SqlParameter("@newROFstID", SqlDbType.Int);
param_ROFstID.Direction = ParameterDirection.Output;
SqlParameter param_ROFstID = new SqlParameter("@newROFstID", SqlDbType.Int)
{
Direction = ParameterDirection.Output
};
cm.Parameters.Add(param_ROFstID);
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);
cm.ExecuteNonQuery();
@@ -1078,40 +971,45 @@ namespace VEPROMS.CSLA.Library
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFst.SQLUpdate", GetHashCode());
try
{
if (_MyRODb != null) _MyRODb.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty)
_MyRODb?.Update();
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 = "updateROFst";
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandTimeout = Database.SQLTimeout;
cm.CommandText = "updateROFst";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@ROFstID", _ROFstID);
cm.Parameters.AddWithValue("@RODbID", RODbID);
cm.Parameters.AddWithValue("@ROLookup", ROFSTLookup.GetRofstLookupBytes(_ROFstID)); // B2022-026 RO Memory reduction - new calls
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);
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@ROFstID", _ROFstID);
cm.Parameters.AddWithValue("@RODbID", RODbID);
cm.Parameters.AddWithValue("@ROLookup", ROFSTLookup.GetRofstLookupBytes(_ROFstID)); // B2022-026 RO Memory reduction - new calls
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);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
{
Direction = ParameterDirection.Output
};
cm.Parameters.Add(param_LastChanged);
cm.ExecuteNonQuery();
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
}
MarkOld();
// use the open connection to update child objects
if (_ROFstAssociations != null) _ROFstAssociations.Update(this);
if (_ROFstFigures != null) _ROFstFigures.Update(this);
_ROFstAssociations?.Update(this);
_ROFstFigures?.Update(this);
}
catch (Exception ex)
{
@@ -1123,18 +1021,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 = ROFst.Add(cn, ref _ROFstID, _MyRODb, _ROLookup, _Config, _DTS, _UserID);
else
_LastChanged = ROFst.Update(cn, ref _ROFstID, _RODbID, _ROLookup, _Config, _DTS, _UserID, ref _LastChanged);
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
{
if (IsNew)
_LastChanged = ROFst.Add(cn, ref _ROFstID, _MyRODb, _ROLookup, _Config, _DTS, _UserID);
else
_LastChanged = ROFst.Update(cn, ref _ROFstID, _RODbID, _ROLookup, _Config, _DTS, _UserID, ref _LastChanged);
}
MarkOld();
}
if (_ROFstAssociations != null) _ROFstAssociations.Update(this);
if (_ROFstFigures != null) _ROFstFigures.Update(this);
_ROFstAssociations?.Update(this);
_ROFstFigures?.Update(this);
}
[Transactional(TransactionalTypes.TransactionScope)]
@@ -1163,8 +1064,10 @@ namespace VEPROMS.CSLA.Library
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);
cm.ExecuteNonQuery();
@@ -1250,16 +1153,10 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _ROFstID;
private readonly int _ROFstID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int rOFstID)
{
_ROFstID = rOFstID;
}
public bool Exists => _exists;
public ExistsCommand(int rOFstID) => _ROFstID = rOFstID;
protected override void DataPortal_Execute()
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFst.DataPortal_Execute", GetHashCode());
@@ -1275,7 +1172,7 @@ namespace VEPROMS.CSLA.Library
cm.CommandText = "existsROFst";
cm.Parameters.AddWithValue("@ROFstID", _ROFstID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
_exists = count > 0;
}
}
}
@@ -1289,7 +1186,7 @@ namespace VEPROMS.CSLA.Library
#endregion
// Standard Default Code
#region extension
ROFstExtension _ROFstExtension = new ROFstExtension();
readonly ROFstExtension _ROFstExtension = new ROFstExtension();
[Serializable()]
partial class ROFstExtension : extensionBase
{
@@ -1298,14 +1195,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)
{
@@ -1334,57 +1225,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 ROFst)
if (destType == typeof(string) && value is ROFst fst)
{
// Return the ToString value
return ((ROFst)value).ToString();
return fst.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create ROFstExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ROFst
// {
// partial class ROFstExtension : 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 */);
// }
// }
// }
//}