Commit Graph

87 Commits

Author SHA1 Message Date
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
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
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
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
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
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
ab67b3fba2 Remove obsolete ReportModel and DI registration
Removed the deprecated ReportModel class and its List method, along with its registration in the dependency injection setup. This cleanup reflects the migration to EnvelopeReport mediator queries.
2026-04-01 11:18:45 +02:00
3855a8fa1e Refactor ReportItem creation and encapsulate mapping
Moved mapping logic from ReportCreator.ToReportItem to a new constructor in ReportItem, improving encapsulation and simplifying report generation. Updated usings to remove unused and add necessary dependencies.
2026-04-01 11:15:33 +02:00
052da02bd0 Refactor ReportCreator: remove logging and simplify logic
Removed ILogger dependency and all related logging from ReportCreator. Inlined DoCreateReport into CreateReportAsync and eliminated the try-catch block, allowing exceptions to propagate naturally. Improved the error message for missing report data. The class is now more focused and streamlined.
2026-04-01 11:15:17 +02:00
53a9a3e3eb Refactor report generation to use async repository access
Replaces obsolete DataTable-based logic in ReportCreator with async repository queries for EnvelopeReport entities. Refactors ReportItem to use explicit header and detail fields, removing legacy Envelope references. Updates report designer bindings to match new ReportItem properties. Improves exception handling and overall type safety.
2026-04-01 10:42:44 +02:00
c2ab18e184 Replace hand-coded envelope report with DevExpress XtraReport
Switch to a designer-generated DevExpress XtraReport for envelope history, replacing the previous manual layout. Added designer (.Designer.cs), resource (.resx), and updated code-behind (.cs) files. Updated the project file to include new report assets. Changed report generation to use the new async API. This modernizes the report, improves maintainability, and enhances appearance.
2026-03-30 16:53:39 +02:00
8f845e8a9a Refactor database namespace for improved modularity
Replaced DigitalData.Modules.Database with EnvelopeGenerator.ServiceHost.Jobs.Infrastructure in using statements and class namespaces. All database operations are now organized under the new namespace for better clarity and project structure.
2026-03-16 16:43:49 +01:00
7af934ea19 Integrate DevExpress Reporting for envelope history
Added DevExpress.Reporting.Core package reference. Refactored rptEnvelopeHistory to inherit from XtraReport and build its layout programmatically using DevExpress bands, tables, and styling. The report now uses A4 paper size, custom margins, and DevExpress UI components for rendering.
2026-03-09 21:27:06 +01:00
b65367fb6d Refactor FinalizeDocumentJob dependencies and method call
Removed unused constructor parameters from FinalizeDocumentJob for cleaner dependency injection. Updated actionService.FinalizeEnvelope to accept a cancellation token. Added missing using directive for Microsoft.Extensions.Options.
2026-03-09 21:26:52 +01:00
25c31108cb Add EnvelopeReport repository dependency to ReportCreator
Updated ReportCreator constructor to require an IRepository<EnvelopeReport> parameter, enabling direct access to envelope report data within the class. This change prepares the class for future data operations involving envelope reports.
2026-03-09 21:26:19 +01:00
070d9be00c Remove obsolete State class and DI registration
Removed the deprecated State class and its properties from the codebase. Also removed State from the dependency injection configuration, as it is no longer used.
2026-03-09 16:52:52 +01:00
6f7b04a26e Refactor: remove strict checks and logging in finalization
Removed exception throwing and logging for failed report creation, email sending, and envelope finalization in FinalizeDocumentJob. Now, these methods are called without checking their return values. Also improved exception message for file export to include envelope Id and added null-forgiving operator to _config.ExportPath.
2026-03-09 16:31:31 +01:00
8f3aa69cbf Refactor document save to use async repository update
Replaced manual SQL and file read with async repository update for saving final document bytes. Removed obsolete helper methods and cleaned up unused imports for improved maintainability and testability.
2026-03-09 16:18:20 +01:00
eededeb1f1 Remove SendFinalEmailWithAttachment and related logic
Removed the SendFinalEmailWithAttachment method and all references to it from SendFinalEmailToCreator and SendFinalEmailToReceivers. The logic for determining email attachments based on FinalEmailType is no longer used. Other functionality in these methods remains unchanged.
2026-03-09 15:41:56 +01:00
737774f077 Remove PDF annotation and envelope data methods
Removed BurnAnnotationsToPdf, GetEnvelopeData, and GetAnnotationData from FinalizeDocumentJob. These methods handled document reading, annotation retrieval, and PDF annotation burning. This change reflects a refactor or shift in document processing responsibilities.
2026-03-09 15:34:58 +01:00
69499273cc Refactor FinalizeDocumentJob to async and use docStatusRepo
Refactored FinalizeDocumentJob to make the Finalize method asynchronous and fetch document annotations from docStatusRepo instead of using GetEnvelopeData. Updated constructor to inject IRepository<Domain.Entities.DocumentStatus>. Improved logging and removed obsolete envelopeData checks.
2026-03-09 15:32:32 +01:00
d1e2840617 Clean up debug logging in FinalizeDocumentJob
Removed numerous debug-level log statements to reduce log verbosity and focus on warnings and information logs. Updated some log messages to use interpolated strings for clarity. Refactored GetAnnotationData to use C# collection expressions for improved code conciseness.
2026-03-09 11:35:49 +01:00
a39ef6a0e2 Improve error handling in FinalizeDocumentJob
Added RethrowOnError property to control exception rethrowing during envelope finalization. Exceptions are now logged as errors and, if RethrowOnError is true, rethrown to enable stricter error handling and halt execution on failure.
2026-03-09 11:30:43 +01:00
7d620988d8 Refactor envelope finalization into a private method
Extracted envelope finalization logic from the foreach loop into a new private Finalize(Envelope envelope) method. This improves code readability and maintainability by encapsulating all steps of the finalization process without changing functionality.
2026-03-09 11:25:36 +01:00
cc4a7d8c20 Refactor ActionService: DI, CancellationToken support
Refactored ActionService to use constructor injection for IRepository<History>. Updated all public methods to accept optional CancellationToken parameters for improved cancellation support. Added necessary using directives. Class remains a placeholder with [Obsolete] attributes and NotImplementedException.
2026-03-09 10:18:53 +01:00
0b8068f926 Add summary comment to ActionService for migration context
Added an XML summary comment to the ActionService class to indicate it is being migrated from EnvelopeGenerator.CommonServices.Services.ActionService. This provides clarity on the class's origin and intended purpose; no functional changes were made.
2026-03-09 10:12:32 +01:00
9fd7a68798 Refactor envelope processing for per-item error handling
Move per-envelope logic in FinalizeDocumentJob into its own try-catch block within the foreach loop. This ensures that exceptions in processing one envelope do not halt the processing of others, improving robustness and fault tolerance. Removed the outer try-catch-finally block and updated logging to reflect per-envelope and overall job status.
2026-03-09 09:42:55 +01:00
d6e2690bb8 Refactor envelope fetch to use EF LINQ instead of SQL
Replaced raw SQL and DataTable usage with Entity Framework LINQ queries for retrieving completed envelopes. The process now works directly with envelope entities, improving code readability, maintainability, and leveraging EF's querying capabilities. Logging and error handling have been updated to use envelope properties directly.
2026-03-09 09:38:08 +01:00
f04385a03c Remove EnvelopeModel class and its GetById method
Deleted the EnvelopeModel class, which included the GetById method for retrieving Envelope entities from the database. Also removed related using directives and namespace declarations. This cleanup eliminates unused or redundant code.
2026-03-06 14:53:14 +01:00
c88e7b2b9e Refactor FinalizeDocumentJob to use async repository access
Replaced EnvelopeModel with IRepository<Envelope> in FinalizeDocumentJob, switching to dependency-injected, repository-based, and asynchronous data access using Entity Framework. Updated envelope retrieval to use SingleOrDefaultAsync, improving maintainability and scalability. Added necessary using directives to support these changes.
2026-03-06 14:53:00 +01:00
0ee7ec82d6 Mark TempFiles class and members as obsolete
The TempFiles class, including its TempPath property, constructor,
and methods (Create, CleanUpFiles, CleanUp), is now marked with
the [Obsolete("Use memory cache instead of temp files.")] attribute.
This deprecates the use of temp files in favor of a memory cache
approach for future development.
2026-03-06 14:48:19 +01:00
a4082fca45 Remove ConfigModel and DbConfig classes
Deleted ConfigModel.cs and DbConfig.cs, removing both the configuration loading logic and the DbConfig data structure from the codebase. This eliminates database-driven configuration management functionality.
2026-03-06 13:58:29 +01:00
f3ae8a9c49 Refactor config loading to async MediatR query in job
Switched FinalizeDocumentJob to use MediatR for async config retrieval, replacing direct model access. Updated _config type to ConfigDto?, injected IMediator, and removed obsolete DbConfig references. Cleaned up ExecuteAsync method for improved clarity and decoupling.
2026-03-06 13:58:16 +01:00