CSLA - M through P
This commit is contained in:
@@ -13,8 +13,6 @@ using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using Csla;
|
||||
using Csla.Data;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using Csla.Validation;
|
||||
@@ -37,10 +35,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (IsDirty)
|
||||
refreshPdfs.Add(this);
|
||||
}
|
||||
private void ClearRefreshList()
|
||||
{
|
||||
_RefreshPdfs = new List<Pdf>();
|
||||
}
|
||||
private void ClearRefreshList() => _RefreshPdfs = new List<Pdf>();
|
||||
private void BuildRefreshList()
|
||||
{
|
||||
ClearRefreshList();
|
||||
@@ -57,6 +52,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<Pdf> _CacheList = new List<Pdf>();
|
||||
protected static void AddToCache(Pdf pdf)
|
||||
{
|
||||
@@ -66,13 +62,14 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
while (_CacheList.Contains(pdf)) _CacheList.Remove(pdf); // In RemoveFromCache
|
||||
}
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static Dictionary<string, List<Pdf>> _CacheByPrimaryKey = new Dictionary<string, List<Pdf>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
while (_CacheList.Count > 0) // Move Pdf(s) from temporary _CacheList to _CacheByPrimaryKey
|
||||
{
|
||||
Pdf tmp = _CacheList[0]; // Get the first Pdf
|
||||
string pKey = tmp.DocID.ToString() + "_" + tmp.DebugStatus.ToString() + "_" + tmp.TopRow.ToString() + "_" + tmp.PageLength.ToString() + "_" + tmp.LeftMargin.ToString() + "_" + tmp.PageWidth.ToString();
|
||||
string pKey = $"{tmp.DocID}_{tmp.DebugStatus}_{tmp.TopRow}_{tmp.PageLength}_{tmp.LeftMargin}_{tmp.PageWidth}";
|
||||
if (!_CacheByPrimaryKey.ContainsKey(pKey))
|
||||
{
|
||||
_CacheByPrimaryKey[pKey] = new List<Pdf>(); // Add new list for PrimaryKey
|
||||
@@ -84,17 +81,14 @@ namespace VEPROMS.CSLA.Library
|
||||
protected static Pdf GetCachedByPrimaryKey(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth)
|
||||
{
|
||||
ConvertListToDictionary();
|
||||
string key = docID.ToString() + "_" + debugStatus.ToString() + "_" + topRow.ToString() + "_" + pageLength.ToString() + "_" + leftMargin.ToString() + "_" + pageWidth.ToString();
|
||||
string key = $"{docID}_{debugStatus}_{topRow}_{pageLength}_{leftMargin}_{pageWidth}";
|
||||
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
#region Business Methods
|
||||
private string _ErrorMessage = string.Empty;
|
||||
public string ErrorMessage
|
||||
{
|
||||
get { return _ErrorMessage; }
|
||||
}
|
||||
public string ErrorMessage => _ErrorMessage;
|
||||
private int _DocID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public int DocID
|
||||
@@ -261,37 +255,22 @@ namespace VEPROMS.CSLA.Library
|
||||
if (base.IsDirty || list.Contains(this))
|
||||
return base.IsDirty;
|
||||
list.Add(this);
|
||||
return base.IsDirty || (_MyDocument == null ? false : _MyDocument.IsDirtyList(list));
|
||||
}
|
||||
public override bool IsValid
|
||||
{
|
||||
get { return IsValidList(new List<object>()); }
|
||||
return base.IsDirty || (_MyDocument != null && _MyDocument.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) && (_MyDocument == null ? true : _MyDocument.IsValidList(list));
|
||||
return ((IsNew && !IsDirty) || base.IsValid) && (_MyDocument == null || _MyDocument.IsValidList(list));
|
||||
}
|
||||
// CSLATODO: Replace base Pdf.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current Pdf</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// CSLATODO: Check Pdf.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 Pdf</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return MyPdfUnique; // Absolutely Unique ID
|
||||
}
|
||||
protected override object GetIdValue() => MyPdfUnique; // Absolutely Unique ID
|
||||
#endregion
|
||||
#region ValidationRules
|
||||
[NonSerialized]
|
||||
@@ -319,8 +298,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()
|
||||
@@ -339,36 +318,11 @@ namespace VEPROMS.CSLA.Library
|
||||
_PdfExtension.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(DocID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DebugStatus, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(TopRow, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(PageLength, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(LeftMargin, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(PageWidth, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(PageCount, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DocPdf, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(PageCount, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DocPdf, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
||||
_PdfExtension.AddAuthorizationRules(AuthorizationRules);
|
||||
}
|
||||
protected override void AddInstanceAuthorizationRules()
|
||||
@@ -376,42 +330,14 @@ namespace VEPROMS.CSLA.Library
|
||||
//CSLATODO: Who can read/write which fields
|
||||
_PdfExtension.AddInstanceAuthorizationRules(AuthorizationRules);
|
||||
}
|
||||
public static bool CanAddObject()
|
||||
{
|
||||
// CSLATODO: Can Add Authorization
|
||||
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
|
||||
return true;
|
||||
}
|
||||
public static bool CanGetObject()
|
||||
{
|
||||
// CSLATODO: CanGet Authorization
|
||||
return true;
|
||||
}
|
||||
public static bool CanDeleteObject()
|
||||
{
|
||||
// CSLATODO: CanDelete Authorization
|
||||
//bool result = false;
|
||||
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
|
||||
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
|
||||
//return result;
|
||||
return true;
|
||||
}
|
||||
public static bool CanEditObject()
|
||||
{
|
||||
// CSLATODO: CanEdit Authorization
|
||||
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
public int CurrentEditLevel
|
||||
{ get { return EditLevel; } }
|
||||
public int CurrentEditLevel => EditLevel;
|
||||
private static int _PdfUnique = 0;
|
||||
protected static int PdfUnique
|
||||
{ get { return ++_PdfUnique; } }
|
||||
private int _MyPdfUnique = PdfUnique;
|
||||
public int MyPdfUnique // Absolutely Unique ID - Editable
|
||||
{ get { return _MyPdfUnique; } }
|
||||
protected static int PdfUnique => ++_PdfUnique;
|
||||
private readonly int _MyPdfUnique = PdfUnique;
|
||||
// Absolutely Unique ID - Editable
|
||||
public int MyPdfUnique => _MyPdfUnique;
|
||||
protected Pdf()
|
||||
{/* require use of factory methods */
|
||||
AddToCache(this);
|
||||
@@ -420,15 +346,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;
|
||||
~Pdf()
|
||||
{
|
||||
_CountFinalized++;
|
||||
@@ -453,8 +375,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static Pdf New()
|
||||
{
|
||||
if (!CanAddObject())
|
||||
throw new System.Security.SecurityException("User not authorized to add a Pdf");
|
||||
try
|
||||
{
|
||||
return DataPortal.Create<Pdf>();
|
||||
@@ -541,8 +461,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static Pdf Get(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth)
|
||||
{
|
||||
if (!CanGetObject())
|
||||
throw new System.Security.SecurityException("User not authorized to view a Pdf");
|
||||
try
|
||||
{
|
||||
Pdf tmp = GetCachedByPrimaryKey(docID, debugStatus, topRow, pageLength, leftMargin, pageWidth);
|
||||
@@ -568,14 +486,9 @@ namespace VEPROMS.CSLA.Library
|
||||
if (dr.Read()) return new Pdf(dr);
|
||||
return null;
|
||||
}
|
||||
internal Pdf(SafeDataReader dr)
|
||||
{
|
||||
ReadData(dr);
|
||||
}
|
||||
internal Pdf(SafeDataReader dr) => ReadData(dr);
|
||||
public static void Delete(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth)
|
||||
{
|
||||
if (!CanDeleteObject())
|
||||
throw new System.Security.SecurityException("User not authorized to remove a Pdf");
|
||||
try
|
||||
{
|
||||
DataPortal.Delete(new PKCriteria(docID, debugStatus, topRow, pageLength, leftMargin, pageWidth));
|
||||
@@ -587,12 +500,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public override Pdf Save()
|
||||
{
|
||||
if (IsDeleted && !CanDeleteObject())
|
||||
throw new System.Security.SecurityException("User not authorized to remove a Pdf");
|
||||
else if (IsNew && !CanAddObject())
|
||||
throw new System.Security.SecurityException("User not authorized to add a Pdf");
|
||||
else if (!CanEditObject())
|
||||
throw new System.Security.SecurityException("User not authorized to update a Pdf");
|
||||
try
|
||||
{
|
||||
BuildRefreshList();
|
||||
@@ -619,24 +526,18 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
protected class PKCriteria
|
||||
{
|
||||
private int _DocID;
|
||||
public int DocID
|
||||
{ get { return _DocID; } }
|
||||
private int _DebugStatus;
|
||||
public int DebugStatus
|
||||
{ get { return _DebugStatus; } }
|
||||
private int _TopRow;
|
||||
public int TopRow
|
||||
{ get { return _TopRow; } }
|
||||
private int _PageLength;
|
||||
public int PageLength
|
||||
{ get { return _PageLength; } }
|
||||
private int _LeftMargin;
|
||||
public int LeftMargin
|
||||
{ get { return _LeftMargin; } }
|
||||
private int _PageWidth;
|
||||
public int PageWidth
|
||||
{ get { return _PageWidth; } }
|
||||
private readonly int _DocID;
|
||||
public int DocID => _DocID;
|
||||
private readonly int _DebugStatus;
|
||||
public int DebugStatus => _DebugStatus;
|
||||
private readonly int _TopRow;
|
||||
public int TopRow => _TopRow;
|
||||
private readonly int _PageLength;
|
||||
public int PageLength => _PageLength;
|
||||
private readonly int _LeftMargin;
|
||||
public int LeftMargin => _LeftMargin;
|
||||
private readonly int _PageWidth;
|
||||
public int PageWidth => _PageWidth;
|
||||
public PKCriteria(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth)
|
||||
{
|
||||
_DocID = docID;
|
||||
@@ -752,36 +653,41 @@ namespace VEPROMS.CSLA.Library
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
internal void SQLInsert()
|
||||
{
|
||||
if (!this.IsDirty) return;
|
||||
if (!IsDirty) return;
|
||||
try
|
||||
{
|
||||
if (_MyDocument != null) _MyDocument.Update();
|
||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
_MyDocument?.Update();
|
||||
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandTimeout = Database.SQLTimeout;
|
||||
cm.CommandText = "addPdf";
|
||||
// Input All Fields - Except Calculated Columns
|
||||
cm.Parameters.AddWithValue("@DocID", DocID);
|
||||
cm.Parameters.AddWithValue("@DebugStatus", _DebugStatus);
|
||||
cm.Parameters.AddWithValue("@TopRow", _TopRow);
|
||||
cm.Parameters.AddWithValue("@PageLength", _PageLength);
|
||||
cm.Parameters.AddWithValue("@LeftMargin", _LeftMargin);
|
||||
cm.Parameters.AddWithValue("@PageWidth", _PageWidth);
|
||||
cm.Parameters.AddWithValue("@PageCount", _PageCount);
|
||||
cm.Parameters.AddWithValue("@DocPdf", _DocPdf);
|
||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||
// Output Calculated Columns
|
||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
||||
param_LastChanged.Direction = ParameterDirection.Output;
|
||||
cm.Parameters.Add(param_LastChanged);
|
||||
// CSLATODO: Define any additional output parameters
|
||||
cm.ExecuteNonQuery();
|
||||
// Save all values being returned from the Procedure
|
||||
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandTimeout = Database.SQLTimeout;
|
||||
cm.CommandText = "addPdf";
|
||||
// Input All Fields - Except Calculated Columns
|
||||
cm.Parameters.AddWithValue("@DocID", DocID);
|
||||
cm.Parameters.AddWithValue("@DebugStatus", _DebugStatus);
|
||||
cm.Parameters.AddWithValue("@TopRow", _TopRow);
|
||||
cm.Parameters.AddWithValue("@PageLength", _PageLength);
|
||||
cm.Parameters.AddWithValue("@LeftMargin", _LeftMargin);
|
||||
cm.Parameters.AddWithValue("@PageWidth", _PageWidth);
|
||||
cm.Parameters.AddWithValue("@PageCount", _PageCount);
|
||||
cm.Parameters.AddWithValue("@DocPdf", _DocPdf);
|
||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||
// Output Calculated Columns
|
||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cm.Parameters.Add(param_LastChanged);
|
||||
// CSLATODO: Define any additional output parameters
|
||||
cm.ExecuteNonQuery();
|
||||
// Save all values being returned from the Procedure
|
||||
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||
}
|
||||
}
|
||||
|
||||
MarkOld();
|
||||
// update child objects
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Pdf.SQLInsert", GetHashCode());
|
||||
@@ -816,8 +722,10 @@ namespace VEPROMS.CSLA.Library
|
||||
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
||||
cm.Parameters.AddWithValue("@UserID", userID);
|
||||
// Output Calculated Columns
|
||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
||||
param_LastChanged.Direction = ParameterDirection.Output;
|
||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cm.Parameters.Add(param_LastChanged);
|
||||
// CSLATODO: Define any additional output parameters
|
||||
cm.ExecuteNonQuery();
|
||||
@@ -861,37 +769,42 @@ namespace VEPROMS.CSLA.Library
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Pdf.SQLUpdate", GetHashCode());
|
||||
try
|
||||
{
|
||||
if (_MyDocument != null) _MyDocument.Update();
|
||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
||||
if (base.IsDirty)
|
||||
_MyDocument?.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 = "updatePdf";
|
||||
// All Fields including Calculated Fields
|
||||
cm.Parameters.AddWithValue("@DocID", DocID);
|
||||
cm.Parameters.AddWithValue("@DebugStatus", _DebugStatus);
|
||||
cm.Parameters.AddWithValue("@TopRow", _TopRow);
|
||||
cm.Parameters.AddWithValue("@PageLength", _PageLength);
|
||||
cm.Parameters.AddWithValue("@LeftMargin", _LeftMargin);
|
||||
cm.Parameters.AddWithValue("@PageWidth", _PageWidth);
|
||||
cm.Parameters.AddWithValue("@PageCount", _PageCount);
|
||||
cm.Parameters.AddWithValue("@DocPdf", _DocPdf);
|
||||
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 = "updatePdf";
|
||||
// All Fields including Calculated Fields
|
||||
cm.Parameters.AddWithValue("@DocID", DocID);
|
||||
cm.Parameters.AddWithValue("@DebugStatus", _DebugStatus);
|
||||
cm.Parameters.AddWithValue("@TopRow", _TopRow);
|
||||
cm.Parameters.AddWithValue("@PageLength", _PageLength);
|
||||
cm.Parameters.AddWithValue("@LeftMargin", _LeftMargin);
|
||||
cm.Parameters.AddWithValue("@PageWidth", _PageWidth);
|
||||
cm.Parameters.AddWithValue("@PageCount", _PageCount);
|
||||
cm.Parameters.AddWithValue("@DocPdf", _DocPdf);
|
||||
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
|
||||
}
|
||||
@@ -904,14 +817,17 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
internal void Update()
|
||||
{
|
||||
if (!this.IsDirty) return;
|
||||
if (!IsDirty) return;
|
||||
if (base.IsDirty)
|
||||
{
|
||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
||||
if (IsNew)
|
||||
_LastChanged = Pdf.Add(cn, _MyDocument, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth, _PageCount, _DocPdf, _DTS, _UserID);
|
||||
else
|
||||
_LastChanged = Pdf.Update(cn, _DocID, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth, _PageCount, _DocPdf, _DTS, _UserID, ref _LastChanged);
|
||||
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||
{
|
||||
if (IsNew)
|
||||
_LastChanged = Pdf.Add(cn, _MyDocument, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth, _PageCount, _DocPdf, _DTS, _UserID);
|
||||
else
|
||||
_LastChanged = Pdf.Update(cn, _DocID, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth, _PageCount, _DocPdf, _DTS, _UserID, ref _LastChanged);
|
||||
}
|
||||
|
||||
MarkOld();
|
||||
}
|
||||
}
|
||||
@@ -939,8 +855,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();
|
||||
@@ -1035,17 +953,14 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
private class ExistsCommand : CommandBase
|
||||
{
|
||||
private int _DocID;
|
||||
private int _DebugStatus;
|
||||
private int _TopRow;
|
||||
private int _PageLength;
|
||||
private int _LeftMargin;
|
||||
private int _PageWidth;
|
||||
private readonly int _DocID;
|
||||
private readonly int _DebugStatus;
|
||||
private readonly int _TopRow;
|
||||
private readonly int _PageLength;
|
||||
private readonly int _LeftMargin;
|
||||
private readonly int _PageWidth;
|
||||
private bool _exists;
|
||||
public bool Exists
|
||||
{
|
||||
get { return _exists; }
|
||||
}
|
||||
public bool Exists => _exists;
|
||||
public ExistsCommand(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth)
|
||||
{
|
||||
_DocID = docID;
|
||||
@@ -1089,7 +1004,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
// Standard Default Code
|
||||
#region extension
|
||||
PdfExtension _PdfExtension = new PdfExtension();
|
||||
readonly PdfExtension _PdfExtension = new PdfExtension();
|
||||
[Serializable()]
|
||||
partial class PdfExtension : extensionBase
|
||||
{
|
||||
@@ -1098,14 +1013,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)
|
||||
{
|
||||
@@ -1134,57 +1043,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 Pdf)
|
||||
if (destType == typeof(string) && value is Pdf mypdf)
|
||||
{
|
||||
// Return the ToString value
|
||||
return ((Pdf)value).ToString();
|
||||
return mypdf.ToString();
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destType);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
} // Namespace
|
||||
|
||||
|
||||
//// The following is a sample Extension File. You can use it to create PdfExt.cs
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Text;
|
||||
//using Csla;
|
||||
|
||||
//namespace VEPROMS.CSLA.Library
|
||||
//{
|
||||
// public partial class Pdf
|
||||
// {
|
||||
// partial class PdfExtension : 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 */);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user