예제 #1
0
        public ActionResult List(GridCommand command, RoleSearchModel searchModel)
        {
            SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);

            ViewBag.PageSize = base.ProcessPageSize(command.PageSize);
            return(View());
        }
예제 #2
0
        public async Task <IActionResult> RoleGrid(RoleSearchModel model)
        {
            model = InitializeRoleModel(model, model.ApplicationId);
            var result = await _employeeFacadeApiClient.GetRoles(model);

            return(PartialView(result));
        }
예제 #3
0
        public async Task <RoleSearchModel> GetRoles(RoleSearchModel model)
        {
            var url    = ODataApiUri + "/Role?" + GetFilterString(model);
            var result = await GetOdataResultFromApi(url);

            var searchResultCount = 0;

            if (result.Count != null)
            {
                int.TryParse(result.Count.ToString(), out searchResultCount);
            }
            model.TotalRows = searchResultCount;
            model.RoleSearchResult.Clear();
            try
            {
                model.RoleSearchResult.AddRange(result.Items.Select(item => JsonConvert.DeserializeObject <RoleDto>(item.ToString())));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(model);
        }
예제 #4
0
        public ActionResult Search()
        {
            RoleSearchModel model = new RoleSearchModel();

            model.Roles = this.roleFacade.GetRoles();
            model.Input = new RoleCreateInputModel();
            return(View(model));
        }
        public ActionResult RolePermission(RoleSearchModel searchModel)
        {
            var          expr        = BuildSearchCriteria(searchModel);
            IRoleService roleService = ServiceFactory.Create <IRoleService>();
            var          roles       = roleService.GetEntitiesByPage(searchModel.PageIndex, 5, expr, false, t => t.ID);

            ViewBag.SearchModel = searchModel;
            return(View(roles));
        }
예제 #6
0
        public async Task <IActionResult> List(RoleSearchModel searchModel)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageUsers))
            {
                return(AccessDeniedKendoGridJson());
            }

            var model = await _roleModelFactory.PrepareRoleListModel(searchModel);

            return(Json(model));
        }
예제 #7
0
        public async Task <RoleListModel> GetByPaging(RoleSearchModel request)
        {
            try
            {
                var start = 1;

                if (request != null)
                {
                    start = request.Start / request.Length + 1;
                }

                var columnOrder = "name";
                var sortDir     = "ASC";

                var url = string.Format(ApiUrl.DEPARTMENT_GET_BY_PAGING,
                                        request.Name,
                                        request.ColumnOrder,
                                        start,
                                        request?.Length ?? 10,
                                        columnOrder,
                                        sortDir);

                var response = await HttpService.Send <PageResult <GetRolePagingResponse> >(url,
                                                                                            null,
                                                                                            HttpMethod.Get,
                                                                                            true);

                if (response.IsSuccess)
                {
                    return new RoleListModel
                           {
                               Draw            = request.Draw,
                               RecordsFiltered = response.Data.TotalCount,
                               Total           = response.Data.TotalCount,
                               RecordsTotal    = response.Data.TotalCount,
                               Data            = response.Data.Data.Select(c => new RoleModel
                        {
                            Id              = c.Id,
                            Name            = c.Name,
                            PageSize        = request.PageSize,
                            PageSizeOptions = request.AvailablePageSizes
                        })
                           }
                }
                ;

                throw new PeloException(response.Message);
            }
            catch (Exception exception)
            {
                throw new PeloException(exception.Message);
            }
        }
예제 #8
0
        public Task <RoleSearchModel> PrepareRoleSearchModel(RoleSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(Task.FromResult(searchModel));
        }
예제 #9
0
        public ActionResult RoleList(RoleSearchModel model)
        {
            IPlatformRoleBLL platformRoleBll = BLLFactory <IPlatformRoleBLL> .GetBLL("PlatformRoleBLL");

            //查询条件
            Expression <Func <T_PlatformRole, bool> > where = u => string.IsNullOrEmpty(model.RoleName) ? true : u.RoleName.Contains(model.RoleName);

            //排序
            var sortModel = this.SettingSorting("Id", false);
            var list      = platformRoleBll.GetPageList(where, sortModel.SortName, sortModel.IsAsc, model.PageIndex);

            return(View(list));
        }
