Fixed issue with how sections with both sections and steps as children were being loaded

This commit is contained in:
Rich 2014-10-14 00:41:56 +00:00
parent 7a29281284
commit f994210ea6

View File

@ -329,17 +329,13 @@ namespace DataLoader
// addpart = false; // addpart = false;
//} //}
//FrType = 0; //FrType = 0;
Console.WriteLine("'before',{0},{1},{2},{3}", SectItm == null ? "" : SectItm.DisplayNumber, parentitem.DisplayNumber, level, dicSecCount.Count > 0 ? dicSecCount[level] : 0);
dicSecParentItem[level] = SectItm; dicSecParentItem[level] = SectItm;
int subSecs = drw["Sequence"].ToString().PadRight(12, ' ')[5] - 48;
if (level > 0) if (level > 0)
{ {
if ((dicSecCount[level]) == 1)
// shift up a level, i.e. give me the parent for the previous level
SectItm = dicSecParentItem[--level];
else
dicSecCount[level]--; // decrements number of sections to process dicSecCount[level]--; // decrements number of sections to process
} }
// get number of subsections for this section
int subSecs = drw["Sequence"].ToString().PadRight(12, ' ')[5] - 48;
if (subSecs > 0) if (subSecs > 0)
{ {
dicSecCount[++level] = subSecs; dicSecCount[++level] = subSecs;
@ -348,6 +344,20 @@ namespace DataLoader
addpart = true; addpart = true;
SectItm = null; // no previous sibling for the first child node. SectItm = null; // no previous sibling for the first child node.
} }
if (level > 0)
{
while (level > 0 && dicSecCount[level] == 0)
{
// shift up a level, i.e. give me the parent for the previous level
dicSecCount.Remove(level);
SectItm = dicSecParentItem[--level];
if (level > 0)
parentitem = dicSecParentItem[level - 1];
else
parentitem = itm;
}
}
Console.WriteLine("'after',{0},{1},{2},{3}", SectItm == null ? "" : SectItm.DisplayNumber, parentitem.DisplayNumber, level, dicSecCount.Count > 0 ? dicSecCount[level] : 0);
} }
dv.Dispose(); dv.Dispose();
//foreach (Item secItm in dicSecParentItem.Values) //foreach (Item secItm in dicSecParentItem.Values)