From fbc4b42ff1e09933bd1e044c87dd891deb4f93ca Mon Sep 17 00:00:00 2001 From: Kathy Date: Thu, 21 Sep 2017 14:08:20 +0000 Subject: [PATCH] B2017-209: Restoring an enhanced step whose source step is deleted causes crash --- PROMS/VEPROMS.CSLA.Library/Extension/AuditExt.cs | 11 ++++++----- PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs | 2 +- PROMS/Volian.Controls.Library/DisplayHistory.cs | 11 +++++++++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/AuditExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/AuditExt.cs index 916c988f..294984e3 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/AuditExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/AuditExt.cs @@ -1632,7 +1632,7 @@ namespace VEPROMS.CSLA.Library } // B2017-069 when we restore a step that once had enhanced document links, // remove the enhanced document link information - fixes delete/restore issue of linked steps. - RemoveEnhancedFromConfig(tmp); + RemoveEnhancedFromConfig(tmp, false); return tmp; } catch (Exception ex) @@ -1641,8 +1641,8 @@ namespace VEPROMS.CSLA.Library } } - // B2017-070 - when retoring a step that once had enhanced links, remove the link info for the notes and cautions as well - private static void RemoveEnhancedFromConfig(ItemInfo tmp) + // B2017-070 - when restoring a step that once had enhanced links, remove the link info for the notes and cautions as well + public static void RemoveEnhancedFromConfig(ItemInfo tmp, bool doOneStepOnly) { XmlDocument xd = new XmlDocument(); if (tmp.MyContent.Config == null || tmp.MyContent.Config == "") return; // B2017-164 & B2017-172 check for null or empty config @@ -1660,17 +1660,18 @@ namespace VEPROMS.CSLA.Library tmp._MyConfig = null; // refresh the memory value } } + if (doOneStepOnly) return; if (tmp.IsHigh) { if (tmp.Cautions != null) foreach (ItemInfo chld in tmp.Cautions) { - RemoveEnhancedFromConfig(chld); + RemoveEnhancedFromConfig(chld, false); } if (tmp.Notes != null) foreach (ItemInfo chld in tmp.Notes) { - RemoveEnhancedFromConfig(chld); + RemoveEnhancedFromConfig(chld, false); } } } diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs index f503d8a5..1228a4b4 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs @@ -884,7 +884,7 @@ namespace VEPROMS.CSLA.Library { // the RemoveEnhancedFromConfig method clears from the pasted step and any cautions/notes that may be off // of the pasted step. - if (pasteItem.HasEnhancedLinkedStep) ItemInfo.RemoveEnhancedFromConfig(pasteItem); + if (pasteItem.HasEnhancedLinkedStep) ItemInfo.RemoveEnhancedFromConfig(pasteItem, false); } } #endregion diff --git a/PROMS/Volian.Controls.Library/DisplayHistory.cs b/PROMS/Volian.Controls.Library/DisplayHistory.cs index 69d88e90..8e9d504c 100644 --- a/PROMS/Volian.Controls.Library/DisplayHistory.cs +++ b/PROMS/Volian.Controls.Library/DisplayHistory.cs @@ -634,6 +634,17 @@ namespace Volian.Controls.Library if (myRoFst != null) myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate); RefreshRequired = true; UpdateHistory(); + MyItemInfo.RefreshConfig(); + // B2017-209: see if the restore has invalid enhanced data, i.e. the source step that it 'links to' does not exist. + // Note that this is only applicable when restoring an enhanced step if its linked source step is deleted because + // the enhanced (background/deviation/etc) cannot be deleted unless they are unlinked first. + if (MyItemInfo.IsEnhancedStep) + { + // get id for step that is linked & see if it exists - if not, clear the enhanced config data + StepConfig sc = MyItemInfo.MyConfig as StepConfig; + ItemInfo iexists = ItemInfo.Get(sc.MyEnhancedDocuments[0].ItemID); + if (iexists == null) ItemInfo.RemoveEnhancedFromConfig(MyItemInfo, true); + } myRTB.Clear(); myVFG.Clear(); MyEditItem.SetAllTabs();