Use template for inserting steps for Callaway Backgrounds

CALBCK format flag
This commit is contained in:
Kathy Ruffing 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);

View File

@ -194,6 +194,33 @@ namespace VEPROMS.CSLA.Library
return LazyLoad(ref _TPL, "@TPL");
}
}
private bool _NewTemplateFormat;
public bool NewTemplateFormat
{
get { return _NewTemplateFormat; }
set { _NewTemplateFormat = value; }
}
private Dictionary<int, int> _TopTemplateTypes;
public Dictionary<int, int> TopTemplateTypes
{
get
{
if (_TopTemplateTypes == null)
{
_TopTemplateTypes = new Dictionary<int, int>();
// loop through all of templates to find those that are top level, i.e.
// right below the '0'.
int indx = 0;
while (indx < Templates.Count)
{
// level of 0 starts a new group.
if (Templates[indx].level == 0) TopTemplateTypes[Templates[indx + 1].type] = indx+1;
indx++;
}
}
return _TopTemplateTypes;
}
}
private List<TPlate> _Templates;
public List<TPlate> Templates
{
@ -201,7 +228,7 @@ namespace VEPROMS.CSLA.Library
{
if (_Templates == null) // Load template class from format's string data.
{
bool oldformat = true;
NewTemplateFormat = false;
// count newlines - which gives number of template records.
int NumTemplates = 0;
int indx = TPL.IndexOf('\n');
@ -214,7 +241,7 @@ namespace VEPROMS.CSLA.Library
_Templates = new List<TPlate>(NumTemplates);
// for each item, create and add to list
if (TPL.IndexOf(',') > -1) oldformat = false;
if (TPL.IndexOf(',') > -1) NewTemplateFormat = true;
int cnt = 0;
int tmpStrIndxStart = 0;
@ -231,7 +258,7 @@ namespace VEPROMS.CSLA.Library
int nocol = 0;
int row = 0;
string stmp = null;
if (oldformat)
if (!NewTemplateFormat)
{
string[] tmpOld = tpl.Split(" ".ToCharArray());
level = Convert.ToInt32(tmpOld[0]);
@ -3669,6 +3696,14 @@ namespace VEPROMS.CSLA.Library
return LazyLoad(ref _UseSmartTemplate, "@UseSmartTemplate");
}
}
private LazyLoad<bool> _UseOldTemplate;
public bool UseOldTemplate
{
get
{
return LazyLoad(ref _UseOldTemplate, "@UseOldTemplate");
}
}
private LazyLoad<bool> _AlwaysUseExtraLines;
public bool AlwaysUseExtraLines
{