B2021-045: Search/Load, don’t crash if noncompatible Xml file

This commit is contained in:
Kathy Ruffing 2021-04-20 16:07:17 +00:00
parent 1e85522762
commit 814d26f713

View File

@ -2321,12 +2321,14 @@ namespace Volian.Controls.Library
lbSrchResults.DataSource = null;
lbSrchResults.Items.Clear();
toolTip1.SetToolTip(lbSrchResults, null);
Cursor = Cursors.WaitCursor;
string unitPrefix = "";
if (Mydocversion != null)
unitPrefix = Mydocversion.DocVersionConfig.Unit_ProcedureNumber;
if (unitPrefix.EndsWith("#"))
unitPrefix = unitPrefix.Replace("#", "");
Cursor = Cursors.WaitCursor;
try // B2021-045: don't crash if xml file cannot be loaded.
{
SearchResults = ItemInfoList.GetByContentID(0);
// C2021-006: removed all file type options except xml
System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
@ -2460,6 +2462,12 @@ namespace Volian.Controls.Library
break;
}
}
}
catch (Exception ex)
{
FlexibleMessageBox.Show("An error occurred while reading the xml file.\r\n\r\nThis can happen when the file selected for the Load is not saved\r\n" +
"from a PROMS Search or if some of the steps no longer exist.", "Search Load Failed", MessageBoxButtons.OK);
}
Cursor = Cursors.Default;
}
btnTranCvtAllToTxt.Enabled = IncTransCvtAllToTextPerm(); // C2020-033: does user have access to at least one item