diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs index 985eb247..ca4bfe25 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs @@ -554,8 +554,11 @@ namespace VEPROMS.CSLA.Library Document doc = _MyDocument.Get(); MyFile.Refresh(); // B2017-255 Get the latest file length before reading and saving FileStream fs = _MyFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + // B2017-262 Verify that the file length is correct. + long savLen2 = fs.Length; long savLen = _MyFile.Length; - Byte[] buf = new byte[_MyFile.Length]; + if(savLen2!=savLen)_MyLog.WarnFormat("FileInfoLength = {0}, FileStreamLength= {1}", savLen, savLen2); + Byte[] buf = new byte[Math.Max(savLen,savLen2)]; fs.Read(buf, 0, buf.Length); fs.Close(); @@ -588,8 +591,9 @@ namespace VEPROMS.CSLA.Library cfg.Edit_Initialized = true; doc.Config = cfg.ToString(); doc.UserID = Volian.Base.Library.VlnSettings.UserID; - //doc.DTS = _MyFile.LastWriteTimeUtc; - doc.DTS = DateTime.Now.ToUniversalTime(); + // B2017-262 use the date time stamp from the file rather than the clock + doc.DTS = _MyFile.LastWriteTimeUtc; + //doc.DTS = DateTime.Now.ToUniversalTime(); doc = doc.Save(); if (myItemInfo != null) // B2016-131 if myItemInfo is null, the lib doc is not referenced from any procedure. Just save changes, but don't generate a PDF {