Commit Graph

2325 Commits

Author SHA1 Message Date
c64c63925e Retrieve GdPicture license key via MediatR from database
Refactored LicenseManager registration to fetch the GdPicture license key from the database using MediatR and ReadThirdPartyModuleLicenseQuery, instead of reading from configuration. Updated using statements accordingly.
2026-04-14 13:25:07 +02:00
2c8ae23203 Add ThirdPartyModule DbSet to EGDbContextBase
Added a DbSet property for ThirdPartyModule entities in EGDbContextBase to enable management and querying of third-party modules via Entity Framework.
2026-04-14 13:21:28 +02:00
b4be718994 Add query/handler to fetch third-party module license text
Introduced ReadThirdPartyModuleLicenseQuery and its handler to retrieve the license text of a third-party module by Id or Name (mutually exclusive), with optional filtering for active modules. Includes validation and exception handling for invalid input, not found, or multiple matches.
2026-04-14 12:39:31 +02:00
33bf5b1a51 Add ThirdPartyModule entity with auditing support
Introduced the ThirdPartyModule entity mapped to the TBDD_3RD_PARTY_MODULES table using Entity Framework. The class includes properties for module details and auditing (added/changed by and when), implements IHasChangedWhen and IHasChangedWho interfaces, and uses conditional compilation for .NET Framework and nullable reference types. Data annotations and schema mapping attributes were added for precise database integration.
2026-04-14 12:15:42 +02:00
6a9792bb57 Refactor WorkerController to manage job state via API
Removed endpoints for starting/stopping/restarting the Worker service. Controller now uses JobStateManager to get and set the state of specific jobs (e.g., FinalizeDocumentJob) through new GET and POST endpoints. Focus shifts from service lifecycle control to job state management.
2026-04-13 16:31:54 +02:00
6954a86358 Add job state check and improve Worker options handling
Refactored Worker to inject JobStateManager and use the full
WorkerOptions object. Now, FinalizeDocumentJob only runs if
its state is State.Running. Delay is also read from options,
improving configuration and control over job execution.
2026-04-13 16:31:00 +02:00
d6c5b63c49 Register JobStateManager as singleton in DI container
JobStateManager is now added as a singleton service, initialized with the InitialJobState from WorkerOptions. This enables consistent state management across the application by providing a shared instance via dependency injection.
2026-04-13 16:30:27 +02:00
8ca360d47e Add InitialJobState and GdPictureLicenseKey to WorkerOptions
Added InitialJobState as a Dictionary<string, State> with an empty default, and introduced a non-nullable GdPictureLicenseKey property to the WorkerOptions class. These additions support initial job state configuration and GdPicture licensing.
2026-04-13 16:29:14 +02:00
2dadefecc5 Add JobStateManager for thread-safe job state tracking
Introduced JobStateManager class to manage job states using a ConcurrentDictionary, supporting thread-safe get/set operations per job type. Added State enum with Running and Stopped values. Allows optional initial state dictionary for job states.
2026-04-13 16:28:40 +02:00
162f066b08 Refactor Worker to use IOptions for configuration
Replaced direct IConfiguration usage in Worker with IOptions<WorkerOptions> for strongly-typed configuration access. Updated delay interval assignment and added necessary namespace import.
2026-04-13 15:25:17 +02:00
6592642945 Update WorkerOptions config section to "Worker"
Changed AddFinalizeDocumentJob to bind WorkerOptions from the "Worker" section in configuration instead of "WorkerOptions" for correct settings mapping.
2026-04-13 15:22:55 +02:00
855f22cf87 Add DelayMilliseconds property to WorkerOptions
Introduced a configurable DelayMilliseconds property to the WorkerOptions class with validation to ensure the value is at least 1 millisecond. This allows for customizable delay settings in worker operations.
2026-04-13 15:22:34 +02:00
726673e277 Add Windows Services hosting support to ServiceHost
Added Microsoft.Extensions.Hosting.WindowsServices package (v8.0.1) to EnvelopeGenerator.ServiceHost.csproj to enable hosting the application as a Windows Service. No other changes were made.
2026-04-13 12:00:01 +02:00
65d615f43e Support inline PDF display or download via query param
Add a 'download' query parameter to DocResultController's GetAsync method. This lets clients choose whether to download the PDF or display it inline by setting the 'download' parameter in the request.
2026-04-13 11:57:46 +02:00
f0f92c5400 Ensure DocResult is included in envelope query handling
Set IncludeDocResult to true on the envelope in the query handler to guarantee the document result is included in responses. This prevents missing document data when processing envelope queries.
2026-04-09 17:10:45 +02:00
7e34f01f6a Include doc result in GetDocResultAsync query
Set IncludeDocResult to true in GetDocResultAsync to ensure the document result is included when retrieving envelope data. This change guarantees that the response contains the necessary document information.
2026-04-09 17:10:08 +02:00
f449767bf9 Add [NotMapped] for Envelope property on .NET Framework
Applied the [NotMapped] attribute to a property in the Envelope class when targeting .NET Framework, ensuring it is not mapped to a database column by Entity Framework in that environment. No changes for other frameworks.
2026-04-09 17:09:40 +02:00
f8ec6065c2 Add IncludeDocResult option to EnvelopeQueryBase
Introduced the IncludeDocResult boolean property to EnvelopeQueryBase, allowing queries to optionally include the DocResult field. By default, DocResult is excluded to prevent unnecessary loading of large binary data.
2026-04-09 16:36:30 +02:00
fabfe80666 Change FinalizeDocumentJob to scoped, add ReportCreator
Changed FinalizeDocumentJob DI registration from singleton to scoped for better instance management. Added ReportCreator as a scoped service. Removed unused EnvelopeGenerator.ServiceHost.Jobs.Infrastructure import.
2026-04-09 16:01:51 +02:00
bdb3863c07 Refactor Kestrel config and add exception middleware
Replaced "UseKestrelConfig" with "UseCustomKestrelEndpoints" and renamed the "Kestrel" section to "ServerConfig" in both Program.cs and appsettings.json. Updated Kestrel server configuration to use the new section. Added ExceptionHandlingMiddleware to the pipeline for global exception handling.
2026-04-09 15:54:38 +02:00
e5295b8302 Add global exception handling middleware
Introduced ExceptionHandlingMiddleware to handle exceptions across the ASP.NET Core request pipeline. The middleware logs exceptions and returns JSON error responses with appropriate HTTP status codes for BadRequestException (400), NotFoundException (404), and generic errors (500). Dependency injection is used for RequestDelegate and ILogger.
2026-04-09 14:47:46 +02:00
00a9cf06da Refactor envelope doc query and improve result validation
Refactored ReadSingleEnvelopeDocResultQuery to remove inheritance from EnvelopeQueryBase and introduce an Envelope property. Enhanced the handler to ensure DocResult is a non-empty byte array before returning, throwing NotFoundException otherwise.
2026-04-09 14:46:04 +02:00
1b387238e8 Configure EnvelopeReport as a keyless entity
Added Entity Framework model configuration for EnvelopeReport in EGDbContextBase, specifying it as a keyless entity using HasNoKey(). This allows EnvelopeReport to be used without a primary key in the database context.
2026-04-09 14:30:23 +02:00
bda4f3dbef Add conditional Windows Service & Kestrel config support
The app now checks configuration values to optionally run as a Windows Service ("UseWindowsService") and/or apply custom Kestrel server settings from the "Kestrel" config section ("UseKestrelConfig"). These changes improve deployment flexibility.
2026-04-09 14:20:04 +02:00
2458d0c07a Configure Kestrel endpoint and hosting options in settings
Added "UseWindowsService" and "UseKestrelConfig" flags to appsettings.json. Defined a custom Kestrel HTTP endpoint at http://localhost:1111 to control how the application is hosted and served.
2026-04-09 14:19:36 +02:00
a72cbab195 Add GET endpoint to return envelope PDF by UUID
Added a new HTTP GET action to DocResultController that accepts a ReadSingleEnvelopeDocResultQuery via query string. The endpoint uses MediatR to retrieve the PDF document and returns it as a file response with the envelope's UUID in the filename and the correct content type.
2026-04-09 14:05:54 +02:00
bcf4e63f7c Add distributed cache, localization, and infra services
- Add DigitalData.Core.API and SQL Server distributed cache dependencies
- Register EnvelopeGenerator.Application project reference
- Configure distributed SQL Server cache and memory cache
- Register infrastructure, application, and user management services
- Set up EF Core with SQL Server and detailed logging
- Enable localization with configurable supported cultures
- Improve modularity and extensibility of service registration
2026-04-09 13:36:40 +02:00
5aabeb4510 Update project to net8.0-windows and enable WinForms
Changed target framework to net8.0-windows to specify Windows platform support. Enabled Windows Forms by setting UseWindowsForms to true in the project file.
2026-04-09 13:34:07 +02:00
32edc6474d Add SupportedCultures and DB connection to appsettings.json
Added "SupportedCultures" for localization support and a "ConnectionStrings" section with a default SQL Server connection string. Also reformatted "AllowedHosts" for consistency.
2026-04-09 13:22:59 +02:00
71bfe3b323 Refactor Worker to resolve FinalizeDocumentJob per scope
Refactored Worker to use IServiceScopeFactory instead of directly injecting FinalizeDocumentJob. Now, a new scope is created in each loop iteration, and FinalizeDocumentJob is resolved from the scoped service provider. This enables FinalizeDocumentJob to use scoped dependencies and improves DI flexibility.
2026-04-09 13:20:02 +02:00
089d2bd1cb Add FinalizeDocumentController and refactor query model
Refactored ReadSingleEnvelopeDocResultQuery to use a parameterless constructor and an Envelope property. Introduced FinalizeDocumentController with a GET endpoint to finalize and return envelope documents as PDFs, supporting force regeneration. Added dependency injection for IMediator and FinalizeDocumentJob. Includes a TODO to migrate forceRegenerate logic into the job.
2026-04-09 10:55:13 +02:00
65c72bcf77 Add DocResultController for envelope PDF download
Introduced DocResultController with a GET endpoint to retrieve envelope PDF documents by sending a query via MediatR. The controller returns the PDF as a file response with an appropriate filename and content type. Added necessary using directives for MediatR, ASP.NET Core MVC, and the application query.
2026-04-09 10:30:04 +02:00
2d8375f26a Refactor envelope query to throw on not found or multiple
Refactored ReadSingleEnvelopeQuery and its handler to return EnvelopeDto directly and throw NotFoundException or BadRequestException when no or multiple envelopes are found, instead of returning null. Updated imports to include custom exceptions.
2026-04-09 10:28:13 +02:00
a7cfb099fa Add query/handler for envelope document retrieval
Introduced ReadSingleEnvelopeDocResultQuery and its handler to fetch an envelope's document as a byte array via MediatR. Throws NotFoundException if the document is missing. Includes XML documentation for clarity.
2026-04-09 10:26:44 +02:00
7a0d4e2fa7 Remove MediatorGetOrContext; add ExecuteAsync overloads
Removed MediatorGetOrContext.cs, eliminating the fluent API for handling null or empty MediatR responses with custom exceptions. Added two ExecuteAsync overloads to FinalizeDocumentJob: one for processing a single EnvelopeDto and another for processing all envelopes with the EnvelopeCompletelySigned status.
2026-04-09 10:25:59 +02:00
3955ee9f39 Refactor Mediator GetOr API for naming consistency
Renamed MediatorExtensions to MediatorGetOrContext and GetOrContext<TResponse> to MediatorGetOrContext<TResponse> for consistent naming. Moved the GetOr extension method into the new static class. Updated XML docs and reorganized declarations; no functional changes.
2026-04-08 15:34:39 +02:00
9bdf24d7d5 Refactor MediatorExtensions to fluent GetOr/Throw API
Replaced GetOrThrow methods with a fluent GetOr/Throw pattern for handling null or empty MediatR responses. Introduced GetOrContext<TResponse> struct with Throw, ThrowNotFound, ThrowInvalidOperation, and ThrowBadRequest methods. Updated all tests to use the new API and added coverage for new exception types. Improved XML docs and performed minor code cleanup.
2026-04-08 15:26:23 +02:00
993ca82596 Rename MediatR extensions to GetOrThrow for ISender
Renamed SendOrThrowAsync and SendOrNotFoundAsync extension methods for IMediator to GetOrThrow for ISender, following MediatR best practices. Updated all usages, XML docs, and tests to use ISender and the new method names. Replaced StubMediator with StubSender in tests. Functionality remains the same, but code now aligns with modern MediatR conventions.
2026-04-08 14:01:24 +02:00
ce9958a8b1 Add MediatorExtensions tests and refactor CreateEnvelopeCommand
Introduce MediatorExtensionsTests to cover SendOrThrowAsync and SendOrNotFoundAsync extension methods for IMediator, including edge cases and cancellation. Refactor CreateEnvelopeCommand in Fake.cs to use Authorize(userId) instead of setting UserId directly. Add test stubs for IMediator and IRequest to support isolated testing.
2026-04-08 13:46:27 +02:00
6c54473d5a Refactor MediatorExtensions for flexible exception handling
Generalize null/empty response handling with SendOrThrowAsync<TResponse, TException>, allowing custom exceptions via a factory delegate. SendOrNotFoundAsync now wraps this method for NotFoundException. Improves type safety, flexibility, and XML docs; avoids treating strings as collections.
2026-04-08 13:44:19 +02:00
9ad4352e02 Add MediatorExtensions for not-found handling in MediatR
Introduced MediatorExtensions with SendOrNotFoundAsync methods to enforce non-null and non-empty responses from MediatR requests. These extensions throw NotFoundException when responses are null or empty, centralizing not-found logic and improving error handling.
2026-04-08 13:25:34 +02:00
90031db6a5 Add query/handler for retrieving a single envelope
Introduced ReadSingleEnvelopeQuery and its handler to enable
retrieval of a single envelope with optional user filtering.
Supports filtering by user ID, envelope ID, or UUID, includes
related documents, and maps results to EnvelopeDto using
AutoMapper for secure and flexible access.
2026-04-08 10:49:23 +02:00
bc07af9622 Refactor jobs to use EnvelopeDto/ReceiverDto instead of entities
Refactored ActionService and FinalizeDocumentJob to use EnvelopeDto and ReceiverDto in place of domain entities. Updated method signatures, internal logic, and envelope receiver handling to operate on DTOs. Improved logging, removed obsolete code, and added necessary using statements for DTO namespaces. Also updated document retrieval logic and removed null-conditional operator from actionService calls.
2026-04-01 16:18:17 +02:00
4caf8cd192 Refactor to use EnvelopeDto in report generation
Updated ReportCreator and ReportItem to accept EnvelopeDto
instead of Envelope, promoting better separation of concerns
and improved data handling via DTOs.
2026-04-01 15:32:09 +02:00
5423d5317b Update DI and add EF Core SqlServer for all frameworks
- Bump Microsoft.Extensions.DependencyInjection to 9.0.6 for .NET 9.0
- Add Microsoft.EntityFrameworkCore.SqlServer for .NET 7.0, 8.0, and 9.0
- Improve ItemGroup formatting for clarity and consistency
2026-04-01 15:24:42 +02:00
6c8c8f22a3 Add EnvelopeReceivers to EnvelopeDto
Added EnvelopeReceivers property to EnvelopeDto to support a collection of envelope receiver DTOs. Also included the required using directive for EnvelopeReceiverDto.
2026-04-01 15:22:56 +02:00
5100504f16 Add MinMinutesSinceLastChange filter to envelope query
Introduced an optional MinMinutesSinceLastChange filter to ReadEnvelopeQuery and updated the handler to return only envelopes whose last change was at least the specified number of minutes ago. This enables time-based filtering of envelope results.
2026-04-01 15:06:13 +02:00
15f8baf54c Add WorkerController API to control background Worker service
Introduced a new WorkerController with endpoints to start, stop, and restart the background Worker service via HTTP API. The controller uses dependency injection to locate the Worker instance and logs each operation. Also removed an unused Controllers folder reference from the project file.
2026-04-01 11:52:07 +02:00
4e847fa737 Remove MSSQLServer service registration from DI
The MSSQLServer service is no longer registered in the dependency injection container within DependencyInjection.cs. This change means MSSQLServer will not be available for injection throughout the application. The comment regarding service lifetimes remains for future review.
2026-04-01 11:27:13 +02:00
53ff48dc3c Remove obsolete Debug property from WorkerOptions
The Debug property, previously marked as obsolete in WorkerOptions, has been removed. Debugging should now be managed through ILogger-based logging instead of this flag.
2026-04-01 11:23:29 +02:00