Commit Graph

363 Commits

Author SHA1 Message Date
7a11ac3635 Add PlaceholderResolutionException for unresolved placeholders
Introduced PlaceholderResolutionException in the ReC.Application.Common.Exceptions namespace. This exception provides detailed context when a placeholder cannot be resolved due to a missing property with a specific column name, including the placeholder, column name, and input string.
2026-03-26 14:36:35 +01:00
a91e3264b4 Remove Action folder reference from project file
The <Folder Include="Common\Behaviors\Action\" /> entry was removed from ReC.Application.csproj, so the folder is no longer explicitly included in the project structure. No code or project references were affected.
2026-03-26 14:35:39 +01:00
2ae5251550 Rename class and update namespace for placeholder logic
Renamed the ReflectionExtensions class to PlaceholderExtensions and moved it from the ReC.Domain.Extensions namespace to ReC.Application.Common.Behaviors.InvokeAction to better reflect its purpose and location within the project structure.
2026-03-26 13:48:16 +01:00
d8aa032a57 Add ReflectionExtensions for property lookup by column name
Introduced a static ReflectionExtensions class with a GetValueByColumnName extension method to retrieve property values by their [Column] attribute name. Also removed an unused folder reference from the project file.
2026-03-26 13:16:04 +01:00
e96773f3c4 Remove DbModelConfigurationException and related logic
Removed the DbModelConfigurationException class and all its usages from DbModelOptions and EntityOptions. Indexers in these classes no longer throw this exception when configuration is missing. Updated the project file to include the Common\Options\DbModel\ folder.
2026-03-26 10:34:24 +01:00
b922cbbb30 Remove ConfigureDbModel from dependency injection setup
Eliminated all references to ConfigureDbModel in DependencyInjection.cs, including related imports, configuration methods, and required service tracking. Dependency injection configuration is otherwise unchanged.
2026-03-26 10:32:24 +01:00
b0d89ceba4 Remove properties from RecActionOptions class
Removed AddedWho and UseHttp1ForNtlm properties from RecActionOptions, leaving the class empty. This change cleans up unused configuration options.
2026-03-25 16:13:32 +01:00
11ebfdd21e Refactor DbModelOptions to use indexers for lookups
Replaced GetEntity and GetColumn extension methods with indexers
on DbModelOptions and EntityOptions. Updated all usages to use
the new indexer syntax, improving code clarity and error handling
for missing entity or column configurations.
2026-03-25 16:10:50 +01:00
1467acc4a1 Refactor DbModel options to use generic entity mapping
Replaces strongly-typed view options classes with a generic EntityOptions class and a dictionary-based configuration for entity-to-view and property-to-column mappings. Updates appsettings.DbModel.json to match the new structure. Refactors RecDbContext to use extension methods for mapping configuration. Removes obsolete options classes and simplifies exception handling for missing mappings. This change improves flexibility and maintainability of database view configuration.
2026-03-25 15:25:29 +01:00
37ba85d681 Add support for configuring DbModelOptions via DI
Introduce ConfigureDbModel methods to DependencyInjection for setting up DbModelOptions from code or configuration. Update required services tracking and add usage in Program.cs to enable structured DbModelOptions injection.
2026-03-25 13:26:54 +01:00
a46cd08122 Refactor DbModel options to use explicit, typed classes
Replaced the old generic, dictionary-based entity configuration system with a new, strongly-typed options structure under ReC.Application.Common.Options.DbModel. Introduced specific options classes for each major database view and result type, each with clear property mappings and defaults. Added a ViewOptions class for view/schema info. Removed all legacy entity mapping infrastructure, resulting in a more maintainable and type-safe configuration approach.
2026-03-25 12:53:10 +01:00
90e8adbd36 Update behavior namespaces to InvokeAction for clarity
Renamed namespaces in PreprocessingBehavior and PostprocessingBehavior from .Action to .InvokeAction, and updated related using directives in DependencyInjection.cs. Added a folder entry for Common\Behaviors\Action\ in the project file for organization.
2026-03-25 11:43:30 +01:00
aef59def7f Add ResultType to InsertResultCommand in all handlers
Added the Type property (ResultType) to every InsertResultCommand sent in PostprocessingBehavior, PreprocessingBehavior, and InvokeRecActionViewCommand. This ensures each result now includes its context (Post, Pre, or Main), both in normal and exception flows.
2026-03-25 11:17:38 +01:00
d7783b6e81 Make InsertObjectProcedure properties nullable, require ResultType
Updated InsertObjectProcedure to make related command properties nullable and removed default initializations. Updated handler to use null-conditional access for these properties. Changed InsertResultCommand.Type to required and updated tests accordingly. Improves null safety and clarifies required fields.
2026-03-25 11:17:21 +01:00
4126f984e4 Expand and refactor OutResDto for richer data support
Refactored OutResDto to include additional properties such as Action, Profile, Status, and Type, and made several fields nullable. This enhances flexibility and allows for more comprehensive and optional data representation in API responses.
2026-03-25 11:06:07 +01:00
0e2328c287 Add support for Result.Info, Error, and Type in insert proc
Extended InsertObjectProcedureHandler to include Result.Info, Result.Error, and Result.Type in both the SQL parameter list and the command string. This ensures these fields are correctly passed to and handled by the stored procedure.
2026-03-25 11:02:56 +01:00
e04e054151 Add optional ResultType to InsertResultCommand
Added a nullable Type property of ResultType to InsertResultCommand for enhanced result categorization. Also included the required using directive for ReC.Domain.Constants.
2026-03-25 11:02:35 +01:00
08c0d29d84 Improve error handling and logging in batch rec actions
Add ILogger support to InvokeRecActionViewsCommandHandler for enhanced error and warning logging. Log and continue on handled exceptions when appropriate, and rethrow for critical errors. Clean up and reorder using directives. This increases robustness and traceability during batch rec action processing.
2026-03-25 10:25:52 +01:00
405b5f3ab1 Add ActionId and ProfileId properties to RecActionException
Expose ActionId and ProfileId as public properties in the
RecActionException class, allowing external access to these
values from exception instances. Refactored the constructor
to use a block body.
2026-03-25 10:17:24 +01:00
32af65d30c Remove InvokeBatchRecActionViewsCommand extension method
Deleted the InvokeBatchRecActionViewsCommandExtensions class and its InvokeBatchRecActionView extension method for ISender. The command record and handler remain unchanged.
2026-03-25 10:07:15 +01:00
30ccf05c57 Use RecActionException for contextual error handling
Replaced generic exception with RecActionException in PostprocessingBehavior when ErrorAction is Stop, providing ActionId and ProfileId for better error context. Added necessary using statements for the new exception and related namespaces.
2026-03-25 09:58:02 +01:00
a14d5ff112 Improve error handling with RecActionException
Wrap exceptions in PreprocessingBehavior with RecActionException, including ActionId and ProfileId for better context and debugging. This enhances error reporting when ErrorAction is set to Stop.
2026-03-25 09:57:46 +01:00
fec125b0d5 Improve exception context in action error handling
Updated InvokeRecActionViewCommandHandler to throw a RecActionException with action Id and ProfileId when an error occurs and ErrorAction is set to Stop. This change enhances error traceability by providing more contextual information in exceptions.
2026-03-25 09:56:58 +01:00
82ae4c5957 Add RecActionException custom exception class
Introduced RecActionException in ReC.Application.Common.Exceptions to encapsulate errors related to rec actions, including actionId, optional profileId, and inner exception details in the error message.
2026-03-25 09:55:52 +01:00
894b7bb070 Improve error handling and resource cleanup in action handler
Refactored InvokeRecActionViewCommandHandler to enhance error handling by logging exceptions and conditionally rethrowing based on ErrorAction. Simplified NTLM HttpClient/handler management for proper disposal. Improved code structure and formatting for clarity.
2026-03-24 17:02:06 +01:00
a707cce6e4 Refactor error handling in Pre/Postprocessing behaviors
Refactored PreprocessingBehavior and PostprocessingBehavior to send InsertResultCommand with only relevant info or error fields. Now throws exceptions when ErrorAction is Stop, allowing upstream error handling and preventing unnecessary or misleading result data. Improves consistency and clarity in error processing.
2026-03-24 16:19:00 +01:00
2ca85a2372 Refactor action behaviors to use Unit instead of bool
Refactored PreprocessingBehavior and PostprocessingBehavior for InvokeRecActionViewCommand to use MediatR's Unit as the response type instead of bool. Updated method signatures, return values, and DI registration accordingly to align with MediatR conventions for commands without return values.
2026-03-24 16:01:24 +01:00
dbe09cd07b Refactor error handling in RecActionView invocation
Switch to exception-based error handling for invoking RecActionView actions, removing boolean return values and related checks. Update command and handler signatures to use void return type. Clean up unused using directives. This improves clarity and robustness of error management during batch processing.
2026-03-24 16:00:47 +01:00
690dcea7a8 Add PostprocessingBehavior to MediatR pipeline
Registered PostprocessingBehavior for InvokeRecActionViewCommand (with bool result) in the MediatR pipeline via DependencyInjection. This ensures both preprocessing and postprocessing behaviors are executed for this command.
2026-03-24 14:41:41 +01:00
fdae4d26be Add PostprocessingBehavior for action result logging
Introduced PostprocessingBehavior as an IPipelineBehavior for InvokeRecActionViewCommand. This behavior handles post-processing by executing optional queries, serializing results, and logging outcomes via InsertResultCommand. It also manages error handling based on the action's ErrorAction setting, ensuring consistent result tracking after command execution.
2026-03-24 14:40:52 +01:00
2883cf9be4 Add PreprocessingBehavior for InvokeRecActionViewCommand
Register PreprocessingBehavior in the MediatR pipeline specifically for InvokeRecActionViewCommand. Update using directives to reflect the shift from Procedures to Commands and from Common.Behaviors to Common.Behaviors.Action.
2026-03-24 14:15:01 +01:00
9410c5dc0d Refactor PreprocessingBehavior to log results and errors
Refactored PreprocessingBehavior to serialize and log the results and errors of preprocessing SQL queries using InsertResultCommand. Now records both successful and failed executions, while preserving the stop-on-error behavior. Cleaned up and updated using directives.
2026-03-24 14:01:45 +01:00
35e99d9f2a Change ExecuteDynamicSqlAsync to return object list
The ExecuteDynamicSqlAsync method now returns an IEnumerable of
dictionaries representing query result rows, instead of a JSON
string. This allows consumers to work directly with the data
in its native .NET object form.
2026-03-24 13:26:10 +01:00
5fd65e52a3 Pass CancellationToken to ExecuteDynamicSqlAsync
Updated PreprocessingBehavior to include the CancellationToken when calling ExecuteDynamicSqlAsync, enabling query execution to be cancelled if the operation is aborted.
2026-03-24 13:21:40 +01:00
2508a8b986 Add CancellationToken to ExecuteDynamicSqlAsync method
The ExecuteDynamicSqlAsync extension for IRecDbContext now accepts an optional CancellationToken, which is passed to all async database operations to support cancellation. Also added a TODO to move this method to Common.Infrastructure in the future.
2026-03-24 13:21:05 +01:00
e691faf620 Rename Result*Procedure to Result*Command for consistency
Refactor all Result-related procedure records, handlers, and usages to use the *Command suffix instead of *Procedure. Update controller actions, handler interfaces, tests, and InsertObjectProcedure accordingly. No functional changes; improves naming consistency across the codebase.
2026-03-24 11:40:28 +01:00
cac33c46df Rename *ActionProcedure classes to *ActionCommand
Renamed InsertActionProcedure, UpdateActionProcedure, and DeleteActionProcedure to their respective *ActionCommand counterparts to align with CQRS conventions. Updated all controller actions, handlers, tests, and related usages accordingly. No changes to business logic or method signatures.
2026-03-24 11:39:55 +01:00
de503cac5b Rename Profile*Procedure types to Profile*Command for clarity
Renamed InsertProfileProcedure, UpdateProfileProcedure, and DeleteProfileProcedure (and their handlers) to use the "Command" suffix for consistency. Updated all usages in controllers, handlers, and tests. No logic changes; only type names were updated for improved clarity.
2026-03-24 11:39:04 +01:00
4999beda3b Refactor endpoint Procedures to Commands for CQRS alignment
Renamed Insert/Update/DeleteEndpointProcedure classes to their
respective Command counterparts to follow CQRS conventions.
Updated controller actions, handlers, InsertObjectProcedure,
and related unit tests to use the new Command types.
No functional changes were made; this is a naming refactor.
2026-03-24 11:38:22 +01:00
5df36d94e0 Rename EndpointParams procedures to commands for CQRS clarity
Renamed Insert/Update/DeleteEndpointParamsProcedure classes and
handlers to use the "Command" suffix (e.g., InsertEndpointParamsCommand)
for consistency with CQRS conventions. Updated all controller actions,
handlers, and tests to use the new command names. This improves
clarity and aligns naming with standard command patterns.
2026-03-24 11:37:30 +01:00
d3d24a0fb6 Refactor: Rename UpdateEndpointAuthProcedure to Command
Renamed UpdateEndpointAuthProcedure to UpdateEndpointAuthCommand across the codebase for improved naming consistency. Updated controller, handler, and tests to use the new command name, aligning with CQRS conventions for state-modifying operations.
2026-03-24 11:36:49 +01:00
a6b0cbaf9d Rename InsertEndpointAuthProcedure to InsertEndpointAuthCommand
Refactored all usages of InsertEndpointAuthProcedure to InsertEndpointAuthCommand, including method signatures, handler interfaces, and test cases, to better align with CQRS naming conventions for write operations.
2026-03-24 11:35:58 +01:00
0162d059da Refactor: Rename DeleteEndpointAuthProcedure to Command
Renamed DeleteEndpointAuthProcedure to DeleteEndpointAuthCommand across the codebase, including controller, handler, and tests, to improve naming consistency and align with CQRS conventions for write operations.
2026-03-24 11:31:33 +01:00
3e10176d98 Add PreprocessingBehavior for action command pipeline
Introduced PreprocessingBehavior implementing MediatR's IPipelineBehavior for InvokeRecActionViewCommand. This behavior executes a preprocessing SQL query if specified, and halts processing if an error occurs and ErrorAction is set to Stop. Added necessary using directives for dependencies.
2026-03-24 11:14:11 +01:00
4f0f99e0f8 Refactor InsertResultProcedure execution method
Replaced sender.ExecuteInsertProcedure with sender.Send for executing InsertResultProcedure. Removed the _options.AddedWho parameter, passing only the procedure object and cancellation token. The construction of InsertResultProcedure remains unchanged.
2026-03-24 11:11:36 +01:00
8fb4b4005c Refactor UpdateObjectProcedure to use DTO properties
Replaced *Procedure properties in UpdateObjectProcedure with corresponding DTO types (e.g., UpdateActionDto, UpdateEndpointDto, etc.) and added the necessary DTO namespace import. This decouples the record from procedure logic, improving separation of concerns and data transfer handling.
2026-03-24 11:11:12 +01:00
b3bb7144ef Refactor IUpdateProcedure to generic with Id and Data props
Changed IUpdateProcedure to a generic interface IUpdateProcedure<T>, adding Id (long) and Data (T) properties for improved type safety and flexibility in update procedures. The interface continues to inherit from IRequest<int>.
2026-03-24 11:10:47 +01:00
eff6350d77 Refactor update procedures to use DTO-based pattern
Refactored Update*Procedure records to encapsulate update data in dedicated DTOs (e.g., UpdateActionDto, UpdateEndpointDto) via a generic Data property. Updated interfaces to be generic and modified handlers to pass only the DTO to UpdateObjectProcedure. This improves maintainability, reduces duplication, and standardizes update logic across entities.
2026-03-24 11:09:46 +01:00
114b5de71d Add Update DTOs for partial entity updates in Procedures
Introduced six new DTO record classes under ReC.Application.Common.Procedures.UpdateProcedure.Dto to support partial (nullable) updates for Action, Endpoint, EndpointAuth, EndpointParams, Profile, and Result entities. These DTOs enable PATCH-like update operations by allowing selective property updates. No existing code was modified.
2026-03-24 11:08:37 +01:00
a590ffd2dc Refactor InsertProfileProcedure to use MediatR handler
Refactored InsertProfileProcedure by removing the ToObjectProcedure method and introducing InsertProfileProcedureHandler, which implements IRequestHandler and delegates insert logic via MediatR's ISender. Updated using directives to include MediatR. This aligns profile insertion with the MediatR request/response pattern.
2026-03-24 10:14:58 +01:00