CSLA - Generated - Batch - As
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;
|
||||
@@ -54,9 +52,10 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
ClearRefreshList();
|
||||
}
|
||||
#endregion
|
||||
#region Collection
|
||||
private static List<AnnotationAudit> _CacheList = new List<AnnotationAudit>();
|
||||
#endregion
|
||||
#region Collection
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static List<AnnotationAudit> _CacheList = new List<AnnotationAudit>();
|
||||
protected static void AddToCache(AnnotationAudit annotationAudit)
|
||||
{
|
||||
if (!_CacheList.Contains(annotationAudit)) _CacheList.Add(annotationAudit); // In AddToCache
|
||||
@@ -65,7 +64,8 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
while (_CacheList.Contains(annotationAudit)) _CacheList.Remove(annotationAudit); // In RemoveFromCache
|
||||
}
|
||||
private static Dictionary<string, List<AnnotationAudit>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationAudit>>();
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static Dictionary<string, List<AnnotationAudit>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationAudit>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
while (_CacheList.Count > 0) // Move AnnotationAudit(s) from temporary _CacheList to _CacheByPrimaryKey
|
||||
@@ -90,16 +90,10 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
#region Business Methods
|
||||
private string _ErrorMessage = string.Empty;
|
||||
public string ErrorMessage
|
||||
{
|
||||
get { return _ErrorMessage; }
|
||||
}
|
||||
private static int _nextAuditID = -1;
|
||||
public static int NextAuditID
|
||||
{
|
||||
get { return _nextAuditID--; }
|
||||
}
|
||||
private long _AuditID;
|
||||
public string ErrorMessage => _ErrorMessage;
|
||||
private static int _nextAuditID = -1;
|
||||
public static int NextAuditID => _nextAuditID--;
|
||||
private long _AuditID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public long AuditID
|
||||
{
|
||||
@@ -275,43 +269,18 @@ 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 AnnotationAudit.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current AnnotationAudit</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// CSLATODO: Check AnnotationAudit.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 AnnotationAudit</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return MyAnnotationAuditUnique; // Absolutely Unique ID
|
||||
}
|
||||
#endregion
|
||||
#region ValidationRules
|
||||
[NonSerialized]
|
||||
public override bool IsDirty => base.IsDirty;
|
||||
public override bool IsValid => (IsNew && !IsDirty) || base.IsValid;
|
||||
|
||||
// CSLATODO: Check AnnotationAudit.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 AnnotationAudit</returns>
|
||||
protected override object GetIdValue() => MyAnnotationAuditUnique; // Absolutely Unique ID
|
||||
#endregion
|
||||
#region ValidationRules
|
||||
[NonSerialized]
|
||||
private bool _CheckingBrokenRules = false;
|
||||
public IVEHasBrokenRules HasBrokenRules
|
||||
{
|
||||
@@ -336,8 +305,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()
|
||||
@@ -356,93 +325,15 @@ namespace VEPROMS.CSLA.Library
|
||||
ValidationRules.AddRule(
|
||||
Csla.Validation.CommonRules.StringMaxLength,
|
||||
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 200));
|
||||
//ValidationRules.AddDependantProperty("x", "y");
|
||||
_AnnotationAuditExtension.AddValidationRules(ValidationRules);
|
||||
// CSLATODO: Add other validation rules
|
||||
}
|
||||
protected override void AddInstanceBusinessRules()
|
||||
{
|
||||
_AnnotationAuditExtension.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(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.AllowRead(DeleteStatus, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(AnnotationID, "<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)>");
|
||||
//AuthorizationRules.AllowWrite(DeleteStatus, "<Role(s)>");
|
||||
_AnnotationAuditExtension.AddAuthorizationRules(AuthorizationRules);
|
||||
}
|
||||
protected override void AddInstanceAuthorizationRules()
|
||||
{
|
||||
//CSLATODO: Who can read/write which fields
|
||||
_AnnotationAuditExtension.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 _AnnotationAuditUnique = 0;
|
||||
protected static int AnnotationAuditUnique
|
||||
{ get { return ++_AnnotationAuditUnique; } }
|
||||
private int _MyAnnotationAuditUnique = AnnotationAuditUnique;
|
||||
public int MyAnnotationAuditUnique // Absolutely Unique ID - Editable
|
||||
{ get { return _MyAnnotationAuditUnique; } }
|
||||
protected static int AnnotationAuditUnique => ++_AnnotationAuditUnique;
|
||||
private readonly int _MyAnnotationAuditUnique = AnnotationAuditUnique;
|
||||
// Absolutely Unique ID - Editable
|
||||
public int MyAnnotationAuditUnique => _MyAnnotationAuditUnique;
|
||||
protected AnnotationAudit()
|
||||
{/* require use of factory methods */
|
||||
AddToCache(this);
|
||||
@@ -451,16 +342,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; } }
|
||||
~AnnotationAudit()
|
||||
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;
|
||||
~AnnotationAudit()
|
||||
{
|
||||
_CountFinalized++;
|
||||
}
|
||||
@@ -484,8 +371,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static AnnotationAudit New()
|
||||
{
|
||||
if (!CanAddObject())
|
||||
throw new System.Security.SecurityException("User not authorized to add a AnnotationAudit");
|
||||
try
|
||||
{
|
||||
return DataPortal.Create<AnnotationAudit>();
|
||||
@@ -531,15 +416,13 @@ namespace VEPROMS.CSLA.Library
|
||||
tmp._ErrorMessage = "Failed Validation:";
|
||||
foreach (Csla.Validation.BrokenRule br in brc)
|
||||
{
|
||||
tmp._ErrorMessage += "\r\n\tFailure: " + br.RuleName;
|
||||
tmp._ErrorMessage += $"\r\n\tFailure: {br.RuleName}";
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
public static AnnotationAudit Get(long auditID)
|
||||
{
|
||||
if (!CanGetObject())
|
||||
throw new System.Security.SecurityException("User not authorized to view a AnnotationAudit");
|
||||
try
|
||||
{
|
||||
AnnotationAudit tmp = GetCachedByPrimaryKey(auditID);
|
||||
@@ -559,20 +442,15 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
throw new DbCslaException("Error on AnnotationAudit.Get", ex);
|
||||
}
|
||||
}
|
||||
public static AnnotationAudit Get(SafeDataReader dr)
|
||||
}
|
||||
public static AnnotationAudit Get(SafeDataReader dr)
|
||||
{
|
||||
if (dr.Read()) return new AnnotationAudit(dr);
|
||||
return null;
|
||||
}
|
||||
internal AnnotationAudit(SafeDataReader dr) => ReadData(dr);
|
||||
public static void Delete(long auditID)
|
||||
{
|
||||
if (dr.Read()) return new AnnotationAudit(dr);
|
||||
return null;
|
||||
}
|
||||
internal AnnotationAudit(SafeDataReader dr)
|
||||
{
|
||||
ReadData(dr);
|
||||
}
|
||||
public static void Delete(long auditID)
|
||||
{
|
||||
if (!CanDeleteObject())
|
||||
throw new System.Security.SecurityException("User not authorized to remove a AnnotationAudit");
|
||||
try
|
||||
{
|
||||
DataPortal.Delete(new PKCriteria(auditID));
|
||||
@@ -584,12 +462,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public override AnnotationAudit Save()
|
||||
{
|
||||
if (IsDeleted && !CanDeleteObject())
|
||||
throw new System.Security.SecurityException("User not authorized to remove a AnnotationAudit");
|
||||
else if (IsNew && !CanAddObject())
|
||||
throw new System.Security.SecurityException("User not authorized to add a AnnotationAudit");
|
||||
else if (!CanEditObject())
|
||||
throw new System.Security.SecurityException("User not authorized to update a AnnotationAudit");
|
||||
try
|
||||
{
|
||||
BuildRefreshList();
|
||||
@@ -609,14 +481,10 @@ 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()]
|
||||
private new void DataPortal_Create()
|
||||
@@ -715,39 +583,44 @@ 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())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandTimeout = Database.SQLTimeout;
|
||||
cm.CommandText = "addAnnotationAudit";
|
||||
// Input All Fields - Except Calculated Columns
|
||||
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("@DeleteStatus", _DeleteStatus);
|
||||
// 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;
|
||||
}
|
||||
MarkOld();
|
||||
// update child objects
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAudit.SQLInsert", GetHashCode());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandTimeout = Database.SQLTimeout;
|
||||
cm.CommandText = "addAnnotationAudit";
|
||||
// Input All Fields - Except Calculated Columns
|
||||
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("@DeleteStatus", _DeleteStatus);
|
||||
// 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}] AnnotationAudit.SQLInsert", GetHashCode());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAudit.SQLInsert", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
@@ -775,10 +648,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("@DeleteStatus", deleteStatus);
|
||||
// Output Calculated Columns
|
||||
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt);
|
||||
param_AuditID.Direction = ParameterDirection.Output;
|
||||
cm.Parameters.Add(param_AuditID);
|
||||
// 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
|
||||
@@ -821,36 +696,39 @@ namespace VEPROMS.CSLA.Library
|
||||
if (!IsDirty) return; // If not dirty - nothing to do
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAudit.SQLUpdate", GetHashCode());
|
||||
try
|
||||
{
|
||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
||||
if (base.IsDirty)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandTimeout = Database.SQLTimeout;
|
||||
cm.CommandText = "updateAnnotationAudit";
|
||||
// All Fields including Calculated Fields
|
||||
cm.Parameters.AddWithValue("@AuditID", _AuditID);
|
||||
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("@DeleteStatus", _DeleteStatus);
|
||||
// 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
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
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 = "updateAnnotationAudit";
|
||||
// All Fields including Calculated Fields
|
||||
cm.Parameters.AddWithValue("@AuditID", _AuditID);
|
||||
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("@DeleteStatus", _DeleteStatus);
|
||||
// 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
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAudit.SQLUpdate", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
@@ -859,17 +737,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)
|
||||
AnnotationAudit.Add(cn, ref _AuditID, _AnnotationID, _ItemID, _TypeID, _RtfText, _SearchText, _Config, _DTS, _UserID, _DeleteStatus);
|
||||
else
|
||||
AnnotationAudit.Update(cn, ref _AuditID, _AnnotationID, _ItemID, _TypeID, _RtfText, _SearchText, _Config, _DTS, _UserID, _DeleteStatus);
|
||||
MarkOld();
|
||||
}
|
||||
}
|
||||
{
|
||||
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||
{
|
||||
if (IsNew)
|
||||
AnnotationAudit.Add(cn, ref _AuditID, _AnnotationID, _ItemID, _TypeID, _RtfText, _SearchText, _Config, _DTS, _UserID, _DeleteStatus);
|
||||
else
|
||||
AnnotationAudit.Update(cn, ref _AuditID, _AnnotationID, _ItemID, _TypeID, _RtfText, _SearchText, _Config, _DTS, _UserID, _DeleteStatus);
|
||||
}
|
||||
|
||||
MarkOld();
|
||||
}
|
||||
}
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
public static void Update(SqlConnection cn, ref long auditID, int annotationID, int itemID, int typeID, string rtfText, string searchText, string config, DateTime dts, string userID, int deleteStatus)
|
||||
{
|
||||
@@ -976,17 +857,11 @@ 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;
|
||||
}
|
||||
protected override void DataPortal_Execute()
|
||||
public bool Exists => _exists;
|
||||
public ExistsCommand(long auditID) => _AuditID = auditID;
|
||||
protected override void DataPortal_Execute()
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAudit.DataPortal_Execute", GetHashCode());
|
||||
try
|
||||
@@ -1012,10 +887,10 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
// Standard Default Code
|
||||
#region extension
|
||||
AnnotationAuditExtension _AnnotationAuditExtension = new AnnotationAuditExtension();
|
||||
#endregion
|
||||
// Standard Default Code
|
||||
#region extension
|
||||
readonly AnnotationAuditExtension _AnnotationAuditExtension = new AnnotationAuditExtension();
|
||||
[Serializable()]
|
||||
partial class AnnotationAuditExtension : extensionBase
|
||||
{
|
||||
@@ -1052,49 +927,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 AnnotationAudit)
|
||||
if (destType == typeof(string) && value is AnnotationAudit audit)
|
||||
{
|
||||
// Return the ToString value
|
||||
return ((AnnotationAudit)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 AnnotationAuditExt.cs
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Text;
|
||||
//using Csla;
|
||||
|
||||
//namespace VEPROMS.CSLA.Library
|
||||
//{
|
||||
// public partial class AnnotationAudit
|
||||
// {
|
||||
// partial class AnnotationAuditExtension : extensionBase
|
||||
// {
|
||||
// // CSLATODO: Override automatic defaults
|
||||
// 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 */);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user