CLSA - Ds
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 DocumentInfo : ReadOnlyBase<DocumentInfo>, IDisposable
|
||||
{
|
||||
public event DocumentInfoEvent 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<DocumentInfo> _CacheList = new List<DocumentInfo>();
|
||||
protected static void AddToCache(DocumentInfo documentInfo)
|
||||
{
|
||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
while (_CacheList.Contains(documentInfo)) _CacheList.Remove(documentInfo); // In RemoveFromCache
|
||||
}
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static Dictionary<string, List<DocumentInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocumentInfo>>();
|
||||
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 Document _Editable;
|
||||
private IVEHasBrokenRules HasBrokenRules
|
||||
{
|
||||
get
|
||||
{
|
||||
IVEHasBrokenRules hasBrokenRules = null;
|
||||
if (_Editable != null)
|
||||
hasBrokenRules = _Editable.HasBrokenRules;
|
||||
return hasBrokenRules;
|
||||
}
|
||||
}
|
||||
private int _DocID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public int DocID
|
||||
@@ -276,32 +260,19 @@ namespace VEPROMS.CSLA.Library
|
||||
foreach (DocumentInfo tmp in _CacheByPrimaryKey[_DocID.ToString()])
|
||||
tmp._DocumentPdfCount = -1; // This will cause the data to be requeried
|
||||
}
|
||||
// CSLATODO: Replace base DocumentInfo.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current DocumentInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// CSLATODO: Check DocumentInfo.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 DocumentInfo</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return MyDocumentInfoUnique; // Absolutely Unique ID
|
||||
}
|
||||
protected override object GetIdValue() => MyDocumentInfoUnique; // Absolutely Unique ID
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _DocumentInfoUnique = 0;
|
||||
private static int DocumentInfoUnique
|
||||
{ get { return ++_DocumentInfoUnique; } }
|
||||
private int _MyDocumentInfoUnique = DocumentInfoUnique;
|
||||
public int MyDocumentInfoUnique // Absolutely Unique ID - Info
|
||||
{ get { return _MyDocumentInfoUnique; } }
|
||||
private static int DocumentInfoUnique => ++_DocumentInfoUnique;
|
||||
private readonly int _MyDocumentInfoUnique = DocumentInfoUnique;
|
||||
// Absolutely Unique ID - Info
|
||||
public int MyDocumentInfoUnique => _MyDocumentInfoUnique;
|
||||
protected DocumentInfo()
|
||||
{/* require use of factory methods */
|
||||
AddToCache(this);
|
||||
@@ -310,15 +281,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;
|
||||
~DocumentInfo()
|
||||
{
|
||||
_CountFinalized++;
|
||||
@@ -335,10 +302,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (listDocumentInfo.Count == 0) // If there are no items left in the list
|
||||
_CacheByPrimaryKey.Remove(DocID.ToString()); // remove the list
|
||||
}
|
||||
public virtual Document Get()
|
||||
{
|
||||
return _Editable = Document.Get(_DocID);
|
||||
}
|
||||
public virtual Document Get() => _Editable = Document.Get(_DocID);
|
||||
public static void Refresh(Document tmp)
|
||||
{
|
||||
string key = tmp.DocID.ToString();
|
||||
@@ -361,8 +325,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static DocumentInfo Get(int docID)
|
||||
{
|
||||
//if (!CanGetObject())
|
||||
// throw new System.Security.SecurityException("User not authorized to view a Document");
|
||||
try
|
||||
{
|
||||
DocumentInfo tmp = GetCachedByPrimaryKey(docID);
|
||||
@@ -401,13 +363,9 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
protected class PKCriteria
|
||||
{
|
||||
private int _DocID;
|
||||
public int DocID
|
||||
{ get { return _DocID; } }
|
||||
public PKCriteria(int docID)
|
||||
{
|
||||
_DocID = docID;
|
||||
}
|
||||
private readonly int _DocID;
|
||||
public int DocID => _DocID;
|
||||
public PKCriteria(int docID) => _DocID = docID;
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
@@ -472,7 +430,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
// Standard Refresh
|
||||
#region extension
|
||||
DocumentInfoExtension _DocumentInfoExtension = new DocumentInfoExtension();
|
||||
readonly DocumentInfoExtension _DocumentInfoExtension = new DocumentInfoExtension();
|
||||
[Serializable()]
|
||||
partial class DocumentInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
@@ -488,10 +446,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 DocumentInfo)
|
||||
if (destType == typeof(string) && value is DocumentInfo info)
|
||||
{
|
||||
// Return the ToString value
|
||||
return ((DocumentInfo)value).ToString();
|
||||
return info.ToString();
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user