Changed ROImage to use GetJustROImage so that the ROFST lookup is not loaded for each ROImage.
This commit is contained in:
@@ -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());
|
||||
|
Reference in New Issue
Block a user