CSLA - Is
This commit is contained in:
@@ -13,11 +13,8 @@ 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 Volian.Base.Library;
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public delegate void ItemInfoEvent(object sender);
|
||||
@@ -29,27 +26,17 @@ namespace VEPROMS.CSLA.Library
|
||||
public partial class ItemInfo : ReadOnlyBase<ItemInfo>, IDisposable
|
||||
{
|
||||
public event ItemInfoEvent 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<ItemInfo> _CacheList = new List<ItemInfo>();
|
||||
protected static void AddToCache(ItemInfo itemInfo)
|
||||
{
|
||||
if (!_CacheList.Contains(itemInfo))
|
||||
_CacheList.Add(itemInfo); // In AddToCache
|
||||
//try
|
||||
//{
|
||||
// _CacheList.Add(itemInfo); // In AddToCache
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// _MyLog.ErrorFormat("ItemInfo {0}.{1} already exists in the cache", itemInfo.ItemID, itemInfo.MyItemInfoUnique);
|
||||
//}
|
||||
_CacheList.Add(itemInfo);
|
||||
}
|
||||
protected static void RemoveFromCache(ItemInfo itemInfo)
|
||||
{
|
||||
@@ -84,10 +71,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
#region Business Methods
|
||||
private string _ErrorMessage = string.Empty;
|
||||
public string ErrorMessage
|
||||
{
|
||||
get { return _ErrorMessage; }
|
||||
}
|
||||
public string ErrorMessage => _ErrorMessage;
|
||||
protected Item _Editable;
|
||||
private IVEHasBrokenRules HasBrokenRules
|
||||
{
|
||||
@@ -259,10 +243,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
private class PreviousIDCriteria
|
||||
{
|
||||
public PreviousIDCriteria(int? previousID)
|
||||
{
|
||||
_PreviousID = previousID;
|
||||
}
|
||||
public PreviousIDCriteria(int? previousID) => _PreviousID = previousID;
|
||||
private int? _PreviousID;
|
||||
public int? PreviousID
|
||||
{
|
||||
@@ -469,24 +450,12 @@ namespace VEPROMS.CSLA.Library
|
||||
foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()])
|
||||
tmp._ItemTransition_ToIDCount = -1; // This will cause the data to be requeried
|
||||
}
|
||||
// CSLATODO: Replace base ItemInfo.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current ItemInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// CSLATODO: Check ItemInfo.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 ItemInfo</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return MyItemInfoUnique; // Absolutely Unique ID
|
||||
}
|
||||
protected override object GetIdValue() => MyItemInfoUnique; // Absolutely Unique ID
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _ItemInfoUnique = 0;
|
||||
@@ -500,9 +469,9 @@ namespace VEPROMS.CSLA.Library
|
||||
return ui;
|
||||
}
|
||||
}
|
||||
private int _MyItemInfoUnique = ItemInfoUnique;
|
||||
public int MyItemInfoUnique // Absolutely Unique ID - Info
|
||||
{ get { return _MyItemInfoUnique; } }
|
||||
private readonly int _MyItemInfoUnique = ItemInfoUnique;
|
||||
// Absolutely Unique ID - Info
|
||||
public int MyItemInfoUnique => _MyItemInfoUnique;
|
||||
protected ItemInfo()
|
||||
{/* require use of factory methods */
|
||||
//AddToCache(this);
|
||||
@@ -511,15 +480,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;
|
||||
~ItemInfo()
|
||||
{
|
||||
_CountFinalized++;
|
||||
@@ -540,21 +505,8 @@ namespace VEPROMS.CSLA.Library
|
||||
_MyContent = null;
|
||||
if (_MyPrevious != null)
|
||||
_MyPrevious = null;
|
||||
//if (_ActiveFormat != null)
|
||||
// _ActiveFormat = null;
|
||||
//if (_ActiveParent != null)
|
||||
// _ActiveParent = null;
|
||||
//if (_ActiveSection != null)
|
||||
// _ActiveSection = null;
|
||||
//if (_MyDocVersion != null)
|
||||
// _MyDocVersion = null;
|
||||
//if (_ParentNoteOrCaution != null)
|
||||
// _ParentNoteOrCaution = null;
|
||||
}
|
||||
public virtual Item Get()
|
||||
{
|
||||
return _Editable = Item.Get(_ItemID);
|
||||
}
|
||||
public virtual Item Get() => _Editable = Item.Get(_ItemID);
|
||||
public static void Refresh(Item tmp)
|
||||
{
|
||||
string key = tmp.ItemID.ToString();
|
||||
@@ -567,18 +519,17 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_PreviousID != tmp.PreviousID)
|
||||
{
|
||||
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for old value
|
||||
MyPrevious?.RefreshNextItems(); // Update List for old value
|
||||
_PreviousID = tmp.PreviousID; // Update the value
|
||||
}
|
||||
_MyPrevious = null; // Reset list so that the next line gets a new list
|
||||
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for new value
|
||||
//if (_ContentID != tmp.ContentID)
|
||||
//{
|
||||
if (MyContent != null) MyContent.RefreshContentItems(); // Update List for old value
|
||||
MyPrevious?.RefreshNextItems(); // Update List for new value
|
||||
|
||||
MyContent?.RefreshContentItems(); // Update List for old value
|
||||
_ContentID = tmp.ContentID; // Update the value
|
||||
//}
|
||||
|
||||
_MyContent = null; // Reset list so that the next line gets a new list
|
||||
if (MyContent != null) MyContent.RefreshContentItems(); // Update List for new value
|
||||
MyContent?.RefreshContentItems(); // Update List for new value
|
||||
_DTS = tmp.DTS;
|
||||
_UserID = tmp.UserID;
|
||||
_ItemInfoExtension.Refresh(this);
|
||||
@@ -596,11 +547,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_PreviousID != tmp.PreviousID)
|
||||
{
|
||||
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for old value
|
||||
MyPrevious?.RefreshNextItems(); // Update List for old value
|
||||
_PreviousID = tmp.PreviousID; // Update the value
|
||||
}
|
||||
_MyPrevious = null; // Reset list so that the next line gets a new list
|
||||
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for new value
|
||||
MyPrevious?.RefreshNextItems(); // Update List for new value
|
||||
_DTS = tmp.DTS;
|
||||
_UserID = tmp.UserID;
|
||||
_ItemInfoExtension.Refresh(this);
|
||||
@@ -675,13 +626,9 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
protected class PKCriteria
|
||||
{
|
||||
private int _ItemID;
|
||||
public int ItemID
|
||||
{ get { return _ItemID; } }
|
||||
public PKCriteria(int itemID)
|
||||
{
|
||||
_ItemID = itemID;
|
||||
}
|
||||
private readonly int _ItemID;
|
||||
public int ItemID => _ItemID;
|
||||
public PKCriteria(int itemID) => _ItemID = itemID;
|
||||
}
|
||||
protected void ReadData(SafeDataReader dr)
|
||||
{
|
||||
@@ -746,7 +693,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
// Standard Refresh
|
||||
#region extension
|
||||
ItemInfoExtension _ItemInfoExtension = new ItemInfoExtension();
|
||||
readonly ItemInfoExtension _ItemInfoExtension = new ItemInfoExtension();
|
||||
[Serializable()]
|
||||
partial class ItemInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
@@ -762,10 +709,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 ItemInfo)
|
||||
if (destType == typeof(string) && value is ItemInfo info)
|
||||
{
|
||||
// Return the ToString value
|
||||
return ((ItemInfo)value).ToString();
|
||||
return info.ToString();
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user