111 Commits

Author SHA1 Message Date
86e599a102 Add SqlConnection navigation property to RecAction
Introduced a new `SqlConnection` property in the `RecAction` class, marked with the `[ForeignKey("SqlConnectionId")]` attribute. This establishes a foreign key relationship with the `SqlConnectionId` property, enabling ORM navigation between `RecAction` and the `Connection` entity.
2025-12-01 14:08:27 +01:00
420762a463 Add EndpointAuth navigation property to RecAction
The RecAction class in RecAction.cs now includes a new
navigation property, EndpointAuth, which is linked to the
EndpointAuthId column via the [ForeignKey] attribute. This
enhances the entity relationship by associating the
EndpointAuthId property with the EndpointAuth entity.
2025-12-01 14:07:43 +01:00
5584a82d8f Add foreign key relationship to RecAction class
Enhanced the `RecAction` class by adding a navigation property
(`Endpoint`) to represent the relationship with the `Endpoint`
entity. Annotated the `Endpoint` property with the
`[ForeignKey("EndpointId")]` attribute to establish the foreign
key mapping. This improves the data model by explicitly defining
the relationship between `RecAction` and `Endpoint`.
2025-12-01 14:06:52 +01:00
6eac642784 Add navigation property for Profile in RecAction
Introduced a `Profile` navigation property to the `RecAction` class, annotated with `[ForeignKey("ProfileId")]`. This establishes a foreign key relationship between the `ProfileId` property and the `Profile` entity, enabling ORM navigation between `RecAction` and `Profile`.
2025-12-01 14:06:24 +01:00
ffc96efd98 Rename ProfileName property to Name in Profile class
The `ProfileName` property in the `Profile` class was renamed to `Name` to improve clarity or consistency. The `[Column("PROFILE_NAME")]` attribute remains unchanged, ensuring the database column mapping is unaffected.
2025-12-01 14:05:03 +01:00
1960151f77 Add Profile entity class for database mapping
Introduced a new `Profile` class in the `ReC.Domain.Entities` namespace to represent the `TBREC_CFG_PROFILE` table in the `dbo` schema.

- Added Entity Framework annotations to map properties to database columns.
- Defined properties for fields such as `Id`, `Active`, `Type`, `ProfileName`, `Description`, and others.
- Used nullable types for all properties to allow null values.
- Marked `Id` as the primary key with auto-generation enabled.

This change enables ORM support for managing profile-related data.
2025-12-01 14:04:34 +01:00
a2af50e436 Add Connection entity mapped to TBDD_CONNECTION table
Introduce a new `Connection` class in the `ReC.Domain.Entities` namespace.
The class is mapped to the `TBDD_CONNECTION` database table and includes
properties for various columns such as `Id`, `Bezeichnung`, `SqlProvider`,
and others. Attributes like `[Key]`, `[Column]`, and `[DatabaseGenerated]`
are used for database mapping. Nullable types are used for all properties.
Added necessary `using` directives for annotations and schema mapping.
2025-12-01 14:00:20 +01:00
7ebe48204a Add EndpointAuth entity for database table mapping
Introduced the `EndpointAuth` class in the `ReC.Domain.Entities` namespace to represent the `TBREC_CFG_ENDPOINT_AUTH` database table.

- Added Entity Framework annotations for table and column mappings.
- Defined properties for all table columns, including `Id`, `Active`, `Description`, `Type`, `ApiKey`, `ApiValue`, `ApiKeyAddTo`, `Token`, `Username`, `Password`, `Domain`, `Workstation`, `AddedWho`, `AddedWhen`, `ChangedWho`, and `ChangedWhen`.
- Configured `Id` as the primary key with auto-generated values.
2025-12-01 13:56:43 +01:00
6ec6cd4621 Rename Guid to Id in RecAction class
Renamed the property `Guid` to `Id` in the `RecAction` class
to improve clarity and align with naming conventions or
database schema updates. No other changes were made to
the file.
2025-12-01 13:52:48 +01:00
e6cb835829 Add Endpoint entity class for database mapping
Introduced a new `Endpoint` class in the `ReC.Domain.Entities` namespace to represent the `TBREC_CFG_ENDPOINT` database table.

