public ActionResult GetFunclistByTreeJson(int RoleID = 0)
        {
            //不分页查询
            List <FunctionDto> list = _functionManagementService.GetAllFunctions();
            var rootModel           = list.Where(m => m.ParentID == "" || m.FunctionID.ToLower() == "root").FirstOrDefault();

            if (!_functionManagementService.ExistFunction("Root"))
            {
                throw new ArgumentNullException("add Root fail");
            }
            if (list == null)
            {
                throw new ArgumentNullException("func list get from service is null!");
            }

            List <TreeResultModelBase> listjson = new List <TreeResultModelBase>();

            if (TryParse.intTryParse(RoleID) <= 0)
            {
                listjson = FunctionDtoToTreeResultModelBase(list, rootModel).ToList();
            }
            else
            {
                var           IRoleFunctionMG = Ioc.GetService <IRoleFunctionManagementService>();
                List <string> auths           = IRoleFunctionMG.GetAllFunctionIDByRoleID(RoleID);
                listjson = FunctionDtoToTreeResultModelBase(list, auths, rootModel).ToList();
            }

            //if (list != null && list.Count() > 0)
            //{
            //    foreach (FunctionDto fun in list)
            //    {
            //        listjson.Add(new TreeResultModelBase() {
            //            id = fun.FunctionID,
            //            text = fun.Name,
            //            state = "open",
            //            iconCls = "",
            //            ischecked = false,//??
            //            children = FunctionDtoToTreeResultModelBase(list.Where(m => m.FunctionID == fun.ParentID))
            //        });
            //    }
            //}
            //var resStr = Serializer.ToJson(result);
            return(new OringinalJsonResult <List <TreeResultModelBase> > {
                Value = listjson
            });
        }
        //获取所有功能列表并转换成需要tree的json格式
        //[PermissionControlAttribute(Functions.Root_SysManagement_EPFunMangement)]
        public ActionResult GetFunclistByTreeJson(int?RoleID)
        {
            var result = new StandardJsonResult <List <TreeDataModelBase> >();

            result.Try(() =>
            {
                string UserID           = GetSession().User.UserID;
                List <FunctionDto> list = _functionManagementService.GetFunctionsByFunctionIds(GetSession().User.FunctionIDs);
                var rootModel           = list.Where(m => m.ParentID == "" || m.FunctionID.ToLower() == "root").FirstOrDefault();
                //if (!_functionManagementService.ExistFunction("Root"))   { }
                if (list == null)
                {
                    throw new ArgumentNullException("func list get from service is null!");
                }
                List <TreeDataModelBase> listjson = new List <TreeDataModelBase>();

                if (rootModel == null || string.IsNullOrEmpty(rootModel.FunctionID))
                {
                    //没有根节点
                    throw new KnownException("无权限");
                }
                if (TryParse.intTryParse(RoleID) <= 0)
                {
                    //新增角色的时候
                    listjson = FunctionDtoToTreeResultModelBase(list, rootModel).ToList();
                }
                else
                {
                    var IRoleFunctionMG = Ioc.GetService <IRoleFunctionManagementService>();
                    List <string> auths = IRoleFunctionMG.GetAllFunctionIDByRoleID((int)RoleID);
                    listjson            = FunctionDtoToTreeResultModelBase(list, auths, rootModel).ToList();
                }
                result.Value = listjson;
            });
            if (result.Success == false)
            {
                result.Value = new List <TreeDataModelBase>();
            }
            return(new OringinalJsonResult <List <TreeDataModelBase> > {
                Value = result.Value
            });
        }