From 3bcd01ce8dfacf7d917726f554c691c4a424f430 Mon Sep 17 00:00:00 2001 From: Kathy Date: Thu, 14 Apr 2016 12:44:51 +0000 Subject: [PATCH] Fix some of enhanced format flags C2016-008: Create an enhanced step if it is missing from a source --- PROMS/Formats/fmtall/EXEDEVall.xml | Bin 33928 -> 34008 bytes .../Extension/ItemInsertExt.cs | 68 +++++++++++++++++- PROMS/Volian.Controls.Library/EditItem.cs | 27 +++++++ 3 files changed, 94 insertions(+), 1 deletion(-) diff --git a/PROMS/Formats/fmtall/EXEDEVall.xml b/PROMS/Formats/fmtall/EXEDEVall.xml index d1260ffcdf90dbaa25d3209a1b4f174c71a8ee56..2e343aacb4e4a42a0dcc2db283d24ce734f17c45 100644 GIT binary patch delta 39 pcmeC^WV+GGv>`!m@+wKK$zF~klRqe`ZJr}%#|#tL{6TR>5&$w=4?h3^ delta 44 ucmcc7$<)!wv>`!m@)>oZ$rBV=COaspZI)3}Vch&eUWy4Oy4gW#MiKyPG!K6O diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs index 4964d07a..c8270800 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs @@ -863,7 +863,12 @@ namespace VEPROMS.CSLA.Library tmp = InsertEnhancedSmartTemplateSubStep(text, number, this, addType, (int)type, fromType, newSourceID); } else - tmp = InsertEnhancedSmartTemplateSteps(text, number, this, addType, 20002, newSourceID); + { + // if 'type' is high level, use standard hls as type. + // if 'type' is caution/note, use the base caution/note for 'type' + int ltype = IsHigh ? 20002 : (IsNote ? 20007 : 20006); + tmp = InsertEnhancedSmartTemplateSteps(text, number, this, addType, ltype, newSourceID); + } if (tmp == null) return null; // if next exists, it is updated in SQL so we have to manually force the iteminfo updates @@ -1447,6 +1452,67 @@ namespace VEPROMS.CSLA.Library } RefreshConfig(); } + public ItemInfo DoAddMissingEnhancedSteps(int enhtype) + { + // from this step, need to find an insertion point in the enhanced procedure/section. Look for a step that has enhanced + // links in its config: first go through previous steps, then if none found in previous go through next, if none found + // go to parent + ItemInfo newEnh = null; + // look through pervious first: + ItemInfo iiCur = this.MyPrevious; + EAddpingPart addtype = EAddpingPart.After; + while (iiCur != null && newEnh == null) + { + foreach (EnhancedDocument edSource in iiCur.GetMyEnhancedDocuments()) + { + if (edSource.Type == enhtype) // found one to use: + { + ItemInfo exEnh = ItemInfo.Get(edSource.ItemID); + newEnh = exEnh.InsertEnhancedSteps(MyContent.Text, null, addtype, MyContent.Type, edSource.Type, this.ItemID); + } + } + iiCur = iiCur.MyPrevious; + } + + // no previous have enhanced links. now go through next: + ItemInfo iiNxt = this.GetNextItem(); + addtype = EAddpingPart.Before; + while (iiNxt != null && newEnh == null) + { + foreach (EnhancedDocument edSource in iiNxt.GetMyEnhancedDocuments()) + { + if (edSource.Type == enhtype) // found one to use: + { + ItemInfo exEnh = ItemInfo.Get(edSource.ItemID); + newEnh = exEnh.InsertEnhancedSteps(MyContent.Text, null, addtype, MyContent.Type, edSource.Type, this.ItemID); + } + } + iiNxt = iiNxt.GetNextItem(); + } + + // no next either, try the parent. + ItemInfo iiPar = this.MyParent; + addtype = EAddpingPart.Child; + while (iiPar != null && !iiPar.IsProcedure && newEnh == null) + { + foreach (EnhancedDocument edSource in iiPar.GetMyEnhancedDocuments()) + { + if (edSource.Type == enhtype) // found one to use: + { + ItemInfo exEnh = ItemInfo.Get(edSource.ItemID); + newEnh = exEnh.InsertEnhancedSteps(MyContent.Text, null, addtype, MyContent.Type, edSource.Type, this.ItemID); + } + } + iiPar = iiPar.MyParent; + } + if (newEnh != null) + { + StepConfig sc = new StepConfig(MyContent.Config); + sc.AddEnhancedDocument(enhtype, newEnh.ItemID); + SaveConfig(sc.ToString()); + } + return newEnh; + } #endregion #region DataPortal private void DataPortal_Fetch(PastingPartCriteria criteria) diff --git a/PROMS/Volian.Controls.Library/EditItem.cs b/PROMS/Volian.Controls.Library/EditItem.cs index 37d89c25..135b2501 100644 --- a/PROMS/Volian.Controls.Library/EditItem.cs +++ b/PROMS/Volian.Controls.Library/EditItem.cs @@ -1399,6 +1399,33 @@ namespace Volian.Controls.Library } } } + public void AddMissingEnhancedStep(ItemInfo ii, int EnhType) + { + // if the missing enhanced step is a cuation or note, check that parent HLS has the needed + // enhanced step to insert the caution/note from. If not, do a message. + if (ii.IsCaution || ii.IsNote) + { + bool canMakeMissingStep = false; + StepConfig sc = ii.MyHLS.MyConfig as StepConfig; + foreach (EnhancedDocument ed in sc.MyEnhancedDocuments) + { + if (EnhType == ed.Type) // the hls has an enhanced linked step of this type, the caution/note can be made: + { + canMakeMissingStep = true; + break; + } + } + if (!canMakeMissingStep) + { + MessageBox.Show("Cannot create the missing enhanced step, the Enhanced Step for the High Level step must be created first."); + return; + } + } + ItemInfo newEnh = ii.DoAddMissingEnhancedSteps(EnhType); + // if enhanced items were created, then see if they need displayed: + if (newEnh != null) AddAllEnhancedItemsToDisplay(MyItemInfo); + SetFocus(); + } private string GetChangeId(ItemInfo iiDest) { // get the change id for the destination's procedure's change id.