private void MapEntityListResponse(EntityListResponse entityListResponse) { if (entityListResponse.Result.Subjects != null && entityListResponse.Result.Subjects.Count != 0) { entityListResponse.Result.Subjects .ForEach(subject => subject.AccountNumbers .ForEach(accountNumber => subject.BankAccountNumbers.Add(new AccountNumber { Number = accountNumber }))); } }
private void OnGetEntities <T>(EntityListResponse <T> response) where T : EntityBase { if (response.Status == ResponseStatus.Success) { _logger.Log(LogLevel.Debug, string.Format("GetEntities {0}: Succeeded", response.Id.ToString())); _logger.Log(LogLevel.Debug, string.Format("{0} entities of type {1} retrieved", response.Entities.Count, typeof(T).Name)); } else { string errors = null; response.Errors.ToList().ForEach(x => { errors = errors + x + "/n"; }); _logger.Log(LogLevel.Error, string.Format("EntitiesUpdated {0}: Failed{2}Errors:{2}{1}", response.Id.ToString(), errors, Environment.NewLine)); } }
public EntityListResponse <ProjectOwner> Get(Expression <Func <ProjectOwner, bool> > filter = null) { EntityListResponse <ProjectOwner> serviceResponse = new EntityListResponse <ProjectOwner>(); try { serviceResponse.EntityList = _repository.Get(filter).ToList(); serviceResponse.SetStatus(ResponseCode.SUCCESS); return(serviceResponse); } catch (Exception) { serviceResponse.SetStatus(ResponseCode.SYSTEM_ERROR); return(serviceResponse); } }
private void OnGetEntitiesResponse <T>(EntityListResponse <T> response, MessageReceivedInfo info, TaskCompletionSource <EntityListResponse <T> > tcs) where T : EntityBase { //Check if we're passing on the result and its one of ours if (_pendingRequests.ContainsKey(response.Id) && tcs != null) { //Remove from pending _pendingRequests.Remove(response.Id); //Unsubscribe from temporary queue and delete it //Doesn't appear to be valid way to unsubscribe so just delete var queueName = response.PrivateResponseQueue; _busManager.DeleteQueue(_busManager.TopicExchange, queueName); _ownedTemporaryQueues.Remove(_ownedTemporaryQueues.SingleOrDefault(q => q == queueName)); //Set result on task completion source tcs.SetResult(response); } }
public void GetEntities(EntityListRequest <T> request) { var responseQueue = request.PrivateResponseQueue; var filter = request.Filter.GetFilter(); var navigationProperties = request.NavigationProperties.GetNavigationProperties(); var user = request.User; var requestId = request.Id; EntityListResponse <T> response = null; IList <T> entities = null; var result = false; //Use generic data accessor using (var dataAccessor = new DataAccessor <T>(user)) { try { entities = dataAccessor.GetEntities(filter, navigationProperties); result = true; } catch (Exception ex) { //Cast as our own exception to get base message var exception = new BaseDbException(ex); _logger.Log(LogLevel.Error, ex); result = false; response = new EntityListResponse <T> { Errors = new string[] { exception.Message }.ToList(), Id = requestId, NavigationProperties = request.NavigationProperties, Status = ResponseStatus.Failure }; } } if (result) { _logger.Log(LogLevel.Info, string.Format("GetEntities request Id {0} completed successfully.", requestId)); response = new EntityListResponse <T> { Entities = entities.ToList(), Id = requestId, NavigationProperties = request.NavigationProperties, Status = ResponseStatus.Success }; } EntitiesGot(response); }
public BaseResponse Authentication(AuthenticationRequest request) { BaseResponse baseResponse = new BaseResponse(); try { EntityListResponse <ProjectInfo> autResult = _projectInfoService.Get(t => t.ProjectCode == request.ProjectCode && t.Password == request.Password); if (autResult.Code != (int)ResponseCode.SUCCESS || autResult.EntityList.Count < 1) { baseResponse.SetStatus(ResponseCode.INVALID_PROJECT_CODE); return(baseResponse); } baseResponse.SetStatus(ResponseCode.SUCCESS); return(baseResponse); } catch (Exception ex) { baseResponse.SetStatus(ResponseCode.SYSTEM_ERROR); return(baseResponse); } }
public IActionResult GetRecordsByEntityName(string entityName) { //TODO - Test data var response = new EntityListResponse(); response.Success = true; var responseObj = new EntityList(); responseObj.Entities = new List <Entity>(); response.Object = responseObj; switch (entityName) { case "role": #region ///////////////////////// ROLES //////////////////////// var roles = new List <Entity>(); var role = new Entity(); //Add Administrator role = new Entity(); role.Id = new Guid("0b3fa332-6018-46e4-a70c-297b30c2b19c"); role.Name = "administrator"; role.Label = "Administrator"; role.LabelPlural = "Administrators"; roles.Add(role); //Add Authenticated users role = new Entity(); role.Id = new Guid("5cdf06ed-a627-4a71-a73b-43bdd390dbf1"); role.Name = "authenticated"; role.Label = "Authenticated user"; role.LabelPlural = "Authenticated users"; roles.Add(role); //Add Guest role = new Entity(); role.Id = new Guid("5cdf06ed-a627-4a71-a73b-43bdd390db22"); role.Name = "guest"; role.Label = "Guest"; role.LabelPlural = "Guests"; roles.Add(role); responseObj.Entities = roles; break; #endregion case "area": ///////////////////////// AREA //////////////////////// var areas = new List <Entity>(); var area = new Entity(); //Entity 1 area = new Entity(); area.Id = Guid.NewGuid(); area.Name = "test"; area.Label = "Test"; area.Weight = 4; area.IconName = "cloud"; areas.Add(area); responseObj.Entities = areas; break; } Thread.Sleep(100); //response.Object = siteMeta; return(Json(response)); }
private void EntitiesGot(EntityListResponse <T> entitiesGot) { //response queue won't be in our management bus queue cache so create it first (even though queue should exist on rabbit mq) _busManager.CreateQueue(_busManager.TopicExchange, entitiesGot.PrivateResponseQueue); _busManager.Publish(_busManager.TopicExchange, entitiesGot.PrivateResponseQueue, entitiesGot); }