- Added Entity Framework annotations to map properties to database columns.
- Defined properties for `Id`, `Active`, `Description`, `Uri`, `AddedWho`, `AddedWhen`, `ChangedWho`, and `ChangedWhen`.
- Configured `Id` as the primary key with auto-generated values.
2025-12-01 13:52:20 +01:00
6fd438809f Add RecAction entity mapped to TBREC_CFG_ACTION table
Introduced the `RecAction` class in the `ReC.Domain.Entities`
namespace to represent the `TBREC_CFG_ACTION` database table.
Added data annotations for table and column mapping, including
a primary key (`Guid`) and other properties for database fields
such as `ProfileId`, `Active`, `Sequence`, and query-related
fields. Included auditing fields (`AddedWho`, `AddedWhen`,
`ChangedWho`, `ChangedWhen`) for tracking changes. All fields
are nullable to handle missing data gracefully.
2025-12-01 13:37:47 +01:00
4b9f375646 Refactor to use RecActionView instead of RecAction
Replaced `RecAction` with `RecActionView` across the codebase to align with the `VWREC_ACTION` database view. Updated mappings, interfaces, and repository registrations accordingly.

- Updated `DtoMappingProfile` to map `RecActionView` to `RecActionDto`.
- Modified `IRecDbContext` to use `DbSet<RecActionView>`.
- Refactored `ReadRecActionQueryHandler` to use `IRepository<RecActionView>`.
- Removed the `RecAction` class entirely.
- Updated `DependencyInjection` to register `RecActionView`.
- Adjusted `RecDbContext` to replace `RecAction` with `RecActionView` and configure it as a keyless entity.
- Introduced the `RecActionView` class, mirroring the structure of the removed `RecAction` class, with nullable properties for schema flexibility.
2025-12-01 13:32:57 +01:00
8ef48942a3 Remove unused using directives in two files
Cleaned up unused namespaces to improve code maintainability:
- Removed `System.Text.Json` from `CreateOutResCommand.cs`.
- Removed `Microsoft.Extensions.Logging` from `InvokeRecActionCommand.cs`.

This reduces unnecessary dependencies and improves readability.
2025-12-01 13:28:08 +01:00
1b9d6e7d8a Remove logger parameter from InvokeRecActionCommandHandler
The constructor of the `InvokeRecActionCommandHandler` class was updated to remove the optional `ILogger<InvokeRecActionsCommandHandler>? logger` parameter. This change simplifies the constructor by no longer requiring or accepting a logger instance.
2025-12-01 13:02:58 +01:00
a7cb237fb6 Refactor CreateOutResCommand properties
Removed unused System.Text.Json dependency and the `EmptyJson` field. Updated `ActionId` to be required during initialization. Changed `Header` and `Body` properties to nullable strings without default values.
2025-12-01 13:01:58 +01:00
e62dfbcc7a Improve error handling with DataIntegrityException
Introduce a new `DataIntegrityException` class to handle data
integrity issues. Replace the logging and early return for
`null` `RestType` in `InvokeRecActionCommandHandler` with
throwing the new exception. This ensures explicit error
handling and improves runtime issue detection.
2025-12-01 12:51:54 +01:00
a2ebbe83cb Make Action property non-nullable in InvokeRecActionCommand
Updated the `Action` property in the `InvokeRecActionCommand` class
to be non-nullable by initializing it with a default value (`= null!;`).
This change ensures better null safety and prevents potential null
reference issues. The `= null!;` syntax suppresses compiler warnings
while guaranteeing the property will be properly initialized before use.
2025-12-01 12:45:58 +01:00
de17d398ff Rename ActionId to Id across the codebase
Updated the `ActionId` property to `Id` in `RecActionDto`
and `RecAction` classes for consistency. Reflected this
change in all relevant files, including log messages,
property assignments, and database column mappings.
Standardized naming conventions to improve code clarity
and maintainability.
2025-12-01 12:30:57 +01:00
dc777a04f6 Refactor InvokeRecActionCommand to use composition
Refactored `InvokeRecActionCommand` to remove inheritance from
`RecActionDto` and introduced a new `Action` property to
encapsulate the data. Updated the `ToInvokeCommand` extension
method to align with this change.

Modified `InvokeRecActionCommandHandler` to reference the
`Action` property instead of directly accessing inherited
properties. Updated HTTP request creation logic and the
`CreateOutResCommand` instantiation to use the `Action` object.

