Changed ROImage to use GetJustROImage so that the ROFST lookup is not loaded for each ROImage.
This commit is contained in:
parent
26ad9239f2
commit
aa21c16ebb
@ -167,7 +167,7 @@ namespace VEPROMS.CSLA.Library
|
||||
int pcount = 1;
|
||||
foreach (int id in imageIds)
|
||||
{
|
||||
using (ROImage ro = ROImage.Get(id))
|
||||
using (ROImage ro = ROImage.GetJustROImage(id))//Don't load figures or ROFST - Causing Memory Crash
|
||||
{
|
||||
string nm = ro.FileName;
|
||||
OnCompressAllExistingImages(null, new ROImageInfoCompressionEventArgs(pcount++, nm));
|
||||
|
@ -173,7 +173,7 @@ namespace VEPROMS.CSLA.Library
|
||||
get
|
||||
{
|
||||
CanReadProperty("MyROImage", true);
|
||||
if (_MyROImage == null && _ImageID != 0) _MyROImage = ROImage.Get(_ImageID);
|
||||
if (_MyROImage == null && _ImageID != 0) _MyROImage = ROImage.GetJustROImage(_ImageID);//Don't load figures or ROFST - Causing Memory Crash
|
||||
return _MyROImage;
|
||||
}
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
|
@ -56,7 +56,7 @@ namespace VEPROMS.CSLA.Library
|
||||
get
|
||||
{
|
||||
CanReadProperty("MyROImage", true);
|
||||
if (_MyROImage == null && _ImageID != 0) _MyROImage = ROImage.Get(_ImageID);
|
||||
if (_MyROImage == null && _ImageID != 0) _MyROImage = ROImage.GetJustROImage(_ImageID);//Don't load figures or ROFST - Causing Memory Crash
|
||||
return _MyROImage;
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ namespace VEPROMS.CSLA.Library
|
||||
get
|
||||
{
|
||||
CanReadProperty("MyROImage", true);
|
||||
if (_MyROImage == null && _ImageID != 0) _MyROImage = ROImage.Get(_ImageID);
|
||||
if (_MyROImage == null && _ImageID != 0) _MyROImage = ROImage.GetJustROImage(_ImageID);//Don't load figures or ROFST - Causing Memory Crash
|
||||
return _MyROImage;
|
||||
}
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
|
@ -653,6 +653,30 @@ namespace VEPROMS.CSLA.Library
|
||||
throw new DbCslaException("Error on ROImage.Get", ex);
|
||||
}
|
||||
}
|
||||
public static ROImage GetJustROImage(int imageID)//Don't load figures or ROFST - Causing Memory Crash
|
||||
{
|
||||
if (!CanGetObject())
|
||||
throw new System.Security.SecurityException("User not authorized to view a ROImage");
|
||||
try
|
||||
{
|
||||
ROImage tmp = GetCachedByPrimaryKey(imageID);
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<ROImage>(new PKCriteriaJustROImage(imageID));
|
||||
AddToCache(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up ROImage
|
||||
tmp = null;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on ROImage.Get", ex);
|
||||
}
|
||||
}
|
||||
public static ROImage GetByRODbID_FileName_DTS(int rODbID, string fileName, DateTime dts)
|
||||
{
|
||||
if (!CanGetObject())
|
||||
@ -735,6 +759,17 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
[Serializable()]
|
||||
protected class PKCriteriaJustROImage//Don't load figures or ROFST - Causing Memory Crash
|
||||
{
|
||||
private int _ImageID;
|
||||
public int ImageID
|
||||
{ get { return _ImageID; } }
|
||||
public PKCriteriaJustROImage(int imageID)
|
||||
{
|
||||
_ImageID = imageID;
|
||||
}
|
||||
}
|
||||
[Serializable()]
|
||||
private class RODbID_FileName_DTSCriteria
|
||||
{
|
||||
private int _RODbID;
|
||||
@ -826,6 +861,43 @@ namespace VEPROMS.CSLA.Library
|
||||
throw new DbCslaException("ROImage.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(PKCriteriaJustROImage criteria)//Don't load figures or ROFST - Causing Memory Crash
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImage.DataPortal_Fetch", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
ApplicationContext.LocalContext["cn"] = cn;
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getJustROImage";
|
||||
cm.Parameters.AddWithValue("@ImageID", criteria.ImageID);
|
||||
cm.CommandTimeout = Database.DefaultTimeout;
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
if (!dr.Read())
|
||||
{
|
||||
_ErrorMessage = "No Record Found";
|
||||
return;
|
||||
}
|
||||
ReadData(dr);
|
||||
// load child objects
|
||||
}
|
||||
}
|
||||
// removing of item only needed for local data portal
|
||||
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
|
||||
ApplicationContext.LocalContext.Remove("cn");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROImage.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("ROImage.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(RODbID_FileName_DTSCriteria criteria)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImage.DataPortal_Fetch", GetHashCode());
|
||||
|
@ -273,7 +273,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public virtual ROImage Get()
|
||||
{
|
||||
return _Editable = ROImage.Get(_ImageID);
|
||||
return _Editable = ROImage.GetJustROImage(_ImageID);//Don't load figures or ROFST - Causing Memory Crash
|
||||
}
|
||||
public static void Refresh(ROImage tmp)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user