B2019-046: Improve error handling for import
This commit is contained in:
parent
b3b98dacff
commit
bbead6687d
@ -12,6 +12,7 @@ using System.Xml;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using Ionic.Zip;
|
using Ionic.Zip;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using JR.Utils.GUI.Forms;
|
||||||
|
|
||||||
namespace VEPROMS
|
namespace VEPROMS
|
||||||
{
|
{
|
||||||
@ -326,9 +327,9 @@ namespace VEPROMS
|
|||||||
{
|
{
|
||||||
TurnChangeManagerOff.Execute();
|
TurnChangeManagerOff.Execute();
|
||||||
MyFrmVEPROMS.DisablePing = true;// Turn-off SessionPing
|
MyFrmVEPROMS.DisablePing = true;// Turn-off SessionPing
|
||||||
TryToLoadImportDataDocument();// Added Try Catch Error Handling to assure that the Change Manager is tuned-on
|
// B2019-046: improved error handling (added return value)
|
||||||
|
isImported = TryToLoadImportDataDocument();// Added Try Catch Error Handling to assure that the Change Manager is tuned-on
|
||||||
MyDocVersion = null;
|
MyDocVersion = null;
|
||||||
isImported = true;
|
|
||||||
MyFrmVEPROMS.DisablePing = false;// Turn-on SessionPing
|
MyFrmVEPROMS.DisablePing = false;// Turn-on SessionPing
|
||||||
TurnChangeManagerOn.Execute();
|
TurnChangeManagerOn.Execute();
|
||||||
}
|
}
|
||||||
@ -683,16 +684,20 @@ namespace VEPROMS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Added Error Handling to assure that Change Manager is turned-on regardless of success or failure of the import
|
// Added Error Handling to assure that Change Manager is turned-on regardless of success or failure of the import
|
||||||
private void TryToLoadImportDataDocument()
|
// B2019-046: improved error handling (added return value & error message)
|
||||||
|
private bool TryToLoadImportDataDocument()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoadImportDataDocument();
|
bool retval = LoadImportDataDocument();
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
FlexibleMessageBox.Show("The import failed, check the error log for more information.", "Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||||
_MyLog.Warn("Failure During Import", ex);
|
_MyLog.Warn("Failure During Import", ex);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
private void ImportProcedureNew(XmlDocument xd)
|
private void ImportProcedureNew(XmlDocument xd)
|
||||||
{
|
{
|
||||||
@ -823,7 +828,7 @@ namespace VEPROMS
|
|||||||
FixFloatingFoldouts();
|
FixFloatingFoldouts();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private void LoadImportDataDocument()
|
private bool LoadImportDataDocument()
|
||||||
{
|
{
|
||||||
floatFoldout = new Dictionary<int, int>();
|
floatFoldout = new Dictionary<int, int>();
|
||||||
ZipEntry ze = MyExpxZipFile[0];
|
ZipEntry ze = MyExpxZipFile[0];
|
||||||
@ -837,13 +842,13 @@ namespace VEPROMS
|
|||||||
this.Cursor = Cursors.Default;
|
this.Cursor = Cursors.Default;
|
||||||
this.btnImport.Enabled = true; // allow user to select a different export file to import
|
this.btnImport.Enabled = true; // allow user to select a different export file to import
|
||||||
this.btnDoImport.Enabled = true; // allow user to change mind and perform the import
|
this.btnDoImport.Enabled = true; // allow user to change mind and perform the import
|
||||||
return; // Return False to Indicate that the Import did not succeed
|
return false; // Return False to Indicate that the Import did not succeed
|
||||||
}
|
}
|
||||||
Folder ff = AddFolder(Folder.Get(MyFolder.FolderID), xd);
|
Folder ff = AddFolder(Folder.Get(MyFolder.FolderID), xd);
|
||||||
if (ff == null)
|
if (ff == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("You can not import the same procedure set more than once", "Duplicate Import Error");
|
MessageBox.Show("You can not import the same procedure set more than once. You should rename the existing folder then try again.", "Duplicate Import Error");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
_MyNewFolder = FolderInfo.Get(ff.FolderID);
|
_MyNewFolder = FolderInfo.Get(ff.FolderID);
|
||||||
AddAnnotationTypes(xd);
|
AddAnnotationTypes(xd);
|
||||||
@ -873,6 +878,7 @@ namespace VEPROMS
|
|||||||
AddTransitions();
|
AddTransitions();
|
||||||
FixFloatingFoldouts();
|
FixFloatingFoldouts();
|
||||||
SaveTransitionAndItemContentIDs();
|
SaveTransitionAndItemContentIDs();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
private void FixSectionStart(ProcedureInfo pi)
|
private void FixSectionStart(ProcedureInfo pi)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user