Example #1
0
        private async Task <IRoleSearchViewModel> PoulateDropDownListAsync(IRoleSearchViewModel model, CancellationToken cancellationToken)
        {
            if (model == null)
            {
                model = new RoleSearchViewModel();
            }

            return(model);
        }
Example #2
0
        public ActionResult JurisdictionRolePackageSearch(RoleSearchViewModel rolesearch)
        {
            //分页获取所有的角色信息
            var total  = 0;
            var result = JurisdictionBusiness.SearchRole(rolesearch, out total);
            var page   = new Page(total, rolesearch.CurrentPage);
            var list   = new List <JurisdictionRoleGroupIndexViewModel>();

            foreach (var item in result)
            {
                var viewModel = new JurisdictionRoleGroupIndexViewModel
                {
                    GroupId   = item.RoleId,
                    GroupName = item.Rolename,
                    GroupCode = item.RoleCode,
                };
                //根据用户id去资源权限分类表查询资源信息
                var relationinfo = JurisdictionBusiness.GetUserRoleRelationByGroupId(long.Parse(EncryptHelper.DesDecrypt(item.RoleId.ToString())));
                if (relationinfo != null)
                {
                    foreach (var roloGroup in relationinfo)
                    {
                        var userInfo = HomeBusiness.GetUserById(roloGroup.BURUserId);
                        if (userInfo != null)
                        {
                            viewModel.UserInfo += userInfo.BUName + "(" + userInfo.BUJobNumber + ")" + ",";
                        }
                    }
                    if (viewModel.UserInfo != null && viewModel.UserInfo.Length > 0)
                    {
                        viewModel.UserInfo = viewModel.UserInfo.Substring(0, viewModel.UserInfo.Length - 1);
                    }
                }
                list.Add(viewModel);
            }

            var resultModel = new JurisdictionRoleGroupSearchModel()
            {
                Models = list,
                Page   = page
            };

            return(View(resultModel));
        }
Example #3
0
        public List <RoleView> SearchRole(RoleSearchViewModel search, out int totalCount)
        {
            var list     = new List <RoleView>();
            var sql      = new StringBuilder();
            var countSql = new StringBuilder();
            var whereSql = new StringBuilder();

            whereSql.Append(" WHERE 1=1 ");
            if (!string.IsNullOrEmpty(search.GroupName))
            {
                whereSql.Append(string.Format(" AND BGName LIKE '%{0}%'", search.GroupName));
            }

            sql.Append(string.Format(@"
                SELECT newTable.*
                FROM    (
                        SELECT TOP ( {0} * {1} )
                        ROW_NUMBER() OVER (ORDER BY Id DESC) RowNum
                        ,Id AS RoleId
                        ,BGCode AS RoleCode
                        ,BGName AS Rolename
                        FROM {2} WITH(NOLOCK) {3}
                        Order BY Id DESC ) newTable
                WHERE newTable.RowNum>(({0}-1)*{1})
            ", search.CurrentPage, search.PageSize, tableName, whereSql.ToString()));

            countSql.Append(string.Format(@"SELECT COUNT(1) FROM {0} WITH(NOLOCK) {1} ", tableName, whereSql.ToString()));

            var ds = ExecuteDataSet(CommandType.Text, sql.ToString());

            totalCount = ExecuteCount(CommandType.Text, countSql.ToString());
            if (ds != null && ds.Tables.Count > 0)
            {
                DataTable dt = new DataTable();
                dt   = ds.Tables[0];
                list = DataConvertHelper.DataTableToList <RoleView>(dt);
            }
            return(list);
        }
Example #4
0
        public async Task <IActionResult> Index(RoleSearchViewModel viewModel)
        {
            // check roles
            var token = HttpContext.Session.GetString("Token");
            var id    = new Guid(HttpContext.Session.GetString("UserId"));
            var roles = await _manageRole.GetRoleByUserId(token, id);

            var rolosAccess = roles.data.Any(x => x.RoleName == CommonController.VIEW);

            if (rolosAccess == false)
            {
                return(Redirect("/Role/AccessDenied"));
            }
            ;
            // end check roles


            var rs = await _manageRole.GetAllRole(token);

            ViewBag.Data          = rs.data;
            ViewBag.statusMessage = TempData["Result"];
            return(View());
        }