CSLA - Generated - Batch - As

This commit is contained in:
2026-09-03 08:05:32 -04:00
parent dc5d547449
commit 222371302f
17 changed files with 1368 additions and 2751 deletions
+193 -346
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;
@@ -37,11 +35,8 @@ namespace VEPROMS.CSLA.Library
if (IsDirty)
refreshAnnotations.Add(this);
}
private void ClearRefreshList()
{
_RefreshAnnotations = new List<Annotation>();
}
private void BuildRefreshList()
private void ClearRefreshList() => _RefreshAnnotations = new List<Annotation>();
private void BuildRefreshList()
{
ClearRefreshList();
AddToRefreshList(_RefreshAnnotations);
@@ -56,9 +51,10 @@ namespace VEPROMS.CSLA.Library
}
ClearRefreshList();
}
#endregion
#region Collection
private static List<Annotation> _CacheList = new List<Annotation>();
#endregion
#region Collection
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static List<Annotation> _CacheList = new List<Annotation>();
protected static void AddToCache(Annotation annotation)
{
if (!_CacheList.Contains(annotation)) _CacheList.Add(annotation); // In AddToCache
@@ -67,7 +63,8 @@ namespace VEPROMS.CSLA.Library
{
while (_CacheList.Contains(annotation)) _CacheList.Remove(annotation); // In RemoveFromCache
}
private static Dictionary<string, List<Annotation>> _CacheByPrimaryKey = new Dictionary<string, List<Annotation>>();
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, List<Annotation>> _CacheByPrimaryKey = new Dictionary<string, List<Annotation>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move Annotation(s) from temporary _CacheList to _CacheByPrimaryKey
@@ -92,16 +89,10 @@ namespace VEPROMS.CSLA.Library
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private static int _nextAnnotationID = -1;
public static int NextAnnotationID
{
get { return _nextAnnotationID--; }
}
private int _AnnotationID;
public string ErrorMessage => _ErrorMessage;
private static int _nextAnnotationID = -1;
public static int NextAnnotationID => _nextAnnotationID--;
private int _AnnotationID;
[System.ComponentModel.DataObjectField(true, true)]
public int AnnotationID
{
@@ -280,40 +271,25 @@ namespace VEPROMS.CSLA.Library
if (base.IsDirty || list.Contains(this))
return base.IsDirty;
list.Add(this);
return base.IsDirty || (_MyAnnotationType == null ? false : _MyAnnotationType.IsDirtyList(list)) || (_MyItem == null ? false : _MyItem.IsDirtyList(list));
return base.IsDirty || (_MyAnnotationType != null && _MyAnnotationType.IsDirtyList(list)) || (_MyItem != null && _MyItem.IsDirtyList(list));
}
public override bool IsValid
{
get { return IsValidList(new List<object>()); }
}
public bool IsValidList(List<object> 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) && (_MyAnnotationType == null ? true : _MyAnnotationType.IsValidList(list)) && (_MyItem == null ? true : _MyItem.IsValidList(list));
return ((IsNew && !IsDirty) || base.IsValid) && (_MyAnnotationType == null || _MyAnnotationType.IsValidList(list)) && (_MyItem == null || _MyItem.IsValidList(list));
}
// CSLATODO: Replace base Annotation.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current Annotation</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check Annotation.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 Annotation</returns>
protected override object GetIdValue()
{
return MyAnnotationUnique; // Absolutely Unique ID
}
#endregion
#region ValidationRules
[NonSerialized]
// CSLATODO: Check Annotation.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 Annotation</returns>
protected override object GetIdValue() => MyAnnotationUnique; // Absolutely Unique ID
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules
{
@@ -340,8 +316,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()
@@ -362,16 +338,10 @@ namespace VEPROMS.CSLA.Library
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
//ValidationRules.AddDependantProperty("x", "y");
_AnnotationExtension.AddValidationRules(ValidationRules);
// CSLATODO: Add other validation rules
}
protected override void AddInstanceBusinessRules()
{
_AnnotationExtension.AddInstanceValidationRules(ValidationRules);
// CSLATODO: Add other validation rules
}
private static bool MyItemRequired(Annotation target, Csla.Validation.RuleArgs e)
protected override void AddInstanceBusinessRules() => _AnnotationExtension.AddInstanceValidationRules(ValidationRules);
private static bool MyItemRequired(Annotation target, Csla.Validation.RuleArgs e)
{
if (target._ItemID == 0 && target._MyItem == null) // Required field missing
{
@@ -389,98 +359,26 @@ 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(AnnotationID, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(TypeID, "<Role(s)>");
//AuthorizationRules.AllowRead(RtfText, "<Role(s)>");
//AuthorizationRules.AllowRead(SearchText, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
//AuthorizationRules.AllowWrite(TypeID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RtfText, "<Role(s)>");
//AuthorizationRules.AllowWrite(SearchText, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
_AnnotationExtension.AddAuthorizationRules(AuthorizationRules);
}
protected override void AddInstanceAuthorizationRules()
{
//CSLATODO: Who can read/write which fields
_AnnotationExtension.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; } }
private static int _AnnotationUnique = 0;
protected static int AnnotationUnique
{ get { return ++_AnnotationUnique; } }
private int _MyAnnotationUnique = AnnotationUnique;
public int MyAnnotationUnique // Absolutely Unique ID - Editable
{ get { return _MyAnnotationUnique; } }
protected static int AnnotationUnique => ++_AnnotationUnique;
private readonly int _MyAnnotationUnique = AnnotationUnique;
// Absolutely Unique ID - Editable
public int MyAnnotationUnique => _MyAnnotationUnique;
protected Annotation()
{/* require use of factory methods */
AddToCache(this);
}
private bool _Disposed = false;
private static int _CountCreated = 0;
private static readonly 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; } }
~Annotation()
public static int CountCreated => _CountCreated;
public static int CountNotDisposed => _CountCreated - _CountDisposed;
public static int CountNotFinalized => _CountCreated - _CountFinalized;
~Annotation()
{
_CountFinalized++;
}
@@ -504,8 +402,6 @@ namespace VEPROMS.CSLA.Library
}
public static Annotation New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Annotation");
try
{
return DataPortal.Create<Annotation>();
@@ -578,8 +474,6 @@ namespace VEPROMS.CSLA.Library
}
public static Annotation Get(int annotationID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Annotation");
try
{
Annotation tmp = GetCachedByPrimaryKey(annotationID);
@@ -599,37 +493,29 @@ namespace VEPROMS.CSLA.Library
{
throw new DbCslaException("Error on Annotation.Get", ex);
}
}
public static Annotation Get(SafeDataReader dr)
{
if (dr.Read()) return new Annotation(dr);
return null;
}
internal Annotation(SafeDataReader dr)
{
ReadData(dr);
}
public static void Delete(int annotationID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Annotation");
try
{
DataPortal.Delete(new PKCriteria(annotationID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on Annotation.Delete", ex);
}
}
}
public static Annotation Get(SafeDataReader dr)
{
if (dr.Read()) return new Annotation(dr);
return null;
}
internal Annotation(SafeDataReader dr)
{
ReadData(dr);
}
public static void Delete(int annotationID)
{
try
{
DataPortal.Delete(new PKCriteria(annotationID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on Annotation.Delete", ex);
}
}
public override Annotation Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Annotation");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Annotation");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a Annotation");
try
{
BuildRefreshList();
@@ -650,14 +536,10 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteria
{
private int _AnnotationID;
public int AnnotationID
{ get { return _AnnotationID; } }
public PKCriteria(int annotationID)
{
_AnnotationID = annotationID;
}
}
private readonly int _AnnotationID;
public int AnnotationID => _AnnotationID;
public PKCriteria(int annotationID) => _AnnotationID = annotationID;
}
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create()
@@ -756,43 +638,50 @@ namespace VEPROMS.CSLA.Library
[Transactional(TransactionalTypes.TransactionScope)]
internal void SQLInsert()
{
if (!this.IsDirty) return;
if (!IsDirty) return;
try
{
if (_MyAnnotationType != null) _MyAnnotationType.Update();
if (_MyItem != null) _MyItem.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandTimeout = Database.SQLTimeout;
cm.CommandText = "addAnnotation";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ItemID", ItemID);
cm.Parameters.AddWithValue("@TypeID", TypeID);
cm.Parameters.AddWithValue("@RtfText", _RtfText);
cm.Parameters.AddWithValue("@SearchText", _SearchText);
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_AnnotationID = new SqlParameter("@newAnnotationID", SqlDbType.Int);
param_AnnotationID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_AnnotationID);
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
_AnnotationID = (int)cm.Parameters["@newAnnotationID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
MarkOld();
// update child objects
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.SQLInsert", GetHashCode());
}
catch (Exception ex)
{
_MyAnnotationType?.Update();
_MyItem?.Update();
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandTimeout = Database.SQLTimeout;
cm.CommandText = "addAnnotation";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ItemID", ItemID);
cm.Parameters.AddWithValue("@TypeID", TypeID);
cm.Parameters.AddWithValue("@RtfText", _RtfText);
cm.Parameters.AddWithValue("@SearchText", _SearchText);
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_AnnotationID = new SqlParameter("@newAnnotationID", SqlDbType.Int)
{
Direction = ParameterDirection.Output
};
cm.Parameters.Add(param_AnnotationID);
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
_AnnotationID = (int)cm.Parameters["@newAnnotationID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
MarkOld();
// update child objects
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.SQLInsert", GetHashCode());
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.SQLInsert", ex);
_ErrorMessage = ex.Message;
@@ -818,13 +707,17 @@ namespace VEPROMS.CSLA.Library
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_AnnotationID = new SqlParameter("@newAnnotationID", SqlDbType.Int);
param_AnnotationID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_AnnotationID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// Output Calculated Columns
SqlParameter param_AnnotationID = new SqlParameter("@newAnnotationID", SqlDbType.Int)
{
Direction = ParameterDirection.Output
};
cm.Parameters.Add(param_AnnotationID);
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
@@ -867,41 +760,46 @@ namespace VEPROMS.CSLA.Library
if (!IsDirty) return; // If not dirty - nothing to do
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.SQLUpdate", GetHashCode());
try
{
if (_MyAnnotationType != null) _MyAnnotationType.Update();
if (_MyItem != null) _MyItem.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandTimeout = Database.SQLTimeout;
cm.CommandText = "updateAnnotation";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@AnnotationID", _AnnotationID);
cm.Parameters.AddWithValue("@ItemID", ItemID);
cm.Parameters.AddWithValue("@TypeID", TypeID);
cm.Parameters.AddWithValue("@RtfText", _RtfText);
cm.Parameters.AddWithValue("@SearchText", _SearchText);
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;
}
}
MarkOld();
// use the open connection to update child objects
}
catch (Exception ex)
{
_MyAnnotationType?.Update();
_MyItem?.Update();
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandTimeout = Database.SQLTimeout;
cm.CommandText = "updateAnnotation";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@AnnotationID", _AnnotationID);
cm.Parameters.AddWithValue("@ItemID", ItemID);
cm.Parameters.AddWithValue("@TypeID", TypeID);
cm.Parameters.AddWithValue("@RtfText", _RtfText);
cm.Parameters.AddWithValue("@SearchText", _SearchText);
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
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Annotation.SQLUpdate", ex);
_ErrorMessage = ex.Message;
@@ -910,17 +808,20 @@ 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 = Annotation.Add(cn, ref _AnnotationID, _MyItem, _MyAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID);
else
_LastChanged = Annotation.Update(cn, ref _AnnotationID, _ItemID, _TypeID, _RtfText, _SearchText, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
}
{
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
{
if (IsNew)
_LastChanged = Annotation.Add(cn, ref _AnnotationID, _MyItem, _MyAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID);
else
_LastChanged = Annotation.Update(cn, ref _AnnotationID, _ItemID, _TypeID, _RtfText, _SearchText, _Config, _DTS, _UserID, ref _LastChanged);
}
MarkOld();
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int annotationID, int itemID, int typeID, string rtfText, string searchText, string config, DateTime dts, string userID, ref byte[] lastChanged)
{
@@ -942,10 +843,12 @@ namespace VEPROMS.CSLA.Library
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);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
@@ -1029,17 +932,11 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _AnnotationID;
private readonly int _AnnotationID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int annotationID)
{
_AnnotationID = annotationID;
}
protected override void DataPortal_Execute()
public bool Exists => _exists;
public ExistsCommand(int annotationID) => _AnnotationID = annotationID;
protected override void DataPortal_Execute()
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Annotation.DataPortal_Execute", GetHashCode());
try
@@ -1065,10 +962,10 @@ namespace VEPROMS.CSLA.Library
}
}
}
#endregion
// Standard Default Code
#region extension
AnnotationExtension _AnnotationExtension = new AnnotationExtension();
#endregion
// Standard Default Code
#region extension
readonly AnnotationExtension _AnnotationExtension = new AnnotationExtension();
[Serializable()]
partial class AnnotationExtension : extensionBase
{
@@ -1076,17 +973,11 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
class extensionBase
{
// Default Values
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Volian.Base.Library.VlnSettings.UserID; }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// Default Values
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)
{
// Needs to be overriden to add new authorization rules
}
@@ -1113,57 +1004,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 Annotation)
if (destType == typeof(string) && value is Annotation ann)
{
// Return the ToString value
return ((Annotation)value).ToString();
return ann.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create AnnotationExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class Annotation
// {
// partial class AnnotationExtension : 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 */);
// }
// }
// }
//}