Beispiel #1
0
        public async Task WhenRequestQueryFileShareServiceData_ThenReturnsFulfilmentDataResponse()
        {
            A.CallTo(() => fakefileShareService.GetBatchInfoBasedOnProducts(A <List <Products> > .Ignored, A <SalesCatalogueServiceResponseQueueMessage> .Ignored, A <CancellationTokenSource> .Ignored, A <CancellationToken> .Ignored, A <string> .Ignored)).Returns(GetSearchBatchResponse());

            var result = await fulfilmentFileShareService.QueryFileShareServiceData(GetProductdetails(), GetScsResponseQueueMessage(), null, CancellationToken.None, string.Empty);

            Assert.IsNotNull(result);
            Assert.IsInstanceOf(typeof(List <FulfilmentDataResponse>), result);

            Assert.AreEqual("Received Fulfilment Data Successfully!!!!", "Received Fulfilment Data Successfully!!!!");
        }
Beispiel #2
0
        public async Task <List <FulfilmentDataResponse> > QueryFileShareServiceData(List <Products> products, SalesCatalogueServiceResponseQueueMessage message, CancellationTokenSource cancellationTokenSource, CancellationToken cancellationToken, string exchangeSetRootPath)
        {
            if (products != null && products.Any())
            {
                var batchProducts    = SliceFileShareServiceProducts(products);
                var listBatchDetails = new List <BatchDetail>();
                int fileShareServiceSearchQueryCount = 0;
                foreach (var item in batchProducts)
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        var productDetail = new StringBuilder();
                        foreach (var productitem in item)
                        {
                            productDetail.AppendFormat("\n Product/CellName:{0}, EditionNumber:{1} and UpdateNumbers:[{2}]", productitem.ProductName, productitem.EditionNumber.ToString(), string.Join(",", productitem?.UpdateNumbers.Select(a => a.Value.ToString())));
                        }
                        logger.LogError(EventIds.CancellationTokenEvent.ToEventId(), "Operation cancelled as IsCancellationRequested flag is true while searching ENC files from File Share Service with cancellationToken:{cancellationTokenSource.Token} at time:{DateTime.UtcNow} and productdetails:{productDetail.ToString()} and BatchId:{batchId} and _X-Correlation-ID:{correlationId}", JsonConvert.SerializeObject(cancellationTokenSource.Token), DateTime.UtcNow, productDetail.ToString(), message.BatchId, message.CorrelationId);
                        throw new OperationCanceledException();
                    }
                    var result = await fileShareService.GetBatchInfoBasedOnProducts(item, message, cancellationTokenSource, cancellationToken, exchangeSetRootPath);

                    listBatchDetails.AddRange(result.Entries);
                    fileShareServiceSearchQueryCount += result.QueryCount;
                }

                var fulFilmentDataResponse = SetFulfilmentDataResponse(new SearchBatchResponse()
                {
                    Entries = listBatchDetails
                });
                if (fulFilmentDataResponse.Count > 0)
                {
                    fulFilmentDataResponse.FirstOrDefault().FileShareServiceSearchQueryCount = fileShareServiceSearchQueryCount;
                }
                return(fulFilmentDataResponse);
            }
            return(null);
        }