diff --git a/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocumentJob.cs b/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocumentJob.cs index 95693b04..94faa23b 100644 --- a/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocumentJob.cs +++ b/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocumentJob.cs @@ -81,23 +81,18 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration var burnedDocument = pdfBurner!.BurnAnnotsToPDF(envelope.DefaultDocument.ByteData!, annotations, envelope.Id) ?? throw new ApplicationException("Document could not be finalized"); - if (!actionService.CreateReport(envelope, cancel)) - { - logger.LogWarning("Document Report could not be created!"); - throw new ApplicationException("Document Report could not be created"); - } + actionService.CreateReport(envelope, cancel); var report = reportCreator!.CreateReport(envelope); var mergedDocument = pdfMerger!.MergeDocuments(burnedDocument, report); - var outputDirectoryPath = Path.Combine(_config.ExportPath, _parentFolderUid); + var outputDirectoryPath = Path.Combine(_config!.ExportPath, _parentFolderUid); if (!Directory.Exists(outputDirectoryPath)) Directory.CreateDirectory(outputDirectoryPath); var outputFilePath = Path.Combine(outputDirectoryPath, $"{envelope.Uuid}.pdf"); - logger.LogInformation("Output path is [{outputFilePath}]", outputFilePath); try { @@ -105,23 +100,15 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration } catch (Exception ex) { - logger.LogWarning("Could not export final document to disk!"); - throw new ExportDocumentException("Could not export final document to disk!", ex); + throw new ExportDocumentException("Could not export final document to disk. Envelope Id is " + envelope.Id, ex); } var outputFile = await File.ReadAllBytesAsync(outputFilePath, cancel); await envRepo.UpdateAsync(e => e.DocResult = outputFile, e => e.Id == envelope.Id, cancel); - if (!SendFinalEmails(envelope)) - throw new ApplicationException("Final emails could not be sent!"); + SendFinalEmails(envelope); - logger.LogInformation("Report-mails successfully sent!"); - - if (actionService?.FinalizeEnvelope(envelope) == false) - { - logger.LogWarning("Envelope could not be finalized!"); - throw new ApplicationException("Envelope could not be finalized"); - } + actionService?.FinalizeEnvelope(envelope); } private bool SendFinalEmails(Envelope envelope)