예제 #1
0
        /// <summary>
        /// 找到当前结点的下一级孩子节点
        /// </summary>
        /// <param name="list"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public List <NetMapInfo> GetChilds(List <NetMapModel> list, Guid parentid)
        {
            List <NetMapInfo> rtnList = new List <NetMapInfo>();

            var childs =
                from item in list
                where item.parentguid == parentid
                orderby item.sort_order
                select item;

            if (childs == null)
            {
                return(null);
            }

            NetMapInfo tep = null;

            foreach (NetMapModel item in childs)
            {
                tep        = new NetMapInfo();
                tep.guid   = item.node_guid;
                tep.name   = string.Concat(item.name, item.station_name, string.IsNullOrEmpty(item.auditor) ? "" : ":" + item.auditor);
                tep.value  = item.auditor;
                tep.prefix = item.station_name;

                tep.children = GetChilds(list, tep.guid);

                rtnList.Add(tep);
            }


            return(rtnList);
        }
예제 #2
0
        public string GenerateTree4Dom()
        {
            List <NetMapModel> allList = DoQuery("1=1 ORDER BY parentguid,sort_order");
            var rootNode =
                (from item in allList
                 where item.parentguid == Guid.Empty
                 select item).FirstOrDefault <NetMapModel>();

            NetMapInfo    tree_data = new NetMapInfo();
            string        ul_tpl_r  = "</ul>";
            string        li_tpl_l  = "<li class='node_hierarchy_@name'>";
            string        li_tpl_r  = "</li>";
            StringBuilder strDom    = new StringBuilder("<ul  id='org' style='display: none'>");

            // strDom = strDom.Replace("@content",li_tpl.Replace("@name", string.Concat(rootNode.name, rootNode.station_name, string.IsNullOrEmpty(rootNode.auditor) ? "" : ":" + rootNode.auditor)));
            //合并左半部分加上文本
            strDom = strDom.Append(li_tpl_l.Replace("@name", "0")).Append(string.Concat(rootNode.name, rootNode.station_name, string.IsNullOrEmpty(rootNode.auditor) ? "" : ":" + rootNode.auditor));
            //合并孩子节点
            strDom = strDom.Append(GetChilds4Dom(allList, rootNode.node_guid));

            //合并后半边
            strDom = strDom.Append(li_tpl_r);

            strDom = strDom.Append(ul_tpl_r);
            return(strDom.ToString());
        }
예제 #3
0
        public NetMapInfo GenerateTree()
        {
            List <NetMapModel> allList = DoQuery("1=1 ORDER BY parentguid,sort_order");
            var rootNode =
                (from item in allList
                 where item.parentguid == Guid.Empty
                 select item).FirstOrDefault <NetMapModel>();

            NetMapInfo tree_data = new NetMapInfo();

            tree_data.name     = string.Concat(rootNode.name, rootNode.station_name, string.IsNullOrEmpty(rootNode.auditor) ? "" : ":" + rootNode.auditor);;
            tree_data.guid     = rootNode.node_guid;
            tree_data.value    = rootNode.auditor;
            tree_data.prefix   = rootNode.station_name;
            tree_data.children = GetChilds(allList, tree_data.guid);

            return(tree_data);
        }