From d7f83fa4d41ce08806605677cd3a72d394d04315 Mon Sep 17 00:00:00 2001 From: mschill Date: Fri, 18 Jul 2025 14:52:05 -0400 Subject: [PATCH] C2025-024 Electronic Procedures Phase 2 - XML Export Export Cleanup --- .../VEPROMS User Interface/dlgExportImport.cs | 181 ++++++++---------- 1 file changed, 77 insertions(+), 104 deletions(-) diff --git a/PROMS/VEPROMS User Interface/dlgExportImport.cs b/PROMS/VEPROMS User Interface/dlgExportImport.cs index c4bc8d6c..40716318 100644 --- a/PROMS/VEPROMS User Interface/dlgExportImport.cs +++ b/PROMS/VEPROMS User Interface/dlgExportImport.cs @@ -155,18 +155,15 @@ namespace VEPROMS if (MyFolder != null) { sfd.FileName = string.Format("{0}-{1}.expx", Database.ActiveDatabase, MyFolder.Name); - if (sfd.ShowDialog(this) == DialogResult.OK) - { - if (sfd.FileName != string.Empty) - { - txtExport.Text = sfd.FileName; - if (File.Exists(txtExport.Text)) - File.Delete(txtExport.Text); - MyExpxZipFile = new ZipFile(txtExport.Text, Encoding.UTF8); - MyExpxZipFile.Save(); - } - } - } + if (sfd.ShowDialog(this) == DialogResult.OK && sfd.FileName != string.Empty) + { + txtExport.Text = sfd.FileName; + if (File.Exists(txtExport.Text)) + File.Delete(txtExport.Text); + MyExpxZipFile = new ZipFile(txtExport.Text, Encoding.UTF8); + MyExpxZipFile.Save(); + } + } else if (MyProcedure != null) { txtExport.Enabled = true; @@ -1330,76 +1327,70 @@ namespace VEPROMS txtImport.Text = ofd.FileName; return; } - if (MyFolder != null) - { - if (ofd.ShowDialog(this) == DialogResult.OK) - { - if (ofd.FileName != string.Empty) - { - Old2NewItem = new Dictionary(); - Old2NewContent = new Dictionary(); - Old2NewLibDoc = new Dictionary(); - GetExistingLibDocsList(); // B2019-035 better memory management - PendingTransitions = new XmlDocument(); - FileInfo fi = new FileInfo(ofd.FileName); - string dn; - if (fi.Name.IndexOf("-") > 0) - dn = fi.Name.Substring(0, fi.Name.IndexOf("-")); - else - dn = fi.Name.Substring(0, fi.Name.IndexOf(".")); - txtImport.Text = ofd.FileName; - ReadOptions ro = new ReadOptions(); - ro.Encoding = Encoding.UTF8; - MyExpxZipFile = ZipFile.Read(txtImport.Text, ro); - string fn = string.Format(@"{0}\{1}.impx", PEIPath, dn); - if (File.Exists(fn)) - { - MyImpxZipFile = ZipFile.Read(fn, ro); - ReadTransitionAndItemContentIDs(); - } - else - { - MyImpxZipFile = new ZipFile(fn, Encoding.UTF8); - //transitions - XmlElement xe = PendingTransitions.CreateElement("transitions"); - PendingTransitions.AppendChild(xe); - fn = PEIPath + @"\transitions.xml"; - PendingTransitions.Save(fn); - MyImpxZipFile.AddFile(fn, ""); - MyImpxZipFile.Save(); - File.Delete(fn); - //itemids - XmlDocument xd = new XmlDocument(); - xe = xd.CreateElement("items"); - xd.AppendChild(xe); - fn = PEIPath + @"\items.xml"; - xd.Save(fn); - MyImpxZipFile.AddFile(fn, ""); - MyImpxZipFile.Save(); - File.Delete(fn); - //contentids - xd = new XmlDocument(); - xe = xd.CreateElement("contents"); - xd.AppendChild(xe); - fn = PEIPath + @"\contents.xml"; - xd.Save(fn); - MyImpxZipFile.AddFile(fn, ""); - MyImpxZipFile.Save(); - File.Delete(fn); - //libdocids - xd = new XmlDocument(); - xe = xd.CreateElement("libdocs"); - xd.AppendChild(xe); - fn = PEIPath + @"\libdocs.xml"; - xd.Save(fn); - MyImpxZipFile.AddFile(fn, ""); - MyImpxZipFile.Save(); - File.Delete(fn); - } - } - } - } - if (MyDocVersion != null) + if (MyFolder != null && ofd.ShowDialog(this) == DialogResult.OK && ofd.FileName != string.Empty) + { + Old2NewItem = new Dictionary(); + Old2NewContent = new Dictionary(); + Old2NewLibDoc = new Dictionary(); + GetExistingLibDocsList(); // B2019-035 better memory management + PendingTransitions = new XmlDocument(); + FileInfo fi = new FileInfo(ofd.FileName); + string dn; + if (fi.Name.IndexOf("-") > 0) + dn = fi.Name.Substring(0, fi.Name.IndexOf("-")); + else + dn = fi.Name.Substring(0, fi.Name.IndexOf(".")); + txtImport.Text = ofd.FileName; + ReadOptions ro = new ReadOptions(); + ro.Encoding = Encoding.UTF8; + MyExpxZipFile = ZipFile.Read(txtImport.Text, ro); + string fn = string.Format(@"{0}\{1}.impx", PEIPath, dn); + if (File.Exists(fn)) + { + MyImpxZipFile = ZipFile.Read(fn, ro); + ReadTransitionAndItemContentIDs(); + } + else + { + MyImpxZipFile = new ZipFile(fn, Encoding.UTF8); + //transitions + XmlElement xe = PendingTransitions.CreateElement("transitions"); + PendingTransitions.AppendChild(xe); + fn = PEIPath + @"\transitions.xml"; + PendingTransitions.Save(fn); + MyImpxZipFile.AddFile(fn, ""); + MyImpxZipFile.Save(); + File.Delete(fn); + //itemids + XmlDocument xd = new XmlDocument(); + xe = xd.CreateElement("items"); + xd.AppendChild(xe); + fn = PEIPath + @"\items.xml"; + xd.Save(fn); + MyImpxZipFile.AddFile(fn, ""); + MyImpxZipFile.Save(); + File.Delete(fn); + //contentids + xd = new XmlDocument(); + xe = xd.CreateElement("contents"); + xd.AppendChild(xe); + fn = PEIPath + @"\contents.xml"; + xd.Save(fn); + MyImpxZipFile.AddFile(fn, ""); + MyImpxZipFile.Save(); + File.Delete(fn); + //libdocids + xd = new XmlDocument(); + xe = xd.CreateElement("libdocs"); + xd.AppendChild(xe); + fn = PEIPath + @"\libdocs.xml"; + xd.Save(fn); + MyImpxZipFile.AddFile(fn, ""); + MyImpxZipFile.Save(); + File.Delete(fn); + } + } + if (MyDocVersion != null) { ofd.Filter = "PROMS Procedure Export Files|*.pxml"; if (ofd.ShowDialog(this) == DialogResult.OK) @@ -2223,16 +2214,9 @@ namespace VEPROMS xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "rodbid", ri.RODbID.ToString())); if (_ExportBothConvertedandNot) SetROLocation(ref xe, ri.ROID, ri.RODbID); - //rousage audits - ExportROUsageAudits(xe, ri); xn.AppendChild(xe); } - private void ExportROUsageAudits(XmlElement xe, RoUsageInfo ri) - { - if (cbxExportAudits.Checked) { }; - } - private void ExportPart(XmlElement xn, PartInfo pi, string nodename) { /* @@ -2309,16 +2293,9 @@ namespace VEPROMS xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", ti.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff"))); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", ti.UserID.ToString())); - //transition audits - ExportTransitionAudits(xe, ti); xn.AppendChild(xe); } - private void ExportTransitionAudits(XmlElement xe, TransitionInfo ti) - { - if (cbxExportAudits.Checked) { }; - } - private void ExportAnnotation(XmlElement xn, AnnotationInfo ai, string nodename) { /* @@ -2813,15 +2790,11 @@ namespace VEPROMS { // create a list of the RO databases currently in the database List roDbNameList = new List(); - RODbInfoList rolist = RODbInfoList.Get(); + using (RODbInfoList rolist = RODbInfoList.Get()) + { + roDbNameList.AddRange(rolist.Where(rodbinfo => !roDbNameList.Contains(rodbinfo.ROName)).Select(rodbinfo => rodbinfo.ROName)); + } - foreach (RODbInfo rodbinfo in rolist) - { - if (!roDbNameList.Contains(rodbinfo.ROName)) - roDbNameList.Add(rodbinfo.ROName); - } - - rolist.Dispose(); int cnt = 0; string roNameNew = roname;