예제 #10
0
        public async Task <PagedModel <SysRoleDto> > SearchRoles(RoleSearchModel searchModel)
        {
            Expression <Func <SysRole, bool> > whereCondition = x => true;

            if (!string.IsNullOrWhiteSpace(searchModel.RoleName))
            {
                whereCondition = whereCondition.And(x => x.Name.Contains(searchModel.RoleName));
            }

            var pagedModel = await _roleRepository.PagedAsync(searchModel.PageIndex, searchModel.PageSize, whereCondition, x => x.ID, true);

            return(_mapper.Map <PagedModel <SysRoleDto> >(pagedModel));
        }
        /// <summary>
        /// 构建查询表达式
        /// </summary>
        /// <returns></returns>
        private Expression <Func <Role, Boolean> > BuildSearchCriteria(RoleSearchModel searchModel)
        {
            DynamicLambda <Role> bulider            = new DynamicLambda <Role>();
            Expression <Func <Role, Boolean> > expr = null;

            if (!string.IsNullOrWhiteSpace(searchModel.RoleName))
            {
                Expression <Func <Role, Boolean> > tmp = t => t.Name.Contains(searchModel.RoleName);
                expr = bulider.BuildQueryAnd(expr, tmp);
            }

            if (!string.IsNullOrWhiteSpace(searchModel.Disabled))
            {
                var flage = searchModel.Disabled == "1" ? true : false;
                Expression <Func <Role, Boolean> > tmp = t => t.Disabled == flage;
                expr = bulider.BuildQueryAnd(expr, tmp);
            }

            if (!string.IsNullOrWhiteSpace(searchModel.startDate))
            {
                try
                {
                    DateTime dt = Convert.ToDateTime(searchModel.startDate);
                    Expression <Func <Role, Boolean> > tmp = t => t.CreateTime >= dt;
                    expr = bulider.BuildQueryAnd(expr, tmp);
                }
                catch
                {
                }
            }

            if (!string.IsNullOrWhiteSpace(searchModel.endDate))
            {
                try
                {
                    DateTime dt = Convert.ToDateTime(searchModel.endDate).AddDays(1);
                    Expression <Func <Role, Boolean> > tmp = t => t.CreateTime < dt;
                    expr = bulider.BuildQueryAnd(expr, tmp);
                }
                catch
                {
                }
            }

            //Expression<Func<Role, Boolean>> tmpSolid = t => t.IsDeleted == false;
            //expr = bulider.BuildQueryAnd(expr, tmpSolid);

            return(expr);
        }
예제 #12
0
        private UserDto PopulateRolesForUser(UserDto model, int applicationId, int userId)
        {
            var searchUserApplicationRoles = new UserApplicationRoleSearchModel {
                PageSize = int.MaxValue, SortColumn = "Role/Role/RoleName", SortDirection = "Asc", ApplicationId = applicationId, UserId = userId
            };

            searchUserApplicationRoles = _employeeApiClient.GetUserApplicationRoles(searchUserApplicationRoles).Result;
            var searchRoles = new RoleSearchModel {
                PageSize = int.MaxValue, SortColumn = "RoleName", SortDirection = "Asc", ApplicationId = applicationId
            };

            searchRoles          = _employeeApiClient.GetRoles(searchRoles).Result;
            model.RoleSelectList = SelectedListHelper.GetApplicationRolesSelectList(searchRoles.RoleSearchResult, searchUserApplicationRoles.UserApplicationRoleSearchResult.Select(x => x.Role.Id).ToList());
            return(model);
        }
예제 #13
0
        public ActionResult CusRoleManage(RoleSearchModel searchModel)
        {
            var          expr        = BuildSearchCriteria(searchModel);
            IRoleService roleService = ServiceFactory.Create <IRoleService>();
            var          roles       = roleService.GetEntitiesByPage(searchModel.PageIndex, 10, expr, false, t => t.ID);

            ViewBag.SearchModel = searchModel;

            IStoresService storesService   = ServiceFactory.Create <IStoresService>();
            List <Stores>  allStores       = storesService.GetEntities(t => t.ShopId == CurrentInfo.CurrentShop.ID && t.Disabled == false).ToList();
            SelectList     allStoresSelect = new SelectList(allStores, "ID", "StoreName", CurrentInfo.CurrentStore.ID);

            ViewData["allStoresSelect"] = allStoresSelect;
            ViewData["showStores"]      = CurrentInfo.IsShopAdmin;
            return(View(roles));
        }
