B2016-115 the comparison of the contents of RO.FST files would also be seen as different (and loading into memory) even when user created a new RO.fst without making any RO changes. We needed to skip past the RO.FST header information in the file which contains the date/time the FST was created. Also needed to do a garbage collection.
This commit is contained in:
		@@ -61,23 +61,8 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
				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.ReadWrite);
 | 
			
		||||
					// 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;
 | 
			
		||||
				// rofsts of the size of the file & compare bytes.
 | 
			
		||||
				return  ROFstInfoList.ROFstDiffBySize(rofstPath, rdi.RODbID, (int)fiRofst.Length);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		#region VersionType
 | 
			
		||||
@@ -244,25 +229,8 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
				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 
 | 
			
		||||
				ROFstInfoList fstList = ROFstInfoList.GetBySize(rdi.RODbID, (int)fiRofst.Length);
 | 
			
		||||
				if (fstList.Count > 0)
 | 
			
		||||
				{
 | 
			
		||||
					// B2017-078  WCN users with Read only access to the RO FST file where not able to open the file for reading when
 | 
			
		||||
					//            another user was accessing the file. Changed FileShare from Read to ReadWrite
 | 
			
		||||
					FileStream fsIn = new FileStream(rofstPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
 | 
			
		||||
					// 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 AddToRoFstLookup(key,true);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				return AddToRoFstLookup(key,false);
 | 
			
		||||
				// rofsts of the size of the file & compare bytes.
 | 
			
		||||
				return AddToRoFstLookup(key, ROFstInfoList.ROFstDiffBySize(rofstPath, rdi.RODbID, (int)fiRofst.Length));
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1079,6 +1079,41 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
				throw new DbCslaException("Error on RoFstInfoList.GetBySize", ex);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		public static bool ROFstDiffBySize(string rofstPath, int roDbID, int len)
 | 
			
		||||
		{
 | 
			
		||||
			try
 | 
			
		||||
			{
 | 
			
		||||
				bool isDifferent = false;
 | 
			
		||||
				using (ROFstInfoList tmp = GetBySize(roDbID, len))
 | 
			
		||||
				{
 | 
			
		||||
					if (tmp.Count > 0)
 | 
			
		||||
					{
 | 
			
		||||
						// B2017-078  WCN users with Read only access to the RO FST file where not able to open the file for reading when
 | 
			
		||||
						//            another user was accessing the file. Changed FileShare from Read to ReadWrite
 | 
			
		||||
						FileStream fsIn = new FileStream(rofstPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
 | 
			
		||||
						// Create an instance of StreamReader that can read characters from the FileStream.
 | 
			
		||||
						BinaryReader r = new BinaryReader(fsIn);
 | 
			
		||||
						byte[] ab = r.ReadBytes((int)fsIn.Length);
 | 
			
		||||
						r.Close();
 | 
			
		||||
						fsIn.Close();
 | 
			
		||||
						foreach (ROFstInfo irofst in tmp)
 | 
			
		||||
						{
 | 
			
		||||
							// compare contents by comparing each byte.
 | 
			
		||||
							for (int i = 20; i < len; i++) // this skips past RO.FST header which has the FST creation date/time
 | 
			
		||||
								if (ab[i] != irofst.ROLookup[i]) isDifferent = true;
 | 
			
		||||
							irofst.Dispose();
 | 
			
		||||
							if (isDifferent) break;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				GC.Collect();
 | 
			
		||||
				return isDifferent;
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception ex)
 | 
			
		||||
			{
 | 
			
		||||
				throw new DbCslaException("Error on RoFstInfoList.ROFstDiffBySize", ex);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		private void DataPortal_Fetch(RoFstSizeCriteria criteria)
 | 
			
		||||
		{
 | 
			
		||||
			this.RaiseListChangedEvents = false;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user