示例#1
0
        public async Task Create_ActionModules_Test()
        {
            var rs = await _actionAppService.GetActions(new GetActionsInput());

            var items = rs.Items;

            var list = await _moduleAppService.GetModules(new GetModulesInput());

            var modules = list.Items; //list.Items.Where(x => x.ParentId != null);

            //var actions = items.Where(
            //        x => x.ActionCode == "CMS.Create" || x.ActionCode == "CMS.Update" || x.ActionCode == "CMS.Delete");
            var actions = items;

            var am = (from m in modules
                      from a in actions
                      select new ActionModuleDto
            {
                ActionId = a.Id,
                ModuleId = m.Id,
                Status = true
            }).ToList();

            await _moduleAppService.CreateOrUpdate(am);
        }
示例#2
0
        public async Task <JsonResult> GetList(string id)
        {
            if (id == null)
            {
                id = "0";
            }
            List <ModuleListDto> list = await _moduleAppService.GetModules(int.Parse(id));

            var json = from r in list
                       select new ModuleListDto()
            {
                Id          = r.Id,
                ModuleCode  = r.ModuleCode,
                ModuleName  = r.ModuleName,
                ParentId    = r.ParentId,
                Url         = r.Url,
                Icon        = r.Icon,
                Sort        = r.Sort,
                Remark      = r.Remark,
                EnabledMark = r.EnabledMark,
                IsLast      = r.IsLast,
                state       = (_moduleAppService.GetModules(r.Id).Result.Count() > 0) ? "closed" : "open"
            };

            return(Json(json));
        }
示例#3
0
        //父ID=0的数据为顶级菜单
        public async Task <ActionResult> GetTopMenu()
        {
            //加入本地化
            //CultureInfo info = Thread.CurrentThread.CurrentCulture;
            //string infoName = info.Name;
            //if (Session["Account"] != null)
            //{
            //    //加入本地化
            //    AccountModel account = (AccountModel)Session["Account"];
            //    List<SysModuleModel> list = homeBLL.GetMenuByPersonId(account.Id, "0");
            //    var json = from r in list
            //               select new SysModuleNavModel()
            //               {
            //                   id = r.Id,
            //                   text = infoName.IndexOf("zh") > -1 || infoName == "" ? r.Name : r.EnglishName,     //text
            //                   attributes = (infoName.IndexOf("zh") > -1 || infoName == "" ? "zh-CN" : "en-US") + "/" + r.Url,
            //                   iconCls = r.Iconic
            //               };


            //    return Json(json);
            //}
            //else
            //{
            //    return Json("0", JsonRequestBehavior.AllowGet);
            //}

            List <ModuleListDto> list = await _moduleAppService.GetModules(0);

            var json = from r in list
                       select new SysModuleNavModel()
            {
                id         = r.Id.ToString(),
                text       = r.ModuleName,          //text
                attributes = r.Url,
                iconCls    = r.Icon
            };

            return(Json(json));

            //List<SysModuleNavModel> list = new List<SysModuleNavModel>();
            //list.Add(new SysModuleNavModel() { id = "201605312304598866131890ede44b6", iconCls = "fa  fa-hand-pointer-o", attributes = "zh-CN/spl", text = "开发指南" });
            //list.Add(new SysModuleNavModel() { id = "20161124112512659817453d009fb84", iconCls = "fa fa-puzzle-piece", attributes = "zh-CN/", text = "信息系统" });
            //list.Add(new SysModuleNavModel() { id = "201407241558264790957ebaf9fec63", iconCls = "fa fa-sort-amount-asc", attributes = "zh-CN/flow", text = "工作流程" });
            //list.Add(new SysModuleNavModel() { id = "2016112411022140581745f0f582911", iconCls = "fa  fa-weixin", attributes = "fa  fa-weixin", text = "微信系统" });
            //list.Add(new SysModuleNavModel() { id = "SystemManage", iconCls = "fa fa-gears", attributes = "zh-CN/sys", text = "系统管理" });
            //list.Add(new SysModuleNavModel() { id = "20161124111315488817464f920b54f", iconCls = "fa  fa-shield", attributes = "zh-CN/", text = "权限系统" });
            //return Json(list, JsonRequestBehavior.AllowGet);
        }
示例#4
0
        public async Task Create_RoleRight_Test()
        {
            var roles = await _roleAppService.GetRoles(new GetRolesInput());

            var modules = await _moduleAppService.GetModules(new GetModulesInput());

            var role  = roles.Items.FirstOrDefault(x => x.RoleCode == "Administrator");
            var items = modules.Items;

            var list = new List <RoleRightDto>();

            foreach (var m in items)
            {
                foreach (var am in m.ActionModules)
                {
                    list.Add(new RoleRightDto
                    {
                        ActionModuleId = am.Id.Value,
                        RoleId         = role.Id,
                        Status         = true
                    });
                }
            }

            await _roleAppService.CreateOrUpdate(list);

            role = roles.Items.FirstOrDefault(x => x.RoleCode == "GroupLeader");

            list = new List <RoleRightDto>();
            foreach (var m in items.Where(x => x.ModuleCode == "CMS.Admin.Setup" || x.ModuleCode == "CMS.Admin.Modules")
                     )
            {
                foreach (var am in m.ActionModules)
                {
                    list.Add(new RoleRightDto
                    {
                        ActionModuleId = am.Id.Value,
                        RoleId         = role.Id,
                        Status         = true
                    });
                }
            }

            await _roleAppService.CreateOrUpdate(list);
        }
        public IHttpActionResult GetModules()
        {
            var data = _moduleAppService.GetModules();

            if (data != null)
            {
                return(Ok(data));
            }
            else
            {
                return(NotFound());
            }
        }