예제 #1
0
        /// <summary>
        /// 不使用分页查询为角色赋予权限
        /// </summary>
        /// <returns></returns>
        public ActionResult SetRoleActionNoPagination()
        {
            /*int id = int.Parse(Request.Form["rid"]);*///使用此种方式无法获取id
            int rid = int.Parse(Request.QueryString["id"]);
            //int pageSize = int.Parse(Request.Form["rows"]);
            //int pageIndex = int.Parse(Request.Form["page"]);
            int rowCount = 0;

            if (rid != null)
            {
                //查询被选中的Action
                //1 根据RoleID查询该Role所对应的Action权限
                //1.1查出未删除的role中指定ID的Role
                var role = roleInfoBLL.GetListBy(r => r.DelFlag == false && r.ID == rid).FirstOrDefault();
                //1.2查出该role中对应的action(ICollection)
                var actions = role.ActionInfo.ToList();
                //将该action中的checked属性赋值为true
                //4月1日 注意此处有bug ,分页应该是对指定role对应的权限+全部其余action的集合整体进行分页
                //2 需要对actions进行分页

                //actions = actions

                //3 查询所有的action集合
                var allActionList = actionInfoBLL.GetListBy(u => u.DelFlag == false);
                //3.1 找到未添加的action集合
                //总行数=所有权限的总和
                rowCount = allActionList.Count();
                //3 将action返回给视图页面,需要添加一个check标签
                List<ActionInfo> list = new List<ActionInfo>();
                foreach (var item in actions)
                {
                    item.Checked = true;
                    //从全部的权限集合中找到与当前权限id不同的其余权限集合
                    allActionList = allActionList.Where(a => a.ID != item.ID);
                    list.Add(item);
                }

                list.AddRange(allActionList);
                list = list.Select(a => a.ToMiddleModel()).ToList();
                //4月1日
                //应对list进行分页
                //list = list.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
                //4
                PMS.Model.EasyUIModel.EasyUIDataGrid dgModel = new PMS.Model.EasyUIModel.EasyUIDataGrid()
                {
                    total = rowCount,
                    rows = list,
                    footer = null
                };

                string temp = Common.SerializerHelper.SerializerToString(dgModel);
                temp = temp.Replace("Checked", "checked");
                return Content(temp);

            }
            return null;
        }
예제 #2
0
        /// <summary>
        /// 根据传入的uid获取作业集合
        /// </summary>
        /// <returns></returns>
        public ContentResult GetJobInfoByUser(int uid)
        {
            //string uid_str = Request.Form["uid"];
            //string uid_str = uid;
            int pageSize = int.Parse(Request.Form["rows"]);
            int pageIndex = int.Parse(Request.Form["page"]);
            int rowCount = 0;
            //分页查询全部用户
            //使用三元运算符判断当前请求中是否包含了uid
            //var list = jobInfoBLL.GetJobInfoByPage(pageIndex, pageSize,ref rowCount, true, true,uid_str!=null?int.Parse(uid_str):-1);
            var list = jobInfoBLL.GetJobInfoByPage(pageIndex, pageSize, ref rowCount, true, true, uid);

            EasyUIDataGrid dgModel = new EasyUIDataGrid()
            {
                total = rowCount,
                rows = list,
                footer = null
            };

            return Content(Common.SerializerHelper.SerializerToString(dgModel));
        }
예제 #3
0
        // GET: Admin/Action
        /// <summary>
        /// 获取权限集合
        /// </summary>
        /// <returns></returns>
        public ActionResult GetActionInfo(ViewModel_ActionInfo_QueryInfo queryModel)
        {
            int pageSize = int.Parse(Request.Form["rows"]);
            int pageIndex = int.Parse(Request.Form["page"]);
            int rowCount=0 ;

            //查询所有的权限
            //使用ref声明时需要在传入之前为其赋值
            var list_record = actionInfoBLL.GetActionRecordListByQuery(pageIndex, pageSize, ref rowCount, queryModel, true, true);
            PMS.Model.EasyUIModel.EasyUIDataGrid dgModel = new PMS.Model.EasyUIModel.EasyUIDataGrid()
            {
                total = rowCount,
                rows = list_record,
                footer = null
            };

            //将权限转换为对应的
            return Content(Common.SerializerHelper.SerializerToString(dgModel));
        }