private void ControllerOnDocumentsBatchCollected(object sender, DocumentBatchEventArgs e) { var batch = e.DocumentBatch; var path = Path.Combine( configuration.BatchesFolder, string.Format(PDF_NAME_FORMAT, batch.Prefix, batch.MinSequenceNumber, batch.MaxSequenceNumber)); var joiner = documentsJoinerFactory.Invoke(cancellationSource.Token); using (var file = File.Create(path)) using (var joinedStream = joiner.Join(batch.Documents)) { joinedStream.CopyTo(file); } }
private void ControllerOnDocumentsBatchCollected(object sender, DocumentBatchEventArgs e) { Status = DocumentsJoinerStatus.BUILDING_BATCH; var batch = e.DocumentBatch; var joiner = documentsJoinerFactory.Invoke(CancellationSource.Token); using (var joinedStream = joiner.Join(batch.Documents)) using (var ms = new MemoryStream()) { joinedStream.Seek(0, SeekOrigin.Begin); joinedStream.CopyTo(ms); var message = ms.ToArray(); documentsQueue.SendMessage(message); } Status = DocumentsJoinerStatus.WAITING; }