diff --git a/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Deployment/DebugTreeBuilder.cs b/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Deployment/DebugTreeBuilder.cs index d8bc15ae..6448e1a3 100644 --- a/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Deployment/DebugTreeBuilder.cs +++ b/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Deployment/DebugTreeBuilder.cs @@ -49,33 +49,13 @@ public static class DebugTreeBuilder } var segments = attr.AttributeName.Split(Separator); - - // Walk/create branch nodes for every segment except the last; the last - // segment becomes the leaf carrying the attribute event. - List currentLevel = roots; - string prefix = string.Empty; - - for (var i = 0; i < segments.Length - 1; i++) - { - prefix = prefix.Length == 0 ? segments[i] : prefix + Separator + segments[i]; - - if (!branchByKey.TryGetValue(prefix, out var branch)) - { - branch = new DebugTreeNode { Key = prefix, Segment = segments[i] }; - branchByKey[prefix] = branch; - currentLevel.Add(branch); - } - - currentLevel = branch.Children; - } - - var leaf = new DebugTreeNode + var parent = WalkBranches(segments, segments.Length - 1, roots, branchByKey); + parent.Add(new DebugTreeNode { Key = attr.AttributeName, Segment = segments[^1], Attribute = attr, - }; - currentLevel.Add(leaf); + }); } SortAndRollUp(roots); @@ -175,6 +155,8 @@ public static class DebugTreeBuilder List roots, Dictionary branchByKey) { + if (string.IsNullOrEmpty(alarm.NativeSourceCanonicalName)) return; + var canonical = alarm.NativeSourceCanonicalName; var segments = canonical.Split(Separator);