Refactor envelope finalization into a private method

Extracted envelope finalization logic from the foreach loop into a new private Finalize(Envelope envelope) method. This improves code readability and maintainability by encapsulating all steps of the finalization process without changing functionality.
This commit is contained in:
2026-03-09 11:25:36 +01:00
parent cc4a7d8c20
commit 7d620988d8

View File

@@ -55,12 +55,25 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
if (envelopes.Count > 0)
logger.LogInformation("Found [{count}] completed envelopes.", envelopes.Count);
var total = envelopes.Count;
var current = 1;
foreach (var envelope in envelopes)
{
try
{
Finalize(envelope);
}
catch (Exception ex)
{
logger.LogError(ex);
logger.LogWarning(ex, "Unhandled exception while working envelope [{id}]", envelope.Id);
}
logger.LogInformation("Envelope [{id}] finalized!", envelope.Id);
}
logger.LogDebug("Completed job {jobId} successfully!", jobId);
}
private void Finalize(Envelope envelope)
{
var envelopeData = GetEnvelopeData(envelope.Id);
@@ -131,18 +144,6 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
throw new ApplicationException("Envelope could not be finalized");
}
}
catch (Exception ex)
{
logger.LogError(ex);
logger.LogWarning(ex, "Unhandled exception while working envelope [{id}]", envelope.Id);
}
current += 1;
logger.LogInformation("Envelope [{id}] finalized!", envelope.Id);
}
logger.LogDebug("Completed job {jobId} successfully!", jobId);
}
private void UpdateFileDb(string filePath, long envelopeId)
{