Clean up debug logging in FinalizeDocumentJob

Removed numerous debug-level log statements to reduce log verbosity and focus on warnings and information logs. Updated some log messages to use interpolated strings for clarity. Refactored GetAnnotationData to use C# collection expressions for improved code conciseness.
This commit is contained in:
2026-03-09 11:35:49 +01:00
parent a39ef6a0e2
commit d1e2840617

View File

@@ -43,7 +43,6 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
var gdPictureKey = _options.GdPictureLicenseKey; var gdPictureKey = _options.GdPictureLicenseKey;
tempFiles.Create(); tempFiles.Create();
var jobId = typeof(FinalizeDocumentJob).FullName; var jobId = typeof(FinalizeDocumentJob).FullName;
logger.LogDebug("Starting job {jobId}", jobId);
_config = await mediator.Send(new ReadDefaultConfigQuery(), cancel); _config = await mediator.Send(new ReadDefaultConfigQuery(), cancel);
@@ -73,8 +72,6 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
logger.LogInformation("Envelope [{id}] finalized!", envelope.Id); logger.LogInformation("Envelope [{id}] finalized!", envelope.Id);
} }
logger.LogDebug("Completed job {jobId} successfully!", jobId);
} }
private void Finalize(Envelope envelope) private void Finalize(Envelope envelope)
@@ -87,7 +84,6 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
throw new ArgumentNullException(nameof(EnvelopeData)); throw new ArgumentNullException(nameof(EnvelopeData));
} }
logger.LogDebug("Burning Annotations to pdf ...");
var burnedDocument = BurnAnnotationsToPdf(envelopeData); var burnedDocument = BurnAnnotationsToPdf(envelopeData);
if (burnedDocument is null) if (burnedDocument is null)
{ {
@@ -101,24 +97,16 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
throw new ApplicationException("Document Report could not be created"); throw new ApplicationException("Document Report could not be created");
} }
logger.LogDebug("Creating report..");
var report = reportCreator!.CreateReport(envelope); var report = reportCreator!.CreateReport(envelope);
logger.LogDebug("Report created!");
logger.LogDebug("Merging documents ...");
var mergedDocument = pdfMerger!.MergeDocuments(burnedDocument, report); var mergedDocument = pdfMerger!.MergeDocuments(burnedDocument, report);
logger.LogDebug("Documents merged!");
var outputDirectoryPath = Path.Combine(_config.ExportPath, _parentFolderUid); var outputDirectoryPath = Path.Combine(_config.ExportPath, _parentFolderUid);
logger.LogDebug("oOutputDirectoryPath is {outputDirectoryPath}", outputDirectoryPath);
if (!Directory.Exists(outputDirectoryPath)) if (!Directory.Exists(outputDirectoryPath))
{
logger.LogDebug("Directory not existing. Creating ... ");
Directory.CreateDirectory(outputDirectoryPath); Directory.CreateDirectory(outputDirectoryPath);
}
var outputFilePath = Path.Combine(outputDirectoryPath, $"{envelope.Uuid}.pdf"); var outputFilePath = Path.Combine(outputDirectoryPath, $"{envelope.Uuid}.pdf");
logger.LogDebug("Writing finalized Pdf to disk..");
logger.LogInformation("Output path is [{outputFilePath}]", outputFilePath); logger.LogInformation("Output path is [{outputFilePath}]", outputFilePath);
try try
@@ -131,17 +119,13 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
throw new ExportDocumentException("Could not export final document to disk!", ex); throw new ExportDocumentException("Could not export final document to disk!", ex);
} }
logger.LogDebug("Writing EB-bytes to database...");
UpdateFileDb(outputFilePath, envelope.Id); UpdateFileDb(outputFilePath, envelope.Id);
if (!SendFinalEmails(envelope)) if (!SendFinalEmails(envelope))
{
throw new ApplicationException("Final emails could not be sent!"); throw new ApplicationException("Final emails could not be sent!");
}
logger.LogInformation("Report-mails successfully sent!"); logger.LogInformation("Report-mails successfully sent!");
logger.LogDebug("Setting envelope status..");
if (actionService?.FinalizeEnvelope(envelope) == false) if (actionService?.FinalizeEnvelope(envelope) == false)
{ {
logger.LogWarning("Envelope could not be finalized!"); logger.LogWarning("Envelope could not be finalized!");
@@ -185,23 +169,17 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
var mailToReceivers = (FinalEmailType)(envelope.FinalEmailToReceivers ?? 0); var mailToReceivers = (FinalEmailType)(envelope.FinalEmailToReceivers ?? 0);
if (mailToCreator != FinalEmailType.No) if (mailToCreator != FinalEmailType.No)
{
logger?.LogDebug("Sending email to creator ...");
SendFinalEmailToCreator(envelope, mailToCreator); SendFinalEmailToCreator(envelope, mailToCreator);
}
else else
{ logger?.LogWarning("No SendFinalEmailToCreator - oMailToCreator [{mailToCreator}] <> [{noFinalEmailType}] ", mailToCreator, FinalEmailType.No);
logger?.LogWarning("No SendFinalEmailToCreator - oMailToCreator [{0}] <> [{1}] ", mailToCreator, FinalEmailType.No);
}
if (mailToReceivers != FinalEmailType.No) if (mailToReceivers != FinalEmailType.No)
{ {
logger?.LogDebug("Sending emails to receivers..");
SendFinalEmailToReceivers(envelope, mailToReceivers); SendFinalEmailToReceivers(envelope, mailToReceivers);
} }
else else
{ {
logger?.LogWarning("No SendFinalEmailToReceivers - oMailToCreator [{0}] <> [{1}] ", mailToReceivers, FinalEmailType.No); logger?.LogWarning("No SendFinalEmailToReceivers - oMailToCreator [{mailToReceivers}] <> [{noFinalEmailType}] ", mailToReceivers, FinalEmailType.No);
} }
return true; return true;
@@ -210,11 +188,10 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
private bool SendFinalEmailToCreator(Envelope envelope, FinalEmailType mailToCreator) private bool SendFinalEmailToCreator(Envelope envelope, FinalEmailType mailToCreator)
{ {
var includeAttachment = SendFinalEmailWithAttachment(mailToCreator); var includeAttachment = SendFinalEmailWithAttachment(mailToCreator);
logger?.LogDebug("Attachment included: [{0}]", includeAttachment);
if (actionService?.CompleteEnvelope(envelope) == false) if (actionService?.CompleteEnvelope(envelope) == false)
{ {
logger?.LogError(new Exception("CompleteEnvelope failed"), "Envelope could not be completed for receiver [{0}]", envelope.User?.Email); logger?.LogError(new Exception("CompleteEnvelope failed"), "Envelope could not be completed for receiver [{email}]", envelope.User?.Email);
return false; return false;
} }
@@ -224,7 +201,6 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
private bool SendFinalEmailToReceivers(Envelope envelope, FinalEmailType mailToReceivers) private bool SendFinalEmailToReceivers(Envelope envelope, FinalEmailType mailToReceivers)
{ {
var includeAttachment = SendFinalEmailWithAttachment(mailToReceivers); var includeAttachment = SendFinalEmailWithAttachment(mailToReceivers);
logger?.LogDebug("Attachment included: [{0}]", includeAttachment);
foreach (var receiver in envelope.EnvelopeReceivers ?? Enumerable.Empty<EnvelopeReceiver>()) foreach (var receiver in envelope.EnvelopeReceivers ?? Enumerable.Empty<EnvelopeReceiver>())
{ {
@@ -257,9 +233,7 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
} }
else else
{ {
logger?.LogDebug("we got bytes..");
inputPath = _config!.DocumentPath; inputPath = _config!.DocumentPath;
logger?.LogDebug("oInputPath: {0}", _config.DocumentPath);
} }
if (envelopeData.DocAsByte is null) if (envelopeData.DocAsByte is null)
@@ -314,8 +288,6 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
EnvelopeUuid = row.ItemEx("ENVELOPE_UUID", string.Empty) EnvelopeUuid = row.ItemEx("ENVELOPE_UUID", string.Empty)
}; };
logger?.LogDebug("Document path: [{0}]", data.DocumentPath);
return data; return data;
} }
@@ -324,8 +296,6 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
var sql = $"SELECT VALUE FROM TBSIG_DOCUMENT_STATUS WHERE ENVELOPE_ID = {envelopeId}"; var sql = $"SELECT VALUE FROM TBSIG_DOCUMENT_STATUS WHERE ENVELOPE_ID = {envelopeId}";
var table = _database!.GetDatatable(sql); var table = _database!.GetDatatable(sql);
return table.Rows.Cast<DataRow>() return [.. table.Rows.Cast<DataRow>().Select(r => r.ItemEx("VALUE", string.Empty))];
.Select(r => r.ItemEx("VALUE", string.Empty))
.ToList();
} }
} }