예제 #1
0
        public ActionResult GetGridJson(Pagination pagination, string keyword)
        {
            var company   = _organizeApp.GetList(pagination, keyword);
            var customers = company.Where(x => x.F_Id != OperatorProvider.Provider.GetCurrent().CompanyId&& x.F_DeleteMark != true).Select(item => new CustomerViewModel
            {
                CompanyInfo = item,
                DefaultUser = _userApp.GetDefaultUser(item.F_Id),
                DefaultRole = _roleApp.GetDefaultCompanyRole(item.F_Id)
            }).ToList();

            return(Content(customers.ToJson()));
        }
예제 #2
0
        public ActionResult GetPermissionTree(string roleId, CustomerTypeEnum customerType)
        {
            var moduledata = customerType != CustomerTypeEnum.Both
                ? moduleApp.GetList(customerType)
                : OperatorProvider.Provider.GetCurrent().IsSystem
                    ? moduleApp.GetList(CustomerTypeEnum.System)
                    : OperatorProvider.Provider.GetCurrent().IsPlatform
                        ? moduleApp.GetList(CustomerTypeEnum.Platform)
                        : moduleApp.GetList(CustomerTypeEnum.Organization);
            var buttondata    = moduleButtonApp.GetList();
            var authorizedata = new List <RoleAuthorizeEntity>();

            if (!string.IsNullOrEmpty(roleId))
            {
                authorizedata = roleAuthorizeApp.GetList(roleId);
            }
            var defaultauthorizedata = new List <RoleAuthorizeEntity>();

            if (!string.IsNullOrEmpty(OperatorProvider.Provider.GetCurrent().CompanyId))
            {
                var role = roleApp.GetDefaultCompanyRole(OperatorProvider.Provider.GetCurrent().CompanyId);
                if (role != null)
                {
                    defaultauthorizedata = roleAuthorizeApp.GetList(role.F_Id);
                }
            }
            var treeList = (from item in moduledata
                            where defaultauthorizedata.Count(t => t.F_ItemId == item.F_Id) > 0 || OperatorProvider.Provider.GetCurrent().IsSystem || customerType != CustomerTypeEnum.Both
                            select new TreeViewModel
            {
                id = item.F_Id,
                text = item.F_FullName,
                value = item.F_EnCode,
                parentId = item.F_ParentId,
                isexpand = true,
                complete = true,
                showcheck = true,
                checkstate = authorizedata.Count(t => t.F_ItemId == item.F_Id),
                hasChildren = true,
                img = item.F_Icon == "" ? "" : item.F_Icon
            }).ToList();

            treeList.AddRange(from item in buttondata
                              where defaultauthorizedata.Count(t => t.F_ItemId == item.F_Id) > 0 || OperatorProvider.Provider.GetCurrent().IsSystem || customerType != CustomerTypeEnum.Both
                              select new TreeViewModel
            {
                id          = item.F_Id,
                text        = item.F_FullName,
                value       = item.F_EnCode,
                parentId    = item.F_ParentId == "0" ? item.F_ModuleId : item.F_ParentId,
                isexpand    = true,
                complete    = true,
                showcheck   = true,
                checkstate  = authorizedata.Count(t => t.F_ItemId == item.F_Id),
                hasChildren = buttondata.Count(t => t.F_ParentId == item.F_Id) != 0,
                img         = item.F_Icon == "" ? "" : item.F_Icon
            });
            return(Content(treeList.TreeViewJson()));
        }