From 31033ae63f8857e8b86a4753b8f63c27187624dd Mon Sep 17 00:00:00 2001 From: Kathy Date: Wed, 6 Feb 2019 14:29:12 +0000 Subject: [PATCH] B2019-014: Import of incorrect file type crashes; B2019-015: Improve message on import of UCFs. --- .../VEPROMS User Interface/dlgExportImport.cs | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/PROMS/VEPROMS User Interface/dlgExportImport.cs b/PROMS/VEPROMS User Interface/dlgExportImport.cs index 411afe84..8975e1ae 100644 --- a/PROMS/VEPROMS User Interface/dlgExportImport.cs +++ b/PROMS/VEPROMS User Interface/dlgExportImport.cs @@ -32,6 +32,7 @@ namespace VEPROMS // B2016-225 notify user when Transitions and/or ROs are converted to text private bool _DidConvertTransitionsToText = false; private bool _DidConvertROsToText = false; + private bool _DidUCF = false; private ItemInfo _ExternalTransitionItem = null; public ItemInfo ExternalTransitionItem @@ -363,7 +364,11 @@ namespace VEPROMS if (isImported) { string msg = string.Format("Finished Importing:\n\n{0}", txtImport.Text.Substring(txtImport.Text.LastIndexOf("\\") + 1)); - if (_DidConvertTransitionsToText || _DidConvertROsToText) + if (_DidUCF) // B2019-015: add a message to state to exit re-enter on format imports + { + msg += "\n\nRestart PROMS to have user controlled formats become available."; + } + else if (_DidConvertTransitionsToText || _DidConvertROsToText) { string msg1 = (_DidConvertTransitionsToText && _DidConvertROsToText) ? "Transitions and Referenced Objects" : (_DidConvertTransitionsToText) ? "Transitions" : "Referenced Objects"; msg += string.Format("\n\n{0} converted to text.\n\nThe locations can be found by doing a Global Search for the \"Link Converted To Text\" annotation type", msg1); @@ -394,6 +399,13 @@ namespace VEPROMS XmlDocument xd = new XmlDocument(); xd.Load(txtImport.Text); XmlNodeList nl = xd.SelectNodes("ucformats/ucformat"); + if (nl == null || nl.Count == 0) // B2019-014: Check contents of import file for compatible operation + { + MessageBox.Show("A Procedure export file can only be imported from the Tree View.", "Import Failed", MessageBoxButtons.OK); + this.Close(); + isImported = false; + return false; + } foreach (XmlNode nd in nl) { int formatid = int.Parse(nd.Attributes.GetNamedItem("formatid").InnerText); @@ -437,6 +449,7 @@ namespace VEPROMS } } isImported = true; + _DidUCF = true; return true; } catch (Exception ex) @@ -467,6 +480,15 @@ namespace VEPROMS XmlDocument xd = new XmlDocument(); xd.Load(txtImport.Text); pbImportProcedure.Maximum = 1; + XmlNode ucf = xd.SelectSingleNode("ucformats"); // B2019-014: Check contents of import file for compatible operation + if (ucf != null) + { + MessageBox.Show("A User Control of Format export file can only be imported from Administration on the V-Button.", "Import Failed", MessageBoxButtons.OK); + this.Cursor = Cursors.Default; + this.btnImport.Enabled = true; // allow user to select a different export file to import + this.btnCloseImport.Enabled = true; // allow user to close import dialog + return false; + } string rofolderpath = xd.DocumentElement.Attributes.GetNamedItem("rofolderpath").InnerText; int rodbid = int.Parse(xd.DocumentElement.Attributes.GetNamedItem("rodbid").InnerText); int rofstid = int.Parse(xd.DocumentElement.Attributes.GetNamedItem("rofstid").InnerText);