diff --git a/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocumentJob.cs b/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocumentJob.cs index 2612b7e1..ff7b6940 100644 --- a/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocumentJob.cs +++ b/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocumentJob.cs @@ -212,84 +212,4 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration { return type == FinalEmailType.YesWithAttachment; } - - private byte[] BurnAnnotationsToPdf(EnvelopeData envelopeData) - { - var envelopeId = envelopeData.EnvelopeId; - - logger?.LogInformation("Burning [{0}] signatures", envelopeData.AnnotationData.Count); - var annotations = envelopeData.AnnotationData; - var inputPath = string.Empty; - if (envelopeData.DocAsByte is null) - { - inputPath = envelopeData.DocumentPath; - logger?.LogInformation("Input path: [{0}]", inputPath); - } - else - { - inputPath = _config!.DocumentPath; - } - - if (envelopeData.DocAsByte is null) - { - var directorySource = Path.GetDirectoryName(inputPath) ?? string.Empty; - var split = directorySource.Split('\\'); - _parentFolderUid = split[^1]; - } - else - { - _parentFolderUid = envelopeData.EnvelopeUuid; - } - - logger?.LogInformation("ParentFolderUID: [{0}]", _parentFolderUid); - byte[] inputDocumentBuffer; - if (envelopeData.DocAsByte is not null) - { - inputDocumentBuffer = envelopeData.DocAsByte; - } - else - { - try - { - inputDocumentBuffer = File.ReadAllBytes(inputPath); - } - catch (Exception ex) - { - throw new BurnAnnotationException("Source document could not be read from disk!", ex); - } - } - - return pdfBurner!.BurnAnnotsToPDF(inputDocumentBuffer, annotations, envelopeId); - } - - private EnvelopeData? GetEnvelopeData(int envelopeId) - { - var sql = $"SELECT T.GUID, T.ENVELOPE_UUID, T.ENVELOPE_TYPE, T2.FILEPATH, T2.BYTE_DATA FROM [dbo].[TBSIG_ENVELOPE] T\n JOIN TBSIG_ENVELOPE_DOCUMENT T2 ON T.GUID = T2.ENVELOPE_ID\n WHERE T.GUID = {envelopeId}"; - var table = _database!.GetDatatable(sql); - var row = table.Rows.Cast().SingleOrDefault(); - if (row is null) - { - return null; - } - - var annotationData = GetAnnotationData(envelopeId); - var data = new EnvelopeData - { - EnvelopeId = envelopeId, - DocumentPath = row.ItemEx("FILEPATH", string.Empty), - AnnotationData = annotationData, - DocAsByte = row.Field("BYTE_DATA"), - EnvelopeUuid = row.ItemEx("ENVELOPE_UUID", string.Empty) - }; - - return data; - } - - private List GetAnnotationData(int envelopeId) - { - var sql = $"SELECT VALUE FROM TBSIG_DOCUMENT_STATUS WHERE ENVELOPE_ID = {envelopeId}"; - var table = _database!.GetDatatable(sql); - - return [.. table.Rows.Cast().Select(r => r.ItemEx("VALUE", string.Empty))]; - } } \ No newline at end of file