예제 #14
0
        public ActionResult RoleList(RoleSearchModel model)
        {
            IPropertyRoleBLL propertyRoleBll = BLLFactory <IPropertyRoleBLL> .GetBLL("PropertyRoleBLL");

            //查询条件
            Expression <Func <T_PropertyRole, bool> > where = u => string.IsNullOrEmpty(model.RoleName) ? true : u.RoleName.Contains(model.RoleName);
            //获取当前用户所属小区ID
            int currentPlaceId = GetSessionModel().PropertyPlaceId.Value;

            //查询条件:所属物业小区为当前用户所在小区
            where = where.And(u => u.PropertyPlaceId == currentPlaceId);
            //排序
            var sortModel = this.SettingSorting("Id", false);
            var list      = propertyRoleBll.GetPageList(where, sortModel.SortName, sortModel.IsAsc, model.PageIndex);

            return(View(list));
        }
예제 #15
0
        public ActionResult RoleList(RoleSearchModel model)
        {
            ICompanyRoleBLL companyRoleBll = BLLFactory <ICompanyRoleBLL> .GetBLL("CompanyRoleBLL");

            //查询条件
            Expression <Func <T_CompanyRole, bool> > where = u => string.IsNullOrEmpty(model.RoleName) ? true : u.RoleName.Contains(model.RoleName);
            //获取当前用户所属总公司ID
            int currentCompanyId = GetSessionModel().CompanyId.Value;

            //查询条件:当前用户所在总公司
            where = where.And(u => u.CompanyId == currentCompanyId);
            //排序
            var sortModel = this.SettingSorting("Id", false);
            var list      = companyRoleBll.GetPageList(where, sortModel.SortName, sortModel.IsAsc, model.PageIndex);

            return(View(list));
        }
예제 #16
0
        public async Task <GridDataModel <RoleListModel> > GetAllAsync(RoleSearchModel searchModel)
        {
            var results = from roles in _dbContext.Role
                          where !roles.IsDeleted
                          select new RoleListModel
            {
                Name        = roles.Name,
                Description = roles.Description,
                RoleId      = roles.RoleId
            };

            if (!string.IsNullOrWhiteSpace(searchModel.Name))
            {
                results = results.Where(e => EF.Functions.Like(e.Name, $"%{ searchModel.Name }%"));
            }

            return(await results.ToGridDataAsync(searchModel));
        }
예제 #17
0
        /// <summary>
        /// the  method  for  Serach Roles  by  Condition
        /// </summary>
        /// <param name="command">GridCommand</param>
        /// <param name="searchModel">RoleSearchModel</param>
        /// <returns>searchStatementModel</returns>
        private SearchStatementModel PrepareSearchStatement(GridCommand command, RoleSearchModel searchModel)
        {
            string         whereStatement = string.Empty;
            IList <object> param          = new List <object>();

            HqlStatementHelper.AddLikeStatement("Code", searchModel.Code, HqlStatementHelper.LikeMatchMode.Start, "u", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Type", searchModel.Type, "u", ref whereStatement, param);

            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);
            SearchStatementModel searchStatementModel = new SearchStatementModel();

            searchStatementModel.SelectCountStatement = selectCountStatement;
            searchStatementModel.SelectStatement      = selectStatement;
            searchStatementModel.WhereStatement       = whereStatement;
            searchStatementModel.SortingStatement     = sortingStatement;
            searchStatementModel.Parameters           = param.ToArray <object>();
            return(searchStatementModel);
        }
