diff --git a/PROMS/VEPROMS User Interface/dlgExportImport.cs b/PROMS/VEPROMS User Interface/dlgExportImport.cs index e0496b3a..a644d255 100644 --- a/PROMS/VEPROMS User Interface/dlgExportImport.cs +++ b/PROMS/VEPROMS User Interface/dlgExportImport.cs @@ -13,9 +13,12 @@ using System.IO; using Ionic.Zip; using System.Text.RegularExpressions; using JR.Utils.GUI.Forms; +using System.Linq; namespace VEPROMS { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Major Code Smell", "S6580:Use a format provider when parsing date and time", Justification = "dts formatting may be different time per plant")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Major Code Smell", "S6561:Avoid using \"DateTime.Now\" for benchmarking or timing operations", Justification = "Rough Time estimate on ProgressBars")] public partial class dlgExportImport : Form { #region Log4Net @@ -110,15 +113,6 @@ namespace VEPROMS PEIPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS\PEI_" + Database.VEPROMS_SqlConnection.Database; if (!Directory.Exists(PEIPath)) Directory.CreateDirectory(PEIPath); - if (_MyMode == "Import") - { - //If you try to import a procedure into an empty PROMS folder, the code was deleting the File System Folder including the import file. This happened during D.C. Cook training (12/3/2015). - //if (MyFolder != null && MyFolder.ChildFolderCount == 0 ) - //{ - // Directory.Delete(PEIPath, true); - // Directory.CreateDirectory(PEIPath); - //} - } pnlExport.Dock = DockStyle.Fill; pnlImport.Dock = DockStyle.Fill; int formsize = 2; @@ -160,8 +154,6 @@ namespace VEPROMS } if (MyFolder != null) { - //Database.SelectedDatabase - //sfd.FileName = string.Format("{0}.expx", MyFolder.Name); sfd.FileName = string.Format("{0}-{1}.expx", Database.ActiveDatabase, MyFolder.Name); if (sfd.ShowDialog(this) == DialogResult.OK) { @@ -189,12 +181,12 @@ namespace VEPROMS else lblExportStatus.Text = "Awaiting Export File Name:"; } - private XmlWriter MyWriter = null; private ZipFile MyExpxZipFile = null; private ZipFile MyImpxZipFile = null; private DateTime MyStart; private bool successfullExport = true; - private void btnDoExport_Click(object sender, EventArgs e) + + private void btnDoExport_Click(object sender, EventArgs e) { @@ -219,7 +211,6 @@ namespace VEPROMS btnDoExport.Enabled = false; lblExportStatus.Text = "Performing Export"; SaveExportData(); - //SaveExportDataWriter(); TimeSpan elapsed = DateTime.Now.Subtract(MyStart); lblExportStatus.Text = "Export Completed in " + elapsed.ToString(); @@ -231,7 +222,7 @@ namespace VEPROMS var fileLocation = txtExport.Text; if (File.Exists(fileLocation)) { // C2022-029 if an existing export of the same name is found, provide option to overwrite it - DialogResult ovewriteEx = FlexibleMessageBox.ShowCustom(null, "There is already another export file with the same name. You can choose to either overwrite the existing file or have the existing file renamed with the original creation date appended.\r\n\r\nSelecting 'Cancel' will cancel the export.", "What would you like to do?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);// == DialogResult.Yes; + DialogResult ovewriteEx = FlexibleMessageBox.ShowCustom(null, "There is already another export file with the same name. You can choose to either overwrite the existing file or have the existing file renamed with the original creation date appended.\r\n\r\nSelecting 'Cancel' will cancel the export.", "What would you like to do?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); // Extract directory, filename, and extension string directory = Path.GetDirectoryName(fileLocation); @@ -316,18 +307,6 @@ namespace VEPROMS MyFrmVEPROMS.DisablePing = false;//B2018-030 turn on ping Export is done } - // appears to not be used -jsj 4-29-2016 - //private void SaveExportDataWriter() - //{ - // XmlWriterSettings ws = new XmlWriterSettings(); - // ws.Indent = true; - // ws.NewLineHandling = NewLineHandling.Entitize; - // ws.CheckCharacters = false; - // MyWriter = XmlWriter.Create(txtExport.Text, ws); - // ExportFolder(MyFolder, "folder"); - // MyWriter.Close(); - //} - private void btnDoImport_Click(object sender, EventArgs e) { bool isImported = false; @@ -341,7 +320,6 @@ namespace VEPROMS _DidConvertROsToText = false; _DidProcessTransitions = false; // B2017-076 to know if we processed any transition (used in status message at the end of importing) _DidProcessROs = false; // B2017-076 to know if we processed any transition (used in status message at the end of importing) - //LoadImportDataReader(); if (_MyMode.ToUpper().Contains("FORMAT")) { TurnChangeManagerOff.Execute(); @@ -424,7 +402,6 @@ namespace VEPROMS } // B2016-225 added more information to the finish import message to tell the user when ROs or Transitions are converted to text. MessageBox.Show(msg, "Import Completed", MessageBoxButtons.OK, MessageBoxIcon.Information); // C2020-042 changed mesage box title - //MessageBox.Show(string.Format("Finished Importing:\n\n{0}", txtImport.Text.Substring(txtImport.Text.LastIndexOf("\\") + 1)), "Import", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (canceledPressed || !isImported) { @@ -433,7 +410,7 @@ namespace VEPROMS } } - private bool TryToImportUCFs(ref bool isImported, ref bool canceledPressed) + private bool TryToImportUCFs(ref bool isImported, ref bool canceledPressed) { try { @@ -630,7 +607,7 @@ namespace VEPROMS fstInfo = tmp; using (DocVersion dv = MyDocVersion.Get()) { - using (ROFst fst = fstInfo.Get()) + using (ROFst fst = fstInfo?.Get()) { dv.DocVersionAssociations.Add(fst); dv.Save(); @@ -660,7 +637,7 @@ namespace VEPROMS // use resolvedProcNum to determine if procedure is 'unique', i.e. if the procedure number exists // and user does not overwrite or copy, then the procedure should NOT be imported. Fix for B2016-045 bool resolvedProcNum = true; - foreach (ProcedureInfo pi in MyDocVersion.Procedures) + foreach (ProcedureInfo pi in MyDocVersion.Procedures.OfType()) { // procedure numbers that contain a hyphen may have the hyphen represented as the unicode character // '\u8209?' or the '-' character. If proc number is same except for hyphen representation, they @@ -677,7 +654,7 @@ namespace VEPROMS if (hyphenNum == hyphenImpNum) { - string msg = string.Format("The procedure you are importing{0}already exists in this procedure set.\n\nDo you want to OVERWRITE the existing procedure?", !hyphenImpNum.Equals("") ? string.Format(" ({0}) ", hyphenImpNum) : " "); + string msg = string.Format("The procedure you are importing{0}already exists in this procedure set.\n\nDo you want to OVERWRITE the existing procedure?", !string.IsNullOrEmpty(hyphenImpNum) ? string.Format(" ({0}) ", hyphenImpNum) : " "); DialogResult dr = MessageBox.Show(this, msg, "Overwrite Existing Procedure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop); if (dr == DialogResult.Yes) { @@ -693,7 +670,7 @@ namespace VEPROMS } if (dr == DialogResult.No) { - msg = string.Format("Do you want to import {0} as a COPY of the existing procedure?\n\nThis will prefix the procedure number with \"Copy of\"", !hyphenImpNum.Equals("") ? string.Format("({0})", hyphenImpNum) : "the procedure"); + msg = string.Format("Do you want to import {0} as a COPY of the existing procedure?\n\nThis will prefix the procedure number with \"Copy of\"", !string.IsNullOrEmpty(hyphenImpNum) ? string.Format("({0})", hyphenImpNum) : "the procedure"); dr = MessageBox.Show(this, msg, "Create Copy Of Existing Procedure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop); if (dr == DialogResult.Yes) { @@ -777,14 +754,13 @@ namespace VEPROMS string fn = PEIPath + @"\transitions.xml"; PendingTransitions.Save(fn); ProcedureInfo lastProcedure = null; - foreach (ProcedureInfo pi in MyDocVersion.Procedures) + foreach (ProcedureInfo pi in MyDocVersion.Procedures.OfType()) lastProcedure = pi; _MyNewProcedure = AddProcedure(xd.DocumentElement, MyDocVersion, lastProcedure); //update transitions AddTransitions(PendingTransitions); PendingTransitions.Save(fn); FixFloatingFoldouts(); - //File.Delete(fn); } private void ImportProcedureCopy(XmlDocument xd) { @@ -812,7 +788,7 @@ namespace VEPROMS // kbr - could replace '-' with unicode in number, here. int count = 0; - foreach (ProcedureInfo pi in MyDocVersion.Procedures) + foreach (ProcedureInfo pi in MyDocVersion.Procedures.OfType()) { lastProcedure = pi; if (pi.MyContent.Number.EndsWith(number)) @@ -848,7 +824,7 @@ namespace VEPROMS PendingTransitions.Save(fn); ProcedureInfo lastProcedure = null; //delete old procedure - foreach (ProcedureInfo lp in MyDocVersion.Procedures) + foreach (ProcedureInfo lp in MyDocVersion.Procedures.OfType()) lastProcedure = lp; //delete opi try @@ -865,7 +841,7 @@ namespace VEPROMS { using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(pi.ItemID)) { - DialogResult ans = MessageBox.Show("Transitions exist to this procedure and cannot be adjusted automatically." + + MessageBox.Show("Transitions exist to this procedure and cannot be adjusted automatically." + "\r\nSteps with Problem Transitions:" + exTrans.Summarize(), "Cannot Overwrite Procedure", MessageBoxButtons.OK, MessageBoxIcon.Question); @@ -932,11 +908,6 @@ namespace VEPROMS ff = AddFolder(Folder.Get(MyFolder.FolderID), xd, name); } - //else if (dr == System.Windows.Forms.DialogResult.Cancel) - //{ - // //canceledPressed = true; - // //resolvedProcNum = false; - //} else return false; } @@ -1139,9 +1110,8 @@ namespace VEPROMS // need to add this format - name must be unique so add 'COPY(x) of 'original name'' where x is unique number: if (UCFImportCase == E_UCFImportOptions.LoadNotUsed || UCFImportCase == E_UCFImportOptions.LoadOnlyImported || UCFImportCase == E_UCFImportOptions.LoadForSetOnly) { - int count = 0; - foreach (FormatInfo fi in fil) if (fi.Name.EndsWith(name)) count++; - if (count > 0) + int count = (fil.Where(fi => fi.Name.EndsWith(name))).Count(); + if (count > 0) { string origname = name; name = string.Format("Copy {0} of {1}", count.ToString(), name); @@ -1158,9 +1128,8 @@ namespace VEPROMS if (UCFImportCase == E_UCFImportOptions.LoadUseAll) { string savname = name; - int count = 0; - foreach (FormatInfo fi in fil) if (fi.Name.EndsWith(name)) count++; - if (count > 0) + int count = (fil.Where(fi => fi.Name.EndsWith(name))).Count(); + if (count > 0) { name = string.Format("Old {0} of {1}", count.ToString(), name); } @@ -1240,239 +1209,18 @@ namespace VEPROMS // See if there is an existing format file that was created as a copy. If so, check if the passed in format's // config is the same as an existing 'Copy of' format - if so, use rather than importing the same format as // defined by config. - foreach (var existname in existingFormat) + foreach (var existname in existingFormat.Where(existname => existname.Key.Contains(name))) { - if (existname.Key.Contains(name)) - { string cpy = existname.Key; if (cpy.StartsWith("Copy") && cpy.Contains("of " + name)) { FormatInfo exFI = FormatInfo.Get(existingFormat[cpy]); if (exFI.Config == config) return cpy; } - } } return null; } - //jsj 4-29-2016 appears to not be used - //Dictionary dicParentItem = null; - //private void UpdateParentItem(int depth, ItemInfo ii) - //{ - // if (dicParentItem == null) dicParentItem = new Dictionary(); - // if (!dicParentItem.ContainsKey(depth)) dicParentItem.Add(depth, null); - // dicParentItem[depth] = ii; - //} - - //jsj 4-29-2016 appears to not be used - //Dictionary dicPreviousItem = null; - //private void UpdatePreviousItem(int depth, ItemInfo ii) - //{ - // if (dicPreviousItem == null) dicPreviousItem = new Dictionary(); - // if (!dicPreviousItem.ContainsKey(depth)) dicPreviousItem.Add(depth, null); - // dicPreviousItem[depth] = ii; - //} - - Dictionary dicItemDepth = null; - - // jsj 4-29-2016 appears to not be used - //private void UpdateItemDepth(int depth, int id) - //{ - // if (dicItemDepth == null) dicItemDepth = new Dictionary(); - // if (!dicItemDepth.ContainsKey(depth)) dicItemDepth.Add(depth, 0); - // dicItemDepth[depth] = id; - //} - // jsj 2016Feb17 - this appears to not be used - //private void LoadImportDataReader() - //{ - // int pCount = 0; - // int sCount = 0; - // Folder folder = null; - // DocVersion docversion = null; - // Dictionary dicRofst = null; - // Dictionary dicEntry = null; - // ROFst rofst = null; - // GetImportDataCounts(); - // pbImportProcedure.Maximum = MyCounts.Count; - // pbImportProcedure.Value = 0; - // Application.DoEvents(); - // FileStream fs = File.OpenRead(txtImport.Text); - // XmlReaderSettings rs = new XmlReaderSettings(); - // rs.CheckCharacters = false; - // XmlReader xr = XmlReader.Create(fs, rs); - // while (xr.Read()) - // { - // if (xr.IsStartElement()) - // { - // switch (xr.Name) - // { - // case "annotation": - // AddAnnotation(xr); - // break; - // //case "association": - // // break; - // case "content": - // { - // if (xr.Depth == 3) //content for procedure - // { - // ItemInfo ii = AddProcedure(xr, docversion, dicPreviousItem[xr.Depth], dicItemDepth[xr.Depth]); - // UpdatePreviousItem(xr.Depth, ii); - // UpdateParentItem(xr.Depth, ii); - // } - // else - // { - - // int fromtype = dicItemDepth.ContainsKey(xr.Depth - 2) ? dicItemDepth[xr.Depth - 2] : 0; - // switch (fromtype) - // { - // case 2: - // { //sections - // ItemInfo ii = AddSection(xr, dicParentItem[xr.Depth], dicPreviousItem[xr.Depth], dicItemDepth[xr.Depth]); - // UpdatePreviousItem(xr.Depth, ii); - // UpdateParentItem(xr.Depth, ii); - // break; - // } - // case 3: - // { //cautions - // ItemInfo ii = AddCaution(xr, dicParentItem[xr.Depth], dicPreviousItem[xr.Depth], dicItemDepth[xr.Depth]); - // UpdatePreviousItem(xr.Depth, ii); - // UpdateParentItem(xr.Depth, ii); - // break; - // } - // case 4: - // { //notes - // ItemInfo ii = AddNote(xr, dicParentItem[xr.Depth], dicPreviousItem[xr.Depth], dicItemDepth[xr.Depth]); - // UpdatePreviousItem(xr.Depth, ii); - // UpdateParentItem(xr.Depth, ii); - // break; - // } - // case 5: - // { //rnos - // ItemInfo ii = AddRNO(xr, dicParentItem[xr.Depth], dicPreviousItem[xr.Depth], dicItemDepth[xr.Depth]); - // UpdatePreviousItem(xr.Depth, ii); - // UpdateParentItem(xr.Depth, ii); - // break; - // } - // case 6: - // { //steps - // ItemInfo ii = AddStep(xr, dicParentItem[xr.Depth], dicPreviousItem[xr.Depth], dicItemDepth[xr.Depth]); - // UpdatePreviousItem(xr.Depth, ii); - // UpdateParentItem(xr.Depth, ii); - // break; - // } - // case 7: - // { //tables - // ItemInfo ii = AddTable(xr, dicParentItem[xr.Depth], dicPreviousItem[xr.Depth], dicItemDepth[xr.Depth]); - // UpdatePreviousItem(xr.Depth, ii); - // UpdateParentItem(xr.Depth, ii); - // break; - // } - // default: - // break; - // } - // } - // break; - // } - // case "document": - // AddDocument(xr, dicEntry); - // break; - // case "docversion": - // { - // docversion = AddDocVersion(folder, xr); - // UpdatePreviousItem(xr.Depth + 2, null); - // break; - // } - // case "entry": - // dicEntry = AddEntry(xr); - // break; - // case "folder": - // folder = AddFolder(Folder.Get(MyFolder.FolderID), xr); - // break; - // case "grid": - // AddGrid(xr); - // break; - // case "procedure": - // { - // UpdateItemDepth(xr.Depth + 1, int.Parse(xr.GetAttribute("itemid"))); - // pbImportProcedure.PerformStep(); - // lblImportProcedure.Text = string.Format("{0} of {1} Procedures", pbImportProcedure.Value.ToString(), pbImportProcedure.Maximum.ToString()); - // pCount++; - // pbImportSection.Maximum = MyCounts[pCount].Count; - // pbImportSection.Value = 0; - // sCount = 0; - // Application.DoEvents(); - // break; - // } - // case "section": - // { - // UpdateItemDepth(xr.Depth + 1, int.Parse(xr.GetAttribute("itemid"))); - // pbImportSection.PerformStep(); - // lblImportSection.Text = string.Format("{0} of {1} Sections", pbImportSection.Value.ToString(), pbImportSection.Maximum.ToString()); - // sCount++; - // pbImportStep.Maximum = MyCounts[pCount][sCount]; - // pbImportStep.Value = 0; - // Application.DoEvents(); - // break; - // } - // case "step": - // { - // UpdateItemDepth(xr.Depth + 1, int.Parse(xr.GetAttribute("itemid"))); - // if (xr.Depth == 8) - // { - // pbImportStep.PerformStep(); - // lblImportStep.Text = string.Format("{0} of {1} Steps", pbImportStep.Value.ToString(), pbImportStep.Maximum.ToString()); - // Application.DoEvents(); - // } - // break; - // } - // case "caution": - // case "note": - // case "rno": - // case "table": - // UpdateItemDepth(xr.Depth + 1, int.Parse(xr.GetAttribute("itemid"))); - // break; - // case "cautions": - // case "notes": - // case "rnos": - // case "sections": - // case "steps": - // case "tables": - // { - // UpdateItemDepth(xr.Depth, int.Parse(xr.GetAttribute("fromtype"))); - // UpdatePreviousItem(xr.Depth + 2, null); - // UpdateParentItem(xr.Depth + 2, dicParentItem[xr.Depth - 1]); - // break; - // } - // case "rodb": - // { - // MyRODb = AddRODb(xr); - // rofst = AddROFst(dicRofst); - // docversion.DocVersionAssociations.Add(rofst); - // docversion.Save(); - // break; - // } - // case "rofst": - // dicRofst = GetROFstData(xr); - // break; - // case "rousage": - // AddROUsage(xr); - // break; - // //case "transition": - // // break; - // default: - // break; - // } - // Console.WriteLine("{0} - {1}", xr.Name, xr.Depth.ToString()); - // } - // } - // pbImportProcedure.PerformStep(); - // Application.DoEvents(); - // fs.Close(); - // FixImportDataTransitions(); - // StoreItemContentIDs(); - // ResolveExternalTransitions(folder); - //} - // This is called only when we are importing an entire folder. // if there is a .impx file (a zip file generated from the last folder export file and based on location -folder name- of the export file you are importing), then it updates it with new values, // else it will create a .impx file, and saves the id information listed below. @@ -1536,78 +1284,6 @@ namespace VEPROMS MyImpxZipFile.Save(); File.Delete(fn); } - // appears to not be used - jsj 4-28-2016 - //private void StoreItemContentIDs() - //{ - // XmlDocument xd = new XmlDocument(); - // string fn = PEIPath + @"\ExternalTransitions.xml"; - // xd.Load(fn); - // XmlElement xe = (XmlElement)xd.SelectSingleNode("externaltransitions/oldtonewitem"); - // foreach (int key in Old2NewItem.Keys) - // { - // XmlElement xee = xd.CreateElement("item"); - // XmlAttribute xa = AddAttribute(xd, "old", key.ToString()); - // xee.Attributes.SetNamedItem(xa); - // xa = AddAttribute(xd, "new", Old2NewItem[key].ToString()); - // xee.Attributes.SetNamedItem(xa); - // xe.AppendChild(xee); - // } - // xd.Save(fn); - // xe = (XmlElement)xd.SelectSingleNode("externaltransitions/oldtonewcontent"); - // foreach (int key in Old2NewContent.Keys) - // { - // XmlElement xee = xd.CreateElement("content"); - // XmlAttribute xa = AddAttribute(xd, "old", key.ToString()); - // xee.Attributes.SetNamedItem(xa); - // xa = AddAttribute(xd, "new", Old2NewContent[key].ToString()); - // xee.Attributes.SetNamedItem(xa); - // xe.AppendChild(xee); - // } - // xd.Save(fn); - //} - //private void ResolveExternalTransitions(Folder folder) - //{ - // XmlDocument xd = new XmlDocument(); - // string fn = PEIPath + @"\ExternalTransitions.xml"; - // xd.Load(fn); - // AddStoredItemContentIDs(xd); - // XmlNodeList nl = xd.SelectNodes("//transition[@folder!='']"); - // foreach (XmlNode nd in nl) - // { - // int transitionid = int.Parse(nd.Attributes.GetNamedItem("transitionid").InnerText); - // int fromid = int.Parse(nd.Attributes.GetNamedItem("fromid").InnerText); - // int toid = int.Parse(nd.Attributes.GetNamedItem("toid").InnerText); - // int rangeid = int.Parse(nd.Attributes.GetNamedItem("rangeid").InnerText); - // if (Old2NewContent.ContainsKey(fromid) && Old2NewItem.ContainsKey(toid) && Old2NewItem.ContainsKey(rangeid)) - // { - // int isrange = int.Parse(nd.Attributes.GetNamedItem("isrange").InnerText); - // int trantype = int.Parse(nd.Attributes.GetNamedItem("trantype").InnerText); - // string config = nd.Attributes.GetNamedItem("config").InnerText; - // string userid = nd.Attributes.GetNamedItem("userid").InnerText; - // DateTime dts = DateTime.Parse(nd.Attributes.GetNamedItem("dts").InnerText); - // string lookfor; - // if (isrange == 0) - // lookfor = string.Format("#Link:Transition:{0} {1} {2}", trantype, transitionid, toid); - // else - // lookfor = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid); - // fromid = Old2NewContent[fromid]; - // toid = Old2NewItem[toid]; - // rangeid = Old2NewItem[rangeid]; - // Content cc = Content.Get(fromid); - // Transition tt = Transition.MakeTransition(cc, Item.Get(toid), Item.Get(rangeid), isrange, trantype, config, dts, userid); - // transitionid = tt.TransitionID; - // string replacewith; - // if (isrange == 0) - // replacewith = string.Format("#Link:Transition:{0} {1} {2}", trantype, transitionid, toid); - // else - // replacewith = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid); - // cc.Text = cc.Text.Replace(lookfor, replacewith); - // cc.Save(); - // nd.Attributes.GetNamedItem("folder").InnerText = ""; - // } - // } - // xd.Save(fn); - //} // This is called only when we are importing an entire folder and there is a .impx file (a zip file) // the name of the .impx file is based on the folder name containing the export file being imported @@ -1620,14 +1296,6 @@ namespace VEPROMS XmlDocument xd = new XmlDocument(); xd.Load(fn); // B2016-176, B2016-197 Transitions were no always properly resolved - don't load in the old item ids - //XmlNodeList nl = xd.SelectNodes("//item"); - //foreach (XmlNode nd in nl) - //{ - // int oldid = int.Parse(nd.Attributes.GetNamedItem("old").InnerText); - // int newid = int.Parse(nd.Attributes.GetNamedItem("new").InnerText); - // //if (!Old2NewItem.ContainsKey(oldid)) - // Old2NewItem.Add(oldid, newid); - //} File.Delete(fn); ze = MyImpxZipFile["contents.xml"]; ze.Extract(PEIPath, ExtractExistingFileAction.OverwriteSilently); @@ -1635,14 +1303,6 @@ namespace VEPROMS xd = new XmlDocument(); xd.Load(fn); // B2016-176, B2016-197 Transitions were no always properly resolved - don't load in the old content ids - //nl = xd.SelectNodes("//content"); - //foreach (XmlNode nd in nl) - //{ - // int oldid = int.Parse(nd.Attributes.GetNamedItem("old").InnerText); - // int newid = int.Parse(nd.Attributes.GetNamedItem("new").InnerText); - // //if (!Old2NewContent.ContainsKey(oldid)) - // Old2NewContent.Add(oldid, newid); - //} File.Delete(fn); ze = MyImpxZipFile["libdocs.xml"]; ze.Extract(PEIPath, ExtractExistingFileAction.OverwriteSilently); @@ -1650,7 +1310,6 @@ namespace VEPROMS xd = new XmlDocument(); xd.Load(fn); XmlNodeList nl = xd.SelectNodes("//libdoc"); - //nl = xd.SelectNodes("//libdoc"); foreach (XmlNode nd in nl) { int oldid = int.Parse(nd.Attributes.GetNamedItem("old").InnerText); @@ -1665,133 +1324,6 @@ namespace VEPROMS PendingTransitions.Load(fn); File.Delete(fn); } - // appears not to be used - jsj 4-28-2016 - //private void AddStoredItemContentIDs(XmlDocument xd) - //{ - // XmlNodeList nl = xd.SelectNodes("//item"); - // foreach (XmlNode nd in nl) - // { - // int oldid = int.Parse(nd.Attributes.GetNamedItem("old").InnerText); - // int newid = int.Parse(nd.Attributes.GetNamedItem("new").InnerText); - // if (!Old2NewItem.ContainsKey(oldid)) - // Old2NewItem.Add(oldid, newid); - // } - // nl = xd.SelectNodes("//content"); - // foreach (XmlNode nd in nl) - // { - // int oldid = int.Parse(nd.Attributes.GetNamedItem("old").InnerText); - // int newid = int.Parse(nd.Attributes.GetNamedItem("new").InnerText); - // if (!Old2NewContent.ContainsKey(oldid)) - // Old2NewContent.Add(oldid, newid); - // } - //} - - // appears not to be used - jsj 4-28-2016 - //private void FixImportDataTransitions() - //{ - // XmlDocument xd = new XmlDocument(); - // string fn = PEIPath + @"\ExternalTransitions.xml"; - // if (!File.Exists(fn)) - // { - // XmlElement xe = xd.CreateElement("externaltransitions"); - // XmlElement xee = xd.CreateElement("oldtonewitem"); - // xe.AppendChild(xee); - // xee = xd.CreateElement("oldtonewcontent"); - // xe.AppendChild(xee); - // xee = xd.CreateElement("transitions"); - // xe.AppendChild(xee); - // xd.AppendChild(xe); - // xd.Save(fn); - // } - // else - // { - // xd.Load(fn); - // } - // FileStream fs = File.OpenRead(txtImport.Text); - // XmlReaderSettings rs = new XmlReaderSettings(); - // rs.CheckCharacters = false; - // XmlReader xr = XmlReader.Create(fs, rs); - // while (xr.Read()) - // { - // if (xr.IsStartElement()) - // { - // switch (xr.Name) - // { - // case "transition": - // AddTransitions(xr); - // break; - // case "externaltransition": - // { - // AddExternalTransition(xr, xd); - // break; - // } - // default: - // break; - // } - // } - // } - // fs.Close(); - // xd.Save(fn); - //} - - // jsj 4-29-2016 appears to not be used - //private Dictionary> MyCounts = null; - //private Dictionary MySubCounts = null; - //private void GetImportDataCounts() - //{ - // int pCount = 0; - // int sCount = 0; - // int tCount = 0; - // MyCounts = new Dictionary>(); - // MySubCounts = new Dictionary(); - // FileStream fs = File.OpenRead(txtImport.Text); - // XmlReaderSettings rs = new XmlReaderSettings(); - // rs.CheckCharacters = false; - // XmlReader xr = XmlReader.Create(fs, rs); - // while (xr.Read()) - // { - // if (xr.IsStartElement()) - // { - // switch (xr.Name) - // { - // case "procedure": - // { - // if (pCount > 0) - // { - // MySubCounts.Add(sCount, tCount); - // MyCounts.Add(pCount, MySubCounts); - // sCount = 0; - // tCount = 0; - // MySubCounts = new Dictionary(); - // } - // pCount++; - // break; - // } - // case "section": - // { - // if (sCount > 0) - // { - // MySubCounts.Add(sCount, tCount); - // tCount = 0; - // } - // sCount++; - // break; - // } - // case "step": - // { - // if (xr.Depth == 8) - // tCount++; - // break; - // } - // default: - // break; - // } - // } - // } - // MySubCounts.Add(sCount, tCount); - // MyCounts.Add(pCount, MySubCounts); - // fs.Close(); - //} private void btnImport_Click(object sender, EventArgs e) { @@ -1981,46 +1513,6 @@ namespace VEPROMS xn.AppendChild(xe); } - // jsj 4-29-2016 appears to not be used - //private void ExportFolder(FolderInfo fi, string nodename) - //{ - // /* - // FolderID - // ParentID - // DBID - // Name - // Title - // ShortName - // FormatID - // ManualOrder - // Config - // DTS - // UsrID - // */ - // string formatFileName = (fi.MyFormat != null) ? fi.MyFormat.Name : ""; - // FromFolderName = fi.Name; - // MyWriter.WriteStartDocument(); - // MyWriter.WriteStartElement(nodename); - // MyWriter.WriteAttributeString("folderid", fi.FolderID.ToString()); - // MyWriter.WriteAttributeString("parentid", fi.ParentID.ToString()); - // MyWriter.WriteAttributeString("dbid", fi.DBID.ToString()); - // MyWriter.WriteAttributeString("name", fi.Name); - // MyWriter.WriteAttributeString("title", fi.Title); - // MyWriter.WriteAttributeString("shortname", fi.ShortName); - // MyWriter.WriteAttributeString("formatid", fi.FormatID.ToString()); - // MyWriter.WriteAttributeString("manualorder", fi.ManualOrder.ToString()); - // MyWriter.WriteAttributeString("config", fi.Config); - // MyWriter.WriteAttributeString("dts", fi.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); - // MyWriter.WriteAttributeString("usrid", fi.UsrID.ToString()); - // MyWriter.WriteAttributeString("formatfilename", formatFileName); - - // if (fi.FolderDocVersionCount > 0) - // foreach (DocVersionInfo dvi in fi.FolderDocVersions) - // ExportDocVersion(dvi, "docversion"); - // MyWriter.WriteEndElement(); - // MyWriter.WriteEndDocument(); - //} - // bug fix: B2017-082 don't export if no RO Path - display an message to the user to assign a RO Path private bool ValidDocVersionAssociation(DocVersionInfo dvi) { @@ -2070,7 +1562,7 @@ namespace VEPROMS xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "name", dvi.Name)); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "title", dvi.Title)); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "itemid", dvi.ItemID.ToString())); - xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "formatid", tmpFormatID.ToString()));//dvi.FormatID.ToString())); + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "formatid", tmpFormatID.ToString())); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "config", dvi.Config)); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", dvi.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff"))); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", dvi.UserID.ToString())); @@ -2107,48 +1599,6 @@ namespace VEPROMS } } } - private void ExportDocVersion(DocVersionInfo dvi, string nodename) - { - /* - VersionID - FolderID - VersionType - Name - Title - ItemID - FormatID - Config - DTS - UserID - */ - string formatFileName = (dvi.MyFormat != null) ? dvi.MyFormat.Name : ""; - MyWriter.WriteStartElement(nodename); - MyWriter.WriteAttributeString("versionid", dvi.VersionID.ToString()); - MyWriter.WriteAttributeString("folderid", dvi.FolderID.ToString()); - MyWriter.WriteAttributeString("versiontype", dvi.VersionType.ToString()); - MyWriter.WriteAttributeString("name", dvi.Name); - MyWriter.WriteAttributeString("title", dvi.Title); - MyWriter.WriteAttributeString("itemid", dvi.ItemID.ToString()); - MyWriter.WriteAttributeString("formatid", dvi.FormatID.ToString()); - MyWriter.WriteAttributeString("config", dvi.Config); - MyWriter.WriteAttributeString("dts", dvi.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); - MyWriter.WriteAttributeString("userid", dvi.UserID.ToString()); - MyWriter.WriteAttributeString("formatfilename", formatFileName); - if (dvi.DocVersionAssociationCount > 0) - foreach (AssociationInfo ai in dvi.DocVersionAssociations) - ExportAssociation(ai, "association"); - if (dvi.Procedures.Count > 0) - { - pbExportProcedure.Value = 0; - pbExportProcedure.Maximum = dvi.Procedures.Count; - lblExportProcedure.Text = pbExportProcedure.Maximum.ToString() + " Procedures"; - foreach (ItemInfo ii in dvi.Procedures) - { - ExportItem(ii, "procedure"); - } - } - MyWriter.WriteEndElement(); - } private void ExportAssociation(XmlElement xn, AssociationInfo ai, string nodename) { /* @@ -2171,27 +1621,6 @@ namespace VEPROMS xn.AppendChild(xe); ExportROFst(xe, ai.MyROFst, "rofst"); } - private void ExportAssociation(AssociationInfo ai, string nodename) - { - /* - AssociationID - VersionID - ROFstID - Config - DTS - UserID - */ - MyWriter.WriteStartElement(nodename); - MyWriter.WriteAttributeString("associationid", ai.AssociationID.ToString()); - MyWriter.WriteAttributeString("versionid", ai.VersionID.ToString()); - MyWriter.WriteAttributeString("rofstid", ai.ROFstID.ToString()); - MyWriter.WriteAttributeString("config", ai.Config); - MyWriter.WriteAttributeString("dts", ai.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); - MyWriter.WriteAttributeString("userid", ai.UserID.ToString()); - ExportROFst(ai.MyROFst, "rofst"); - MyWriter.WriteEndElement(); - } - private void ExportROFst(XmlElement xn, ROFstInfo fst, string nodename) { /* @@ -2218,28 +1647,6 @@ namespace VEPROMS ExportRODb(xe, fst.MyRODb, "rodb"); } - private void ExportROFst(ROFstInfo fst, string nodename) - { - /* - ROFstID - RODbID - ROLookup - Config - DTS - UserID - */ - MyWriter.WriteStartElement(nodename); - MyWriter.WriteAttributeString("rofstid", fst.ROFstID.ToString()); - MyWriter.WriteAttributeString("rodbid", fst.RODbID.ToString()); - MyWriter.WriteAttributeString("rolookup", Convert.ToBase64String(ROFSTLookup.GetRofstLookupBytes(fst.ROFstID))); // B2022-026 RO Memory reduction - new calls - MyWriter.WriteAttributeString("config", fst.Config); - MyWriter.WriteAttributeString("dts", fst.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); - MyWriter.WriteAttributeString("userid", fst.UserID.ToString()); - - ExportRODb(fst.MyRODb, "rodb"); - MyWriter.WriteEndElement(); - } - private void ExportFigures(XmlElement xn, ROFstInfo fst) { if (fst.ROFstFigureCount > 0) @@ -2306,28 +1713,6 @@ namespace VEPROMS xn.AppendChild(xe); } - private void ExportRODb(RODbInfo db, string nodename) - { - /* - RODbID - ROName - FolderPath - DBConnectionString - Config - DTS - UserID - */ - MyWriter.WriteStartElement(nodename); - MyWriter.WriteAttributeString("rodbid", db.RODbID.ToString()); - MyWriter.WriteAttributeString("roname", db.ROName); - MyWriter.WriteAttributeString("folderpath", db.FolderPath); - MyWriter.WriteAttributeString("dbconnectionstring", db.DBConnectionString); - MyWriter.WriteAttributeString("config", db.Config); - MyWriter.WriteAttributeString("dts", db.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); - MyWriter.WriteAttributeString("userid", db.UserID.ToString()); - MyWriter.WriteEndElement(); - } - public void ExportItem(XmlDocument xd, ItemInfo ii, string nodename) { XmlElement xe = xd.CreateElement(nodename); @@ -2434,7 +1819,28 @@ namespace VEPROMS //and handled/overridden in dlgExportEP.cs } - private void ExportItemAudits(XmlElement xn, ItemInfo ii) + protected virtual void SetROLocation(ref XmlElement xindivid, ROFSTLookup.rochild roc, RODbInfo rodb, bool isMulti) + { + //do nothing - this will be for Electronic procedures only + //and handled/overridden in dlgExportEP.cs + } + + //C2025-024 Electronic Procedures Phase 2 - XML Export + //use overridden method to set the location for ROs + protected void SetROLocation(ref XmlElement xindivid, string roid, int rodbid) + { + ROFSTLookup lookup = MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(MyDocVersion); + + using (RODbInfo myRODB = RODbInfoList.Get().FirstOrDefault(x => x.RODbID == rodbid)) + { + roid = ROFSTLookup.FormatRoidKey(roid, true); + ROFSTLookup.rochild roc = lookup.GetRoChild(roid); + SetROLocation(ref xindivid, roc, myRODB, roc.type != 8); + } + + } + + private void ExportItemAudits(XmlElement xn, ItemInfo ii) { if (cbxExportAudits.Checked) { @@ -2479,76 +1885,6 @@ namespace VEPROMS } } - private void ExportItem(ItemInfo ii, string nodename) - { - /* - ItemID - PreviousID - ContentID - DTS - */ - if (ii.IsProcedure) - { - pbExportProcedure.PerformStep(); - lblExportProcedure.Text = string.Format("{0} of {1} Procedures", pbExportProcedure.Value.ToString(), pbExportProcedure.Maximum.ToString()); - Application.DoEvents(); - - pbExportSection.Value = 0; - pbExportStep.Value = 0; - pbExportSection.Maximum = ii.Sections.Count; - - if (ii.Sections != null) - pbExportSection.Maximum = ii.Sections.Count; - else - { - pbExportSection.Maximum = 1; - pbExportSection.PerformStep(); - pbExportStep.Maximum = 1; - pbExportStep.PerformStep(); - lblExportSection.Text = "Sections"; - lblExportStep.Text = "Steps"; - Application.DoEvents(); - } - } - - if (ii.IsSection) - { - pbExportSection.PerformStep(); - lblExportSection.Text = string.Format("{0} of {1} Sections", pbExportSection.Value.ToString(), pbExportSection.Maximum.ToString()); - Application.DoEvents(); - pbExportStep.Value = 0; - if (ii.Steps != null) - pbExportStep.Maximum = ii.Steps.Count; - else - { - pbExportStep.Maximum = 1; - pbExportStep.PerformStep(); - lblExportStep.Text = "Word Section Data"; - Application.DoEvents(); - } - } - - if (ii.IsStep) - { - pbExportStep.PerformStep(); - lblExportStep.Text = string.Format("{0} of {1} Steps", pbExportStep.Value.ToString(), pbExportStep.Maximum.ToString()); - Application.DoEvents(); - } - - MyWriter.WriteStartElement(nodename); - MyWriter.WriteAttributeString("itemid", ii.ItemID.ToString()); - MyWriter.WriteAttributeString("previousid", ii.PreviousID.ToString()); - MyWriter.WriteAttributeString("contentid", ii.ContentID.ToString()); - MyWriter.WriteAttributeString("dts", ii.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); - - ExportContent(ii.MyContent, "content"); - if (ii.ItemAnnotationCount > 0) - foreach (AnnotationInfo ai in ii.ItemAnnotations) - ExportAnnotation(ai, "annotation"); - - MyWriter.WriteEndElement(); - } - private void ExportContent(XmlElement xn, ContentInfo ci, string nodename) { /* @@ -2587,7 +1923,7 @@ namespace VEPROMS if (ci.ContentRoUsageCount > 0) foreach (RoUsageInfo ri in ci.ContentRoUsages) - ExportROUsage(xe, ri, "rousage"); + ExportROUsage(xe, ri, "rousage"); if (ci.ContentEntryCount > 0) ExportEntry(xe, ci.MyEntry, "entry"); @@ -2636,58 +1972,6 @@ namespace VEPROMS } } - private void ExportContent(ContentInfo ci, string nodename) - { - /* - ContentID - Number - Text - Type - FormatID - Config - DTS - UserID - */ - // strip the link information if we are convertinga the ROs and Transitions to text - string ciText = (_ConvertROsAndTransitionsToText) ? ItemInfo.StripLinks(ci.Text) : ci.Text; - string formatFileName = (ci.MyFormat != null) ? ci.MyFormat.Name : ""; - - MyWriter.WriteStartElement(nodename); - MyWriter.WriteAttributeString("contentid", ci.ContentID.ToString()); - MyWriter.WriteAttributeString("number", ci.Number); - MyWriter.WriteAttributeString("text", ciText); - MyWriter.WriteAttributeString("type", ci.Type.ToString()); - MyWriter.WriteAttributeString("formatid", ci.FormatID.ToString()); - MyWriter.WriteAttributeString("config", ci.Config); - MyWriter.WriteAttributeString("dts", ci.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); - MyWriter.WriteAttributeString("userid", ci.UserID.ToString()); - MyWriter.WriteAttributeString("formatfilename", formatFileName); - if (_ExportBothConvertedandNot) MyWriter.WriteAttributeString("textwithlinks", ci.Text); - - if (ci.ContentTransitionCount > 0) - foreach (TransitionInfo ti in ci.ContentTransitions) - ExportTransition(ti, "transition"); - - if (ci.ContentRoUsageCount > 0) - foreach (RoUsageInfo ri in ci.ContentRoUsages) - ExportROUsage(ri, "rousage"); - - if (ci.ContentEntryCount > 0) - ExportEntry(ci.MyEntry, "entry"); - - if (ci.ContentGridCount > 0) - ExportGrid(ci.MyGrid, "grid"); - - if (ci.ContentImageCount > 0) - ExportImage(ci.MyImage, "image"); - - if (ci.ContentPartCount > 0) - foreach (PartInfo pi in ci.ContentParts) - ExportPart(pi, ((E_FromTypes)pi.FromType).ToString().ToLower()); - - MyWriter.WriteEndElement(); - } - private void ExportGrid(XmlElement xn, GridInfo gi, string nodename) { /* @@ -2748,32 +2032,6 @@ namespace VEPROMS } } - private void ExportGrid(GridInfo gi, string nodename) - { - /* - ContentID - Data - Config - DTS - UserID - */ - string giData = gi.Data; - if (_ConvertROsAndTransitionsToText) - { - giData = giData.Replace("IsRoTable>True", "IsRoTable>False"); // converts a RO table to regular table - giData = ItemInfo.StripLinks(giData); // converts ROs and Transitions to text - } - - MyWriter.WriteStartElement(nodename); - MyWriter.WriteAttributeString("contentid", gi.ContentID.ToString()); - MyWriter.WriteAttributeString("data", giData); - MyWriter.WriteAttributeString("config", gi.Config); - MyWriter.WriteAttributeString("dts", gi.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); - MyWriter.WriteAttributeString("userid", gi.UserID.ToString()); - if (_ExportBothConvertedandNot) MyWriter.WriteAttributeString("datawithlinks", gi.Data); - MyWriter.WriteEndElement(); - } - private void ExportEntry(XmlElement xn, EntryInfo ei, string nodename) { /* @@ -2822,23 +2080,6 @@ namespace VEPROMS } } - private void ExportEntry(EntryInfo ei, string nodename) - { - /* - ContentID - DocID - DTS - UserID - */ - MyWriter.WriteStartElement(nodename); - MyWriter.WriteAttributeString("contentid", ei.ContentID.ToString()); - MyWriter.WriteAttributeString("docid", ei.DocID.ToString()); - MyWriter.WriteAttributeString("dts", ei.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); - MyWriter.WriteAttributeString("userid", ei.UserID.ToString()); - ExportDocument(ei.MyDocument, "document"); - MyWriter.WriteEndElement(); - } - private void ExportImage(XmlElement xn, ImageInfo ii, string nodename) { /* @@ -2894,28 +2135,6 @@ namespace VEPROMS } } - private void ExportImage(ImageInfo ii, string nodename) - { - /* - ContentID - ImageType - FileName - Data - Config - DTS - UserID - */ - MyWriter.WriteStartElement(nodename); - MyWriter.WriteAttributeString("contentid", ii.ContentID.ToString()); - MyWriter.WriteAttributeString("imagetype", ii.ImageType.ToString()); - MyWriter.WriteAttributeString("filename", ii.FileName); - MyWriter.WriteAttributeString("data", Convert.ToBase64String(ii.Data)); - MyWriter.WriteAttributeString("config", ii.Config); - MyWriter.WriteAttributeString("dts", ii.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); - MyWriter.WriteAttributeString("userid", ii.UserID.ToString()); - MyWriter.WriteEndElement(); - } - private void ExportDocument(XmlElement xn, DocumentInfo di, string nodename) { /* @@ -2938,7 +2157,7 @@ namespace VEPROMS XmlElement xe = xn.OwnerDocument.CreateElement(nodename); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "docid", di.DocID.ToString())); - xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "libtitle", libDocTitle)); // di.LibTitle)); + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "libtitle", libDocTitle)); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "doccontent", Convert.ToBase64String(buf))); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "docascii", di.DocAscii)); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "config", di.Config)); @@ -2983,38 +2202,6 @@ namespace VEPROMS } } } - private void ExportDocument(DocumentInfo di, string nodename) - { - /* - DocID - LibTitle - DocContent - DocAscii - Config - DTS - UserID - FileExtension - */ - byte[] buf = di.DocContent; - string libDocTitle = di.LibTitle; - if (DocReplace != null && DocReplace.ContainsKey(di.DocID) && _ConvertROsAndTransitionsToText) - { - buf = DocReplace[di.DocID]; - libDocTitle = null; // unlink the word section from the library document - } - - MyWriter.WriteStartElement(nodename); - MyWriter.WriteAttributeString("docid", di.DocID.ToString()); - MyWriter.WriteAttributeString("libtitle", libDocTitle);// di.LibTitle); - MyWriter.WriteAttributeString("doccontent", Convert.ToBase64String(buf)); - MyWriter.WriteAttributeString("docascii", di.DocAscii); - MyWriter.WriteAttributeString("config", di.Config); - MyWriter.WriteAttributeString("dts", di.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); - MyWriter.WriteAttributeString("userid", di.UserID.ToString()); - MyWriter.WriteAttributeString("fileextension", di.FileExtension); - if (_ExportBothConvertedandNot) MyWriter.WriteAttributeString("doccontentwithlinks", Convert.ToBase64String(di.DocContent)); - MyWriter.WriteEndElement(); - } private void ExportROUsage(XmlElement xn, RoUsageInfo ri, string nodename) { @@ -3035,7 +2222,8 @@ namespace VEPROMS xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", ri.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff"))); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", ri.UserID.ToString())); 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); @@ -3046,28 +2234,6 @@ namespace VEPROMS if (cbxExportAudits.Checked) { }; } - private void ExportROUsage(RoUsageInfo ri, string nodename) - { - /* - ROUsageID - ContentID - ROID - Config - DTS - UserID - RODbID - */ - MyWriter.WriteStartElement(nodename); - MyWriter.WriteAttributeString("rousageid", ri.ROUsageID.ToString()); - MyWriter.WriteAttributeString("contentid", ri.ContentID.ToString()); - MyWriter.WriteAttributeString("roid", ri.ROID); - MyWriter.WriteAttributeString("config", ri.Config); - MyWriter.WriteAttributeString("dts", ri.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); - MyWriter.WriteAttributeString("userid", ri.UserID.ToString()); - MyWriter.WriteAttributeString("rodbid", ri.RODbID.ToString()); - MyWriter.WriteEndElement(); - } - private void ExportPart(XmlElement xn, PartInfo pi, string nodename) { /* @@ -3120,26 +2286,6 @@ namespace VEPROMS } } - private void ExportPart(PartInfo pi, string nodename) - { - /* - ContentID - FromType - ItemID - DTS - UserID - */ - MyWriter.WriteStartElement(nodename); - MyWriter.WriteAttributeString("contentid", pi.ContentID.ToString()); - MyWriter.WriteAttributeString("fromtype", pi.FromType.ToString()); - MyWriter.WriteAttributeString("itemid", pi.ItemID.ToString()); - MyWriter.WriteAttributeString("dts", pi.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); - MyWriter.WriteAttributeString("userid", pi.UserID.ToString()); - foreach (ItemInfo ii in pi.MyItems) - ExportItem(ii, pi.PartType.ToString().ToLower()); - MyWriter.WriteEndElement(); - } - private void ExportTransition(XmlElement xn, TransitionInfo ti, string nodename) { /* @@ -3174,48 +2320,6 @@ namespace VEPROMS if (cbxExportAudits.Checked) { }; } - private void ExportTransition(TransitionInfo ti, string nodename) - { - /* - TransitionID - FromID - ToID - RangeID - IsRange - TranType - Config - DTS - UserID - */ - string folder = string.Empty; - if (ti.MyItemToID.MyDocVersion != null && ti.MyItemToID.MyDocVersion.MyFolder.Name != MyFolder.Name) - { - nodename = "external" + nodename; - folder = ti.MyItemToID.MyDocVersion.MyFolder.Name; - } - else - { - nodename = "external" + nodename; - folder = "UNKNOWN"; - } - - MyWriter.WriteStartElement(nodename); - - if (folder != string.Empty) - MyWriter.WriteAttributeString("folder", folder); - - MyWriter.WriteAttributeString("transitionid", ti.TransitionID.ToString()); - MyWriter.WriteAttributeString("fromid", ti.FromID.ToString()); - MyWriter.WriteAttributeString("toid", ti.ToID.ToString()); - MyWriter.WriteAttributeString("rangeid", ti.RangeID.ToString()); - MyWriter.WriteAttributeString("isrange", ti.IsRange.ToString()); - MyWriter.WriteAttributeString("trantype", ti.TranType.ToString()); - MyWriter.WriteAttributeString("config", ti.Config); - MyWriter.WriteAttributeString("dts", ti.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); - MyWriter.WriteAttributeString("userid", ti.UserID.ToString()); - MyWriter.WriteEndElement(); - } - private void ExportAnnotation(XmlElement xn, AnnotationInfo ai, string nodename) { /* @@ -3232,7 +2336,6 @@ namespace VEPROMS xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "annotationid", ai.AnnotationID.ToString())); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "itemid", ai.ItemID.ToString())); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "typeid", ai.TypeID.ToString())); - //if(ai.TypeID > 6) xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "typename", ai.MyAnnotationType.Name)); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "rtftext", ai.RtfText)); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "searchtext", ai.SearchText)); @@ -3278,93 +2381,10 @@ namespace VEPROMS } } - private void ExportAnnotation(AnnotationInfo ai, string nodename) - { - /* - AnnotationID - ItemID - TypeID - RtfText - SearchText - Config - DTS - UserID - */ - MyWriter.WriteStartElement(nodename); - MyWriter.WriteAttributeString("annotationid", ai.AnnotationID.ToString()); - MyWriter.WriteAttributeString("itemid", ai.ItemID.ToString()); - MyWriter.WriteAttributeString("typeid", ai.TypeID.ToString()); - MyWriter.WriteAttributeString("rtftext", ai.RtfText); - MyWriter.WriteAttributeString("searchtext", ai.SearchText); - MyWriter.WriteAttributeString("config", ai.Config); - MyWriter.WriteAttributeString("dts", ai.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); - MyWriter.WriteAttributeString("userid", ai.UserID.ToString()); - MyWriter.WriteEndElement(); - } - #endregion #region Import for Merge - // jsj 4-29-2016 appears to not be used - //private void AddExternalTransition(XmlReader xr, XmlDocument xd) - //{ - // XmlElement xe = xd.CreateElement("transition"); - // XmlAttribute xa = AddAttribute(xd, "folder", xr.GetAttribute("folder")); - // xe.Attributes.SetNamedItem(xa); - // xa = AddAttribute(xd, "transitionid", xr.GetAttribute("transitionid")); - // xe.Attributes.SetNamedItem(xa); - // xa = AddAttribute(xd, "fromid", xr.GetAttribute("fromid")); - // xe.Attributes.SetNamedItem(xa); - // xa = AddAttribute(xd, "toid", xr.GetAttribute("toid")); - // xe.Attributes.SetNamedItem(xa); - // xa = AddAttribute(xd, "rangeid", xr.GetAttribute("rangeid")); - // xe.Attributes.SetNamedItem(xa); - // xa = AddAttribute(xd, "isrange", xr.GetAttribute("isrange")); - // xe.Attributes.SetNamedItem(xa); - // xa = AddAttribute(xd, "trantype", xr.GetAttribute("trantype")); - // xe.Attributes.SetNamedItem(xa); - // xa = AddAttribute(xd, "config", xr.GetAttribute("config")); - // xe.Attributes.SetNamedItem(xa); - // xa = AddAttribute(xd, "userid", xr.GetAttribute("userid")); - // xe.Attributes.SetNamedItem(xa); - // xa = AddAttribute(xd, "dts", xr.GetAttribute("dts")); - // xe.Attributes.SetNamedItem(xa); - // xd.SelectSingleNode("externaltransitions/transitions").AppendChild(xe); - //} - - // jsj 4-29-2016 appears to not be used - //private void AddTransitions(XmlReader xr) - //{ - // int transitionid = int.Parse(xr.GetAttribute("transitionid")); - // int fromid = int.Parse(xr.GetAttribute("fromid")); - // int toid = int.Parse(xr.GetAttribute("toid")); - // int rangeid = int.Parse(xr.GetAttribute("rangeid")); - // int isrange = int.Parse(xr.GetAttribute("isrange")); - // int trantype = int.Parse(xr.GetAttribute("trantype")); - // string config = xr.GetAttribute("config"); - // string userid = xr.GetAttribute("userid"); - // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - // string lookfor; - // if (isrange == 0) - // lookfor = string.Format("#Link:Transition:{0} {1} {2}", trantype, transitionid, toid); - // else - // lookfor = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid); - // fromid = Old2NewContent[fromid]; - // toid = Old2NewItem[toid]; - // rangeid = Old2NewItem[rangeid]; - // Content cc = Content.Get(fromid); - // Transition tt = Transition.MakeTransition(cc, Item.Get(toid), Item.Get(rangeid), isrange, trantype, config, dts, userid); - // transitionid = tt.TransitionID; - // string replacewith; - // if (isrange == 0) - // replacewith = string.Format("#Link:Transition:{0} {1} {2}", trantype, transitionid, toid); - // else - // replacewith = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid); - // cc.Text = cc.Text.Replace(lookfor, replacewith); - // cc.Save(); - //} - private bool _DidProcessTransitions = false; // B2017-076 keep track whether we procrocessed Transitions private void AddTransitions(Content content, XmlNode xn) @@ -3408,7 +2428,6 @@ namespace VEPROMS else lookfor = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid); - //fromid = content.ContentID; toid = Old2NewItem[toid]; rangeid = Old2NewItem[rangeid]; Transition tt = Transition.MakeTransition(content, Item.Get(toid), Item.Get(rangeid), isrange, trantype, config, dts, userid); @@ -3574,24 +2593,6 @@ namespace VEPROMS // B2016-176, B2016-197 - external transitions should be converted to text forceConvertToText = true; - //if (TransitionInfo.Get(tt.TransitionID).MyItemToID.ActiveSection != null) - //{ - // SectionConfig sc = TransitionInfo.Get(tt.TransitionID).MyItemToID.ActiveSection.MyConfig as SectionConfig; - // forceConvertToText = (sc.SubSection_Edit == "N"); - //} - //if (!forceConvertToText) //check to see if external with internal format - //{ - // TransitionInfo tran = TransitionInfo.Get(transitionid); - // if (tran.MyContent.ContentItems[0].MyProcedure.ItemID != tran.MyItemToID.MyProcedure.ItemID) - // if (!tran.MyContent.ContentItems[0].ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[tran.TranType].TransMenu.Contains("Proc")) - // forceConvertToText = true; - //} - //if (!forceConvertToText) //check to see if external to different doc version - //{ - // TransitionInfo tran = TransitionInfo.Get(transitionid); - // if (tran.MyContent.ContentItems[0].MyDocVersion.VersionID != tran.MyItemToID.MyDocVersion.VersionID) - // forceConvertToText = true; - //} _DidProcessTransitions |= cc.FixTransitionText(TransitionInfo.Get(tt.TransitionID), forceConvertToText); // B2017-076 FixTransitionText will tell us if transitions were processed/changed // B2017=003 make sure any grid changes are saved. // done here because FixTransitionText() could update the transitions in the grid @@ -3613,32 +2614,12 @@ namespace VEPROMS private XmlDocument PendingTransitions; private RODb MyRODb = null; - // jsj 4-29-2016 appears to not be used - //private Folder AddFolder(Folder folder, XmlReader xr) - //{ - // Old2NewItem = new Dictionary(); - // Old2NewContent = new Dictionary(); - // Old2NewLibDoc = new Dictionary(); - // string title = xr.GetAttribute("title"); - // string name = xr.GetAttribute("name"); - // string shortname = xr.GetAttribute("shortname"); - // string usrid = xr.GetAttribute("usrid"); - // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - // string formatid = xr.GetAttribute("formatid"); - // string formatfilename = xr.GetAttribute("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to - // Format format = formatid == string.Empty ? null : OldToNewFormat(int.Parse(formatid),formatfilename); - // folder = Folder.MakeFolder(folder, folder.MyConnection, name, title, shortname, format, null, dts, usrid); - // //f.Save(); - // return folder; - //} - private Folder AddFolder(Folder p, XmlDocument xd, string name) { lblImportStatus.Text = "Creating Folder..."; Application.DoEvents(); string title = xd.DocumentElement.Attributes.GetNamedItem("title").InnerText; - //string name = xd.DocumentElement.Attributes.GetNamedItem("name").InnerText; string shortname = xd.DocumentElement.Attributes.GetNamedItem("shortname").InnerText; string usrid = xd.DocumentElement.Attributes.GetNamedItem("usrid").InnerText; DateTime dts = DateTime.Parse(xd.DocumentElement.Attributes.GetNamedItem("dts").InnerText); @@ -3677,22 +2658,6 @@ namespace VEPROMS } } - private DocVersion AddDocVersion(Folder f, XmlReader xr) - { - int versiontype = int.Parse(xr.GetAttribute("versiontype")); - string name = xr.GetAttribute("name"); - string config = xr.GetAttribute("config"); - string userid = xr.GetAttribute("userid"); - DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - string formatid = xr.GetAttribute("formatid"); - string formatfilename = xr.GetAttribute("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to - Format format = formatid == string.Empty ? null : OldToNewFormat(int.Parse(formatid), formatfilename); - - DocVersion dv = DocVersion.MakeDocVersion(f, versiontype, name, null, null, format, config, dts, userid); - - return dv; - } - private void AddAnnotationTypes(XmlDocument xd) { XmlNodeList nl = xd.SelectNodes("folder/annotationtypes/annotationtype"); @@ -3739,31 +2704,6 @@ namespace VEPROMS return DocVersionInfo.Get(dv.VersionID); } - // jsj 4-29-2016 appears to not be used - //private Dictionary GetROFstData(XmlReader xr) - //{ - // Dictionary rv = new Dictionary(); - // rv.Add("rolookup", xr.GetAttribute("rolookup")); - // rv.Add("config", xr.GetAttribute("config")); - // rv.Add("userid", xr.GetAttribute("userid")); - // rv.Add("dts", xr.GetAttribute("dts")); - // return rv; - //} - - // jsj 4-29-2016 appears to not be used - //private ROFst AddROFst(Dictionary dic) - //{ - // byte[] rolookup = Convert.FromBase64String(dic["rolookup"]); - // string config = dic["config"]; - // string userid = dic["userid"]; - // DateTime dts = DateTime.Parse(dic["dts"]); - // ROFst rv = null; - // rv = ROFst.GetByRODbID_DTS(MyRODb.RODbID, dts); //MyRODb.DTS); - // if (rv == null) - // rv = ROFst.MakeROFst(MyRODb, rolookup, config, dts, userid); - // return rv; - //} - private ROFst AddROFst(XmlNode xrofst) { lblImportStatus.Text = "Creating ROFst..."; @@ -3855,24 +2795,6 @@ namespace VEPROMS } } - // jsj 4-29-2016 appears to not be used - //private RODb AddRODb(XmlReader xr) - //{ - // oldRODbID = int.Parse(xr.GetAttribute("rodbid")); - // string roname = xr.GetAttribute("roname"); - // string folderpath = xr.GetAttribute("folderpath"); - // string dbconnectionstring = xr.GetAttribute("dbconnectionstring"); - // string config = xr.GetAttribute("config"); - // string userid = xr.GetAttribute("userid"); - // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - // RODb rv = null; - // rv = RODb.GetByFolderPath(folderpath); - // if (rv == null) - // rv = RODb.MakeRODb(roname, folderpath, dbconnectionstring, config, dts, userid); - // newRODbID = rv.RODbID; - // return rv; - //} - private RODb AddRODb(XmlNode xrodb) { lblImportStatus.Text = "Creating RODb..."; @@ -3918,38 +2840,6 @@ namespace VEPROMS return rv; } - // jsj 4-29-2016 appears to not be used - //private int GetProcedureData(XmlReader xr) - //{ - // return int.Parse(xr.GetAttribute("itemid")); - //} - - // jsj 4-29-2016 appears to not be used - //private ItemInfo AddProcedure(XmlReader xr, DocVersion dv, ItemInfo procInfo, int oldid) - //{ - // DocVersionInfo dvInfo = DocVersionInfo.Get(dv.VersionID); - // string number = xr.GetAttribute("number"); - // string text = xr.GetAttribute("text"); - // int proctype = int.Parse(xr.GetAttribute("type")); - // string formatid = xr.GetAttribute("formatid"); - // string config = xr.GetAttribute("config"); - // string userid = xr.GetAttribute("userid"); - // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - // Procedure p = Procedure.MakeProcedure(dvInfo, procInfo, number, text, proctype); - // p.DTS = dts; - // p.UserID = userid; - // string formatfilename = xr.GetAttribute("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to - // if (formatid != string.Empty) - // p.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid),formatfilename); - // p.MyContent.Config = config; - // p.MyContent.DTS = dts; - // p.MyContent.UserID = userid; - // p.Save(); - // Old2NewItem.Add(oldid, p.ItemID); - // Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), p.MyContent.ContentID); - // procInfo = ProcedureInfo.Get(p.ItemID); - // return procInfo; - //} private ProcedureInfo AddProcedure(XmlNode xn, DocVersionInfo dvInfo, ProcedureInfo procInfo) { pbImportProcedure.PerformStep(); @@ -4015,27 +2905,6 @@ namespace VEPROMS return procInfo; } - // jsj 2016Feb16 - This appears to not be used - //private void AddROUsage(XmlReader xr) - //{ - // int contentid = int.Parse(xr.GetAttribute("contentid")); - // contentid = Old2NewContent[contentid]; - // Content content = Content.Get(contentid); - // string rousageid = xr.GetAttribute("rousageid"); - // string roid = xr.GetAttribute("roid"); - // string config = xr.GetAttribute("config"); - // string userid = xr.GetAttribute("userid"); - // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - // RoUsage rou = RoUsage.MakeRoUsage(content, roid, config, dts, userid, MyRODb); - // rou.Save(); - // string lookFor = string.Format("#Link:ReferencedObject:{0} {1} {2}[END>", rousageid, roid, oldRODbID.ToString()); - // string replaceWith = (cbxCvrtROsToText.Checked) ? "" : string.Format("#Link:ReferencedObject:{0} {1} {2}[END>", rou.ROUsageID.ToString(), roid, newRODbID.ToString()); - // if (lookFor != replaceWith) - // { - // content.Text = content.Text.Replace(lookFor, replaceWith); - // content.Save(); - // } - //} private string GetMyPrefix(string text, int start, int lastIndex) { string defPrefix = text.Substring(start - 3, 3); @@ -4158,10 +3027,7 @@ namespace VEPROMS txtRO = txtRO.Replace(@"\u8595?", "\x19"); // Down Arrow - changes to \xd6 Item myitem = content.ContentItems[0].MyItem; // The Using statement caused the content.text to disappear - //using (Item myitem = content.ContentItems[0].MyItem) // so that myitem does not stay in cache - //{ Annotation.MakeAnnotation(myitem, AnnotationType.GetByNameOrCreate("Link Converted To Text"), "", string.Format("RO value ({0}) converted to text", txtRO), null); - //} _DidConvertROsToText |= true; } @@ -4208,7 +3074,7 @@ namespace VEPROMS if (roval == "?") { RoUsageInfo roui = RoUsageInfo.Get(int.Parse(rousageid)); - content.FixContentText(roui, roval, 0, MyDocVersion.DocVersionAssociations[0].MyROFst, null, rousageid); // + " " + roid); + content.FixContentText(roui, roval, 0, MyDocVersion.DocVersionAssociations[0].MyROFst, null, rousageid); _DidConvertROsToText |= true; // B2016-225 (follow through) add annotation when RO is converted to text _DidProcessROs = true; // B2017-076 flag that ROs where processed } @@ -4262,20 +3128,6 @@ namespace VEPROMS } } - // jsj 4-29-2016 appears to not be used - //private void AddAnnotation(XmlReader xr) - //{ - // int itemid = int.Parse(xr.GetAttribute("itemid")); - // itemid = Old2NewItem[itemid]; - // Item itm = Item.Get(itemid); - // int typeid = int.Parse(xr.GetAttribute("typeid")); - // string rtftext = xr.GetAttribute("rtftext"); - // string searchtext = xr.GetAttribute("searchtext"); - // string config = xr.GetAttribute("config"); - // string userid = xr.GetAttribute("userid"); - // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - // Annotation ann = Annotation.MakeAnnotation(itm, AnnotationType.Get(typeid), rtftext, searchtext, config, dts, userid); - //} private void AddImage(Content content, XmlNode xc) { XmlNode xn = xc.SelectSingleNode("image"); @@ -4368,30 +3220,6 @@ namespace VEPROMS prevInfo = AddTable(nd, parentInfo, prevInfo); } - // jsj 2016Feb16 - This appears to not be used - //private ItemInfo AddTable(XmlReader xr, ItemInfo parentInfo, ItemInfo prevInfo, int oldid) - //{ - // string number = xr.GetAttribute("number"); - // string text = xr.GetAttribute("text"); - // int steptype = int.Parse(xr.GetAttribute("type")); - // string formatid = xr.GetAttribute("formatid"); - // string config = xr.GetAttribute("config"); - // string userid = xr.GetAttribute("userid"); - // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - // Step step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.Table); - // step.DTS = dts; - // step.UserID = userid; - // if (formatid != string.Empty) - // step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid)); - // step.MyContent.Config = config; - // step.MyContent.DTS = dts; - // step.MyContent.UserID = userid; - // step.Save(); - // Old2NewItem.Add(oldid, step.ItemID); - // Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), step.MyContent.ContentID); - // prevInfo = StepInfo.Get(step.ItemID); - // return prevInfo; - //} private ItemInfo AddTable(XmlNode xn, ItemInfo parentInfo, ItemInfo prevInfo) { pbImportStep.PerformStep(); @@ -4480,31 +3308,6 @@ namespace VEPROMS prevInfo = AddStep(nd, parentInfo, prevInfo); } - // jsj 4-29-2016 appears to not be used - //private ItemInfo AddStep(XmlReader xr, ItemInfo parentInfo, ItemInfo prevInfo, int oldid) - //{ - // string number = xr.GetAttribute("number"); - // string text = xr.GetAttribute("text"); - // int steptype = int.Parse(xr.GetAttribute("type")); - // string formatid = xr.GetAttribute("formatid"); - // string config = xr.GetAttribute("config"); - // string userid = xr.GetAttribute("userid"); - // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - // Step step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.Step); - // step.DTS = dts; - // step.UserID = userid; - // string formatfilename = xr.GetAttribute("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to - // if (formatid != string.Empty) - // step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid),formatfilename); - // step.MyContent.Config = config; - // step.MyContent.DTS = dts; - // step.MyContent.UserID = userid; - // step.Save(); - // Old2NewItem.Add(oldid, step.ItemID); - // Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), step.MyContent.ContentID); - // prevInfo = StepInfo.Get(step.ItemID); - // return prevInfo; - //} private ItemInfo AddStep(XmlNode xn, ItemInfo parentInfo, ItemInfo prevInfo) { pbImportStep.PerformStep(); @@ -4605,32 +3408,6 @@ namespace VEPROMS prevInfo = AddSupInfo(nd, parentInfo, prevInfo); } - // jsj 4-29-2016 appears to not be used - //private ItemInfo AddRNO(XmlReader xr, ItemInfo parentInfo, ItemInfo prevInfo, int oldid) - //{ - // string number = xr.GetAttribute("number"); - // string text = xr.GetAttribute("text"); - // int steptype = int.Parse(xr.GetAttribute("type")); - // string formatid = xr.GetAttribute("formatid"); - // string config = xr.GetAttribute("config"); - // string userid = xr.GetAttribute("userid"); - // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - // Step step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.RNO); - // step.DTS = dts; - // step.UserID = userid; - // string formatfilename = xr.GetAttribute("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to - // if (formatid != string.Empty) - // step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid), formatfilename); - // step.MyContent.Config = config; - // step.MyContent.DTS = dts; - // step.MyContent.UserID = userid; - // step.Save(); - // Old2NewItem.Add(oldid, step.ItemID); - // Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), step.MyContent.ContentID); - // prevInfo = StepInfo.Get(step.ItemID); - // return prevInfo; - //} - private ItemInfo AddRNO(XmlNode xn, ItemInfo parentInfo, ItemInfo prevInfo) { pbImportStep.PerformStep(); @@ -4745,32 +3522,6 @@ namespace VEPROMS prevInfo = AddNote(nd, parentInfo, prevInfo); } - // jsj 4-29-2016 appears to not be used - //private ItemInfo AddNote(XmlReader xr, ItemInfo parentInfo, ItemInfo prevInfo, int oldid) - //{ - // string number = xr.GetAttribute("number"); - // string text = xr.GetAttribute("text"); - // int steptype = int.Parse(xr.GetAttribute("type")); - // string formatid = xr.GetAttribute("formatid"); - // string config = xr.GetAttribute("config"); - // string userid = xr.GetAttribute("userid"); - // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - // Step step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.Note); - // step.DTS = dts; - // step.UserID = userid; - // string formatfilename = xr.GetAttribute("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to - // if (formatid != string.Empty) - // step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid), formatfilename); - // step.MyContent.Config = config; - // step.MyContent.DTS = dts; - // step.MyContent.UserID = userid; - // step.Save(); - // Old2NewItem.Add(oldid, step.ItemID); - // Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), step.MyContent.ContentID); - // prevInfo = StepInfo.Get(step.ItemID); - // return prevInfo; - //} - private ItemInfo AddNote(XmlNode xn, ItemInfo parentInfo, ItemInfo prevInfo) { pbImportStep.PerformStep(); @@ -4839,32 +3590,6 @@ namespace VEPROMS prevInfo = AddCaution(nd, parentInfo, prevInfo); } - // jsj 4-29-2016 appears to not be used - //private ItemInfo AddCaution(XmlReader xr, ItemInfo parentInfo, ItemInfo prevInfo, int oldid) - //{ - // string number = xr.GetAttribute("number"); - // string text = xr.GetAttribute("text"); - // int steptype = int.Parse(xr.GetAttribute("type")); - // string formatid = xr.GetAttribute("formatid"); - // string config = xr.GetAttribute("config"); - // string userid = xr.GetAttribute("userid"); - // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - // Step step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.Caution); - // step.DTS = dts; - // step.UserID = userid; - // string formatfilename = xr.GetAttribute("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to - // if (formatid != string.Empty) - // step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid), formatfilename); - // step.MyContent.Config = config; - // step.MyContent.DTS = dts; - // step.MyContent.UserID = userid; - // step.Save(); - // Old2NewItem.Add(oldid, step.ItemID); - // Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), step.MyContent.ContentID); - // prevInfo = StepInfo.Get(step.ItemID); - // return prevInfo; - //} - private ItemInfo AddCaution(XmlNode xn, ItemInfo parentInfo, ItemInfo prevInfo) { pbImportStep.PerformStep(); @@ -4933,39 +3658,6 @@ namespace VEPROMS prevInfo = AddSection(nd, parentInfo, prevInfo); } - private Dictionary GetSectionData(XmlReader xr) - { - Dictionary rv = new Dictionary(); - rv.Add("itemid", xr.GetAttribute("itemid")); - return rv; - } - - // js j4-29-2016 appears to not be used - //private ItemInfo AddSection(XmlReader xr, ItemInfo parentInfo, ItemInfo prevInfo, int oldid) - //{ - // string number = xr.GetAttribute("number"); - // string text = xr.GetAttribute("text"); - // int sectiontype = int.Parse(xr.GetAttribute("type")); - // string formatid = xr.GetAttribute("formatid"); - // string config = xr.GetAttribute("config"); - // string userid = xr.GetAttribute("userid"); - // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - // Section sect = Section.MakeSection(parentInfo, prevInfo, number, text, sectiontype); - // sect.DTS = dts; - // sect.UserID = userid; - // string formatfilename = xr.GetAttribute("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to - // if (formatid != string.Empty) - // sect.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid), formatfilename); - // sect.MyContent.Config = config; - // sect.MyContent.DTS = dts; - // sect.MyContent.UserID = userid; - // sect.Save(); - // Old2NewItem.Add(oldid, sect.ItemID); - // Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), sect.MyContent.ContentID); - // prevInfo = SectionInfo.Get(sect.ItemID); - // return prevInfo; - //} - private ItemInfo AddSection(XmlNode xn, ItemInfo parentInfo, ItemInfo prevInfo) { pbImportSection.PerformStep(); @@ -5049,19 +3741,6 @@ namespace VEPROMS } } - // jsj 2016Feb16 - This appears to not be used - //private void AddGrid(XmlReader xr) - //{ - // int contentid = int.Parse(xr.GetAttribute("contentid")); - // contentid = Old2NewContent[contentid]; - // Content content = Content.Get(contentid); - // string data = xr.GetAttribute("data"); - // string config = xr.GetAttribute("config"); - // string userid = xr.GetAttribute("userid"); - // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - // Grid gg = Grid.MakeGrid(content, data, config, dts, userid); - //} - private void AddGrid(Content content, XmlNode xc) { XmlNode nd = xc.SelectSingleNode("grid"); @@ -5093,14 +3772,13 @@ namespace VEPROMS string newvalue = ""; // if it's an ro within a table, need to process into an flex grid to save the grid data: string findLinkXml = @"<START\].*?\[END>"; - //string lookForXml = string.Format(@"^<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}} \\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>$", rousageid); string lookForXml = @"^<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}} \\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:.*?\[END>$"; MatchCollection msg = Regex.Matches(data, findLinkXml); int nmsg = msg.Count; for (int i = nmsg - 1; i >= 0; i--) { Match mmg = msg[i]; - Match mg = Regex.Match(mmg.Value, lookForXml);// Regex.Match(MyGrid.Data, lookForXml); + Match mg = Regex.Match(mmg.Value, lookForXml); if (mg != null && mg.Groups.Count > 1) { int myIndex = mg.Groups[4].Index + mmg.Index; @@ -5145,17 +3823,6 @@ namespace VEPROMS content.MyGrid = gg; } - - // jsj 4-29-2016 appears to not be used - //private Dictionary AddEntry(XmlReader xr) - //{ - // Dictionary dic = new Dictionary(); - // dic.Add("contentid", xr.GetAttribute("contentid")); - // dic.Add("dts", xr.GetAttribute("dts")); - // dic.Add("userid", xr.GetAttribute("userid")); - // return dic; - //} - private void AddEntry(Content content, XmlNode xc) { XmlNode nd = xc.SelectSingleNode("entry"); @@ -5167,25 +3834,7 @@ namespace VEPROMS ee.Save(); } } - // jsj 2016Feb16 - This appears to not be used - //private void AddDocument(XmlReader xr, Dictionary dic) - //{ - // string libtitle = xr.GetAttribute("libtitle"); - // byte[] doccontent = Convert.FromBase64String(xr.GetAttribute("doccontent")); - // string docascii = xr.GetAttribute("docascii"); - // string config = xr.GetAttribute("config"); - // string userid = xr.GetAttribute("userid"); - // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - // string fileextension = xr.GetAttribute("fileextension"); - // Document dd = Document.MakeDocument(libtitle, doccontent, docascii, config, dts, userid, fileextension); - // int contentid = int.Parse(dic["contentid"]); - // contentid = Old2NewContent[contentid]; - // Content content = Content.Get(contentid); - // dts = DateTime.Parse(dic["dts"]); - // userid = dic["userid"]; - // Entry ee = Entry.MakeEntry(content, dd, dts, userid); - //} - + // B2019-035 This is called only once to get the existing library document info. // when it was in the AddDocument() logic, it would use up (and not free up) memory each time // a Word section was added during the import diff --git a/PROMS/VEPROMS User Interface/dlgExportImportEP.cs b/PROMS/VEPROMS User Interface/dlgExportImportEP.cs index 569ec633..9e286827 100644 --- a/PROMS/VEPROMS User Interface/dlgExportImportEP.cs +++ b/PROMS/VEPROMS User Interface/dlgExportImportEP.cs @@ -246,26 +246,21 @@ namespace VEPROMS } //For Exporting an RO that is an image - //returns an xmlElement - // - that is a child to xindivid - // - that has a name of Name - // - that has a value of the binary representation of the image - // - that has an attribute designating the location of the image file - private XmlElement AddGraphic(XmlElement xindivid, string Name, ROFSTLookup.rochild roc, RODbInfo rodb, bool isMulti) + //returns the Location and FileName of the RO Image + private string GetROImageFileLocation(ROFSTLookup.rochild roc, RODbInfo rodb, bool isMulti) { - XmlElement xroid = xindivid.OwnerDocument.CreateElement(Name); string rodbpath = rodb.FolderPath; string rocval = roc.value; if (rocval == null) rocval = Array.Find(roc.children, x => x.value.Contains('.')).value; - if (rocval == null) return xroid; + if (rocval == null) return ""; string imgname; if (isMulti) - { + { imgname = rocval.Substring(rocval.IndexOf(' ') + 1, rocval.IndexOf("\r\n") - rocval.IndexOf(' ') - 1); } - else + else { imgname = rocval.Substring(0, rocval.IndexOf('\n')); } @@ -278,6 +273,21 @@ namespace VEPROMS } string imgfile = Path.Combine(rodbpath, fname); + return imgfile; + } + + //For Exporting an RO that is an image + //returns an xmlElement + // - that is a child to xindivid + // - that has a name of Name + // - that has a value of the binary representation of the image + // - that has an attribute designating the location of the image file + private XmlElement AddGraphic(XmlElement xindivid, string Name, ROFSTLookup.rochild roc, RODbInfo rodb, bool isMulti) + { + XmlElement xroid = xindivid.OwnerDocument.CreateElement(Name); + + string imgfile = GetROImageFileLocation(roc, rodb, isMulti); + if (string.IsNullOrEmpty(imgfile)) return xroid; xroid.Attributes.SetNamedItem(AddAttribute(xroid.OwnerDocument, "Location", imgfile)); if (File.Exists(imgfile)) @@ -293,6 +303,12 @@ namespace VEPROMS return xroid; } + protected override void SetROLocation(ref XmlElement xindivid, ROFSTLookup.rochild roc, RODbInfo rodb, bool isMulti) + { + string imgfile = GetROImageFileLocation(roc, rodb, isMulti); + if (!string.IsNullOrEmpty(imgfile)) xindivid.Attributes.SetNamedItem(AddAttribute(xindivid.OwnerDocument, "Location", imgfile)); + } + //clear objects to release memory private void OnClose(object sender, EventArgs e) {