|
|
|
@@ -2650,97 +2650,174 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
firstTrans = false;
|
|
|
|
|
if (!CanDeleteObject())
|
|
|
|
|
throw new System.Security.SecurityException("User not authorized to remove a Item");
|
|
|
|
|
// B2016-009 check source and desintation types and display message box if needed
|
|
|
|
|
// B2016-009 check source and destination types and display message box if needed
|
|
|
|
|
// C2022-017 moved the CheckSourceDestinationType call to btnPasteReplace_Click in StepTabRibbon
|
|
|
|
|
// B2023-101 Handle Paste Replace when procedure to be replaced has Incoming Transitions, i.e. do a separate try/catch for this case
|
|
|
|
|
ItemInfo newItemInfo = null;
|
|
|
|
|
try
|
|
|
|
|
using (ItemInfo copyItemInfo = ItemInfo.Get(copyStartID))
|
|
|
|
|
{
|
|
|
|
|
// C2017-031: Support for paste/replace an enhanced step, if this is replacing enhanced, do a specific query
|
|
|
|
|
if (itemInfo.IsEnhancedStep)
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
newItemInfo = ItemInfo.CopyPasteReplaceEnhancedItemInfoFetch(copyStartID, itemInfo);
|
|
|
|
|
if (newItemInfo == null) return null;
|
|
|
|
|
// C2017-031: Support for paste/replace an enhanced step, if this is replacing enhanced, do a specific query
|
|
|
|
|
if (itemInfo.IsEnhancedStep)
|
|
|
|
|
{
|
|
|
|
|
newItemInfo = ItemInfo.CopyPasteReplaceEnhancedItemInfoFetch(copyStartID, itemInfo);
|
|
|
|
|
if (newItemInfo == null) return null;
|
|
|
|
|
}
|
|
|
|
|
//C2025-003 Enhanced Copy/Paste Upgrade - Added support for paste/replace on a master step
|
|
|
|
|
else if (itemInfo.HasEnhancedLinkedStep || copyItemInfo.HasEnhancedLinkedStep)
|
|
|
|
|
{
|
|
|
|
|
DialogResult rslt = DialogResult.No;
|
|
|
|
|
|
|
|
|
|
SectionConfig secCfg = itemInfo.ActiveSection.MyConfig as SectionConfig;
|
|
|
|
|
if (copyItemInfo.HasEnhancedLinkedStep && secCfg.MyEnhancedDocuments.Count > 0)
|
|
|
|
|
rslt = FlexibleMessageBox.Show("The step you are copying contains linked background documents." +
|
|
|
|
|
"\r\n\r\nDo you also wish to make a copy of the background documents?",
|
|
|
|
|
"Paste background documents", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
|
|
|
|
|
|
|
//unlink and remove any background documents attached to where you are copying to
|
|
|
|
|
//and then delete them
|
|
|
|
|
//if selected want to replace BG step (DialogResult.Yes)
|
|
|
|
|
if (itemInfo.HasEnhancedLinkedStep && rslt == DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
foreach (EnhancedDocument ed in itemInfo.GetMyEnhancedDocuments())
|
|
|
|
|
{
|
|
|
|
|
using (ItemInfo exEnh = ItemInfo.Get(ed.ItemID))
|
|
|
|
|
{
|
|
|
|
|
exEnh.DoUnlinkEnhanced(exEnh, 0, false);
|
|
|
|
|
DeleteItemAndChildren(exEnh);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//do copy/paste replace of the master step
|
|
|
|
|
newItemInfo = ItemInfo.CopyPasteReplaceItemInfoFetch(copyStartID, itemInfo);
|
|
|
|
|
if (newItemInfo == null) return null;
|
|
|
|
|
|
|
|
|
|
//copy any background documents
|
|
|
|
|
//if selected want to replace BG step (DialogResult.Yes)
|
|
|
|
|
if (copyItemInfo.HasEnhancedLinkedStep && rslt == DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
foreach (EnhancedDocument ed in copyItemInfo.GetMyEnhancedDocuments())
|
|
|
|
|
{
|
|
|
|
|
using (ItemInfo exEnh = newItemInfo.DoAddMissingEnhancedItems(ed.Type))
|
|
|
|
|
{
|
|
|
|
|
PasteReplace(exEnh, ed.ItemID, chgid, ref firstTrans);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (rslt == DialogResult.No)
|
|
|
|
|
{
|
|
|
|
|
//if selected didn't want to copy BG documents (DialogResult.No)
|
|
|
|
|
//need to unlink BG doc from old removed content (what was pasted over top of)
|
|
|
|
|
//re-link BG document to new paste replace master doc
|
|
|
|
|
//this should also auto update the text of the main linked item
|
|
|
|
|
//to match the new master doc wording
|
|
|
|
|
|
|
|
|
|
//get original BG documents
|
|
|
|
|
EnhancedDocuments orig_eds = itemInfo.GetMyEnhancedDocuments();
|
|
|
|
|
|
|
|
|
|
//remove link from pre-existing BG docs
|
|
|
|
|
foreach (EnhancedDocument ed in orig_eds)
|
|
|
|
|
{
|
|
|
|
|
using (ItemInfo exEnh = ItemInfo.Get(ed.ItemID))
|
|
|
|
|
{ exEnh.DoUnlinkEnhanced(exEnh, 0, false); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//remove link from steps just copied
|
|
|
|
|
ItemInfo.PasteClearEnhanced(newItemInfo);
|
|
|
|
|
|
|
|
|
|
//re-link pre-existing BG docs to newly replaced master step
|
|
|
|
|
foreach (EnhancedDocument ed in orig_eds)
|
|
|
|
|
{
|
|
|
|
|
using (ItemInfo orig_ed_item = ItemInfo.Get(ed.ItemID))
|
|
|
|
|
{ newItemInfo.DoCreateLinksEnhancedSingleItem(orig_ed_item, ed.Type); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
newItemInfo = ItemInfo.CopyPasteReplaceItemInfoFetch(copyStartID, itemInfo); if (newItemInfo == null) return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
catch (Exception ex1)
|
|
|
|
|
{
|
|
|
|
|
newItemInfo = ItemInfo.CopyPasteReplaceItemInfoFetch(copyStartID, itemInfo); if (newItemInfo == null) return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex1)
|
|
|
|
|
{
|
|
|
|
|
if (ex1.Message.Contains("has External Transitions and has no next step")
|
|
|
|
|
if (ex1.Message.Contains("has External Transitions and has no next step")
|
|
|
|
|
|| ex1.Message.Contains("has External Transitions to Procedure")
|
|
|
|
|
|| ex1.Message.Contains("has External Transitions to it's children"))
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
FlexibleMessageBox.Show("This procedure has external transition references to it that must be resolved before doing the Paste/Replace.\r\nRight Click on the procedure and select the Incoming Transitions menu option to find these references and resolve them.", "Paste Replace Failed", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
|
|
|
|
|
return null;
|
|
|
|
|
{
|
|
|
|
|
FlexibleMessageBox.Show("This procedure has external transition references to it that must be resolved before doing the Paste/Replace.\r\nRight Click on the procedure and select the Incoming Transitions menu option to find these references and resolve them.", "Paste Replace Failed", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Delete business objects, including remove from tree
|
|
|
|
|
ItemInfo.DeleteItemInfoAndChildren(itemInfo.ItemID); // Dispose ItemInfo and Children
|
|
|
|
|
using (Item item = Get(newItemInfo.ItemID)) ItemInfo.Refresh(item);
|
|
|
|
|
ItemInfo.PasteSetChangeId(newItemInfo, chgid);
|
|
|
|
|
ItemInfo.PasteClearEnhanced(newItemInfo);
|
|
|
|
|
if (newItemInfo.NextItem != null) using (Item item = newItemInfo.NextItem.Get()) ItemInfo.Refresh(item);
|
|
|
|
|
newItemInfo.RefreshNextItems();
|
|
|
|
|
// if inserting after a caution or note, refreshes tabs. This will adjust bullets
|
|
|
|
|
// of any previous cautions or notes.
|
|
|
|
|
if (newItemInfo.IsCaution || newItemInfo.IsNote) newItemInfo.ResetOrdinal();
|
|
|
|
|
newItemInfo.UpdateTransitionText();
|
|
|
|
|
newItemInfo.UpdateROText();
|
|
|
|
|
newItemInfo.UpdatePastedStepTransitionText();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Delete business objects, including remove from tree
|
|
|
|
|
ItemInfo.DeleteItemInfoAndChildren(itemInfo.ItemID); // Dispose ItemInfo and Children
|
|
|
|
|
using (Item item = Get(newItemInfo.ItemID)) ItemInfo.Refresh(item);
|
|
|
|
|
ItemInfo.PasteSetChangeId(newItemInfo, chgid);
|
|
|
|
|
if (!copyItemInfo.HasEnhancedLinkedStep && !itemInfo.HasEnhancedLinkedStep) ItemInfo.PasteClearEnhanced(newItemInfo);
|
|
|
|
|
if (newItemInfo.NextItem != null) using (Item item = newItemInfo.NextItem.Get()) ItemInfo.Refresh(item);
|
|
|
|
|
newItemInfo.RefreshNextItems();
|
|
|
|
|
// if inserting after a caution or note, refreshes tabs. This will adjust bullets
|
|
|
|
|
// of any previous cautions or notes.
|
|
|
|
|
if (newItemInfo.IsCaution || newItemInfo.IsNote) newItemInfo.ResetOrdinal();
|
|
|
|
|
newItemInfo.UpdateTransitionText();
|
|
|
|
|
newItemInfo.UpdateROText();
|
|
|
|
|
newItemInfo.UpdatePastedStepTransitionText();
|
|
|
|
|
|
|
|
|
|
// Add to tree
|
|
|
|
|
if (newItemInfo.NextItem != null)
|
|
|
|
|
{
|
|
|
|
|
using (ItemInfo itm = ItemInfo.GetNonCached(newItemInfo.NextItem.ItemID))
|
|
|
|
|
// Add to tree
|
|
|
|
|
if (newItemInfo.NextItem != null)
|
|
|
|
|
{
|
|
|
|
|
itm.OnNewSiblingBefore(new ItemInfoInsertEventArgs(newItemInfo, ItemInfo.EAddpingPart.Before));
|
|
|
|
|
using (ItemInfo itm = ItemInfo.GetNonCached(newItemInfo.NextItem.ItemID))
|
|
|
|
|
{
|
|
|
|
|
itm.OnNewSiblingBefore(new ItemInfoInsertEventArgs(newItemInfo, ItemInfo.EAddpingPart.Before));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (newItemInfo.PreviousID != null)
|
|
|
|
|
{
|
|
|
|
|
using (ItemInfo itm2 = ItemInfo.GetNonCached((int)newItemInfo.PreviousID))
|
|
|
|
|
else if (newItemInfo.PreviousID != null)
|
|
|
|
|
{
|
|
|
|
|
itm2.OnNewSiblingAfter(new ItemInfoInsertEventArgs(newItemInfo, ItemInfo.EAddpingPart.After));
|
|
|
|
|
using (ItemInfo itm2 = ItemInfo.GetNonCached((int)newItemInfo.PreviousID))
|
|
|
|
|
{
|
|
|
|
|
itm2.OnNewSiblingAfter(new ItemInfoInsertEventArgs(newItemInfo, ItemInfo.EAddpingPart.After));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// B2024-045, 049 and 050: if not a single procedure replace, update user interface by using the 'OnNewChild'. Single
|
|
|
|
|
// procedure's MyParent is null because its parent is a working draft (docversion) since MyParent's type is iteminfo.
|
|
|
|
|
// For the single procedure case, the user interface code in vlntreeview will update the tree.
|
|
|
|
|
if (newItemInfo.MyParent != null)
|
|
|
|
|
newItemInfo.MyParent.OnNewChild(new ItemInfoInsertEventArgs(newItemInfo, ItemInfo.EAddpingPart.Child));
|
|
|
|
|
}
|
|
|
|
|
return newItemInfo;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
// B2024-045, 049 and 050: if not a single procedure replace, update user interface by using the 'OnNewChild'. Single
|
|
|
|
|
// procedure's MyParent is null because its parent is a working draft (docversion) since MyParent's type is iteminfo.
|
|
|
|
|
// For the single procedure case, the user interface code in vlntreeview will update the tree.
|
|
|
|
|
if (newItemInfo.MyParent != null)
|
|
|
|
|
newItemInfo.MyParent.OnNewChild(new ItemInfoInsertEventArgs(newItemInfo, ItemInfo.EAddpingPart.Child));
|
|
|
|
|
ItemInfo iii = itemInfo.HandleSqlExceptionOnDelete(ex);
|
|
|
|
|
if (iii == itemInfo) return null;// If self returned then return null
|
|
|
|
|
if (iii != null)
|
|
|
|
|
{
|
|
|
|
|
firstTrans = true; // B2017-179 set the firstTrans to true and return the itminfo of the first transition location that needs resolved
|
|
|
|
|
return iii;
|
|
|
|
|
}
|
|
|
|
|
if (!HandleSqlExceptionOnCopy(ex))
|
|
|
|
|
{
|
|
|
|
|
if (ex.Message.Contains("has External Transitions and has no next step")
|
|
|
|
|
|| ex.Message.Contains("has External Transitions to Procedure")
|
|
|
|
|
|| ex.Message.Contains("has External Transitions to it's children")
|
|
|
|
|
|| ex.Message.Contains("This step has been deleted"))
|
|
|
|
|
throw ex;
|
|
|
|
|
|
|
|
|
|
FlexibleMessageBox.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;
|
|
|
|
|
}
|
|
|
|
|
return newItemInfo;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ItemInfo iii = itemInfo.HandleSqlExceptionOnDelete(ex);
|
|
|
|
|
if (iii == itemInfo) return null;// If self returned then return null
|
|
|
|
|
if (iii != null)
|
|
|
|
|
{
|
|
|
|
|
firstTrans = true; // B2017-179 set the firstTrans to true and return the itminfo of the first transition location that needs resolved
|
|
|
|
|
return iii;
|
|
|
|
|
}
|
|
|
|
|
if (!HandleSqlExceptionOnCopy(ex))
|
|
|
|
|
{
|
|
|
|
|
if (ex.Message.Contains("has External Transitions and has no next step")
|
|
|
|
|
|| ex.Message.Contains("has External Transitions to Procedure")
|
|
|
|
|
|| ex.Message.Contains("has External Transitions to it's children")
|
|
|
|
|
|| ex.Message.Contains("This step has been deleted")
|
|
|
|
|
)
|
|
|
|
|
throw ex;
|
|
|
|
|
FlexibleMessageBox.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
|
|
|
|
|