Enhanced Document support
Null check Move DisplayText.cs to CSLA Enhanced Documents – don’t allow ‘Save’ RO on enhanced step Enhanced Documents windowing Enhanced Documents remove unnecessary options Enhanced Documents – don’t allow ‘Save’ transition on enhanced step Enhanced Documents/Insert,Delete,Paste
This commit is contained in:
@@ -632,9 +632,9 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetType() == typeof(ProcedureInfo))
|
||||
if (GetType() == typeof(ProcedureInfo) || MyContent.Type < 10000)
|
||||
tmp = DataPortal.Fetch<ProcedureInfo>(new PastingPartCriteria(copyStartID, itemID, addType, type, fromType, DateTime.Now, Volian.Base.Library.VlnSettings.UserID));
|
||||
else if (GetType() == typeof(SectionInfo))
|
||||
else if (GetType() == typeof(SectionInfo) || (MyContent.Type < 20000))
|
||||
tmp = DataPortal.Fetch<SectionInfo>(new PastingPartCriteria(copyStartID, itemID, addType, type, fromType, DateTime.Now, Volian.Base.Library.VlnSettings.UserID));
|
||||
else
|
||||
tmp = DataPortal.Fetch<StepInfo>(new PastingPartCriteria(copyStartID, itemID, addType, type, fromType, DateTime.Now, Volian.Base.Library.VlnSettings.UserID));
|
||||
@@ -838,19 +838,32 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
#endregion
|
||||
#region Enhanced Document Support
|
||||
public ItemInfo DoAddEnhancedSteps(int enhType, int enhItemID, EAddpingPart addpart)
|
||||
{
|
||||
// get the item object in the enhanced document so that inserting of the new enhanced item and
|
||||
// its children can be done:
|
||||
ItemInfo existingEnhancedItemInfo = ItemInfo.Get(enhItemID);
|
||||
ItemInfo newEnhancedItemInfo = existingEnhancedItemInfo.InsertEnhancedSteps(MyContent.Text, null, addpart, MyContent.Type, enhType, ItemID);
|
||||
if (newEnhancedItemInfo == null) return null;
|
||||
StepConfig sc = new StepConfig(MyContent.Config);
|
||||
sc.AddEnhancedDocument(enhType, newEnhancedItemInfo.ItemID);
|
||||
SaveConfig(sc.ToString());
|
||||
return newEnhancedItemInfo;
|
||||
}
|
||||
public ItemInfo InsertEnhancedSteps(string text, string number, EAddpingPart addType, int? type, int eDocType, int newSourceID)
|
||||
//public ItemInfo InsertEnhancedSiblingAfter(string text, string number, int? type, int eDocType, int newID)
|
||||
{
|
||||
ItemInfo tmp = null;
|
||||
if (addType == EAddpingPart.Child)
|
||||
{
|
||||
E_FromType fromType = E_FromType.Caution;
|
||||
if (ActiveFormat.PlantFormat.FormatData.StepDataList[(int)type- 20000].Type.ToUpper() == "NOTE") fromType = E_FromType.Note;
|
||||
if (this.IsSection) fromType = E_FromType.Step;
|
||||
else if (ActiveFormat.PlantFormat.FormatData.StepDataList[(int)type - 20000].Type.ToUpper() == "NOTE") fromType = E_FromType.Note;
|
||||
tmp = InsertEnhancedSmartTemplateSubStep(text, number, this, addType, (int)type, fromType, newSourceID);
|
||||
}
|
||||
else
|
||||
tmp = InsertEnhancedSmartTemplateSteps(text, number, this, addType, (int)type, newSourceID);
|
||||
//ItemInfo tmp = InsertEnhancedSmartTemplateSteps(text, number, this, EAddpingPart.After, (int)MyContent.Type, newID);
|
||||
tmp = InsertEnhancedSmartTemplateSteps(text, number, this, addType, 20002, newSourceID);
|
||||
if (tmp == null) return null;
|
||||
|
||||
// if next exists, it is updated in SQL so we have to manually force the iteminfo updates
|
||||
// Refresh ItemInfo to update PreviousID field
|
||||
if (tmp.NextItem != null) using (Item item = tmp.NextItem.Get()) ItemInfo.Refresh(item);
|
||||
@@ -858,14 +871,21 @@ namespace VEPROMS.CSLA.Library
|
||||
// if inserting after a caution or note, refreshes tabs. This will adjust bullets
|
||||
// of any previous cautions or notes.
|
||||
if (tmp.IsCaution || tmp.IsNote) ResetOrdinal();
|
||||
// Update all of the content records that have transitions that point to the Siblings or Sibling Children of the new item
|
||||
//tmp.UpdateTransitionText();
|
||||
tmp.UpdateROText();
|
||||
//?? OnNewSiblingAfter(new ItemInfoInsertEventArgs(tmp, EAddpingPart.After));
|
||||
// Note that non-enhanced update transition and ro text at this point. But since
|
||||
// transitions and ro's are converted to text, this is not needed.
|
||||
|
||||
if (addType == EAddpingPart.Child)
|
||||
OnNewChild(new ItemInfoInsertEventArgs(tmp, EAddpingPart.Child));
|
||||
else if (addType == EAddpingPart.After)
|
||||
{
|
||||
OnNewSiblingAfter(new ItemInfoInsertEventArgs(tmp, EAddpingPart.After));
|
||||
|
||||
}
|
||||
else if (addType == EAddpingPart.Before)
|
||||
OnNewSiblingBefore(new ItemInfoInsertEventArgs(tmp, EAddpingPart.Before));
|
||||
return tmp;
|
||||
}
|
||||
|
||||
private ItemInfo InsertEnhancedSmartTemplateSubStep(string text, string number, ItemInfo tmp, EAddpingPart addType, int type, E_FromType fromTypeTop, int newID)
|
||||
private ItemInfo InsertEnhancedSmartTemplateSubStep(string text, string number, ItemInfo tmp, EAddpingPart addType, int type, E_FromType fromTypeTop, int newSourceID)
|
||||
{
|
||||
int newItemID = 0;
|
||||
int topType = GetSmartTemplateTopLevelIndxOfThisType(type);
|
||||
@@ -882,11 +902,9 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (firstSmart == null)
|
||||
{
|
||||
// set stepconfig for this new enhanced item:
|
||||
StepConfig sc = new StepConfig("");
|
||||
sc.AddEnhancedDocument(0, newID);
|
||||
|
||||
firstSmart = NewItemInfoFetch(ItemID, addType, number, tmptext, type, (int?)fromTypeTop, null, null, DateTime.Now, Volian.Base.Library.VlnSettings.UserID);
|
||||
sc.AddEnhancedDocument(0, newSourceID);
|
||||
firstSmart = NewItemInfoFetch(ItemID, addType, number, tmptext, type, (int?)fromTypeTop, null, sc.ToString(), DateTime.Now, Volian.Base.Library.VlnSettings.UserID);
|
||||
siblingSmart = firstSmart;
|
||||
newItemID = firstSmart.ItemID;
|
||||
}
|
||||
@@ -942,10 +960,9 @@ namespace VEPROMS.CSLA.Library
|
||||
if (firstSmart == null)
|
||||
{
|
||||
// set stepconfig for this new enhanced item:
|
||||
StepConfig sc = new StepConfig("" );
|
||||
StepConfig sc = new StepConfig("");
|
||||
sc.AddEnhancedDocument(0, newSourceID);
|
||||
firstSmart = CopyPasteItemInfoFetch(newSourceID, this.ItemID, type, type, eAddpingPart);
|
||||
//firstSmart = NewItemInfoFetch(ItemID, eAddpingPart, number, tmptext, type, null, null, sc.ToString(), DateTime.Now, Volian.Base.Library.VlnSettings.UserID);
|
||||
firstSmart = NewItemInfoFetch(ItemID, eAddpingPart, number, tmptext, type, null, null, sc.ToString(), DateTime.Now, Volian.Base.Library.VlnSettings.UserID);
|
||||
siblingSmart = parentSmart = firstSmart;
|
||||
newItemID = firstSmart.ItemID;
|
||||
}
|
||||
@@ -983,8 +1000,424 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
tmp = firstSmart;
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
public ItemInfo EnhancedPasteItem(int copyStartID, ItemInfo pasteFromItem, EAddpingPart addType, string chgid)
|
||||
{
|
||||
EnhancedDocuments pasteFromItemsEnhancedDocuments = pasteFromItem.GetMyEnhancedDocuments();
|
||||
if (pasteFromItemsEnhancedDocuments == null || pasteFromItemsEnhancedDocuments.Count == 0) return null;
|
||||
ItemInfo newItemInfo = this;
|
||||
ItemInfo newEnhancedItemInfo = null;
|
||||
// need to save the original item ids in the copied item so that they can be
|
||||
// changed to the new enhanced ids in 'config'. The oldid/newid pairs will
|
||||
// be stored in a dictionary & the update will be made after the loop.
|
||||
Dictionary<int, int> oldToNewEnhancedIds = new Dictionary<int, int>();
|
||||
|
||||
// tmpCopyStartSourceItem is the item that was copied in source.
|
||||
ItemInfo tmpCopyStartSourceItem = ItemInfo.Get(copyStartID);
|
||||
|
||||
// loop through all enhanced document types, pasting in the copied item(s).
|
||||
// Note that the copy/paste finds the enhanced items that relate to source,
|
||||
// i.e. copied item & paste from, and uses those to do the copy/paste.
|
||||
// sc is the config (passed in) for the item that we are pasting around.
|
||||
foreach (EnhancedDocument edSource in pasteFromItem.GetMyEnhancedDocuments())
|
||||
{
|
||||
if (edSource.Type != 0)
|
||||
{
|
||||
ItemInfo tmpPasteItemFrom = ItemInfo.Get(edSource.ItemID); // here is problem
|
||||
|
||||
// get the 'enhanced' item to copy. To do this, get the enhanced link
|
||||
// from source's config that matches this 'type'. Use that Id to get the enhanced
|
||||
// Item that is to be copied:
|
||||
int tmpCopyEnhancedID = 0;
|
||||
foreach (EnhancedDocument edCopy in tmpCopyStartSourceItem.GetMyEnhancedDocuments())
|
||||
{
|
||||
if (edSource.Type == edCopy.Type)
|
||||
{
|
||||
tmpCopyEnhancedID = edCopy.ItemID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tmpCopyEnhancedID == 0) break; // no connected copied item.
|
||||
if (addType == EAddpingPart.Before)
|
||||
newEnhancedItemInfo = tmpPasteItemFrom.PasteSiblingBefore(tmpCopyEnhancedID, chgid);
|
||||
else if (addType == EAddpingPart.After)
|
||||
newEnhancedItemInfo = tmpPasteItemFrom.PasteSiblingAfter(tmpCopyEnhancedID, chgid);
|
||||
else if (addType == EAddpingPart.Child)
|
||||
newEnhancedItemInfo = tmpPasteItemFrom.PasteChild(tmpCopyEnhancedID, chgid);
|
||||
else if (addType == EAddpingPart.Replace) // what about user interface for enhanced pasted steps?
|
||||
{
|
||||
ItemInfo enhReplaceItem = ItemInfo.Get(edSource.ItemID);
|
||||
newEnhancedItemInfo = Item.PasteReplace(enhReplaceItem, tmpCopyEnhancedID, chgid);
|
||||
}
|
||||
|
||||
// update the config data for the new enhanced item (procedure, section or step) to point back to the correct source
|
||||
string cfgEnhStr = null;
|
||||
if (newEnhancedItemInfo.IsStep)
|
||||
{
|
||||
StepConfig scnewenh = newEnhancedItemInfo.MyConfig as StepConfig;
|
||||
if (scnewenh == null) break; //error here, i.e. should have a related enhanced step
|
||||
scnewenh.MyEnhancedDocuments[0].ItemID = newItemInfo.ItemID;
|
||||
scnewenh.SaveEnhancedDocuments();
|
||||
cfgEnhStr = scnewenh.ToString();
|
||||
}
|
||||
else if (newEnhancedItemInfo.IsSection)
|
||||
{
|
||||
SectionConfig secnewenh = newEnhancedItemInfo.MyConfig as SectionConfig;
|
||||
if (secnewenh == null) break; //error here, i.e. should have a related enhanced step
|
||||
secnewenh.MyEnhancedDocuments[0].ItemID = newItemInfo.ItemID;
|
||||
secnewenh.SaveEnhancedDocuments();
|
||||
cfgEnhStr = secnewenh.ToString();
|
||||
}
|
||||
else if (newEnhancedItemInfo.IsProcedure)
|
||||
{
|
||||
ProcedureConfig pnewenh = newEnhancedItemInfo.MyConfig as ProcedureConfig;
|
||||
if (pnewenh == null) break; //error here, i.e. should have a related enhanced step
|
||||
pnewenh.MyEnhancedDocuments[0].ItemID = newItemInfo.ItemID;
|
||||
pnewenh.SaveEnhancedDocuments();
|
||||
cfgEnhStr = pnewenh.ToString();
|
||||
}
|
||||
if (cfgEnhStr != null) newEnhancedItemInfo.SaveConfig(cfgEnhStr);
|
||||
// save the new enhanced step ids to set in the new source's config (to relate steps)
|
||||
foreach (EnhancedDocument edNew in newItemInfo.GetMyEnhancedDocuments())
|
||||
{
|
||||
if (edNew.ItemID == tmpCopyEnhancedID) oldToNewEnhancedIds.Add(edNew.ItemID, newEnhancedItemInfo.ItemID);
|
||||
}
|
||||
}
|
||||
}
|
||||
// update the config to point to new enhanced document steps for the new source item
|
||||
if (oldToNewEnhancedIds.Count > 0)
|
||||
{
|
||||
// save the updated config info on the newly pasted source: step, section or procedure:
|
||||
string cfgNewSrc = null;
|
||||
if (newItemInfo.IsStep)
|
||||
{
|
||||
StepConfig scnewpst1 = newItemInfo.MyConfig as StepConfig;
|
||||
foreach (EnhancedDocument edOrig in scnewpst1.MyEnhancedDocuments)
|
||||
edOrig.ItemID = oldToNewEnhancedIds[edOrig.ItemID];
|
||||
scnewpst1.SaveEnhancedDocuments();
|
||||
cfgNewSrc = scnewpst1.ToString();
|
||||
}
|
||||
else if (newItemInfo.IsSection)
|
||||
{
|
||||
SectionConfig secnewpst1 = newItemInfo.MyConfig as SectionConfig;
|
||||
foreach (EnhancedDocument edOrig in secnewpst1.MyEnhancedDocuments)
|
||||
edOrig.ItemID = oldToNewEnhancedIds[edOrig.ItemID];
|
||||
secnewpst1.SaveEnhancedDocuments();
|
||||
cfgNewSrc = secnewpst1.ToString();
|
||||
}
|
||||
else if (newItemInfo.IsProcedure)
|
||||
{
|
||||
ProcedureConfig pnewpst1 = newItemInfo.MyConfig as ProcedureConfig;
|
||||
foreach (EnhancedDocument edOrig in pnewpst1.MyEnhancedDocuments)
|
||||
edOrig.ItemID = oldToNewEnhancedIds[edOrig.ItemID];
|
||||
pnewpst1.SaveEnhancedDocuments();
|
||||
cfgNewSrc = pnewpst1.ToString();
|
||||
}
|
||||
if (cfgNewSrc != null) newItemInfo.SaveConfig(cfgNewSrc);
|
||||
}
|
||||
// if this is a HLS, then need to adjust links between any associated notes/cautions too:
|
||||
if (newItemInfo.IsStep)
|
||||
{
|
||||
StepConfig scForNC = newItemInfo.MyConfig as StepConfig;
|
||||
foreach (EnhancedDocument ed in scForNC.MyEnhancedDocuments) EnhancedSetNoteCautionLinks(newItemInfo, ed.Type);
|
||||
}
|
||||
return newEnhancedItemInfo;
|
||||
}
|
||||
#region HandleEnhancedNoteCautionConfigLinks
|
||||
private static void EnhancedSetNoteCautionLinks(ItemInfo newItemInfo, int enhType)
|
||||
{
|
||||
// For this enhanced document type, adjust all of the ids to link between source & enhanced if there are
|
||||
// notes & cautions. Notes first. There may be some source notes that aren't linked and some enhanced
|
||||
// that are not linked, so account for this.
|
||||
// get the high level enhanced step, this will be used for both note & caution code:
|
||||
ItemInfo enhHls = null;
|
||||
foreach (EnhancedDocument enh in newItemInfo.GetMyEnhancedDocuments())
|
||||
{
|
||||
if (enh.Type == enhType)
|
||||
{
|
||||
enhHls = ItemInfo.Get(enh.ItemID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newItemInfo.IsHigh && enhHls != null && newItemInfo.Notes != null && newItemInfo.Notes.Count > 0)
|
||||
{
|
||||
int srcIndxNt = 0;
|
||||
int enhIndxNt = 0;
|
||||
// for each note association between the source & enhanced document, update
|
||||
// the config items to link them.
|
||||
ItemInfo srcNtItem = newItemInfo.Notes[srcIndxNt];
|
||||
while (srcNtItem != null)
|
||||
{
|
||||
StepConfig scSourceNote = newItemInfo.Notes[srcIndxNt].MyConfig as StepConfig;
|
||||
if (scSourceNote.MyEnhancedDocuments.Count > 0)
|
||||
{
|
||||
// Loop through for each enhanced document related to the pasted source HLS
|
||||
foreach (EnhancedDocument enh in srcNtItem.GetMyEnhancedDocuments())
|
||||
{
|
||||
if (enh.Type == enhType)
|
||||
{
|
||||
// Find hls in enhanced in order to get its notes to set their config to
|
||||
// point back to the new source's note itemid. There may be enhanced items that
|
||||
// don't connect back, so find one that does based on Enhance HLS note list &
|
||||
// the notes' links back to source.
|
||||
ItemInfo enhNtItem = null;
|
||||
while (enhNtItem == null && enhIndxNt < enhHls.Notes.Count)
|
||||
{
|
||||
ItemInfo enhTstNote = enhHls.Notes[enhIndxNt];
|
||||
StepConfig enhTstNoteCfg = enhTstNote.MyConfig as StepConfig;
|
||||
if (enhTstNoteCfg.MyEnhancedDocuments.Count > 0)
|
||||
{
|
||||
foreach (EnhancedDocument enhNt in enhTstNote.GetMyEnhancedDocuments())
|
||||
{
|
||||
if (enhNt.Type == 0) // found it:
|
||||
{
|
||||
enhNtItem = enhTstNote;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (enhNtItem == null) enhIndxNt++;
|
||||
}
|
||||
if (enhNtItem != null)
|
||||
{
|
||||
StepConfig scNewEnhancedNote = enhNtItem.MyConfig as StepConfig;
|
||||
scNewEnhancedNote.MyEnhancedDocuments[0].ItemID = newItemInfo.Notes[srcIndxNt].ItemID;
|
||||
scNewEnhancedNote.SaveEnhancedDocuments();
|
||||
enhNtItem.SaveConfig(scNewEnhancedNote.ToString());
|
||||
foreach (EnhancedDocument noteEnh in scSourceNote.MyEnhancedDocuments)
|
||||
{
|
||||
if (noteEnh.Type == enhType)
|
||||
{
|
||||
noteEnh.ItemID = enhHls.Notes[enhIndxNt].ItemID;
|
||||
scSourceNote.SaveEnhancedDocuments();
|
||||
newItemInfo.Notes[srcIndxNt].SaveConfig(scSourceNote.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
enhIndxNt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
srcIndxNt++;
|
||||
srcNtItem = srcIndxNt>=newItemInfo.Notes.Count?null:newItemInfo.Notes[srcIndxNt];
|
||||
}
|
||||
}
|
||||
// now do any cautions.
|
||||
if (newItemInfo.IsHigh && newItemInfo.Cautions != null && newItemInfo.Cautions.Count > 0)
|
||||
{
|
||||
int srcIndxCt = 0;
|
||||
int enhIndxCt = 0;
|
||||
// for each caution association between the source & enhanced document, update
|
||||
// the config items to link them.
|
||||
ItemInfo srcCtItem = newItemInfo.Cautions[srcIndxCt];
|
||||
while (srcCtItem != null)
|
||||
{
|
||||
StepConfig scSourceCaution = newItemInfo.Cautions[srcIndxCt].MyConfig as StepConfig;
|
||||
if (scSourceCaution.MyEnhancedDocuments.Count > 0)
|
||||
{
|
||||
// Loop through for each enhanced document related to the pasted source HLS
|
||||
foreach (EnhancedDocument enh in srcCtItem.GetMyEnhancedDocuments())
|
||||
{
|
||||
if (enh.Type == enhType)
|
||||
{
|
||||
// Find hls in enhanced in order to get its notes to set their config to
|
||||
// point back to the new source's note itemid.
|
||||
ItemInfo enhCtItem = null;
|
||||
while (enhCtItem == null && enhIndxCt < enhHls.Cautions.Count)
|
||||
{
|
||||
ItemInfo enhTstCaut = enhHls.Cautions[enhIndxCt];
|
||||
StepConfig enhTstCautCfg = enhTstCaut.MyConfig as StepConfig;
|
||||
if (enhTstCautCfg.MyEnhancedDocuments.Count > 0)
|
||||
{
|
||||
foreach (EnhancedDocument enhCt in enhTstCaut.GetMyEnhancedDocuments())
|
||||
{
|
||||
if (enhCt.Type == 0)
|
||||
{
|
||||
enhCtItem = enhTstCaut;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (enhCtItem == null) enhIndxCt++;
|
||||
}
|
||||
if (enhCtItem != null)
|
||||
{
|
||||
StepConfig scNewEnhancedCaution = enhCtItem.MyConfig as StepConfig;
|
||||
scNewEnhancedCaution.MyEnhancedDocuments[0].ItemID = newItemInfo.Cautions[srcIndxCt].ItemID;
|
||||
scNewEnhancedCaution.SaveEnhancedDocuments();
|
||||
enhCtItem.SaveConfig(scNewEnhancedCaution.ToString());
|
||||
foreach (EnhancedDocument cautionEnh in scSourceCaution.MyEnhancedDocuments)
|
||||
{
|
||||
if (cautionEnh.Type == enh.Type)
|
||||
{
|
||||
cautionEnh.ItemID = enhHls.Cautions[enhIndxCt].ItemID;
|
||||
scSourceCaution.SaveEnhancedDocuments();
|
||||
newItemInfo.Cautions[srcIndxCt].SaveConfig(scSourceCaution.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
enhIndxCt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
srcIndxCt++;
|
||||
srcCtItem = srcIndxCt >= newItemInfo.Cautions.Count ? null : newItemInfo.Cautions[srcIndxCt];
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region HandleEnhancedStepConfigLinks
|
||||
private void EnhancedSetStepLinks(ItemInfo newSourceSectionInfo, int enhType)
|
||||
{
|
||||
//for the input source section, link all HLS to enhanced HLS (and any associated cautions/notes). Note that
|
||||
// this assumes that all source steps are linked, but there may be 'deleted' steps in enhanced that may not be linked back.
|
||||
ItemInfo newEnhSectionInfo = null;
|
||||
ItemInfo enhStep = null; // in enhanced document, find first step that has links (there may be enhanced steps that don't have links)
|
||||
SectionConfig newSectCfg = newSourceSectionInfo.MyConfig as SectionConfig;
|
||||
foreach (EnhancedDocument ed in newSectCfg.MyEnhancedDocuments)
|
||||
{
|
||||
if (ed.Type == enhType)
|
||||
{
|
||||
newEnhSectionInfo = ItemInfo.Get(ed.ItemID);
|
||||
StepConfig cfg = newEnhSectionInfo.Steps[0].MyConfig as StepConfig;
|
||||
if (cfg.MyEnhancedDocuments.Count > 0) enhStep = newEnhSectionInfo.Steps[0];
|
||||
else enhStep = GetNextEnhancedStep(newEnhSectionInfo.Steps[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (enhStep == null) return;
|
||||
// now adjust all of the ids to link between source & enhanced for this section's steps.
|
||||
// The enhType represents which enhanced document we are working with, for example, backgrounds or deviations.
|
||||
for (int iStp = 0; iStp < newSourceSectionInfo.Steps.Count; iStp++)
|
||||
{
|
||||
StepConfig scSourceStep = newSourceSectionInfo.Steps[iStp].MyConfig as StepConfig;
|
||||
if (scSourceStep.MyEnhancedDocuments.Count > 0)
|
||||
{
|
||||
// Loop through for each enhanced document related to the pasted source HLS
|
||||
foreach (EnhancedDocument enh in scSourceStep.MyEnhancedDocuments)
|
||||
{
|
||||
if (enh.Type == enhType)
|
||||
{
|
||||
// Find hls in enhanced in order to set the config to point back to the new source's itemid.
|
||||
ItemInfo enhHls = enhStep;
|
||||
StepConfig scNewEnhancedStep = enhHls.MyConfig as StepConfig;
|
||||
scNewEnhancedStep.MyEnhancedDocuments[0].ItemID = newSourceSectionInfo.Steps[iStp].ItemID;
|
||||
scNewEnhancedStep.SaveEnhancedDocuments();
|
||||
enhHls.SaveConfig(scNewEnhancedStep.ToString());
|
||||
// set the source to go to this enh.
|
||||
enh.ItemID = enhHls.ItemID;
|
||||
scSourceStep.SaveEnhancedDocuments();
|
||||
newSourceSectionInfo.Steps[iStp].SaveConfig(scSourceStep.ToString());
|
||||
EnhancedSetNoteCautionLinks(newSourceSectionInfo.Steps[iStp], enhType);
|
||||
}
|
||||
}
|
||||
}
|
||||
enhStep = GetNextEnhancedStep(enhStep);
|
||||
}
|
||||
}
|
||||
private ItemInfo GetNextEnhancedStep(ItemInfo itemInfo)
|
||||
{
|
||||
if (itemInfo==null) return null;
|
||||
ItemInfo curStep = itemInfo.NextItem;
|
||||
while (curStep != null)
|
||||
{
|
||||
StepConfig cfg = curStep.MyConfig as StepConfig;
|
||||
if (cfg.MyEnhancedDocuments.Count > 0) return curStep;
|
||||
curStep = curStep.NextItem;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private ItemInfo GetNextEnhancedSection(ItemInfo itemInfo)
|
||||
{
|
||||
if (itemInfo == null) return null;
|
||||
ItemInfo curSect = itemInfo.NextItem;
|
||||
while (curSect != null)
|
||||
{
|
||||
SectionConfig cfg = curSect.MyConfig as SectionConfig;
|
||||
if (cfg.MyEnhancedDocuments.Count > 0) return curSect;
|
||||
curSect = curSect.NextItem;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
public ItemInfo PasteEnhancedItems(int copyStartID, ItemInfo pasteFromItem, EAddpingPart addType, string chgid)
|
||||
{
|
||||
ItemInfo retItem = null;
|
||||
if (IsProcedure) // newly Pasted Item is a procedure.
|
||||
{
|
||||
// the following pastes each type of enhanced procedure, including its sections/steps
|
||||
EnhancedPasteItem(copyStartID, pasteFromItem, addType, chgid);
|
||||
// for each enhanced type for this procedure, adjust the config data for its sections/steps:
|
||||
ProcedureConfig sourceProcConfig = this.MyConfig as ProcedureConfig;
|
||||
foreach (EnhancedDocument enhProc in sourceProcConfig.MyEnhancedDocuments)
|
||||
{
|
||||
if (enhProc.Type != 0)
|
||||
{
|
||||
ItemInfo pastedEnhancedProc = ItemInfo.Get(enhProc.ItemID);
|
||||
// get the first enhanced section, there may be non-linked sections before first linked section:
|
||||
SectionConfig firstEnhSectionConfig = pastedEnhancedProc.Sections == null ? null : pastedEnhancedProc.Sections[0].MyConfig as SectionConfig;
|
||||
ItemInfo pastedEnhancedCurrentSection = null;
|
||||
if (firstEnhSectionConfig.MyEnhancedDocuments.Count > 0) pastedEnhancedCurrentSection = pastedEnhancedProc.Sections[0];
|
||||
else pastedEnhancedCurrentSection = GetNextEnhancedSection(pastedEnhancedProc.Sections[0]);
|
||||
|
||||
// newly pasted procedure has sections/steps, need to adjust 'MyEnhancedDocuments' config items to point to correct
|
||||
if (Sections != null)
|
||||
{
|
||||
foreach (ItemInfo sourceSect in Sections)
|
||||
{
|
||||
SectionConfig srcCfg = sourceSect.MyConfig as SectionConfig;
|
||||
if (srcCfg != null && (srcCfg.Section_LnkEnh=="Y" || srcCfg.Section_LnkEnh=="T") && srcCfg.MyEnhancedDocuments != null && srcCfg.MyEnhancedDocuments.Count > 0)
|
||||
{
|
||||
// use pastedEnhancedCurrentSection to link to:
|
||||
foreach (EnhancedDocument ed in srcCfg.MyEnhancedDocuments)
|
||||
{
|
||||
if (ed.Type == enhProc.Type)
|
||||
{
|
||||
ed.ItemID = pastedEnhancedCurrentSection.ItemID;
|
||||
srcCfg.SaveEnhancedDocuments();
|
||||
sourceSect.SaveConfig(srcCfg.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
SectionConfig enhSectCfg = pastedEnhancedCurrentSection.MyConfig as SectionConfig;
|
||||
enhSectCfg.MyEnhancedDocuments[0].ItemID = sourceSect.ItemID;
|
||||
enhSectCfg.SaveEnhancedDocuments();
|
||||
pastedEnhancedCurrentSection.SaveConfig(enhSectCfg.ToString());
|
||||
if (srcCfg.Section_LnkEnh == "Y") EnhancedSetStepLinks(sourceSect, enhProc.Type); //if steps, do them for this type
|
||||
pastedEnhancedCurrentSection = GetNextEnhancedSection(pastedEnhancedCurrentSection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
retItem = null;
|
||||
}
|
||||
else if (IsSection)
|
||||
{
|
||||
ItemInfo pastedSect = EnhancedPasteItem(copyStartID, pasteFromItem, addType, chgid);
|
||||
SectionConfig sourceSectConfig = this.MyConfig as SectionConfig;
|
||||
foreach (EnhancedDocument enhSect in sourceSectConfig.MyEnhancedDocuments)
|
||||
if (enhSect.Type != 0) EnhancedSetStepLinks(this, enhSect.Type);
|
||||
retItem = pastedSect;
|
||||
}
|
||||
else if (pasteFromItem.IsStep || (pasteFromItem.IsSection && addType == EAddpingPart.Child))
|
||||
{
|
||||
ItemInfo pastedStep = EnhancedPasteItem(copyStartID, pasteFromItem, addType, chgid);
|
||||
retItem = pastedStep;
|
||||
}
|
||||
return retItem;
|
||||
}
|
||||
private void SaveConfig(string cfg)
|
||||
{
|
||||
using (Content c1 = Content.Get(ContentID))
|
||||
{
|
||||
c1.Config = cfg;
|
||||
c1.Save();
|
||||
}
|
||||
RefreshConfig();
|
||||
}
|
||||
#endregion
|
||||
#region DataPortal
|
||||
|
Reference in New Issue
Block a user