diff --git a/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocument/PDFBurner.cs b/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocument/PDFBurner.cs index 8a9ac595..2a76e4af 100644 --- a/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocument/PDFBurner.cs +++ b/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocument/PDFBurner.cs @@ -185,7 +185,7 @@ public class PDFBurner : BaseClass foreach (var annotation in annotationData.annotations) { - Logger.Debug("Adding AnnotationID: " + annotation.id); + Logger.LogDebug("Adding AnnotationID: " + annotation.id); switch (annotation.type) { diff --git a/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocument/ReportCreator.cs b/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocument/ReportCreator.cs index ad31a841..b7cc67e5 100644 --- a/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocument/ReportCreator.cs +++ b/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocument/ReportCreator.cs @@ -23,7 +23,7 @@ public class ReportCreator : BaseClass { try { - Logger.Debug("Loading report data.."); + Logger.LogDebug("Loading report data.."); var table = _reportModel.List(envelope.Id); var items = GetReportSource(table); @@ -34,9 +34,9 @@ public class ReportCreator : BaseClass throw new CreateReportException("No report data found!"); } - Logger.Debug("Creating report with [{0}] items..", items.Count); + Logger.LogDebug("Creating report with [{0}] items..", items.Count); var buffer = DoCreateReport(items); - Logger.Debug("Report created!"); + Logger.LogDebug("Report created!"); return buffer; } @@ -49,7 +49,7 @@ public class ReportCreator : BaseClass private List GetReportSource(DataTable dataTable) { - Logger.Debug("Preparing report data"); + Logger.LogDebug("Preparing report data"); return dataTable.Rows .Cast() .Select(ToReportItem) @@ -63,14 +63,14 @@ public class ReportCreator : BaseClass var source = new ReportSource { Items = items }; var report = new rptEnvelopeHistory { DataSource = source, DataMember = "Items" }; - Logger.Debug("Creating report in memory.."); + Logger.LogDebug("Creating report in memory.."); report.CreateDocument(); - Logger.Debug("Exporting report to stream.."); + Logger.LogDebug("Exporting report to stream.."); using var stream = new MemoryStream(); report.ExportToPdf(stream); - Logger.Debug("Writing report to buffer.."); + Logger.LogDebug("Writing report to buffer.."); return stream.ToArray(); } diff --git a/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocumentJob.cs b/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocumentJob.cs index 71a43dc5..674e018f 100644 --- a/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocumentJob.cs +++ b/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocumentJob.cs @@ -57,43 +57,43 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration _tempFiles = new TempFiles(_logConfig); _tempFiles.Create(); var jobId = typeof(FinalizeDocumentJob).FullName; - _logger.Debug("Starting job {0}", jobId); + _logger.LogDebug("Starting job {0}", jobId); try { - _logger.Debug("Loading GdViewer.."); + _logger.LogDebug("Loading GdViewer.."); _gdViewer = new GdViewer(); _licenseManager.RegisterKEY(gdPictureKey); - _logger.Debug("Loading Database.."); + _logger.LogDebug("Loading Database.."); var connectionString = config.GetConnectionString("Default") ?? throw new InvalidOperationException("Connection string 'Default' not found."); _databaseConnectionString = MSSQLServer.DecryptConnectionString(connectionString); _database = new MSSQLServer(_logConfig, _databaseConnectionString); - _logger.Debug("Loading Models & Services"); + _logger.LogDebug("Loading Models & Services"); var state = GetState(); InitializeModels(state); - _logger.Debug("Loading Configuration.."); + _logger.LogDebug("Loading Configuration.."); _config = _configModel?.LoadConfiguration() ?? new DbConfig(); state.DbConfig = _config; InitializeServices(state); - _logger.Debug("Loading PDFBurner.."); + _logger.LogDebug("Loading PDFBurner.."); var pdfBurnerParams = _options.PdfBurner; _pdfBurner = new PDFBurner(_logConfig, gdPictureKey, pdfBurnerParams, _databaseConnectionString); - _logger.Debug("Loading PDFMerger.."); + _logger.LogDebug("Loading PDFMerger.."); _pdfMerger = new PDFMerger(_logConfig, gdPictureKey); - _logger.Debug("Loading ReportCreator.."); + _logger.LogDebug("Loading ReportCreator.."); _reportCreator = new ReportCreator(_logConfig, state); _config.DocumentPath = _config.DocumentPath; - _logger.Debug("DocumentPath: [{0}]", _config.DocumentPath); - _logger.Debug("ExportPath: [{0}]", _config.ExportPath); + _logger.LogDebug("DocumentPath: [{0}]", _config.DocumentPath); + _logger.LogDebug("ExportPath: [{0}]", _config.ExportPath); var completeStatus = EnvelopeStatus.EnvelopeCompletelySigned; var sql = $"SELECT * FROM TBSIG_ENVELOPE WHERE STATUS = {completeStatus} AND DATEDIFF(minute, CHANGED_WHEN, GETDATE()) >= {CompleteWaitTime} ORDER BY GUID"; @@ -123,7 +123,7 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration throw new ArgumentNullException(nameof(EnvelopeData)); } - _logger.Debug("Loading Envelope Data.."); + _logger.LogDebug("Loading Envelope Data.."); var envelopeData = GetEnvelopeData(id); if (envelopeData is null) @@ -132,7 +132,7 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration throw new ArgumentNullException(nameof(EnvelopeData)); } - _logger.Debug("Burning Annotations to pdf ..."); + _logger.LogDebug("Burning Annotations to pdf ..."); var burnedDocument = BurnAnnotationsToPdf(envelopeData); if (burnedDocument is null) { @@ -146,24 +146,24 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration throw new ApplicationException("Document Report could not be created"); } - _logger.Debug("Creating report.."); + _logger.LogDebug("Creating report.."); var report = _reportCreator!.CreateReport(envelope); - _logger.Debug("Report created!"); + _logger.LogDebug("Report created!"); - _logger.Debug("Merging documents ..."); + _logger.LogDebug("Merging documents ..."); var mergedDocument = _pdfMerger!.MergeDocuments(burnedDocument, report); - _logger.Debug("Documents merged!"); + _logger.LogDebug("Documents merged!"); var outputDirectoryPath = Path.Combine(_config.ExportPath, _parentFolderUid); - _logger.Debug("oOutputDirectoryPath is {0}", outputDirectoryPath); + _logger.LogDebug("oOutputDirectoryPath is {0}", outputDirectoryPath); if (!Directory.Exists(outputDirectoryPath)) { - _logger.Debug("Directory not existing. Creating ... "); + _logger.LogDebug("Directory not existing. Creating ... "); Directory.CreateDirectory(outputDirectoryPath); } var outputFilePath = Path.Combine(outputDirectoryPath, $"{envelope.Uuid}.pdf"); - _logger.Debug("Writing finalized Pdf to disk.."); + _logger.LogDebug("Writing finalized Pdf to disk.."); _logger.Info("Output path is [{0}]", outputFilePath); try @@ -176,7 +176,7 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration throw new ExportDocumentException("Could not export final document to disk!", ex); } - _logger.Debug("Writing EB-bytes to database..."); + _logger.LogDebug("Writing EB-bytes to database..."); UpdateFileDb(outputFilePath, envelope.Id); if (!SendFinalEmails(envelope)) @@ -186,7 +186,7 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration _logger.Info("Report-mails successfully sent!"); - _logger.Debug("Setting envelope status.."); + _logger.LogDebug("Setting envelope status.."); if (_actionService?.FinalizeEnvelope(envelope) == false) { _logger.Warn("Envelope could not be finalized!"); @@ -203,7 +203,7 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration _logger.Info("Envelope [{0}] finalized!", id); } - _logger.Debug("Completed job {0} successfully!", jobId); + _logger.LogDebug("Completed job {0} successfully!", jobId); } catch (MergeDocumentException ex) { @@ -222,7 +222,7 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration } finally { - _logger.Debug("Job execution for [{0}] ended", jobId); + _logger.LogDebug("Job execution for [{0}] ended", jobId); } return Task.FromResult(true); @@ -265,7 +265,7 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration if (mailToCreator != FinalEmailType.No) { - _logger?.Debug("Sending email to creator ..."); + _logger?.LogDebug("Sending email to creator ..."); SendFinalEmailToCreator(envelope, mailToCreator); } else @@ -275,7 +275,7 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration if (mailToReceivers != FinalEmailType.No) { - _logger?.Debug("Sending emails to receivers.."); + _logger?.LogDebug("Sending emails to receivers.."); SendFinalEmailToReceivers(envelope, mailToReceivers); } else @@ -289,7 +289,7 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration private bool SendFinalEmailToCreator(Envelope envelope, FinalEmailType mailToCreator) { var includeAttachment = SendFinalEmailWithAttachment(mailToCreator); - _logger?.Debug("Attachment included: [{0}]", includeAttachment); + _logger?.LogDebug("Attachment included: [{0}]", includeAttachment); if (_actionService?.CompleteEnvelope(envelope) == false) { @@ -303,7 +303,7 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration private bool SendFinalEmailToReceivers(Envelope envelope, FinalEmailType mailToReceivers) { var includeAttachment = SendFinalEmailWithAttachment(mailToReceivers); - _logger?.Debug("Attachment included: [{0}]", includeAttachment); + _logger?.LogDebug("Attachment included: [{0}]", includeAttachment); foreach (var receiver in envelope.EnvelopeReceivers ?? Enumerable.Empty()) { @@ -336,9 +336,9 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration } else { - _logger?.Debug("we got bytes.."); + _logger?.LogDebug("we got bytes.."); inputPath = _config!.DocumentPathOrigin; - _logger?.Debug("oInputPath: {0}", _config.DocumentPathOrigin); + _logger?.LogDebug("oInputPath: {0}", _config.DocumentPathOrigin); } if (envelopeData.DocAsByte is null) @@ -393,7 +393,7 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration EnvelopeUuid = row.ItemEx("ENVELOPE_UUID", string.Empty) }; - _logger?.Debug("Document path: [{0}]", data.DocumentPath); + _logger?.LogDebug("Document path: [{0}]", data.DocumentPath); return data; } diff --git a/EnvelopeGenerator.ServiceHost/Jobs/Infrastructure/Logging.cs b/EnvelopeGenerator.ServiceHost/Jobs/Infrastructure/Logging.cs index 6a3f7a08..f474d7f4 100644 --- a/EnvelopeGenerator.ServiceHost/Jobs/Infrastructure/Logging.cs +++ b/EnvelopeGenerator.ServiceHost/Jobs/Infrastructure/Logging.cs @@ -11,7 +11,9 @@ public class LogConfig public class Logger { - public void Debug(string message, params object?[] args) => Write("DEBUG", message, args); + ILogger logger; + + public void LogDebug(string message, params object?[] args) => Write("DEBUG", message, args); public void Info(string message, params object?[] args) => Write("INFO", message, args); public void Warn(string message, params object?[] args) => Write("WARN", message, args); public void Warn(Exception exception, string message, params object?[] args) => Write("WARN", message + " " + exception.Message, args); diff --git a/EnvelopeGenerator.ServiceHost/Jobs/TempFiles.cs b/EnvelopeGenerator.ServiceHost/Jobs/TempFiles.cs index ad9a51db..559e1344 100644 --- a/EnvelopeGenerator.ServiceHost/Jobs/TempFiles.cs +++ b/EnvelopeGenerator.ServiceHost/Jobs/TempFiles.cs @@ -42,7 +42,7 @@ public class TempFiles : BaseClass { foreach (var fileItem in Directory.GetFiles(TempPath)) { - Logger.Debug("Deleting tempPath-file: {0} ...", fileItem); + Logger.LogDebug("Deleting tempPath-file: {0} ...", fileItem); File.Delete(fileItem); } @@ -59,7 +59,7 @@ public class TempFiles : BaseClass { try { - Logger.Debug("Deleting tempPath-Data: {0} ...", TempPath); + Logger.LogDebug("Deleting tempPath-Data: {0} ...", TempPath); Directory.Delete(TempPath, true); return true; }