Calvert: copied steps/sections have change ids

This commit is contained in:
Kathy Ruffing 2014-09-17 16:44:31 +00:00
parent 373634318b
commit e785302c9e
5 changed files with 82 additions and 18 deletions

View File

@ -245,6 +245,7 @@ namespace VEPROMS
tv.InsertItemInfo += new vlnTreeViewItemInfoInsertEvent(tv_InsertItemInfo); tv.InsertItemInfo += new vlnTreeViewItemInfoInsertEvent(tv_InsertItemInfo);
tv.NodeInsert += new vlnTreeViewEvent(tv_NodeInsert); tv.NodeInsert += new vlnTreeViewEvent(tv_NodeInsert);
tv.PasteItemInfo += new vlnTreeViewItemInfoPasteEvent(tv_PasteItemInfo); tv.PasteItemInfo += new vlnTreeViewItemInfoPasteEvent(tv_PasteItemInfo);
tv.GetChangeId += new vlnTreeViewGetChangeIdEvent(tv_GetChangeId);
tv.NodeCopy += new vlnTreeViewEvent(tv_NodeCopy); tv.NodeCopy += new vlnTreeViewEvent(tv_NodeCopy);
tv.ClipboardStatus += new vlnTreeViewClipboardStatusEvent(tv_ClipboardStatus); tv.ClipboardStatus += new vlnTreeViewClipboardStatusEvent(tv_ClipboardStatus);
tc.ItemPaste += new StepPanelItemPastedEvent(tc_ItemPasted); tc.ItemPaste += new StepPanelItemPastedEvent(tc_ItemPasted);
@ -282,6 +283,12 @@ namespace VEPROMS
displayApplicability.ApplicabilityViewModeChanged += new DisplayApplicability.DisplayApplicabilityEvent(displayApplicability_ApplicabilityViewModeChanged); displayApplicability.ApplicabilityViewModeChanged += new DisplayApplicability.DisplayApplicabilityEvent(displayApplicability_ApplicabilityViewModeChanged);
tv.ExportImportProcedureSets += new vlnTreeViewEvent(tv_ExportImportProcedureSets); tv.ExportImportProcedureSets += new vlnTreeViewEvent(tv_ExportImportProcedureSets);
} }
string tv_GetChangeId(object sender, vlnTreeItemInfoEventArgs args)
{
tc.HandleChangeId(args.MyItemInfo, null);
return tc.ChgId;
}
ItemInfo tv_ClipboardStatus(object sender, vlnTreeEventArgs args) ItemInfo tv_ClipboardStatus(object sender, vlnTreeEventArgs args)
{ {
return tc.MyCopyStep; return tc.MyCopyStep;

View File

@ -413,8 +413,41 @@ namespace VEPROMS.CSLA.Library
return tmp; return tmp;
} }
#endregion #endregion
#region PasteChangeId
public static void PasteSetChangeId(ItemInfo ii, string chgid)
{
if (ii.IsProcedure)
{
return; // copy over change bars & change ids as they exist.
}
else if (ii.IsSection)
{
// don't save change id for section. DON'T return though because code below sets
// change ids for steps within section.
}
else if (ii.IsStep)
{
StepConfig sc = ii.MyConfig as StepConfig;
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
if (ii.Cautions != null) foreach (ItemInfo chldc in ii.Cautions) PasteSetChangeId(chldc, chgid);
if (ii.Notes != null) foreach (ItemInfo chldn in ii.Notes) PasteSetChangeId(chldn, chgid);
if (ii.RNOs != null) foreach (ItemInfo chldr in ii.RNOs) PasteSetChangeId(chldr, chgid);
if (ii.Tables != null) foreach (ItemInfo chldt in ii.Tables) PasteSetChangeId(chldt, chgid);
if (ii.Sections != null) foreach (ItemInfo chldsc in ii.Sections) PasteSetChangeId(chldsc, chgid);
if (ii.Steps != null) foreach (ItemInfo chlds in ii.Steps) PasteSetChangeId(chlds, chgid);
}
#endregion
#region PasteSiblingBefore #region PasteSiblingBefore
public ItemInfo PasteSiblingBefore(int copyStartID) public ItemInfo PasteSiblingBefore(int copyStartID, string chgid)
{ {
// To determine 'type' of pasted item, if it's a step (type >=20000), use the originating // 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. // item, i.e. item inserting after. If it's a section or procedure, use the copied item's type.
@ -426,6 +459,7 @@ namespace VEPROMS.CSLA.Library
using (Item item = Get()) ItemInfo.Refresh(item); using (Item item = Get()) ItemInfo.Refresh(item);
tmp.UpdateTransitionText(); tmp.UpdateTransitionText();
tmp.UpdatePastedStepTransitionText(); tmp.UpdatePastedStepTransitionText();
PasteSetChangeId(tmp, chgid);
OnNewSiblingBefore(new ItemInfoInsertEventArgs(tmp, EAddpingPart.Before)); OnNewSiblingBefore(new ItemInfoInsertEventArgs(tmp, EAddpingPart.Before));
return tmp; return tmp;
} }
@ -436,7 +470,7 @@ namespace VEPROMS.CSLA.Library
return this; return this;
} }
} }
public ItemInfo PasteSiblingAfter(int copyStartID) public ItemInfo PasteSiblingAfter(int copyStartID, string chgid)
{ {
// To determine 'type' of pasted item, if it's a step (type >=20000), use the originating // 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. // item, i.e. item inserting after. If it's a section or procedure, use the copied item's type.
@ -453,6 +487,7 @@ namespace VEPROMS.CSLA.Library
if (tmp.IsCaution || tmp.IsNote) ResetOrdinal(); if (tmp.IsCaution || tmp.IsNote) ResetOrdinal();
tmp.UpdateTransitionText(); tmp.UpdateTransitionText();
tmp.UpdatePastedStepTransitionText(); tmp.UpdatePastedStepTransitionText();
PasteSetChangeId(tmp, chgid);
OnNewSiblingAfter(new ItemInfoInsertEventArgs(tmp, EAddpingPart.After)); OnNewSiblingAfter(new ItemInfoInsertEventArgs(tmp, EAddpingPart.After));
return tmp; return tmp;
} }
@ -1214,7 +1249,7 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region PasteReplace #region PasteReplace
public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID) public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid)
{ {
if (!CanDeleteObject()) if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Item"); throw new System.Security.SecurityException("User not authorized to remove a Item");
@ -1224,6 +1259,7 @@ namespace VEPROMS.CSLA.Library
// Delete business objects, including remove from tree // Delete business objects, including remove from tree
ItemInfo.DeleteItemInfoAndChildren(itemInfo.ItemID); // Dispose ItemInfo and Children ItemInfo.DeleteItemInfoAndChildren(itemInfo.ItemID); // Dispose ItemInfo and Children
using (Item item = Get(newItemInfo.ItemID)) ItemInfo.Refresh(item); using (Item item = Get(newItemInfo.ItemID)) ItemInfo.Refresh(item);
ItemInfo.PasteSetChangeId(newItemInfo, chgid);
if (newItemInfo.NextItem != null) using (Item item = newItemInfo.NextItem.Get()) ItemInfo.Refresh(item); if (newItemInfo.NextItem != null) using (Item item = newItemInfo.NextItem.Get()) ItemInfo.Refresh(item);
newItemInfo.RefreshNextItems(); newItemInfo.RefreshNextItems();
// if inserting after a caution or note, refreshes tabs. This will adjust bullets // if inserting after a caution or note, refreshes tabs. This will adjust bullets

View File

@ -874,7 +874,7 @@ namespace Volian.Controls.Library
} }
private void PromptForChangeId(ItemInfo myItemInfo, DisplayTabItem pg) private void PromptForChangeId(ItemInfo myItemInfo, DisplayTabItem pg)
{ {
dlgChgId dlgCI = new dlgChgId(this); dlgChgId dlgCI = new dlgChgId(this); //, null);
dlgCI.ShowDialog(this); dlgCI.ShowDialog(this);
ItemsChangeIds.Add(myItemInfo.MyProcedure.ItemID, ChgId); ItemsChangeIds.Add(myItemInfo.MyProcedure.ItemID, ChgId);
SetChangeId(ChgId, pg, myItemInfo); SetChangeId(ChgId, pg, myItemInfo);
@ -882,12 +882,12 @@ namespace Volian.Controls.Library
private void SetChangeId(string chgid, DisplayTabItem pg, ItemInfo ii) private void SetChangeId(string chgid, DisplayTabItem pg, ItemInfo ii)
{ {
if (pg == null || pg.MyStepTabPanel == null) //if (pg == null || pg.MyStepTabPanel == null)
{ //{
ChgId = null; // ChgId = null;
return; // return;
} //}
pg.MyStepTabPanel.MyStepTabRibbon.SetChangeId(chgid, ii); if (pg != null && pg.MyStepTabPanel != null) pg.MyStepTabPanel.MyStepTabRibbon.SetChangeId(chgid, ii);
ChgId = chgid; ChgId = chgid;
} }
/// <summary> /// <summary>

View File

@ -1178,8 +1178,10 @@ namespace Volian.Controls.Library
#region CopyPaste #region CopyPaste
public void PasteSiblingBefore(int copyStartID) public void PasteSiblingBefore(int copyStartID)
{ {
ItemInfo newItemInfo = MyItemInfo.PasteSiblingBefore(copyStartID); ItemInfo newItemInfo = MyItemInfo.PasteSiblingBefore(copyStartID, GetChangeId(MyItemInfo));
if (newItemInfo.ItemID == MyItemInfo.ItemID) return; if (newItemInfo.ItemID == MyItemInfo.ItemID) return;
EditItem newEditItem = null; EditItem newEditItem = null;
switch (_MyChildRelation) switch (_MyChildRelation)
{ {
@ -1199,9 +1201,18 @@ namespace Volian.Controls.Library
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.Before, newItemInfo.MyContent.Type)); MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.Before, newItemInfo.MyContent.Type));
} }
private string GetChangeId(ItemInfo iiDest)
{
// get the change id for the destination's procedure's change id.
string chgid = null;
if (iiDest.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds)
chgid = MyStepPanel.MyStepTabPanel.MyDisplayTabControl.ItemsChangeIds[iiDest.MyProcedure.ItemID];
return chgid;
}
public void PasteSiblingAfter(int copyStartID) public void PasteSiblingAfter(int copyStartID)
{ {
ItemInfo newItemInfo = MyItemInfo.PasteSiblingAfter(copyStartID); ItemInfo newItemInfo = MyItemInfo.PasteSiblingAfter(copyStartID, GetChangeId(MyItemInfo));
if (newItemInfo.ItemID == MyItemInfo.ItemID) return; if (newItemInfo.ItemID == MyItemInfo.ItemID) return;
EditItem newEditItem = null; EditItem newEditItem = null;
switch (_MyChildRelation) switch (_MyChildRelation)
@ -1241,7 +1252,7 @@ namespace Volian.Controls.Library
ItemInfo newItemInfo = null; ItemInfo newItemInfo = null;
try try
{ {
newItemInfo = Item.PasteReplace(MyItemInfo, copyStartID); newItemInfo = Item.PasteReplace(MyItemInfo, copyStartID, GetChangeId(MyItemInfo));
} }
//catch (System.Data.SqlClient.SqlException ex) //catch (System.Data.SqlClient.SqlException ex)
catch (Exception ex) catch (Exception ex)

View File

@ -30,6 +30,7 @@ namespace Volian.Controls.Library
public delegate void vlnTreeViewSectionInfoEvent(object sender, vlnTreeSectionInfoEventArgs args); public delegate void vlnTreeViewSectionInfoEvent(object sender, vlnTreeSectionInfoEventArgs args);
public delegate void WordSectionDeletedEvent(object sender, WordSectionEventArgs args); public delegate void WordSectionDeletedEvent(object sender, WordSectionEventArgs args);
public delegate void vlnTreeViewPdfEvent(object sender, vlnTreeViewPdfArgs args); public delegate void vlnTreeViewPdfEvent(object sender, vlnTreeViewPdfArgs args);
public delegate string vlnTreeViewGetChangeIdEvent(object sender, vlnTreeItemInfoEventArgs args);
public partial class vlnTreeSectionInfoEventArgs public partial class vlnTreeSectionInfoEventArgs
{ {
private bool _IsDeleting = false; private bool _IsDeleting = false;
@ -336,6 +337,12 @@ namespace Volian.Controls.Library
ItemInfo _LastItemInfo = null; ItemInfo _LastItemInfo = null;
#endregion #endregion
#region Events #region Events
public event vlnTreeViewGetChangeIdEvent GetChangeId;
private string OnGetChangeId(object sender, vlnTreeItemInfoEventArgs args)
{
if (GetChangeId != null) return GetChangeId(sender, args);
return null;
}
public event vlnTreeViewPdfEvent ViewPDF; public event vlnTreeViewPdfEvent ViewPDF;
private void OnViewPDF(object sender, vlnTreeViewPdfArgs args) private void OnViewPDF(object sender, vlnTreeViewPdfArgs args)
{ {
@ -1488,11 +1495,13 @@ namespace Volian.Controls.Library
if (ii.IsProcedure || !OnPasteItemInfo(this, new vlnTreeItemInfoPasteEventArgs(ii, copyStartID, pasteOpt, ii.MyContent.Type))) if (ii.IsProcedure || !OnPasteItemInfo(this, new vlnTreeItemInfoPasteEventArgs(ii, copyStartID, pasteOpt, ii.MyContent.Type)))
{ {
// The parent step was not open in the step editor, just paste step (in data) and add treenode. // The parent step was not open in the step editor, just paste step (in data) and add treenode.
// first, check if a changeid is required.
string chgId = OnGetChangeId(this, new vlnTreeItemInfoEventArgs(ii));
ItemInfo newItemInfo = null; ItemInfo newItemInfo = null;
if (newtype == MenuSelections.StepBefore) if (newtype == MenuSelections.StepBefore)
newItemInfo = ii.PasteSiblingBefore(copyStartID); newItemInfo = ii.PasteSiblingBefore(copyStartID, chgId);
else else
newItemInfo = ii.PasteSiblingAfter(copyStartID); newItemInfo = ii.PasteSiblingAfter(copyStartID, chgId);
} }
SelectedNode = (VETreeNode)((newtype == MenuSelections.StepAfter) ? tn.NextNode : tn.PrevNode); SelectedNode = (VETreeNode)((newtype == MenuSelections.StepAfter) ? tn.NextNode : tn.PrevNode);
} }
@ -1503,8 +1512,9 @@ namespace Volian.Controls.Library
ItemInfo ii = tn.VEObject as ItemInfo; ItemInfo ii = tn.VEObject as ItemInfo;
if (!OnPasteItemInfo(this, new vlnTreeItemInfoPasteEventArgs(ii, copyStartID, ItemInfo.EAddpingPart.Replace, ii.MyContent.Type))) if (!OnPasteItemInfo(this, new vlnTreeItemInfoPasteEventArgs(ii, copyStartID, ItemInfo.EAddpingPart.Replace, ii.MyContent.Type)))
{ {
//return; // first, check if a changeid is required.
ItemInfo replItemInfo = Item.PasteReplace(ii, copyStartID); string chgId = OnGetChangeId(this, new vlnTreeItemInfoEventArgs(ii));
ItemInfo replItemInfo = Item.PasteReplace(ii, copyStartID, chgId);
} }
SelectedNode = (VETreeNode)((prevtn != null) ? prevtn.NextNode : partn.FirstNode); SelectedNode = (VETreeNode)((prevtn != null) ? prevtn.NextNode : partn.FirstNode);
} }