B2022-098: ROs not being resolved in Word Sections

This commit is contained in:
Jake
2022-08-16 15:02:30 +00:00
parent 9bdaebadfc
commit ac8e8432b7
10 changed files with 913 additions and 302 deletions

View File

@@ -11,6 +11,7 @@ using DevComponents.AdvTree;
using Volian.Base.Library;
using System.Text.RegularExpressions;
using JR.Utils.GUI.Forms;
using System.Linq;
namespace Volian.Controls.Library
{
@@ -1346,25 +1347,15 @@ namespace Volian.Controls.Library
{
for (int i = 0; i < dbs.Length; i++)
{
DevComponents.AdvTree.Node tn = new DevComponents.AdvTree.Node();
ROFSTLookup.rodbi db = dbs[i];
tn.Text = db.dbiTitle;
DevComponents.AdvTree.Node tn = new DevComponents.AdvTree.Node(db.dbiTitle);
tn.Tag = db;
cmboTreeROs.Nodes.Add(tn);
AddDummyGroup(db, tn);
}
}
//for (int i = 0; i < _MyROFSTLookup.myHdr.myDbs.Length; i++)
//{
// DevComponents.AdvTree.Node tn = new DevComponents.AdvTree.Node();
// tn.Text = _MyROFSTLookup.myHdr.myDbs[i].dbiTitle;
// tn.Tag = _MyROFSTLookup.myHdr.myDbs[i];
// cmboTreeROs.Nodes.Add(tn);
// AddDummyGroup(_MyROFSTLookup.myHdr.myDbs[i], tn);
//}
}
}
}
@@ -1395,10 +1386,9 @@ namespace Volian.Controls.Library
private void AddDummyGroup(ROFSTLookup.rodbi rodbi, DevComponents.AdvTree.Node tn)
{
if (rodbi.children != null && rodbi.children.Length > 0)
if (MyROFSTLookup.HasChildren(ref rodbi))
{
DevComponents.AdvTree.Node tmp = new DevComponents.AdvTree.Node();
tmp.Text = DummyNodeText;
DevComponents.AdvTree.Node tmp = new DevComponents.AdvTree.Node(DummyNodeText);
tn.Nodes.Add(tmp);
}
}
@@ -1410,29 +1400,21 @@ namespace Volian.Controls.Library
private void LoadChildren(DevComponents.AdvTree.Node tn)
{
object tag = tn.Tag;
if (tn.HasChildNodes && tn.Nodes[0].Text != DummyNodeText) return; // already loaded.
if (tn.HasChildNodes && tn.Nodes[0].Text == DummyNodeText) tn.Nodes[0].Remove();
ROFSTLookup.rochild[] chld = null;
if (tn.Tag is ROFSTLookup.rodbi)
{
ROFSTLookup.rodbi db = (ROFSTLookup.rodbi)tn.Tag;
// Try to Lazy Load children - B2022-026 RO Memory Reduction code
if (db.children == null || db.children.Length <= 0)
db.children = MyROFSTLookup.GetRoChildrenByID(db.ID, db.dbiID, true);
MyROFSTLookup.LoadChildren(ref db);
chld = db.children;
}
else if (tn.Tag is ROFSTLookup.rochild)
{
ROFSTLookup.rochild ch = (ROFSTLookup.rochild)tn.Tag;
// Try to Lazy Load children - B2022-026 RO Memory Reduction code
if (ch.children == null || ch.children.Length <= 0)
ch.children = MyROFSTLookup.GetRoChildrenByRoid(ch.roid, true);
MyROFSTLookup.LoadChildren(ref ch);
chld = ch.children;
}
else
@@ -1440,6 +1422,7 @@ namespace Volian.Controls.Library
Console.WriteLine("error - no type");
return;
}
// if children, add dummy node
// B2022-026 RO Memory Reduction code - need to check length
if (chld != null && chld.Length > 0)
@@ -1451,43 +1434,54 @@ namespace Volian.Controls.Library
ProgressBar_SetValue(i);
DevComponents.AdvTree.Node tmp = null;
// Try to Lazy Load children - B2022-026 RO Memory Reduction code
if (chld[i].children == null || chld[i].children.Length <= 0)
chld[i].children = MyROFSTLookup.GetRoChildrenByRoid(chld[i].roid, true);
ROFSTLookup.rochild roc = chld[i];
// if this is a group, i.e. type 0, add a dummy node
// B2022-026 RO Memory Reduction code - check children length
if (chld[i].type == 0 && (chld[i].children == null || chld[i].children.Length <= 0))
if (roc.type == 0 && !MyROFSTLookup.HasChildren(ref roc))
{
//skip it.
// TODO: KBR how to handle this?
//Console.WriteLine("ro junk");
continue;
continue; // Ignore: Junk Scenario
}
else if (chld[i].value == null)
else if (!string.IsNullOrEmpty(roc.appid))
{
tmp = new DevComponents.AdvTree.Node();
MyROFSTLookup.LoadChildren(ref roc);
if (roc.children.Length == 1 && roc.children.First().roid.Length == 16)
{
roc.appid = roc.children.First().appid;
roc.roid = roc.children.First().roid;
roc.value = roc.children.First().value;
roc.children = new List<ROFSTLookup.rochild>().ToArray();
}
}
if (roc.value == null)
{
tmp = new DevComponents.AdvTree.Node(roc.title);
tmp.Tag = roc;
tmp.Text = chld[i].title;
tmp.Tag = chld[i];
int index = FindIndex(tn.Nodes, tmp.Text);
tn.Nodes.Insert(index, tmp);
//tn.Nodes.Add(tmp);
DevComponents.AdvTree.Node sub = new DevComponents.AdvTree.Node();
sub.Text = DummyNodeText;
DevComponents.AdvTree.Node sub = new DevComponents.AdvTree.Node(DummyNodeText);
tmp.Nodes.Add(sub);
}
else
{
tmp = new DevComponents.AdvTree.Node();
tmp = new DevComponents.AdvTree.Node(roc.title);
tmp.Tag = roc;
tmp.Text = chld[i].title;
tmp.Tag = chld[i];
int index = FindIndex(tn.Nodes, tmp.Text);
tn.Nodes.Insert(index, tmp);
//tn.Nodes.Add(tmp);
if (roc.roid.Length == 16)
{
tn.Nodes.Add(tmp);
}
else
{
int index = FindIndex(tn.Nodes, tmp.Text);
tn.Nodes.Insert(index, tmp);
}
}
}
}