public async Task <bool> CreateCatalogFile(string batchId, string exchangeSetRootPath, string correlationId, List <FulfilmentDataResponse> listFulfilmentData, SalesCatalogueDataResponse salesCatalogueDataResponse, SalesCatalogueProductResponse salesCatalogueProductResponse) { var catBuilder = new Catalog031BuilderFactory().Create(); var readMeFileName = Path.Combine(exchangeSetRootPath, fileShareServiceConfig.Value.ReadMeFileName); var outputFileName = Path.Combine(exchangeSetRootPath, fileShareServiceConfig.Value.CatalogFileName); if (fileSystemHelper.CheckFileExists(readMeFileName)) { catBuilder.Add(new CatalogEntry() { FileLocation = fileShareServiceConfig.Value.ReadMeFileName, Implementation = "TXT" }); } if (listFulfilmentData != null && listFulfilmentData.Any()) { listFulfilmentData = listFulfilmentData.OrderBy(a => a.ProductName).ThenBy(b => b.EditionNumber).ThenBy(c => c.UpdateNumber).ToList(); List <Tuple <string, string> > orderPreference = new List <Tuple <string, string> > { new Tuple <string, string>("application/s63", "BIN"), new Tuple <string, string>("text/plain", "ASC"), new Tuple <string, string>("text/plain", "TXT"), new Tuple <string, string>("image/tiff", "TIF") }; foreach (var listItem in listFulfilmentData) { CreateCatalogEntry(listItem, orderPreference, catBuilder, salesCatalogueDataResponse, salesCatalogueProductResponse, exchangeSetRootPath, batchId, correlationId); } } var cat031Bytes = catBuilder.WriteCatalog(fileShareServiceConfig.Value.ExchangeSetFileFolder); fileSystemHelper.CheckAndCreateFolder(exchangeSetRootPath); fileSystemHelper.CreateFileContentWithBytes(outputFileName, cat031Bytes); await Task.CompletedTask; if (fileSystemHelper.CheckFileExists(outputFileName)) { return(true); } else { logger.LogError(EventIds.CatalogFileIsNotCreated.ToEventId(), "Error in creating catalog.031 file for BatchId:{BatchId} and _X-Correlation-ID:{CorrelationId}", batchId, correlationId); throw new FulfilmentException(EventIds.CatalogFileIsNotCreated.ToEventId()); } }