Example #1
0
        private void BuildTree(Tb_Pos_Role_Module_Tree root, IList <Tb_Pos_Role_Module_Tree> list)
        {
            if (root == null)
            {
                return;
            }

            var source = list;

            if (source == null)
            {
                return;
            }

            var children = source.Where(d => d.id_module_fatherid == root.id_module);

            if (children == null)
            {
                return;
            }

            root.children = children.ToList();

            foreach (var item in children)
            {
                BuildTree(item, source);
            }
        }
Example #2
0
        public IList <Tb_Pos_Role_Module_Tree> GetRoleModuleTree(Hashtable param)
        {
            if (!param.ContainsKey("id_platform_role"))
            {
                //默认为供应商
                param.Add("id_platform_role", 0);
            }

            param.Add("sort", "sort_id");
            param.Add("dir", "asc");

            var sourceList = DAL.QueryList <Tb_Pos_Role_Module_Tree>(typeof(Tb_Pos_Role_Module), param);

            //var targetList = sourceList.Where(d => d.id_module_fatherid == 0).ToList();

            var root = new Tb_Pos_Role_Module_Tree
            {
                id        = 0,
                id_module = 0,
                name      = "根目录",
                children  = sourceList,
                isclose   = false
            };

            //foreach (var item in sourceList)
            //{
            //    BuildTree(item, sourceList);
            //}

            var rootList = new List <Tb_Pos_Role_Module_Tree>();

            rootList.Add(root);

            return(rootList);
        }