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:
@@ -55,12 +55,25 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
|
|||||||
if (envelopes.Count > 0)
|
if (envelopes.Count > 0)
|
||||||
logger.LogInformation("Found [{count}] completed envelopes.", envelopes.Count);
|
logger.LogInformation("Found [{count}] completed envelopes.", envelopes.Count);
|
||||||
|
|
||||||
var total = envelopes.Count;
|
|
||||||
var current = 1;
|
|
||||||
|
|
||||||
foreach (var envelope in envelopes)
|
foreach (var envelope in envelopes)
|
||||||
{
|
{
|
||||||
try
|
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);
|
var envelopeData = GetEnvelopeData(envelope.Id);
|
||||||
|
|
||||||
@@ -131,18 +144,6 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
|
|||||||
throw new ApplicationException("Envelope could not be finalized");
|
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)
|
private void UpdateFileDb(string filePath, long envelopeId)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user