Added new property NewerRoFst that checks to see if a Newer ROFst is available to DocVersion and DocVersionInfo
Corrected the logic to use the datetime of the ROFST rather than the datetime of it's folder. Use DocVersionInfo.NewerROFst to determine if the update button is enabled.
This commit is contained in:
parent
1088563cec
commit
381fa7361a
@ -14,12 +14,52 @@ using System.Data.SqlClient;
|
||||
using Csla;
|
||||
using Csla.Data;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
//using VEPROMS.Properties;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public partial class DocVersion: IVEDrillDown
|
||||
{
|
||||
public bool NewerRoFst
|
||||
{
|
||||
get
|
||||
{
|
||||
if (DocVersionAssociations == null) return false;
|
||||
ROFstInfo roFstInfo = ROFstInfo.GetJustROFst(DocVersionAssociations[0].ROFstID);
|
||||
RODbInfo rdi = RODbInfo.GetJustRODB(roFstInfo.RODbID);
|
||||
string rofstPath = rdi.FolderPath + @"\ro.fst";
|
||||
if (!File.Exists(rofstPath)) return false;
|
||||
FileInfo fiRofst = new FileInfo(rofstPath);
|
||||
|
||||
// if the database Ro.Fst is newer or if the files have identical DTS,
|
||||
// assume that they are the same file.
|
||||
if (roFstInfo.DTS >= fiRofst.LastWriteTimeUtc) return false;
|
||||
|
||||
// next see if the data is the same size, i.e. byte count of record and byte count
|
||||
// of file. If different sizes, the date/time stamp check will hold.
|
||||
if (fiRofst.Length != roFstInfo.ROLookup.Length) return fiRofst.LastWriteTimeUtc > roFstInfo.DTS;
|
||||
|
||||
// if we can't tell by the DTS or size, compare the contents. Get all of the rodb's
|
||||
// rofsts of the size of the file & compare bytes. If
|
||||
ROFstInfoList fstList = ROFstInfoList.GetBySize(rdi.RODbID, (int)fiRofst.Length);
|
||||
if (fstList.Count > 0)
|
||||
{
|
||||
FileStream fsIn = new FileStream(rofstPath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
// Create an instance of StreamReader that can read characters from the FileStream.
|
||||
BinaryReader r = new BinaryReader(fsIn);
|
||||
byte[] ab = r.ReadBytes((int)fsIn.Length);
|
||||
fsIn.Close();
|
||||
foreach (ROFstInfo irofst in fstList)
|
||||
{
|
||||
// compare contents by comparing each byte.
|
||||
for (int i = 0; i < fiRofst.Length; i++)
|
||||
if (ab[i] != irofst.ROLookup[i]) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#region VersionType
|
||||
public VersionTypeEnum eVersionType
|
||||
{
|
||||
@ -124,6 +164,46 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public partial class DocVersionInfo : IVEDrillDownReadOnly
|
||||
{
|
||||
public bool NewerRoFst
|
||||
{
|
||||
get
|
||||
{
|
||||
if (DocVersionAssociations == null) return false;
|
||||
ROFstInfo roFstInfo = ROFstInfo.GetJustROFst(DocVersionAssociations[0].ROFstID);
|
||||
RODbInfo rdi = RODbInfo.GetJustRODB(roFstInfo.RODbID);
|
||||
string rofstPath = rdi.FolderPath + @"\ro.fst";
|
||||
if (!File.Exists(rofstPath)) return false;
|
||||
FileInfo fiRofst = new FileInfo(rofstPath);
|
||||
|
||||
// if the database Ro.Fst is newer or if the files have identical DTS,
|
||||
// assume that they are the same file.
|
||||
if (roFstInfo.DTS >= fiRofst.LastWriteTimeUtc) return false;
|
||||
|
||||
// next see if the data is the same size, i.e. byte count of record and byte count
|
||||
// of file. If different sizes, the date/time stamp check will hold.
|
||||
if (fiRofst.Length != roFstInfo.ROLookup.Length) return fiRofst.LastWriteTimeUtc > roFstInfo.DTS;
|
||||
|
||||
// if we can't tell by the DTS or size, compare the contents. Get all of the rodb's
|
||||
// rofsts of the size of the file & compare bytes. If
|
||||
ROFstInfoList fstList = ROFstInfoList.GetBySize(rdi.RODbID, (int)fiRofst.Length);
|
||||
if (fstList.Count > 0)
|
||||
{
|
||||
FileStream fsIn = new FileStream(rofstPath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
// Create an instance of StreamReader that can read characters from the FileStream.
|
||||
BinaryReader r = new BinaryReader(fsIn);
|
||||
byte[] ab = r.ReadBytes((int)fsIn.Length);
|
||||
fsIn.Close();
|
||||
foreach (ROFstInfo irofst in fstList)
|
||||
{
|
||||
// compare contents by comparing each byte.
|
||||
for (int i = 0; i < fiRofst.Length; i++)
|
||||
if (ab[i] != irofst.ROLookup[i]) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#region SearchPaths
|
||||
public string _SearchDVPath;
|
||||
public string SearchDVPath
|
||||
|
@ -274,9 +274,12 @@ namespace VEPROMS.CSLA.Library
|
||||
public static ROFst UpdateRoFst(RODbInfo rdi, DocVersionAssociation dva, DocVersion docver, ROFstInfo origROFst)
|
||||
{
|
||||
DirectoryInfo di = new DirectoryInfo(rdi.FolderPath);
|
||||
string rofstfilepath = rdi.FolderPath + @"\ro.fst";
|
||||
FileStream fsIn = new FileStream(rofstfilepath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
FileInfo rofstFI = new FileInfo(rofstfilepath);
|
||||
// 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.LastWriteTimeUtc);
|
||||
ROFst rofst = ROFst.GetByRODbID_DTS(rdi.RODbID, rofstFI.LastWriteTimeUtc);
|
||||
if (rofst != null)
|
||||
{
|
||||
docver.DocVersionAssociations[0].MyROFst = rofst;
|
||||
@ -285,15 +288,13 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
|
||||
// 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);
|
||||
byte[] ab = r.ReadBytes((int)fsIn.Length);
|
||||
fsIn.Close();
|
||||
using (RODb rodb = RODb.GetJustRoDb(rdi.RODbID))
|
||||
{
|
||||
rofst = ROFst.MakeROFst(rodb, ab, null, di.LastWriteTimeUtc, rdi.UserID);
|
||||
rofst = ROFst.MakeROFst(rodb, ab, null, rofstFI.LastWriteTimeUtc, rdi.UserID);
|
||||
// Hook this into the current docversion by replacing the rofstid field in the doc version
|
||||
// association object:
|
||||
dva.MyROFst = rofst;
|
||||
|
@ -1771,39 +1771,8 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
public bool NewerRoFst()
|
||||
{
|
||||
if (_MyDVI == null || _MyDVI.DocVersionAssociations == null) return false;
|
||||
ROFstInfo roFstInfo = ROFstInfo.GetJustROFst( _MyDVI.DocVersionAssociations[0].ROFstID);
|
||||
RODbInfo rdi = RODbInfo.GetJustRODB(roFstInfo.RODbID);
|
||||
string rofstPath = rdi.FolderPath + @"\ro.fst";
|
||||
if (!File.Exists(rofstPath)) return false;
|
||||
FileInfo fiRofst = new FileInfo(rofstPath);
|
||||
|
||||
// if the database Ro.Fst is newer or if the files have identical DTS,
|
||||
// assume that they are the same file.
|
||||
if (roFstInfo.DTS >= fiRofst.LastWriteTimeUtc) return false;
|
||||
|
||||
// next see if the data is the same size, i.e. byte count of record and byte count
|
||||
// of file. If different sizes, the date/time stamp check will hold.
|
||||
if (fiRofst.Length != roFstInfo.ROLookup.Length) return fiRofst.LastWriteTimeUtc > roFstInfo.DTS;
|
||||
|
||||
// if we can't tell by the DTS or size, compare the contents. Get all of the rodb's
|
||||
// rofsts of the size of the file & compare bytes. If
|
||||
ROFstInfoList fstList = ROFstInfoList.GetBySize(rdi.RODbID, (int)fiRofst.Length);
|
||||
if (fstList.Count > 0)
|
||||
{
|
||||
FileStream fsIn = new FileStream(rofstPath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
// Create an instance of StreamReader that can read characters from the FileStream.
|
||||
BinaryReader r = new BinaryReader(fsIn);
|
||||
byte[] ab = r.ReadBytes((int)fsIn.Length);
|
||||
fsIn.Close();
|
||||
foreach (ROFstInfo irofst in fstList)
|
||||
{
|
||||
// compare contents by comparing each byte.
|
||||
for (int i = 0; i < fiRofst.Length; i++)
|
||||
if (ab[i] != irofst.ROLookup[i]) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if (_MyDVI == null)return false;
|
||||
return _MyDVI.NewerRoFst;
|
||||
}
|
||||
public void SetUpdRoValBtn(bool en)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user