예제 #18
0
        public JsonResult LoadRoleData(RoleSearchModel model, GridPager pager)
        {
            var pagerTuple = Tuple.Create(pager.SortColumn, pager.OrderBy, pager.Page, pager.Size, 0, 0);
            var result     = _component.GetRoleRecordList(model.RoleName, ref pagerTuple);

            pager.Count     = pagerTuple.Item5;
            pager.TotalPage = pagerTuple.Item6;

            var models = result.ToGridJson(pager, item => new
            {
                Id          = item.Id,
                RoleName    = item.Name,
                Description = item.Description == null ? "" : item.Description,
                CreateTime  = item.CreateTime.AddHours(8).ToString("yyyy-MM-dd HH:mm"),
                Authorize   = item.Id,
                Operate     = item.Id
            });

            return(Json(models, JsonRequestBehavior.AllowGet));
        }
예제 #19
0
        private string GetFilterString(RoleSearchModel searchModel)
        {
            var filterString = string.Empty;

            if (searchModel != null)
            {
                if (searchModel.ApplicationId > 0)
                {
                    filterString = ODataFilterConstant.Filter + $"ApplicationRoles/any(ap: ap/ApplicationId eq {searchModel.ApplicationId})";
                    if (!string.IsNullOrWhiteSpace(searchModel.FilterText))
                    {
                        if (!string.IsNullOrWhiteSpace(filterString))
                        {
                            filterString += $" and (contains(RoleName,'{searchModel.FilterText}') eq true";
                            filterString += $" or contains(RoleDescription,'{searchModel.FilterText}') eq true )";
                        }
                    }
                }
                AddPageSizeNumberAndSortingInFilterString(searchModel, ref filterString);
            }
            return(filterString);
        }
예제 #20
0
        public async Task <RoleListModel> PrepareRoleListModel(RoleSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            var roles = _userService.GetRoles(true);

            var model = new RoleListModel
            {
                Data = roles.PaginationByRequestModel(searchModel).Select(role =>
                {
                    var roleModel = role.ToModel <RoleModel>();
                    return(roleModel);
                }),
                Total = roles.Count
            };

            // sort
            if (searchModel.Sort != null && searchModel.Sort.Any())
            {
                foreach (var s in searchModel.Sort)
                {
                    model.Data = await model.Data.Sort(s.Field, s.Dir);
                }
            }

            // filter
            if (searchModel.Filter != null && searchModel.Filter.Filters != null && searchModel.Filter.Filters.Any())
            {
                var filter = searchModel.Filter;
                model.Data = await model.Data.Filter(filter);

                model.Total = model.Data.Count();
            }

            return(model);
        }
예제 #21
0
        public async Task <PagedListModel <ApplicationRole> > GetRoles(RoleSearchModel roleSearchModel)
        {
            PagedListModel <ApplicationRole> rolesPagedList = new PagedListModel <ApplicationRole>();

            int count = await roleManager.Roles
                        .Where(w => (string.IsNullOrEmpty(roleSearchModel.RoleName) || w.Name.Contains(roleSearchModel.RoleName)) &&
                               (!roleSearchModel.IsDeleted.HasValue || w.IsDeleted == roleSearchModel.IsDeleted ||
                                (roleSearchModel.IsDeleted == false && w.IsDeleted != true)))
                        .CountAsync();

            IList <ApplicationRole> roles = await roleManager.Roles
                                            .Where(w => (string.IsNullOrEmpty(roleSearchModel.RoleName) || w.Name.Contains(roleSearchModel.RoleName)) &&
                                                   (!roleSearchModel.IsDeleted.HasValue || w.IsDeleted == roleSearchModel.IsDeleted ||
                                                    (roleSearchModel.IsDeleted == false && w.IsDeleted != true)))
                                            .OrderByDescending(o => o.CreationDate)
                                            .Skip(roleSearchModel.PageIndex * config.Value.PageSize).Take(config.Value.PageSize)
                                            .ToListAsync();

            rolesPagedList.PagingModel = commonFunctions.PreparePagingModel(roleSearchModel.PageIndex, count);
            rolesPagedList.ListObj     = roles;

            return(rolesPagedList);
        }
예제 #22
0
 private RoleSearchModel InitializeRoleModel(RoleSearchModel model, int applicationId)
 {
     if (model == null)
     {
         model = new RoleSearchModel
         {
             SortColumn    = "Id",
             SortDirection = "Desc",
             PageSize      = 8,
             PageNumber    = 1
         };
     }
     else
     {
         if (string.IsNullOrWhiteSpace(model.SortColumn))
         {
             model.SortColumn    = "Id";
             model.SortDirection = "Desc";
         }
     }
     model.ApplicationId = applicationId;
     model.TargetGridId  = "ApplicationRoleGrid";
     return(model);
 }
