public Role[] GetRoleList(RoleListRequestData request)
        {
            VBMCallDispatcher callDispatcher = new VBMCallDispatcher();

            RoleListResponse roleListResponse = new RoleListResponse();
            RoleListRequest  roleListRequest  = new RoleListRequest();

            if (request == null)
            {
                return(null);
            }
            try
            {
                roleListRequest.UserID      = request.UserID;
                roleListRequest.ChannelCode = Channel.GetChannelID(Channels.BackOffice);
                roleListResponse            = callDispatcher.DispatchAction <RoleListRequest, VeriBranch.Common.MessageDefinitions.RoleListResponse>(TransactionNameConstants.GetRoleListTransaction, MethodTypeEnum.Execute, Channels.SharedAspects, roleListRequest);
            }
            catch (Exception ex)
            {
                throw new FaultException(
                          ex.Message,
                          new FaultCode("Response Fault"));
            }

            if (roleListResponse == null)
            {
                return(null);
            }

            return(roleListResponse.Role);
        }
        public RoleListResponse GetRoles([FromBody] RoleRequest role)
        {
            RoleListResponse roleListResponse = new RoleListResponse();

            try
            {
                roleListResponse.Roles = new List <RoleRow>();
                var existedRole = _roleManager.Roles.Where((a => (a.Name == role.Name || string.IsNullOrEmpty(role.Name)) &&
                                                            (a.Id == role.Id || string.IsNullOrEmpty(role.Id)))).ToList();
                foreach (var item in existedRole)
                {
                    roleListResponse.Roles.Add(new RoleRow()
                    {
                        Id = item.Id, Name = item.Name
                    });
                }
                roleListResponse.ToSuccess <RoleListResponse>();
                roleListResponse.LstCount = existedRole.Count();
                return(roleListResponse);
            }
            catch (Exception ex)
            {
                return(roleListResponse.ToApiError <RoleListResponse>());
            }
        }
Пример #3
0
        public RoleListResponse Execute(RoleListRequest request)
        {
            RoleListResponse      roleListResponse = new RoleListResponse();
            IPagedList <RoleInfo> pagedRoles       = ServiceHelper.LoadService <IRoleService>().GetPagedRoles(request.PageNumber, request.PageSize);
            List <RoleModel>      list             = pagedRoles.Select <RoleInfo, RoleModel>((Func <RoleInfo, RoleModel>)(m => m.ToModel())).ToList <RoleModel>();

            roleListResponse.Roles = new PagedData <RoleModel>((IEnumerable <RoleModel>)list, (IPagedList)pagedRoles);
            return(roleListResponse);
        }
Пример #4
0
        public void RefreshData()
        {
            RoleListResponse roleListResponse = LocalApi.Execute(new RoleListRequest()
            {
                PageNumber = this.pager.PageNumber, PageSize = 10
            });

            this.pager.Setup(roleListResponse.Roles);
            this.dataGrid.ItemsSource = roleListResponse.Roles;
        }
Пример #5
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     RoleListResponse roleListResponse = LocalApi.Execute(new RoleListRequest() { PageNumber = 1, PageSize = int.MaxValue });
     //this.CRAFTWORK.ItemsSource = CraftWork.M6S.ToArrayList();
     //this.PROCESS.ItemsSource = Process.最终目检.ToArrayList();
     //this.QUARTERS.ItemsSource = Quarters.手动包胶.ToArrayList();
     //this.SEGMENT.ItemsSource = Segment.后工序.ToArrayList();
     this.model = new UserModel();
     CraftListResponse craftListResponse = LocalApi.GetCraftsList(new CraftListRequest());
     this.DataContext = this.model;
 }
Пример #6
0
        private string HandleNprintingRole(Model.Role role)
        {
            RoleListResponse nPrintingRole = _rolesApi.RolesGet(role.Name);

            //Role must exists NPrinting
            if (nPrintingRole.Data.Items != null && nPrintingRole.Data.Items.Count > 0)
            {
                RoleResponseDataItem npRole = nPrintingRole.Data.Items[0];
                return(npRole.Id.ToString());
            }
            return(null);
        }
        public async Task <RoleListResponse> getUserRolesByUserIdAsync(string UserId)
        {
            var lst    = Context.UserRoles.Where(a => a.UserId == UserId).AsQueryable();
            var result = Context.Roles.Join(lst, a => a.Id, b => b.RoleId, (a, b) => new RoleRow {
                Name = a.Name, Id = a.Id
            }).AsQueryable();
            RoleListResponse rowListResponse = new RoleListResponse();

            rowListResponse.Roles = new List <RoleRow>();
            rowListResponse.Roles = await result.ToListAsync();

            rowListResponse.LstCount = rowListResponse.Roles.Count();
            rowListResponse.ToSuccess <RoleListResponse>();
            return(rowListResponse);
        }
        public async Task <IActionResult> FindAll()
        {
            var result = new RoleListResponse();

            try
            {
                var cache = await cacheManager.Find <RoleListResponse>(MemoryCacheManager.ROLES_ALL);

                if (cache != null)
                {
                    return(cache.ToOk(this.Response));
                }

                var roles = await roleRepository.FindAll();

                result.Data = roles.ToList().Select(s => new RoleListResponseData {
                    Code = s.Code, Name = s.Name
                }).ToList();

                await cacheManager.Save(MemoryCacheManager.ROLES_ALL, result);

                return(result.ToOk());
            }
            catch (ArgumentException ex)
            {
                return(result.ToBadRequest(ex.Message));
            }
            catch (UnauthorizedAccessException ex)
            {
                await logRepository.AddError("RoleController.FindAll", ex);

                return(result.ToUnauthorized(ex.Message));
            }
            catch (Exception ex)
            {
                await logRepository.AddError("RoleController.FindAll", ex);

                return(result.ToInternalServerError(ex.Message));
            }
        }
Пример #9
0
        public IHttpActionResult GetRoleList(string ProjectGuid)
        {
            RoleListResponse response = new RoleListResponse()
            {
                IsSuccess      = true,
                MessageCode    = (int)ApiBaseErrorCode.API_SUCCESS,
                MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString(),
                RoleList       = new List <RoleModel>()
            };

            if (string.IsNullOrWhiteSpace(ProjectGuid))
            {
                response.IsSuccess      = false;
                response.MessageCode    = (int)ApiBaseErrorCode.API_PARAM_ERROR;
                response.MessageContent = "项目标识不能为空,请检查";
                return(Ok(response));
            }

            List <RolePermissionModel> rolelistmodel = rolemanager.GetRoleList(ProjectGuid);

            if (rolelistmodel != null)
            {
                foreach (var item in rolelistmodel)
                {
                    response.RoleList.Add(new RoleModel()
                    {
                        Guid     = item.Guid,
                        RoleName = item.RoleName
                    });
                }
            }
            else
            {
                response.IsSuccess      = false;
                response.MessageCode    = (int)ApiPersonnelErrorCode.API_DATA_NULL_ERROR;
                response.MessageContent = ApiPersonnelErrorCode.API_DATA_NULL_ERROR.ToString();
            }
            return(Ok(response));
        }