CSLA - E & F
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 FolderInfo : ReadOnlyBase<FolderInfo>, IDisposable
|
||||
{
|
||||
public event FolderInfoEvent 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<FolderInfo> _CacheList = new List<FolderInfo>();
|
||||
protected static void AddToCache(FolderInfo folderInfo)
|
||||
{
|
||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
while (_CacheList.Contains(folderInfo)) _CacheList.Remove(folderInfo); // In RemoveFromCache
|
||||
}
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static Dictionary<string, List<FolderInfo>> _CacheByPrimaryKey = new Dictionary<string, List<FolderInfo>>();
|
||||
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 Folder _Editable;
|
||||
private IVEHasBrokenRules HasBrokenRules
|
||||
{
|
||||
get
|
||||
{
|
||||
IVEHasBrokenRules hasBrokenRules = null;
|
||||
if (_Editable != null)
|
||||
hasBrokenRules = _Editable.HasBrokenRules;
|
||||
return hasBrokenRules;
|
||||
}
|
||||
}
|
||||
private int _FolderID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public int FolderID
|
||||
@@ -330,32 +314,19 @@ namespace VEPROMS.CSLA.Library
|
||||
foreach (FolderInfo tmp in _CacheByPrimaryKey[_FolderID.ToString()])
|
||||
tmp._ChildFolderCount = -1; // This will cause the data to be requeried
|
||||
}
|
||||
// CSLATODO: Replace base FolderInfo.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current FolderInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// CSLATODO: Check FolderInfo.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 FolderInfo</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return MyFolderInfoUnique; // Absolutely Unique ID
|
||||
}
|
||||
protected override object GetIdValue() => MyFolderInfoUnique; // Absolutely Unique ID
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _FolderInfoUnique = 0;
|
||||
private static int FolderInfoUnique
|
||||
{ get { return ++_FolderInfoUnique; } }
|
||||
private int _MyFolderInfoUnique = FolderInfoUnique;
|
||||
public int MyFolderInfoUnique // Absolutely Unique ID - Info
|
||||
{ get { return _MyFolderInfoUnique; } }
|
||||
private static int FolderInfoUnique => ++_FolderInfoUnique;
|
||||
private readonly int _MyFolderInfoUnique = FolderInfoUnique;
|
||||
// Absolutely Unique ID - Info
|
||||
public int MyFolderInfoUnique => _MyFolderInfoUnique;
|
||||
protected FolderInfo()
|
||||
{/* require use of factory methods */
|
||||
AddToCache(this);
|
||||
@@ -364,15 +335,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;
|
||||
~FolderInfo()
|
||||
{
|
||||
_CountFinalized++;
|
||||
@@ -389,10 +356,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (listFolderInfo.Count == 0) // If there are no items left in the list
|
||||
_CacheByPrimaryKey.Remove(FolderID.ToString()); // remove the list
|
||||
}
|
||||
public virtual Folder Get()
|
||||
{
|
||||
return _Editable = Folder.Get(_FolderID);
|
||||
}
|
||||
public virtual Folder Get() => _Editable = Folder.Get(_FolderID);
|
||||
public static void Refresh(Folder tmp)
|
||||
{
|
||||
string key = tmp.FolderID.ToString();
|
||||
@@ -405,28 +369,28 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_ParentID != tmp.ParentID)
|
||||
{
|
||||
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for old value
|
||||
MyParent?.RefreshChildFolders(); // Update List for old value
|
||||
_ParentID = tmp.ParentID; // Update the value
|
||||
}
|
||||
_MyParent = null; // Reset list so that the next line gets a new list
|
||||
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for new value
|
||||
MyParent?.RefreshChildFolders(); // Update List for new value
|
||||
if (_DBID != tmp.DBID)
|
||||
{
|
||||
if (MyConnection != null) MyConnection.RefreshConnectionFolders(); // Update List for old value
|
||||
MyConnection?.RefreshConnectionFolders(); // Update List for old value
|
||||
_DBID = tmp.DBID; // Update the value
|
||||
}
|
||||
_MyConnection = null; // Reset list so that the next line gets a new list
|
||||
if (MyConnection != null) MyConnection.RefreshConnectionFolders(); // Update List for new value
|
||||
MyConnection?.RefreshConnectionFolders(); // Update List for new value
|
||||
_Name = tmp.Name;
|
||||
_Title = tmp.Title;
|
||||
_ShortName = tmp.ShortName;
|
||||
if (_FormatID != tmp.FormatID)
|
||||
{
|
||||
if (MyFormat != null) MyFormat.RefreshFormatFolders(); // Update List for old value
|
||||
MyFormat?.RefreshFormatFolders(); // Update List for old value
|
||||
_FormatID = tmp.FormatID; // Update the value
|
||||
}
|
||||
_MyFormat = null; // Reset list so that the next line gets a new list
|
||||
if (MyFormat != null) MyFormat.RefreshFormatFolders(); // Update List for new value
|
||||
MyFormat?.RefreshFormatFolders(); // Update List for new value
|
||||
_ManualOrder = tmp.ManualOrder;
|
||||
_Config = tmp.Config;
|
||||
_DTS = tmp.DTS;
|
||||
@@ -446,21 +410,21 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_ParentID != tmp.ParentID)
|
||||
{
|
||||
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for old value
|
||||
MyParent?.RefreshChildFolders(); // Update List for old value
|
||||
_ParentID = tmp.ParentID; // Update the value
|
||||
}
|
||||
_MyParent = null; // Reset list so that the next line gets a new list
|
||||
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for new value
|
||||
MyParent?.RefreshChildFolders(); // Update List for new value
|
||||
_Name = tmp.Name;
|
||||
_Title = tmp.Title;
|
||||
_ShortName = tmp.ShortName;
|
||||
if (_FormatID != tmp.FormatID)
|
||||
{
|
||||
if (MyFormat != null) MyFormat.RefreshFormatFolders(); // Update List for old value
|
||||
MyFormat?.RefreshFormatFolders(); // Update List for old value
|
||||
_FormatID = tmp.FormatID; // Update the value
|
||||
}
|
||||
_MyFormat = null; // Reset list so that the next line gets a new list
|
||||
if (MyFormat != null) MyFormat.RefreshFormatFolders(); // Update List for new value
|
||||
MyFormat?.RefreshFormatFolders(); // Update List for new value
|
||||
_ManualOrder = tmp.ManualOrder;
|
||||
_Config = tmp.Config;
|
||||
_DTS = tmp.DTS;
|
||||
@@ -480,18 +444,18 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_ParentID != tmp.ParentID)
|
||||
{
|
||||
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for old value
|
||||
MyParent?.RefreshChildFolders(); // Update List for old value
|
||||
_ParentID = tmp.ParentID; // Update the value
|
||||
}
|
||||
_MyParent = null; // Reset list so that the next line gets a new list
|
||||
if (MyParent != null) MyParent.RefreshChildFolders(); // Update List for new value
|
||||
MyParent?.RefreshChildFolders(); // Update List for new value
|
||||
if (_DBID != tmp.DBID)
|
||||
{
|
||||
if (MyConnection != null) MyConnection.RefreshConnectionFolders(); // Update List for old value
|
||||
MyConnection?.RefreshConnectionFolders(); // Update List for old value
|
||||
_DBID = tmp.DBID; // Update the value
|
||||
}
|
||||
_MyConnection = null; // Reset list so that the next line gets a new list
|
||||
if (MyConnection != null) MyConnection.RefreshConnectionFolders(); // Update List for new value
|
||||
MyConnection?.RefreshConnectionFolders(); // Update List for new value
|
||||
_Name = tmp.Name;
|
||||
_Title = tmp.Title;
|
||||
_ShortName = tmp.ShortName;
|
||||
@@ -513,8 +477,6 @@ namespace VEPROMS.CSLA.Library
|
||||
|
||||
public static FolderInfo Get(int folderID)
|
||||
{
|
||||
//if (!CanGetObject())
|
||||
// throw new System.Security.SecurityException("User not authorized to view a Folder");
|
||||
try
|
||||
{
|
||||
FolderInfo tmp = GetCachedByPrimaryKey(folderID);
|
||||
@@ -553,13 +515,9 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
protected class PKCriteria
|
||||
{
|
||||
private int _FolderID;
|
||||
public int FolderID
|
||||
{ get { return _FolderID; } }
|
||||
public PKCriteria(int folderID)
|
||||
{
|
||||
_FolderID = folderID;
|
||||
}
|
||||
private readonly int _FolderID;
|
||||
public int FolderID => _FolderID;
|
||||
public PKCriteria(int folderID) => _FolderID = folderID;
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
@@ -627,7 +585,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
// Standard Refresh
|
||||
#region extension
|
||||
FolderInfoExtension _FolderInfoExtension = new FolderInfoExtension();
|
||||
readonly FolderInfoExtension _FolderInfoExtension = new FolderInfoExtension();
|
||||
[Serializable()]
|
||||
partial class FolderInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
@@ -643,10 +601,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 FolderInfo)
|
||||
if (destType == typeof(string) && value is FolderInfo info)
|
||||
{
|
||||
// Return the ToString value
|
||||
return ((FolderInfo)value).ToString();
|
||||
return info.ToString();
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user