public async Task <bool> Callback(CancellationToken cancellationToken) { _logger.LogInfo("Reporting callback invoked"); var reportZipFileKey = $"R{_reportServiceContext.ReturnPeriod:00}_{_reportServiceContext.Ukprn}_Reports.zip"; cancellationToken.ThrowIfCancellationRequested(); MemoryStream memoryStream = new MemoryStream(); var zipFileExists = await _streamableKeyValuePersistenceService.ContainsAsync(reportZipFileKey, cancellationToken); if (zipFileExists) { if (_reportServiceContext.Tasks.Any(x => x.CaseInsensitiveEquals(ReportTaskNameConstants.TaskClearPeriodEndDASZip))) { await _streamableKeyValuePersistenceService.RemoveAsync(reportZipFileKey, cancellationToken); } else { await _streamableKeyValuePersistenceService.GetAsync(reportZipFileKey, memoryStream, cancellationToken); } } using (memoryStream) { using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Update, true)) { await ExecuteTasks(_reportServiceContext, archive, cancellationToken); } await _streamableKeyValuePersistenceService.SaveAsync(reportZipFileKey, memoryStream, cancellationToken); } return(true); }