Ejemplo n.º 1
0
        /// <summary>
        /// 确认亲子关系;
        /// </summary>
        /// <param name="NodeList"></param>
        /// <returns></returns>
        public static List <ObjNode> ArrangeParentage(List <ObjNode> NodeList)
        {
            List <ObjNode> RootNodeShow = new List <ObjNode>();
            ObjNode        Root         = new ObjTreeNode(0, 0, "1.0", "基站节点列表", @"/");

            // 遍历所有节点确认亲子关系;
            foreach (ObjNode iter in NodeList)
            {
                if (iter.ObjParentID == 0)
                {
                    Root.Add(iter);
                }
                else
                {
                    foreach (ObjNode iterParent in NodeList)
                    {
                        if (iterParent.ObjID == iter.ObjParentID)
                        {
                            iterParent.Add(iter);
                        }
                    }
                }
            }

            RootNodeShow.Add(Root);

            return(RootNodeShow);
        }
Ejemplo n.º 2
0
        private void Collect_Node_Click(object sender, EventArgs e)
        {
            ObjNode        Objnode;
            List <ObjNode> m_NodeList   = new List <ObjNode>();
            List <ObjNode> RootNodeShow = new List <ObjNode>();
            ObjNode        Root         = new ObjTreeNode(0, 0, "1.0", "收藏节点", @"/");
            NodeB          node         = new NodeB("172.27.245.92", "NodeB");
            string         cfgFile      = node.m_ObjTreeDataPath;
            StreamReader   reader       = File.OpenText(cfgFile);
            JObject        JObj         = new JObject();

            JObj = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
            IEnumerable <int> AllNodes = from nodes in JObj.First.Next.First
                                         select(int) nodes["ObjID"];

            int TempCount = 0;

            foreach (var iter in AllNodes)
            {
                var ObjParentNodes = (int)JObj.First.Next.First[TempCount]["ObjParentID"];
                var name           = (string)JObj.First.Next.First[TempCount]["ObjName"];
                var TableName      = (string)JObj.First.Next.First[TempCount]["MibTableName"];
                var version        = (string)JObj.First.First;
                if (JObj.First.Next.First[TempCount]["ObjCollect"] == null)
                {
                    TempCount++;
                    continue;
                }
                int ObjCollect = (int)JObj.First.Next.First[TempCount]["ObjCollect"];


                Objnode = new ObjTreeNode(iter, ObjParentNodes, version, name, TableName);
                if (ObjCollect == 1)
                {
                    int index = m_NodeList.IndexOf(Objnode);
                    if (index < 0)
                    {
                        m_NodeList.Add(Objnode);
                    }
                }

                TempCount++;
            }
            reader.Close();
            ObjNodeControl Ctrl = new ObjNodeControl(node);

            // 遍历所有节点确认亲子关系;
            foreach (ObjNode iter in m_NodeList)
            {
                //Root.Add(iter);
                if (Root.SubObj_Lsit != null)
                {
                    bIsRepeat = false;
                    IsRepeatNode(iter, Root.SubObj_Lsit);
                    if (bIsRepeat)
                    {
                        continue;
                    }
                }

                // 遍历所有节点确认亲子关系;
                foreach (ObjNode iter1 in Ctrl.m_NodeList)
                {
                    if (iter1.ObjID == iter.ObjID)
                    {
                        Root.Add(iter1);
                    }
                    else if (iter1.ObjID > iter.ObjID)
                    {
                        foreach (ObjNode iterParent in Ctrl.m_NodeList)
                        {
                            if (iterParent.ObjID == iter1.ObjParentID)
                            {
                                iterParent.Add(iter1);
                            }
                        }
                    }
                }
            }
            RootNodeShow.Add(Root);

            // 将右侧叶节点容器容器加入到对象树子容器中;
            this.Obj_Collect.Clear();
            this.Obj_Collect.SubExpender = this.FavLeaf_Lists;

            foreach (ObjNode items in RootNodeShow)
            {
                items.TraverseCollectChildren(this.Obj_Collect, this.FavLeaf_Lists, 0);
            }
        }