Use template for inserting steps for Callaway Backgrounds

CALBCK format flag
This commit is contained in:
2013-10-02 10:41:04 +00:00
parent 4b7c3ee5d8
commit 062cf39e53
2 changed files with 73 additions and 18 deletions

View File

@@ -284,7 +284,7 @@ namespace VEPROMS.CSLA.Library
public ItemInfo InsertSiblingBefore(string text, string number)
{
ItemInfo tmp = null;
if (!IsSection && (FormatStepData.UseSmartTemplate || MyHLS.FormatStepData.UseSmartTemplate))
if (!IsSection && (FormatStepData.UseSmartTemplate || MyHLS.FormatStepData.UseSmartTemplate || FormatStepData.UseOldTemplate))
tmp = InsertSmartTemplateSteps(text, number, tmp, EAddpingPart.Before, (int)MyContent.Type);
else
tmp = NewItemInfoFetch(ItemID, EAddpingPart.Before, number, text, null, null, null, null, DateTime.Now, Volian.Base.Library.VlnSettings.UserID);
@@ -302,34 +302,54 @@ namespace VEPROMS.CSLA.Library
private ItemInfo InsertSmartTemplateSteps(string text, string number, ItemInfo tmp, EAddpingPart adPart, int type)
{
int newItemID = 0;
// this step type may be a template step, if so, we need to put out edit windows for
// the template, by making these 'empty' (one space) steps:
int tpIndx = GetSmartTemplateIndex();
int topType = GetSmartTemplateTopLevelIndx();
if (topType == -1) return null;
int tpIndx = GetSmartTemplateIndex(topType, (int)MyContent.Type);
if (tpIndx != -1)
{
bool firstInsert = true;
ItemInfo tmpSmart = null;
ItemInfo subSmart = null;
ItemInfo siblingSmart = null;
ItemInfo firstSmart = null;
int level = FormatStepData.MyFormat.PlantFormat.FormatData.Templates[tpIndx].level;
string tmptext = FormatStepData.MyFormat.PlantFormat.FormatData.NewTemplateFormat?text:FormatStepData.MyFormat.PlantFormat.FormatData.Templates[tpIndx].text;
int prevlevel = level;
while (level > 0)
{
if (firstInsert)
if (firstSmart == null)
{
subSmart = NewItemInfoFetch(ItemID, adPart, number, text, type, null, null, null, DateTime.Now, Volian.Base.Library.VlnSettings.UserID);
tmpSmart = subSmart;
firstInsert = false;
newItemID = subSmart.ItemID;
firstSmart = NewItemInfoFetch(ItemID, adPart, number, tmptext, type, null, null, null, DateTime.Now, Volian.Base.Library.VlnSettings.UserID);
siblingSmart = firstSmart;
newItemID = firstSmart.ItemID;
}
else
{
tmp = NewItemInfoFetch(newItemID, EAddpingPart.Child, null, " ", FormatStepData.MyFormat.PlantFormat.FormatData.Templates[tpIndx].type + 20001, (int?)E_FromType.Step, null, null, DateTime.Now, Volian.Base.Library.VlnSettings.UserID);
E_FromType fromType = E_FromType.Step;
EAddpingPart addPart = EAddpingPart.Child; // level > previous, add a child.
if (level == prevlevel) addPart = EAddpingPart.After;
if (level < prevlevel)
{
if (FormatStepData.MyFormat.PlantFormat.FormatData.Templates[tpIndx].type == 39)
{
fromType = E_FromType.RNO;
addPart = EAddpingPart.Child;
}
else
{
addPart = EAddpingPart.After;
}
newItemID = siblingSmart.ItemID;
}
tmptext = FormatStepData.MyFormat.PlantFormat.FormatData.NewTemplateFormat ? " ": FormatStepData.MyFormat.PlantFormat.FormatData.Templates[tpIndx].text;
tmp = NewItemInfoFetch(newItemID, addPart, null, tmptext, FormatStepData.MyFormat.PlantFormat.FormatData.Templates[tpIndx].type + 20001, (int ?)fromType, null, null, DateTime.Now, Volian.Base.Library.VlnSettings.UserID);
newItemID = tmp.ItemID;
if (level < prevlevel) siblingSmart = tmp;
}
tpIndx++;
prevlevel = level;
level = tpIndx < FormatStepData.MyFormat.PlantFormat.FormatData.Templates.Count ?
FormatStepData.MyFormat.PlantFormat.FormatData.Templates[tpIndx].level : -1;
}
tmp = tmpSmart;
tmp = firstSmart;
}
return tmp;
}
@@ -427,7 +447,7 @@ namespace VEPROMS.CSLA.Library
public ItemInfo InsertSiblingAfter(string text, string number, int? type)
{
ItemInfo tmp = null;
if (!IsSection &&(FormatStepData.UseSmartTemplate || MyHLS.FormatStepData.UseSmartTemplate))
if (!IsSection && (FormatStepData.UseSmartTemplate || MyHLS.FormatStepData.UseSmartTemplate || FormatStepData.UseOldTemplate))
tmp = InsertSmartTemplateSteps(text, number, tmp, EAddpingPart.After, (int)MyContent.Type);
else
tmp = NewItemInfoFetch(ItemID, EAddpingPart.After, number, text, type, null, null, null, DateTime.Now, Volian.Base.Library.VlnSettings.UserID);