Enhanced: Code to refresh contents for item list that is unlinked; gets list of items that have text differences between enhanced/source and refresh text
Enhanced: Insert new procs & section for enhanced docs; Link 2 existing items, enhanced <->source
This commit is contained in:
@@ -852,6 +852,60 @@ namespace VEPROMS.CSLA.Library
|
||||
SaveConfig(sc.ToString());
|
||||
return newEnhancedItemInfo;
|
||||
}
|
||||
|
||||
// this method handles inserting new procedures & sections for enhanced documents.
|
||||
// It also handles the case of inserting a step within an EMPTY section. In this case, the template steps
|
||||
public ItemInfo InsertEnhancedItems(string text, string number, EAddpingPart addType, int? type, int eDocType, int newSourceID)
|
||||
{
|
||||
ItemInfo tmp = null;
|
||||
if (this.IsProcedure && addType == EAddpingPart.Child) // Created a section off a procedure
|
||||
{
|
||||
string scng = null;
|
||||
ProcedureConfig pc = new ProcedureConfig("<Config/>");
|
||||
pc.AddEnhancedDocument(0, newSourceID);
|
||||
scng = pc.ToString();
|
||||
tmp = InsertChild(E_FromType.Section, 10000, "New Section", null);
|
||||
tmp.SaveConfig(scng);
|
||||
}
|
||||
else if (this.IsSection && addType == EAddpingPart.Child) // Created a HLS off a section, note that the template gets added for the HLS
|
||||
{
|
||||
string scng = null;
|
||||
StepConfig sc = new StepConfig("<Config/>");
|
||||
sc.AddEnhancedDocument(0, newSourceID);
|
||||
scng = sc.ToString();
|
||||
tmp = InsertChild(E_FromType.Step, 20002, "New Step", null);
|
||||
tmp.SaveConfig(scng);
|
||||
}
|
||||
else // the following code is used for inserting before/after.
|
||||
{
|
||||
string scng = null;
|
||||
if (IsSection)
|
||||
{
|
||||
SectionConfig sc = new SectionConfig();
|
||||
sc.AddEnhancedDocument(0, newSourceID);
|
||||
scng = sc.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcedureConfig sc = new ProcedureConfig("<Config/>");
|
||||
sc.AddEnhancedDocument(0, newSourceID);
|
||||
scng = sc.ToString();
|
||||
}
|
||||
tmp = NewItemInfoFetch(ItemID, addType, number, text, type, null, null, scng, DateTime.Now, Volian.Base.Library.VlnSettings.UserID);
|
||||
}
|
||||
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);
|
||||
RefreshNextItems();
|
||||
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;
|
||||
}
|
||||
public ItemInfo InsertEnhancedSteps(string text, string number, EAddpingPart addType, int? type, int eDocType, int newSourceID)
|
||||
{
|
||||
ItemInfo tmp = null;
|
||||
@@ -1452,11 +1506,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
RefreshConfig();
|
||||
}
|
||||
public ItemInfo DoAddMissingEnhancedSteps(int enhtype)
|
||||
public ItemInfo DoAddMissingEnhancedItems(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
|
||||
// from this item, need to find an insertion point in the enhanced procedure/section. Look for an item that has enhanced
|
||||
// links in its config: first go through previous items, 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;
|
||||
@@ -1468,14 +1522,17 @@ namespace VEPROMS.CSLA.Library
|
||||
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);
|
||||
if (exEnh.IsStep)
|
||||
newEnh = exEnh.InsertEnhancedSteps(MyContent.Text, null, addtype, MyContent.Type, edSource.Type, this.ItemID);
|
||||
else
|
||||
newEnh = exEnh.InsertEnhancedItems(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();
|
||||
ItemInfo iiNxt = this.NextItem;
|
||||
addtype = EAddpingPart.Before;
|
||||
while (iiNxt != null && newEnh == null)
|
||||
{
|
||||
@@ -1484,35 +1541,162 @@ namespace VEPROMS.CSLA.Library
|
||||
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);
|
||||
if (exEnh.IsStep)
|
||||
newEnh = exEnh.InsertEnhancedSteps(MyContent.Text, null, addtype, MyContent.Type, edSource.Type, this.ItemID);
|
||||
else
|
||||
newEnh = exEnh.InsertEnhancedItems(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)
|
||||
if (this.IsProcedure && newEnh == null) // procedure is a special case since it has to be added from the doc version:
|
||||
{
|
||||
foreach (EnhancedDocument edSource in iiPar.GetMyEnhancedDocuments())
|
||||
// need to make a new procedure off working draft of enhanced set:
|
||||
DocVersionConfig dvc = this.MyDocVersion.MyConfig as DocVersionConfig;
|
||||
ProcedureInfo pi = ProcedureInfo.Get(this.ItemID);
|
||||
ProcedureConfig sourcecfg = pi.ProcedureConfig;
|
||||
if (dvc != null)
|
||||
{
|
||||
if (edSource.Type == enhtype) // found one to use:
|
||||
foreach (DVEnhancedDocument ded in dvc.MyEnhancedDocuments)
|
||||
{
|
||||
ItemInfo exEnh = ItemInfo.Get(edSource.ItemID);
|
||||
newEnh = exEnh.InsertEnhancedSteps(MyContent.Text, null, addtype, MyContent.Type, edSource.Type, this.ItemID);
|
||||
if (ded.Type == enhtype)
|
||||
{
|
||||
// get the enhaced docversioninfo:
|
||||
DocVersionInfo enhDVInfo = DocVersionInfo.Get(ded.VersionID);
|
||||
using (Procedure newenhProcedure = Procedure.MakeProcedure(enhDVInfo, enhDVInfo.Procedures.Count != 0 ? enhDVInfo.Procedures[enhDVInfo.Procedures.Count - 1] : null, null, "New Procedure", 0))
|
||||
{
|
||||
newEnh = ItemInfo.Get(newenhProcedure.ItemID);
|
||||
string scng = null;
|
||||
ProcedureConfig sc = new ProcedureConfig("<Config/>");
|
||||
sc.AddEnhancedDocument(0, pi.ItemID);
|
||||
scng = sc.ToString();
|
||||
newEnh.SaveConfig(scng);
|
||||
enhDVInfo.ResetProcedures();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
iiPar = iiPar.MyParent;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemInfo iiPar = this.MyParent;
|
||||
addtype = EAddpingPart.Child;
|
||||
while (iiPar != null && newEnh == null)
|
||||
{
|
||||
foreach (EnhancedDocument edSource in iiPar.GetMyEnhancedDocuments())
|
||||
{
|
||||
if (edSource.Type == enhtype) // found one to use:
|
||||
{
|
||||
ItemInfo exEnh = ItemInfo.Get(edSource.ItemID);
|
||||
if (exEnh.IsStep)
|
||||
newEnh = exEnh.InsertEnhancedSteps(MyContent.Text, null, addtype, MyContent.Type, edSource.Type, this.ItemID);
|
||||
else
|
||||
newEnh = exEnh.InsertEnhancedItems(MyContent.Text, null, addtype, MyContent.Type, edSource.Type, this.ItemID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
iiPar = iiPar.MyParent;
|
||||
}
|
||||
}
|
||||
// Now set the config in the source to link to the newly created enhanced item:
|
||||
if (newEnh != null)
|
||||
{
|
||||
StepConfig sc = new StepConfig(MyContent.Config);
|
||||
sc.AddEnhancedDocument(enhtype, newEnh.ItemID);
|
||||
SaveConfig(sc.ToString());
|
||||
if (IsStep)
|
||||
{
|
||||
StepConfig sc = new StepConfig(MyContent.Config);
|
||||
sc.AddEnhancedDocument(enhtype, newEnh.ItemID);
|
||||
SaveConfig(sc.ToString());
|
||||
}
|
||||
else if (IsSection)
|
||||
{
|
||||
SectionConfig sc = new SectionConfig(SectionInfo.Get(this.ItemID));
|
||||
sc.AddEnhancedDocument(enhtype, newEnh.ItemID);
|
||||
sc.Section_LnkEnh = "Y";
|
||||
SaveConfig(sc.ToString());
|
||||
}
|
||||
else if (IsProcedure)
|
||||
{
|
||||
ProcedureConfig sc = new ProcedureConfig(MyContent.Config);
|
||||
sc.AddEnhancedDocument(enhtype, newEnh.ItemID);
|
||||
SaveConfig(sc.ToString());
|
||||
}
|
||||
}
|
||||
return newEnh;
|
||||
}
|
||||
public void DoCreateLinksEnhancedSteps(ItemInfo enhii, int enhtype)
|
||||
{
|
||||
// Link the 2 items, srcII & enhii:
|
||||
if (IsStep)
|
||||
{
|
||||
using (Item ii = this.Get())
|
||||
{
|
||||
StepConfig sc = this.MyConfig as StepConfig;
|
||||
sc.AddEnhancedDocument(enhtype, enhii.ItemID);
|
||||
sc.SaveEnhancedDocuments();
|
||||
ii.MyContent.Config = sc.ToString();
|
||||
ii.Save();
|
||||
RefreshConfig();
|
||||
}
|
||||
using (Item ei = Item.Get(enhii.ItemID))
|
||||
{
|
||||
StepConfig sc = enhii.MyConfig as StepConfig;
|
||||
sc.AddEnhancedDocument(0, this.ItemID);
|
||||
sc.SaveEnhancedDocuments();
|
||||
ei.MyContent.Text = DisplayText;
|
||||
ei.MyContent.Config = sc.ToString();
|
||||
ei.Save();
|
||||
enhii.RefreshConfig();
|
||||
}
|
||||
}
|
||||
else if (IsSection)
|
||||
{
|
||||
using (Item ii = this.Get())
|
||||
{
|
||||
SectionConfig sc = this.MyConfig as SectionConfig;
|
||||
sc.AddEnhancedDocument(enhtype, enhii.ItemID);
|
||||
sc.SaveEnhancedDocuments();
|
||||
sc.Section_LnkEnh = "Y";
|
||||
ii.MyContent.Config = sc.ToString();
|
||||
ii.Save();
|
||||
RefreshConfig();
|
||||
}
|
||||
using (Item ei = Item.Get(enhii.ItemID))
|
||||
{
|
||||
SectionConfig sc = enhii.MyConfig as SectionConfig;
|
||||
sc.AddEnhancedDocument(0, this.ItemID);
|
||||
sc.SaveEnhancedDocuments();
|
||||
ei.MyContent.Text = DisplayText;
|
||||
ei.MyContent.Config = sc.ToString();
|
||||
ei.Save();
|
||||
enhii.RefreshConfig();
|
||||
}
|
||||
}
|
||||
else if (IsProcedure)
|
||||
{
|
||||
using (Item ii = this.Get())
|
||||
{
|
||||
ProcedureConfig sc = this.MyConfig as ProcedureConfig;
|
||||
sc.AddEnhancedDocument(enhtype, enhii.ItemID);
|
||||
sc.SaveEnhancedDocuments();
|
||||
ii.MyContent.Config = sc.ToString();
|
||||
ii.Save();
|
||||
RefreshConfig();
|
||||
}
|
||||
using (Item ei = Item.Get(enhii.ItemID))
|
||||
{
|
||||
ProcedureConfig sc = enhii.MyConfig as ProcedureConfig;
|
||||
sc.AddEnhancedDocument(0, this.ItemID);
|
||||
sc.SaveEnhancedDocuments();
|
||||
ei.MyContent.Text = DisplayText;
|
||||
ei.MyContent.Config = sc.ToString();
|
||||
ei.Save();
|
||||
enhii.RefreshConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region DataPortal
|
||||
private void DataPortal_Fetch(PastingPartCriteria criteria)
|
||||
|
Reference in New Issue
Block a user