// Get the Root Assemblies public List <TabItem> GetRootAssemblies(bool isPart = true) { var items = new List <TabItem>(); var RootConfigs = (from c in dataContext.Configurations where c.IsRoot.HasValue && c.IsRoot.Value && !string.IsNullOrEmpty(c.ConfigurationName) orderby c.Id descending select c).ToList(); foreach (var rootConfig in RootConfigs) { //if(rootConfig.Id == 1) //{ var rootNode = ConvertEntities.GetNodeFromEntity(rootConfig, null, isPart); rootNode.Level = 1; List <Node> display = new List <Node>(); LoadData(display, rootNode); var tabitem = new TabItem() { Header = rootConfig.ConfigurationName, Id = rootConfig.Id.Value, Content = LoadData(rootNode, isPart), }; items.Add(tabitem); // } } return(items); }
private void LoadData(List <Node> children, Node parent, bool isPart = true) { if (children == null) { return; } if (parent == null) { return; } var boms = (from b in dataContext.Boms where b.ParentConfigIndex == parent.Id select b).ToList(); if (boms == null || boms.Count == 0) { children.Add(parent); } foreach (var bom in boms) { var config = (from c in dataContext.Configurations where (!c.IsRoot.HasValue || !c.IsRoot.Value) && c.Id == bom.ChildConfigIndex select c).FirstOrDefault(); if (config != null) { var node = ConvertEntities.GetNodeFromEntity(config, bom, isPart); if (node != null) { node.Level = parent.Level + 1; node.ParentNode = parent; LoadData(children, node); children.Add(node); } } } }