示例#1
0
        public async Task Execute(IJobExecutionContext context)
        {
            _logger.LogInformation("Search Request started!");

            var cts = new CancellationTokenSource();

            try
            {
                List <SSG_SearchApiRequest> requestList = await GetAllReadyForSearchAsync(cts.Token);

                foreach (SSG_SearchApiRequest ssgSearchRequest in requestList)
                {
                    _logger.LogDebug(
                        $"Attempting to post person search for request {ssgSearchRequest.SearchApiRequestId}");

                    var result = await _searchApiClient.SearchAsync(
                        _mapper.Map <PersonSearchRequest>(ssgSearchRequest),
                        $"{ssgSearchRequest.SearchApiRequestId}",
                        cts.Token);

                    _logger.LogInformation($"Successfully posted person search id:{result.Id}");

                    await MarkInProgress(ssgSearchRequest, cts.Token);
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message, null);
            }
        }
示例#2
0
        public async Task <IActionResult> Search(string keyword)
        {
            var viewModel    = new List <SearchViewModel>();
            var searchResult = await _searchApiClient.SearchAsync(keyword).ConfigureAwait(false);

            searchResult.ForEach(advertDocument =>
            {
                var viewModelItem = _mapper.Map <SearchViewModel>(advertDocument);
                viewModel.Add(viewModelItem);
            });
            return(View("SearchResults", viewModel));
        }
示例#3
0
        public async Task Execute(IJobExecutionContext context)
        {
            _logger.LogInformation("Retreiving failed Search Request started!");

            var cts = new CancellationTokenSource();

            try
            {
                List <SSG_SearchApiRequest> requestList = await GetAllFailedForSearchAsync(cts.Token);

                foreach (SSG_SearchApiRequest ssgSearchRequest in requestList)
                {
                    if (ssgSearchRequest.SearchRequestId != Guid.Empty)
                    {
                        try
                        {
                            using (LogContext.PushProperty("SearchRequestKey", $"{ssgSearchRequest.SearchRequest?.FileId}_{ssgSearchRequest.SequenceNumber}"))
                            {
                                _logger.LogDebug(
                                    $"Attempting to post failed person search for request {ssgSearchRequest.SearchApiRequestId}");

                                SSG_SearchApiRequest request = _register.FilterDuplicatedIdentifier(ssgSearchRequest);

                                bool registerSuccessfully = await _register.RegisterSearchApiRequest(request);

                                if (registerSuccessfully)
                                {
                                    var result = await _searchApiClient.SearchAsync(
                                        _mapper.Map <PersonSearchRequest>(request),
                                        $"{request.SearchApiRequestId}",
                                        cts.Token);

                                    _logger.LogInformation($"Successfully posted person search id:{result.Id}");
                                }
                                else
                                {
                                    throw new RegisterFailedException("Register SearchApiRequest to cache failed.");
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            _logger.LogError(e, e.Message, null);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message, null);
            }
        }