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 DocVersionInfo : ReadOnlyBase<DocVersionInfo>, IDisposable
|
||||
{
|
||||
public event DocVersionInfoEvent 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<DocVersionInfo> _CacheList = new List<DocVersionInfo>();
|
||||
protected static void AddToCache(DocVersionInfo docVersionInfo)
|
||||
{
|
||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
while (_CacheList.Contains(docVersionInfo)) _CacheList.Remove(docVersionInfo); // In RemoveFromCache
|
||||
}
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static Dictionary<string, List<DocVersionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocVersionInfo>>();
|
||||
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 DocVersion _Editable;
|
||||
private IVEHasBrokenRules HasBrokenRules
|
||||
{
|
||||
get
|
||||
{
|
||||
IVEHasBrokenRules hasBrokenRules = null;
|
||||
if (_Editable != null)
|
||||
hasBrokenRules = _Editable.HasBrokenRules;
|
||||
return hasBrokenRules;
|
||||
}
|
||||
}
|
||||
private int _VersionID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public int VersionID
|
||||
@@ -252,32 +236,19 @@ namespace VEPROMS.CSLA.Library
|
||||
foreach (DocVersionInfo tmp in _CacheByPrimaryKey[_VersionID.ToString()])
|
||||
tmp._DocVersionAssociationCount = -1; // This will cause the data to be requeried
|
||||
}
|
||||
// CSLATODO: Replace base DocVersionInfo.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current DocVersionInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// CSLATODO: Check DocVersionInfo.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 DocVersionInfo</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return MyDocVersionInfoUnique; // Absolutely Unique ID
|
||||
}
|
||||
protected override object GetIdValue() => MyDocVersionInfoUnique; // Absolutely Unique ID
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _DocVersionInfoUnique = 0;
|
||||
private static int DocVersionInfoUnique
|
||||
{ get { return ++_DocVersionInfoUnique; } }
|
||||
private int _MyDocVersionInfoUnique = DocVersionInfoUnique;
|
||||
public int MyDocVersionInfoUnique // Absolutely Unique ID - Info
|
||||
{ get { return _MyDocVersionInfoUnique; } }
|
||||
private static int DocVersionInfoUnique => ++_DocVersionInfoUnique;
|
||||
private readonly int _MyDocVersionInfoUnique = DocVersionInfoUnique;
|
||||
// Absolutely Unique ID - Info
|
||||
public int MyDocVersionInfoUnique => _MyDocVersionInfoUnique;
|
||||
protected DocVersionInfo()
|
||||
{/* require use of factory methods */
|
||||
AddToCache(this);
|
||||
@@ -286,15 +257,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;
|
||||
~DocVersionInfo()
|
||||
{
|
||||
_CountFinalized++;
|
||||
@@ -311,10 +278,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (listDocVersionInfo.Count == 0) // If there are no items left in the list
|
||||
_CacheByPrimaryKey.Remove(VersionID.ToString()); // remove the list
|
||||
}
|
||||
public virtual DocVersion Get()
|
||||
{
|
||||
return _Editable = DocVersion.Get(_VersionID);
|
||||
}
|
||||
public virtual DocVersion Get() => _Editable = DocVersion.Get(_VersionID);
|
||||
public static void Refresh(DocVersion tmp)
|
||||
{
|
||||
string key = tmp.VersionID.ToString();
|
||||
@@ -327,28 +291,28 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_FolderID != tmp.FolderID)
|
||||
{
|
||||
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for old value
|
||||
MyFolder?.RefreshFolderDocVersions(); // Update List for old value
|
||||
_FolderID = tmp.FolderID; // Update the value
|
||||
}
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for new value
|
||||
MyFolder?.RefreshFolderDocVersions(); // Update List for new value
|
||||
_VersionType = tmp.VersionType;
|
||||
_Name = tmp.Name;
|
||||
_Title = tmp.Title;
|
||||
if (_ItemID != tmp.ItemID)
|
||||
{
|
||||
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for old value
|
||||
MyItem?.RefreshItemDocVersions(); // Update List for old value
|
||||
_ItemID = tmp.ItemID; // Update the value
|
||||
}
|
||||
_MyItem = null; // Reset list so that the next line gets a new list
|
||||
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for new value
|
||||
MyItem?.RefreshItemDocVersions(); // Update List for new value
|
||||
if (_FormatID != tmp.FormatID)
|
||||
{
|
||||
if (MyFormat != null) MyFormat.RefreshFormatDocVersions(); // Update List for old value
|
||||
MyFormat?.RefreshFormatDocVersions(); // 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.RefreshFormatDocVersions(); // Update List for new value
|
||||
MyFormat?.RefreshFormatDocVersions(); // Update List for new value
|
||||
_Config = tmp.Config;
|
||||
_DTS = tmp.DTS;
|
||||
_UserID = tmp.UserID;
|
||||
@@ -370,18 +334,18 @@ namespace VEPROMS.CSLA.Library
|
||||
_Title = tmp.Title;
|
||||
if (_ItemID != tmp.ItemID)
|
||||
{
|
||||
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for old value
|
||||
MyItem?.RefreshItemDocVersions(); // Update List for old value
|
||||
_ItemID = tmp.ItemID; // Update the value
|
||||
}
|
||||
_MyItem = null; // Reset list so that the next line gets a new list
|
||||
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for new value
|
||||
MyItem?.RefreshItemDocVersions(); // Update List for new value
|
||||
if (_FormatID != tmp.FormatID)
|
||||
{
|
||||
if (MyFormat != null) MyFormat.RefreshFormatDocVersions(); // Update List for old value
|
||||
MyFormat?.RefreshFormatDocVersions(); // 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.RefreshFormatDocVersions(); // Update List for new value
|
||||
MyFormat?.RefreshFormatDocVersions(); // Update List for new value
|
||||
_Config = tmp.Config;
|
||||
_DTS = tmp.DTS;
|
||||
_UserID = tmp.UserID;
|
||||
@@ -400,21 +364,21 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_FolderID != tmp.FolderID)
|
||||
{
|
||||
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for old value
|
||||
MyFolder?.RefreshFolderDocVersions(); // Update List for old value
|
||||
_FolderID = tmp.FolderID; // Update the value
|
||||
}
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for new value
|
||||
MyFolder?.RefreshFolderDocVersions(); // Update List for new value
|
||||
_VersionType = tmp.VersionType;
|
||||
_Name = tmp.Name;
|
||||
_Title = tmp.Title;
|
||||
if (_ItemID != tmp.ItemID)
|
||||
{
|
||||
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for old value
|
||||
MyItem?.RefreshItemDocVersions(); // Update List for old value
|
||||
_ItemID = tmp.ItemID; // Update the value
|
||||
}
|
||||
_MyItem = null; // Reset list so that the next line gets a new list
|
||||
if (MyItem != null) MyItem.RefreshItemDocVersions(); // Update List for new value
|
||||
MyItem?.RefreshItemDocVersions(); // Update List for new value
|
||||
_Config = tmp.Config;
|
||||
_DTS = tmp.DTS;
|
||||
_UserID = tmp.UserID;
|
||||
@@ -433,21 +397,21 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_FolderID != tmp.FolderID)
|
||||
{
|
||||
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for old value
|
||||
MyFolder?.RefreshFolderDocVersions(); // Update List for old value
|
||||
_FolderID = tmp.FolderID; // Update the value
|
||||
}
|
||||
_MyFolder = null; // Reset list so that the next line gets a new list
|
||||
if (MyFolder != null) MyFolder.RefreshFolderDocVersions(); // Update List for new value
|
||||
MyFolder?.RefreshFolderDocVersions(); // Update List for new value
|
||||
_VersionType = tmp.VersionType;
|
||||
_Name = tmp.Name;
|
||||
_Title = tmp.Title;
|
||||
if (_FormatID != tmp.FormatID)
|
||||
{
|
||||
if (MyFormat != null) MyFormat.RefreshFormatDocVersions(); // Update List for old value
|
||||
MyFormat?.RefreshFormatDocVersions(); // 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.RefreshFormatDocVersions(); // Update List for new value
|
||||
MyFormat?.RefreshFormatDocVersions(); // Update List for new value
|
||||
_Config = tmp.Config;
|
||||
_DTS = tmp.DTS;
|
||||
_UserID = tmp.UserID;
|
||||
@@ -456,8 +420,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static DocVersionInfo Get(int versionID)
|
||||
{
|
||||
//if (!CanGetObject())
|
||||
// throw new System.Security.SecurityException("User not authorized to view a DocVersion");
|
||||
try
|
||||
{
|
||||
DocVersionInfo tmp = GetCachedByPrimaryKey(versionID);
|
||||
@@ -496,13 +458,9 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
protected class PKCriteria
|
||||
{
|
||||
private int _VersionID;
|
||||
public int VersionID
|
||||
{ get { return _VersionID; } }
|
||||
public PKCriteria(int versionID)
|
||||
{
|
||||
_VersionID = versionID;
|
||||
}
|
||||
private readonly int _VersionID;
|
||||
public int VersionID => _VersionID;
|
||||
public PKCriteria(int versionID) => _VersionID = versionID;
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
@@ -567,7 +525,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
// Standard Refresh
|
||||
#region extension
|
||||
DocVersionInfoExtension _DocVersionInfoExtension = new DocVersionInfoExtension();
|
||||
readonly DocVersionInfoExtension _DocVersionInfoExtension = new DocVersionInfoExtension();
|
||||
[Serializable()]
|
||||
partial class DocVersionInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
@@ -583,10 +541,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 DocVersionInfo)
|
||||
if (destType == typeof(string) && value is DocVersionInfo info)
|
||||
{
|
||||
// Return the ToString value
|
||||
return ((DocVersionInfo)value).ToString();
|
||||
return info.ToString();
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user