132 Commits

Author SHA1 Message Date
6195d99fab refactor: remove usePdfBurner parameter from AddEnvelopeGeneratorServices 2025-11-12 16:55:06 +01:00
50a372a224 feat(CCommonServicces.FinalizeDocument.PDFMerger): update to use SaveToStream instead of ConvertToPDFA 2025-11-12 16:27:20 +01:00
35dd2e8e07 refactor(email): replace Task.WhenAll with foreach in SendEmailBehavior
Changed the SendFinalEmailToReceiversAsync method to use a sequential `foreach` loop
instead of `Task.WhenAll` for sending history commands. Added a null check for
receiver emails to prevent potential exceptions.
2025-11-12 16:14:32 +01:00
fac5419589 refactor: simplify email sending logic and remove debug checks
- Removed unused `EnvelopeGenerator.Domain.Entities` import.
- Changed `SendFinalEmailWithAttachment` calls to explicitly cast envelope email type to `int`.
- Removed `Debug` conditional checks around history creation; history commands are now always sent.
- Made `SendFinalEmailWithAttachment` a static method for clarity.
2025-11-12 15:44:37 +01:00
d442ad0ce0 refactor(SendEmailBehavior): update to add history recors when request is not debug 2025-11-12 15:35:23 +01:00
cbe2acc37d feat(SendEmailBehavior): make SendEmailBehavior fully async and record history
- Added ISender dependency to send history commands
- Refactored SendFinalEmailToCreator and SendFinalEmailToReceivers to async
- Log attachment inclusion for emails
- Use Task.WhenAll for sending to multiple receivers
2025-11-12 15:32:06 +01:00
40cc467b47 feat(SendEmailBehavior): add SendEmailBehavior for sending final emails after PDF burn
- Implements IPipelineBehavior<BurnPdfCommand, byte[]> to send emails to creator and receivers.
- Logs debug information when sending emails and warnings if email sending is skipped.
- Uses Envelope's FinalEmailType to determine whether to send emails.
2025-11-12 15:12:04 +01:00
d1513dab5e feat(WritePdfBehavior): add WritePdfBehavior to handle PDF writing pipeline
- Implements WritePdfBehavior as an IPipelineBehavior for BurnPdfCommand
- Writes generated PDF to configured export path
- Automatically creates export directory if missing
- Adds logging for export path and file operations
2025-11-12 14:55:35 +01:00
dee424e7db feat(DefaultReadConfigQuery): add DefaultReadConfigQuery with caching and AutoMapper support
- Implemented DefaultReadConfigQuery and its handler for reading default configuration.
- Added memory caching using IMemoryCache to improve performance.
- Integrated AutoMapper to map Config entities to ConfigDto.
- Included extension method for easier MediatR query invocation.
- Added error handling for missing configuration records.
2025-11-12 14:34:30 +01:00
e57e9e1834 fix(PdfMergeBehavior): improve error diagnostics and exception messages in PdfMergeBehavior
- Added detailed request context to all MergeDocumentException messages
- Clarified conversion error message from "converted to PDF/A" to "converted to byte"
- Removed unused base64 conversion and redundant variable assignment
- Improved code readability and string concatenation formatting
2025-11-12 14:02:40 +01:00
5b30465126 refactor(pdf): simplify and inline PDF merge logic in PdfMergeBehavior
- Removed MergeDocuments static method; integrated merge process directly in Handle()
- Added null check for request.Report before merging
- Cleaned up redundant return and improved flow for memory stream handling
- Added DevExpress.XtraReports using directive
- Clarified comment and exception messages for PDF loading and merging
2025-11-12 13:59:35 +01:00
2dfa1de7e1 refactor(PdfMergeBehavior): update to use SaveToStream instead of ConvertToPDFA 2025-11-12 13:51:49 +01:00
e68965543e refactor(BurnPdfCommand): add Report property to forward report.
- Reverse the order in which behaviors are added.
2025-11-12 12:47:19 +01:00
958bcdfc42 chore: wrap AddReportBehavior with #if WINDOWS directive 2025-11-12 11:08:09 +01:00
d88ed324be refactor(Pdf\Behaviors): Handle the history recording process in another behavior named CreateHistoryBehavior 2025-11-12 11:00:24 +01:00
380b141738 refactor(project): add net8.0-windows target and unify net8.0 package references
- Updated <TargetFrameworks> to include net8.0-windows
- Consolidated package references for net8.0 and net8.0-windows into a single ItemGroup
2025-11-12 10:51:04 +01:00
f3a15216a8 chore: update TargetFramework to net8.0-windows in project file 2025-11-12 10:43:18 +01:00
8a48bf6b51 feat(EnvelopeGenerator.Finalizer.Win): Create to process window-oriented services 2025-11-12 10:17:37 +01:00
0038eeed76 feat(EGDbContextBase): add EnvelopeReports-property 2025-11-11 23:31:35 +01:00
4ed118ed2b update to add as closed behavior 2025-11-11 23:24:51 +01:00
Developer 02
350aa259c8 chore(Application): add DevExpress.Reporting.Core 2025-11-11 23:16:36 +01:00
Developer 02
737de2202e remove unnecessary projects 2025-11-11 23:08:50 +01:00
Developer 02
ff60cd7ef8 refactor: simplify AddReportBehavior by making DoCreateReport static and reordering base64 conversion 2025-11-11 22:57:50 +01:00
Developer 02
e1aa7fe650 chore(Application): add CommonServices reference 2025-11-11 22:51:14 +01:00
Developer 02
9c0b1e3fa8 chore(App.VB): fix reference 2025-11-11 22:33:46 +01:00
6b34b55c4f chore(Application.VB): add System.Drawing.Common and DevExpress-packages 2025-11-11 22:22:47 +01:00
4a5608249e refactor(Application.VB): add dev express dependencies 2025-11-11 21:59:27 +01:00
Developer 02
965838513f create EnvelopeGenerator.Application.VB 2025-11-11 21:49:56 +01:00
Developer 02
9c4766518e feat(AddReportBehavior): add PDF report generation logic with logging
- Introduced `ILogger<AddReportBehavior>` for logging support.
- Added `DoCreateReport` method to generate PDF from `EnvelopeReport` items.
- Added `ReportSource` class to structure report data.
- Retained existing history creation and MediatR pipeline behavior.
2025-11-11 21:40:20 +01:00
Developer 02
292b6b2ccf feat(AddReportBehavior): add report creation logic to AddReportBehavior
- Added CreateReport method to generate PDF report from envelope data
- Integrated call to CreateReport within pipeline after history creation
- Introduced error handling via CreateReportException for missing report data
- Added necessary using directives for EnvelopeReports, Exceptions, and Entities
2025-11-11 21:19:21 +01:00
Developer 02
6f9b5d4b13 feat(envelope-reports): add extension method for reading envelope reports via ISender 2025-11-11 19:21:22 +01:00
Developer 02
8459706c45 feat: implement ReadEnvelopeReportQuery with handler and repository integration
- Add ReadEnvelopeReportQuery record that returns IEnumerable<EnvelopeReport>
- Implement ReadEnvelopeReportQueryHandler with repository and AutoMapper integration
- Add ThrowIfNotFound property with JsonIgnore and NotMapped attributes
- Integrate IRepository<EnvelopeReport> for data access
- Add NotFoundException when no reports found and ThrowIfNotFound is true
- Configure Entity Framework Core using Microsoft.EntityFrameworkCore
- Add JSON serialization configuration with System.Text.Json
- Update using statements with necessary abstractions and exceptions
2025-11-11 18:22:23 +01:00
Developer 02
972c63388e add EnvelopeReport to EnvelopeReportDto mapping 2025-11-11 17:34:42 +01:00
Developer 02
cde9ed06a1 create EnvelopeReportDto 2025-11-11 17:32:52 +01:00
Developer 02
d94f885e92 init a query to read envelope report by envelope id via mediator 2025-11-11 17:27:46 +01:00
Developer 02
028785a8c9 create EnvelopeReport-entity 2025-11-11 17:11:32 +01:00
Developer 02
e6285f13f7 feat(AddReportBehavior): add conditional history creation based on Debug flag in AddReportBehavior 2025-11-11 13:08:34 +01:00
35b7b1a080 refactor(AddReportBehavior): update to add history record. 2025-11-10 17:05:35 +01:00
67d0980c63 move the behaviours about pdf to pdf dir 2025-11-10 16:46:10 +01:00
c6a99b56a2 add GdPicture packages via nuget 2025-11-10 16:18:42 +01:00
31f5d1f340 add SaveBurnedPdfBehavior to services 2025-11-10 15:29:16 +01:00
a2df5d7691 create SaveBurnedPdfBehavior 2025-11-10 15:13:57 +01:00
f8c586dd31 feat(FinishEnvelopeJob): add PDF burning with concurrency control
- Introduced PDFBurnerParams configuration for concurrency limit.
- Added SemaphoreSlim to handle concurrent PDF burning for envelopes.
- Updated job to call _mediator.BurnPdf for each envelope with error handling.
- Preserved logging of job execution and envelope UUIDs.
2025-11-10 15:01:07 +01:00
8aea3c8301 refactor(BurnPdfCommand): add extension methods for ISender
- Introduce BurnPdfCommandExtensions to simplify sending BurnPdfCommand via ISender
- Enables calling `sender.BurnPdf(envelopeId, cancel)` or `sender.BurnPdf(envelopeUuid, cancel)`
- No changes to the underlying PDF burning logic in BurnPdfCommandHandler
2025-11-10 14:00:21 +01:00
495adb8c31 feat(dependency-injection): add optional usePdfBurner flag to AddServices
- Updated EGConfiguration.AddServices to accept a new `usePdfBurner` boolean parameter.
- Pass `usePdfBurner` through to AddEnvelopeGeneratorServices to enable optional PDF burner functionality.
- Maintains existing behavior when parameter is not provided (default false).
2025-11-10 13:53:26 +01:00
86c0a65540 refactor: add conditional PDFBurner and GdPicture service registration 2025-11-10 13:43:44 +01:00
d2e8f1fc5e refactor: simplify GdPicture license resolution in dependency injection 2025-11-10 13:29:02 +01:00
f8369e350f refactor(BurnPdfCommand): replace manual JSON serialization with ToJson extension
- Replaced `System.Text.Json.JsonSerializer.Serialize(request, Format.Json.ForDiagnostics)`
  with `request.ToJson(Format.Json.ForDiagnostics)` for better readability and consistency.
- No functional changes, purely a code style and maintainability improvement.
2025-11-10 13:01:33 +01:00
b8a2ad97ef refactor(BurnPdfCommand): simplify BurnPdfCommand and improve envelope/document handling
- Updated `BurnPdfCommand` to accept `EnvelopeId` or `EnvelopeUuid` instead of full `EnvelopeQueryBase` and document data.
- Reworked `BurnPdfCommandHandler` to fetch envelope and document from repositories, including proper validations and exceptions.
- Removed direct dependency on `Signature` repository; annotations now retrieved via document elements.
- Added detailed exception handling for missing envelope, document, or byte data.
- Minor namespace and using cleanup.
2025-11-10 12:58:04 +01:00
ffffc2d470 refactor(BurnPdfCommand): update BurnPdfCommand to use EnvelopeQueryBase and enhance request structure
- Replaced record-based BurnPdfCommand with class-based implementation
- Added Envelope property of type EnvelopeQueryBase
- Changed parameters to nullable (Document, InstantJSONList)
- Added ByCronService flag for cron-based PDF burning control
- Updated query logic to use request.Envelope.Id instead of EnvelopeId
- Improved code structure for flexibility and service integration
2025-11-10 09:30:04 +01:00
36b03da084 fix(DependencyInjection): change AnnotationManager registration from Scoped to Transient 2025-11-07 15:21:36 +01:00
defa53fa26 refactor(BurnPdfCommand): rename SourceBuffer to Document in BurnPdfCommand and handler
- Renamed parameter `SourceBuffer` to `Document` in BurnPdfCommand record
- Updated all usages of `request.SourceBuffer` to `request.Document`
- Reorganized method order for better readability (Handle moved up)
- No functional or behavioral changes introduced
2025-11-07 14:56:34 +01:00
6134b58a4c refactor(BurnPdfCommand): extract GdPicture and math helpers into extension classes and simplify BurnPdfCommandHandler
- Refactored BurnPdfCommandHandler to use new extension methods for cleaner annotation handling.
- Introduced ITextStyle interface to generalize font styling for text annotations.
- Updated PDFBurnerParams to implement ITextStyle for consistent font settings reuse.
- Added MathematExtensions for coordinate and unit conversion (ToInches, ToPointF).
- Added GdPictureExtensions to encapsulate annotation-related logic (form fields, images, ink).
- Improved readability and maintainability by removing redundant helper methods.
2025-11-07 14:46:55 +01:00
5299016b43 move PSDPFKitModels namespace to Dto and rename as PSPDFKitInstant 2025-11-07 13:51:53 +01:00
55c20e83d8 refactor: convert BurnPdfCommand to record and update handler to return byte[]
- Changed `BurnPdfCommand` from empty class to a `record` with properties: `SourceBuffer`, `InstantJSONList`, `EnvelopeId`.
- Updated `BurnPdfCommandHandler` to implement `IRequestHandler<BurnPdfCommand, byte[]>`.
- Modified `Handle` method to be async and use the `request` data to return PDF bytes.
- Removed obsolete `BurnPdfCommand` class and updated related logic accordingly.
2025-11-07 13:44:53 +01:00
f1a140faa7 feat(BurnPdfCommandHandler): implement AddInkAnnotation for Annotation parameter
- Added implementation for AddInkAnnotation(Annotation) to handle ink annotations from Annotation objects.
- Retained existing AddInkAnnotation(int, string) method for backward compatibility.
- Refactored PDF burning logic to support both Annotation-based and JSON-based annotations.
2025-11-07 13:24:26 +01:00
b20d25e5b9 feat(BurnPdfCommandHandler): implement AddInkAnnotation for freehand annotations
- Added implementation for AddInkAnnotation(int page, string value) to render ink annotations from JSON.
- Deserialize ink lines and stroke color, convert points to PDF coordinates, and add as freehand annotations.
- Retained placeholder for AddInkAnnotation(Annotation pAnnotation) for future use.
2025-11-07 13:21:33 +01:00
e21eb2c0d6 refactor(BurnPdfCommandHandler): rename AddInstantJSONAnnotationToPdf to AddInstantJsonAnnotationToPdf for consistent casing 2025-11-07 13:16:14 +01:00
d237b4ab95 feat(BurnPdfCommand): implement AddImageAnnotation with attachment handling
- Added logic to AddImageAnnotation to handle image attachments from a dictionary.
- Removed NotImplementedException placeholder for AddImageAnnotation with attachments.
- Refactored code to convert annotation bounds from pixels to inches before adding images.
2025-11-07 13:14:02 +01:00
dff99b163d refactor: simplify AddFormFieldValue method and remove redundant parameters 2025-11-07 13:12:01 +01:00
70fbf31b14 feat(BurnPdfCommandHandler): implement AddImageAnnotation for base64 images
- Added implementation for AddImageAnnotation(double x, double y, double width, double height, int page, string base64)
- Allows embedding images directly from base64 into PDF pages
- Existing annotation burning logic remains unchanged
2025-11-07 13:09:54 +01:00
339e0e81cd feat(PDFBurnerParams): add DefaultIndexOfAnnot and GetAnnotationIndex
- add `DefaultIndexOfAnnot` property to provide a fallback index for annotations
 - add `GetAnnotationIndex(string name)` method to safely retrieve an annotation index, returning default if not found
2025-11-07 13:03:50 +01:00
a386ad72bb refactor(BurnPdfCommandHandler): use IOptions<PDFBurnerParams> and improve form field handling
- Updated BurnPdfCommandHandler constructor to accept IOptions<PDFBurnerParams> instead of raw PDFBurnerParams.
- Updated AddFormFieldValue to calculate coordinates based on PDFBurnerParams offsets and margins.
- Added helper methods for converting pixels to inches (ToInches, ToPointF).
- Removed unused NotImplemented methods in AddFormFieldValue overload.
- Improved code readability and maintainability for annotation burning logic.
2025-11-07 12:59:13 +01:00
02c5f286ec feat(pdf): implement AddFormFieldValue for PDF annotations
- Added implementation for AddFormFieldValue method to properly add text annotations to PDF pages using AnnotationManager.
- Preserves font settings from PDFBurnerParams.
- Other annotation methods remain unimplemented.
2025-11-07 12:44:05 +01:00
5fa358ca79 refactor(BurnPdfCommandHandler): deserialize and process instant JSON annotations
- Added Newtonsoft.Json to parse instant JSON into `InstantData`.
- Replaced `AddInstantJSONAnnotationToPDF` logic with `AddInstantJsonAnnotationToPdf`.
- Process annotations by type (Image, Ink, Widget) and apply attachments/form fields.
- Introduced checks for ignored form field values using `_pdfBurnerParams.IgnoredLabels`.
- Added logging for annotation IDs when processing instant JSON.
2025-11-07 12:36:19 +01:00
7233d2ce98 add InstantData 2025-11-07 11:37:28 +01:00
5784cc7a97 refactor(Application.Pdf.PSPDFKit): rename as Application.Pdf.PSPDFKitModels 2025-11-07 11:28:55 +01:00
f31f680f91 add PSPDFKit.Annotation 2025-11-07 11:27:07 +01:00
e7c2d46ef0 add PSPDFKit.Ink 2025-11-07 11:23:04 +01:00
85d70c1db4 feat(PDFBurnerParams): add IndexOfAnnot-dictionary 2025-11-07 11:16:22 +01:00
fb340fb08a create PSPDFKit.Lines 2025-11-07 10:59:13 +01:00
7d3959ae51 add PSPDFKit.Attachment 2025-11-07 10:56:53 +01:00
9d4890b10d add PSPDFKit.FormFieldValue 2025-11-07 10:52:15 +01:00
b64f4d71f5 feat(BurnPdfCommandHandler): add logging and implement BurnInstantJSONAnnotsToPDF
- Added ILogger<BurnPdfCommandHandler> to log warnings during annotation processing
- Implemented BurnInstantJSONAnnotsToPDF method to handle instant JSON annotations
- Added AddInstantJSONAnnotationToPDF stub for future implementation
- Updated PDF burn flow to include error handling and logging
2025-11-07 10:40:44 +01:00
b7d146ddb5 refactor: standardize annotation types and clean up PDF burn handler
- Introduced `AnnotationType.PSPDFKit` constants for consistent annotation type references.
- Updated `BurnPdfCommandHandler` to use new PSPDFKit annotation types.
- Refactored method signatures and local variables for clarity (e.g., using 'var', null-coalescing for annotation properties).
- Streamlined `using` statements and memory management in PDF burning process.
- Added placeholder methods for form fields, image, and ink annotations to centralize future implementations.
2025-11-07 10:11:48 +01:00
6a5c9a3489 fix(BurnPdfCommand): improve JSON serialization and null safety in Signature entity and BurnPdfCommandHandler
- Added System.Text.Json.Serialization namespace and [JsonIgnore] attributes to Top and Left properties in Signature entity for .NET builds
- Applied null-forgiving operator (!) and null-coalescing defaults for frame.X and frame.Y in BurnPdfCommandHandler
- Improved runtime safety and prevented unintended JSON serialization of computed properties
2025-11-07 09:51:02 +01:00
Developer 02
15f6ee7be0 add ExportDocumentException 2025-11-06 21:53:36 +01:00
Developer 02
1051c5356f add CreateReportException 2025-11-06 21:52:35 +01:00
Developer 02
7b13350fbf add BurnAnnotationException 2025-11-06 21:51:20 +01:00
Developer 02
2bada327d8 add MergeDocumentException 2025-11-06 21:50:17 +01:00
Developer 02
a47729ebca feat(pdf): implement annotation burning logic in BurnPdfCommandHandler
- Added full implementation of BurnElementAnnotsToPDF method
- Integrated PdfEditor for background rendering
- Added annotation handling for form fields, images, and ink types
- Included error handling for PDF loading and saving
- Removed unused DigitalData.Core.Abstractions namespace
2025-11-06 21:49:24 +01:00
Developer 02
fcfed963b7 feat(pdf): add annotation burning logic and repository dependency to BurnPdfCommandHandler
- Inject IRepository<Signature> for accessing signature and annotation data
- Implement BurnAnnotsToPDF method to process annotations from DB or JSON
- Add BurnElementAnnotsToPDF and BurnInstantJSONAnnotsToPDF stubs
- Integrate EF Core Include for loading related entities
2025-11-06 21:30:51 +01:00
Developer 02
b2ace61cd4 refactor(BurnPdfCommandHandler): inject AnnotationManager 2025-11-06 21:20:57 +01:00
Developer 02
77cdc83a4e add AnnotationManager as scoped 2025-11-06 21:19:05 +01:00
Developer 02
a611df4914 inject LicenseManager 2025-11-06 21:09:46 +01:00
Developer 02
1341f69ab1 move gdpucture parmas configuration to application layer 2025-11-06 20:57:10 +01:00
Developer 02
0480513288 add gdpicture dependencies 2025-11-06 20:10:41 +01:00
Developer 02
9dbd1b16b5 inject pdf burner params 2025-11-06 19:57:56 +01:00
Developer 02
c649c93921 move pdf burner to application layer 2025-11-06 19:51:15 +01:00
Developer 02
1843119b1b add PDFBurnerParams 2025-11-06 19:39:43 +01:00
Developer 02
bc4371cb99 feat(PDFBurner): init for only .net 2025-11-06 19:34:39 +01:00
Developer 02
05130d6163 feat(FinishEnvelopeJob): enhance FinishEnvelopeJob logging for finalized envelopes
- Removed redundant initial info log.
- Added detailed logging after job execution:
  - Logs total finalized envelope count.
  - Logs UUIDs of finalized envelopes when available.
  - Logs success message when no envelopes were finalized.
2025-11-06 09:59:16 +01:00
567b9c9565 refactor(Envelope): remove unnecessary [NotMapped] attribute from DocResult property 2025-11-05 16:49:39 +01:00
b798181f91 feat(notification): implement handler to remove document result on signature removal 2025-11-05 15:26:48 +01:00
7e8fc25ec9 refactor: update core inf and abst.app 2025-11-05 14:31:24 +01:00
db76162697 Refactor: Convert envelope query filters to LINQ query syntax
- Replaced multiple sequential 'Where' calls with a single LINQ query expression
- Preserved all status filters (Include, Ignore, Min, Max)
- Preserved DocResult filtering logic
- Improves readability while keeping behavior identical
2025-11-05 13:39:10 +01:00
2b4573ea73 feat(ReadEnvelopeQuery): implement ReadEnvelopeQueryHandler with filtering support
- Added `ReadEnvelopeQueryHandler` to handle `ReadEnvelopeQuery`.
- Supports filtering envelopes by:
  - Included and ignored `EnvelopeStatus` values.
  - Minimum and maximum status.
  - Presence or absence of `DocResult`.
- Uses repository query extension methods and AutoMapper to map to `EnvelopeDto`.
2025-11-05 13:32:30 +01:00
4a043ed247 feat(FinishEnvelopeJob): update Execute to add cancelation token 2025-11-05 12:58:35 +01:00
a62a035ec6 feat(FinishEnvelopeJob): enhance FinishEnvelopeJob to fetch signed envelopes
- Added MediatR dependency to query envelopes
- Injected GdPictureOptions via IOptions
- Updated Execute method to fetch envelopes with status 'EnvelopeCompletelySigned'
- Preserved logging with job details
- Prepared loop for further processing of envelopes
2025-11-05 12:55:49 +01:00
1713a65014 refactor(Program): simplify Quartz job registration and add EnvelopeTaskApiJob
- Replaced manual FinishEnvelopeJob Quartz setup with ScheduleJobDefault extension
- Added scheduling for EnvelopeTaskApiJob
- Updated using directives to include EnvelopeGenerator.Finalizer namespace
- Improved maintainability by removing redundant Quartz configuration logic
2025-11-05 11:24:35 +01:00
695d7c83e0 feat(Extensions): add Quartz job scheduling extension methods
- Introduced ScheduleJobDefault<TJob> extension for IServiceCollectionQuartzConfigurator
- Allows scheduling jobs using either a cron expression or configuration-based cron settings
- Includes validation for missing or invalid cron expressions
2025-11-05 10:43:25 +01:00
428f71863d create EnvelopeTaskApi 2025-11-05 09:41:02 +01:00
cce2f8f90e refactor(Worker): rename as FinishEnvelopeJob 2025-11-05 09:34:56 +01:00
Developer 02
86c9fdfcd7 refactor: inject IScheduler via DI instead of using StdSchedulerFactory directly 2025-11-04 17:34:36 +01:00
Developer 02
89ec887510 feat(quartz): integrate Quartzmon dashboard and CommandDotNet
- Added `Quartzmon` package and configured its middleware for job monitoring.
- Integrated `CommandDotNet.Execution` for command-line execution support.
- Updated using directives and service registrations accordingly.
- Preserved existing Serilog logging, DB context, and EnvelopeGenerator setup.
2025-11-04 17:29:07 +01:00
Developer 02
7d5b988842 fix(middleware): add UseRouting before UseAuthorization
Added `app.UseRouting()` in the middleware pipeline to ensure proper endpoint routing before authorization and controller mapping.
2025-11-04 17:18:29 +01:00
Developer 02
3c456562cc refactor: replace QuartzHostedService with QuartzServer and remove unnecessary using
- Replaced `AddQuartzHostedService` with `AddQuartzServer` for better Quartz integration.
- Removed `Microsoft.Extensions.Options` using as it was unused.
- Updated Quartz job naming to remove GUID and simplify identity.
- Minor code cleanup in using statements and regions.
2025-11-04 17:06:00 +01:00
Developer 02
4d6b01030c refactor(startup): migrate from generic Host to WebApplication and integrate Web API support
- Replaced Host.CreateApplicationBuilder with WebApplication.CreateBuilder
- Added Web API service registrations (Controllers, Swagger)
- Organized startup into clear regions: Logging, Configuration, Worker, Services, Middleware
- Introduced Swagger and HTTPS middleware for API
- Improved structure and readability of Program.cs
2025-11-04 16:12:21 +01:00
Developer 02
75e7e9925b feat(Program): make Quartz cron schedule configurable via appsettings
- Replaced hardcoded cron expression with configuration-based `Worker:CronExpression`.
- Throws descriptive exception if cron expression is missing.
- Keeps previous worker and DB context setup unchanged.
2025-11-04 15:37:20 +01:00
Developer 02
0a175b9e9d refactor: remove unnecessary while loop in Worker.Execute 2025-11-04 15:18:38 +01:00
Developer 02
f611e74de1 refactor(config): allow GdPicture license key from configuration
- Updated GdPictureOptions setup to read license key from `GdPictureLicenseKey` config value.
- Falls back to reading from third-party module if config key is not set.
2025-11-04 14:56:44 +01:00
Developer 02
08ca116628 refactor(worker): replace BackgroundService with Quartz IJob for scheduled execution
- Removed inheritance from BackgroundService
- Implemented Quartz IJob interface for better scheduling control
- Replaced ExecuteAsync with Execute(IJobExecutionContext)
- Updated cancellation handling to use context.CancellationToken
2025-11-04 14:49:56 +01:00
Developer 02
4997f7d75c feat: add in-memory database support via appsettings UseInMemoryDb flag
- Introduced conditional EF Core configuration to support InMemoryDatabase for testing or lightweight runs.
- Added `UseInMemoryDb` config flag read from appsettings.
- Retained SQL Server as the default when the flag is false.
- Added missing Quartz namespace import.
2025-11-04 13:44:39 +01:00
b5cd42b6fa add WorkerOptions.
- bind IntervalInMin with worker task delay
2025-11-03 16:38:41 +01:00
187f4a42fc feat(GdPictureOptions): Created to configure parameters related to GdPicture.
- Configure the GdPicture license key via a third-party module entity.
2025-11-03 15:36:11 +01:00
23d4b2f31e chore: move finalizer to presentation layer 2025-11-03 14:51:13 +01:00
8e71e5b4bb feat(third-party-modules): add query and handler for reading third-party modules with filtering by name and active status 2025-11-03 14:49:54 +01:00
b693615561 feat(ThirdPartyModuleDto): create DTO of ThirdPartyModule with mapping profile 2025-11-03 14:30:45 +01:00
36dc9266bc Add ThirdPartyModule entity for 3rd party module tracking
- Created ThirdPartyModule class in EnvelopeGenerator.Domain.Entities
- Mapped to TBDD_3RD_PARTY_MODULES table with appropriate columns
- Added properties: Id, Active, Name, Description, License, Version, AddedWho, AddedWhen, ChangedWho, ChangedWhen
- Configured data annotations for primary key, required fields, string lengths, and nullable support
- Conditional nullable support based on compilation symbols
2025-11-03 13:05:24 +01:00
9aabe270b4 add appsettings for PDF burner 2025-11-03 11:56:10 +01:00
b303b7be06 chore(Finalizer.Program): enhance configuration and environment-specific JSON loading
- Changed Serilog configuration file from `appsettings.json` to `appsettings.Logging.json`.
- Added logging for application startup.
- Dynamically load environment-specific appsettings JSON files, excluding `Development` and `migration` files.
2025-11-03 11:41:55 +01:00
02937360ea chore(Finalizer.appsettings): update Serilog configuration to increase log verbosity and retention
- Changed default minimum log level from Information to Verbose.
- Updated console sink to use Verbose level.
- Renamed and consolidated log files for Verbose, Debug, Info, Warning, Error, and Fatal levels.
- Increased retained file count from 7 to 30 for all log levels.
2025-11-03 11:26:14 +01:00
c2735b92e0 feat(logging): enhance Serilog configuration with separate level-based log files 2025-11-03 10:48:35 +01:00
568f43186c refactor(Finalizer.Program): simplify EnvelopeGenerator service registration using AddEnvelopeGenerator extension
- Replaced manual service setup with AddEnvelopeGenerator fluent configuration
- Added EnvelopeGenerator.DependencyInjection namespace
- Integrated distributed SQL Server cache for EG services
- Improved DI structure and reduced obsolete warnings
2025-11-03 10:24:09 +01:00
3bc5439b5a feat(dependency-injection): add service configuration validation and simplify setup
- Removed unnecessary IConfiguration and SqlServerCacheOptions parameters from AddEnvelopeGenerator
- Added EnsureAllServicesConfigured() to validate that all required service methods are invoked
- Introduced _addingStatus dictionary to track configuration status
- Renamed internal queue field to _serviceRegs for consistency
- Added AddServices() method to explicitly register EnvelopeGenerator services
- Improved AddLocalization() to support optional custom localization options
2025-11-03 09:30:43 +01:00
22b494a262 refactor(di): unify Application and Infrastructure DI registrations under a central method
- Added central AddEnvelopeGenerator extension to aggregate existing DI setups
- Introduced EGConfiguration for modular service registration
- Standardized configuration pattern for Application and Infrastructure layers
- Simplified distributed cache and localization registration
2025-11-03 08:44:22 +01:00
209785dda5 refactor(DependencyInjection): created to handle DependencyInjection 2025-10-31 11:31:39 +01:00
44ea893f05 move memory-cache injection to Application-layer 2025-10-31 10:58:22 +01:00
b4aa7984aa chore(Application): Update your packages with vulnerabilities
- Added `SixLabors.ImageSharp` (v3.1.12) to main package references.
- Added `System.Formats.Asn1` for all target frameworks:
  - net7.0 → v8.0.2
  - net8.0, net9.0 → v9.0.10
