Example #1
0
        public void ProcessRequest(HttpContext context)
        {
            string relation_id  = context.Request["relation_id"];
            string pms_ids      = context.Request["pms_ids"];
            string rel_type     = context.Request["rel_type"];
            int    relationType = 2;

            if (!string.IsNullOrWhiteSpace(rel_type))
            {
                relationType = int.Parse(rel_type);
            }

            if (string.IsNullOrWhiteSpace(pms_ids))
            {
                pms_ids = "0";
            }
            List <long> pms_id_list = pms_ids.Split(',').Select(p => Convert.ToInt64(p)).ToList();
            List <BLLPermission.Model.PermissionRelationInfo> relOList = bllPermission.GetPermissionRelationList(relation_id, relationType);
            List <long> pmso_id_list = relOList.Select(p => p.PermissionID).ToList();
            List <BLLPermission.Model.PermissionRelationInfo> relDelList = relOList.Where(p => !pms_id_list.Contains(p.PermissionID)).ToList();
            List <BLLPermission.Model.PermissionRelationInfo> relAddList = new List <BLLPermission.Model.PermissionRelationInfo>();

            foreach (long item in pms_id_list.Where(p => !pmso_id_list.Contains(p) && p != 0))
            {
                BLLPermission.Model.PermissionRelationInfo nPerRel = new BLLPermission.Model.PermissionRelationInfo();
                nPerRel.RelationType = relationType;
                nPerRel.PermissionID = item;
                nPerRel.RelationID   = relation_id;
                relAddList.Add(nPerRel);
            }
            BLLTransaction tran = new BLLTransaction();

            foreach (BLLPermission.Model.PermissionRelationInfo item in relDelList)
            {
                if (bllPermission.Delete(item, tran) < 0)
                {
                    tran.Rollback();
                    apiResp.code = (int)APIErrCode.OperateFail;
                    apiResp.msg  = "删除原权限关系失败。";
                    bllPermission.ContextResponse(context, apiResp);
                    return;
                }
            }
            foreach (BLLPermission.Model.PermissionRelationInfo item in relAddList)
            {
                if (!bllPermission.Add(item, tran))
                {
                    tran.Rollback();
                    apiResp.code = (int)APIErrCode.OperateFail;
                    apiResp.msg  = "保存新权限关系失败。";
                    bllPermission.ContextResponse(context, apiResp);
                    return;
                }
            }
            tran.Commit();
            apiResp.status = true;
            apiResp.code   = (int)APIErrCode.IsSuccess;
            apiResp.msg    = "保存完成。";
            bllPermission.ContextResponse(context, apiResp);
        }
Example #2
0
        public void ProcessRequest(HttpContext context)
        {
            StringBuilder sbWhere   = new StringBuilder();
            int           pageIndex = Convert.ToInt32(context.Request["page"]);
            int           pageSize  = Convert.ToInt32(context.Request["rows"]);
            string        keyWord   = context.Request["searchReq"];

            List <BLLPermission.Model.PermissionGroupInfo> list = bllPms.GetGroupList(pageSize, pageIndex, keyWord, bllPms.WebsiteOwner, null, 2);

            list.AddRange(bllPms.GetGroupList(pageSize, pageIndex, keyWord, "common", null, 3));
            list.AddRange(bllPms.GetGroupList(pageSize, pageIndex, keyWord, "common", null, 4));
            List <BLLPermission.Model.PermissionGroupInfo> dataList = new List <BLLPermission.Model.PermissionGroupInfo>();

            if (currentUserInfo.UserType != 1 && currentUserInfo.UserID != bllPms.WebsiteOwner)
            {
                List <BLLPermission.Model.PermissionGroupInfo> groupList = bllPms.GetUserGroupList(currentUserInfo.UserID, bllPms.WebsiteOwner, 2);
                if (groupList.Count > 0)
                {
                    foreach (BLLPermission.Model.PermissionGroupInfo item in groupList)
                    {
                        if (dataList.FirstOrDefault(p => p.GroupID == item.GroupID) != null)
                        {
                            continue;
                        }
                        bllPms.GetDataList(ref dataList, list, item.GroupID, 1, 9);
                    }
                }
            }
            else
            {
                bllPms.GetDataList(ref dataList, list, 0, 1, 9);
            }
            int total = dataList.Count;

            if (dataList.Count > pageSize)
            {
                dataList = dataList.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
            }
            var data = new
            {
                total = total,
                rows  = dataList//列表
            };

            bllPms.ContextResponse(context, data);
        }