Added code to raise an error if trying to paste a step in reference to a step that has been deleted by another user (eg: paste before, paste after or paste replace)

Added handlers for new treeview events of NodeCopy and ClipboardStatus
Added exception handlers to handle the exception of trying to use a deleted step as a reference point for a paste operation (before, after or replace)
Added code to set the MyCopyStep property to the value of the new step added in a paste replace operation
This commit is contained in:
Rich
2014-08-06 00:55:41 +00:00
parent b5ded05838
commit a17c27c0a8
5 changed files with 85 additions and 20 deletions

View File

@@ -471,7 +471,13 @@ namespace VEPROMS.CSLA.Library
, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand);
return true;
}
return false;
if(ex.Message.Contains("This current step has been deleted in another session"))
{
System.Windows.Forms.MessageBox.Show("The highlighted step has been deleted by another user!", "Cannot Paste Step"
, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand);
return true;
}
return false;
}
private ItemInfo CopyPasteItemInfoFetch(int copyStartID, int itemID, int? type, int? fromType, EAddpingPart addType)
{
@@ -717,9 +723,12 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemInfo.DataPortal_Fetch", ex);
if (!ex.Message.Contains("This step has been deleted") && !ex.Message.Contains("This current step has been deleted in another session"))
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfo.DataPortal_Fetch", ex);
}
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemInfo.DataPortal_Fetch", ex);
}
}
private void DataPortal_Fetch(AddingPartCriteria criteria)
@@ -1237,15 +1246,36 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
if (ex.Message.Contains("has External Transitions and has no next step")
|| ex.Message.Contains("has External Transitions to it's children")
|| ex.Message.Contains("This step has been deleted")
)
throw ex;
System.Windows.Forms.MessageBox.Show("Details were written to the Error Log.", "Paste Replace Failed", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
return itemInfo;
if (!HandleSqlExceptionOnCopy(ex))
{
if (ex.Message.Contains("has External Transitions and has no next step")
|| ex.Message.Contains("has External Transitions to it's children")
|| ex.Message.Contains("This step has been deleted")
)
throw ex;
System.Windows.Forms.MessageBox.Show("Details were written to the Error Log.", "Paste Replace Failed", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
return itemInfo;
}
else
return itemInfo;
}
}
#endregion
}
private static bool HandleSqlExceptionOnCopy(Exception ex)
{
if (ex.Message.Contains("This step has been deleted"))
{
System.Windows.Forms.MessageBox.Show("The step being pasted has been deleted!", "Cannot Paste Deleted Step"
, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand);
return true;
}
if (ex.Message.Contains("This current step has been deleted in another session"))
{
System.Windows.Forms.MessageBox.Show("The highlighted step has been deleted by another user!", "Cannot Paste Step"
, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand);
return true;
}
return false;
}
}
}