B2015-071: Fixed handling of sublevels in templates (for EXEBCK)

B2015-071: EXEBCK template had spaces in template text, fixed parsing of this
This commit is contained in:
2015-06-22 14:41:55 +00:00
parent 3c489b709e
commit 7bc11c7fb6
2 changed files with 29 additions and 10 deletions

View File

@@ -367,8 +367,9 @@ namespace VEPROMS.CSLA.Library
int tpIndx = GetSmartTemplateIndex(topType, (int)MyContent.Type); int tpIndx = GetSmartTemplateIndex(topType, (int)MyContent.Type);
if (tpIndx != -1) if (tpIndx != -1)
{ {
ItemInfo siblingSmart = null; ItemInfo siblingSmart = null; // keep track of sibling
ItemInfo firstSmart = null; ItemInfo firstSmart = null; // hls or top template step
ItemInfo parentSmart = null; // keep track of parent as creating children
int level = ActiveFormat.PlantFormat.FormatData.Templates[tpIndx].level; int level = ActiveFormat.PlantFormat.FormatData.Templates[tpIndx].level;
string tmptext = ActiveFormat.PlantFormat.FormatData.NewTemplateFormat ? text : ActiveFormat.PlantFormat.FormatData.Templates[tpIndx].text; string tmptext = ActiveFormat.PlantFormat.FormatData.NewTemplateFormat ? text : ActiveFormat.PlantFormat.FormatData.Templates[tpIndx].text;
int prevlevel = level; int prevlevel = level;
@@ -377,32 +378,35 @@ namespace VEPROMS.CSLA.Library
if (firstSmart == null) if (firstSmart == null)
{ {
firstSmart = NewItemInfoFetch(ItemID, adPart, number, tmptext, type, null, null, null, DateTime.Now, Volian.Base.Library.VlnSettings.UserID); firstSmart = NewItemInfoFetch(ItemID, adPart, number, tmptext, type, null, null, null, DateTime.Now, Volian.Base.Library.VlnSettings.UserID);
siblingSmart = firstSmart; siblingSmart = parentSmart = firstSmart;
newItemID = firstSmart.ItemID; newItemID = firstSmart.ItemID;
} }
else else
{ {
E_FromType fromType = E_FromType.Step; E_FromType fromType = E_FromType.Step;
EAddpingPart addPart = EAddpingPart.Child; // level > previous, add a child. EAddpingPart addPart = EAddpingPart.Child; // level > previous, add a child.
if (level == prevlevel) addPart = EAddpingPart.After; if (level == prevlevel) addPart = EAddpingPart.After; // level = previous, add a sibling
if (level < prevlevel) if (level < prevlevel) // level < previous, go up to previous level's id
{ {
if (ActiveFormat.PlantFormat.FormatData.Templates[tpIndx].type == 39) if (ActiveFormat.PlantFormat.FormatData.Templates[tpIndx].type == 39)
{ {
fromType = E_FromType.RNO; fromType = E_FromType.RNO;
addPart = EAddpingPart.Child; addPart = EAddpingPart.Child;
newItemID = firstSmart.ItemID;
} }
else else
{ {
addPart = EAddpingPart.After; addPart = EAddpingPart.After;
newItemID = parentSmart.ItemID;
} }
newItemID = siblingSmart.ItemID;
} }
tmptext = /*ActiveFormat.PlantFormat.FormatData.NewTemplateFormat ? " ": */ActiveFormat.PlantFormat.FormatData.Templates[tpIndx].text; tmptext = ActiveFormat.PlantFormat.FormatData.Templates[tpIndx].text;
tmp = NewItemInfoFetch(newItemID, addPart, null, tmptext, ActiveFormat.PlantFormat.FormatData.Templates[tpIndx].type + 20001, (int?)fromType, null, null, DateTime.Now, Volian.Base.Library.VlnSettings.UserID); tmp = NewItemInfoFetch(newItemID, addPart, null, tmptext, ActiveFormat.PlantFormat.FormatData.Templates[tpIndx].type + 20001, (int?)fromType, null, null, DateTime.Now, Volian.Base.Library.VlnSettings.UserID);
newItemID = tmp.ItemID; newItemID = tmp.ItemID;
if (level < prevlevel) siblingSmart = tmp; if (level < prevlevel) siblingSmart = parentSmart;
else if (level > prevlevel) parentSmart = siblingSmart;
if (level == prevlevel) siblingSmart = tmp;
} }
tpIndx++; tpIndx++;
prevlevel = level; prevlevel = level;

View File

@@ -288,7 +288,22 @@ namespace VEPROMS.CSLA.Library
string[] tmpOld = tpl.Split(" ".ToCharArray()); string[] tmpOld = tpl.Split(" ".ToCharArray());
level = Convert.ToInt32(tmpOld[0]); level = Convert.ToInt32(tmpOld[0]);
type = Convert.ToInt32(tmpOld[1]); type = Convert.ToInt32(tmpOld[1]);
stmp = tmpOld.Length <= 2 ? null : tmpOld[2]; if (tmpOld.Length <= 2)
stmp = null;
else if (tmpOld.Length > 3)
{
// Braidwood has spaces as part of the text in the 3rd field, i.e. (See Deviation Document)
// handle this special case
int indxx = tpl.IndexOf(" ");
if (indxx < 0) stmp = null;
else
{
indxx = tpl.IndexOf(" ", indxx+1);
stmp = (indxx > -1) ? tpl.Substring(indxx) : null;
}
}
else
stmp = tmpOld[2];
} }
else else
{ {