diff --git a/PROMS/VEPROMS User Interface/dlgExportImport.cs b/PROMS/VEPROMS User Interface/dlgExportImport.cs index 04d2f796..98479d83 100644 --- a/PROMS/VEPROMS User Interface/dlgExportImport.cs +++ b/PROMS/VEPROMS User Interface/dlgExportImport.cs @@ -4820,10 +4820,22 @@ namespace VEPROMS DateTime dts = DateTime.Parse(xn.Attributes.GetNamedItem("dts").InnerText); if (libtitle != "") { - // B2019-035 better memory management. Prior logic would eat up memory (and not free it). - string libkey = libtitle + "_" + dts.ToString(); - if (ExistingLibDocs.ContainsKey(libkey)) - d = Document.Get(ExistingLibDocs[libkey]); // found library document in existing database + // C2019-026 if the lib doc title exists in the current database, compare it with the contents of what we + // are importing. If the same, use it, else enter a new lib doc appending the date/time + byte[] doccontent = Convert.FromBase64String(xn.Attributes.GetNamedItem("doccontent").InnerText); + if (ExistingLibDocs.ContainsKey(libtitle)) + { + d = Document.Get(ExistingLibDocs[libtitle]); + if (!ByteArrayCompare.DoCompare(d.DocContent,doccontent)) + d = null; + } + if (d == null) + { + // B2019-035 better memory management. Prior logic would eat up memory (and not free it). + string libkey = libtitle + "_" + dts.ToString(); + if (ExistingLibDocs.ContainsKey(libkey)) + d = Document.Get(ExistingLibDocs[libkey]); // found library document in existing database + } } if (d == null) // not found in existing database, create it { diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs index d48a2367..7d2c0a78 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs @@ -982,9 +982,9 @@ namespace VEPROMS.CSLA.Library int size = Convert.ToInt32(roicfg.Image_Size); byte[] tmpb = ROImageInfo.Decompress(roii.Content, size); - if (ByteArrayCompare(roii.Content, cmpFileContents)) + if (ByteArrayCompare.DoCompare(roii.Content, cmpFileContents)) return imgId; - if (ByteArrayCompare(tmpb, fileContents)) + if (ByteArrayCompare.DoCompare(tmpb, fileContents)) return imgId; } } @@ -993,14 +993,6 @@ namespace VEPROMS.CSLA.Library return 0; } - private bool ByteArrayCompare(byte[] ba1, byte[] ba2) - { - // we wrote our own byte array comparinson because the system's 'equals' did not work! - if (ba1.Length != ba2.Length) return false; - for (int i = 0; i < ba1.Length; i++) - if (ba1[i] != ba2[i]) return false; - return true; - } private ROImageInfo GetMyImage(Dictionary myImages, string imgname, DateTime dts) { diff --git a/PROMS/Volian.Base.Library/ByteArrayCompare.cs b/PROMS/Volian.Base.Library/ByteArrayCompare.cs new file mode 100644 index 00000000..bd833e4a --- /dev/null +++ b/PROMS/Volian.Base.Library/ByteArrayCompare.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Volian.Base.Library +{ + public static class ByteArrayCompare + { + // C2019-026 Took this from ROFSTExt.cs so that we can also use when importing procedures with library documents + public static bool DoCompare(byte[] ba1, byte[] ba2) + { + // we wrote our own byte array comparison because the system's 'equals' did not work! + if (ba1.Length != ba2.Length) return false; + for (int i = 0; i < ba1.Length; i++) + if (ba1[i] != ba2[i]) return false; + return true; + } + + } +}