diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs index 9a99f8df..2825fdfc 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs @@ -205,6 +205,14 @@ namespace VEPROMS.CSLA.Library } return exists; } + // The following dictionary is used to store the state of the ro.fst check so that it is + // not made repeatedly in NewerRoFst. (B2017-050) + private static Dictionary NewerRoFstLookup = new Dictionary(); + private static bool AddToRoFstLookup(string key, bool result) + { + if (!NewerRoFstLookup.ContainsKey(key)) NewerRoFstLookup.Add(key, result); + return result; + } public bool NewerRoFst { get @@ -223,13 +231,17 @@ namespace VEPROMS.CSLA.Library // 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; + + // put this in a dictionary so we don't have to keep testing to see if the file version of ro.fst is newer than database version + string key = string.Format("{0}-{1}", DocVersionAssociations[0].ROFstID, fiRofst.LastWriteTimeUtc); + if (NewerRoFstLookup.ContainsKey(key)) return NewerRoFstLookup[key]; + if (roFstInfo.DTS >= fiRofst.LastWriteTimeUtc) return AddToRoFstLookup(key, false); TimeSpan ts = roFstInfo.DTS - fiRofst.LastWriteTimeUtc; - if (ts.TotalSeconds > -1F) return false; + if (ts.TotalSeconds > -1F) return AddToRoFstLookup(key, 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 (fiRofst.Length != roFstInfo.ROLookup.Length) return AddToRoFstLookup(key,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 @@ -245,10 +257,10 @@ namespace VEPROMS.CSLA.Library { // compare contents by comparing each byte. for (int i = 0; i < fiRofst.Length; i++) - if (ab[i] != irofst.ROLookup[i]) return true; + if (ab[i] != irofst.ROLookup[i]) return AddToRoFstLookup(key,true); } } - return false; + return AddToRoFstLookup(key,false); } }