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
+135 -299
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;
@@ -108,6 +106,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<RODb> _CacheList = new List<RODb>();
protected static void AddToCache(RODb rODb)
{
@@ -117,7 +116,9 @@ namespace VEPROMS.CSLA.Library
{
while (_CacheList.Contains(rODb)) _CacheList.Remove(rODb); // In RemoveFromCache
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, List<RODb>> _CacheByPrimaryKey = new Dictionary<string, List<RODb>>();
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, List<RODb>> _CacheByFolderPath = new Dictionary<string, List<RODb>>();
private static void ConvertListToDictionary()
{
@@ -152,15 +153,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 _nextRODbID = -1;
public static int NextRODbID
{
get { return _nextRODbID--; }
}
public static int NextRODbID => _nextRODbID--;
private int _RODbID;
[System.ComponentModel.DataObjectField(true, true)]
public int RODbID
@@ -325,10 +320,7 @@ namespace VEPROMS.CSLA.Library
return _RODbDROUsages;
}
}
public void Reset_RODbDROUsages()
{
_RODbDROUsageCount = -1;
}
public void Reset_RODbDROUsages() => _RODbDROUsageCount = -1;
private int _RODbROFstCount = 0;
/// <summary>
/// Count of RODbROFsts for this RODb
@@ -360,10 +352,7 @@ namespace VEPROMS.CSLA.Library
return _RODbROFsts;
}
}
public void Reset_RODbROFsts()
{
_RODbROFstCount = -1;
}
public void Reset_RODbROFsts() => _RODbROFstCount = -1;
private int _RODbROImageCount = 0;
/// <summary>
/// Count of RODbROImages for this RODb
@@ -395,10 +384,7 @@ namespace VEPROMS.CSLA.Library
return _RODbROImages;
}
}
public void Reset_RODbROImages()
{
_RODbROImageCount = -1;
}
public void Reset_RODbROImages() => _RODbROImageCount = -1;
private int _RODbRoUsageCount = 0;
/// <summary>
/// Count of RODbRoUsages for this RODb
@@ -430,10 +416,7 @@ namespace VEPROMS.CSLA.Library
return _RODbRoUsages;
}
}
public void Reset_RODbRoUsages()
{
_RODbRoUsageCount = -1;
}
public void Reset_RODbRoUsages() => _RODbRoUsageCount = -1;
public override bool IsDirty
{
get
@@ -448,37 +431,22 @@ namespace VEPROMS.CSLA.Library
if (base.IsDirty || list.Contains(this))
return base.IsDirty;
list.Add(this);
return base.IsDirty || (_RODbDROUsages == null ? false : _RODbDROUsages.IsDirtyList(list)) || (_RODbROFsts == null ? false : _RODbROFsts.IsDirtyList(list)) || (_RODbROImages == null ? false : _RODbROImages.IsDirtyList(list)) || (_RODbRoUsages == null ? false : _RODbRoUsages.IsDirtyList(list));
}
public override bool IsValid
{
get { return IsValidList(new List<object>()); }
return base.IsDirty || (_RODbDROUsages != null && _RODbDROUsages.IsDirtyList(list)) || (_RODbROFsts != null && _RODbROFsts.IsDirtyList(list)) || (_RODbROImages != null && _RODbROImages.IsDirtyList(list)) || (_RODbRoUsages != null && _RODbRoUsages.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) && (_RODbDROUsages == null ? true : _RODbDROUsages.IsValidList(list)) && (_RODbROFsts == null ? true : _RODbROFsts.IsValidList(list)) && (_RODbROImages == null ? true : _RODbROImages.IsValidList(list)) && (_RODbRoUsages == null ? true : _RODbRoUsages.IsValidList(list));
return ((IsNew && !IsDirty) || base.IsValid) && (_RODbDROUsages == null || _RODbDROUsages.IsValidList(list)) && (_RODbROFsts == null || _RODbROFsts.IsValidList(list)) && (_RODbROImages == null || _RODbROImages.IsValidList(list)) && (_RODbRoUsages == null || _RODbRoUsages.IsValidList(list));
}
// CSLATODO: Replace base RODb.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RODb</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check RODb.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 RODb</returns>
protected override object GetIdValue()
{
return MyRODbUnique; // Absolutely Unique ID
}
protected override object GetIdValue() => MyRODbUnique; // Absolutely Unique ID
#endregion
#region ValidationRules
[NonSerialized]
@@ -510,8 +478,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()
@@ -548,35 +516,11 @@ namespace VEPROMS.CSLA.Library
_RODbExtension.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(RODbID, "<Role(s)>");
//AuthorizationRules.AllowRead(ROName, "<Role(s)>");
//AuthorizationRules.AllowRead(FolderPath, "<Role(s)>");
//AuthorizationRules.AllowRead(DBConnectionString, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ROName, "<Role(s)>");
//AuthorizationRules.AllowWrite(FolderPath, "<Role(s)>");
//AuthorizationRules.AllowWrite(DBConnectionString, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
_RODbExtension.AddAuthorizationRules(AuthorizationRules);
}
protected override void AddInstanceAuthorizationRules()
@@ -584,58 +528,14 @@ namespace VEPROMS.CSLA.Library
//CSLATODO: Who can read/write which fields
_RODbExtension.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 += _RODbDROUsageCount;
usedByCount += _RODbROFstCount;
usedByCount += _RODbROImageCount;
usedByCount += _RODbRoUsageCount;
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 _RODbUnique = 0;
protected static int RODbUnique
{ get { return ++_RODbUnique; } }
private int _MyRODbUnique = RODbUnique;
public int MyRODbUnique // Absolutely Unique ID - Editable
{ get { return _MyRODbUnique; } }
protected static int RODbUnique => ++_RODbUnique;
private readonly int _MyRODbUnique = RODbUnique;
// Absolutely Unique ID - Editable
public int MyRODbUnique => _MyRODbUnique;
protected RODb()
{/* require use of factory methods */
AddToCache(this);
@@ -644,15 +544,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;
~RODb()
{
_CountFinalized++;
@@ -689,8 +585,6 @@ namespace VEPROMS.CSLA.Library
}
public static RODb New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a RODb");
try
{
return DataPortal.Create<RODb>();
@@ -762,8 +656,6 @@ namespace VEPROMS.CSLA.Library
}
public static RODb Get(int rODbID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a RODb");
try
{
RODb tmp = GetCachedByPrimaryKey(rODbID);
@@ -786,8 +678,6 @@ namespace VEPROMS.CSLA.Library
}
public static RODb GetByFolderPath(string folderPath)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a RODb");
try
{
RODb tmp = GetCachedByFolderPath(folderPath);
@@ -813,14 +703,9 @@ namespace VEPROMS.CSLA.Library
if (dr.Read()) return new RODb(dr);
return null;
}
internal RODb(SafeDataReader dr)
{
ReadData(dr);
}
internal RODb(SafeDataReader dr) => ReadData(dr);
public static void Delete(int rODbID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a RODb");
try
{
DataPortal.Delete(new PKCriteria(rODbID));
@@ -832,12 +717,6 @@ namespace VEPROMS.CSLA.Library
}
public override RODb Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a RODb");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a RODb");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a RODb");
try
{
BuildRefreshList();
@@ -857,24 +736,16 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteria
{
private int _RODbID;
public int RODbID
{ get { return _RODbID; } }
public PKCriteria(int rODbID)
{
_RODbID = rODbID;
}
private readonly int _RODbID;
public int RODbID => _RODbID;
public PKCriteria(int rODbID) => _RODbID = rODbID;
}
[Serializable()]
private class FolderPathCriteria
{
private string _FolderPath;
public string FolderPath
{ get { return _FolderPath; } }
public FolderPathCriteria(string folderPath)
{
_FolderPath = folderPath;
}
private readonly string _FolderPath;
public string FolderPath => _FolderPath;
public FolderPathCriteria(string folderPath) => _FolderPath = folderPath;
}
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
@@ -1025,41 +896,48 @@ 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 = "addRODb";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ROName", _ROName);
cm.Parameters.AddWithValue("@FolderPath", _FolderPath);
cm.Parameters.AddWithValue("@DBConnectionString", _DBConnectionString);
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_RODbID = new SqlParameter("@newRODbID", SqlDbType.Int);
param_RODbID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_RODbID);
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
_RODbID = (int)cm.Parameters["@newRODbID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandTimeout = Database.SQLTimeout;
cm.CommandText = "addRODb";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ROName", _ROName);
cm.Parameters.AddWithValue("@FolderPath", _FolderPath);
cm.Parameters.AddWithValue("@DBConnectionString", _DBConnectionString);
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_RODbID = new SqlParameter("@newRODbID", SqlDbType.Int)
{
Direction = ParameterDirection.Output
};
cm.Parameters.Add(param_RODbID);
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
_RODbID = (int)cm.Parameters["@newRODbID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
MarkOld();
// update child objects
if (_RODbRoUsages != null) _RODbRoUsages.Update(this);
if (_RODbDROUsages != null) _RODbDROUsages.Update(this);
if (_RODbROFsts != null) _RODbROFsts.Update(this);
if (_RODbROImages != null) _RODbROImages.Update(this);
_RODbRoUsages?.Update(this);
_RODbDROUsages?.Update(this);
_RODbROFsts?.Update(this);
_RODbROImages?.Update(this);
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODb.SQLInsert", GetHashCode());
}
catch (Exception ex)
@@ -1088,11 +966,15 @@ 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_RODbID = new SqlParameter("@newRODbID", SqlDbType.Int);
param_RODbID.Direction = ParameterDirection.Output;
SqlParameter param_RODbID = new SqlParameter("@newRODbID", SqlDbType.Int)
{
Direction = ParameterDirection.Output
};
cm.Parameters.Add(param_RODbID);
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();
@@ -1137,39 +1019,44 @@ namespace VEPROMS.CSLA.Library
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODb.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 = "updateRODb";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@RODbID", _RODbID);
cm.Parameters.AddWithValue("@ROName", _ROName);
cm.Parameters.AddWithValue("@FolderPath", _FolderPath);
cm.Parameters.AddWithValue("@DBConnectionString", _DBConnectionString);
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 = "updateRODb";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@RODbID", _RODbID);
cm.Parameters.AddWithValue("@ROName", _ROName);
cm.Parameters.AddWithValue("@FolderPath", _FolderPath);
cm.Parameters.AddWithValue("@DBConnectionString", _DBConnectionString);
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
if (_RODbRoUsages != null) _RODbRoUsages.Update(this);
if (_RODbDROUsages != null) _RODbDROUsages.Update(this);
if (_RODbROFsts != null) _RODbROFsts.Update(this);
if (_RODbROImages != null) _RODbROImages.Update(this);
_RODbRoUsages?.Update(this);
_RODbDROUsages?.Update(this);
_RODbROFsts?.Update(this);
_RODbROImages?.Update(this);
}
catch (Exception ex)
{
@@ -1180,20 +1067,23 @@ 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 = RODb.Add(cn, ref _RODbID, _ROName, _FolderPath, _DBConnectionString, _Config, _DTS, _UserID);
else
_LastChanged = RODb.Update(cn, ref _RODbID, _ROName, _FolderPath, _DBConnectionString, _Config, _DTS, _UserID, ref _LastChanged);
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
{
if (IsNew)
_LastChanged = RODb.Add(cn, ref _RODbID, _ROName, _FolderPath, _DBConnectionString, _Config, _DTS, _UserID);
else
_LastChanged = RODb.Update(cn, ref _RODbID, _ROName, _FolderPath, _DBConnectionString, _Config, _DTS, _UserID, ref _LastChanged);
}
MarkOld();
}
if (_RODbRoUsages != null) _RODbRoUsages.Update(this);
if (_RODbDROUsages != null) _RODbDROUsages.Update(this);
if (_RODbROFsts != null) _RODbROFsts.Update(this);
if (_RODbROImages != null) _RODbROImages.Update(this);
_RODbRoUsages?.Update(this);
_RODbDROUsages?.Update(this);
_RODbROFsts?.Update(this);
_RODbROImages?.Update(this);
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int rODbID, string rOName, string folderPath, string dBConnectionString, string config, DateTime dts, string userID, ref byte[] lastChanged)
@@ -1216,8 +1106,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();
@@ -1302,16 +1194,10 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _RODbID;
private readonly int _RODbID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int rODbID)
{
_RODbID = rODbID;
}
public bool Exists => _exists;
public ExistsCommand(int rODbID) => _RODbID = rODbID;
protected override void DataPortal_Execute()
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODb.DataPortal_Execute", GetHashCode());
@@ -1327,7 +1213,7 @@ namespace VEPROMS.CSLA.Library
cm.CommandText = "existsRODb";
cm.Parameters.AddWithValue("@RODbID", _RODbID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
_exists = count > 0;
}
}
}
@@ -1341,7 +1227,7 @@ namespace VEPROMS.CSLA.Library
#endregion
// Standard Default Code
#region extension
RODbExtension _RODbExtension = new RODbExtension();
readonly RODbExtension _RODbExtension = new RODbExtension();
[Serializable()]
partial class RODbExtension : extensionBase
{
@@ -1350,14 +1236,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)
{
@@ -1386,57 +1266,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 RODb)
if (destType == typeof(string) && value is RODb db)
{
// Return the ToString value
return ((RODb)value).ToString();
return db.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create RODbExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class RODb
// {
// partial class RODbExtension : 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 */);
// }
// }
// }
//}