private void SearchRequest(SearchRequestEvent searchRequestEvent)
        {
            searchRequestEvent.Search.SearchOptions.OrderBy = "ReferenceKey";

            this.entityService.ExecuteAsyncSearchRD(
                this.search = searchRequestEvent.Search,
                response =>
            {
                ReferenceDataList searchResults             = response;
                Dictionary <string, string> combinedResults = new Dictionary <string, string>();
                foreach (var rd in searchResults)
                {
                    if (combinedResults.ContainsKey(rd.ReferenceKey))
                    {
                        combinedResults[rd.ReferenceKey] = combinedResults[rd.ReferenceKey] + "|" + rd.Value;
                    }
                    else
                    {
                        combinedResults.Add(rd.ReferenceKey, rd.Value);
                    }
                }

                this.ReferenceDatas =
                    new ObservableCollection <ReferenceDataViewModel>(
                        combinedResults.Select(
                            x => new ReferenceDataViewModel(x.Key, x.Value, this.eventAggregator))
                        .OrderBy(y => y.ReferenceKey));
            },
                this.eventAggregator);
        }
コード例 #2
0
        public void SetUp()
        {
            _sendEndpointProviderMock = new Mock <ISendEndpointProvider>();

            _rabbitMqConfigurationMock = new Mock <IOptions <RabbitMqConfiguration> >();

            _sendEndpointMock = new Mock <ISendEndpoint>();

            _loggerMock = new Mock <ILogger <SearchRequestEventPublisher> >();

            RabbitMqConfiguration rabbitMqConfiguration = new RabbitMqConfiguration();

            rabbitMqConfiguration.Host     = "localhost";
            rabbitMqConfiguration.Port     = 15672;
            rabbitMqConfiguration.Username = "******";
            rabbitMqConfiguration.Password = "******";

            _sendEndpointProviderMock
            .Setup(x => x.GetSendEndpoint(It.IsAny <Uri>()))
            .Returns(Task.FromResult(_sendEndpointMock.Object));

            _rabbitMqConfigurationMock.Setup(x => x.Value).Returns(rabbitMqConfiguration);

            _sendEndpointMock.Setup(x => x.Send <SearchRequestFailedEvent>(It.IsAny <SearchRequestFailed>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(_sendEndpointMock));

            _baseEvent = new FakeSearchRequestEvent()
            {
                SearchRequestKey = "key"
            };

            _sut = new SearchRequestEventPublisher(_sendEndpointProviderMock.Object, _rabbitMqConfigurationMock.Object, _loggerMock.Object);
        }
コード例 #3
0
 public SearchRequestNotificationEvent(SearchRequestEvent baseEvent)
 {
     this.RequestId        = baseEvent.RequestId;
     this.SearchRequestId  = baseEvent.SearchRequestId;
     this.TimeStamp        = DateTime.Now;
     this.SearchRequestKey = baseEvent.SearchRequestKey;
 }
コード例 #4
0
 public async Task PublishSearchRequestFailed(SearchRequestEvent baseEvent, string message)
 {
     if (baseEvent == null)
     {
         throw new ArgumentNullException(nameof(baseEvent));
     }
     await PublishFailed(baseEvent, message);
 }
コード例 #5
0
 public SearchRequestSavedEvent(SearchRequestEvent baseEvent)
 {
     this.RequestId        = baseEvent.RequestId;
     this.SearchRequestId  = baseEvent.SearchRequestId;
     this.TimeStamp        = DateTime.Now;
     this.SearchRequestKey = baseEvent.SearchRequestKey;
     this.Action           = baseEvent.Action;
 }
コード例 #6
0
        public async Task PublishSearchRequestRejected(SearchRequestEvent baseEvent, IEnumerable <ValidationResult> reasons)
        {
            if (baseEvent == null)
            {
                throw new ArgumentNullException(nameof(baseEvent));
            }

            await PublishRejected(baseEvent, reasons);
        }
コード例 #7
0
 public SearchRequestRejectedEvent(SearchRequestEvent baseEvent)
 {
     this.RequestId        = baseEvent.RequestId;
     this.SearchRequestId  = baseEvent.SearchRequestId;
     this.TimeStamp        = DateTime.Now;
     this.SearchRequestKey = baseEvent.SearchRequestKey;
     this.Action           = baseEvent.Action;
     this.ProviderProfile  = baseEvent.ProviderProfile;
 }
コード例 #8
0
        private async Task PublishRejected(SearchRequestEvent baseEvent, IEnumerable <ValidationResult> reasons)
        {
            var endpoint = await _sendEndpointProvider.GetSendEndpoint(new Uri($"rabbitmq://{this._rabbitMqConfiguration.Host}:{this._rabbitMqConfiguration.Port}/{nameof(SearchRequestRejected)}_queue"));

            _logger.LogInformation($"SearchRequestRejected has been published to {endpoint.ToString()}");
            await endpoint.Send <SearchRequestRejected>(new SearchRequestRejectedEvent(baseEvent)
            {
                Reasons = reasons
            });
        }
コード例 #9
0
        private async Task PublishFailed(SearchRequestEvent baseEvent, string message)
        {
            var endpoint = await _sendEndpointProvider.GetSendEndpoint(new Uri($"rabbitmq://{this._rabbitMqConfiguration.Host}:{this._rabbitMqConfiguration.Port}/{nameof(SearchRequestFailed)}_queue"));

            _logger.LogInformation($"SearchRequestFailed has been published to {endpoint.ToString()}");
            await endpoint.Send <SearchRequestFailed>(new SearchRequestFailedEvent(baseEvent)
            {
                Cause = message
            });
        }
コード例 #10
0
        private void SearchRequest(SearchRequestEvent searchRequestEvent)
        {
            searchRequestEvent.Search.SearchOptions.OrderBy = "LastName";

            this.entityService.ExecuteAsyncSearch <Person>(
                this.search = searchRequestEvent.Search,
                response =>
            {
                IList <Person> searchResults = response;
                this.Persons =
                    new ObservableCollection <PersonViewModel>(
                        searchResults.Select(
                            x => new PersonViewModel(new EntityWithETag <Person>(x, null), this.eventAggregator))
                        .OrderBy(y => y.Name));
            },
                this.eventAggregator);
        }