2025-10-31 10:34:25 +01:00
7c5a505ad1 add serilog 2025-10-31 10:23:11 +01:00
bd6d57e1e8 feat: integrate EnvelopeGenerator infrastructure, DB context, and services
- Added references to EnvelopeGenerator.Application, Infrastructure, and EF Core.
- Configured DB context with SQL Server connection string from configuration.
- Registered EnvelopeGenerator services and infrastructure with dependency injection.
- Preserved warnings suppression for obsolete members.
- Structured DI registration under a dedicated region for clarity.
2025-10-30 17:05:45 +01:00
8403ce2c6a init EnvelopeGenerator.Finalizer 2025-10-30 16:31:22 +01:00
170 changed files with 4737 additions and 3366 deletions

View File

@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>EnvelopeGenerator.Application.VB</RootNamespace>
<TargetFrameworks>net7.0;net8.0;net9.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DevExpress.Data" Version="21.2.4" />
<PackageReference Include="DevExpress.Reporting.Core" Version="21.2.4" />
<PackageReference Include="DevExpress.Win" Version="21.2.0" />
<PackageReference Include="DevExpress.Xpo" Version="21.2.4" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<Compile Update="Reports\rptEnvelopeHistory.vb">
<SubType>Component</SubType>
</Compile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,730 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Public Class rptEnvelopeHistory
Inherits DevExpress.XtraReports.UI.XtraReport
'XtraReport overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Designer
'It can be modified using the Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(rptEnvelopeHistory))
Me.TopMargin = New DevExpress.XtraReports.UI.TopMarginBand()
Me.BottomMargin = New DevExpress.XtraReports.UI.BottomMarginBand()
Me.XrLabel1 = New DevExpress.XtraReports.UI.XRLabel()
Me.pageInfo1 = New DevExpress.XtraReports.UI.XRPageInfo()
Me.pageInfo2 = New DevExpress.XtraReports.UI.XRPageInfo()
Me.ReportHeader = New DevExpress.XtraReports.UI.ReportHeaderBand()
Me.label1 = New DevExpress.XtraReports.UI.XRLabel()
Me.XrTable3 = New DevExpress.XtraReports.UI.XRTable()
Me.XrTableRow8 = New DevExpress.XtraReports.UI.XRTableRow()
Me.XrTableCell13 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell15 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableRow9 = New DevExpress.XtraReports.UI.XRTableRow()
Me.XrTableCell14 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell17 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell16 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell18 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableRow10 = New DevExpress.XtraReports.UI.XRTableRow()
Me.XrTableCell19 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell20 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell21 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell22 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableRow11 = New DevExpress.XtraReports.UI.XRTableRow()
Me.XrTableCell23 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell24 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell25 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell26 = New DevExpress.XtraReports.UI.XRTableCell()
Me.GroupHeader1 = New DevExpress.XtraReports.UI.GroupHeaderBand()
Me.table1 = New DevExpress.XtraReports.UI.XRTable()
Me.tableRow1 = New DevExpress.XtraReports.UI.XRTableRow()
Me.tableCell1 = New DevExpress.XtraReports.UI.XRTableCell()
Me.tableCell2 = New DevExpress.XtraReports.UI.XRTableCell()
Me.tableCell3 = New DevExpress.XtraReports.UI.XRTableCell()
Me.Detail = New DevExpress.XtraReports.UI.DetailBand()
Me.table2 = New DevExpress.XtraReports.UI.XRTable()
Me.tableRow2 = New DevExpress.XtraReports.UI.XRTableRow()
Me.tableCell4 = New DevExpress.XtraReports.UI.XRTableCell()
Me.tableCell5 = New DevExpress.XtraReports.UI.XRTableCell()
Me.tableCell6 = New DevExpress.XtraReports.UI.XRTableCell()
Me.Title = New DevExpress.XtraReports.UI.XRControlStyle()
Me.DetailCaption1 = New DevExpress.XtraReports.UI.XRControlStyle()
Me.DetailData1 = New DevExpress.XtraReports.UI.XRControlStyle()
Me.DetailData3_Odd = New DevExpress.XtraReports.UI.XRControlStyle()
Me.PageInfo = New DevExpress.XtraReports.UI.XRControlStyle()
Me.GalleryDropDown1 = New DevExpress.XtraBars.Ribbon.GalleryDropDown(Me.components)
Me.ObjectDataSource1 = New DevExpress.DataAccess.ObjectBinding.ObjectDataSource(Me.components)
CType(Me.XrTable3, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.table1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.table2, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.GalleryDropDown1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.ObjectDataSource1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me, System.ComponentModel.ISupportInitialize).BeginInit()
'
'TopMargin
'
Me.TopMargin.Dpi = 254.0!
Me.TopMargin.HeightF = 190.6042!
Me.TopMargin.Name = "TopMargin"
'
'BottomMargin
'
Me.BottomMargin.Controls.AddRange(New DevExpress.XtraReports.UI.XRControl() {Me.XrLabel1, Me.pageInfo1, Me.pageInfo2})
Me.BottomMargin.Dpi = 254.0!
Me.BottomMargin.Name = "BottomMargin"
'
'XrLabel1
'
Me.XrLabel1.BorderColor = System.Drawing.Color.FromArgb(CType(CType(165, Byte), Integer), CType(CType(36, Byte), Integer), CType(CType(49, Byte), Integer))
Me.XrLabel1.Borders = DevExpress.XtraPrinting.BorderSide.Top
Me.XrLabel1.Dpi = 254.0!
Me.XrLabel1.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold)
Me.XrLabel1.LocationFloat = New DevExpress.Utils.PointFloat(896.5417!, 0!)
Me.XrLabel1.Name = "XrLabel1"
Me.XrLabel1.Padding = New DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 254.0!)
Me.XrLabel1.SizeF = New System.Drawing.SizeF(645.5836!, 58.0!)
Me.XrLabel1.StyleName = "Title"
Me.XrLabel1.StylePriority.UseBorderColor = False
Me.XrLabel1.StylePriority.UseBorders = False
Me.XrLabel1.StylePriority.UseFont = False
Me.XrLabel1.StylePriority.UsePadding = False
Me.XrLabel1.Text = "Erstellt mit SignFlow"
'
'pageInfo1
'
Me.pageInfo1.BorderColor = System.Drawing.Color.FromArgb(CType(CType(165, Byte), Integer), CType(CType(36, Byte), Integer), CType(CType(49, Byte), Integer))
Me.pageInfo1.Borders = DevExpress.XtraPrinting.BorderSide.Top
Me.pageInfo1.Dpi = 254.0!
Me.pageInfo1.LocationFloat = New DevExpress.Utils.PointFloat(0!, 0!)
Me.pageInfo1.Name = "pageInfo1"
Me.pageInfo1.PageInfo = DevExpress.XtraPrinting.PageInfo.DateTime
Me.pageInfo1.SizeF = New System.Drawing.SizeF(896.5417!, 58.0!)
Me.pageInfo1.StyleName = "PageInfo"
Me.pageInfo1.StylePriority.UseBorderColor = False
Me.pageInfo1.StylePriority.UseBorders = False
Me.pageInfo1.TextFormatString = "{0:dddd, d. MMMM yyyy HH:mm}"
'
'pageInfo2
'
Me.pageInfo2.BorderColor = System.Drawing.Color.FromArgb(CType(CType(165, Byte), Integer), CType(CType(36, Byte), Integer), CType(CType(49, Byte), Integer))
Me.pageInfo2.Borders = DevExpress.XtraPrinting.BorderSide.Top
Me.pageInfo2.Dpi = 254.0!
Me.pageInfo2.LocationFloat = New DevExpress.Utils.PointFloat(1542.125!, 0!)
Me.pageInfo2.Name = "pageInfo2"
Me.pageInfo2.SizeF = New System.Drawing.SizeF(357.875!, 58.0!)
Me.pageInfo2.StyleName = "PageInfo"
Me.pageInfo2.StylePriority.UseBorderColor = False
Me.pageInfo2.StylePriority.UseBorders = False
Me.pageInfo2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight
Me.pageInfo2.TextFormatString = "Seite {0} von {1}"
'
'ReportHeader
'
Me.ReportHeader.Controls.AddRange(New DevExpress.XtraReports.UI.XRControl() {Me.label1, Me.XrTable3})
Me.ReportHeader.Dpi = 254.0!
Me.ReportHeader.HeightF = 406.0843!
Me.ReportHeader.Name = "ReportHeader"
'
'label1
'
Me.label1.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer))
Me.label1.BorderColor = System.Drawing.Color.FromArgb(CType(CType(165, Byte), Integer), CType(CType(36, Byte), Integer), CType(CType(49, Byte), Integer))
Me.label1.Borders = DevExpress.XtraPrinting.BorderSide.Bottom
Me.label1.BorderWidth = 2.0!
Me.label1.Dpi = 254.0!
Me.label1.Font = New System.Drawing.Font("Segoe UI", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.label1.ForeColor = System.Drawing.Color.Black
Me.label1.LocationFloat = New DevExpress.Utils.PointFloat(0.0002422333!, 0!)
Me.label1.Name = "label1"
Me.label1.Padding = New DevExpress.XtraPrinting.PaddingInfo(10, 10, 5, 5, 254.0!)
Me.label1.SizeF = New System.Drawing.SizeF(1900.0!, 77.32857!)
Me.label1.StyleName = "Title"
Me.label1.StylePriority.UseBackColor = False
Me.label1.StylePriority.UseBorderColor = False
Me.label1.StylePriority.UseBorders = False
Me.label1.StylePriority.UseBorderWidth = False
Me.label1.StylePriority.UseFont = False
Me.label1.StylePriority.UseForeColor = False
Me.label1.StylePriority.UsePadding = False
Me.label1.Text = "Signierungszertifikat"
'
'XrTable3
'
Me.XrTable3.Dpi = 254.0!
Me.XrTable3.LocationFloat = New DevExpress.Utils.PointFloat(0.0002422333!, 96.60422!)
Me.XrTable3.Name = "XrTable3"
Me.XrTable3.OddStyleName = "DetailData3_Odd"
Me.XrTable3.Rows.AddRange(New DevExpress.XtraReports.UI.XRTableRow() {Me.XrTableRow8, Me.XrTableRow9, Me.XrTableRow10, Me.XrTableRow11})
Me.XrTable3.SizeF = New System.Drawing.SizeF(1900.0!, 284.4801!)
'
'XrTableRow8
'
Me.XrTableRow8.Cells.AddRange(New DevExpress.XtraReports.UI.XRTableCell() {Me.XrTableCell13, Me.XrTableCell15})
Me.XrTableRow8.Dpi = 254.0!
Me.XrTableRow8.Name = "XrTableRow8"
Me.XrTableRow8.Weight = 1.0R
'
'XrTableCell13
'
Me.XrTableCell13.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer))
Me.XrTableCell13.BorderColor = System.Drawing.Color.FromArgb(CType(CType(165, Byte), Integer), CType(CType(36, Byte), Integer), CType(CType(49, Byte), Integer))
Me.XrTableCell13.Borders = DevExpress.XtraPrinting.BorderSide.Bottom
Me.XrTableCell13.BorderWidth = 1.0!
Me.XrTableCell13.Dpi = 254.0!
Me.XrTableCell13.ForeColor = System.Drawing.Color.Black
Me.XrTableCell13.Name = "XrTableCell13"
Me.XrTableCell13.StyleName = "DetailCaption1"
Me.XrTableCell13.StylePriority.UseBackColor = False
Me.XrTableCell13.StylePriority.UseBorderColor = False
Me.XrTableCell13.StylePriority.UseBorders = False
Me.XrTableCell13.StylePriority.UseBorderWidth = False
Me.XrTableCell13.StylePriority.UseForeColor = False
Me.XrTableCell13.Text = "Ersteller"
Me.XrTableCell13.Weight = 0.38139956730411484R
'
'XrTableCell15
'
Me.XrTableCell15.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer))
Me.XrTableCell15.BorderColor = System.Drawing.Color.FromArgb(CType(CType(165, Byte), Integer), CType(CType(36, Byte), Integer), CType(CType(49, Byte), Integer))
Me.XrTableCell15.Borders = DevExpress.XtraPrinting.BorderSide.Bottom
Me.XrTableCell15.BorderWidth = 1.0!
Me.XrTableCell15.Dpi = 254.0!
Me.XrTableCell15.ForeColor = System.Drawing.Color.Black
Me.XrTableCell15.Name = "XrTableCell15"
Me.XrTableCell15.StyleName = "DetailCaption1"
Me.XrTableCell15.StylePriority.UseBackColor = False
Me.XrTableCell15.StylePriority.UseBorderColor = False
Me.XrTableCell15.StylePriority.UseBorders = False
Me.XrTableCell15.StylePriority.UseBorderWidth = False
Me.XrTableCell15.StylePriority.UseForeColor = False
Me.XrTableCell15.Text = "Umschlag"
Me.XrTableCell15.Weight = 0.49859081604996847R
'
'XrTableRow9
'
Me.XrTableRow9.Cells.AddRange(New DevExpress.XtraReports.UI.XRTableCell() {Me.XrTableCell14, Me.XrTableCell17, Me.XrTableCell16, Me.XrTableCell18})
Me.XrTableRow9.Dpi = 254.0!
Me.XrTableRow9.Name = "XrTableRow9"
Me.XrTableRow9.Weight = 1.0R
'
'XrTableCell14
'
Me.XrTableCell14.BackColor = System.Drawing.Color.White
Me.XrTableCell14.BorderColor = System.Drawing.Color.Empty
Me.XrTableCell14.Borders = DevExpress.XtraPrinting.BorderSide.None
Me.XrTableCell14.Dpi = 254.0!
Me.XrTableCell14.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.XrTableCell14.ForeColor = System.Drawing.Color.Black
Me.XrTableCell14.Multiline = True
Me.XrTableCell14.Name = "XrTableCell14"
Me.XrTableCell14.StyleName = "DetailCaption1"
Me.XrTableCell14.StylePriority.UseBackColor = False
Me.XrTableCell14.StylePriority.UseBorderColor = False
Me.XrTableCell14.StylePriority.UseBorders = False
Me.XrTableCell14.StylePriority.UseFont = False
Me.XrTableCell14.StylePriority.UseForeColor = False
Me.XrTableCell14.Text = "Name"
Me.XrTableCell14.Weight = 0.11578820509129036R
'
'XrTableCell17
'
Me.XrTableCell17.BackColor = System.Drawing.Color.White
Me.XrTableCell17.BorderColor = System.Drawing.Color.Empty
Me.XrTableCell17.Borders = DevExpress.XtraPrinting.BorderSide.None
Me.XrTableCell17.Dpi = 254.0!
Me.XrTableCell17.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Envelope].[User].[FullName]")})
Me.XrTableCell17.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.XrTableCell17.ForeColor = System.Drawing.Color.Black
Me.XrTableCell17.Multiline = True
Me.XrTableCell17.Name = "XrTableCell17"
Me.XrTableCell17.StyleName = "DetailCaption1"
Me.XrTableCell17.StylePriority.UseBackColor = False
Me.XrTableCell17.StylePriority.UseBorderColor = False
Me.XrTableCell17.StylePriority.UseBorders = False
Me.XrTableCell17.StylePriority.UseFont = False
Me.XrTableCell17.StylePriority.UseForeColor = False
Me.XrTableCell17.Text = "XrTableCell17"
Me.XrTableCell17.Weight = 0.2656113622128245R
'
'XrTableCell16
'
Me.XrTableCell16.BackColor = System.Drawing.Color.White
Me.XrTableCell16.BorderColor = System.Drawing.Color.Empty
Me.XrTableCell16.Borders = DevExpress.XtraPrinting.BorderSide.None
Me.XrTableCell16.Dpi = 254.0!
Me.XrTableCell16.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.XrTableCell16.ForeColor = System.Drawing.Color.Black
Me.XrTableCell16.Multiline = True
Me.XrTableCell16.Name = "XrTableCell16"
Me.XrTableCell16.StyleName = "DetailCaption1"
Me.XrTableCell16.StylePriority.UseBackColor = False
Me.XrTableCell16.StylePriority.UseBorderColor = False
Me.XrTableCell16.StylePriority.UseBorders = False
Me.XrTableCell16.StylePriority.UseFont = False
Me.XrTableCell16.StylePriority.UseForeColor = False
Me.XrTableCell16.Text = "Titel"
Me.XrTableCell16.Weight = 0.11578821158083684R
'
'XrTableCell18
'
Me.XrTableCell18.BackColor = System.Drawing.Color.White
Me.XrTableCell18.BorderColor = System.Drawing.Color.Empty
Me.XrTableCell18.Borders = DevExpress.XtraPrinting.BorderSide.None
Me.XrTableCell18.Dpi = 254.0!
Me.XrTableCell18.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Envelope].[Title]")})
Me.XrTableCell18.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.XrTableCell18.ForeColor = System.Drawing.Color.Black
Me.XrTableCell18.Multiline = True
Me.XrTableCell18.Name = "XrTableCell18"
Me.XrTableCell18.StyleName = "DetailCaption1"
Me.XrTableCell18.StylePriority.UseBackColor = False
Me.XrTableCell18.StylePriority.UseBorderColor = False
Me.XrTableCell18.StylePriority.UseBorders = False
Me.XrTableCell18.StylePriority.UseFont = False
Me.XrTableCell18.StylePriority.UseForeColor = False
Me.XrTableCell18.Text = "XrTableCell18"
Me.XrTableCell18.Weight = 0.38280260446913167R
'
'XrTableRow10
'
Me.XrTableRow10.Cells.AddRange(New DevExpress.XtraReports.UI.XRTableCell() {Me.XrTableCell19, Me.XrTableCell20, Me.XrTableCell21, Me.XrTableCell22})
Me.XrTableRow10.Dpi = 254.0!
Me.XrTableRow10.Name = "XrTableRow10"
Me.XrTableRow10.Weight = 1.0R
'
'XrTableCell19
'
Me.XrTableCell19.BackColor = System.Drawing.Color.White
Me.XrTableCell19.BorderColor = System.Drawing.Color.Empty
Me.XrTableCell19.Borders = DevExpress.XtraPrinting.BorderSide.None
Me.XrTableCell19.Dpi = 254.0!
Me.XrTableCell19.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.XrTableCell19.ForeColor = System.Drawing.Color.Black
Me.XrTableCell19.Multiline = True
Me.XrTableCell19.Name = "XrTableCell19"
Me.XrTableCell19.StyleName = "DetailCaption1"
Me.XrTableCell19.StylePriority.UseBackColor = False
Me.XrTableCell19.StylePriority.UseBorderColor = False
Me.XrTableCell19.StylePriority.UseBorders = False
Me.XrTableCell19.StylePriority.UseFont = False
Me.XrTableCell19.StylePriority.UseForeColor = False
Me.XrTableCell19.Text = "EmailAddress"
Me.XrTableCell19.Weight = 0.11578820509129036R
'
'XrTableCell20
'
Me.XrTableCell20.BackColor = System.Drawing.Color.White
Me.XrTableCell20.BorderColor = System.Drawing.Color.Empty
Me.XrTableCell20.Borders = DevExpress.XtraPrinting.BorderSide.None
Me.XrTableCell20.Dpi = 254.0!
Me.XrTableCell20.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Envelope].[User].[EmailAddress]")})
Me.XrTableCell20.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.XrTableCell20.ForeColor = System.Drawing.Color.Black
Me.XrTableCell20.Multiline = True
Me.XrTableCell20.Name = "XrTableCell20"
Me.XrTableCell20.StyleName = "DetailCaption1"
Me.XrTableCell20.StylePriority.UseBackColor = False
Me.XrTableCell20.StylePriority.UseBorderColor = False
Me.XrTableCell20.StylePriority.UseBorders = False
Me.XrTableCell20.StylePriority.UseFont = False
Me.XrTableCell20.StylePriority.UseForeColor = False
Me.XrTableCell20.Text = "XrTableCell20"
Me.XrTableCell20.Weight = 0.2656113622128245R
'
'XrTableCell21
'
Me.XrTableCell21.BackColor = System.Drawing.Color.White
Me.XrTableCell21.BorderColor = System.Drawing.Color.Empty
Me.XrTableCell21.Borders = DevExpress.XtraPrinting.BorderSide.None
Me.XrTableCell21.Dpi = 254.0!
Me.XrTableCell21.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.XrTableCell21.ForeColor = System.Drawing.Color.Black
Me.XrTableCell21.Multiline = True
Me.XrTableCell21.Name = "XrTableCell21"
Me.XrTableCell21.StyleName = "DetailCaption1"
Me.XrTableCell21.StylePriority.UseBackColor = False
Me.XrTableCell21.StylePriority.UseBorderColor = False
Me.XrTableCell21.StylePriority.UseBorders = False
Me.XrTableCell21.StylePriority.UseFont = False
Me.XrTableCell21.StylePriority.UseForeColor = False
Me.XrTableCell21.Text = "Umschlag-ID"
Me.XrTableCell21.Weight = 0.11578821158083684R
'
'XrTableCell22
'
Me.XrTableCell22.BackColor = System.Drawing.Color.White
Me.XrTableCell22.BorderColor = System.Drawing.Color.Empty
Me.XrTableCell22.Borders = DevExpress.XtraPrinting.BorderSide.None
Me.XrTableCell22.Dpi = 254.0!
Me.XrTableCell22.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Envelope].[Uuid]")})
Me.XrTableCell22.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.XrTableCell22.ForeColor = System.Drawing.Color.Black
Me.XrTableCell22.Multiline = True
Me.XrTableCell22.Name = "XrTableCell22"
Me.XrTableCell22.StyleName = "DetailCaption1"
Me.XrTableCell22.StylePriority.UseBackColor = False
Me.XrTableCell22.StylePriority.UseBorderColor = False
Me.XrTableCell22.StylePriority.UseBorders = False
Me.XrTableCell22.StylePriority.UseFont = False
Me.XrTableCell22.StylePriority.UseForeColor = False
Me.XrTableCell22.Text = "XrTableCell22"
Me.XrTableCell22.Weight = 0.38280260446913167R
'
'XrTableRow11
'
Me.XrTableRow11.Cells.AddRange(New DevExpress.XtraReports.UI.XRTableCell() {Me.XrTableCell23, Me.XrTableCell24, Me.XrTableCell25, Me.XrTableCell26})
Me.XrTableRow11.Dpi = 254.0!
Me.XrTableRow11.Name = "XrTableRow11"
Me.XrTableRow11.Weight = 1.0R
'
'XrTableCell23
'
Me.XrTableCell23.BackColor = System.Drawing.Color.White
Me.XrTableCell23.BorderColor = System.Drawing.Color.Empty
Me.XrTableCell23.Borders = DevExpress.XtraPrinting.BorderSide.None
Me.XrTableCell23.Dpi = 254.0!
Me.XrTableCell23.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.XrTableCell23.ForeColor = System.Drawing.Color.Black
Me.XrTableCell23.Multiline = True
Me.XrTableCell23.Name = "XrTableCell23"
Me.XrTableCell23.StyleName = "DetailCaption1"
Me.XrTableCell23.StylePriority.UseBackColor = False
Me.XrTableCell23.StylePriority.UseBorderColor = False
Me.XrTableCell23.StylePriority.UseBorders = False
Me.XrTableCell23.StylePriority.UseFont = False
Me.XrTableCell23.StylePriority.UseForeColor = False
Me.XrTableCell23.Weight = 0.11578820509129036R
'
'XrTableCell24
'
Me.XrTableCell24.BackColor = System.Drawing.Color.White
Me.XrTableCell24.BorderColor = System.Drawing.Color.Empty
Me.XrTableCell24.Borders = DevExpress.XtraPrinting.BorderSide.None
Me.XrTableCell24.Dpi = 254.0!
Me.XrTableCell24.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.XrTableCell24.ForeColor = System.Drawing.Color.Black
Me.XrTableCell24.Multiline = True
Me.XrTableCell24.Name = "XrTableCell24"
Me.XrTableCell24.StyleName = "DetailCaption1"
Me.XrTableCell24.StylePriority.UseBackColor = False
Me.XrTableCell24.StylePriority.UseBorderColor = False
Me.XrTableCell24.StylePriority.UseBorders = False
Me.XrTableCell24.StylePriority.UseFont = False
Me.XrTableCell24.StylePriority.UseForeColor = False
Me.XrTableCell24.Weight = 0.2656113622128245R
'
'XrTableCell25
'
Me.XrTableCell25.BackColor = System.Drawing.Color.White
Me.XrTableCell25.BorderColor = System.Drawing.Color.Empty
Me.XrTableCell25.Borders = DevExpress.XtraPrinting.BorderSide.None
Me.XrTableCell25.Dpi = 254.0!
Me.XrTableCell25.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.XrTableCell25.ForeColor = System.Drawing.Color.Black
Me.XrTableCell25.Multiline = True
Me.XrTableCell25.Name = "XrTableCell25"
Me.XrTableCell25.StyleName = "DetailCaption1"
Me.XrTableCell25.StylePriority.UseBackColor = False
Me.XrTableCell25.StylePriority.UseBorderColor = False
Me.XrTableCell25.StylePriority.UseBorders = False
Me.XrTableCell25.StylePriority.UseFont = False
Me.XrTableCell25.StylePriority.UseForeColor = False
Me.XrTableCell25.Text = "Zertifizierung"
Me.XrTableCell25.Weight = 0.11578821158083684R
'
'XrTableCell26
'
Me.XrTableCell26.BackColor = System.Drawing.Color.White
Me.XrTableCell26.BorderColor = System.Drawing.Color.Empty
Me.XrTableCell26.Borders = DevExpress.XtraPrinting.BorderSide.None
Me.XrTableCell26.Dpi = 254.0!
Me.XrTableCell26.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Envelope].[CertificationType]")})
Me.XrTableCell26.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.XrTableCell26.ForeColor = System.Drawing.Color.Black
Me.XrTableCell26.Multiline = True
Me.XrTableCell26.Name = "XrTableCell26"
Me.XrTableCell26.StyleName = "DetailCaption1"
Me.XrTableCell26.StylePriority.UseBackColor = False
Me.XrTableCell26.StylePriority.UseBorderColor = False
Me.XrTableCell26.StylePriority.UseBorders = False
Me.XrTableCell26.StylePriority.UseFont = False
Me.XrTableCell26.StylePriority.UseForeColor = False
Me.XrTableCell26.Text = "XrTableCell26"
Me.XrTableCell26.Weight = 0.38280260446913161R
'
'GroupHeader1
'
Me.GroupHeader1.Controls.AddRange(New DevExpress.XtraReports.UI.XRControl() {Me.table1})
Me.GroupHeader1.Dpi = 254.0!
Me.GroupHeader1.GroupUnion = DevExpress.XtraReports.UI.GroupUnion.WithFirstDetail
Me.GroupHeader1.HeightF = 71.12!
Me.GroupHeader1.Name = "GroupHeader1"
'
'table1
'
Me.table1.Dpi = 254.0!
Me.table1.LocationFloat = New DevExpress.Utils.PointFloat(0!, 0!)
Me.table1.Name = "table1"
Me.table1.Rows.AddRange(New DevExpress.XtraReports.UI.XRTableRow() {Me.tableRow1})
Me.table1.SizeF = New System.Drawing.SizeF(1900.0!, 71.12!)
'
'tableRow1
'
Me.tableRow1.Cells.AddRange(New DevExpress.XtraReports.UI.XRTableCell() {Me.tableCell1, Me.tableCell2, Me.tableCell3})
Me.tableRow1.Dpi = 254.0!
Me.tableRow1.Name = "tableRow1"
Me.tableRow1.Weight = 1.0R
'
'tableCell1
'
Me.tableCell1.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer))
Me.tableCell1.BorderColor = System.Drawing.Color.FromArgb(CType(CType(165, Byte), Integer), CType(CType(36, Byte), Integer), CType(CType(49, Byte), Integer))
Me.tableCell1.Borders = DevExpress.XtraPrinting.BorderSide.Bottom
Me.tableCell1.BorderWidth = 1.0!
Me.tableCell1.Dpi = 254.0!
Me.tableCell1.ForeColor = System.Drawing.Color.Black
Me.tableCell1.Name = "tableCell1"
Me.tableCell1.StyleName = "DetailCaption1"
Me.tableCell1.StylePriority.UseBackColor = False
Me.tableCell1.StylePriority.UseBorderColor = False
Me.tableCell1.StylePriority.UseBorders = False
Me.tableCell1.StylePriority.UseBorderWidth = False
Me.tableCell1.StylePriority.UseForeColor = False
Me.tableCell1.Text = "Ereignis"
Me.tableCell1.Weight = 0.51726482588176181R
'
'tableCell2
'
Me.tableCell2.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer))
Me.tableCell2.BorderColor = System.Drawing.Color.FromArgb(CType(CType(165, Byte), Integer), CType(CType(36, Byte), Integer), CType(CType(49, Byte), Integer))
Me.tableCell2.Borders = DevExpress.XtraPrinting.BorderSide.Bottom
Me.tableCell2.BorderWidth = 1.0!
Me.tableCell2.Dpi = 254.0!
Me.tableCell2.ForeColor = System.Drawing.Color.Black
Me.tableCell2.Name = "tableCell2"
Me.tableCell2.StyleName = "DetailCaption1"
Me.tableCell2.StylePriority.UseBackColor = False
Me.tableCell2.StylePriority.UseBorderColor = False
Me.tableCell2.StylePriority.UseBorders = False
Me.tableCell2.StylePriority.UseBorderWidth = False
Me.tableCell2.StylePriority.UseForeColor = False
Me.tableCell2.Text = "Benutzer"
Me.tableCell2.Weight = 0.45140669898958585R
'
'tableCell3
'
Me.tableCell3.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer))
Me.tableCell3.BorderColor = System.Drawing.Color.FromArgb(CType(CType(165, Byte), Integer), CType(CType(36, Byte), Integer), CType(CType(49, Byte), Integer))
Me.tableCell3.Borders = DevExpress.XtraPrinting.BorderSide.Bottom
Me.tableCell3.BorderWidth = 1.0!
Me.tableCell3.Dpi = 254.0!
Me.tableCell3.ForeColor = System.Drawing.Color.Black
Me.tableCell3.Name = "tableCell3"
Me.tableCell3.StyleName = "DetailCaption1"
Me.tableCell3.StylePriority.UseBackColor = False
Me.tableCell3.StylePriority.UseBorderColor = False
Me.tableCell3.StylePriority.UseBorders = False
Me.tableCell3.StylePriority.UseBorderWidth = False
Me.tableCell3.StylePriority.UseForeColor = False
Me.tableCell3.Text = "Zeitstempel"
Me.tableCell3.Weight = 0.22479583469004233R
'
'Detail
'
Me.Detail.Controls.AddRange(New DevExpress.XtraReports.UI.XRControl() {Me.table2})
Me.Detail.Dpi = 254.0!
Me.Detail.HeightF = 86.174!
Me.Detail.HierarchyPrintOptions.Indent = 50.8!
Me.Detail.Name = "Detail"
'
'table2
'
Me.table2.Dpi = 254.0!
Me.table2.LocationFloat = New DevExpress.Utils.PointFloat(0!, 0!)
Me.table2.Name = "table2"
Me.table2.Rows.AddRange(New DevExpress.XtraReports.UI.XRTableRow() {Me.tableRow2})
Me.table2.SizeF = New System.Drawing.SizeF(1900.0!, 63.42!)
'
'tableRow2
'
Me.tableRow2.Cells.AddRange(New DevExpress.XtraReports.UI.XRTableCell() {Me.tableCell4, Me.tableCell5, Me.tableCell6})
Me.tableRow2.Dpi = 254.0!
Me.tableRow2.Name = "tableRow2"
Me.tableRow2.Weight = 11.683999633789062R
'
'tableCell4
'
Me.tableCell4.Borders = DevExpress.XtraPrinting.BorderSide.None
Me.tableCell4.Dpi = 254.0!
Me.tableCell4.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[ItemStatusTranslated]")})
Me.tableCell4.Name = "tableCell4"
Me.tableCell4.StyleName = "DetailData1"
Me.tableCell4.StylePriority.UseBorders = False
Me.tableCell4.Weight = 0.51726482142156094R
'
'tableCell5
'
Me.tableCell5.Dpi = 254.0!
Me.tableCell5.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[ItemUserReference]")})
Me.tableCell5.Name = "tableCell5"
Me.tableCell5.StyleName = "DetailData1"
Me.tableCell5.Weight = 0.45140669932916544R
'
'tableCell6
'
Me.tableCell6.Dpi = 254.0!
Me.tableCell6.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[ItemDate]")})
Me.tableCell6.Name = "tableCell6"
Me.tableCell6.StyleName = "DetailData1"
Me.tableCell6.StylePriority.UseTextAlignment = False
Me.tableCell6.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight
Me.tableCell6.Weight = 0.22479581593269077R
'
'Title
'
Me.Title.BackColor = System.Drawing.Color.Transparent
Me.Title.BorderColor = System.Drawing.Color.Black
Me.Title.Borders = DevExpress.XtraPrinting.BorderSide.None
Me.Title.BorderWidth = 1.0!
Me.Title.Font = New System.Drawing.Font("Arial", 14.25!)
Me.Title.ForeColor = System.Drawing.Color.FromArgb(CType(CType(75, Byte), Integer), CType(CType(75, Byte), Integer), CType(CType(75, Byte), Integer))
Me.Title.Name = "Title"
Me.Title.Padding = New DevExpress.XtraPrinting.PaddingInfo(15, 15, 0, 0, 254.0!)
'
'DetailCaption1
'
Me.DetailCaption1.BackColor = System.Drawing.Color.FromArgb(CType(CType(75, Byte), Integer), CType(CType(75, Byte), Integer), CType(CType(75, Byte), Integer))
Me.DetailCaption1.BorderColor = System.Drawing.Color.White
Me.DetailCaption1.Borders = DevExpress.XtraPrinting.BorderSide.Left
Me.DetailCaption1.BorderWidth = 2.0!
Me.DetailCaption1.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold)
Me.DetailCaption1.ForeColor = System.Drawing.Color.White
Me.DetailCaption1.Name = "DetailCaption1"
Me.DetailCaption1.Padding = New DevExpress.XtraPrinting.PaddingInfo(15, 15, 0, 0, 254.0!)
Me.DetailCaption1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft
'
'DetailData1
'
Me.DetailData1.BorderColor = System.Drawing.Color.Transparent
Me.DetailData1.Borders = DevExpress.XtraPrinting.BorderSide.Left
Me.DetailData1.BorderWidth = 2.0!
Me.DetailData1.Font = New System.Drawing.Font("Arial", 8.25!)
Me.DetailData1.ForeColor = System.Drawing.Color.Black
Me.DetailData1.Name = "DetailData1"
Me.DetailData1.Padding = New DevExpress.XtraPrinting.PaddingInfo(15, 15, 0, 0, 254.0!)
Me.DetailData1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft
'
'DetailData3_Odd
'
Me.DetailData3_Odd.BackColor = System.Drawing.Color.FromArgb(CType(CType(231, Byte), Integer), CType(CType(231, Byte), Integer), CType(CType(231, Byte), Integer))
Me.DetailData3_Odd.BorderColor = System.Drawing.Color.Transparent
Me.DetailData3_Odd.Borders = DevExpress.XtraPrinting.BorderSide.None
Me.DetailData3_Odd.BorderWidth = 1.0!
Me.DetailData3_Odd.Font = New System.Drawing.Font("Arial", 8.25!)
Me.DetailData3_Odd.ForeColor = System.Drawing.Color.Black
Me.DetailData3_Odd.Name = "DetailData3_Odd"
Me.DetailData3_Odd.Padding = New DevExpress.XtraPrinting.PaddingInfo(15, 15, 0, 0, 254.0!)
Me.DetailData3_Odd.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft
'
'PageInfo
'
Me.PageInfo.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold)
Me.PageInfo.ForeColor = System.Drawing.Color.FromArgb(CType(CType(75, Byte), Integer), CType(CType(75, Byte), Integer), CType(CType(75, Byte), Integer))
Me.PageInfo.Name = "PageInfo"
Me.PageInfo.Padding = New DevExpress.XtraPrinting.PaddingInfo(15, 15, 0, 0, 254.0!)
'
'GalleryDropDown1
'
Me.GalleryDropDown1.Manager = Nothing
Me.GalleryDropDown1.Name = "GalleryDropDown1"
'
'ObjectDataSource1
'
Me.ObjectDataSource1.DataMember = "Items"
'Me.ObjectDataSource1.DataSource = GetType(EnvelopeGenerator.CommonServices.ReportSource)
Me.ObjectDataSource1.Name = "ObjectDataSource1"
'
'rptEnvelopeHistory
'
Me.Bands.AddRange(New DevExpress.XtraReports.UI.Band() {Me.TopMargin, Me.BottomMargin, Me.ReportHeader, Me.GroupHeader1, Me.Detail})
Me.ComponentStorage.AddRange(New System.ComponentModel.IComponent() {Me.ObjectDataSource1})
Me.DataSource = Me.ObjectDataSource1
Me.Dpi = 254.0!
Me.Font = New System.Drawing.Font("Arial", 9.75!)
Me.Margins = New System.Drawing.Printing.Margins(100, 100, 191, 100)
Me.PageHeight = 2970
Me.PageWidth = 2100
Me.PaperKind = System.Drawing.Printing.PaperKind.A4
Me.ReportUnit = DevExpress.XtraReports.UI.ReportUnit.TenthsOfAMillimeter
Me.SnapGridSize = 25.0!
Me.StyleSheet.AddRange(New DevExpress.XtraReports.UI.XRControlStyle() {Me.Title, Me.DetailCaption1, Me.DetailData1, Me.DetailData3_Odd, Me.PageInfo})
Me.Version = "21.2"
Me.Watermark.ImageSource = New DevExpress.XtraPrinting.Drawing.ImageSource("img", resources.GetString("rptEnvelopeHistory.Watermark.ImageSource"))
Me.Watermark.ImageTransparency = 220
CType(Me.XrTable3, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.table1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.table2, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.GalleryDropDown1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.ObjectDataSource1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me, System.ComponentModel.ISupportInitialize).EndInit()
End Sub
Friend WithEvents TopMargin As DevExpress.XtraReports.UI.TopMarginBand
Friend WithEvents BottomMargin As DevExpress.XtraReports.UI.BottomMarginBand
Friend WithEvents pageInfo1 As DevExpress.XtraReports.UI.XRPageInfo
Friend WithEvents pageInfo2 As DevExpress.XtraReports.UI.XRPageInfo
Friend WithEvents ReportHeader As DevExpress.XtraReports.UI.ReportHeaderBand
Friend WithEvents label1 As DevExpress.XtraReports.UI.XRLabel
Friend WithEvents GroupHeader1 As DevExpress.XtraReports.UI.GroupHeaderBand
Friend WithEvents table1 As DevExpress.XtraReports.UI.XRTable
Friend WithEvents tableRow1 As DevExpress.XtraReports.UI.XRTableRow
Friend WithEvents tableCell1 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents tableCell2 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents tableCell3 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents Detail As DevExpress.XtraReports.UI.DetailBand
Friend WithEvents table2 As DevExpress.XtraReports.UI.XRTable
Friend WithEvents tableRow2 As DevExpress.XtraReports.UI.XRTableRow
Friend WithEvents tableCell4 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents tableCell5 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents tableCell6 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents ObjectDataSource1 As DevExpress.DataAccess.ObjectBinding.ObjectDataSource
Friend WithEvents Title As DevExpress.XtraReports.UI.XRControlStyle
Friend WithEvents DetailCaption1 As DevExpress.XtraReports.UI.XRControlStyle
Friend WithEvents DetailData1 As DevExpress.XtraReports.UI.XRControlStyle
Friend WithEvents DetailData3_Odd As DevExpress.XtraReports.UI.XRControlStyle
Friend WithEvents PageInfo As DevExpress.XtraReports.UI.XRControlStyle
Friend WithEvents XrLabel1 As DevExpress.XtraReports.UI.XRLabel
Friend WithEvents XrTable3 As DevExpress.XtraReports.UI.XRTable
Friend WithEvents XrTableRow8 As DevExpress.XtraReports.UI.XRTableRow
Friend WithEvents XrTableCell13 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents XrTableCell15 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents XrTableRow9 As DevExpress.XtraReports.UI.XRTableRow
Friend WithEvents XrTableCell14 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents XrTableCell17 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents XrTableCell16 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents XrTableCell18 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents XrTableRow10 As DevExpress.XtraReports.UI.XRTableRow
Friend WithEvents XrTableCell19 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents XrTableCell20 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents XrTableCell21 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents XrTableCell22 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents XrTableRow11 As DevExpress.XtraReports.UI.XRTableRow
Friend WithEvents XrTableCell23 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents XrTableCell24 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents XrTableCell25 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents XrTableCell26 As DevExpress.XtraReports.UI.XRTableCell
Friend WithEvents GalleryDropDown1 As DevExpress.XtraBars.Ribbon.GalleryDropDown
End Class

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
Public Class rptEnvelopeHistory
End Class

