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

            var source = list;

            if (source == null)
            {
                return;
            }

            var children = source.Where(d => d.id_father == root.id);

            if (children == null)
            {
                return;
            }

            root.children = children.ToList();

            foreach (var item in children)
            {
                BuildTree(item, source);
            }
        }
Exemple #2
0
 private void HandleFunctionTree(Tb_Function_Tree node)
 {
     if (node != null)
     {
         if (node.flag_type == "module")
         {
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// 获取功能树
        /// </summary>
        /// <returns></returns>
        public IList <Tb_Function_Tree> GetFunctionTree(Hashtable param)
        {
            param.Add("flag_stop", 0);
            param.Add("sort", "sort_id");
            param.Add("dir", "asc");

            var list = DAL.QueryList <Tb_Function>(typeof(Tb_Function), param);

            var sourceList = list.Select(d => new Tb_Function_Tree
            {
                id              = d.id,
                id_father       = d.id_father,
                flag_stop       = d.flag_stop,
                flag_type       = d.flag_type,
                id_create       = d.id_create,
                id_edit         = d.id_edit,
                name            = d.name,
                path            = d.path,
                rq_create       = d.rq_create,
                rq_edit         = d.rq_edit,
                sort_id         = d.sort_id,
                version         = d.version,
                isclose         = true,
                controller_name = d.controller_name,
                action_name     = d.action_name,
                icon            = d.icon,
                tag_name        = d.tag_name
            }).ToList();

            var targetList = sourceList.Where(d => d.id_father == "0").OrderBy(a => a.sort_id).ToList();

            var root = new Tb_Function_Tree
            {
                id        = "0",
                flag_type = "module",
                path      = "0",
                name      = "根目录",
                children  = targetList,
                isclose   = false
            };

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

            var rootList = new List <Tb_Function_Tree>();

            rootList.Add(root);

            return(rootList);
        }
Exemple #4
0
 private void BuildTree(Tb_Function_Tree root, IList <Tb_Function_Tree> list)
 {
     if (root == null || list == null || !list.Any())
     {
         return;
     }
     root.children = list.Where(d => d.id_father == root.id).ToList();
     if (!root.children.Any())
     {
         return;
     }
     foreach (var item in root.children)
     {
         BuildTree(item, list);
     }
 }
Exemple #5
0
        public BaseResult GetUserMenu(string id_user)
        {
            BaseResult br    = new BaseResult();
            Hashtable  param = new Hashtable();

            param.Add("id_user", id_user);
            param.Add("flag_delete", (byte)Enums.FlagDelete.NoDelete);
            var roleList = DAL.QueryList <Tb_User_Role>(typeof(Tb_User_Role), param);

            if (roleList.Any())
            {
                var roleArray = (from role in roleList select role.id_role).ToArray();
                param.Add("rolelist", roleArray);
                param.Add("flag_stop", 0);
                param.Add("sort", "sort_id");
                param.Add("dir", "asc");
                var funcList = DAL.QueryList <Tb_Function>(typeof(Tb_Function), param);
                funcList = funcList.OrderBy(a => a.sort_id).ToList();
                var delModel = funcList.FirstOrDefault(a => a.id == "b4fbb82c-783a-4fc7-b0b2-0f7129ed8838");
                if (delModel != null)
                {
                    funcList.Remove(delModel);
                }
                var sourceList = funcList.Select(d => new Tb_Function_Tree
                {
                    id              = d.id,
                    id_father       = d.id_father,
                    flag_stop       = d.flag_stop,
                    flag_type       = d.flag_type,
                    id_create       = d.id_create,
                    id_edit         = d.id_edit,
                    name            = d.name,
                    path            = d.path,
                    rq_create       = d.rq_create,
                    rq_edit         = d.rq_edit,
                    sort_id         = d.sort_id,
                    version         = d.version,
                    isclose         = true,
                    action_name     = d.action_name,
                    controller_name = d.controller_name,
                    icon            = d.icon,
                    tag_name        = d.tag_name
                }).ToList();


                var targetList = sourceList.Where(d => d.id_father == "0").ToList();
                targetList = targetList.OrderBy(a => a.sort_id).ToList();
                var root = new Tb_Function_Tree
                {
                    id        = "0",
                    flag_type = "module",
                    path      = "0",
                    name      = "根目录",
                    children  = targetList,
                    isclose   = false
                };
                foreach (var item in targetList)
                {
                    BuildTree(item, sourceList);
                }
                var rootList = new List <Tb_Function_Tree>();
                rootList.Add(root);
                br.Data = rootList;
            }
            br.Success = true;
            return(br);
        }
Exemple #6
0
        public IList <Tb_Function_Tree> GetControllerList(string id_user, string noUse)
        {
            IList <Tb_Function_Tree> controllerList = DataCache.Get <IList <Tb_Function_Tree> >(id_user + "_purview");

            if (controllerList == null)
            {
                lock (lock1)
                {
                    controllerList = DataCache.Get <IList <Tb_Function_Tree> >(id_user + "_purview");
                    if (controllerList == null)
                    {
                        Hashtable param = new Hashtable();
                        param.Add("id", id_user);
                        Tb_User user = DAL.GetItem <Tb_User>(typeof(Tb_User), param);

                        if (user == null)
                        {
                            return(new List <Tb_Function_Tree>());
                        }

                        param.Clear();
                        param.Add("id_user", id_user);
                        param.Add("flag_delete", (byte)Enums.FlagDelete.NoDelete);
                        var roleList = DAL.QueryList <Tb_User_Role>(typeof(Tb_User_Role), param);

                        if (roleList.Count > 0)
                        {
                            string[]   roles    = roleList.Select(m => m.id_role).ToArray();
                            List <int> sysRoles = new List <int>();
                            param.Clear();
                            if (user.id_father != "0")//user.fatherId != 0
                            {
                                param.Add("id_user_master", user.id_father);
                            }
                            else
                            {
                                param.Add("id_user_master", user.id);
                            }
                            param.Clear();
                            param.Add("id_user", id_user);
                            param.Add("id_roleList", roles);
                            param.Add("flag_stop", (int)YesNoFlag.No);
                            //param.Add("flag_typeList", new string[] { "controller", "action" });
                            var list       = DAL.QueryList <Tb_Function>(typeof(Tb_Function), param);
                            var sourceList = list.Select(d => new Tb_Function_Tree
                            {
                                id              = d.id,
                                id_father       = d.id_father,
                                flag_stop       = d.flag_stop,
                                flag_type       = d.flag_type,
                                id_create       = d.id_create,
                                id_edit         = d.id_edit,
                                name            = d.name,
                                path            = d.path,
                                rq_create       = d.rq_create,
                                rq_edit         = d.rq_edit,
                                sort_id         = d.sort_id,
                                version         = d.version,
                                isclose         = true,
                                action_name     = d.action_name,
                                controller_name = d.controller_name,
                                icon            = d.icon,
                                tag_name        = d.tag_name
                            }).ToList();

                            var targetList = sourceList.Where(d => d.id_father == "0").ToList();
                            var root       = new Tb_Function_Tree
                            {
                                id        = "0",
                                flag_type = "module",
                                path      = "0",
                                name      = "根目录",
                                children  = targetList,
                                isclose   = false
                            };

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

                            var rootList = new List <Tb_Function_Tree>();
                            rootList.Add(root);
                            return(rootList);
                            //var query = from item in list where item.flag_type == "controller" group item by item.name.ToLower() into g select g.Key;
                            //controllerList = query.ToList(m => new ControllerModel() { name = m });
                            //foreach (var item in controllerList)
                            //{
                            //    var query1 = from action in list
                            //                 join controller in list on action.fatherId equals controller.id
                            //                 where action.flag_type == "action" && controller.flag_type == "controller" && controller.name.ToLower() == item.name
                            //                 group action by action.name.ToLower() into g
                            //                 select g.Key;
                            //    item.actions = query1.ToList(m => m);
                            //}
                        }
                        else
                        {
                            controllerList = new List <Tb_Function_Tree>();
                        }
                    }
                }
            }

            return(controllerList);
        }