CSLA - Is
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;
|
||||
namespace VEPROMS.CSLA.Library
|
||||
@@ -28,14 +26,12 @@ namespace VEPROMS.CSLA.Library
|
||||
public partial class ItemAuditInfo : ReadOnlyBase<ItemAuditInfo>, IDisposable
|
||||
{
|
||||
public event ItemAuditInfoEvent Changed;
|
||||
private void OnChange()
|
||||
{
|
||||
if (Changed != null) Changed(this);
|
||||
}
|
||||
private void OnChange() => Changed?.Invoke(this);
|
||||
#region Log4Net
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#endregion
|
||||
#region Collection
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static List<ItemAuditInfo> _CacheList = new List<ItemAuditInfo>();
|
||||
protected static void AddToCache(ItemAuditInfo itemAuditInfo)
|
||||
{
|
||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
while (_CacheList.Contains(itemAuditInfo)) _CacheList.Remove(itemAuditInfo); // In RemoveFromCache
|
||||
}
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static Dictionary<string, List<ItemAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ItemAuditInfo>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
@@ -74,21 +71,8 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
#region Business Methods
|
||||
private string _ErrorMessage = string.Empty;
|
||||
public string ErrorMessage
|
||||
{
|
||||
get { return _ErrorMessage; }
|
||||
}
|
||||
public string ErrorMessage => _ErrorMessage;
|
||||
protected ItemAudit _Editable;
|
||||
private IVEHasBrokenRules HasBrokenRules
|
||||
{
|
||||
get
|
||||
{
|
||||
IVEHasBrokenRules hasBrokenRules = null;
|
||||
if (_Editable != null)
|
||||
hasBrokenRules = _Editable.HasBrokenRules;
|
||||
return hasBrokenRules;
|
||||
}
|
||||
}
|
||||
private long _AuditID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public long AuditID
|
||||
@@ -153,32 +137,19 @@ namespace VEPROMS.CSLA.Library
|
||||
return _DeleteStatus;
|
||||
}
|
||||
}
|
||||
// CSLATODO: Replace base ItemAuditInfo.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current ItemAuditInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// CSLATODO: Check ItemAuditInfo.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 ItemAuditInfo</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return MyItemAuditInfoUnique; // Absolutely Unique ID
|
||||
}
|
||||
protected override object GetIdValue() => MyItemAuditInfoUnique; // Absolutely Unique ID
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _ItemAuditInfoUnique = 0;
|
||||
private static int ItemAuditInfoUnique
|
||||
{ get { return ++_ItemAuditInfoUnique; } }
|
||||
private int _MyItemAuditInfoUnique = ItemAuditInfoUnique;
|
||||
public int MyItemAuditInfoUnique // Absolutely Unique ID - Info
|
||||
{ get { return _MyItemAuditInfoUnique; } }
|
||||
private static int ItemAuditInfoUnique => ++_ItemAuditInfoUnique;
|
||||
private readonly int _MyItemAuditInfoUnique = ItemAuditInfoUnique;
|
||||
// Absolutely Unique ID - Info
|
||||
public int MyItemAuditInfoUnique => _MyItemAuditInfoUnique;
|
||||
protected ItemAuditInfo()
|
||||
{/* require use of factory methods */
|
||||
AddToCache(this);
|
||||
@@ -187,15 +158,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;
|
||||
~ItemAuditInfo()
|
||||
{
|
||||
_CountFinalized++;
|
||||
@@ -212,10 +179,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (listItemAuditInfo.Count == 0) // If there are no items left in the list
|
||||
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
|
||||
}
|
||||
public virtual ItemAudit Get()
|
||||
{
|
||||
return _Editable = ItemAudit.Get(_AuditID);
|
||||
}
|
||||
public virtual ItemAudit Get() => _Editable = ItemAudit.Get(_AuditID);
|
||||
public static void Refresh(ItemAudit tmp)
|
||||
{
|
||||
string key = tmp.AuditID.ToString();
|
||||
@@ -237,8 +201,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static ItemAuditInfo Get(long auditID)
|
||||
{
|
||||
//if (!CanGetObject())
|
||||
// throw new System.Security.SecurityException("User not authorized to view a ItemAudit");
|
||||
try
|
||||
{
|
||||
ItemAuditInfo tmp = GetCachedByPrimaryKey(auditID);
|
||||
@@ -277,13 +239,9 @@ 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;
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
@@ -344,7 +302,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
// Standard Refresh
|
||||
#region extension
|
||||
ItemAuditInfoExtension _ItemAuditInfoExtension = new ItemAuditInfoExtension();
|
||||
readonly ItemAuditInfoExtension _ItemAuditInfoExtension = new ItemAuditInfoExtension();
|
||||
[Serializable()]
|
||||
partial class ItemAuditInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
@@ -360,10 +318,10 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||
{
|
||||
if (destType == typeof(string) && value is ItemAuditInfo)
|
||||
if (destType == typeof(string) && value is ItemAuditInfo info)
|
||||
{
|
||||
// Return the ToString value
|
||||
return ((ItemAuditInfo)value).ToString();
|
||||
return info.ToString();
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user