Calvert: copied steps/sections have change ids

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

View File

@@ -413,8 +413,41 @@ namespace VEPROMS.CSLA.Library
return tmp;
}
#endregion
#region PasteSiblingBefore
public ItemInfo PasteSiblingBefore(int copyStartID)
#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
public ItemInfo PasteSiblingBefore(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.
@@ -426,6 +459,7 @@ namespace VEPROMS.CSLA.Library
using (Item item = Get()) ItemInfo.Refresh(item);
tmp.UpdateTransitionText();
tmp.UpdatePastedStepTransitionText();
PasteSetChangeId(tmp, chgid);
OnNewSiblingBefore(new ItemInfoInsertEventArgs(tmp, EAddpingPart.Before));
return tmp;
}
@@ -436,7 +470,7 @@ namespace VEPROMS.CSLA.Library
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
// 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();
tmp.UpdateTransitionText();
tmp.UpdatePastedStepTransitionText();
PasteSetChangeId(tmp, chgid);
OnNewSiblingAfter(new ItemInfoInsertEventArgs(tmp, EAddpingPart.After));
return tmp;
}
@@ -1214,7 +1249,7 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region PasteReplace
public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID)
public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid)
{
if (!CanDeleteObject())
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
ItemInfo.DeleteItemInfoAndChildren(itemInfo.ItemID); // Dispose ItemInfo and Children
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);
newItemInfo.RefreshNextItems();
// if inserting after a caution or note, refreshes tabs. This will adjust bullets