View File

@@ -0,0 +1,12 @@
namespace EnvelopeGenerator.Application.Common.Configurations;
/// <summary>
///
/// </summary>
public class GdPictureParams
{
/// <summary>
///
/// </summary>
public string License { get; set; } = null!;
}

View File

@@ -0,0 +1,78 @@
using EnvelopeGenerator.Application.Common.Interfaces.Model;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
namespace EnvelopeGenerator.Application.Common.Configurations;
/// <summary>
///
/// </summary>
public class PDFBurnerParams : ITextStyle
{
/// <summary>
///
/// </summary>
public int ConcurrencyLimit { get; set; } = 5;
/// <summary>
///
/// </summary>
public IEnumerable<string> IgnoredLabels { get; set; } = new List<string>
{
"Date", "Datum", "ZIP", "PLZ", "Place", "Ort", "Position", "Stellung"
};
/// <summary>
///
/// </summary>
public double TopMargin { get; set; } = 0.1;
/// <summary>
///
/// </summary>
public double YOffset { get; set; } = -0.3;
/// <summary>
///
/// </summary>
public string FontName { get; set; } = "Arial";
/// <summary>
///
/// </summary>
public int FontSize { get; set; } = 8;
/// <summary>
///
/// </summary>
[SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
public FontStyle FontStyle { get; set; } = FontStyle.Italic;
/// <summary>
///
/// </summary>
public Dictionary<string, int> IndexOfAnnot { get; init; } = new()
{
{ string.Empty, 0 },
{ "seal", 0 },
{ "position", 1 },
{ "city", 2 },
{ "date", 3 }
};
/// <summary>
///
/// </summary>
public int DefaultIndexOfAnnot { get; set; } = 0;
/// <summary>
///
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public int GetAnnotationIndex(string name) => IndexOfAnnot.TryGetValue(name, out var value) ? value : DefaultIndexOfAnnot;
}

View File

@@ -74,11 +74,6 @@ public record EnvelopeDto
/// </summary>
public int? EnvelopeTypeId { get; set; }
/// <summary>
///
/// </summary>
public bool ReadOnly => EnvelopeTypeId == 2;
/// <summary>
///
/// </summary>
@@ -87,7 +82,7 @@ public record EnvelopeDto
/// <summary>
///
/// </summary>
public bool UseAccessCode { get; set; } = true;
public bool? UseAccessCode { get; set; }
/// <summary>
///

View File

@@ -0,0 +1,44 @@
namespace EnvelopeGenerator.Application.Common.Dto;
/// <summary>
///
/// </summary>
public record EnvelopeReportDto
{
/// <summary>
///
/// </summary>
public int EnvelopeId { get; set; }
// --- HEAD ---
/// <summary>
///
/// </summary>
public string HeadUuid { get; set; } = null!;
/// <summary>
///
/// </summary>
public string EnvelopeTitle { get; set; } = string.Empty;
/// <summary>
///
/// </summary>
public string HeadMessage { get; set; } = null!;
// --- POSITIONS ---
/// <summary>
///
/// </summary>
public int ItemStatus { get; set; }
/// <summary>
///
/// </summary>
public DateTime? ItemDate { get; set; }
/// <summary>
///
/// </summary>
public string ItemUserReference { get; set; } = null!;
}

View File

@@ -36,6 +36,8 @@ public class MappingProfile : Profile
CreateMap<Domain.Entities.Receiver, ReceiverDto>();
CreateMap<Domain.Entities.EnvelopeReceiverReadOnly, EnvelopeReceiverReadOnlyDto>();
CreateMap<ElementAnnotation, AnnotationDto>();
CreateMap<ThirdPartyModule, ThirdPartyModuleDto>();
CreateMap<EnvelopeReport, EnvelopeReportDto>();
// DTO to Entity mappings
CreateMap<ConfigDto, Config>();

View File

@@ -0,0 +1,122 @@
using EnvelopeGenerator.Application.Exceptions;
namespace EnvelopeGenerator.Application.Common.Dto.PSPDFKitInstant;
/// <summary>
///
/// </summary>
public class Annotation
{
private string? _id;
/// <summary>
///
/// </summary>
public int EnvelopeId { get; private set; } = 0;
/// <summary>
///
/// </summary>
public int ReceiverId { get; private set; } = 0;
/// <summary>
///
/// </summary>
public int Index { get; private set; } = 0;
/// <summary>
///
/// </summary>
public string EgName { get; private set; } = string.Empty;
/// <summary>
///
/// </summary>
public bool HasStructuredID { get; private set; } = false;
/// <summary>
///
/// </summary>
public bool IsLabel
{
get
{
if (string.IsNullOrEmpty(EgName))
return false;
var parts = EgName.Split('_');
return parts.Length > 1 && parts[1] == "label";
}
}
/// <summary>
///
/// </summary>
public string? Id
{
get => _id;
set
{
_id = value;
if (string.IsNullOrWhiteSpace(value))
throw new BurnAnnotationException("The identifier of annotation is null or empty.");
var parts = value.Split('#');
if (parts.Length != 4)
return;
// throw new BurnAnnotationException($"The identifier of annotation has more or less than 4 sub-part. Id: {_id}");
if (!int.TryParse(parts[0], out int envelopeId))
throw new BurnAnnotationException($"The envelope ID of annotation is not integer. Id: {_id}");
EnvelopeId = envelopeId;
if (!int.TryParse(parts[1], out int receiverId))
throw new BurnAnnotationException($"The receiver ID of annotation is not integer. Id: {_id}");
ReceiverId = receiverId;
if (!int.TryParse(parts[2], out int index))
throw new BurnAnnotationException($"The index of annotation is not integer. Id: {_id}");
Index = index;
EgName = parts[3];
HasStructuredID = true;
}
}
/// <summary>
///
/// </summary>
public List<double>? Bbox { get; set; }
/// <summary>
///
/// </summary>
public string? Type { get; set; }
/// <summary>
///
/// </summary>
public bool IsSignature { get; set; }
/// <summary>
///
/// </summary>
public string? ImageAttachmentId { get; set; }
/// <summary>
///
/// </summary>
public Lines? Lines { get; set; }
/// <summary>
///
/// </summary>
public int PageIndex { get; set; }
/// <summary>
///
/// </summary>
public string? StrokeColor { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace EnvelopeGenerator.Application.Common.Dto.PSPDFKitInstant;
/// <summary>
///
/// </summary>
/// <param name="Binary"></param>
/// <param name="ContentType"></param>
public record Attachment(string Binary, string ContentType);

View File

@@ -0,0 +1,8 @@
namespace EnvelopeGenerator.Application.Common.Dto.PSPDFKitInstant;
/// <summary>
///
/// </summary>
/// <param name="Name"></param>
/// <param name="Value"></param>
public record FormFieldValue(string Name, string? Value = null);

View File

@@ -0,0 +1,8 @@
namespace EnvelopeGenerator.Application.Common.Dto.PSPDFKitInstant;
/// <summary>
///
/// </summary>
/// <param name="Lines"></param>
/// <param name="StrokeColor"></param>
public record Ink(Lines Lines, string? StrokeColor = null);

View File

@@ -0,0 +1,50 @@
namespace EnvelopeGenerator.Application.Common.Dto.PSPDFKitInstant;
/// <summary>
///
/// </summary>
public class InstantData
{
/// <summary>
///
/// </summary>
public List<Annotation>? Annotations { get; set; }
/// <summary>
///
/// </summary>
public IEnumerable<List<Annotation>>? AnnotationsByReceiver
{
get
{
return Annotations?
.Where(a => a.HasStructuredID)
.GroupBy(a => a.ReceiverId)
.Select(g => g.ToList());
}
}
/// <summary>
///
/// </summary>
public IEnumerable<List<Annotation>>? UnstructuredAnnotations
{
get
{
return Annotations?
.Where(a => !a.HasStructuredID)
.GroupBy(a => a.ReceiverId)
.Select(g => g.ToList());
}
}
/// <summary>
///
/// </summary>
public Dictionary<string, Attachment>? Attachments { get; set; }
/// <summary>
///
/// </summary>
public List<FormFieldValue>? FormFieldValues { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace EnvelopeGenerator.Application.Common.Dto.PSPDFKitInstant;
/// <summary>
///
/// </summary>
/// <param name="Points"></param>
public record Lines(List<List<List<float>>> Points);

View File

@@ -0,0 +1,57 @@
namespace EnvelopeGenerator.Application.Common.Dto;
/// <summary>
///
/// </summary>
public record ThirdPartyModuleDto
{
/// <summary>
///
/// </summary>
public int Id { get; init; }
/// <summary>
///
/// </summary>
public bool Active { get; init; }
/// <summary>
///
/// </summary>
public string Name { get; init; } = default!;
/// <summary>
///
/// </summary>
public string? Description { get; init; }
/// <summary>
///
/// </summary>
public string License { get; init; } = default!;
/// <summary>
///
/// </summary>
public string Version { get; init; } = default!;
/// <summary>
///
/// </summary>
public string? AddedWho { get; init; }
/// <summary>
///
/// </summary>
public DateTime? AddedWhen { get; init; }
/// <summary>
///
/// </summary>
public string? ChangedWho { get; init; }
/// <summary>
///
/// </summary>
public DateTime? ChangedWhen { get; init; }
}

View File

@@ -0,0 +1,176 @@
using EnvelopeGenerator.Application.Common.Dto.PSPDFKitInstant;
using EnvelopeGenerator.Domain.Constants;
using GdPicture14;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using SixLabors.ImageSharp;
using System.Drawing;
using EnvelopeGenerator.Application.Common.Extensions;
using EnvelopeGenerator.Application.Common.Interfaces.Model;
using EnvelopeGenerator.Application.Common.Configurations;
namespace EnvelopeGenerator.Application.Common.Extensions;
/// <summary>
///
/// </summary>
public static class GdPictureExtensions
{
/// <summary>
///
/// </summary>
/// <param name="manager"></param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="page"></param>
/// <param name="value"></param>
/// <param name="textStyle"></param>
public static void AddFormFieldValue(this AnnotationManager manager, double x, double y, double width, double height, int page, string value, ITextStyle textStyle)
{
manager.SelectPage(page);
// Add the text annotation
var ant = manager.AddTextAnnot((float)x, (float)y, (float)width, (float)height, value);
// Set the font properties
ant.FontName = textStyle.FontName;
ant.FontSize = textStyle.FontSize;
ant.FontStyle = textStyle.FontStyle;
manager.SaveAnnotationsToPage();
}
/// <summary>
///
/// </summary>
/// <param name="manager"></param>
/// <param name="pAnnotation"></param>
/// <param name="formFieldValue"></param>
/// <param name="options"></param>
public static void AddFormFieldValue(this AnnotationManager manager, Annotation pAnnotation, FormFieldValue formFieldValue, PDFBurnerParams options)
{
var ffIndex = options.GetAnnotationIndex(pAnnotation.EgName);
// Convert pixels to Inches
var oBounds = pAnnotation.Bbox?.Select(points => points.ToInches()).ToList();
if (oBounds is null || oBounds.Count < 4)
return;
double oX = oBounds[0];
double oY = oBounds[1] + options.YOffset * ffIndex + options.TopMargin;
double oWidth = oBounds[2];
double oHeight = oBounds[3];
manager.SelectPage(pAnnotation.PageIndex + 1);
// Add the text annotation
var ant = manager.AddTextAnnot((float)oX, (float)oY, (float)oWidth, (float)oHeight, formFieldValue.Value);
// Set the font properties
ant.FontName = options.FontName;
ant.FontSize = options.FontSize;
ant.FontStyle = options.FontStyle;
manager.SaveAnnotationsToPage();
}
/// <summary>
///
/// </summary>
/// <param name="manager"></param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="page"></param>
/// <param name="base64"></param>
public static void AddImageAnnotation(this AnnotationManager manager, double x, double y, double width, double height, int page, string base64)
{
manager.SelectPage(page);
manager.AddEmbeddedImageAnnotFromBase64(base64, (float)x, (float)y, (float)width, (float)height);
}
/// <summary>
///
/// </summary>
/// <param name="manager"></param>
/// <param name="pAnnotation"></param>
/// <param name="pAttachments"></param>
public static void AddImageAnnotation(this AnnotationManager manager, Annotation pAnnotation, Dictionary<string, Attachment> pAttachments)
{
var oAttachment = pAttachments
.Where(a => a.Key == pAnnotation.ImageAttachmentId)
.SingleOrDefault();
if (oAttachment.Value == null)
return;
// Convert pixels to Inches
var oBounds = pAnnotation.Bbox?.Select(post => post.ToInches()).ToList();
if (oBounds is null || oBounds.Count < 4)
return;
var oX = oBounds[0];
var oY = oBounds[1];
var oWidth = oBounds[2];
var oHeight = oBounds[3];
manager.SelectPage(pAnnotation.PageIndex + 1);
manager.AddEmbeddedImageAnnotFromBase64(oAttachment.Value.Binary, (float)oX, (float)oY, (float)oWidth, (float)oHeight);
}
/// <summary>
///
/// </summary>
/// <param name="manager"></param>
/// <param name="page"></param>
/// <param name="value"></param>
public static void AddInkAnnotation(this AnnotationManager manager, int page, string value)
{
var ink = JsonConvert.DeserializeObject<Ink>(value);
var oSegments = ink?.Lines.Points;
var oColor = ColorTranslator.FromHtml(ink?.StrokeColor ?? "#000000");
manager.SelectPage(page);
if (oSegments is null)
return;
foreach (var oSegment in oSegments)
{
var oPoints = oSegment
.Select(points => points.ToPointF())
.ToArray();
manager.AddFreeHandAnnot(oColor, oPoints);
}
}
/// <summary>
///
/// </summary>
/// <param name="manager"></param>
/// <param name="pAnnotation"></param>
public static void AddInkAnnotation(this AnnotationManager manager, Annotation pAnnotation)
{
var oSegments = pAnnotation.Lines?.Points;
var oColor = ColorTranslator.FromHtml(pAnnotation.StrokeColor ?? "#000000");
manager.SelectPage(pAnnotation.PageIndex + 1);
if (oSegments is null)
return;
foreach (var oSegment in oSegments)
{
var oPoints = oSegment
.Select(points => points.ToPointF())
.ToArray();
manager.AddFreeHandAnnot(oColor, oPoints);
}
}
}

View File

@@ -0,0 +1,40 @@
using System.Drawing;
namespace EnvelopeGenerator.Application.Common.Extensions;
/// <summary>
///
/// </summary>
public static class MathematExtensions
{
/// <summary>
///
/// </summary>
/// <param name="points"></param>
/// <returns></returns>
public static PointF ToPointF(this List<float> points)
{
var pointsInch = points.Select(ToInches).ToList();
return new PointF(pointsInch[0], pointsInch[1]);
}
/// <summary>
///
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static double ToInches(this double value)
{
return value / 72.0;
}
/// <summary>
///
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static float ToInches(this float value)
{
return value / 72f;
}
}

View File

@@ -5,7 +5,6 @@ namespace EnvelopeGenerator.Application.Common.Extensions;
/// <summary>
/// Extension methods for tasks
/// </summary>
[Obsolete("Implement Mediator behaviors in the Osolete .NET project.")]
public static class TaskExtensions
{
/// <summary>
@@ -18,7 +17,6 @@ public static class TaskExtensions
/// <param name="factory">Exception provider</param>
/// <returns>The awaited result if not <c>null</c>.</returns>
/// <exception>Thrown if the result is <c>null</c>.</exception>
[Obsolete("Implement Mediator behaviors in the Osolete .NET project.")]
public static async Task<T> ThrowIfNull<T, TException>(this Task<T?> task, Func<TException> factory) where TException : Exception
{
var result = await task;
@@ -35,7 +33,6 @@ public static class TaskExtensions
/// <param name="factory">Exception provider</param>
/// <returns>The awaited collection if it is not <c>null</c> or empty.</returns>
/// <exception cref="NotFoundException">Thrown if the result is <c>null</c> or empty.</exception>
[Obsolete("Implement Mediator behaviors in the Osolete .NET project.")]
public static async Task<IEnumerable<T>> ThrowIfEmpty<T, TException>(this Task<IEnumerable<T>> task, Func<TException> factory) where TException : Exception
{
var result = await task;
@@ -50,33 +47,11 @@ public static class TaskExtensions
/// <param name="task"></param>
/// <param name="act"></param>
/// <returns></returns>
[Obsolete("Implement Mediator behaviors in the Osolete .NET project.")]
public static async Task<I> Then<T, I>(this Task<T> task, Func<T, I> act)
{
var res = await task;
return act(res);
}
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="task"></param>
/// <returns></returns>
[Obsolete("Implement Mediator behaviors in the Osolete .NET project.")]
public static Task<T?> FirstOrDefaultAsync<T>(this Task<IEnumerable<T>> task) => task.Then(t => t.FirstOrDefault());
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="TException"></typeparam>
/// <param name="task"></param>
/// <param name="factory"></param>
/// <returns></returns>
public static Task<T> FirstAsync<T, TException>(this Task<IEnumerable<T>> task, Func<TException> factory)
where TException : Exception
=> task.Then(t => t.FirstOrDefault() ?? throw factory());
}
/// <summary>
@@ -93,13 +68,11 @@ public static class Exceptions
///
/// </summary>
/// <returns></returns>
[Obsolete("Implement Mediator behaviors in the Osolete .NET project.")]
public static BadRequestException BadRequest() => new();
/// <summary>
///
/// </summary>
/// <returns></returns>
[Obsolete("Implement Mediator behaviors in the Osolete .NET project.")]
public static ForbiddenException Forbidden() => new();
}

View File

@@ -0,0 +1,27 @@
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
namespace EnvelopeGenerator.Application.Common.Interfaces.Model;
/// <summary>
///
/// </summary>
public interface ITextStyle
{
/// <summary>
///
/// </summary>
public string FontName { get; set; }
/// <summary>
///
/// </summary>
public int FontSize { get; set; }
/// <summary>
///
/// </summary>
[SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
public FontStyle FontStyle { get; set; }
}

View File

@@ -24,7 +24,7 @@ public record DocSignedNotification(EnvelopeReceiverDto Original) : EnvelopeRece
/// <summary>
///
/// </summary>
public PsPdfKitAnnotation? PsPdfKitAnnotation { get; init; }
public PsPdfKitAnnotation PsPdfKitAnnotation { get; init; } = null!;
/// <summary>
///
@@ -59,7 +59,7 @@ public static class DocSignedNotificationExtensions
/// <param name="dtoTask"></param>
/// <param name="psPdfKitAnnotation"></param>
/// <returns></returns>
public static async Task<DocSignedNotification?> ToDocSignedNotification(this Task<EnvelopeReceiverDto?> dtoTask, PsPdfKitAnnotation? psPdfKitAnnotation)
public static async Task<DocSignedNotification?> ToDocSignedNotification(this Task<EnvelopeReceiverDto?> dtoTask, PsPdfKitAnnotation psPdfKitAnnotation)
=> await dtoTask is EnvelopeReceiverDto dto ? new(dto) { PsPdfKitAnnotation = psPdfKitAnnotation } : null;
/// <summary>

View File

@@ -29,9 +29,6 @@ public class AnnotationHandler : INotificationHandler<DocSignedNotification>
/// <param name="notification"></param>
/// <param name="cancel"></param>
/// <returns></returns>
public async Task Handle(DocSignedNotification notification, CancellationToken cancel)
{
if (notification.PsPdfKitAnnotation is PsPdfKitAnnotation annot)
await _repo.CreateAsync(annot.Structured, cancel);
}
public Task Handle(DocSignedNotification notification, CancellationToken cancel)
=> _repo.CreateAsync(notification.PsPdfKitAnnotation.Structured, cancel);
}

View File

@@ -10,8 +10,6 @@ namespace EnvelopeGenerator.Application.Common.Notifications.DocSigned.Handlers;
/// </summary>
public class DocStatusHandler : INotificationHandler<DocSignedNotification>
{
private const string BlankAnnotationJson = "{}";
private readonly ISender _sender;
/// <summary>
@@ -35,9 +33,7 @@ public class DocStatusHandler : INotificationHandler<DocSignedNotification>
{
Envelope = new() { Id = notification.EnvelopeId },
Receiver = new() { Id = notification.ReceiverId},
Value = notification.PsPdfKitAnnotation is PsPdfKitAnnotation annot
? JsonSerializer.Serialize(annot.Instant, Format.Json.ForAnnotations)
: BlankAnnotationJson
Value = JsonSerializer.Serialize(notification.PsPdfKitAnnotation.Instant, Format.Json.ForAnnotations)
}, cancel);
}
}

View File

@@ -0,0 +1,47 @@
using DigitalData.Core.Abstraction.Application.Repository;
using EnvelopeGenerator.Domain.Entities;
using MediatR;
namespace EnvelopeGenerator.Application.Common.Notifications.RemoveSignature.Handlers;
/// <summary>
///
/// </summary>
public class RemoveDocResult : INotificationHandler<RemoveSignatureNotification>
{
private readonly IRepository<Envelope> _repo;
/// <summary>
///
/// </summary>
/// <param name="repository"></param>
public RemoveDocResult(IRepository<Envelope> repository)
{
_repo = repository;
}
/// <summary>
///
/// </summary>
/// <param name="notification"></param>
/// <param name="cancel"></param>
/// <returns></returns>
public Task Handle(RemoveSignatureNotification notification, CancellationToken cancel)
{
if(notification.EnvelopeId is null && notification.EnvelopeUuid is null)
return Task.CompletedTask;
return _repo.UpdateAsync(
envelope => envelope.DocResult = null,
query => {
if (notification.EnvelopeId is int envelopeId)
query = query.Where(envelope => envelope.Id == envelopeId);
if (notification.EnvelopeUuid is string uuid)
query = query.Where(envelope => envelope.Uuid == uuid);
return query;
}, cancel);
}
}

View File

@@ -0,0 +1,87 @@
using AutoMapper;
using DigitalData.Core.Abstraction.Application.Repository;
using DigitalData.Core.Exceptions;
using EnvelopeGenerator.Application.Common.Dto;
using EnvelopeGenerator.Domain.Entities;
using MediatR;
using Microsoft.Extensions.Caching.Memory;
namespace EnvelopeGenerator.Application.Configs;
/// <summary>
///
/// </summary>
public class DefaultReadConfigQuery : IRequest<ConfigDto>
{
/// <summary>
///
/// </summary>
public static readonly Guid MemoryCacheKey = Guid.NewGuid();
}
/// <summary>
///
/// </summary>
public static class DefaultReadConfigQueryExtensions
{
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="cancel"></param>
/// <returns></returns>
public static Task<ConfigDto> ReadDefaultConfigAsync(this ISender sender, CancellationToken cancel = default)
=> sender.Send(new DefaultReadConfigQuery(), cancel);
}
/// <summary>
///
/// </summary>
public class DefaultReadConfigQueryHandler : IRequestHandler<DefaultReadConfigQuery, ConfigDto>
{
private readonly IRepository<Config> _repo;
private readonly IMapper _mapper;
private readonly IMemoryCache _cache;
/// <summary>
///
/// </summary>
/// <param name="repo"></param>
/// <param name="mapper"></param>
/// <param name="cache"></param>
public DefaultReadConfigQueryHandler(IRepository<Config> repo, IMapper mapper, IMemoryCache cache)
{
_repo = repo;
_mapper = mapper;
_cache = cache;
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancel"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<ConfigDto> Handle(DefaultReadConfigQuery request, CancellationToken cancel)
{
var config = await _cache.GetOrCreateAsync(DefaultReadConfigQuery.MemoryCacheKey, async entry =>
{
entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5);
var configs = await _repo.GetAllAsync(cancel);
var defaultConfig = configs.FirstOrDefault();
var defaultConfigDto = _mapper.Map<ConfigDto>(defaultConfig);
return defaultConfigDto;
});
if(config is null)
{
_cache.Remove(DefaultReadConfigQuery.MemoryCacheKey);
throw new NotFoundException("No configuration record is found.");
}
return config;
}
}

View File

@@ -2,11 +2,16 @@
using EnvelopeGenerator.Application.Common.Configurations;
using EnvelopeGenerator.Application.Common.Interfaces.Services;
using EnvelopeGenerator.Application.Services;
using EnvelopeGenerator.Application.ThirdPartyModules.Queries;
using MediatR;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using QRCoder;
using System.Reflection;
using GdPicture14;
using EnvelopeGenerator.Application.Pdf.Behaviors;
namespace EnvelopeGenerator.Application;
@@ -47,6 +52,30 @@ public static class DependencyInjection
services.Configure<AuthenticatorParams>(config.GetSection(nameof(AuthenticatorParams)));
services.Configure<TotpSmsParams>(config.GetSection(nameof(TotpSmsParams)));
#region PDF Burner
services.Configure<PDFBurnerParams>(config.GetSection(nameof(PDFBurnerParams)));
services.AddOptions<GdPictureParams>()
.Configure((GdPictureParams opt, IServiceProvider provider) =>
{
opt.License = config["GdPictureLicenseKey"]
?? provider.GetRequiredService<IMediator>().ReadThirdPartyModuleLicenseAsync("GDPICTURE").GetAwaiter().GetResult()
?? throw new InvalidOperationException($"License record not found for key: {"GDPICTURE"}");
});
services.AddSingleton(provider =>
{
var license = provider.GetRequiredService<IOptions<GdPictureParams>>().Value.License;
var licenseManager = new LicenseManager();
licenseManager.RegisterKEY(license);
return licenseManager;
});
services.AddTransient(provider =>
{
// Ensure LicenseManager is resolved so that its constructor is called
_ = provider.GetRequiredService<LicenseManager>();
return new AnnotationManager();
});
#endregion PDF Burner
services.AddHttpClientService<GtxMessagingParams>(config.GetSection(nameof(GtxMessagingParams)));
services.TryAddSingleton<ISmsSender, GTXSmsSender>();
services.TryAddSingleton<IEnvelopeSmsHandler, EnvelopeSmsHandler>();
@@ -56,8 +85,23 @@ public static class DependencyInjection
services.AddMediatR(cfg =>
{
cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
cfg.AddBehavior<CreateHistoryBehavior>();
cfg.AddBehavior<SavePdfBehavior>();
#if WINDOWS
cfg.AddBehavior<SendEmailBehavior>();
cfg.AddBehavior<WritePdfBehavior>();
cfg.AddBehavior<PdfMergeBehavior>();
cfg.AddBehavior<AddReportBehavior>();
#endif
});
// Add memory cache
services.AddMemoryCache();
// Register mail services
services.AddScoped<IEnvelopeMailService, EnvelopeMailService>();
return services;
}
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net7.0;net8.0;net9.0;net8.0-windows</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
@@ -14,7 +14,8 @@
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.66" />
<PackageReference Include="DigitalData.Core.Abstraction.Application" Version="1.6.0" />
<PackageReference Include="DevExpress.Reporting.Core" Version="21.2.4" />
<PackageReference Include="DigitalData.Core.Abstraction.Application" Version="1.5.0" />
<PackageReference Include="DigitalData.Core.Application" Version="3.4.0" />
<PackageReference Include="DigitalData.Core.Client" Version="2.1.0" />
<PackageReference Include="DigitalData.Core.Exceptions" Version="1.1.0" />
@@ -25,23 +26,36 @@
<PackageReference Include="Otp.NET" Version="1.4.0" />
<PackageReference Include="QRCoder" Version="1.6.0" />
<PackageReference Include="QRCoder-ImageSharp" Version="0.10.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.12" />
<PackageReference Include="UserManager" Version="1.1.3" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="System.Formats.Asn1" Version="8.0.2" />
<PackageReference Include="GdPicture" Version="14.3.19.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net8.0-windows'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.5" />
<PackageReference Include="System.Formats.Asn1" Version="9.0.10" />
<PackageReference Include="GdPicture" Version="14.3.19.1" />
<PackageReference Include="GdPicture.runtimes.windows" Version="14.3.19.1" />
<PackageReference Include="GdPicture.runtimes.linux" Version="14.3.19.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.5" />
<PackageReference Include="System.Formats.Asn1" Version="9.0.10" />
<PackageReference Include="GdPicture" Version="14.3.19.1" />
<PackageReference Include="GdPicture.runtimes.windows" Version="14.3.19.1" />
<PackageReference Include="GdPicture.runtimes.linux" Version="14.3.19.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EnvelopeGenerator.CommonServices\EnvelopeGenerator.CommonServices.vbproj" />
<ProjectReference Include="..\EnvelopeGenerator.Domain\EnvelopeGenerator.Domain.csproj" />
<ProjectReference Include="..\EnvelopeGenerator.PdfEditor\EnvelopeGenerator.PdfEditor.csproj" />
</ItemGroup>
<ItemGroup>
@@ -79,7 +93,7 @@
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net8.0-windows'">
<PackageReference Include="AutoMapper" Version="14.0.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.2" />
<PackageReference Include="CommandDotNet">

View File

@@ -1,4 +1,4 @@
using AutoMapper;
using AutoMapper;
using DigitalData.Core.Abstraction.Application.Repository;
using DigitalData.Core.Exceptions;
using EnvelopeGenerator.Application.Envelopes.Queries;
@@ -47,13 +47,7 @@ namespace EnvelopeGenerator.Application.EnvelopeReceivers.Queries;
/// Die Antwort enthält Details wie den Include, die Zuordnung zwischen Umschlag und Empfänger
/// sowie zusätzliche Metadaten.
/// </remarks>
public record ReadEnvelopeReceiverQuery : EnvelopeReceiverQueryBase<ReadEnvelopeQuery, ReadReceiverQuery>, IRequest<IEnumerable<EnvelopeReceiverDto>>
{
/// <summary>
/// Optionaler Benutzernamefilter, um Ergebnisse auf Umschläge eines bestimmten Besitzers einzuschränken.
/// </summary>
public string? Username { get; init; }
}
public record ReadEnvelopeReceiverQuery : EnvelopeReceiverQueryBase<ReadEnvelopeQuery, ReadReceiverQuery>, IRequest<IEnumerable<EnvelopeReceiverDto>>;
/// <summary>
///
@@ -88,74 +82,73 @@ public static class Extensions
q.Receiver.Signature = signature;
return mediator.Send(q, cancel).Then(envRcvs => envRcvs.FirstOrDefault());
}
}
/// <summary>
///
/// </summary>
public class ReadEnvelopeReceiverQueryHandler : IRequestHandler<ReadEnvelopeReceiverQuery, IEnumerable<EnvelopeReceiverDto>>
{
private readonly IRepository<EnvelopeReceiver> _repo;
private readonly IRepository<Receiver> _rcvRepo;
private readonly IMapper _mapper;
/// <summary>
/// Verarbeitet <see cref="ReadEnvelopeReceiverQuery"/> und liefert passende <see cref="EnvelopeReceiverDto"/>-Ergebnisse.
///
/// </summary>
public class ReadEnvelopeReceiverQueryHandler : IRequestHandler<ReadEnvelopeReceiverQuery, IEnumerable<EnvelopeReceiverDto>>
/// <param name="envelopeReceiver"></param>
/// <param name="mapper"></param>
public ReadEnvelopeReceiverQueryHandler(IRepository<EnvelopeReceiver> envelopeReceiver, IRepository<Receiver> rcvRepo, IMapper mapper)
{
private readonly IRepository<EnvelopeReceiver> _repo;
private readonly IRepository<Receiver> _rcvRepo;
private readonly IMapper _mapper;
_repo = envelopeReceiver;
_mapper = mapper;
_rcvRepo = rcvRepo;
}
/// <summary>
///
/// </summary>
/// <param name="envelopeReceiver"></param>
/// <param name="rcvRepo"></param>
/// <param name="mapper"></param>
public ReadEnvelopeReceiverQueryHandler(IRepository<EnvelopeReceiver> envelopeReceiver, IRepository<Receiver> rcvRepo, IMapper mapper)
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancel"></param>
/// <returns></returns>
/// <exception cref="BadRequestException"></exception>
public async Task<IEnumerable<EnvelopeReceiverDto>> Handle(ReadEnvelopeReceiverQuery request, CancellationToken cancel)
{
var q = _repo.ReadOnly().Where(request, notnull: false);
if (request.Envelope.Status is not null)
{
_repo = envelopeReceiver;
_mapper = mapper;
_rcvRepo = rcvRepo;
var status = request.Envelope.Status;
if (status.Min is not null)
q = q.Where(er => er.Envelope!.Status >= status.Min);
if (status.Max is not null)
q = q.Where(er => er.Envelope!.Status <= status.Max);
if (status.Include?.Length > 0)
q = q.Where(er => status.Include.Contains(er.Envelope!.Status));
if (status.Ignore is not null)
q = q.Where(er => !status.Ignore.Contains(er.Envelope!.Status));
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancel"></param>
/// <returns></returns>
/// <exception cref="BadRequestException"></exception>
public async Task<IEnumerable<EnvelopeReceiverDto>> Handle(ReadEnvelopeReceiverQuery request, CancellationToken cancel)
var envRcvs = await q
.Include(er => er.Envelope).ThenInclude(e => e!.Documents!).ThenInclude(d => d.Elements)
.Include(er => er.Envelope).ThenInclude(e => e!.Histories)
.Include(er => er.Envelope).ThenInclude(e => e!.User)
.Include(er => er.Receiver)
.ToListAsync(cancel);
if (request.Receiver.HasAnyCriteria && envRcvs.Any())
{
var q = _repo.Query.Where(request, notnull: false);
var receiver = await _rcvRepo.ReadOnly().Where(request.Receiver).FirstAsync(cancel);
if (request.Username is string username)
q = q.Where(er => er.Envelope!.User.Username == username);
if (request.Envelope.Status is not null)
{
var status = request.Envelope.Status;
if (status.Min is not null)
q = q.Where(er => er.Envelope!.Status >= status.Min);
if (status.Max is not null)
q = q.Where(er => er.Envelope!.Status <= status.Max);
if (status.Include?.Length > 0)
q = q.Where(er => status.Include.Contains(er.Envelope!.Status));
if (status.Ignore is not null)
q = q.Where(er => !status.Ignore.Contains(er.Envelope!.Status));
}
var envRcvs = await q
.Include(er => er.Envelope).ThenInclude(e => e!.Documents!).ThenInclude(d => d.Elements)
.Include(er => er.Envelope).ThenInclude(e => e!.Histories)
.Include(er => er.Envelope).ThenInclude(e => e!.User)
.Include(er => er.Receiver)
.ToListAsync(cancel);
if (request.Receiver.HasAnyCriteria && envRcvs.Count != 0)
{
var receiver = await _rcvRepo.Query.Where(request.Receiver).FirstAsync(cancel);
foreach (var envRcv in envRcvs)
envRcv.Envelope?.Documents?.FirstOrDefault()?.Elements?.RemoveAll(s => s.ReceiverId != receiver.Id);
}
return _mapper.Map<List<EnvelopeReceiverDto>>(envRcvs);
foreach (var envRcv in envRcvs)
envRcv.Envelope?.Documents?.First().Elements.RemoveAll(s => s.ReceiverId != receiver.Id);
}
return _mapper.Map<List<EnvelopeReceiverDto>>(envRcvs);
}
}

View File

@@ -0,0 +1,92 @@
using AutoMapper;
using DigitalData.Core.Abstraction.Application.Repository;
using DigitalData.Core.Exceptions;
using EnvelopeGenerator.Domain.Entities;
using MediatR;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace EnvelopeGenerator.Application.EnvelopeReports;
/// <summary>
///
/// </summary>
public record ReadEnvelopeReportQuery(int EnvelopeId) : IRequest<IEnumerable<EnvelopeReport>>
{
/// <summary>
///
/// </summary>
[JsonIgnore]
[NotMapped]
public bool ThrowIfNotFound { get; init; } = true;
};
/// <summary>
///
/// </summary>
public static class ReadEnvelopeReportQueryExtensions
{
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="envelopeId"></param>
/// <param name="throwIfNotFound"></param>
/// <param name="cancel"></param>
/// <returns></returns>
public static Task<IEnumerable<EnvelopeReport>> ReadEnvelopeReportAsync(this ISender sender, int envelopeId, bool throwIfNotFound = true, CancellationToken cancel = default)
=> sender.Send(new ReadEnvelopeReportQuery(envelopeId)
{
ThrowIfNotFound = throwIfNotFound
}, cancel);
}
/// <summary>
///
/// </summary>
public class ReadEnvelopeReportQueryHandler : IRequestHandler<ReadEnvelopeReportQuery, IEnumerable<EnvelopeReport>>
{
/// <summary>
///
/// </summary>
private readonly IRepository<EnvelopeReport> _repo;
/// <summary>
///
/// </summary>
private readonly IMapper _mapper;
/// <summary>
///
/// </summary>
/// <param name="repo"></param>
/// <param name="mapper"></param>
public ReadEnvelopeReportQueryHandler(IRepository<EnvelopeReport> repo, IMapper mapper)
{
_repo = repo;
_mapper = mapper;
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancel"></param>
/// <returns></returns>
public async Task<IEnumerable<EnvelopeReport>> Handle(ReadEnvelopeReportQuery request, CancellationToken cancel = default)
{
var reports = await _repo.Where(r => r.EnvelopeId == request.EnvelopeId).ToListAsync(cancel);
var reportDtos = _mapper.Map<IEnumerable<EnvelopeReport>>(reports);
if(request.ThrowIfNotFound && !reportDtos.Any())
throw new NotFoundException($"EnvelopeReport with EnvelopeId '{request.EnvelopeId}' was not found.");
return reportDtos;
}
}

View File

@@ -1,45 +0,0 @@
using EnvelopeGenerator.Application.Common.Dto;
using MediatR;
using AutoMapper;
using DigitalData.Core.Abstraction.Application.Repository;
using EnvelopeGenerator.Domain.Entities;
using Microsoft.EntityFrameworkCore;
namespace EnvelopeGenerator.Application.EnvelopeTypes.Queries;
/// <summary>
///
/// </summary>
public record ReadEnvelopeTypesQuery : IRequest<IEnumerable<EnvelopeTypeDto>>;
/// <summary>
///
/// </summary>
public class ReadEnvelopeTypesQueryHandler : IRequestHandler<ReadEnvelopeTypesQuery, IEnumerable<EnvelopeTypeDto>>
{
private readonly IRepository<EnvelopeType> _repository;
private readonly IMapper _mapper;
/// <summary>
///
/// </summary>
/// <param name="repository"></param>
/// <param name="mapper"></param>
public ReadEnvelopeTypesQueryHandler(IRepository<EnvelopeType> repository, IMapper mapper)
{
_repository = repository;
_mapper = mapper;
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<IEnumerable<EnvelopeTypeDto>> Handle(ReadEnvelopeTypesQuery request, CancellationToken cancellationToken)
{
var types = await _repository.Query.ToListAsync(cancellationToken);
return _mapper.Map<IEnumerable<EnvelopeTypeDto>>(types);
}
}

View File

@@ -33,18 +33,7 @@ public record CreateEnvelopeCommand : IRequest<EnvelopeDto?>
/// <summary>
/// ID des Absenders
/// </summary>
internal int UserId { get; private set; }
/// <summary>
///
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public bool Authorize(int userId)
{
UserId = userId;
return true;
}
public int UserId { get; set; }
/// <summary>
/// Determines which component is used for envelope processing.

View File

@@ -4,6 +4,7 @@ using EnvelopeGenerator.Application.Common.Query;
using EnvelopeGenerator.Application.Common.Dto;
using AutoMapper;
using DigitalData.Core.Abstraction.Application.Repository;
using EnvelopeGenerator.Application.Common.Extensions;
using EnvelopeGenerator.Domain.Entities;
using Microsoft.EntityFrameworkCore;
@@ -20,14 +21,9 @@ public record ReadEnvelopeQuery : EnvelopeQueryBase, IRequest<IEnumerable<Envelo
public EnvelopeStatusQuery? Status { get; init; }
/// <summary>
/// Optionaler Benutzerfilter; wenn gesetzt, werden nur Umschläge des Benutzers geladen.
///
/// </summary>
public int? UserId { get; init; }
/// <summary>
/// Setzt den Benutzerkontext für die Abfrage.
/// </summary>
public ReadEnvelopeQuery Authorize(int userId) => this with { UserId = userId };
public bool? HasDocResult { get; init; }
}
/// <summary>
@@ -83,22 +79,23 @@ public record EnvelopeStatusQuery
}
/// <summary>
/// Verarbeitet <see cref="ReadEnvelopeQuery"/> und liefert passende <see cref="EnvelopeDto"/>-Ergebnisse.
///
/// </summary>
public class ReadEnvelopeQueryHandler : IRequestHandler<ReadEnvelopeQuery, IEnumerable<EnvelopeDto>>
{
private readonly IRepository<Envelope> _repository;
private readonly IMapper _mapper;
private readonly IRepository<Envelope> _repo;
/// <summary>
///
/// </summary>
/// <param name="repository"></param>
/// <param name="mapper"></param>
public ReadEnvelopeQueryHandler(IRepository<Envelope> repository, IMapper mapper)
/// <param name="repo"></param>
public ReadEnvelopeQueryHandler(IMapper mapper, IRepository<Envelope> repo)
{
_repository = repository;
_mapper = mapper;
_repo = repo;
}
/// <summary>
@@ -107,34 +104,24 @@ public class ReadEnvelopeQueryHandler : IRequestHandler<ReadEnvelopeQuery, IEnum
/// <param name="request"></param>
/// <param name="cancel"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<IEnumerable<EnvelopeDto>> Handle(ReadEnvelopeQuery request, CancellationToken cancel)
{
var query = _repository.Query;
var envelopesQ = _repo.Query.Where(request, notnull: false);
if (request.UserId is int userId)
query = query.Where(e => e.UserId == userId);
EnvelopeStatusQuery? statusQ = request.Status;
bool? hasDocResult = request.HasDocResult;
if (request.Id is int id)
query = query.Where(e => e.Id == id);
var filtered =
from envelope in envelopesQ
where (statusQ == null || statusQ.Include == null || statusQ.Include.Contains(envelope.Status))
&& (statusQ == null || statusQ.Ignore == null || !statusQ.Ignore.Contains(envelope.Status))
&& (statusQ == null || statusQ.Min == null || envelope.Status > statusQ.Min)
&& (statusQ == null || statusQ.Max == null || envelope.Status < statusQ.Max)
&& (!hasDocResult.HasValue || (hasDocResult.Value ? envelope.DocResult != null : envelope.DocResult == null))
select envelope;
if (request.Uuid is string uuid)
query = query.Where(e => e.Uuid == uuid);
if (request.Status is { } status)
{
if (status.Min is not null)
query = query.Where(e => e.Status >= status.Min);
if (status.Max is not null)
query = query.Where(e => e.Status <= status.Max);
if (status.Include?.Length > 0)
query = query.Where(e => status.Include.Contains(e.Status));
if (status.Ignore?.Length > 0)
query = query.Where(e => !status.Ignore.Contains(e.Status));
}
var envelopes = await query
.Include(e => e.Documents)
.ToListAsync(cancel);
var envelopes = await filtered.ToListAsync(cancel);
return _mapper.Map<IEnumerable<EnvelopeDto>>(envelopes);
}

View File

@@ -1,8 +1,4 @@
using DigitalData.Core.Abstraction.Application.Repository;
using EnvelopeGenerator.Application.Common.Query;
using MediatR;
using EnvelopeGenerator.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using EnvelopeGenerator.Application.Receivers.Queries;
namespace EnvelopeGenerator.Application.Envelopes.Queries;
@@ -10,54 +6,6 @@ namespace EnvelopeGenerator.Application.Envelopes.Queries;
/// Eine Abfrage, um die zuletzt verwendete Anrede eines Empfängers zu ermitteln,
/// damit diese für zukünftige Umschläge wiederverwendet werden kann.
/// </summary>
public record ReadReceiverNameQuery() : ReceiverQueryBase, IRequest<string?>;
/// <summary>
///
/// </summary>
public class ReadReceiverNameQueryHandler : IRequestHandler<ReadReceiverNameQuery, string?>
public record ReadReceiverNameQuery() : ReadReceiverQuery
{
private readonly IRepository<EnvelopeReceiver> _envelopeReceiverRepository;
private readonly IRepository<Receiver> _receiverRepository;
/// <summary>
///
/// </summary>
/// <param name="envelopeReceiverRepository"></param>
/// <param name="receiverRepository"></param>
public ReadReceiverNameQueryHandler(IRepository<EnvelopeReceiver> envelopeReceiverRepository, IRepository<Receiver> receiverRepository)
{
_envelopeReceiverRepository = envelopeReceiverRepository;
_receiverRepository = receiverRepository;
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<string?> Handle(ReadReceiverNameQuery request, CancellationToken cancellationToken)
{
var receiverQuery = _receiverRepository.Query.AsNoTracking();
if (request.Id is int id)
receiverQuery = receiverQuery.Where(r => r.Id == id);
if (request.EmailAddress is string email)
receiverQuery = receiverQuery.Where(r => r.EmailAddress == email);
if (request.Signature is string signature)
receiverQuery = receiverQuery.Where(r => r.Signature == signature);
var receiver = await receiverQuery.FirstOrDefaultAsync(cancellationToken);
if (receiver is null)
return null;
var erName = await _envelopeReceiverRepository.Query
.Where(er => er.ReceiverId == receiver.Id)
.OrderByDescending(er => er.AddedWhen)
.Select(er => er.Name)
.FirstOrDefaultAsync(cancellationToken);
return erName;
}
}

View File

@@ -0,0 +1,19 @@
namespace EnvelopeGenerator.Application.Exceptions;
/// <summary>
///
/// </summary>
public class BurnAnnotationException : ApplicationException
{
/// <summary>
///
/// </summary>
public BurnAnnotationException(string message)
: base(message) { }
/// <summary>
///
/// </summary>
public BurnAnnotationException(string message, Exception innerException)
: base(message, innerException) { }
}

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EnvelopeGenerator.Application.Exceptions;
/// <summary>
///
/// </summary>
public class CreateReportException : ApplicationException
{
/// <summary>
///
/// </summary>
/// <param name="message"></param>
public CreateReportException(string message)
: base(message) { }
/// <summary>
///
/// </summary>
/// <param name="message"></param>
/// <param name="innerException"></param>
public CreateReportException(string message, Exception innerException)
: base(message, innerException) { }
}

View File

@@ -0,0 +1,22 @@
namespace EnvelopeGenerator.Application.Exceptions;
/// <summary>
///
/// </summary>
public class ExportDocumentException : ApplicationException
{
/// <summary>
///
/// </summary>
/// <param name="message"></param>
public ExportDocumentException(string message)
: base(message) { }
/// <summary>
///
/// </summary>
/// <param name="message"></param>
/// <param name="innerException"></param>
public ExportDocumentException(string message, Exception innerException)
: base(message, innerException) { }
}

View File

@@ -0,0 +1,22 @@
namespace EnvelopeGenerator.Application.Exceptions;
/// <summary>
///
/// </summary>
public class MergeDocumentException : ApplicationException
{
/// <summary>
///
/// </summary>
/// <param name="message"></param>
public MergeDocumentException(string message)
: base(message) { }
/// <summary>
///
/// </summary>
/// <param name="message"></param>
/// <param name="innerException"></param>
public MergeDocumentException(string message, Exception innerException)
: base(message, innerException) { }
}

View File

@@ -34,7 +34,7 @@ public record CreateHistoryCommand : EnvelopeReceiverQueryBase, IRequest<History
/// <summary>
///
/// </summary>
public DateTime AddedWhen { get; } = DateTime.Now;
public DateTime AddedWhen { get; } = DateTime.UtcNow;
/// <summary>
///

View File

@@ -1,101 +0,0 @@
using DigitalData.Core.Abstraction.Application.Repository;
using DigitalData.Core.Exceptions;
using EnvelopeGenerator.Domain.Constants;
using EnvelopeGenerator.Domain.Entities;
using MediatR;
using Microsoft.EntityFrameworkCore;
namespace EnvelopeGenerator.Application.Histories.Queries;
//TODO: Add sender query
/// <summary>
/// Repräsentiert eine Abfrage für die Verlaufshistorie eines Umschlags.
/// </summary>
public record CountHistoryQuery : HistoryQueryBase, IRequest<int>;
/// <summary>
///
/// </summary>
public static class CountHistoryQueryExtensions
{
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="uuid"></param>
/// <param name="statuses"></param>
/// <param name="cancel"></param>
/// <returns></returns>
public static async Task<bool> AnyHistoryAsync(this ISender sender, string uuid, IEnumerable<EnvelopeStatus> statuses, CancellationToken cancel = default)
{
var count = await sender.Send(new CountHistoryQuery
{
Envelope = new() { Uuid = uuid },
Statuses = new() { Include = statuses }
}, cancel);
return count > 0;
}
}
/// <summary>
///
/// </summary>
public class CountHistoryQueryHandler : IRequestHandler<CountHistoryQuery, int>
{
private readonly IRepository<History> _repo;
/// <summary>
///
/// </summary>
/// <param name="repo"></param>
public CountHistoryQueryHandler(IRepository<History> repo)
{
_repo = repo;
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancel"></param>
/// <returns></returns>
/// <exception cref="NotFoundException"></exception>
public Task<int> Handle(CountHistoryQuery request, CancellationToken cancel = default)
{
var query = _repo.Query;
if (request.Envelope.Id is int envId)
query = query.Where(e => e.Id == envId);
else if (request.Envelope.Uuid is string uuid)
query = query.Where(e => e.Envelope!.Uuid == uuid);
#pragma warning disable CS0618 // Type or member is obsolete
else if (request.EnvelopeId is not null)
query = query.Where(h => h.EnvelopeId == request.EnvelopeId);
#pragma warning restore CS0618 // Type or member is obsolete
else
throw new BadRequestException("Invalid request: An Envelope object or a valid EnvelopeId/UUID must be supplied.");
#pragma warning disable CS0618 // Type or member is obsolete
if (request.Status is not null)
query = query.Where(h => h.Status == request.Status);
#pragma warning restore CS0618 // Type or member is obsolete
if (request.Statuses is not null)
{
var status = request.Statuses;
if (status.Min is not null)
query = query.Where(er => er.Envelope!.Status >= status.Min);
if (status.Max is not null)
query = query.Where(er => er.Envelope!.Status <= status.Max);
if (status.Include?.Count() > 0)
query = query.Where(er => status.Include.Contains(er.Envelope!.Status));
if (status.Ignore is not null)
query = query.Where(er => !status.Ignore.Contains(er.Envelope!.Status));
}
return query.CountAsync(cancel);
}
}

View File

@@ -1,60 +0,0 @@
using EnvelopeGenerator.Application.Common.Query;
using EnvelopeGenerator.Domain.Constants;
using System.ComponentModel.DataAnnotations;
namespace EnvelopeGenerator.Application.Histories.Queries;
//TODO: Add sender query
/// <summary>
///
/// </summary>
public record HistoryQueryBase
{
/// <summary>
/// Die eindeutige Kennung des Umschlags.
/// </summary>
[Obsolete("Use Envelope property")]
public int? EnvelopeId { get; set; }
/// <summary>
/// Der Include des Umschlags, der abgefragt werden soll. Kann optional angegeben werden, um die Ergebnisse zu filtern.
/// </summary>
[Obsolete("Use statuses")]
public EnvelopeStatus? Status { get; set; }
/// <summary>
///
/// </summary>
public EnvelopeStatusQuery Statuses { get; set; } = new();
/// <summary>
///
/// </summary>
public EnvelopeQueryBase Envelope { get; set; } = new EnvelopeQueryBase();
}
/// <summary>
///
/// </summary>
public record EnvelopeStatusQuery
{
/// <summary>
/// Der minimale Statuswert, der berücksichtigt werden.
/// </summary>
public EnvelopeStatus? Min { get; init; }
/// <summary>
/// Der maximale Statuswert, der berücksichtigt werden.
/// </summary>
public EnvelopeStatus? Max { get; init; }
/// <summary>
/// Eine Liste von Statuswerten, die einbezogen werden.
/// </summary>
public IEnumerable<EnvelopeStatus>? Include { get; init; }
/// <summary>
/// Eine Liste von Statuswerten, die ignoriert werden werden.
/// </summary>
public IEnumerable<EnvelopeStatus>? Ignore { get; init; }
}

View File

@@ -1,10 +1,7 @@
using AutoMapper;
using DigitalData.Core.Abstraction.Application.Repository;
using DigitalData.Core.Exceptions;
using EnvelopeGenerator.Application.Common.Dto.History;
using EnvelopeGenerator.Application.Common.Dto.History;
using EnvelopeGenerator.Domain.Constants;
using MediatR;
using EnvelopeGenerator.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
namespace EnvelopeGenerator.Application.Histories.Queries;
@@ -12,81 +9,21 @@ namespace EnvelopeGenerator.Application.Histories.Queries;
/// <summary>
/// Repräsentiert eine Abfrage für die Verlaufshistorie eines Umschlags.
/// </summary>
public record ReadHistoryQuery : HistoryQueryBase, IRequest<IEnumerable<HistoryDto>>
public record ReadHistoryQuery : IRequest<IEnumerable<HistoryDto>>
{
/// <summary>
/// Die eindeutige Kennung des Umschlags.
/// </summary>
[Required]
public int EnvelopeId { get; init; }
/// <summary>
/// Der Include des Umschlags, der abgefragt werden soll. Kann optional angegeben werden, um die Ergebnisse zu filtern.
/// </summary>
public EnvelopeStatus? Status { get; init; }
/// <summary>
/// Abfrage zur Steuerung, ob nur der aktuelle Include oder der gesamte Datensatz zurückgegeben wird.
/// </summary>
public bool OnlyLast { get; init; } = true;
}
/// <summary>
///
/// </summary>
public class ReadHistoryQueryHandler : IRequestHandler<ReadHistoryQuery, IEnumerable<HistoryDto>>
{
private readonly IRepository<History> _repo;
private readonly IMapper _mapper;
/// <summary>
///
/// </summary>
/// <param name="repo"></param>
/// <param name="mapper"></param>
public ReadHistoryQueryHandler(IRepository<History> repo, IMapper mapper)
{
_repo = repo;
_mapper = mapper;
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancel"></param>
/// <returns></returns>
/// <exception cref="NotFoundException"></exception>
public async Task<IEnumerable<HistoryDto>> Handle(ReadHistoryQuery request, CancellationToken cancel = default)
{
var query = _repo.Query;
if (request.Envelope.Id is int envId)
query = query.Where(e => e.Id == envId);
else if (request.Envelope.Uuid is string uuid)
query = query.Where(e => e.Envelope!.Uuid == uuid);
#pragma warning disable CS0618 // Type or member is obsolete
else if (request.EnvelopeId is not null)
query = query.Where(h => h.EnvelopeId == request.EnvelopeId);
#pragma warning restore CS0618 // Type or member is obsolete
else
throw new BadRequestException("Invalid request: An Envelope object or a valid EnvelopeId/UUID must be supplied.");
#pragma warning disable CS0618 // Type or member is obsolete
if (request.Status is not null)
query = query.Where(h => h.Status == request.Status);
#pragma warning restore CS0618 // Type or member is obsolete
if (request.Statuses is not null)
{
var status = request.Statuses;
if (status.Min is not null)
query = query.Where(er => er.Envelope!.Status >= status.Min);
if (status.Max is not null)
query = query.Where(er => er.Envelope!.Status <= status.Max);
if (status.Include?.Count() > 0)
query = query.Where(er => status.Include.Contains(er.Envelope!.Status));
if (status.Ignore is not null)
query = query.Where(er => !status.Ignore.Contains(er.Envelope!.Status));
}
if (request.OnlyLast)
query = query.OrderByDescending(x => x.AddedWhen);
var hists = await query.ToListAsync(cancel);
return _mapper.Map<List<HistoryDto>>(hists);
}
public bool? OnlyLast { get; init; } = true;
}

View File

@@ -0,0 +1,47 @@
using AutoMapper;
using DigitalData.Core.Abstraction.Application.Repository;
using DigitalData.Core.Exceptions;
using EnvelopeGenerator.Application.Common.Dto.History;
using EnvelopeGenerator.Domain.Entities;
using MediatR;
using Microsoft.EntityFrameworkCore;
namespace EnvelopeGenerator.Application.Histories.Queries;
/// <summary>
///
/// </summary>
public class ReadHistoryQueryHandler : IRequestHandler<ReadHistoryQuery, IEnumerable<HistoryDto>>
{
private readonly IRepository<History> _repo;
private readonly IMapper _mapper;
/// <summary>
///
/// </summary>
/// <param name="repo"></param>
/// <param name="mapper"></param>
public ReadHistoryQueryHandler(IRepository<History> repo, IMapper mapper)
{
_repo = repo;
_mapper = mapper;
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancel"></param>
/// <returns></returns>
/// <exception cref="NotFoundException"></exception>
public async Task<IEnumerable<HistoryDto>> Handle(ReadHistoryQuery request, CancellationToken cancel = default)
{
var query = _repo.ReadOnly().Where(h => h.EnvelopeId == request.EnvelopeId);
if (request.Status is not null)
query = query.Where(h => h.Status == request.Status);
var hists = await query.ToListAsync(cancel);
return _mapper.Map<List<HistoryDto>>(hists);
}
}

View File

@@ -0,0 +1,99 @@
#if WINDOWS
using MediatR;
using EnvelopeGenerator.Application.EnvelopeReports;
using EnvelopeGenerator.Application.Exceptions;
using EnvelopeGenerator.Domain.Entities;
using Microsoft.Extensions.Logging;
using EnvelopeGenerator.CommonServices;
namespace EnvelopeGenerator.Application.Pdf.Behaviors;
/// <summary>
///
/// </summary>
public class AddReportBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
{
private readonly ISender _sender;
private readonly ILogger<AddReportBehavior> _logger;
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="logger"></param>
public AddReportBehavior(ISender sender, ILogger<AddReportBehavior> logger)
{
_sender = sender;
_logger = logger;
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="next"></param>
/// <param name="cancel"></param>
/// <returns></returns>
public async Task<byte[]> Handle(BurnPdfCommand request, RequestHandlerDelegate<byte[]> next, CancellationToken cancel)
{
var docResult = await next(cancel);
request.Report = await CreateReport(request.Envelope!, cancel);
return docResult;
}
/// <summary>
///
/// </summary>
/// <param name="envelope"></param>
/// <param name="cancel"></param>
/// <returns></returns>
/// <exception cref="CreateReportException"></exception>
public async Task<byte[]> CreateReport(Envelope envelope, CancellationToken cancel)
{
var oItems = await _sender.ReadEnvelopeReportAsync(envelope.Id, cancel: cancel);
if (!oItems.Any())
{
throw new CreateReportException("No report data found!");
}
var oBuffer = DoCreateReport(oItems);
return oBuffer;
}
private static byte[] DoCreateReport(IEnumerable<EnvelopeReport> oItems)
{
var oSource = new ReportSource { Items = oItems };
var oReport = new rptEnvelopeHistory
{
DataSource = oSource,
DataMember = "Items"
};
// Creating report in memory
oReport.CreateDocument();
// Exporting report to stream
using var oStream = new MemoryStream();
oReport.ExportToPdf(oStream);
// Writing report to buffer
return oStream.ToArray();
}
/// <summary>
///
/// </summary>
public class ReportSource
{
/// <summary>
///
/// </summary>
public required IEnumerable<EnvelopeReport> Items { get; init; }
}
}
#endif

View File

@@ -0,0 +1,49 @@
using MediatR;
using EnvelopeGenerator.Application.Histories.Commands;
using EnvelopeGenerator.Domain.Constants;
using Microsoft.Extensions.Logging;
namespace EnvelopeGenerator.Application.Pdf.Behaviors;
/// <summary>
///
/// </summary>
public class CreateHistoryBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
{
private readonly ISender _sender;
private readonly ILogger<CreateHistoryBehavior> _logger;
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="logger"></param>
public CreateHistoryBehavior(ISender sender, ILogger<CreateHistoryBehavior> logger)
{
_sender = sender;
_logger = logger;
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="next"></param>
/// <param name="cancel"></param>
/// <returns></returns>
public async Task<byte[]> Handle(BurnPdfCommand request, RequestHandlerDelegate<byte[]> next, CancellationToken cancel)
{
var doc = await next(cancel);
if (!request.Debug)
await _sender.Send(new CreateHistoryCommand()
{
EnvelopeId = request.EnvelopeId,
UserReference = "System",
Status = EnvelopeStatus.EnvelopeReportCreated,
}, cancel);
return doc;
}
}

View File

@@ -0,0 +1,71 @@
#if WINDOWS
using EnvelopeGenerator.Application.Common.Extensions;
using EnvelopeGenerator.Application.Exceptions;
using EnvelopeGenerator.Domain.Constants;
using GdPicture14;
using MediatR;
namespace EnvelopeGenerator.Application.Pdf.Behaviors;
/// <summary>
///
/// </summary>
public class PdfMergeBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
{
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="next"></param>
/// <param name="cancel"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<byte[]> Handle(BurnPdfCommand request, RequestHandlerDelegate<byte[]> next, CancellationToken cancel)
{
var doc = await next(cancel);
if (request.Report is null)
throw new InvalidOperationException("The final document report could not be merged."
+ "There may be an error related to the behavior register order."
+ "Request details:\n" + request.ToJson(Format.Json.ForDiagnostics));
using var oDocumentStream = new MemoryStream(doc);
using var oReportStream = new MemoryStream(request.Report);
using var oFinalStream = new MemoryStream();
using var oDocumentPDF = new GdPicturePDF();
using var oReportPDF = new GdPicturePDF();
GdPictureStatus oStatus = GdPictureStatus.OK;
// Load the source file into memory
oDocumentPDF.LoadFromStream(oDocumentStream, true);
oStatus = oDocumentPDF.GetStat();
if (oStatus != GdPictureStatus.OK)
throw new MergeDocumentException($"Document could not be loaded: {oStatus}."
+ "Request details:\n" + request.ToJson(Format.Json.ForDiagnostics));
// Load the report file into memory
oReportPDF.LoadFromStream(oReportStream, true);
oStatus = oReportPDF.GetStat();
if (oStatus != GdPictureStatus.OK)
throw new MergeDocumentException($"Report could not be loaded: {oStatus}."
+ "Request details:\n" + request.ToJson(Format.Json.ForDiagnostics));
// Merge the documents
var oMergedPDF = oDocumentPDF.Merge2Documents(oDocumentPDF, oReportPDF);
oStatus = oMergedPDF.GetStat();
if (oStatus != GdPictureStatus.OK)
throw new MergeDocumentException($"Documents could not be merged: {oStatus}."
+ "Request details:\n" + request.ToJson(Format.Json.ForDiagnostics));
// Convert to byte
oMergedPDF.SaveToStream(oFinalStream);
oStatus = oDocumentPDF.GetStat();
if (oStatus != GdPictureStatus.OK)
throw new MergeDocumentException($"Document could not be converted to byte: {oStatus}."
+ "Request details:\n" + request.ToJson(Format.Json.ForDiagnostics));
return oFinalStream.ToArray();
}
}
#endif

View File

@@ -0,0 +1,23 @@
using MediatR;
namespace EnvelopeGenerator.Application.Pdf.Behaviors;
/// <summary>
///
/// </summary>
public class SavePdfBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
{
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="next"></param>
/// <param name="cancel"></param>
/// <returns></returns>
public async Task<byte[]> Handle(BurnPdfCommand request, RequestHandlerDelegate<byte[]> next, CancellationToken cancel)
{
var docResult = await next(cancel);
var base64 = Convert.ToBase64String(docResult);
return docResult;
}
}

View File

@@ -0,0 +1,113 @@
using EnvelopeGenerator.Application.Histories.Commands;
using EnvelopeGenerator.Domain.Constants;
using MediatR;
using Microsoft.Extensions.Logging;
namespace EnvelopeGenerator.Application.Pdf.Behaviors;
/// <summary>
///
/// </summary>
public class SendEmailBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
{
private readonly ILogger<SendEmailBehavior> _logger;
private readonly ISender _sender;
/// <summary>
///
/// </summary>
/// <param name="logger"></param>
/// <param name="sender"></param>
public SendEmailBehavior(ILogger<SendEmailBehavior> logger, ISender sender)
{
_logger = logger;
_sender = sender;
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="next"></param>
/// <param name="cancel"></param>
/// <returns></returns>
public async Task<byte[]> Handle(BurnPdfCommand request, RequestHandlerDelegate<byte[]> next, CancellationToken cancel)
{
var docResult = await next(cancel);
var mailToCreator = request.Envelope!.FinalEmailToCreator;
var mailToReceivers = request.Envelope.FinalEmailToReceivers;
if (mailToCreator is not null && mailToCreator != (int)FinalEmailType.No)
{
_logger.LogDebug("Sending email to creator ...");
await SendFinalEmailToCreatorAsync(request, cancel); // , pAttachment
}
else
{
_logger.LogWarning("No SendFinalEmailToCreatorAsync - mailToCreator [{mailToCreator}] <> [{FinalEmailType.No}] ",
mailToCreator, FinalEmailType.No);
}
if (mailToReceivers != (int)FinalEmailType.No)
{
_logger.LogDebug("Sending emails to receivers...");
await SendFinalEmailToReceiversAsync(request, cancel); // , pAttachment
}
else
{
_logger.LogWarning("No SendFinalEmailToReceiversAsync - mailToReceivers [{mailToReceivers}] <> [{FinalEmailType.No}] ",
mailToReceivers, FinalEmailType.No);
}
return docResult;
}
private async Task SendFinalEmailToCreatorAsync(BurnPdfCommand request, CancellationToken cancel) //, string pAttachment
{
bool oIncludeAttachment = SendFinalEmailWithAttachment((int)request.Envelope!.FinalEmailToCreator!);
// string oAttachment = string.Empty;
_logger.LogDebug("Attachment included: [{oIncludeAttachment}]", oIncludeAttachment);
if (oIncludeAttachment)
{
// oAttachment = pAttachment;
}
await _sender.Send(new CreateHistoryCommand()
{
EnvelopeId = request.Envelope!.Id,
Status = EnvelopeStatus.MessageCompletionSent,
UserReference = request.Envelope.User.Email,
}, cancel);
}
private async Task SendFinalEmailToReceiversAsync(BurnPdfCommand request, CancellationToken cancel) //, string pAttachment
{
bool oIncludeAttachment = SendFinalEmailWithAttachment((int)request.Envelope!.FinalEmailToReceivers!);
// string oAttachment = string.Empty;
_logger.LogDebug("Attachment included: [{oIncludeAttachment}]", oIncludeAttachment);
if (oIncludeAttachment)
{
// oAttachment = pAttachment;
}
// TODO update CreateHistoryCommand to be able to create all records together
foreach (var receiver in request.Envelope.EnvelopeReceivers!)
{
if (receiver.Receiver?.EmailAddress != null)
{
await _sender.Send(new CreateHistoryCommand()
{
EnvelopeId = request.Envelope.Id,
Status = EnvelopeStatus.MessageCompletionSent,
UserReference = receiver.Receiver.EmailAddress,
}, cancel);
}
}
}
private static bool SendFinalEmailWithAttachment(int type) => type == (int)FinalEmailType.YesWithAttachment;
}

View File

@@ -0,0 +1,64 @@
#if WINDOWS
using EnvelopeGenerator.Application.Configs;
using MediatR;
using Microsoft.Extensions.Logging;
namespace EnvelopeGenerator.Application.Pdf.Behaviors;
/// <summary>
///
/// </summary>
public class WritePdfBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
{
private readonly ISender _sender;
private readonly ILogger<WritePdfBehavior> _logger;
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="logger"></param>
public WritePdfBehavior(ISender sender, ILogger<WritePdfBehavior> logger)
{
_sender = sender;
_logger = logger;
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="next"></param>
/// <param name="cancel"></param>
/// <returns></returns>
public async Task<byte[]> Handle(BurnPdfCommand request, RequestHandlerDelegate<byte[]> next, CancellationToken cancel)
{
var docResult = await next(cancel);
var config = await _sender.ReadDefaultConfigAsync(cancel);
var exportPath = config.ExportPath ?? throw new InvalidOperationException(nameof(WritePdfBehavior) + " is not possible."
+ "No export path found in config table.");
var dirPath = Path.Combine(exportPath, request.Envelope!.Uuid);
_logger.LogDebug("dirPath is {dirPath}", dirPath);
if (!Directory.Exists(dirPath))
{
_logger.LogDebug("Directory not existing. Creating ...");
Directory.CreateDirectory(dirPath);
}
var outputFilePath = Path.Combine(dirPath, $"{request.Envelope.Uuid}.pdf");
_logger.LogDebug("Writing finalized Pdf to disk..");
_logger.LogInformation("Output path is {outputFilePath}", outputFilePath);
await File.WriteAllBytesAsync(outputFilePath, docResult, cancel);
return docResult;
}
}
#endif

View File

@@ -0,0 +1,305 @@
using DigitalData.Core.Abstraction.Application.Repository;
using DigitalData.Core.Exceptions;
using EnvelopeGenerator.Application.Common.Configurations;
using EnvelopeGenerator.Application.Common.Dto.PSPDFKitInstant;
using EnvelopeGenerator.Application.Common.Extensions;
using EnvelopeGenerator.Application.Exceptions;
using EnvelopeGenerator.Domain.Constants;
using EnvelopeGenerator.Domain.Entities;
using GdPicture14;
using MediatR;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
namespace EnvelopeGenerator.Application.Pdf;
/// <summary>
///
/// </summary>
public record BurnPdfCommand(int? EnvelopeId = null, string? EnvelopeUuid = null) : IRequest<byte[]>
{
internal bool Debug { get; set; }
internal Envelope? Envelope { get; set; }
#if WINDOWS
internal byte[]? Report { get; set; }
#endif
}
/// <summary>
///
/// </summary>
public static class BurnPdfCommandExtensions
{
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="envelopeId"></param>
/// <param name="cancel"></param>
/// <returns></returns>
public static Task<byte[]> BurnPdf(this ISender sender, int envelopeId, CancellationToken cancel = default)
=> sender.Send(new BurnPdfCommand(EnvelopeId: envelopeId), cancel);
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="envelopeUuid"></param>
/// <param name="cancel"></param>
/// <returns></returns>
public static Task<byte[]> BurnPdf(this ISender sender, string envelopeUuid, CancellationToken cancel = default)
=> sender.Send(new BurnPdfCommand(EnvelopeUuid: envelopeUuid), cancel);
}
/// <summary>
///
/// </summary>
public class BurnPdfCommandHandler : IRequestHandler<BurnPdfCommand, byte[]>
{
private readonly PDFBurnerParams _options;
private readonly AnnotationManager _manager;
private readonly ILogger<BurnPdfCommandHandler> _logger;
private readonly IRepository<Envelope> _envRepo;
private readonly IRepository<Domain.Entities.DocumentStatus> _docStatusRepo;
private readonly IConfiguration _config;
/// <summary>
///
/// </summary>
/// <param name="pdfBurnerParams"></param>
/// <param name="manager"></param>
/// <param name="logger"></param>
/// <param name="envRepo"></param>
/// <param name="docStatusRepo"></param>
/// <param name="config"></param>
public BurnPdfCommandHandler(IOptions<PDFBurnerParams> pdfBurnerParams, AnnotationManager manager, ILogger<BurnPdfCommandHandler> logger, IRepository<Envelope> envRepo, IRepository<Domain.Entities.DocumentStatus> docStatusRepo, IConfiguration config)
{
_options = pdfBurnerParams.Value;
_manager = manager;
_docStatusRepo = docStatusRepo;
_logger = logger;
_envRepo = envRepo;
_config = config;
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancel"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<byte[]> Handle(BurnPdfCommand request, CancellationToken cancel)
{
request.Debug = _config.GetValue<bool>("Debug");
var envQuery =
request.EnvelopeId is not null ? _envRepo.Where(env => env.Id == request.EnvelopeId) :
request.EnvelopeUuid is not null ? _envRepo.Where(env => env.Uuid == request.EnvelopeUuid) :
throw new BadRequestException("Request validation failed: Either Envelope Id or Envelope Uuid must be provided.");
request.Envelope = await envQuery
.Include(env => env.Documents!).ThenInclude(doc => doc.Elements!).ThenInclude(element => element.Annotations)
.Include(env => env.User)
.Include(env => env.EnvelopeReceivers!).ThenInclude(envRcv => envRcv.Receiver)
.FirstOrDefaultAsync(cancel)
?? throw new BadRequestException($"Envelope could not be found. Request details:\n" +
request.ToJson(Format.Json.ForDiagnostics));
var doc = request.Envelope.Documents?.FirstOrDefault()
?? throw new NotFoundException($"Document could not be located within the specified envelope. Request details:\n" +
request.ToJson(Format.Json.ForDiagnostics));
if (doc.ByteData is null)
throw new InvalidOperationException($"Document byte data is missing, indicating a potential data integrity issue. Request details:\n" +
request.ToJson(Format.Json.ForDiagnostics));
return doc.Elements?.SelectMany(e => e.Annotations ?? Enumerable.Empty<ElementAnnotation>()).Where(annot => annot is not null).Any() ?? false
? BurnElementAnnotsToPDF(doc.ByteData, doc.Elements)
: BurnInstantJSONAnnotsToPDF(doc.ByteData, await _docStatusRepo
.Where(status => status.EnvelopeId == request.Envelope.Id)
.Select(status => status.Value)
.ToListAsync(cancel));
}
private byte[] BurnElementAnnotsToPDF(byte[] pSourceBuffer, List<Signature> elements)
{
// Add background
using var doc = PdfEditor.Pdf.FromMemory(pSourceBuffer);
// TODO: take the length from the largest y
pSourceBuffer = doc.Background(elements, 1.9500000000000002 * 0.93, 2.52 * 0.67)
.ExportStream()
.ToArray();
GdPictureStatus oResult;
using var oSourceStream = new MemoryStream(pSourceBuffer);
// Open PDF
oResult = _manager.InitFromStream(oSourceStream);
if (oResult != GdPictureStatus.OK)
throw new BurnAnnotationException($"Could not open document for burning: [{oResult}]");
// Imported from background (add to configuration)
var margin = 0.2;
var inchFactor = 72;
// Y offset of form fields
var keys = new[] { "position", "city", "date" }; // add to configuration
var unitYOffsets = 0.2;
var yOffsetsOfFF = keys
.Select((k, i) => new { Key = k, Value = unitYOffsets * i + 1 })
.ToDictionary(x => x.Key, x => x.Value);
// Add annotations
foreach (var element in elements)
{
var frameX = element.Left - 0.7 - margin;
var frame = element.Annotations?.FirstOrDefault(a => a.Name == "frame");
var frameY = element.Top - 0.5 - margin;
var frameYShift = (frame!.Y ?? default) - frameY * inchFactor;
var frameXShift = (frame.X ?? default) - frameX * inchFactor;
foreach (var annot in element.Annotations!)
{
if (!yOffsetsOfFF.TryGetValue(annot.Name, out var yOffsetofFF))
yOffsetofFF = 0;
var y = frameY + yOffsetofFF;
if (annot.Type == AnnotationType.PSPDFKit.FormField)
{
_manager.AddFormFieldValue(
(annot.X ?? default) / inchFactor,
y,
(annot.Width ?? default) / inchFactor,
(annot.Height ?? default) / inchFactor,
element.Page,
annot.Value,
_options
);
}
else if (annot.Type == AnnotationType.PSPDFKit.Image)
{
_manager.AddImageAnnotation(
(annot.X ?? default) / inchFactor,
annot.Name == "signature" ? ((annot.Y ?? default) - frameYShift) / inchFactor : y,
(annot.Width ?? default) / inchFactor,
(annot.Height ?? default) / inchFactor,
element.Page,
annot.Value
);
}
else if (annot.Type == AnnotationType.PSPDFKit.Ink)
{
_manager.AddInkAnnotation(element.Page, annot.Value);
}
}
}
// Save PDF
using var oNewStream = new MemoryStream();
oResult = _manager.SaveDocumentToPDF(oNewStream);
if (oResult != GdPictureStatus.OK)
throw new BurnAnnotationException($"Could not save document to stream: [{oResult}]");
_manager.Close();
return oNewStream.ToArray();
}
private byte[] BurnInstantJSONAnnotsToPDF(byte[] pSourceBuffer, List<string> pInstantJSONList)
{
GdPictureStatus oResult;
using var oSourceStream = new MemoryStream(pSourceBuffer);
// Open PDF
oResult = _manager.InitFromStream(oSourceStream);
if (oResult != GdPictureStatus.OK)
{
throw new BurnAnnotationException($"Could not open document for burning: [{oResult}]");
}
// Add annotation to PDF
foreach (var oJSON in pInstantJSONList)
{
try
{
if (oJSON is string json)
AddInstantJsonAnnotationToPdf(json);
}
catch (Exception ex)
{
_logger.LogWarning("Error in AddInstantJSONAnnotationToPDF - oJson: ");
_logger.LogWarning(oJSON);
throw new BurnAnnotationException("Adding Annotation failed", ex);
}
}
oResult = _manager.BurnAnnotationsToPage(RemoveInitialAnnots: true, VectorMode: true);
if (oResult != GdPictureStatus.OK)
{
throw new BurnAnnotationException($"Could not burn annotations to file: [{oResult}]");
}
// Save PDF
using var oNewStream = new MemoryStream();
oResult = _manager.SaveDocumentToPDF(oNewStream);
if (oResult != GdPictureStatus.OK)
{
throw new BurnAnnotationException($"Could not save document to stream: [{oResult}]");
}
_manager.Close();
return oNewStream.ToArray();
}
private void AddInstantJsonAnnotationToPdf(string instantJson)
{
var annotationData = JsonConvert.DeserializeObject<InstantData>(instantJson);
annotationData?.Annotations?.Reverse();
if (annotationData?.Annotations is null)
return;
foreach (var annotation in annotationData.Annotations)
{
_logger.LogDebug("Adding AnnotationID: {id}", annotation.Id);
switch (annotation.Type)
{
case AnnotationType.PSPDFKit.Image:
if (annotationData?.Attachments is not null)
_manager.AddImageAnnotation(annotation, annotationData.Attachments);
break;
case AnnotationType.PSPDFKit.Ink:
_manager.AddInkAnnotation(annotation);
break;
case AnnotationType.PSPDFKit.Widget:
// Add form field values
var formFieldValue = annotationData?.FormFieldValues?
.FirstOrDefault(fv => fv.Name == annotation.Id);
if (formFieldValue != null && !_options.IgnoredLabels.Contains(formFieldValue.Value))
{
_manager.AddFormFieldValue(annotation, formFieldValue, _options);
}
break;
}
}
}
}

View File

@@ -1,10 +1,4 @@
using AutoMapper;
using DigitalData.Core.Abstraction.Application.Repository;
using EnvelopeGenerator.Application.Common.Dto.Receiver;
using EnvelopeGenerator.Application.Common.Query;
using MediatR;
using EnvelopeGenerator.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using EnvelopeGenerator.Application.Common.Query;
namespace EnvelopeGenerator.Application.Receivers.Queries;
@@ -12,53 +6,4 @@ namespace EnvelopeGenerator.Application.Receivers.Queries;
/// Stellt eine Abfrage dar, um die Details eines Empfängers zu lesen.
/// um spezifische Informationen über einen Empfänger abzurufen.
/// </summary>
public record ReadReceiverQuery : ReceiverQueryBase, IRequest<IEnumerable<ReceiverDto>>;
/// <summary>
///
/// </summary>
public class ReadReceiverQueryHandler : IRequestHandler<ReadReceiverQuery, IEnumerable<ReceiverDto>>
{
private readonly IRepository<Receiver> _repository;
private readonly IMapper _mapper;
/// <summary>
///
/// </summary>
/// <param name="repository"></param>
/// <param name="mapper"></param>
public ReadReceiverQueryHandler(IRepository<Receiver> repository, IMapper mapper)
{
_repository = repository;
_mapper = mapper;
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<IEnumerable<ReceiverDto>> Handle(ReadReceiverQuery request, CancellationToken cancellationToken)
{
var query = _repository.Query;
if (request.Id is int id)
{
query = query.Where(r => r.Id == id);
}
if (request.EmailAddress is string email)
{
query = query.Where(r => r.EmailAddress == email);
}
if (request.Signature is string signature)
{
query = query.Where(r => r.Signature == signature);
}
var receiver = await query.ToListAsync(cancellationToken);
return _mapper.Map<IEnumerable<ReceiverDto>>(receiver);
}
}
public record ReadReceiverQuery : ReceiverQueryBase;

View File

@@ -0,0 +1,92 @@
using AutoMapper;
using DigitalData.Core.Abstraction.Application.Repository;
using EnvelopeGenerator.Application.Common.Dto;
using EnvelopeGenerator.Domain.Entities;
using MediatR;
using Microsoft.EntityFrameworkCore;
namespace EnvelopeGenerator.Application.ThirdPartyModules.Queries;
/// <summary>
///
/// </summary>
public record ReadThirdPartyModuleQuery : IRequest<IEnumerable<ThirdPartyModuleDto>>
{
/// <summary>
///
/// </summary>
public string? Name { get; init; }
/// <summary>
///
/// </summary>
public bool? Active { get; init; }
}
/// <summary>
///
/// </summary>
public record ReadThirdPartyModuleQueryHandler : IRequestHandler<ReadThirdPartyModuleQuery, IEnumerable<ThirdPartyModuleDto>>
{
private readonly IMapper _mapper;
private readonly IRepository<ThirdPartyModule> _repo;
/// <summary>
///
/// </summary>
/// <param name="mapper"></param>
/// <param name="repo"></param>
public ReadThirdPartyModuleQueryHandler(IMapper mapper, IRepository<ThirdPartyModule> repo)
{
_mapper = mapper;
_repo = repo;
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancel"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<IEnumerable<ThirdPartyModuleDto>> Handle(ReadThirdPartyModuleQuery request, CancellationToken cancel)
{
var query = _repo.Query;
if(request.Name is string name)
query = query.Where(m => m.Name == name);
if (request.Active is bool active)
query = query.Where(m => m.Active == active);
var modules = await query.ToListAsync(cancel);
return _mapper.Map<IEnumerable<ThirdPartyModuleDto>>(modules);
}
}
/// <summary>
///
/// </summary>
public static class ReadThirdPartyModuleQueryExtensions
{
/// <summary>
///
/// </summary>
/// <param name="mediator"></param>
/// <param name="name"></param>
/// <param name="active"></param>
/// <param name="cancel"></param>
/// <returns></returns>
public static async Task<string?> ReadThirdPartyModuleLicenseAsync(this IMediator mediator, string name, bool active = true, CancellationToken cancel = default)
{
var modules = await mediator.Send(new ReadThirdPartyModuleQuery()
{
Name = name,
Active = active,
}, cancel);
return modules.FirstOrDefault()?.License;
}
}

View File

@@ -70,8 +70,8 @@
<Reference Include="DigitalData.Controls.DocumentViewer, Version=1.9.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DigitalData.Controls.DocumentViewer.1.9.8\lib\net462\DigitalData.Controls.DocumentViewer.dll</HintPath>
</Reference>
<Reference Include="DigitalData.Core.Abstraction.Application, Version=1.6.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DigitalData.Core.Abstraction.Application.1.6.0\lib\net462\DigitalData.Core.Abstraction.Application.dll</HintPath>
<Reference Include="DigitalData.Core.Abstraction.Application, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DigitalData.Core.Abstraction.Application.1.5.0\lib\net462\DigitalData.Core.Abstraction.Application.dll</HintPath>
</Reference>
<Reference Include="DigitalData.Core.Abstractions, Version=4.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DigitalData.Core.Abstractions.4.3.0\lib\net462\DigitalData.Core.Abstractions.dll</HintPath>
@@ -109,6 +109,9 @@
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.5.1\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="EnvelopeGenerator.CommonServices">
<HintPath>..\EnvelopeGenerator.CommonServices\bin\Debug\EnvelopeGenerator.CommonServices.dll</HintPath>
</Reference>
<Reference Include="FirebirdSql.Data.FirebirdClient, Version=7.5.0.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c, processorArchitecture=MSIL">
<HintPath>..\packages\FirebirdSql.Data.FirebirdClient.7.5.0\lib\net452\FirebirdSql.Data.FirebirdClient.dll</HintPath>
</Reference>
@@ -463,12 +466,8 @@
<Project>{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}</Project>
<Name>EnvelopeGenerator.CommonServices</Name>
</ProjectReference>
<ProjectReference Include="..\EnvelopeGenerator.CommonServices\EnvelopeGenerator.CommonServices.vbproj">
<Project>{6ea0c51f-c2b1-4462-8198-3de0b32b74f8}</Project>
<Name>EnvelopeGenerator.CommonServices</Name>
</ProjectReference>
<ProjectReference Include="..\EnvelopeGenerator.Domain\EnvelopeGenerator.Domain.csproj">
<Project>{4f32a98d-e6f0-4a09-bd97-1cf26107e837}</Project>
<Project>{4F32A98D-E6F0-4A09-BD97-1CF26107E837}</Project>
<Name>EnvelopeGenerator.Domain</Name>
</ProjectReference>
<ProjectReference Include="..\EnvelopeGenerator.Infrastructure\EnvelopeGenerator.Infrastructure.csproj">
@@ -496,9 +495,6 @@
<Content Include="MailLicense.xml" />
<Content Include="README.txt" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<Import Project="..\packages\GdPicture.runtimes.windows.14.3.3\build\net462\GdPicture.runtimes.windows.targets" Condition="Exists('..\packages\GdPicture.runtimes.windows.14.3.3\build\net462\GdPicture.runtimes.windows.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

View File

@@ -32,7 +32,7 @@ Public Class frmFinalizePDF
#Disable Warning BC40000 ' Type or member is obsolete
Factory.Shared _
.BehaveOnPostBuild(PostBuildBehavior.Ignore) _
.AddEnvelopeGeneratorInfrastructureServices(
.AddEGInfrastructureServices(
Sub(opt)
opt.AddDbTriggerParams(
Sub(triggers)

View File

@@ -3,7 +3,7 @@
<package id="AutoMapper" version="10.1.1" targetFramework="net462" />
<package id="BouncyCastle.Cryptography" version="2.5.0" targetFramework="net462" />
<package id="DigitalData.Controls.DocumentViewer" version="1.9.8" targetFramework="net462" />
<package id="DigitalData.Core.Abstraction.Application" version="1.6.0" targetFramework="net462" />
<package id="DigitalData.Core.Abstraction.Application" version="1.5.0" targetFramework="net462" />
<package id="DigitalData.Core.Abstractions" version="4.3.0" targetFramework="net462" />
<package id="DigitalData.Modules.Base" version="1.3.8" targetFramework="net462" />
<package id="DigitalData.Modules.Config" version="1.3.0" targetFramework="net462" />

View File

@@ -72,8 +72,8 @@
<Reference Include="DevExpress.XtraEditors.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.XtraGauges.v21.2.Core, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.XtraReports.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DigitalData.Core.Abstraction.Application, Version=1.6.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DigitalData.Core.Abstraction.Application.1.6.0\lib\net462\DigitalData.Core.Abstraction.Application.dll</HintPath>
<Reference Include="DigitalData.Core.Abstraction.Application, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DigitalData.Core.Abstraction.Application.1.5.0\lib\net462\DigitalData.Core.Abstraction.Application.dll</HintPath>
</Reference>
<Reference Include="DigitalData.Core.Abstractions, Version=4.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DigitalData.Core.Abstractions.4.3.0\lib\net462\DigitalData.Core.Abstractions.dll</HintPath>
@@ -560,10 +560,6 @@
<Project>{4f32a98d-e6f0-4a09-bd97-1cf26107e837}</Project>
<Name>EnvelopeGenerator.Domain</Name>
</ProjectReference>
<ProjectReference Include="..\EnvelopeGenerator.Infrastructure\EnvelopeGenerator.Infrastructure.csproj">
<Project>{63e32615-0eca-42dc-96e3-91037324b7c7}</Project>
<Name>EnvelopeGenerator.Infrastructure</Name>
</ProjectReference>
<ProjectReference Include="..\EnvelopeGenerator.PdfEditor\EnvelopeGenerator.PdfEditor.csproj">
<Project>{211619f5-ae25-4ba5-a552-bacafe0632d3}</Project>
<Name>EnvelopeGenerator.PdfEditor</Name>

View File

@@ -69,29 +69,6 @@ Namespace Jobs
Dim oConnectionString As String = pContext.MergedJobDataMap.Item(Value.DATABASE)
Database = New MSSQLServer(LogConfig, MSSQLServer.DecryptConnectionString(oConnectionString))
#Disable Warning BC40000 ' Type or member is obsolete
Factory.Shared _
.BehaveOnPostBuild(PostBuildBehavior.Ignore) _
.AddEnvelopeGeneratorInfrastructureServices(
Sub(opt)
opt.AddDbTriggerParams(
Sub(triggers)
triggers("Envelope") = New List(Of String) From {"TBSIG_ENVELOPE_AFT_INS"}
triggers("History") = New List(Of String) From {"TBSIG_ENVELOPE_HISTORY_AFT_INS"}
triggers("EmailOut") = New List(Of String) From {"TBEMLP_EMAIL_OUT_AFT_INS", "TBEMLP_EMAIL_OUT_AFT_UPD"}
triggers("EnvelopeReceiverReadOnly") = New List(Of String) From {"TBSIG_ENVELOPE_RECEIVER_READ_ONLY_UPD"}
triggers("Receiver") = New List(Of String)() ' no tigger
triggers("EmailTemplate") = New List(Of String) From {"TBSIG_EMAIL_TEMPLATE_AFT_UPD"}
End Sub)
opt.AddDbContext(
Sub(options)
options.UseSqlServer(oConnectionString) _
.EnableSensitiveDataLogging() _
.EnableDetailedErrors()
End Sub)
End Sub)
#Enable Warning BC40000 ' Type or member is obsolete
Logger.Debug("Loading Models & Services")
Dim oState = GetState()
InitializeModels(oState)
@@ -422,7 +399,7 @@ Namespace Jobs
End Function
Private Function GetEnvelopeData(pEnvelopeId As Integer) As EnvelopeData
Dim oSql = $"SELECT T.GUID, T.ENVELOPE_UUID, T.ENVELOPE_TYPE, T2.FILEPATH, T2.BYTE_DATA FROM [dbo].[TBSIG_ENVELOPE] T
Dim oSql = $"SELECT T.GUID, T.ENVELOPE_UUID,T2.FILEPATH, T2.BYTE_DATA FROM [dbo].[TBSIG_ENVELOPE] T
JOIN TBSIG_ENVELOPE_DOCUMENT T2 ON T.GUID = T2.ENVELOPE_ID
WHERE T.GUID = {pEnvelopeId}"
Dim oTable As DataTable = Database.GetDatatable(oSql)

View File

@@ -37,15 +37,6 @@ Namespace Jobs.FinalizeDocument
Public Function BurnAnnotsToPDF(pSourceBuffer As Byte(), pInstantJSONList As List(Of String), envelopeId As Integer) As Byte()
'read the elements of envelope with their annotations
Using scope = Factory.Shared.ScopeFactory.CreateScope()
Dim envRepo = scope.ServiceProvider.Repository(Of Envelope)()
Dim envelope = envRepo.Where(Function(env) env.Id = envelopeId).FirstOrDefault()
If envelope Is Nothing Then
Throw New BurnAnnotationException($"Envelope with Id {envelopeId} not found.")
ElseIf envelope.ReadOnly Then
Return pSourceBuffer
End If
Dim sigRepo = scope.ServiceProvider.Repository(Of Signature)()
Dim elements = sigRepo _
.Where(Function(sig) sig.Document.EnvelopeId = envelopeId) _

View File

@@ -55,7 +55,7 @@ Public Class PDFMerger
End If
' Convert to PDF/A
oMergedPDF.ConvertToPDFA(oFinalStream, PDFAConformanceLevel, ALLOW_VECTORIZATION, ALLOW_RASTERIZATION)
oMergedPDF.SaveToStream(oFinalStream)
oStatus = oDocumentPDF.GetStat()
If oStatus <> GdPictureStatus.OK Then
Throw New MergeDocumentException($"Document could not be converted to PDF/A: {oStatus}")

View File

@@ -2,7 +2,7 @@
<packages>
<package id="AutoMapper" version="10.1.1" targetFramework="net462" />
<package id="BouncyCastle.Cryptography" version="2.5.0" targetFramework="net462" />
<package id="DigitalData.Core.Abstraction.Application" version="1.6.0" targetFramework="net462" />
<package id="DigitalData.Core.Abstraction.Application" version="1.5.0" targetFramework="net462" />
<package id="DigitalData.Core.Abstractions" version="4.3.0" targetFramework="net462" />
<package id="DigitalData.Modules.Base" version="1.3.8" targetFramework="net462" />
<package id="DigitalData.Modules.Config" version="1.3.0" targetFramework="net462" />

View File

@@ -0,0 +1,98 @@
using DigitalData.EmailProfilerDispatcher;
using DigitalData.UserManager.DependencyInjection;
using EnvelopeGenerator.Application;
using EnvelopeGenerator.Infrastructure;
using Microsoft.Extensions.Caching.SqlServer;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using static EnvelopeGenerator.Infrastructure.DependencyInjection;
namespace EnvelopeGenerator.DependencyInjection;
public static class DependencyInjection
{
public static IServiceCollection AddEnvelopeGenerator(this IServiceCollection services, Action<EGConfiguration> options)
{
var egConfig = new EGConfiguration();
options.Invoke(egConfig);
egConfig.EnsureAllServicesConfigured();
egConfig.RegisterAll(services);
// Add envelope generator services
#pragma warning disable CS0618
services.AddUserManager<EGDbContext>();
#pragma warning restore CS0618
services.AddDispatcher<EGDbContext>();
return services;
}
public record EGConfiguration
{
internal readonly Queue<Action<IServiceCollection>> _serviceRegs = new();
internal void RegisterAll(IServiceCollection services)
{
while (_serviceRegs.Count > 0)
_serviceRegs.Dequeue().Invoke(services);
}
// TODO: update to use attributes and reflections instead of _addingStatus-dictionary
private readonly Dictionary<string, bool> _addingStatus = new ()
{
{ nameof(AddLocalization), false },
{ nameof(AddDistributedSqlServerCache), false },
{ nameof(AddInfrastructure), false },
{ nameof(AddServices), false },
};
public EGConfiguration AddLocalization(Action<IServiceCollection>? customLocalizationOptions = null)
{
_serviceRegs.Enqueue(customLocalizationOptions ?? (s => s.AddLocalization()));
_addingStatus[nameof(AddLocalization)] = true;
return this;
}
public EGConfiguration AddDistributedSqlServerCache(Action<SqlServerCacheOptions> setupAction)
{
_serviceRegs.Enqueue(s => s.AddDistributedSqlServerCache(setupAction));
_addingStatus[nameof(AddDistributedSqlServerCache)] = true;
return this;
}
public EGConfiguration AddInfrastructure(Action<EGInfrastructureConfiguration> options)
{
#pragma warning disable CS0618
_serviceRegs.Enqueue(s => s.AddEGInfrastructureServices(options));
#pragma warning restore CS0618
_addingStatus[nameof(AddInfrastructure)] = true;
return this;
}
public EGConfiguration AddServices(IConfiguration config, bool usePdfBurner = false)
{
#pragma warning disable CS0618
_serviceRegs.Enqueue(s => s.AddEnvelopeGeneratorServices(config));
#pragma warning restore CS0618
_addingStatus[nameof(AddServices)] = true;
return this;
}
internal void EnsureAllServicesConfigured()
{
var missingServices = _addingStatus
.Where(kv => !kv.Value)
.Select(kv => kv.Key)
.ToList();
if (missingServices.Count > 0)
{
var missingList = string.Join(", ", missingServices);
throw new InvalidOperationException(
$"Service configuration incomplete. The following required service methods were not called: {missingList}. " +
"Please ensure all necessary configuration methods are invoked before building the application.");
}
}
}
}

View File

@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.10" />
<PackageReference Include="Microsoft.Extensions.Caching.SqlServer" Version="9.0.10" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.10" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EnvelopeGenerator.Application\EnvelopeGenerator.Application.csproj" />
<ProjectReference Include="..\EnvelopeGenerator.Infrastructure\EnvelopeGenerator.Infrastructure.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,13 @@
namespace EnvelopeGenerator.Domain.Constants
{
public static class AnnotationType
{
public static class PSPDFKit
{
public const string Image = "pspdfkit/image";
public const string Ink = "pspdfkit/ink";
public const string Widget = "pspdfkit/widget";
public const string FormField = "pspdfkit/form-field-value";
}
}
}

View File

@@ -2,8 +2,6 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using EnvelopeGenerator.Domain.Constants;
using Newtonsoft.Json;
#if NETFRAMEWORK
using System;
using System.Collections.Generic;
@@ -108,10 +106,6 @@ public class Envelope
[Column("ENVELOPE_TYPE")]
public int? EnvelopeTypeId { get; set; }
[JsonIgnore]
[NotMapped]
public bool ReadOnly => EnvelopeTypeId == 2;
[Column("CERTIFICATION_TYPE")]
public int? CertificationType { get; set; }
@@ -139,14 +133,12 @@ public class Envelope
= false;
#endif
[NotMapped]
[Column("DOC_RESULT")]
public byte[]
#if NET
?
#endif
DocResult
{ get; set; }
DocResult { get; set; }
[ForeignKey("EnvelopeTypeId")]
public virtual EnvelopeType

View File

@@ -0,0 +1,36 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#if NETFRAMEWORK
using System;
#endif
namespace EnvelopeGenerator.Domain.Entities
{
[Table("VWSIG_ENVELOPE_REPORT", Schema = "dbo")]
public class EnvelopeReport
{
[Key]
[Column("ENVELOPE_ID")]
public int EnvelopeId { get; set; }
// --- HEAD ---
[Column("HEAD_UUID")]
public string HeadUuid { get; set; }
[Column("HEAD_TITLE")]
public string EnvelopeTitle { get; set; } = string.Empty;
[Column("HEAD_MESSAGE")]
public string HeadMessage { get; set; }
// --- POSITIONS ---
[Column("POS_STATUS")]
public int ItemStatus { get; set; }
[Column("POS_WHEN")]
public DateTime? ItemDate { get; set; }
[Column("POS_WHO")]
public string ItemUserReference { get; set; }
}
}

View File

@@ -5,6 +5,8 @@ using System.ComponentModel.DataAnnotations.Schema;
#if NETFRAMEWORK
using System;
using System.Collections.Generic;
#elif NET
using System.Text.Json.Serialization;
#endif
namespace EnvelopeGenerator.Domain.Entities
@@ -120,13 +122,17 @@ public class Signature : ISignature, IHasReceiver
#endif
Annotations { get; set; }
#if NETFRAMEWORK
#if NET
[JsonIgnore]
#endif
[NotMapped]
public double Top => Math.Round(Y, 5);
#if NET
[JsonIgnore]
#endif
[NotMapped]
public double Left => Math.Round(X, 5);
#endif
}
#if NETFRAMEWORK

View File

@@ -0,0 +1,73 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#if NETFRAMEWORK
using System;
#endif
namespace EnvelopeGenerator.Domain.Entities
{
[Table("TBDD_3RD_PARTY_MODULES")]
public class ThirdPartyModule
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")]
public int Id { get; set; }
[Required]
[Column("ACTIVE")]
public bool Active { get; set; }
[Required]
[StringLength(50)]
[Column("NAME")]
public string Name { get; set; }
[StringLength(500)]
[Column("DESCRIPTION")]
public string
#if nullable
?
#endif
Description { get; set; }
[Required]
[Column("LICENSE", TypeName = "varchar(max)")]
public string License { get; set; }
[Required]
[StringLength(20)]
[Column("VERSION")]
public string Version { get; set; }
[StringLength(50)]
[Column("ADDED_WHO")]
public string
#if nullable
?
#endif
AddedWho { get; set; }
[Column("ADDED_WHEN")]
public DateTime
#if nullable
?
#endif
AddedWhen { get; set; }
[StringLength(50)]
[Column("CHANGED_WHO")]
public string
#if nullable
?
#endif
ChangedWho { get; set; }
[Column("CHANGED_WHEN")]
public DateTime
#if nullable
?
#endif
ChangedWhen { get; set; }
}
}

View File

@@ -0,0 +1,44 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>dotnet-EnvelopeGenerator.Finalizer.Win-6d5cc618-4159-4ff2-b600-8a15fbfa8099</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Quartz.AspNetCore" Version="3.15.1" />
<PackageReference Include="Quartzmon" Version="1.0.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.10" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageReference Include="Quartz" Version="3.15.1" />
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.15.1" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="9.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EnvelopeGenerator.Application\EnvelopeGenerator.Application.csproj" />
<ProjectReference Include="..\EnvelopeGenerator.DependencyInjection\EnvelopeGenerator.DependencyInjection.csproj" />
<ProjectReference Include="..\EnvelopeGenerator.Infrastructure\EnvelopeGenerator.Infrastructure.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\" />
<Folder Include="Controllers\" />
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.Database.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="appsettings.Logging.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,35 @@
using EnvelopeGenerator.Finalizer.Job;
using Quartz;
namespace EnvelopeGenerator.Finalizer;
public static class Extensions
{
public static IServiceCollectionQuartzConfigurator ScheduleJobDefault<TJob>(this IServiceCollectionQuartzConfigurator q,
string croneEpression)
where TJob : IJob
{
var name = $"{typeof(TJob).FullName}";
var jobKey = new JobKey(name);
return q.ScheduleJob<TJob>(trigger => trigger
.WithIdentity(name + "-trigger")
.WithCronSchedule(croneEpression),
job => job.WithIdentity(jobKey)
);
}
public static IServiceCollectionQuartzConfigurator ScheduleJobDefault<TJob>(this IServiceCollectionQuartzConfigurator q,
IConfiguration configuration)
where TJob : IJob
{
var expression = configuration[$"{typeof(TJob).Name}:CronExpression"];
if (string.IsNullOrWhiteSpace(expression))
throw new InvalidOperationException(
"Cron expression for the Worker job is not configured. " +
"Please provide a valid cron schedule in the configuration under " +
$"'{typeof(TJob).FullName}:CronExpression'.");
return q.ScheduleJobDefault<TJob>(expression);
}
}

View File

@@ -0,0 +1,28 @@
using EnvelopeGenerator.Application.Common.Configurations;
using MediatR;
using Microsoft.Extensions.Options;
using Quartz;
namespace EnvelopeGenerator.Finalizer.Job
{
public class CreateReportJob : IJob
{
private readonly ILogger<CreateReportJob> _logger;
private readonly IMediator _mediator;
private readonly PDFBurnerParams _options;
public CreateReportJob(ILogger<CreateReportJob> logger, IMediator mediator, IOptions<PDFBurnerParams> options)
{
_logger = logger;
_mediator = mediator;
_options = options.Value;
}
public Task Execute(IJobExecutionContext context)
{
return Task.CompletedTask;
}
}
}

View File

@@ -0,0 +1,128 @@
using EnvelopeGenerator.DependencyInjection;
using EnvelopeGenerator.Finalizer;
using EnvelopeGenerator.Finalizer.Job;
using EnvelopeGenerator.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Quartz;
using Quartz.AspNetCore;
using Quartzmon;
using Serilog;
// Load Serilog from appsettings.json
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(new ConfigurationBuilder()
.AddJsonFile("appsettings.Logging.json", optional: false, reloadOnChange: true)
.Build())
.CreateLogger();
try
{
Log.Information("Application is starting...");
var builder = WebApplication.CreateBuilder(args);
#region Logging
builder.Logging.ClearProviders();
builder.Logging.AddSerilog();
#endregion
#region Configuration
var config = builder.Configuration;
Directory
.GetFiles(builder.Environment.ContentRootPath, "appsettings.*.json", SearchOption.TopDirectoryOnly)
.Where(file => Path.GetFileName(file) != $"appsettings.Development.json")
.Where(file => Path.GetFileName(file) != $"appsettings.migration.json")
.ToList()
.ForEach(file => config.AddJsonFile(file, true, true));
#endregion
#region Web API Services
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
#endregion
#region Quartz
builder.Services.AddQuartz(q =>
{
q.ScheduleJobDefault<CreateReportJob>(config);
});
builder.Services.AddQuartzServer(options =>
{
options.WaitForJobsToComplete = true;
});
builder.Services.AddQuartzmon();
builder.Services.AddSingleton(provider =>
provider.GetRequiredService<ISchedulerFactory>().GetScheduler().Result
);
#endregion
#region Add DB Context, EG Inf. and Services
var cnnStrName = "Default";
var connStr = config.GetConnectionString(cnnStrName)
?? throw new InvalidOperationException($"Connection string '{cnnStrName}' is missing in the application configuration.");
builder.Services.AddEnvelopeGenerator(egOptions => egOptions
.AddLocalization()
.AddDistributedSqlServerCache(options =>
{
options.ConnectionString = connStr;
options.SchemaName = "dbo";
options.TableName = "TBDD_CACHE";
})
.AddInfrastructure(opt =>
{
opt.AddDbTriggerParams(config);
opt.AddDbContext((provider, options) =>
{
var logger = provider.GetRequiredService<ILogger<EGDbContext>>();
var useInMemoryDb = config.GetValue<bool>("UseInMemoryDb");
var dbCtxOpt = useInMemoryDb ? options.UseInMemoryDatabase("EGInMemoryDb") : options.UseSqlServer(connStr);
dbCtxOpt.LogTo(log => logger.LogInformation("{log}", log), LogLevel.Trace)
.EnableSensitiveDataLogging()
.EnableDetailedErrors();
});
})
.AddServices(config, true)
);
#endregion Add DB Context, EG Inf. and Services
var app = builder.Build();
#region Web API Middleware
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseQuartzmon(new QuartzmonOptions()
{
Scheduler = app.Services.GetRequiredService<IScheduler>(),
VirtualPathRoot = "/quartz"
});
app.MapControllers();
#endregion
app.Run();
Log.Information("The worker was stopped.");
}
catch (Exception ex)
{
Log.Fatal(ex, "Worker could not be started!");
}
finally
{
Log.CloseAndFlush();
}

View File

@@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:17119",
"sslPort": 44321
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5010",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "quartz",
"applicationUrl": "https://localhost:7141;http://localhost:5010",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": false,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,22 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"UseDbMigration": false,
"ConnectionStrings": {
"Default": "Server=SDD-VMP04-SQL17\\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;",
"DbMigrationTest": "Server=SDD-VMP04-SQL17\\DD_DEVELOP01;Database=DD_ECM_DATA_MIGR_TEST;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;"
},
"DbTriggerParams": {
"Envelope": [ "TBSIG_ENVELOPE_AFT_INS" ],
"History": [ "TBSIG_ENVELOPE_HISTORY_AFT_INS" ],
"EmailOut": [ "TBEMLP_EMAIL_OUT_AFT_INS", "TBEMLP_EMAIL_OUT_AFT_UPD" ],
"EnvelopeReceiverReadOnly": [ "TBSIG_ENVELOPE_RECEIVER_READ_ONLY_UPD" ],
"Receiver": [],
"EmailTemplate": [ "TBSIG_EMAIL_TEMPLATE_AFT_UPD" ]
},
"UseInMemoryDb": false
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"Debug": true
}

View File

@@ -0,0 +1,8 @@
{
"FinishEnvelopeJob": {
"CronExpression": "* * * * * ?"
},
"EnvelopeTaskApiJob": {
"CronExpression": "* * * * * ?"
}
}

View File

@@ -0,0 +1,81 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
"MinimumLevel": {
"Default": "Verbose",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "E:/LogFiles/Digital Data/signFlow.Finalizer/log.Verbose-.txt",
"rollingInterval": "Day",
"restrictedToMinimumLevel": "Verbose",
"retainedFileCountLimit": 30,
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "E:/LogFiles/Digital Data/signFlow.Finalizer/log.Debug-.txt",
"rollingInterval": "Day",
"restrictedToMinimumLevel": "Debug",
"retainedFileCountLimit": 30,
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "E:/LogFiles/Digital Data/signFlow.Finalizer/log.Info-.txt",
"rollingInterval": "Day",
"restrictedToMinimumLevel": "Information",
"retainedFileCountLimit": 30,
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "E:/LogFiles/Digital Data/signFlow.Finalizer/log.Warning-.txt",
"rollingInterval": "Day",
"restrictedToMinimumLevel": "Warning",
"retainedFileCountLimit": 30,
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "E:/LogFiles/Digital Data/signFlow.Finalizer/log.Error-.txt",
"rollingInterval": "Day",
"restrictedToMinimumLevel": "Error",
"retainedFileCountLimit": 30,
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "E:/LogFiles/Digital Data/signFlow.Finalizer/log.Fatal-.txt",
"rollingInterval": "Day",
"restrictedToMinimumLevel": "Fatal",
"retainedFileCountLimit": 30,
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ]
}
}

View File

@@ -0,0 +1,14 @@
{
"IgnoredLabels": {
"Label": [
"Date",
"Datum",
"ZIP",
"PLZ",
"Place",
"Ort",
"Position",
"Stellung"
]
}
}

View File

@@ -0,0 +1,3 @@
{
"GdPictureLicenseKey": "kG1Qf9PwmqgR8aDmIW2zI_ebj48RzqAJegRxcystEmkbTGQqfkNBdFOXIb6C_A00Ra8zZkrHdfjqzOPXK7kgkF2YDhvrqKfqh4WDug2vOt0qO31IommzkANSuLjZ4zmraoubyEVd25rE3veQ2h_j7tGIoH_LyIHmy24GaXsxdG0yCzIBMdiLbMMMDwcPY-809KeZ83Grv76OVhFvcbBWyYc251vou1N-kGg5_ZlHDgfWoY85gTLRxafjD3KS_i9ARW4BMiy36y8n7UP2jN8kGRnW_04ubpFtfjJqvtsrP_J9D0x7bqV8xtVtT5JI6dpKsVTiMgDCrIcoFSo5gCC1fw9oUopX4TDCkBQttO4-WHBlOeq9dG5Yb0otonVmJKaQA2tP6sMR-lZDs3ql_WI9t91yPWgpssrJUxSHDd27_LMTH_owJIqkF3NOJd9mYQuAv22oNKFYbH8e41pVKb8cT33Y9CgcQ_sy6YDA5PTuIRi67mjKge_nD9rd0IN213Ir9M_EFWqg9e4haWzIdHXQUo0md70kVhPX4UIH_BKJnxEEnFfoFRNMh77bB0N4jkcBEHPl-ghOERv8dOztf4vCnNpzzWvcLD2cqWIm6THy8XGGq9h4hp8aEreRleSMwv9QQAC7mjLwhQ1rBYkpUHlpTjhTLnMwHknl6HH0Z6zzmsgkRKVyfquv94Pd7QbQfZrRka0ss_48pf9p8hAywEn81Q=="
}

View File

@@ -0,0 +1,44 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>dotnet-EnvelopeGenerator.Finalizer-6d5cc618-4159-4ff2-b600-8a15fbfa8099</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Quartz.AspNetCore" Version="3.15.1" />
<PackageReference Include="Quartzmon" Version="1.0.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.10" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageReference Include="Quartz" Version="3.15.1" />
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.15.1" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="9.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EnvelopeGenerator.Application\EnvelopeGenerator.Application.csproj" />
<ProjectReference Include="..\EnvelopeGenerator.DependencyInjection\EnvelopeGenerator.DependencyInjection.csproj" />
<ProjectReference Include="..\EnvelopeGenerator.Infrastructure\EnvelopeGenerator.Infrastructure.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\" />
<Folder Include="Controllers\" />
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.Database.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="appsettings.Logging.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,35 @@
using EnvelopeGenerator.Finalizer.Job;
using Quartz;
namespace EnvelopeGenerator.Finalizer;
public static class Extensions
{
public static IServiceCollectionQuartzConfigurator ScheduleJobDefault<TJob>(this IServiceCollectionQuartzConfigurator q,
string croneEpression)
where TJob : IJob
{
var name = $"{typeof(TJob).FullName}";
var jobKey = new JobKey(name);
return q.ScheduleJob<TJob>(trigger => trigger
.WithIdentity(name + "-trigger")
.WithCronSchedule(croneEpression),
job => job.WithIdentity(jobKey)
);
}
public static IServiceCollectionQuartzConfigurator ScheduleJobDefault<TJob>(this IServiceCollectionQuartzConfigurator q,
IConfiguration configuration)
where TJob : IJob
{
var expression = configuration[$"{typeof(TJob).Name}:CronExpression"];
if (string.IsNullOrWhiteSpace(expression))
throw new InvalidOperationException(
"Cron expression for the Worker job is not configured. " +
"Please provide a valid cron schedule in the configuration under " +
$"'{typeof(TJob).FullName}:CronExpression'.");
return q.ScheduleJobDefault<TJob>(expression);
}
}

View File

@@ -0,0 +1,24 @@
using Quartz;
namespace EnvelopeGenerator.Finalizer.Job
{
public class EnvelopeTaskApiJob : IJob
{
private readonly ILogger<EnvelopeTaskApiJob> _logger;
public EnvelopeTaskApiJob(ILogger<EnvelopeTaskApiJob> logger)
{
_logger = logger;
}
public Task Execute(IJobExecutionContext context)
{
if (_logger.IsEnabled(LogLevel.Information))
{
_logger.LogInformation("{jobName} running at: {time}", context.JobDetail.Key, DateTimeOffset.Now);
}
return Task.CompletedTask;
}
}
}

View File

@@ -0,0 +1,72 @@
using EnvelopeGenerator.Application.Common.Configurations;
using EnvelopeGenerator.Application.Envelopes.Queries;
using EnvelopeGenerator.Application.Pdf;
using EnvelopeGenerator.Domain.Constants;
using MediatR;
using Microsoft.Extensions.Options;
using Quartz;
namespace EnvelopeGenerator.Finalizer.Job
{
public class FinishEnvelopeJob : IJob
{
private readonly ILogger<FinishEnvelopeJob> _logger;
private readonly IMediator _mediator;
private readonly PDFBurnerParams _options;
public FinishEnvelopeJob(ILogger<FinishEnvelopeJob> logger, IMediator mediator, IOptions<PDFBurnerParams> options)
{
_logger = logger;
_mediator = mediator;
_options = options.Value;
}
public async Task Execute(IJobExecutionContext context)
{
var cancel = context.CancellationToken;
var envelopes = await _mediator.Send(new ReadEnvelopeQuery()
{
Status = new() { Include = [ EnvelopeStatus.EnvelopeCompletelySigned ] },
HasDocResult = false
}, cancel);
using var semaphore = new SemaphoreSlim(_options.ConcurrencyLimit);
await Task.WhenAll(envelopes.Select(async envelope =>
{
await semaphore.WaitAsync(cancel);
try
{
await _mediator.BurnPdf(envelope.Id, cancel);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error burning envelope {EnvelopeId}", envelope.Id);
}
finally
{
semaphore.Release();
}
}));
var envelopeCount = envelopes.Count();
if (envelopeCount > 0)
{
_logger.LogInformation(
"Job '{JobName}' executed at {Timestamp}. {EnvelopeCount} envelope(s) successfully finalized. UUID(s): {EnvelopeUuids}",
context.JobDetail.Key.Name,
context.FireTimeUtc.ToLocalTime(),
envelopeCount,
string.Join(", ", envelopes.Select(e => e.Uuid))
);
}
else
_logger.LogInformation("Job '{JobName}' executed successfully at {Timestamp}. No envelopes were finalized.",
context.JobDetail.Key.Name,
context.FireTimeUtc.ToLocalTime()
);
}
}
}

View File

@@ -0,0 +1,129 @@
using EnvelopeGenerator.DependencyInjection;
using EnvelopeGenerator.Finalizer;
using EnvelopeGenerator.Finalizer.Job;
using EnvelopeGenerator.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Quartz;
using Quartz.AspNetCore;
using Quartzmon;
using Serilog;
// Load Serilog from appsettings.json
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(new ConfigurationBuilder()
.AddJsonFile("appsettings.Logging.json", optional: false, reloadOnChange: true)
.Build())
.CreateLogger();
try
{
Log.Information("Application is starting...");
var builder = WebApplication.CreateBuilder(args);
#region Logging
builder.Logging.ClearProviders();
builder.Logging.AddSerilog();
#endregion
#region Configuration
var config = builder.Configuration;
Directory
.GetFiles(builder.Environment.ContentRootPath, "appsettings.*.json", SearchOption.TopDirectoryOnly)
.Where(file => Path.GetFileName(file) != $"appsettings.Development.json")
.Where(file => Path.GetFileName(file) != $"appsettings.migration.json")
.ToList()
.ForEach(file => config.AddJsonFile(file, true, true));
#endregion
#region Web API Services
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
#endregion
#region Quartz
builder.Services.AddQuartz(q =>
{
q.ScheduleJobDefault<FinishEnvelopeJob>(config);
q.ScheduleJobDefault<EnvelopeTaskApiJob>(config);
});
builder.Services.AddQuartzServer(options =>
{
options.WaitForJobsToComplete = true;
});
builder.Services.AddQuartzmon();
builder.Services.AddSingleton(provider =>
provider.GetRequiredService<ISchedulerFactory>().GetScheduler().Result
);
#endregion
#region Add DB Context, EG Inf. and Services
var cnnStrName = "Default";
var connStr = config.GetConnectionString(cnnStrName)
?? throw new InvalidOperationException($"Connection string '{cnnStrName}' is missing in the application configuration.");
builder.Services.AddEnvelopeGenerator(egOptions => egOptions
.AddLocalization()
.AddDistributedSqlServerCache(options =>
{
options.ConnectionString = connStr;
options.SchemaName = "dbo";
options.TableName = "TBDD_CACHE";
})
.AddInfrastructure(opt =>
{
opt.AddDbTriggerParams(config);
opt.AddDbContext((provider, options) =>
{
var logger = provider.GetRequiredService<ILogger<EGDbContext>>();
var useInMemoryDb = config.GetValue<bool>("UseInMemoryDb");
var dbCtxOpt = useInMemoryDb ? options.UseInMemoryDatabase("EGInMemoryDb") : options.UseSqlServer(connStr);
dbCtxOpt.LogTo(log => logger.LogInformation("{log}", log), LogLevel.Trace)
.EnableSensitiveDataLogging()
.EnableDetailedErrors();
});
})
.AddServices(config, true)
);
#endregion Add DB Context, EG Inf. and Services
var app = builder.Build();
#region Web API Middleware
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseQuartzmon(new QuartzmonOptions()
{
Scheduler = app.Services.GetRequiredService<IScheduler>(),
VirtualPathRoot = "/quartz"
});
app.MapControllers();
#endregion
app.Run();
Log.Information("The worker was stopped.");
}
catch (Exception ex)
{
Log.Fatal(ex, "Worker could not be started!");
}
finally
{
Log.CloseAndFlush();
}

View File

@@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:17119",
"sslPort": 44321
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5010",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "quartz",
"applicationUrl": "https://localhost:7141;http://localhost:5010",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": false,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,22 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"UseDbMigration": false,
"ConnectionStrings": {
"Default": "Server=SDD-VMP04-SQL17\\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;",
"DbMigrationTest": "Server=SDD-VMP04-SQL17\\DD_DEVELOP01;Database=DD_ECM_DATA_MIGR_TEST;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;"
},
"DbTriggerParams": {
"Envelope": [ "TBSIG_ENVELOPE_AFT_INS" ],
"History": [ "TBSIG_ENVELOPE_HISTORY_AFT_INS" ],
"EmailOut": [ "TBEMLP_EMAIL_OUT_AFT_INS", "TBEMLP_EMAIL_OUT_AFT_UPD" ],
"EnvelopeReceiverReadOnly": [ "TBSIG_ENVELOPE_RECEIVER_READ_ONLY_UPD" ],
"Receiver": [],
"EmailTemplate": [ "TBSIG_EMAIL_TEMPLATE_AFT_UPD" ]
},
"UseInMemoryDb": false
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Error",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"Debug": true
}

View File

@@ -0,0 +1,11 @@
{
"FinishEnvelopeJob": {
"CronExpression": "0 0/1 * 1/1 * ? *"
},
"EnvelopeTaskApiJob": {
"CronExpression": "0 0/1 * 1/1 * ? *"
}
"Expressions": {
"PerSec": "* * * * * ?"
}
}

View File

@@ -0,0 +1,81 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
"MinimumLevel": {
"Default": "Verbose",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "E:/LogFiles/Digital Data/signFlow.Finalizer/log.Verbose-.txt",
"rollingInterval": "Day",
"restrictedToMinimumLevel": "Verbose",
"retainedFileCountLimit": 30,
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "E:/LogFiles/Digital Data/signFlow.Finalizer/log.Debug-.txt",
"rollingInterval": "Day",
"restrictedToMinimumLevel": "Debug",
"retainedFileCountLimit": 30,
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "E:/LogFiles/Digital Data/signFlow.Finalizer/log.Info-.txt",
"rollingInterval": "Day",
"restrictedToMinimumLevel": "Information",
"retainedFileCountLimit": 30,
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "E:/LogFiles/Digital Data/signFlow.Finalizer/log.Warning-.txt",
"rollingInterval": "Day",
"restrictedToMinimumLevel": "Warning",
"retainedFileCountLimit": 30,
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "E:/LogFiles/Digital Data/signFlow.Finalizer/log.Error-.txt",
"rollingInterval": "Day",
"restrictedToMinimumLevel": "Error",
"retainedFileCountLimit": 30,
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "E:/LogFiles/Digital Data/signFlow.Finalizer/log.Fatal-.txt",
"rollingInterval": "Day",
"restrictedToMinimumLevel": "Fatal",
"retainedFileCountLimit": 30,
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ]
}
}

View File

@@ -0,0 +1,14 @@
{
"IgnoredLabels": {
"Label": [
"Date",
"Datum",
"ZIP",
"PLZ",
"Place",
"Ort",
"Position",
"Stellung"
]
}
}

View File

@@ -0,0 +1,3 @@
{
"GdPictureLicenseKey": "kG1Qf9PwmqgR8aDmIW2zI_ebj48RzqAJegRxcystEmkbTGQqfkNBdFOXIb6C_A00Ra8zZkrHdfjqzOPXK7kgkF2YDhvrqKfqh4WDug2vOt0qO31IommzkANSuLjZ4zmraoubyEVd25rE3veQ2h_j7tGIoH_LyIHmy24GaXsxdG0yCzIBMdiLbMMMDwcPY-809KeZ83Grv76OVhFvcbBWyYc251vou1N-kGg5_ZlHDgfWoY85gTLRxafjD3KS_i9ARW4BMiy36y8n7UP2jN8kGRnW_04ubpFtfjJqvtsrP_J9D0x7bqV8xtVtT5JI6dpKsVTiMgDCrIcoFSo5gCC1fw9oUopX4TDCkBQttO4-WHBlOeq9dG5Yb0otonVmJKaQA2tP6sMR-lZDs3ql_WI9t91yPWgpssrJUxSHDd27_LMTH_owJIqkF3NOJd9mYQuAv22oNKFYbH8e41pVKb8cT33Y9CgcQ_sy6YDA5PTuIRi67mjKge_nD9rd0IN213Ir9M_EFWqg9e4haWzIdHXQUo0md70kVhPX4UIH_BKJnxEEnFfoFRNMh77bB0N4jkcBEHPl-ghOERv8dOztf4vCnNpzzWvcLD2cqWIm6THy8XGGq9h4hp8aEreRleSMwv9QQAC7mjLwhQ1rBYkpUHlpTjhTLnMwHknl6HH0Z6zzmsgkRKVyfquv94Pd7QbQfZrRka0ss_48pf9p8hAywEn81Q=="
}

View File

@@ -1,130 +0,0 @@
using DigitalData.Core.Abstraction.Application.DTO;
using DigitalData.Core.Exceptions;
using EnvelopeGenerator.Application.Common.Extensions;
using EnvelopeGenerator.Application.Common.Interfaces.Services;
using EnvelopeGenerator.Application.Common.Notifications.DocSigned;
using EnvelopeGenerator.Application.EnvelopeReceivers.Queries;
using EnvelopeGenerator.Application.Histories.Queries;
using EnvelopeGenerator.Domain.Constants;
using EnvelopeGenerator.GeneratorAPI.Extensions;
using MediatR;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
/// <summary>
/// Manages annotations and signature lifecycle for envelopes.
/// </summary>
[Authorize(Roles = ReceiverRole.FullyAuth)]
[ApiController]
[Route("api/[controller]")]
public class AnnotationController : ControllerBase
{
[Obsolete("Use MediatR")]
private readonly IEnvelopeHistoryService _historyService;
[Obsolete("Use MediatR")]
private readonly IEnvelopeReceiverService _envelopeReceiverService;
private readonly IMediator _mediator;
private readonly ILogger<AnnotationController> _logger;
/// <summary>
/// Initializes a new instance of <see cref="AnnotationController"/>.
/// </summary>
[Obsolete("Use MediatR")]
public AnnotationController(
ILogger<AnnotationController> logger,
IEnvelopeHistoryService envelopeHistoryService,
IEnvelopeReceiverService envelopeReceiverService,
IMediator mediator)
{
_historyService = envelopeHistoryService;
_envelopeReceiverService = envelopeReceiverService;
_mediator = mediator;
_logger = logger;
}
/// <summary>
/// Creates or updates annotations for the authenticated envelope receiver.
/// </summary>
/// <param name="psPdfKitAnnotation">Annotation payload.</param>
/// <param name="cancel">Cancellation token.</param>
[Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpPost]
[Obsolete("This endpoint is for PSPDF Kit.")]
public async Task<IActionResult> CreateOrUpdate([FromBody] PsPdfKitAnnotation? psPdfKitAnnotation = null, CancellationToken cancel = default)
{
var signature = User.GetAuthReceiverSignature();
var uuid = User.GetAuthEnvelopeUuid();
if (signature is null || uuid is null)
{
_logger.LogError("Authorization failed: authenticated user does not have a valid signature or envelope UUID.");
return Unauthorized("User authentication is incomplete. Missing required claims for processing this request.");
}
var envelopeReceiver = await _mediator.ReadEnvelopeReceiverAsync(uuid, signature, cancel).ThrowIfNull(Exceptions.NotFound);
if (!envelopeReceiver.Envelope!.ReadOnly && psPdfKitAnnotation is null)
return BadRequest();
if (await _mediator.IsSignedAsync(uuid, signature, cancel))
return Problem(statusCode: StatusCodes.Status409Conflict);
else if (await _mediator.AnyHistoryAsync(uuid, new[] { EnvelopeStatus.EnvelopeRejected, EnvelopeStatus.DocumentRejected }, cancel))
return Problem(statusCode: StatusCodes.Status423Locked);
var docSignedNotification = await _mediator
.ReadEnvelopeReceiverAsync(uuid, signature, cancel)
.ToDocSignedNotification(psPdfKitAnnotation)
?? throw new NotFoundException("Envelope receiver is not found.");
await _mediator.PublishSafely(docSignedNotification, cancel);
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
return Ok();
}
/// <summary>
/// Rejects the document for the current receiver.
/// </summary>
/// <param name="reason">Optional rejection reason.</param>
[Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpPost("reject")]
[Obsolete("Use MediatR")]
public async Task<IActionResult> Reject([FromBody] string? reason = null)
{
var signature = User.GetAuthReceiverSignature();
var uuid = User.GetAuthEnvelopeUuid();
var mail = User.GetAuthReceiverMail();
if (uuid is null || signature is null || mail is null)
{
_logger.LogEnvelopeError(uuid: uuid, signature: signature,
message: @$"Unauthorized POST request in api\\envelope\\reject. One of claims, Envelope, signature or mail ({mail}) is null.");
return Unauthorized();
}
var envRcvRes = await _envelopeReceiverService.ReadByUuidSignatureAsync(uuid: uuid, signature: signature);
if (envRcvRes.IsFailed)
{
_logger.LogNotice(envRcvRes.Notices);
return Unauthorized("you are not authorized");
}
var histRes = await _historyService.RecordAsync(envRcvRes.Data.EnvelopeId, userReference: mail, EnvelopeStatus.DocumentRejected, comment: reason);
if (histRes.IsSuccess)
{
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
return NoContent();
}
_logger.LogEnvelopeError(uuid: uuid, signature: signature, message: "Unexpected error happened in api/envelope/reject");
_logger.LogNotice(histRes.Notices);
return StatusCode(500, histRes.Messages);
}
}

View File

@@ -1,29 +0,0 @@
using EnvelopeGenerator.GeneratorAPI.Models.PsPdfKitAnnotation;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
/// <summary>
/// Exposes configuration data required by the client applications.
/// </summary>
/// <remarks>
/// Initializes a new instance of <see cref="ConfigController"/>.
/// </remarks>
[Route("api/[controller]")]
[ApiController]
[Authorize]
public class ConfigController(IOptionsMonitor<AnnotationParams> annotationParamsOptions) : ControllerBase
{
private readonly AnnotationParams _annotationParams = annotationParamsOptions.CurrentValue;
/// <summary>
/// Returns annotation configuration that was previously rendered by MVC.
/// </summary>
[HttpGet("Annotations")]
public IActionResult GetAnnotationParams()
{
return Ok(_annotationParams.AnnotationJSObject);
}
}

View File

@@ -1,43 +0,0 @@
using DigitalData.Core.Exceptions;
using EnvelopeGenerator.Application.Common.Extensions;
using EnvelopeGenerator.Application.EnvelopeReceivers.Queries;
using EnvelopeGenerator.Domain.Constants;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
/// <summary>
/// Provides access to envelope documents for authenticated receivers.
/// </summary>
/// <remarks>
/// Initializes a new instance of the <see cref="DocumentController"/> class.
/// </remarks>
[Authorize(Roles = ReceiverRole.FullyAuth)]
[ApiController]
[Route("api/[controller]")]
public class DocumentController(IMediator mediator, ILogger<DocumentController> logger) : ControllerBase
{
/// <summary>
/// Returns the document bytes for the specified envelope receiver key.
/// </summary>
/// <param name="query">Encoded envelope key.</param>
/// <param name="cancel">Cancellation token.</param>
[HttpGet]
public async Task<IActionResult> GetDocument(ReadEnvelopeReceiverQuery query, CancellationToken cancel)
{
var envRcv = await mediator.Send(query, cancel).FirstAsync(Exceptions.NotFound);
var byteData = envRcv.Envelope?.Documents?.FirstOrDefault()?.ByteData;
if (byteData is null || byteData.Length == 0)
{
logger.LogError("Document byte data is null or empty for envelope-receiver entity:\n{envelopeKey}.",
envRcv.ToJson(Format.Json.ForDiagnostics));
throw new NotFoundException("Document is empty.");
}
return File(byteData, "application/octet-stream");
}
}

View File

@@ -7,10 +7,10 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using MediatR;
using System.Threading.Tasks;
using DigitalData.UserManager.Application.Services;
using DigitalData.Core.Exceptions;
using EnvelopeGenerator.Application.Common.Dto;
using DigitalData.Core.Abstraction.Application.Repository;
using EnvelopeGenerator.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using EnvelopeGenerator.Application.Common.Interfaces.Repositories;
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
@@ -23,9 +23,12 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers;
[Authorize]
public class EmailTemplateController : ControllerBase
{
private readonly ILogger<EmailTemplateController> _logger;
private readonly IMapper _mapper;
private readonly IRepository<EmailTemplate> _repository;
[Obsolete("Use IRepository")]
private readonly IEmailTemplateRepository _repository;
private readonly IMediator _mediator;
@@ -36,11 +39,12 @@ public class EmailTemplateController : ControllerBase
/// <param name="repository">
/// Die AutoMapper-Instanz, die zum Zuordnen von Objekten verwendet wird.
/// </param>
[Obsolete("Use MediatR")]
public EmailTemplateController(IMapper mapper, IRepository<EmailTemplate> repository, IMediator mediator)
[Obsolete("Use IRepository")]
public EmailTemplateController(IMapper mapper, IEmailTemplateRepository repository, ILogger<EmailTemplateController> logger, IMediator mediator)
{
_mapper = mapper;
_repository = repository;
_logger = logger;
_mediator = mediator;
}
@@ -63,7 +67,7 @@ public class EmailTemplateController : ControllerBase
{
if (emailTemplate is null || (emailTemplate.Id is null && emailTemplate.Type is null))
{
var temps = await _repository.Query.ToListAsync();
var temps = await _repository.ReadAllAsync();
return Ok(_mapper.Map<IEnumerable<EmailTemplateDto>>(temps));
}
else

View File

@@ -1,9 +1,11 @@
using EnvelopeGenerator.Application.Envelopes.Commands;
using DigitalData.Core.Abstraction.Application.DTO;
using EnvelopeGenerator.Application.Envelopes.Commands;
using EnvelopeGenerator.Application.Envelopes.Queries;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using EnvelopeGenerator.Application.Common.Interfaces.Services;
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
@@ -27,16 +29,21 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers;
public class EnvelopeController : ControllerBase
{
private readonly ILogger<EnvelopeController> _logger;
[Obsolete("Use MediatR")]
private readonly IEnvelopeService _envelopeService;
private readonly IMediator _mediator;
/// <summary>
/// Erstellt eine neue Instanz des EnvelopeControllers.
/// </summary>
/// <param name="logger">Der Logger, der für das Protokollieren von Informationen verwendet wird.</param>
/// <param name="envelopeService">Der Dienst, der für die Verarbeitung von Umschlägen zuständig ist.</param>
/// <param name="mediator"></param>
public EnvelopeController(ILogger<EnvelopeController> logger, IMediator mediator)
[Obsolete("Use MediatR")]
public EnvelopeController(ILogger<EnvelopeController> logger, IEnvelopeService envelopeService, IMediator mediator)
{
_logger = logger;
_envelopeService = envelopeService;
_mediator = mediator;
}
@@ -52,56 +59,98 @@ public class EnvelopeController : ControllerBase
/// <response code="500">Ein unerwarteter Fehler ist aufgetreten.</response>
[Authorize]
[HttpGet]
[Obsolete("Use MediatR")]
public async Task<IActionResult> GetAsync([FromQuery] ReadEnvelopeQuery envelope)
{
var result = await _mediator.Send(envelope.Authorize(User.GetId()));
return result.Any() ? Ok(result) : NotFound();
if (User.GetId() is int intId)
return await _envelopeService.ReadByUserAsync(intId, min_status: envelope.Status?.Min, max_status: envelope.Status?.Max).ThenAsync(
Success: envelopes =>
{
if (envelope.Id is int id)
envelopes = envelopes.Where(e => e.Id == id);
if (envelope.Status is EnvelopeStatusQuery status)
envelopes = envelopes.Where(e => e.Status == status);
if (envelope.Uuid is string uuid)
envelopes = envelopes.Where(e => e.Uuid == uuid);
return envelopes.Any() ? Ok(envelopes) : NotFound();
},
Fail: IActionResult (msg, ntc) =>
{
_logger.LogNotice(ntc);
return StatusCode(StatusCodes.Status500InternalServerError);
});
else
{
_logger.LogError("Trotz erfolgreicher Autorisierung wurde die Benutzer-ID nicht als Ganzzahl erkannt. Dies könnte auf eine fehlerhafte Erstellung der Anspruchsliste zurückzuführen sein.");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
/// <summary>
/// Ruft das Ergebnis eines Dokuments basierend auf der ID ab.
/// </summary>
/// <param name="query"></param>
/// <param name="id">Die eindeutige ID des Umschlags.</param>
/// <param name="view">Gibt an, ob das Dokument inline angezeigt werden soll (true) oder als Download bereitgestellt wird (false).</param>
/// <returns>Eine IActionResult-Instanz, die das Dokument oder einen Fehlerstatus enthält.</returns>
/// <response code="200">Das Dokument wurde erfolgreich abgerufen.</response>
/// <response code="404">Das Dokument wurde nicht gefunden oder ist nicht verfügbar.</response>
/// <response code="500">Ein unerwarteter Fehler ist aufgetreten.</response>
[HttpGet("doc-result")]
public async Task<IActionResult> GetDocResultAsync([FromQuery] ReadEnvelopeQuery query, [FromQuery] bool view = false)
[Obsolete("Use MediatR")]
public async Task<IActionResult> GetDocResultAsync([FromQuery] int id, [FromQuery] bool view = false)
{
var envelopes = await _mediator.Send(query.Authorize(User.GetId()));
var envelope = envelopes.FirstOrDefault();
if (User.GetId() is int intId)
return await _envelopeService.ReadByUserAsync(intId).ThenAsync(
Success: envelopes =>
{
var envelope = envelopes.Where(e => e.Id == id).FirstOrDefault();
if (envelope is null)
return NotFound("Envelope not available.");
if (envelope.DocResult is null)
return NotFound("The document has not been fully signed or the result has not yet been released.");
if (view)
if (envelope is null)
return NotFound("Envelope not available.");
else if (envelope?.DocResult is null)
return NotFound("The document has not been fully signed or the result has not yet been released.");
else
{
if (view)
{
Response.Headers.Append("Content-Disposition", "inline; filename=\"" + envelope.Uuid + ".pdf\"");
return File(envelope.DocResult, "application/pdf");
}
else
return File(envelope.DocResult, "application/pdf", $"{envelope.Uuid}.pdf");
}
},
Fail: IActionResult (msg, ntc) =>
{
_logger.LogNotice(ntc);
return StatusCode(StatusCodes.Status500InternalServerError);
});
else
{
Response.Headers.Append("Content-Disposition", "inline; filename=\"" + envelope.Uuid + ".pdf\"");
return File(envelope.DocResult, "application/pdf");
_logger.LogError("Trotz erfolgreicher Autorisierung wurde die Benutzer-ID nicht als Ganzzahl erkannt. Dies könnte auf eine fehlerhafte Erstellung der Anspruchsliste zurückzuführen sein.");
return StatusCode(StatusCodes.Status500InternalServerError);
}
return File(envelope.DocResult, "application/pdf", $"{envelope.Uuid}.pdf");
}
/// <summary>
///
/// </summary>
/// <param name="command"></param>
/// <param name="envelope"></param>
/// <returns></returns>
[NonAction]
[Authorize]
[HttpPost]
public async Task<IActionResult> CreateAsync([FromBody] CreateEnvelopeCommand command)
public async Task<IActionResult> CreateAsync([FromQuery] CreateEnvelopeCommand envelope)
{
var res = await _mediator.Send(command.Authorize(User.GetId()));
envelope.UserId = User.GetId();
var res = await _mediator.Send(envelope);
if (res is null)
{
_logger.LogError("Failed to create envelope. Envelope details: {EnvelopeDetails}", JsonConvert.SerializeObject(command));
_logger.LogError("Failed to create envelope. Envelope details: {EnvelopeDetails}", JsonConvert.SerializeObject(envelope));
return StatusCode(StatusCodes.Status500InternalServerError);
}
else

View File

@@ -1,4 +1,5 @@
using AutoMapper;
using DigitalData.Core.Abstraction.Application.DTO;
using EnvelopeGenerator.Application.EnvelopeReceivers.Commands;
using EnvelopeGenerator.Application.EnvelopeReceivers.Queries;
using EnvelopeGenerator.Application.Envelopes.Queries;
@@ -10,8 +11,12 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Options;
using System.Data;
using System.Reflection.Metadata;
using EnvelopeGenerator.Domain;
using EnvelopeGenerator.Domain.Constants;
using EnvelopeGenerator.Application.Common.SQL;
using EnvelopeGenerator.Application.Common.Dto.Receiver;
using EnvelopeGenerator.Application.Common.Interfaces.Services;
using EnvelopeGenerator.Application.Common.Interfaces.SQLExecutor;
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
@@ -28,19 +33,38 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers;
public class EnvelopeReceiverController : ControllerBase
{
private readonly ILogger<EnvelopeReceiverController> _logger;
[Obsolete("Use MediatR")]
private readonly IEnvelopeReceiverService _erService;
private readonly IMediator _mediator;
private readonly IMapper _mapper;
private readonly IEnvelopeExecutor _envelopeExecutor;
private readonly IEnvelopeReceiverExecutor _erExecutor;
private readonly IDocumentExecutor _documentExecutor;
private readonly string _cnnStr;
/// <summary>
/// Konstruktor für den EnvelopeReceiverController.
/// </summary>
public EnvelopeReceiverController(ILogger<EnvelopeReceiverController> logger, IMediator mediator, IMapper mapper, IEnvelopeExecutor envelopeExecutor, IEnvelopeReceiverExecutor erExecutor, IDocumentExecutor documentExecutor, IOptions<ConnectionString> csOpt)
/// <param name="logger">Logger-Instanz zur Protokollierung von Informationen und Fehlern.</param>
/// <param name="envelopeReceiverService">Service zur Verwaltung von Umschlagempfängern.</param>
/// <param name="mediator">Mediator-Instanz zur Verarbeitung von Befehlen und Abfragen.</param>
/// <param name="mapper"></param>
/// <param name="envelopeExecutor"></param>
/// <param name="erExecutor"></param>
/// <param name="documentExecutor"></param>
/// <param name="csOpt"></param>
[Obsolete("Use MediatR")]
public EnvelopeReceiverController(ILogger<EnvelopeReceiverController> logger, IEnvelopeReceiverService envelopeReceiverService, IMediator mediator, IMapper mapper, IEnvelopeExecutor envelopeExecutor, IEnvelopeReceiverExecutor erExecutor, IDocumentExecutor documentExecutor, IOptions<ConnectionString> csOpt)
{
_logger = logger;
_erService = envelopeReceiverService;
_mediator = mediator;
_mapper = mapper;
_envelopeExecutor = envelopeExecutor;
@@ -63,6 +87,7 @@ public class EnvelopeReceiverController : ControllerBase
/// <response code="500">Ein unerwarteter Fehler ist aufgetreten.</response>
[Authorize]
[HttpGet]
[Obsolete("Use MediatR")]
public async Task<IActionResult> GetEnvelopeReceiver([FromQuery] ReadEnvelopeReceiverQuery envelopeReceiver)
{
var username = User.GetUsernameOrDefault();
@@ -74,11 +99,20 @@ public class EnvelopeReceiverController : ControllerBase
return StatusCode(StatusCodes.Status500InternalServerError);
}
envelopeReceiver = envelopeReceiver with { Username = username };
var result = await _mediator.Send(envelopeReceiver);
return Ok(result);
return await _erService.ReadByUsernameAsync(
username: username,
min_status: envelopeReceiver.Envelope.Status?.Min,
max_status: envelopeReceiver.Envelope.Status?.Max,
envelopeQuery: envelopeReceiver.Envelope,
receiverQuery: envelopeReceiver.Receiver,
ignore_statuses: envelopeReceiver.Envelope.Status?.Ignore ?? Array.Empty<EnvelopeStatus>())
.ThenAsync(
Success: Ok,
Fail: IActionResult (msg, ntc) =>
{
_logger.LogNotice(ntc);
return StatusCode(StatusCodes.Status500InternalServerError, msg);
});
}
/// <summary>
@@ -95,17 +129,25 @@ public class EnvelopeReceiverController : ControllerBase
/// <response code="500">Ein unerwarteter Fehler ist aufgetreten.</response>
[Authorize]
[HttpGet("salute")]
[Obsolete("Use MediatR")]
public async Task<IActionResult> GetReceiverName([FromQuery] ReadReceiverNameQuery receiver)
{
var name = await _mediator.Send(receiver);
return name is null ? NotFound() : Ok(name);
return await _erService.ReadLastUsedReceiverNameByMailAsync(receiver.EmailAddress, receiver.Id, receiver.Signature).ThenAsync(
Success: res => res is null ? NotFound() : Ok(res),
Fail: IActionResult (msg, ntc) =>
{
if (ntc.HasFlag(Flag.NotFound))
return NotFound();
_logger.LogNotice(ntc);
return StatusCode(StatusCodes.Status500InternalServerError);
});
}
/// <summary>
/// Datenübertragungsobjekt mit Informationen zu Umschlägen, Empfängern und Unterschriften.
/// </summary>
/// <param name="request"></param>
/// <param name="cancel"></param>
/// <returns>HTTP-Antwort</returns>
/// <remarks>
/// Sample request:
@@ -141,10 +183,13 @@ public class EnvelopeReceiverController : ControllerBase
/// <response code="500">Es handelt sich um einen unerwarteten Fehler. Die Protokolle sollten überprüft werden.</response>
[Authorize]
[HttpPost]
public async Task<IActionResult> CreateAsync([FromBody] CreateEnvelopeReceiverCommand request, CancellationToken cancel)
public async Task<IActionResult> CreateAsync([FromBody] CreateEnvelopeReceiverCommand request)
{
CancellationToken cancel = default;
int userId = User.GetId();
#region Create Envelope
var envelope = await _envelopeExecutor.CreateEnvelopeAsync(User.GetId(), request.Title, request.Message, request.TFAEnabled, cancel);
var envelope = await _envelopeExecutor.CreateEnvelopeAsync(userId, request.Title, request.Message, request.TFAEnabled, cancel);
#endregion
#region Add receivers

View File

@@ -1,5 +1,5 @@
using MediatR;
using EnvelopeGenerator.Application.EnvelopeTypes.Queries;
using DigitalData.Core.Abstraction.Application.DTO;
using EnvelopeGenerator.Application.Common.Interfaces.Services;
using Microsoft.AspNetCore.Mvc;
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
@@ -13,27 +13,36 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers;
public class EnvelopeTypeController : ControllerBase
{
private readonly ILogger<EnvelopeTypeController> _logger;
private readonly IMediator _mediator;
[Obsolete("Use MediatR")]
private readonly IEnvelopeTypeService _service;
/// <summary>
///
/// </summary>
/// <param name="logger"></param>
/// <param name="mediator"></param>
public EnvelopeTypeController(ILogger<EnvelopeTypeController> logger, IMediator mediator)
/// <param name="service"></param>
[Obsolete("Use MediatR")]
public EnvelopeTypeController(ILogger<EnvelopeTypeController> logger, IEnvelopeTypeService service)
{
_logger = logger;
_mediator = mediator;
_service = service;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
[Obsolete("Use MediatR")]
[HttpGet]
public async Task<IActionResult> GetAllAsync()
{
var result = await _mediator.Send(new ReadEnvelopeTypesQuery());
return Ok(result);
return await _service.ReadAllAsync().ThenAsync(
Success: Ok,
Fail: IActionResult (msg, ntc) =>
{
_logger.LogNotice(ntc);
return ntc.HasFlag(Flag.NotFound) ? NotFound() : StatusCode(StatusCodes.Status500InternalServerError);
});
}
}

View File

@@ -1,95 +0,0 @@
using DigitalData.Core.Abstraction.Application.DTO;
using EnvelopeGenerator.Application.Common.Dto.EnvelopeReceiverReadOnly;
using EnvelopeGenerator.Application.Common.Interfaces.Services;
using EnvelopeGenerator.Domain.Constants;
using EnvelopeGenerator.GeneratorAPI.Extensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
/// <summary>
/// Manages read-only envelope sharing flows.
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class ReadOnlyController : ControllerBase
{
private readonly ILogger<ReadOnlyController> _logger;
private readonly IEnvelopeReceiverReadOnlyService _readOnlyService;
private readonly IEnvelopeMailService _mailService;
private readonly IEnvelopeHistoryService _historyService;
/// <summary>
/// Initializes a new instance of the <see cref="ReadOnlyController"/> class.
/// </summary>
public ReadOnlyController(ILogger<ReadOnlyController> logger, IEnvelopeReceiverReadOnlyService readOnlyService, IEnvelopeMailService mailService, IEnvelopeHistoryService historyService)
{
_logger = logger;
_readOnlyService = readOnlyService;
_mailService = mailService;
_historyService = historyService;
}
/// <summary>
/// Creates a new read-only receiver for the current envelope.
/// </summary>
/// <param name="createDto">Creation payload.</param>
[HttpPost]
[Authorize(Roles = ReceiverRole.FullyAuth)]
public async Task<IActionResult> CreateAsync([FromBody] EnvelopeReceiverReadOnlyCreateDto createDto)
{
var authReceiverMail = User.GetAuthReceiverMail();
if (authReceiverMail is null)
{
_logger.LogError("EmailAddress claim is not found in envelope-receiver-read-only creation process. Create DTO is:\n {dto}", JsonConvert.SerializeObject(createDto));
return Unauthorized();
}
var envelopeId = User.GetAuthEnvelopeId();
if (envelopeId is null)
{
_logger.LogError("Envelope Id claim is not found in envelope-receiver-read-only creation process. Create DTO is:\n {dto}", JsonConvert.SerializeObject(createDto));
return Unauthorized();
}
createDto.AddedWho = authReceiverMail;
createDto.EnvelopeId = envelopeId;
var creationRes = await _readOnlyService.CreateAsync(createDto: createDto);
if (creationRes.IsFailed)
{
_logger.LogNotice(creationRes);
return StatusCode(StatusCodes.Status500InternalServerError);
}
var readRes = await _readOnlyService.ReadByIdAsync(creationRes.Data.Id);
if (readRes.IsFailed)
{
_logger.LogNotice(creationRes);
return StatusCode(StatusCodes.Status500InternalServerError);
}
var newReadOnly = readRes.Data;
return await _mailService.SendAsync(newReadOnly).ThenAsync<int, IActionResult>(SuccessAsync: async _ =>
{
var histRes = await _historyService.RecordAsync((int)createDto.EnvelopeId, createDto.AddedWho, EnvelopeStatus.EnvelopeShared);
if (histRes.IsFailed)
{
_logger.LogError("Although the envelope was sent as read-only, the EnvelopeShared history could not be saved. Create DTO:\n{createDto}", JsonConvert.SerializeObject(createDto));
_logger.LogNotice(histRes.Notices);
}
return Ok();
},
Fail: (msg, ntc) =>
{
_logger.LogNotice(ntc);
return StatusCode(StatusCodes.Status500InternalServerError);
});
}
}

View File

@@ -1,7 +1,12 @@
using MediatR;
using DigitalData.Core.Abstraction.Application.DTO;
using DigitalData.Core.API;
using EnvelopeGenerator.Application.Receivers.Queries;
using EnvelopeGenerator.Domain.Entities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using EnvelopeGenerator.Application.Receivers.Commands;
using EnvelopeGenerator.Application.Common.Dto.Receiver;
using EnvelopeGenerator.Application.Common.Interfaces.Services;
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
@@ -9,22 +14,22 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers;
/// Controller für die Verwaltung von Empfängern.
/// </summary>
/// <remarks>
/// Dieser Controller bietet Endpunkte für das Abrufen von Empfängern basierend auf E-Mail-Adresse oder Signatur.
/// Dieser Controller bietet Endpunkte für CRUD-Operationen (Erstellen, Lesen, Aktualisieren, Löschen)
/// sowie zusätzliche Funktionen wie das Abrufen von Empfängern basierend auf E-Mail-Adresse oder Signatur.
/// </remarks>
[Route("api/[controller]")]
[ApiController]
[Authorize]
public class ReceiverController : ControllerBase
[Obsolete("Use MediatR")]
public class ReceiverController : CRUDControllerBaseWithErrorHandling<IReceiverService, CreateReceiverCommand, ReceiverDto, UpdateReceiverCommand, Receiver, int>
{
private readonly IMediator _mediator;
/// <summary>
/// Initialisiert eine neue Instanz des <see cref="ReceiverController"/>-Controllers.
/// </summary>
/// <param name="mediator">Mediator für Anfragen.</param>
public ReceiverController(IMediator mediator)
/// <param name="logger">Der Logger für die Protokollierung.</param>
/// <param name="service">Der Dienst für Empfängeroperationen.</param>
public ReceiverController(ILogger<ReceiverController> logger, IReceiverService service) : base(logger, service)
{
_mediator = mediator;
}
/// <summary>
@@ -35,13 +40,60 @@ public class ReceiverController : ControllerBase
[HttpGet]
public async Task<IActionResult> Get([FromQuery] ReadReceiverQuery receiver)
{
if (!receiver.HasAnyCriteria)
{
var all = await _mediator.Send(new ReadReceiverQuery());
return Ok(all);
}
if (receiver.Id is null && receiver.EmailAddress is null && receiver.Signature is null)
return await base.GetAll();
var result = await _mediator.Send(receiver);
return result is null ? NotFound() : Ok(result);
if (receiver.Id is int id)
return await _service.ReadByIdAsync(id).ThenAsync(
Success: Ok,
Fail: IActionResult (msg, ntc) =>
{
return NotFound();
});
return await _service.ReadByAsync(emailAddress: receiver.EmailAddress, signature: receiver.Signature).ThenAsync(
Success: Ok,
Fail: IActionResult (msg, ntc) =>
{
return NotFound();
});
}
#region REMOVED ENDPOINTS
/// <summary>
/// Diese Methode ist deaktiviert und wird nicht verwendet.
/// </summary>
[NonAction]
public override Task<IActionResult> GetAll() => base.GetAll();
/// <summary>
/// Diese Methode ist deaktiviert und wird nicht verwendet.
/// </summary>
[NonAction]
public override Task<IActionResult> Delete([FromRoute] int id) => base.Delete(id);
/// <summary>
/// Diese Methode ist deaktiviert und wird nicht verwendet.
/// </summary>
[NonAction]
public override Task<IActionResult> Update(UpdateReceiverCommand updateDto) => base.Update(updateDto);
/// <summary>
/// Diese Methode ist deaktiviert und wird nicht verwendet.
/// </summary>
[NonAction]
public override Task<IActionResult> Create(CreateReceiverCommand createDto)
{
return base.Create(createDto);
}
/// <summary>
/// Diese Methode ist deaktiviert und wird nicht verwendet.
/// </summary>
[NonAction]
public override Task<IActionResult> GetById([FromRoute] int id)
{
return base.GetById(id);
}
#endregion
}

View File

@@ -1,130 +0,0 @@
using DigitalData.Core.Abstraction.Application.DTO;
using EnvelopeGenerator.Application.Common.Extensions;
using EnvelopeGenerator.Application.Common.Interfaces.Services;
using EnvelopeGenerator.Application.Resources;
using EnvelopeGenerator.Domain.Constants;
using EnvelopeGenerator.GeneratorAPI.Extensions;
using EnvelopeGenerator.GeneratorAPI.Models;
using Ganss.Xss;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Options;
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
/// <summary>
/// Exposes endpoints for registering and managing two-factor authentication for envelope receivers.
/// </summary>
[ApiController]
[Route("api/tfa")]
public class TfaRegistrationController : ControllerBase
{
private readonly ILogger<TfaRegistrationController> _logger;
private readonly IEnvelopeReceiverService _envelopeReceiverService;
private readonly IAuthenticator _authenticator;
private readonly IReceiverService _receiverService;
private readonly TFARegParams _parameters;
private readonly IStringLocalizer<Resource> _localizer;
/// <summary>
/// Initializes a new instance of the <see cref="TfaRegistrationController"/> class.
/// </summary>
public TfaRegistrationController(
ILogger<TfaRegistrationController> logger,
IEnvelopeReceiverService envelopeReceiverService,
IAuthenticator authenticator,
IReceiverService receiverService,
IOptions<TFARegParams> tfaRegParamsOptions,
IStringLocalizer<Resource> localizer)
{
_logger = logger;
_envelopeReceiverService = envelopeReceiverService;
_authenticator = authenticator;
_receiverService = receiverService;
_parameters = tfaRegParamsOptions.Value;
_localizer = localizer;
}
/// <summary>
/// Generates registration metadata (QR code and deadline) for a receiver.
/// </summary>
/// <param name="envelopeReceiverId">Encoded envelope receiver id.</param>
[Authorize]
[HttpGet("{envelopeReceiverId}")]
public async Task<IActionResult> RegisterAsync(string envelopeReceiverId)
{
try
{
var (uuid, signature) = envelopeReceiverId.DecodeEnvelopeReceiverId();
if (uuid is null || signature is null)
{
_logger.LogEnvelopeError(uuid: uuid, signature: signature, message: _localizer.WrongEnvelopeReceiverId());
return Unauthorized(new { message = _localizer.WrongEnvelopeReceiverId() });
}
var secretResult = await _envelopeReceiverService.ReadWithSecretByUuidSignatureAsync(uuid: uuid, signature: signature);
if (secretResult.IsFailed)
{
_logger.LogNotice(secretResult.Notices);
return NotFound(new { message = _localizer.WrongEnvelopeReceiverId() });
}
var envelopeReceiver = secretResult.Data;
if (!envelopeReceiver.Envelope!.TFAEnabled)
return Unauthorized(new { message = _localizer.WrongAccessCode() });
var receiver = envelopeReceiver.Receiver;
receiver!.TotpSecretkey = _authenticator.GenerateTotpSecretKey();
await _receiverService.UpdateAsync(receiver);
var totpQr64 = _authenticator.GenerateTotpQrCode(userEmail: receiver.EmailAddress, secretKey: receiver.TotpSecretkey).ToBase64String();
if (receiver.TfaRegDeadline is null)
{
receiver.TfaRegDeadline = _parameters.Deadline;
await _receiverService.UpdateAsync(receiver);
}
else if (receiver.TfaRegDeadline <= DateTime.Now)
{
return StatusCode(StatusCodes.Status410Gone, new { message = _localizer.WrongAccessCode() });
}
return Ok(new
{
envelopeReceiver.EnvelopeId,
envelopeReceiver.Envelope!.Uuid,
envelopeReceiver.Receiver!.Signature,
receiver.TfaRegDeadline,
TotpQR64 = totpQr64
});
}
catch (Exception ex)
{
_logger.LogEnvelopeError(envelopeReceiverId: envelopeReceiverId, exception: ex, message: _localizer.WrongEnvelopeReceiverId());
return StatusCode(StatusCodes.Status500InternalServerError, new { message = _localizer.UnexpectedError() });
}
}
/// <summary>
/// Logs out the envelope receiver from cookie authentication.
/// </summary>
[Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpPost("auth/logout")]
public async Task<IActionResult> LogOutAsync()
{
try
{
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
return Ok();
}
catch (Exception ex)
{
_logger.LogError(ex, "{message}", ex.Message);
return StatusCode(StatusCodes.Status500InternalServerError, new { message = _localizer.UnexpectedError() });
}
}
}

View File

@@ -1,18 +0,0 @@
namespace EnvelopeGenerator.GeneratorAPI
{
/// <summary>
/// Provides custom claim types for envelope-related information.
/// </summary>
public static class EnvelopeClaimTypes
{
/// <summary>
/// Claim type for the title of an envelope.
/// </summary>
public static readonly string Title = $"Envelope{nameof(Title)}";
/// <summary>
/// Claim type for the ID of an envelope.
/// </summary>
public static readonly string Id = $"Envelope{nameof(Id)}";
}
}

Some files were not shown because too many files have changed in this diff Show More