This change improves code clarity and adheres to composition
over inheritance principles.
2025-12-01 12:30:24 +01:00
9c028c5e66 Make ActionId a required field across DTOs and entities
Updated the `RecActionDto`, `RecAction`, and `InvokeRecActionCommandHandler` to enforce `ActionId` as a required field. This change improves data integrity by removing nullable `ActionId` properties and eliminates the need for null checks or null-forgiveness operators.
2025-12-01 12:27:47 +01:00
211d369509 Add CreateOutResCommand handling to RecActionCommand
Enhanced InvokeRecActionCommandHandler to send a
CreateOutResCommand after processing HTTP responses.
Added dependencies for configuration and command handling.
Updated the constructor to include ISender and optional
IConfiguration for improved extensibility.
2025-12-01 11:39:41 +01:00
3301b35067 Add MediatR support and CreateOutResCommand handler
Integrated MediatR for command handling by modifying the
CreateOutResCommand class to implement the IRequest interface.
Added a static EmptyJson property for default JSON serialization
and updated Header and Body properties to use it. Introduced
CreateOutResCommandHandler to handle command creation using
IRepository asynchronously.
2025-12-01 11:28:57 +01:00
41d00036e4 Add AutoMapper profile for CreateOutResCommand mapping
Introduced a new `MappingProfiles` class in the `ReC.Application.OutResults` namespace to configure object-object mapping using the `AutoMapper` library.

Added a mapping configuration between `CreateOutResCommand` and `OutRes` using the `CreateMap` method. This simplifies data transformation between application layers.
2025-12-01 11:10:46 +01:00
bf5e2e1d25 Rename ResultHeader/ResultBody to Header/Body
Renamed the `ResultHeader` and `ResultBody` properties to `Header`
and `Body` in both `CreateOutResCommand` and `OutRes` classes
to improve naming consistency. Default values and database
column mappings remain unchanged.
2025-12-01 11:05:33 +01:00
c5709c148b Add CreateOutResCommand class for handling output results
Introduced the `CreateOutResCommand` class in the `ReC.Application.OutResults.Commands` namespace. This class includes properties for managing output results, such as `ActionId`, `ResultHeader`, `ResultBody`, and `AddedWho`. Added a static readonly `EmptyJson` property for initializing JSON fields with a serialized empty object. Included `System.Text.Json` for JSON serialization functionality.
2025-12-01 11:03:34 +01:00
d4bd8b0d1a Update appsettings.json configuration
Removed `MaxConcurrentInvocations` from the `RecAction` section.
Added a new property `AddedWho` with the value `"ReC.API"`.
2025-12-01 10:38:54 +01:00
3b4858f5b1 Refactor variable names for clarity in response handling
Renamed variables `body` to `resBody` and `headers` to `resHeaders`
to improve clarity and better reflect their association with the
response object. These changes enhance code readability and
maintainability without altering functionality.
2025-12-01 10:35:02 +01:00
2610fc8f07 Remove query execution tracking properties
Simplified the codebase by removing `BodyQueryExecuted`,
`HeaderQueryExecuted`, and related computed properties
(`IsBodyQueryReturnedNoData` and `IsHeaderQueryReturnedNoData`)
from `RecActionDto`. These properties were used to track
whether `BodyQuery` and `HeaderQuery` were executed and
whether they returned data.

Updated `BodyQueryBehavior` and `HeaderQueryBehavior` to
remove logic that set these properties. Also removed the
conditional block in `InvokeRecActionCommandHandler` that
logged warnings based on these properties.

These changes streamline the code and reflect a shift away
from tracking query execution and results at this level.
2025-12-01 10:33:08 +01:00
90e2460716 Refactor query behaviors for execution tracking
Refactored `BodyQueryBehavior` and `HeaderQueryBehavior` to introduce explicit execution tracking with new properties (`BodyQueryExecuted` and `HeaderQueryExecuted`). Updated `RecActionDto` to include computed properties (`IsBodyQueryReturnedNoData` and `IsHeaderQueryReturnedNoData`) for clearer null-checking logic. Removed the `IsReturnedNoData` tuple for simplicity.

Updated `InvokeRecActionCommandHandler` to use the new `IsBodyQueryReturnedNoData` property. Improved logging for better diagnostics and clarified handling of null results in query behaviors.
2025-12-01 10:10:41 +01:00
29f0a82f0f Enhance query handling and diagnostics
Improved robustness and error handling in `BodyQueryBehavior`
and `HeaderQueryBehavior` by adding null checks, logging,
and introducing the `IsReturnedNoData` flag to track query
results. Updated `RecActionDto` to include the new flag for
better state management. Enhanced HTTP request construction
in `InvokeRecActionCommand` to handle `Body` and `Headers`
more reliably and log potential issues with unexecuted
behaviors. These changes improve resilience, traceability,
and diagnostics across the application.
2025-12-01 09:55:06 +01:00
Developer 02
b78b3e43f4 Add support for custom headers in HTTP requests
Enhanced HTTP request handling by adding support for dynamically including custom headers from the `request.Headers` collection. Implemented a null check to ensure robustness and prevent null reference exceptions when processing headers. This change improves flexibility and customization of HTTP requests.
2025-12-01 09:45:41 +01:00
Developer 02
07afcf3aa2 Add logging for unexpected BodyQuery and IsReturnedNoData
Improve observability by adding a warning log when `request.BodyQuery` is not null but `request.IsReturnedNoData.BodyQuery` is false.