예제 #23
0
        public async Task <IActionResult> Search(RoleSearchModel searchModel)
        {
            var response = await UserManagementHttpClient.PostJsonAsync <GridDataModel <RoleListModel> >(EndpointConstant.Roles.LIST, new RoleSearchModel());

            return(Json(response));
        }
예제 #24
0
 public async Task <GridDataModel <RoleListModel> > GetAllAsync(RoleSearchModel searchModel)
 {
     return(await _manager.GetAllAsync(searchModel));
 }
예제 #25
0
 public async Task <RoleSearchModel> GetRoles(RoleSearchModel model)
 {
     return(await _roleApiClient.GetRoles(model));
 }
예제 #26
0
        public ActionResult _AjaxList(GridCommand command, RoleSearchModel searchModel)
        {
            SearchStatementModel searchStatementModel = this.PrepareSearchStatement(command, searchModel);

            return(PartialView(GetAjaxPageData <Role>(searchStatementModel, command)));
        }
예제 #27
0
 public async Task <PagedModel <SysRoleDto> > SearchRoles([FromQuery] RoleSearchModel searchModel)
 {
     return(await _roleService.SearchRoles(searchModel));
 }
예제 #28
0
        /// <summary>
        /// 构建查询表达式
        /// </summary>
        /// <returns></returns>
        private Expression <Func <Role, Boolean> > BuildSearchCriteria(RoleSearchModel searchModel)
        {
            DynamicLambda <Role> bulider            = new DynamicLambda <Role>();
            Expression <Func <Role, Boolean> > expr = null;

            if (CurrentInfo.IsShopAdmin)
            {
                Expression <Func <Role, Boolean> > tmpStoreID = t => t.ShopsID == CurrentInfo.CurrentShop.ID;
                expr = bulider.BuildQueryAnd(expr, tmpStoreID);
            }
            else
            {
                Expression <Func <Role, Boolean> > tmpStoreID = t => t.StoreID == CurrentInfo.CurrentStore.ID;
                expr = bulider.BuildQueryAnd(expr, tmpStoreID);
            }

            if (!string.IsNullOrWhiteSpace(searchModel.RoleName))
            {
                Expression <Func <Role, Boolean> > tmp = t => t.Name.Contains(searchModel.RoleName);
                expr = bulider.BuildQueryAnd(expr, tmp);
            }

            if (!string.IsNullOrWhiteSpace(searchModel.Disabled))
            {
                var flage = searchModel.Disabled == "1" ? true : false;
                Expression <Func <Role, Boolean> > tmp = t => t.Disabled == flage;
                expr = bulider.BuildQueryAnd(expr, tmp);
            }

            if (!string.IsNullOrWhiteSpace(searchModel.startDate))
            {
                try
                {
                    DateTime dt = Convert.ToDateTime(searchModel.startDate);
                    Expression <Func <Role, Boolean> > tmp = t => t.CreateTime >= dt;
                    expr = bulider.BuildQueryAnd(expr, tmp);
                }
                catch
                {
                }
            }

            if (!string.IsNullOrWhiteSpace(searchModel.endDate))
            {
                try
                {
                    DateTime dt = Convert.ToDateTime(searchModel.endDate).AddDays(1);
                    Expression <Func <Role, Boolean> > tmp = t => t.CreateTime < dt;
                    expr = bulider.BuildQueryAnd(expr, tmp);
                }
                catch
                {
                }
            }

            //Expression<Func<Role, Boolean>> tmpSolid = t => t.IsDeleted == false;
            //expr = bulider.BuildQueryAnd(expr, tmpSolid);
            //如果不是管理员账号则 把“店长”这个角色隐藏掉,防止其他客户修改
            if (!CurrentInfo.IsAdministrator)
            {
                Expression <Func <Role, Boolean> > tmpAdmin = t => t.ID != 42;
                expr = bulider.BuildQueryAnd(expr, tmpAdmin);
            }

            return(expr);
        }