CSLA - R - Group 1
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 ROImageInfo : ReadOnlyBase<ROImageInfo>, IDisposable
|
||||
{
|
||||
public event ROImageInfoEvent 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<ROImageInfo> _CacheList = new List<ROImageInfo>();
|
||||
protected static void AddToCache(ROImageInfo rOImageInfo)
|
||||
{
|
||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
while (_CacheList.Contains(rOImageInfo)) _CacheList.Remove(rOImageInfo); // In RemoveFromCache
|
||||
}
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static Dictionary<string, List<ROImageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ROImageInfo>>();
|
||||
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 ROImage _Editable;
|
||||
private IVEHasBrokenRules HasBrokenRules
|
||||
{
|
||||
get
|
||||
{
|
||||
IVEHasBrokenRules hasBrokenRules = null;
|
||||
if (_Editable != null)
|
||||
hasBrokenRules = _Editable.HasBrokenRules;
|
||||
return hasBrokenRules;
|
||||
}
|
||||
}
|
||||
private int _ImageID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public int ImageID
|
||||
@@ -200,32 +184,19 @@ namespace VEPROMS.CSLA.Library
|
||||
foreach (ROImageInfo tmp in _CacheByPrimaryKey[_ImageID.ToString()])
|
||||
tmp._ROImageFigureCount = -1; // This will cause the data to be requeried
|
||||
}
|
||||
// CSLATODO: Replace base ROImageInfo.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current ROImageInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// CSLATODO: Check ROImageInfo.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 ROImageInfo</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return MyROImageInfoUnique; // Absolutely Unique ID
|
||||
}
|
||||
protected override object GetIdValue() => MyROImageInfoUnique; // Absolutely Unique ID
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _ROImageInfoUnique = 0;
|
||||
private static int ROImageInfoUnique
|
||||
{ get { return ++_ROImageInfoUnique; } }
|
||||
private int _MyROImageInfoUnique = ROImageInfoUnique;
|
||||
public int MyROImageInfoUnique // Absolutely Unique ID - Info
|
||||
{ get { return _MyROImageInfoUnique; } }
|
||||
private static int ROImageInfoUnique => ++_ROImageInfoUnique;
|
||||
private readonly int _MyROImageInfoUnique = ROImageInfoUnique;
|
||||
// Absolutely Unique ID - Info
|
||||
public int MyROImageInfoUnique => _MyROImageInfoUnique;
|
||||
protected ROImageInfo()
|
||||
{/* require use of factory methods */
|
||||
AddToCache(this);
|
||||
@@ -234,15 +205,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;
|
||||
~ROImageInfo()
|
||||
{
|
||||
_CountFinalized++;
|
||||
@@ -261,10 +228,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (listROImageInfo.Count == 0) // If there are no items left in the list
|
||||
_CacheByPrimaryKey.Remove(ImageID.ToString()); // remove the list
|
||||
}
|
||||
public virtual ROImage Get()
|
||||
{
|
||||
return _Editable = ROImage.GetJustROImage(_ImageID);//Don't load figures or ROFST - Causing Memory Crash
|
||||
}
|
||||
public virtual ROImage Get() => _Editable = ROImage.GetJustROImage(_ImageID);//Don't load figures or ROFST - Causing Memory Crash
|
||||
public static void Refresh(ROImage tmp)
|
||||
{
|
||||
string key = tmp.ImageID.ToString();
|
||||
@@ -277,11 +241,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_RODbID != tmp.RODbID)
|
||||
{
|
||||
if (MyRODb != null) MyRODb.RefreshRODbROImages(); // Update List for old value
|
||||
MyRODb?.RefreshRODbROImages(); // Update List for old value
|
||||
_RODbID = tmp.RODbID; // Update the value
|
||||
}
|
||||
_MyRODb = null; // Reset list so that the next line gets a new list
|
||||
if (MyRODb != null) MyRODb.RefreshRODbROImages(); // Update List for new value
|
||||
MyRODb?.RefreshRODbROImages(); // Update List for new value
|
||||
_FileName = tmp.FileName;
|
||||
_Content = tmp.Content;
|
||||
_Config = tmp.Config;
|
||||
@@ -310,8 +274,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static ROImageInfo Get(int imageID)
|
||||
{
|
||||
//if (!CanGetObject())
|
||||
// throw new System.Security.SecurityException("User not authorized to view a ROImage");
|
||||
try
|
||||
{
|
||||
ROImageInfo tmp = GetCachedByPrimaryKey(imageID);
|
||||
@@ -350,13 +312,9 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
protected class PKCriteria
|
||||
{
|
||||
private int _ImageID;
|
||||
public int ImageID
|
||||
{ get { return _ImageID; } }
|
||||
public PKCriteria(int imageID)
|
||||
{
|
||||
_ImageID = imageID;
|
||||
}
|
||||
private readonly int _ImageID;
|
||||
public int ImageID => _ImageID;
|
||||
public PKCriteria(int imageID) => _ImageID = imageID;
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
@@ -418,7 +376,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
// Standard Refresh
|
||||
#region extension
|
||||
ROImageInfoExtension _ROImageInfoExtension = new ROImageInfoExtension();
|
||||
readonly ROImageInfoExtension _ROImageInfoExtension = new ROImageInfoExtension();
|
||||
[Serializable()]
|
||||
partial class ROImageInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
@@ -434,10 +392,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 ROImageInfo)
|
||||
if (destType == typeof(string) && value is ROImageInfo info)
|
||||
{
|
||||
// Return the ToString value
|
||||
return ((ROImageInfo)value).ToString();
|
||||
return info.ToString();
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user