Added method RofstInfo.GetROImageByFilename to find image files by name.
Added method RoImageInforList GetByRODbIDFilename to find image files by name. Find ROImages if not attached to the current ROFST. The Export/Import code was not saving ROImage usages properly
This commit is contained in:
@@ -443,5 +443,70 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
this.RaiseListChangedEvents = true;
|
||||
}
|
||||
public static ROImageInfoList GetByRODbIDFilename(int rODbID,string filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
ROImageInfoList tmp = DataPortal.Fetch<ROImageInfoList>(new RODbIDFilenameCriteria(rODbID,filename));
|
||||
//ROImageInfo.AddList(tmp);
|
||||
tmp.AddEvents();
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on ROImageInfoList.GetByRODbIDFilename", ex);
|
||||
}
|
||||
}
|
||||
private class RODbIDFilenameCriteria
|
||||
{
|
||||
public RODbIDFilenameCriteria(int rODbID,string filename)
|
||||
{
|
||||
_RODbID = rODbID;
|
||||
_Filename = filename;
|
||||
}
|
||||
private int _RODbID;
|
||||
public int RODbID
|
||||
{
|
||||
get { return _RODbID; }
|
||||
set { _RODbID = value; }
|
||||
}
|
||||
private string _Filename;
|
||||
public string Filename
|
||||
{
|
||||
get { return _Filename; }
|
||||
set { _Filename = value; }
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(RODbIDFilenameCriteria criteria)
|
||||
{
|
||||
this.RaiseListChangedEvents = false;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImageInfoList.DataPortal_FetchRODbIDFilename", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getROImagesByRODbID_Filename";
|
||||
cm.Parameters.AddWithValue("@RODbID", criteria.RODbID);
|
||||
cm.Parameters.AddWithValue("@FileName", criteria.Filename);
|
||||
cm.CommandTimeout = Database.DefaultTimeout;
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
IsReadOnly = false;
|
||||
while (dr.Read()) this.Add(new ROImageInfo(dr));
|
||||
IsReadOnly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROImageInfoList.DataPortal_FetchRODbIDFilename", ex);
|
||||
throw new DbCslaException("ROImageInfoList.DataPortal_FetchRODbIDFilename", ex);
|
||||
}
|
||||
this.RaiseListChangedEvents = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user