The log message highlights potential issues, such as skipped `BodyQueryBehavior` execution or missing control steps, and includes `ProfileId` and `ActionId` for better debugging context.
2025-11-29 01:12:03 +01:00
Developer 02
e0736ff6df Improve HeaderQueryBehavior error handling and logging
Updated HeaderQueryBehavior to handle null or missing
REQUEST_HEADER gracefully by logging warnings and setting
action.IsReturnedNoData.HeaderQuery to true instead of
throwing exceptions. Enhanced log messages for failed
RawHeader deserialization to improve clarity and added
pipeline continuity by calling await next(cancel).
Refactored log formatting for consistency.
2025-11-29 00:55:43 +01:00
Developer 02
0d801466cf Add properties for query tracking and post-processing
Added `IsReturnedNoData` property as a tuple to track the state
of `BodyQuery` and `HeaderQuery` data returns. Introduced
`PostprocessingQuery` property to support initialization of
post-processing queries. These changes enhance the functionality
of the `RecActionDto` class by enabling better query handling
and processing capabilities.
2025-11-29 00:36:03 +01:00
Developer 02
ff53be5d13 Throw exception for null RawHeader in HeaderQueryBehavior
Previously, the code continued execution when the RawHeader
property of the query result was null. This change introduces
an InvalidOperationException to handle this case, ensuring
that the absence of a valid RawHeader is treated as an error.
The exception message includes ProfileId and ActionId for
better debugging context.
2025-11-28 23:41:35 +01:00
Developer 02
cc787f445a Improve null-checking and error handling in Handle
Simplified null-checks in the `Handle` method of the
`BodyQueryBehavior` class using the null-conditional operator.
Enhanced the exception message to include `ProfileId` and
`ActionId` for better debugging context when `result?.RawBody`
is null.
2025-11-28 23:37:09 +01:00
Developer 02
97c57d4fb1 Add validation for BodyQuery result in Handle method
Previously, the `Handle` method in `BodyQueryBehavior<TRecAction>`
did not validate the `BodyQuery` result before setting `action.Body`.
This change introduces a check to ensure that the result and its
`RawBody` are not null. If either is null, an
`InvalidOperationException` is thrown with a clear error message.
This ensures `action.Body` is only set when a valid result is
retrieved, improving robustness and preventing potential null
reference issues.
2025-11-28 23:32:28 +01:00
Developer 02
ff3908cdd2 Support HTTP request body in InvokeRecActionCommandHandler
Added logic to handle non-null `request.Body` in HTTP requests.
Introduced a `StringContent` object to encapsulate the body
content and assigned it to the `Content` property of the
HTTP request. This ensures that the request body is included
when sending data to the specified endpoint.
2025-11-28 23:24:36 +01:00
6208f642be Use SingleOrDefaultAsync for stricter query constraints
Replaced FirstOrDefaultAsync with SingleOrDefaultAsync in
BodyQueryBehavior.cs and HeaderQueryBehavior.cs to enforce
that database queries return at most one result. This change
ensures an exception is thrown if multiple results are found,
making debugging and error handling more explicit.
2025-11-28 12:19:40 +01:00
6f5409f528 Implement HeaderQueryBehavior with database support
Updated `HeaderQueryBehavior` to include dependency injection
for `IRecDbContext` and `ILogger`, enabling database interaction
and logging. Replaced the placeholder `NotImplementedException`
in the `Handle` method with functionality to process `HeaderQuery`
SQL results, deserialize JSON headers, and assign them to the
`Headers` property of the action. Added error handling and
logging for deserialization failures. Updated constructor and
method signatures to support new dependencies and asynchronous
behavior. Added necessary `using` directives for new features.
2025-11-27 17:16:13 +01:00
03498275d7 Implement BodyQueryBehavior and add SQL Server support
Updated BodyQueryBehavior to process BodyQuery using the
IRecDbContext dependency. Added logic to execute SQL queries
via FromSqlRaw and assign results to the action's Body property.
Removed placeholder NotImplementedException.

