Added Error Log code to record errors when import fails
Added Error handling to Import so that Change Manager is turned-on after Import whether it is successful or not. Don't allow import if the Referenced Objects have not been selected. Turn On Change Manager if there are no active sessions Don't crash if the Referenced Objects are not set when you right-click on a Working Draft.
This commit is contained in:
parent
0deea55d7e
commit
69b7de9fc5
@ -16,6 +16,9 @@ namespace VEPROMS
|
|||||||
{
|
{
|
||||||
public partial class dlgExportImport : Form
|
public partial class dlgExportImport : Form
|
||||||
{
|
{
|
||||||
|
#region Log4Net
|
||||||
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
#endregion
|
||||||
private bool _ConvertROsToTextDuringImport = false;
|
private bool _ConvertROsToTextDuringImport = false;
|
||||||
private bool _ConvertROsAndTransitionsToText = false; // set to true when Approval creates an Export file
|
private bool _ConvertROsAndTransitionsToText = false; // set to true when Approval creates an Export file
|
||||||
|
|
||||||
@ -211,7 +214,7 @@ namespace VEPROMS
|
|||||||
if (MyFolder != null) // import a folder - a .expx file
|
if (MyFolder != null) // import a folder - a .expx file
|
||||||
{
|
{
|
||||||
TurnChangeManagerOff.Execute();
|
TurnChangeManagerOff.Execute();
|
||||||
LoadImportDataDocument();
|
TryToLoadImportDataDocument();// Added Try Catch Error Handling to assure that the Change Manager is tuned-on
|
||||||
MyDocVersion = null;
|
MyDocVersion = null;
|
||||||
isImported = true;
|
isImported = true;
|
||||||
TurnChangeManagerOn.Execute();
|
TurnChangeManagerOn.Execute();
|
||||||
@ -226,6 +229,57 @@ namespace VEPROMS
|
|||||||
// * set newRODbid to MyDocVersion rodbid
|
// * set newRODbid to MyDocVersion rodbid
|
||||||
// - or convert ROs to text
|
// - or convert ROs to text
|
||||||
TurnChangeManagerOff.Execute();
|
TurnChangeManagerOff.Execute();
|
||||||
|
// Added Try Catch Error Handling to assure that the Change Manager is tuned-on
|
||||||
|
bool result = TryToImportProcedure(ref isImported, ref canceledPressed);
|
||||||
|
TurnChangeManagerOn.Execute();
|
||||||
|
if (!result) return;
|
||||||
|
if (isImported)
|
||||||
|
{
|
||||||
|
TimeSpan elapsed = DateTime.Now.Subtract(MyStart);
|
||||||
|
lblImportStatus.Text = "Import Completed in " + elapsed.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
btnImport.Enabled = true;
|
||||||
|
btnDoImport.Enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.Cursor = Cursors.Default;
|
||||||
|
btnCloseImport.Enabled = true;
|
||||||
|
if (isImported)
|
||||||
|
{
|
||||||
|
string msg = string.Format("Finished Importing:\n\n{0}", txtImport.Text.Substring(txtImport.Text.LastIndexOf("\\") + 1));
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
// 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", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
//MessageBox.Show(string.Format("Finished Importing:\n\n{0}", txtImport.Text.Substring(txtImport.Text.LastIndexOf("\\") + 1)), "Import", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
if (canceledPressed)
|
||||||
|
{
|
||||||
|
MessageBox.Show(string.Format("Canceling the import of:\n\n{0}",txtImport.Text.Substring(txtImport.Text.LastIndexOf("\\")+1)),"Import",MessageBoxButtons.OK,MessageBoxIcon.Information);
|
||||||
|
btnCloseImport.PerformClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private bool TryToImportProcedure(ref bool isImported, ref bool canceledPressed)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return ImportProcedure(ref isImported, ref canceledPressed);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||||
|
_MyLog.Warn("Failed during Procedure Import", ex);
|
||||||
|
this.Close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private bool ImportProcedure(ref bool isImported, ref bool canceledPressed)
|
||||||
|
{
|
||||||
XmlDocument xd = new XmlDocument();
|
XmlDocument xd = new XmlDocument();
|
||||||
xd.Load(txtImport.Text);
|
xd.Load(txtImport.Text);
|
||||||
pbImportProcedure.Maximum = 1;
|
pbImportProcedure.Maximum = 1;
|
||||||
@ -249,7 +303,7 @@ 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; // Return False to Indicate that the Import did not succeed
|
||||||
}
|
}
|
||||||
_ConvertROsToTextDuringImport = dlg.ConvertROsToText;
|
_ConvertROsToTextDuringImport = dlg.ConvertROsToText;
|
||||||
}
|
}
|
||||||
@ -293,7 +347,7 @@ namespace VEPROMS
|
|||||||
{
|
{
|
||||||
MessageBox.Show("There has been no RO folder defined for this database.\r\n\r\nIn order to import a procedure, you need to assign a RO folder path.\r\n\r\nImport process will terminate.");
|
MessageBox.Show("There has been no RO folder defined for this database.\r\n\r\nIn order to import a procedure, you need to assign a RO folder path.\r\n\r\nImport process will terminate.");
|
||||||
this.Cursor = Cursors.Default;
|
this.Cursor = Cursors.Default;
|
||||||
return;
|
return false;// Return False to Indicate that the Import did not succeed
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -326,7 +380,7 @@ namespace VEPROMS
|
|||||||
{
|
{
|
||||||
MessageBox.Show("Since you did not pick an existing RO folder defined for this database, the import process will terminate.");
|
MessageBox.Show("Since you did not pick an existing RO folder defined for this database, the import process will terminate.");
|
||||||
this.Close();// Close the Import Window
|
this.Close();// Close the Import Window
|
||||||
return;
|
return false;// Return False to Indicate that the Import did not succeed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -341,7 +395,7 @@ namespace VEPROMS
|
|||||||
// procedure numbers that contain a hyphen may have the hyphen represented as the unicode character
|
// 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
|
// '\u8209?' or the '-' character. If proc number is same except for hyphen representation, they
|
||||||
// should be considered the same procedure (fix for B2016-084)
|
// should be considered the same procedure (fix for B2016-084)
|
||||||
string hyphenNum = pi.MyContent.Number == null ? "" : pi.MyContent.Number.Replace(@"\u8209?", "-").Replace("\u2011", "-").Replace(@"\u9586?",@"\").Replace("\u2572", @"\");
|
string hyphenNum = pi.MyContent.Number == null ? "" : pi.MyContent.Number.Replace(@"\u8209?", "-").Replace("\u2011", "-").Replace(@"\u9586?", @"\").Replace("\u2572", @"\");
|
||||||
string hyphenImpNum = xd.SelectSingleNode("procedure/content/@number").InnerText;
|
string hyphenImpNum = xd.SelectSingleNode("procedure/content/@number").InnerText;
|
||||||
// bug fix C2015-044 - jsj
|
// bug fix C2015-044 - jsj
|
||||||
// - the cancel button would ignor the user's wishes and proceed with the import (overwriting the existing procedure)
|
// - the cancel button would ignor the user's wishes and proceed with the import (overwriting the existing procedure)
|
||||||
@ -353,7 +407,7 @@ namespace VEPROMS
|
|||||||
|
|
||||||
if (hyphenNum == hyphenImpNum)
|
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?", !hyphenImpNum.Equals("") ? string.Format(" ({0}) ", hyphenImpNum) : " ");
|
||||||
DialogResult dr = MessageBox.Show(this, msg, "Overwrite Existing Procedure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop);
|
DialogResult dr = MessageBox.Show(this, msg, "Overwrite Existing Procedure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop);
|
||||||
if (dr == DialogResult.Yes)
|
if (dr == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
@ -364,7 +418,7 @@ namespace VEPROMS
|
|||||||
if (dr == DialogResult.No)
|
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\"", !hyphenImpNum.Equals("") ? string.Format("({0})", hyphenImpNum) : "the procedure");
|
||||||
dr = MessageBox.Show(this, msg , "Create Copy Of Existing Procedure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop);
|
dr = MessageBox.Show(this, msg, "Create Copy Of Existing Procedure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop);
|
||||||
if (dr == DialogResult.Yes)
|
if (dr == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
ImportProcedureCopy(xd);
|
ImportProcedureCopy(xd);
|
||||||
@ -387,36 +441,18 @@ namespace VEPROMS
|
|||||||
ImportProcedureNew(xd);
|
ImportProcedureNew(xd);
|
||||||
isImported = true;
|
isImported = true;
|
||||||
}
|
}
|
||||||
TurnChangeManagerOn.Execute();
|
return true;// Import Suceeded
|
||||||
if (isImported)
|
|
||||||
{
|
|
||||||
TimeSpan elapsed = DateTime.Now.Subtract(MyStart);
|
|
||||||
lblImportStatus.Text = "Import Completed in " + elapsed.ToString();
|
|
||||||
}
|
}
|
||||||
else
|
// Added Error Handling to assure that Change Manager is turned-on regardless of success or failure of the import
|
||||||
|
private void TryToLoadImportDataDocument()
|
||||||
{
|
{
|
||||||
btnImport.Enabled = true;
|
try
|
||||||
btnDoImport.Enabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.Cursor = Cursors.Default;
|
|
||||||
btnCloseImport.Enabled = true;
|
|
||||||
if (isImported)
|
|
||||||
{
|
{
|
||||||
string msg = string.Format("Finished Importing:\n\n{0}", txtImport.Text.Substring(txtImport.Text.LastIndexOf("\\") + 1));
|
LoadImportDataDocument();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
// B2016-225 added more information to the finish import message to tell the user when ROs or Transitions are converted to text.
|
catch (Exception ex)
|
||||||
MessageBox.Show(msg, "Import", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
//MessageBox.Show(string.Format("Finished Importing:\n\n{0}", txtImport.Text.Substring(txtImport.Text.LastIndexOf("\\") + 1)), "Import", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
if (canceledPressed)
|
|
||||||
{
|
{
|
||||||
MessageBox.Show(string.Format("Canceling the import of:\n\n{0}",txtImport.Text.Substring(txtImport.Text.LastIndexOf("\\")+1)),"Import",MessageBoxButtons.OK,MessageBoxIcon.Information);
|
_MyLog.Warn("Failure During Import", ex);
|
||||||
btnCloseImport.PerformClick();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ImportProcedureNew(XmlDocument xd)
|
private void ImportProcedureNew(XmlDocument xd)
|
||||||
|
@ -538,6 +538,13 @@ namespace VEPROMS
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
dvi.RefreshDocVersionAssociations(); // Refresh Associations Count
|
||||||
|
//Only allow Import if the Referenced Object Database is set
|
||||||
|
if ( dvi.DocVersionAssociationCount == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Prior to Importing Procedures you must set the Referenced Object Database", "No RO Database set", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||||
|
return;
|
||||||
|
}
|
||||||
int ownerid = MySessionInfo.CheckOutItem(dvi.VersionID, CheckOutType.DocVersion);
|
int ownerid = MySessionInfo.CheckOutItem(dvi.VersionID, CheckOutType.DocVersion);
|
||||||
dlgExportImport dlg = new dlgExportImport("Import", dvi);
|
dlgExportImport dlg = new dlgExportImport("Import", dvi);
|
||||||
dlg.MyNewProcedure = null;
|
dlg.MyNewProcedure = null;
|
||||||
@ -1494,6 +1501,7 @@ namespace VEPROMS
|
|||||||
private void CloseSessionsNoLongerActive()
|
private void CloseSessionsNoLongerActive()
|
||||||
{
|
{
|
||||||
SessionInfoList sil = SessionInfoList.Get();
|
SessionInfoList sil = SessionInfoList.Get();
|
||||||
|
int i = 0;
|
||||||
foreach(SessionInfo si in sil)
|
foreach(SessionInfo si in sil)
|
||||||
{
|
{
|
||||||
if (si.DTSEnd == null && si.MachineName == Environment.MachineName && si.UserID == Volian.Base.Library.VlnSettings.UserID)
|
if (si.DTSEnd == null && si.MachineName == Environment.MachineName && si.UserID == Volian.Base.Library.VlnSettings.UserID)
|
||||||
@ -1502,12 +1510,16 @@ namespace VEPROMS
|
|||||||
{
|
{
|
||||||
System.Diagnostics.Process p = System.Diagnostics.Process.GetProcessById(si.ProcessID);
|
System.Diagnostics.Process p = System.Diagnostics.Process.GetProcessById(si.ProcessID);
|
||||||
}
|
}
|
||||||
catch(Exception ex)// Process not found
|
catch (Exception ex)// Process not found
|
||||||
{
|
{
|
||||||
Session.Delete(si.SessionID);// Remove Session record associated with a closed process
|
Session.Delete(si.SessionID);// Remove Session record associated with a closed process
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (si.DTSEnd == null)
|
||||||
|
i = i + 1;
|
||||||
}
|
}
|
||||||
|
if (i == 0)// Turn-on Change Manger if there are no active Sessions
|
||||||
|
TurnChangeManagerOn.Execute();
|
||||||
}
|
}
|
||||||
//public bool IsEnhancedDocumentOpen(ItemInfo ii)
|
//public bool IsEnhancedDocumentOpen(ItemInfo ii)
|
||||||
//{
|
//{
|
||||||
|
@ -209,7 +209,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (DocVersionAssociations == null) return false;
|
if (DocVersionAssociations == null || DocVersionAssociationCount==0) return false;
|
||||||
ROFstInfo roFstInfo = ROFstInfo.GetJustROFst(DocVersionAssociations[0].ROFstID);
|
ROFstInfo roFstInfo = ROFstInfo.GetJustROFst(DocVersionAssociations[0].ROFstID);
|
||||||
RODbInfo rdi = RODbInfo.GetJustRODB(roFstInfo.RODbID);
|
RODbInfo rdi = RODbInfo.GetJustRODB(roFstInfo.RODbID);
|
||||||
string rofstPath = rdi.FolderPath + @"\ro.fst";
|
string rofstPath = rdi.FolderPath + @"\ro.fst";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user