This commit is contained in:
parent
9ac5db39d7
commit
84732957e3
@ -17,7 +17,10 @@ using System.Xml.Serialization;
|
||||
using System.Xml;
|
||||
using System.Xml.XPath;
|
||||
using System.Text.RegularExpressions;
|
||||
//using Config;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using Csla;
|
||||
using Csla.Data;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
@ -167,17 +170,20 @@ namespace VEPROMS.CSLA.Library
|
||||
/// <returns>ROFst: Returns the created rofst object</returns>
|
||||
public static ROFst UpdateRoFst(RODbInfo rdi, DocVersionAssociation dva, DocVersion docver, ROFstInfo origROFst)
|
||||
{
|
||||
// file validity checks are done before getting here - just do the import
|
||||
// here.
|
||||
string rofstfilepath = rdi.FolderPath + @"\ro.fst";
|
||||
|
||||
DirectoryInfo di = new DirectoryInfo(rdi.FolderPath);
|
||||
|
||||
// There may be more than 1 'ro' as the 'ROName' field (ROName is derived from the ropath).
|
||||
// Get new name be incrementing, if so.
|
||||
string newname = NewROName(di.Name);
|
||||
|
||||
// Next read in the rofst & make the rofst record.
|
||||
|
||||
// check if this rofst has been loaded, i.e. dts on file versus dts in db...
|
||||
// if so, just make association to existing with docversion.
|
||||
ROFst rofst = ROFst.GetByRODbID_DTS(rdi.RODbID, di.LastWriteTime);
|
||||
if (rofst != null)
|
||||
{
|
||||
docver.DocVersionAssociations[0].MyROFst = rofst;
|
||||
docver.Save();
|
||||
return rofst;
|
||||
}
|
||||
|
||||
// Read in the rofst & make the rofst record.
|
||||
string rofstfilepath = rdi.FolderPath + @"\ro.fst";
|
||||
FileStream fsIn = new FileStream(rofstfilepath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
// Create an instance of StreamReader that can read characters from the FileStream.
|
||||
BinaryReader r = new BinaryReader(fsIn);
|
||||
@ -186,7 +192,7 @@ namespace VEPROMS.CSLA.Library
|
||||
|
||||
using (RODb rd = RODb.Get(rdi.RODbID))
|
||||
{
|
||||
ROFst rofst = ROFst.MakeROFst(rd, ab, null, di.LastWriteTime, rdi.UserID);
|
||||
rofst = ROFst.MakeROFst(rd, ab, null, di.LastWriteTime, rdi.UserID);
|
||||
// Hook this into the current docversion by replacing the rofstid field in the doc version
|
||||
// association object:
|
||||
dva.MyROFst = rofst;
|
||||
@ -351,4 +357,74 @@ namespace VEPROMS.CSLA.Library
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public partial class ROFstInfoList
|
||||
{
|
||||
[Serializable()]
|
||||
private class RoFstSizeCriteria
|
||||
{
|
||||
public RoFstSizeCriteria(int roDbID, int len)
|
||||
{
|
||||
_RODbID = roDbID;
|
||||
_Len = len;
|
||||
}
|
||||
private int _RODbID;
|
||||
public int RODbID
|
||||
{
|
||||
get { return _RODbID; }
|
||||
set { _RODbID = value; }
|
||||
}
|
||||
private int _Len;
|
||||
public int Len
|
||||
{
|
||||
get { return _Len; }
|
||||
set { _Len = value; }
|
||||
}
|
||||
}
|
||||
public static ROFstInfoList GetBySize(int roDbID, int len)
|
||||
{
|
||||
try
|
||||
{
|
||||
ROFstInfoList tmp = DataPortal.Fetch<ROFstInfoList>(new RoFstSizeCriteria(roDbID, len));
|
||||
ROFstInfo.AddList(tmp);
|
||||
tmp.AddEvents();
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on RoFstInfoList.GetBySize", ex);
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(RoFstSizeCriteria criteria)
|
||||
{
|
||||
this.RaiseListChangedEvents = false;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfoList.DataPortal_FetchBySize", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getRoFstBySize";
|
||||
cm.Parameters.AddWithValue("@RODbID", criteria.RODbID);
|
||||
cm.Parameters.AddWithValue("@Len", criteria.Len);
|
||||
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
IsReadOnly = false;
|
||||
while (dr.Read())
|
||||
this.Add(new ROFstInfo(dr));
|
||||
IsReadOnly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstInfoList.DataPortal_FetchBySize", ex);
|
||||
throw new DbCslaException("ROFstInfoList.DataPortal_FetchBySize", ex);
|
||||
}
|
||||
this.RaiseListChangedEvents = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user