From d4be18b454318cb68f03bf3dcb51d60353b29da9 Mon Sep 17 00:00:00 2001 From: Kathy Date: Thu, 29 Jan 2015 13:45:25 +0000 Subject: [PATCH] support pasting of step into section and section into procedure; when updating transition text, refresh transinfo --- .../Extension/ItemInsertExt.cs | 52 +++++++++++++++---- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs index 35c3cfe0..019c6a6d 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs @@ -416,6 +416,7 @@ namespace VEPROMS.CSLA.Library #region PasteChangeId public static void PasteSetChangeId(ItemInfo ii, string chgid) { + if (!ii.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds) return; if (ii.IsProcedure) { return; // copy over change bars & change ids as they exist. @@ -428,13 +429,16 @@ namespace VEPROMS.CSLA.Library else if (ii.IsStep) { StepConfig sc = ii.MyConfig as StepConfig; - sc.Step_ChangeID = chgid; - using (Item itm = ii.Get()) + if (chgid != null && sc.Step_ChangeID != chgid) { - itm.MyContent.Config = sc.ToString(); - itm.MyContent.DTS = DateTime.Now; - itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID; - itm.Save(); + sc.Step_ChangeID = chgid; + using (Item itm = ii.Get()) + { + itm.MyContent.Config = sc.ToString(); + itm.MyContent.DTS = DateTime.Now; + itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID; + itm.Save(); + } } } // handle all of the children @@ -446,7 +450,35 @@ namespace VEPROMS.CSLA.Library if (ii.Steps != null) foreach (ItemInfo chlds in ii.Steps) PasteSetChangeId(chlds, chgid); } #endregion - #region PasteSiblingBefore + #region Paste + public ItemInfo PasteChild(int copyStartID, string chgid) + { + // To determine 'type' of pasted item, if it's a step (type >=20000), use the originating + // item, i.e. item inserting after. If it's a section or procedure, use the copied item's type. + ItemInfo cpItem = ItemInfo.Get(copyStartID); + int? type = MyContent.Type >= 20000 ? MyContent.Type : cpItem.MyContent.Type; + int? fromtype = MyContent.Type >= 20000 ? MyContent.Type + : ((int?)(IsProcedure ? E_FromType.Section + : (cpItem.IsSection ? E_FromType.Section : E_FromType.Step))); + try + { + ItemInfo tmp = CopyPasteItemInfoFetch(copyStartID, this.ItemID, type, fromtype, EAddpingPart.Child); + using (Item item = Get()) ItemInfo.Refresh(item); + if (tmp.NextItem != null) using (Item item = tmp.NextItem.Get()) ItemInfo.Refresh(item); + RefreshNextItems(); + tmp.UpdateTransitionText(); + tmp.UpdatePastedStepTransitionText(); + PasteSetChangeId(tmp, chgid); + OnNewChild(new ItemInfoInsertEventArgs(tmp, EAddpingPart.Child)); + return tmp; + } + catch (Exception ex) + { + if (!HandleSqlExceptionOnCopy(ex)) + System.Windows.Forms.MessageBox.Show("Details were written to the Error Log.", "Paste Failed", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); + return this; + } + } public ItemInfo PasteSiblingBefore(int copyStartID, string chgid) { // To determine 'type' of pasted item, if it's a step (type >=20000), use the originating @@ -623,6 +655,8 @@ namespace VEPROMS.CSLA.Library #region B2012-071 fix JCB foreach (TransitionInfo tran in trans) { + using (Transition trn = tran.Get()) + TransitionInfo.Refresh(trn); Content oldContent = null; using (Content content = tran.MyContent.Get()) { @@ -731,8 +765,8 @@ namespace VEPROMS.CSLA.Library switch (criteria.AddType) { case EAddpingPart.Child: - //cm.CommandText = "addItemChild"; - //cm.Parameters.AddWithValue("@FromType", criteria.FromType); //--C + cm.CommandText = "PasteItemChild"; + cm.Parameters.AddWithValue("@FromType", criteria.FromType); //--C break; case EAddpingPart.Before: cm.CommandText = "PasteItemSiblingBefore";