Added Microsoft.EntityFrameworkCore.SqlServer package to
ReC.Application.csproj to enable SQL Server database operations.
2025-11-27 17:05:12 +01:00
f8581deaf9 Refactor DbContext and add IRecDbContext interface
Refactored `DependencyInjection` to use a generic `TRecDbContext`
for flexibility and added scoped registration for `IRecDbContext`.
Updated `RecDbContext` to implement the new `IRecDbContext`
interface, ensuring adherence to the application-layer contract.

Introduced the `IRecDbContext` interface in the application layer,
defining `DbSet` properties for key entities and a `SaveChangesAsync`
method. Updated `ReC.Infrastructure.csproj` to reference the
application project for interface access.
2025-11-27 16:51:49 +01:00
8ea7d47868 Add DbSets and configure keyless entity in RecDbContext
Added `HeaderQueryResults` and `BodyQueryResults` DbSet
properties to the `RecDbContext` class for interacting
with `HeaderQueryResult` and `BodyQueryResult` entities.

Overrode the `OnModelCreating` method to configure the
`RecAction` entity as keyless using
`modelBuilder.Entity<RecAction>().HasNoKey()`.
2025-11-27 16:40:33 +01:00
2bbfd96d62 Add keyless query result entities for headers and bodies
Added `HeaderQueryResult` and `BodyQueryResult` classes to represent
query results for headers and bodies, respectively. These classes
map their properties to database columns (`REQUEST_HEADER` and
`REQUEST_BODY`) using the `[Column]` attribute. Both properties
are nullable and immutable.

Updated `RecDbContext` to configure these entities as keyless
using the `HasNoKey()` method in the `OnModelCreating` method,
indicating they are used for read-only queries.
2025-11-27 16:37:30 +01:00
4f364e3eb2 Refactor behaviors to Common namespace
Moved `BodyQueryBehavior` and `HeaderQueryBehavior` from
`ReC.Application.RecActions.Behaviors` to
`ReC.Application.Common.Behaviors` to reflect their broader
applicability. Updated `DependencyInjection.cs` to use the new
namespace. This reorganization improves code structure and
maintainability.
2025-11-27 15:54:24 +01:00
0c4d145e20 Add HeaderQueryBehavior and update DI configuration
Added `HeaderQueryBehavior<TRecAction>` to handle header query
processing in the MediatR pipeline. Updated the `DependencyInjection`
class to register `HeaderQueryBehavior<>` alongside
`BodyQueryBehavior<>` in the MediatR configuration. The new behavior
currently throws a `NotImplementedException` as its logic is pending
implementation.
2025-11-27 15:47:12 +01:00
1757c0e055 Add BodyQueryBehavior and register in MediatR pipeline
Introduced the `BodyQueryBehavior<TRecAction>` class, which implements the `IPipelineBehavior` interface to handle actions of type `RecActionDto`. The behavior is currently unimplemented and throws a `NotImplementedException`.

Updated the `DependencyInjection` class to register `BodyQueryBehavior<>` as an open generic pipeline behavior in MediatR. Added necessary `using` directives in both `DependencyInjection.cs` and `BodyQueryBehavior.cs` to support the new behavior.
2025-11-27 15:46:07 +01:00
b1df50bc32 Enhance RecActionDto with HTTP and query handling
Added new properties to `RecActionDto`:
- `Headers` to store HTTP headers as a dictionary.
- `BodyQuery` to represent a query related to the body.
- `Body` to store the body content.
- `PostprocessingQuery` to represent a query for postprocessing.

These changes improve the class's ability to handle HTTP requests and related operations, providing greater flexibility for preprocessing and postprocessing tasks.
2025-11-27 15:30:54 +01:00
a66a70fab3 Refactor HTTP request handling in InvokeRecActionCommand
Replaced the `reqMsg` variable with `httpReq` to simplify the
creation and usage of `HttpRequestMessage`. The `request.RestType`
is now used directly to create `httpReq`, which is passed to
`http.SendAsync`. This change reduces redundancy and improves
code clarity.
2025-11-27 14:54:28 +01:00
a84b5531b7 Add ToHttpRequestMessage and refactor HTTP handling
Introduced a new extension method `ToHttpRequestMessage` in
`HttpExtensions` to simplify `HttpRequestMessage` creation
with URI validation. Added `System.Diagnostics.CodeAnalysis`
for `StringSyntaxAttribute` support.

Refactored `InvokeRecActionCommandHandler` to use the new
`ToHttpRequestMessage` method, improving readability and
encapsulation. Renamed `msg` to `reqMsg` for clarity.
2025-11-27 14:51:43 +01:00