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)
|
||||
refreshOwners.Add(this);
|
||||
}
|
||||
private void ClearRefreshList()
|
||||
{
|
||||
_RefreshOwners = new List<Owner>();
|
||||
}
|
||||
private void ClearRefreshList() => _RefreshOwners = new List<Owner>();
|
||||
private void BuildRefreshList()
|
||||
{
|
||||
ClearRefreshList();
|
||||
@@ -56,6 +51,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<Owner> _CacheList = new List<Owner>();
|
||||
protected static void AddToCache(Owner owner)
|
||||
{
|
||||
@@ -65,6 +61,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
while (_CacheList.Contains(owner)) _CacheList.Remove(owner); // In RemoveFromCache
|
||||
}
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static Dictionary<string, List<Owner>> _CacheByPrimaryKey = new Dictionary<string, List<Owner>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
@@ -90,15 +87,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 _nextOwnerID = -1;
|
||||
public static int NextOwnerID
|
||||
{
|
||||
get { return _nextOwnerID--; }
|
||||
}
|
||||
public static int NextOwnerID => _nextOwnerID--;
|
||||
private int _OwnerID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public int OwnerID
|
||||
@@ -182,40 +173,14 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
private byte[] _LastChanged = new byte[8];//timestamp
|
||||
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 Owner.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current Owner</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
public override bool IsDirty => base.IsDirty;
|
||||
public override bool IsValid => (IsNew && !IsDirty) || base.IsValid;
|
||||
// CSLATODO: Check Owner.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 Owner</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return MyOwnerUnique; // Absolutely Unique ID
|
||||
}
|
||||
protected override object GetIdValue() => MyOwnerUnique; // Absolutely Unique ID
|
||||
#endregion
|
||||
#region ValidationRules
|
||||
[NonSerialized]
|
||||
@@ -243,8 +208,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()
|
||||
@@ -258,31 +223,11 @@ namespace VEPROMS.CSLA.Library
|
||||
_OwnerExtension.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(OwnerID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(SessionID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(OwnerType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(OwnerItemID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTSStart, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(SessionID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(OwnerType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(OwnerItemID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTSStart, "<Role(s)>");
|
||||
_OwnerExtension.AddAuthorizationRules(AuthorizationRules);
|
||||
}
|
||||
protected override void AddInstanceAuthorizationRules()
|
||||
@@ -290,42 +235,14 @@ namespace VEPROMS.CSLA.Library
|
||||
//CSLATODO: Who can read/write which fields
|
||||
_OwnerExtension.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 _OwnerUnique = 0;
|
||||
protected static int OwnerUnique
|
||||
{ get { return ++_OwnerUnique; } }
|
||||
private int _MyOwnerUnique = OwnerUnique;
|
||||
public int MyOwnerUnique // Absolutely Unique ID - Editable
|
||||
{ get { return _MyOwnerUnique; } }
|
||||
protected static int OwnerUnique => ++_OwnerUnique;
|
||||
private readonly int _MyOwnerUnique = OwnerUnique;
|
||||
// Absolutely Unique ID - Editable
|
||||
public int MyOwnerUnique => _MyOwnerUnique;
|
||||
protected Owner()
|
||||
{/* require use of factory methods */
|
||||
AddToCache(this);
|
||||
@@ -334,15 +251,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;
|
||||
~Owner()
|
||||
{
|
||||
_CountFinalized++;
|
||||
@@ -367,8 +280,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static Owner New()
|
||||
{
|
||||
if (!CanAddObject())
|
||||
throw new System.Security.SecurityException("User not authorized to add a Owner");
|
||||
try
|
||||
{
|
||||
return DataPortal.Create<Owner>();
|
||||
@@ -405,8 +316,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static Owner Get(int ownerID)
|
||||
{
|
||||
if (!CanGetObject())
|
||||
throw new System.Security.SecurityException("User not authorized to view a Owner");
|
||||
try
|
||||
{
|
||||
Owner tmp = GetCachedByPrimaryKey(ownerID);
|
||||
@@ -432,14 +341,9 @@ namespace VEPROMS.CSLA.Library
|
||||
if (dr.Read()) return new Owner(dr);
|
||||
return null;
|
||||
}
|
||||
internal Owner(SafeDataReader dr)
|
||||
{
|
||||
ReadData(dr);
|
||||
}
|
||||
internal Owner(SafeDataReader dr) => ReadData(dr);
|
||||
public static void Delete(int ownerID)
|
||||
{
|
||||
if (!CanDeleteObject())
|
||||
throw new System.Security.SecurityException("User not authorized to remove a Owner");
|
||||
try
|
||||
{
|
||||
DataPortal.Delete(new PKCriteria(ownerID));
|
||||
@@ -451,12 +355,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public override Owner Save()
|
||||
{
|
||||
if (IsDeleted && !CanDeleteObject())
|
||||
throw new System.Security.SecurityException("User not authorized to remove a Owner");
|
||||
else if (IsNew && !CanAddObject())
|
||||
throw new System.Security.SecurityException("User not authorized to add a Owner");
|
||||
else if (!CanEditObject())
|
||||
throw new System.Security.SecurityException("User not authorized to update a Owner");
|
||||
try
|
||||
{
|
||||
BuildRefreshList();
|
||||
@@ -476,13 +374,9 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
protected class PKCriteria
|
||||
{
|
||||
private int _OwnerID;
|
||||
public int OwnerID
|
||||
{ get { return _OwnerID; } }
|
||||
public PKCriteria(int ownerID)
|
||||
{
|
||||
_OwnerID = ownerID;
|
||||
}
|
||||
private readonly int _OwnerID;
|
||||
public int OwnerID => _OwnerID;
|
||||
public PKCriteria(int ownerID) => _OwnerID = ownerID;
|
||||
}
|
||||
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
|
||||
[RunLocal()]
|
||||
@@ -581,33 +475,40 @@ 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 = "addOwner";
|
||||
// Input All Fields - Except Calculated Columns
|
||||
cm.Parameters.AddWithValue("@SessionID", _SessionID);
|
||||
cm.Parameters.AddWithValue("@OwnerType", _OwnerType);
|
||||
cm.Parameters.AddWithValue("@OwnerItemID", _OwnerItemID);
|
||||
if (_DTSStart.Year >= 1753 && _DTSStart.Year <= 9999) cm.Parameters.AddWithValue("@DTSStart", _DTSStart);
|
||||
// Output Calculated Columns
|
||||
SqlParameter param_OwnerID = new SqlParameter("@newOwnerID", SqlDbType.Int);
|
||||
param_OwnerID.Direction = ParameterDirection.Output;
|
||||
cm.Parameters.Add(param_OwnerID);
|
||||
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
|
||||
_OwnerID = (int)cm.Parameters["@newOwnerID"].Value;
|
||||
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandTimeout = Database.SQLTimeout;
|
||||
cm.CommandText = "addOwner";
|
||||
// Input All Fields - Except Calculated Columns
|
||||
cm.Parameters.AddWithValue("@SessionID", _SessionID);
|
||||
cm.Parameters.AddWithValue("@OwnerType", _OwnerType);
|
||||
cm.Parameters.AddWithValue("@OwnerItemID", _OwnerItemID);
|
||||
if (_DTSStart.Year >= 1753 && _DTSStart.Year <= 9999) cm.Parameters.AddWithValue("@DTSStart", _DTSStart);
|
||||
// Output Calculated Columns
|
||||
SqlParameter param_OwnerID = new SqlParameter("@newOwnerID", SqlDbType.Int)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cm.Parameters.Add(param_OwnerID);
|
||||
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
|
||||
_OwnerID = (int)cm.Parameters["@newOwnerID"].Value;
|
||||
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||
}
|
||||
}
|
||||
|
||||
MarkOld();
|
||||
// update child objects
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Owner.SQLInsert", GetHashCode());
|
||||
@@ -636,11 +537,15 @@ namespace VEPROMS.CSLA.Library
|
||||
cm.Parameters.AddWithValue("@OwnerItemID", ownerItemID);
|
||||
if (dTSStart.Year >= 1753 && dTSStart.Year <= 9999) cm.Parameters.AddWithValue("@DTSStart", dTSStart);
|
||||
// Output Calculated Columns
|
||||
SqlParameter param_OwnerID = new SqlParameter("@newOwnerID", SqlDbType.Int);
|
||||
param_OwnerID.Direction = ParameterDirection.Output;
|
||||
SqlParameter param_OwnerID = new SqlParameter("@newOwnerID", SqlDbType.Int)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cm.Parameters.Add(param_OwnerID);
|
||||
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();
|
||||
@@ -685,31 +590,36 @@ namespace VEPROMS.CSLA.Library
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Owner.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 = "updateOwner";
|
||||
// All Fields including Calculated Fields
|
||||
cm.Parameters.AddWithValue("@OwnerID", _OwnerID);
|
||||
cm.Parameters.AddWithValue("@SessionID", _SessionID);
|
||||
cm.Parameters.AddWithValue("@OwnerType", _OwnerType);
|
||||
cm.Parameters.AddWithValue("@OwnerItemID", _OwnerItemID);
|
||||
if (_DTSStart.Year >= 1753 && _DTSStart.Year <= 9999) cm.Parameters.AddWithValue("@DTSStart", _DTSStart);
|
||||
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 = "updateOwner";
|
||||
// All Fields including Calculated Fields
|
||||
cm.Parameters.AddWithValue("@OwnerID", _OwnerID);
|
||||
cm.Parameters.AddWithValue("@SessionID", _SessionID);
|
||||
cm.Parameters.AddWithValue("@OwnerType", _OwnerType);
|
||||
cm.Parameters.AddWithValue("@OwnerItemID", _OwnerItemID);
|
||||
if (_DTSStart.Year >= 1753 && _DTSStart.Year <= 9999) cm.Parameters.AddWithValue("@DTSStart", _DTSStart);
|
||||
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
|
||||
}
|
||||
@@ -722,14 +632,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 = Owner.Add(cn, ref _OwnerID, _SessionID, _OwnerType, _OwnerItemID, _DTSStart);
|
||||
else
|
||||
_LastChanged = Owner.Update(cn, ref _OwnerID, _SessionID, _OwnerType, _OwnerItemID, _DTSStart, ref _LastChanged);
|
||||
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||
{
|
||||
if (IsNew)
|
||||
_LastChanged = Owner.Add(cn, ref _OwnerID, _SessionID, _OwnerType, _OwnerItemID, _DTSStart);
|
||||
else
|
||||
_LastChanged = Owner.Update(cn, ref _OwnerID, _SessionID, _OwnerType, _OwnerItemID, _DTSStart, ref _LastChanged);
|
||||
}
|
||||
|
||||
MarkOld();
|
||||
}
|
||||
}
|
||||
@@ -752,8 +665,10 @@ namespace VEPROMS.CSLA.Library
|
||||
if (dTSStart.Year >= 1753 && dTSStart.Year <= 9999) cm.Parameters.AddWithValue("@DTSStart", dTSStart);
|
||||
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();
|
||||
@@ -838,16 +753,10 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
private class ExistsCommand : CommandBase
|
||||
{
|
||||
private int _OwnerID;
|
||||
private readonly int _OwnerID;
|
||||
private bool _exists;
|
||||
public bool Exists
|
||||
{
|
||||
get { return _exists; }
|
||||
}
|
||||
public ExistsCommand(int ownerID)
|
||||
{
|
||||
_OwnerID = ownerID;
|
||||
}
|
||||
public bool Exists => _exists;
|
||||
public ExistsCommand(int ownerID) => _OwnerID = ownerID;
|
||||
protected override void DataPortal_Execute()
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Owner.DataPortal_Execute", GetHashCode());
|
||||
@@ -877,7 +786,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
// Standard Default Code
|
||||
#region extension
|
||||
OwnerExtension _OwnerExtension = new OwnerExtension();
|
||||
readonly OwnerExtension _OwnerExtension = new OwnerExtension();
|
||||
[Serializable()]
|
||||
partial class OwnerExtension : extensionBase
|
||||
{
|
||||
@@ -886,22 +795,10 @@ namespace VEPROMS.CSLA.Library
|
||||
class extensionBase
|
||||
{
|
||||
// Default Values
|
||||
public virtual int DefaultSessionID
|
||||
{
|
||||
get { return 0; }
|
||||
}
|
||||
public virtual byte DefaultOwnerType
|
||||
{
|
||||
get { return 0; }
|
||||
}
|
||||
public virtual int DefaultOwnerItemID
|
||||
{
|
||||
get { return 0; }
|
||||
}
|
||||
public virtual DateTime DefaultDTSStart
|
||||
{
|
||||
get { return DateTime.Now; }
|
||||
}
|
||||
public virtual int DefaultSessionID => 0;
|
||||
public virtual byte DefaultOwnerType => 0;
|
||||
public virtual int DefaultOwnerItemID => 0;
|
||||
public virtual DateTime DefaultDTSStart => DateTime.Now;
|
||||
// Authorization Rules
|
||||
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
||||
{
|
||||
@@ -930,65 +827,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 Owner)
|
||||
if (destType == typeof(string) && value is Owner owner)
|
||||
{
|
||||
// Return the ToString value
|
||||
return ((Owner)value).ToString();
|
||||
return owner.ToString();
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destType);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
} // Namespace
|
||||
|
||||
|
||||
//// The following is a sample Extension File. You can use it to create OwnerExt.cs
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Text;
|
||||
//using Csla;
|
||||
|
||||
//namespace VEPROMS.CSLA.Library
|
||||
//{
|
||||
// public partial class Owner
|
||||
// {
|
||||
// partial class OwnerExtension : extensionBase
|
||||
// {
|
||||
// // CSLATODO: Override automatic defaults
|
||||
// public virtual int DefaultSessionID
|
||||
// {
|
||||
// get { return 0; }
|
||||
// }
|
||||
// public virtual byte DefaultOwnerType
|
||||
// {
|
||||
// get { return 0; }
|
||||
// }
|
||||
// public virtual int DefaultOwnerItemID
|
||||
// {
|
||||
// get { return 0; }
|
||||
// }
|
||||
// public virtual DateTime DefaultDTSStart
|
||||
// {
|
||||
// get { return DateTime.Now; }
|
||||
// }
|
||||
// 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