Beispiel #1
0
        private string Copy(HttpContext context)
        {
            string idStr = context.Request["id"];
            long   id    = Convert.ToInt64(idStr);
            PermissionGroupInfo model = bllPms.GetPermissionGroup(null, id);
            string newIdStr           = bllPer.GetGUID(TransacType.PermissionGroupAdd);

            model.GroupID   = Convert.ToInt64(newIdStr);
            model.GroupName = model.GroupName + "—复制";
            //权限组权限关系
            List <PermissionRelationInfo> listPermissionRelation = bllPms.GetPermissionRelationList(idStr, 0);
            //权限组权限栏目关系
            List <PermissionRelationInfo> listPermissionRelation3 = bllPms.GetPermissionRelationList(idStr, 3);

            listPermissionRelation.AddRange(listPermissionRelation3);
            foreach (var item in listPermissionRelation)
            {
                item.RelationID = newIdStr;
            }
            List <MenuRelationInfo> listMenuRelation = bllMenu.GetMenuRelationList(idStr, 0);

            foreach (var item in listMenuRelation)
            {
                item.RelationID = newIdStr;
            }

            BLLTransaction tran   = new BLLTransaction();
            bool           result = bllPer.Add(model, tran);

            if (!result)
            {
                tran.Rollback();
                return("复制权限组失败");
            }
            foreach (var item in listPermissionRelation)
            {
                if (!bllPer.Add(item, tran))
                {
                    tran.Rollback();
                    return("复制权限组权限失败");
                }
            }
            foreach (var item in listMenuRelation)
            {
                if (!bllPer.Add(item, tran))
                {
                    tran.Rollback();
                    return("复制权限组菜单失败");
                }
            }
            tran.Commit();
            return(result.ToString().ToLower());
        }
Beispiel #2
0
        public void ProcessRequest(HttpContext context)
        {
            int    pageIndex    = Convert.ToInt32(context.Request["page"]);
            int    pageSize     = Convert.ToInt32(context.Request["rows"]);
            string websiteOwner = context.Request["website_owner"];
            string show_hide    = context.Request["show_hide"];
            string max_level    = context.Request["max_level"];
            bool   showHide     = show_hide == "1" ? true : false;
            int    maxLevel     = 9;

            if (string.IsNullOrWhiteSpace(max_level))
            {
                max_level = "9";
            }
            int.TryParse(max_level, out maxLevel);
            List <BLLPermission.Model.PermissionColumn> list = new List <BLLPermission.Model.PermissionColumn>();

            if (currentUserInfo.UserType != 1 && currentUserInfo.UserID != websiteOwner && (currentUserInfo.PermissionGroupID != 3))
            {
                list = bllPermissionColumn.GetColumnListByUser(currentUserInfo.UserID, websiteOwner, showHide);
            }
            else
            {
                list = bllPermissionColumn.GetColumnListByWebsiteOwner(websiteOwner, showHide);
            }
            List <BLLPermission.Model.PermissionColumn> showList = new List <BLLPermission.Model.PermissionColumn>();

            bllPermissionColumn.GetDataList(ref showList, list, 0, 0, 1, maxLevel);

            int total = showList.Count;

            if (showList.Count > pageSize)
            {
                showList = showList.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
            }
            List <dynamic> result = new List <dynamic>();

            foreach (var item in showList)
            {
                var has_menu  = false;
                var menu_list = bllMenu.GetMenuRelationList(item.PermissionColumnID.ToString(), 5);
                var menu_strs = "";
                if (menu_list.Count > 0)
                {
                    has_menu  = true;
                    menu_strs = ZentCloud.Common.MyStringHelper.ListToStr(menu_list.Select(p => p.MenuID).ToList(), "", ",");
                }
                var has_permission  = false;
                var permission_list = bllPermission.GetPermissionRelationList(item.PermissionColumnID.ToString(), 2);
                var permission_strs = "";
                if (permission_list.Count > 0)
                {
                    has_permission  = true;
                    permission_strs = ZentCloud.Common.MyStringHelper.ListToStr(permission_list.Select(p => p.PermissionID).ToList(), "", ",");
                }
                result.Add(new
                {
                    id              = item.PermissionColumnID,
                    name            = item.PermissionColumnName,
                    pre_id          = item.PermissionColumnPreID,
                    base_id         = item.PermissionColumnBaseID,
                    order_num       = item.OrderNum,
                    is_hide         = item.IsHide,
                    website_owner   = item.WebsiteOwner,
                    has_menu        = has_menu,
                    has_permission  = has_permission,
                    menu_strs       = menu_strs,
                    permission_strs = permission_strs
                });
            }
            var data = new
            {
                totalcount = total,
                list       = result//列表
            };

            apiResp.result = data;
            apiResp.status = true;
            apiResp.code   = (int)APIErrCode.IsSuccess;
            bllPermissionColumn.ContextResponse(context, apiResp);
        }