Refactor: remove strict checks and logging in finalization

Removed exception throwing and logging for failed report creation, email sending, and envelope finalization in FinalizeDocumentJob. Now, these methods are called without checking their return values. Also improved exception message for file export to include envelope Id and added null-forgiving operator to _config.ExportPath.
This commit is contained in:
2026-03-09 16:31:31 +01:00
parent 473358e2b9
commit 6f7b04a26e

View File

@@ -81,23 +81,18 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> 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<WorkerOptions> 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)