Compare commits

...

51 Commits

Author SHA1 Message Date
8624742eb3 Add CreateFakeAction endpoint and update command defaults
The ActionController class was updated to include a new
CreateFakeAction endpoint. This endpoint accepts optional
parameters (endpointUri, type, and bodyQuery) and sends a
CreateRecActionCommand with hardcoded and default values.

The CreateRecActionCommand record was modified to remove
default values for ProfileId, Type, and BodyQuery. These
properties now require explicit initialization, with Type
and BodyQuery marked as non-nullable using the null! syntax.

These changes improve flexibility and add support for
creating "fake" actions via the new endpoint.
2025-12-01 16:48:05 +01:00
a27000a75b Refactor DeleteRecActionsCommandHandler.Handle method
Simplified the `Handle` method by removing the `async` modifier
and replacing the `await` call with a direct `return` statement
for `repo.DeleteAsync`. This optimization eliminates the
overhead of creating an async state machine, as no additional
asynchronous operations or logic are performed in the method.
2025-12-01 16:29:41 +01:00
e74ee56f42 Add DeleteRecActionsCommand and handler for deletion
Introduced `DeleteRecActionsCommand` and its handler to enable
deletion of `RecAction` entities based on `ProfileId`. Added
necessary `using` directives and organized the code under the
`ReC.Application.RecActions.Commands` namespace. The handler
uses dependency injection for the repository and performs
asynchronous deletion with cancellation support.
2025-12-01 16:19:51 +01:00
ac214dc8e1 Add CreateAction POST endpoint to ActionController
A new HTTP POST endpoint `CreateAction` was added to the
`ActionController` class. This endpoint accepts a
`CreateRecActionCommand` object from the request body, sends
it to the `mediator` for processing, and returns a `201 Created`
response using the `CreatedAtAction` method. This change
enables the creation of actions via HTTP POST requests,
enhancing the controller's functionality.
2025-12-01 16:16:35 +01:00
d6b914b9c8 Add new DbSet properties to RecDbContext
Expanded RecDbContext to include new DbSet properties for
managing `Connections`, `Endpoints`, `EndpointAuths`,
`Profiles`, and `RecActions`. These additions enable
interaction with corresponding database tables/entities.

Updated the `OnModelCreating` method to ensure proper
configuration of the context. Removed an extraneous
closing brace to maintain proper syntax.
2025-12-01 16:14:15 +01:00
d764668cd7 Add CreateAction endpoint to ActionController
Introduced a new asynchronous `CreateAction` method in the
`ActionController` class to handle HTTP POST requests for
creating "rec actions". The method accepts a `CreateRecActionCommand`
object from the request body, processes it using `mediator.Send`,
and returns a `201 Created` response using `CreatedAtAction`.
2025-12-01 16:10:57 +01:00
6208a1cf93 Set default ProfileId and clean up unused directives
Removed unused `using` directives for `DigitalData.Core.Abstraction.Application.Repository` and `ReC.Domain.Entities`. Reordered `using` directives for better organization. Updated the `ProfileId` property in `CreateRecActionCommand` to have a default value of `2`, improving code clarity and reducing the need for explicit initialization.
2025-12-01 16:07:52 +01:00
a7ad55e973 Add MappingProfile for CreateRecActionCommand mapping
Introduced a new `MappingProfile` class in the `ReC.Application.RecActions` namespace to define object-to-object mapping configurations using AutoMapper.

The profile maps `CreateRecActionCommand` to `RecAction`, enabling seamless data transformation between these types. Added necessary `using` directives for `ReC.Application.RecActions.Commands` and `ReC.Domain.Entities`.
2025-12-01 16:07:11 +01:00
918372371e Refactor GetOrCreateEndpointCommand to ObtainEndpointCommand
Replaced `GetOrCreateEndpointCommand` with `ObtainEndpointCommand`
to improve clarity and align with naming conventions. Removed
`GetOrCreateEndpointCommand` and its handler, and introduced
`ObtainEndpointCommand` with equivalent functionality.

Updated `MappingProfile.cs` to map `ObtainEndpointCommand` to
`Endpoint`. Refactored `CreateRecActionCommand.cs` to use the
new `ObtainEndpointCommand` for retrieving or creating `Endpoint`
entities.

These changes ensure consistent naming and maintain the same
behavior while improving code readability.
2025-12-01 16:00:41 +01:00
a962299c95 Refactor GetOrCreateCommand to GetOrCreateEndpointCommand
Renamed `GetOrCreateCommand` to `GetOrCreateEndpointCommand`
to improve clarity and consistency. Removed the old
`GetOrCreateCommand` class and handler, and introduced the
new `GetOrCreateEndpointCommand` class with equivalent
functionality.

Updated `MappingProfile` to reflect the new command name
and adjusted `CreateRecActionCommand` to use the renamed
command. Added the appropriate namespace for the new class
to ensure proper organization.
2025-12-01 15:56:25 +01:00
cacd5eddbe Make Id property in Endpoint class non-nullable
The `Id` property in the `Endpoint` class was changed from a
nullable `long?` to a non-nullable `long`. This ensures that
the `Id` property is always assigned a value and cannot be
`null`, improving data integrity and aligning with potential
database or application requirements.
2025-12-01 15:55:23 +01:00
d30feb6034 Add handler for CreateRecActionCommand with validation
Updated `CreateRecActionCommand` to implement `IRequest` for MediatR compatibility. Introduced `CreateRecActionCommandHandler` to process requests, including validation for `EndpointId` and `EndpointUri`. Added logic to fetch or create an endpoint when `EndpointUri` is provided. Updated `EndpointId` property to be mutable. Added necessary `using` directives and adjusted the namespace declaration.
2025-12-01 15:55:01 +01:00
c6f2437300 Refactor endpoint commands and mappings
Removed unused `using` directives across files for cleanup. Deleted `CreateEndpointCommand` and `Endpoint` classes as they are no longer needed. Added `GetOrCreateCommand` to handle endpoint retrieval or creation. Updated `MappingProfile` to remove mappings for `CreateEndpointCommand` and ensure proper inheritance from `AutoMapper.Profile`.
2025-12-01 15:48:58 +01:00
46664d62ba Refactor GetOrCreateCommand and add AutoMapper profile
Refactored the `GetOrCreateCommand` to simplify the creation
of `Endpoint` entities by delegating the creation logic to
`repo.CreateAsync`.

Added a new `MappingProfile` class using AutoMapper to define
mappings between command objects (`CreateEndpointCommand` and
`GetOrCreateCommand`) and the `Endpoint` entity, improving
code maintainability and reducing boilerplate.

Included necessary `using` directives in `MappingProfile.cs`
to support the new mapping functionality.
2025-12-01 15:47:58 +01:00
4d6df7ccc8 Add CreateEndpointCommand and Endpoint classes
Introduced the `CreateEndpointCommand` class as a placeholder for future implementation. Added the `Endpoint` class with properties `Active`, `Description`, and `Uri` to represent endpoint details. Included necessary `using` directives and organized the code under the `ReC.Application.Endpoints.Commands` namespace.
2025-12-01 15:45:04 +01:00
79e5097590 Add GetOrCreateCommandHandler for endpoint management
Introduced `GetOrCreateCommandHandler` to handle `GetOrCreateCommand` requests.
The handler checks if an `Endpoint` with the specified `Uri` exists in the repository
and returns it if found. If not, it creates a new `Endpoint`, saves it, and returns
the newly created object. Added necessary `using` directives for repository abstraction
and Entity Framework Core functionality.
2025-12-01 15:41:38 +01:00
594057c4db Add GetOrCreateCommand for endpoint handling
Introduced the `GetOrCreateCommand` class in the `ReC.Application.Endpoints.Commands` namespace. This class implements the `IRequest<Endpoint>` interface from MediatR to handle requests for retrieving or creating an `Endpoint`.

Added `Uri` property to the command with an `init` accessor for immutability. Included necessary `using` directives for `MediatR` and `ReC.Domain.Entities`.
2025-12-01 15:34:25 +01:00
773b939a5c Rename Guid property to Id in EndpointParam class
The `Guid` property in the `EndpointParam` class was renamed to `Id` to improve code readability and align with naming conventions. The `[Key]` and `[Column("GUID")]` attributes remain unchanged, ensuring the database schema mapping and primary key designation are preserved.
2025-12-01 15:25:33 +01:00
8c47082c7f Make EndpointId nullable and add EndpointUri property
The `EndpointId` property in the `CreateRecActionCommand` class
was updated from a non-nullable `long` to a nullable `long?`
to allow it to hold `null` values.

Additionally, a new nullable `string?` property `EndpointUri`
was introduced to support specifying an optional endpoint URI.
2025-12-01 15:22:49 +01:00
9b22987397 Add CreateRecActionCommand record for RecActions
Introduced a new namespace `ReC.Application.RecActions.Commands`
and added the `CreateRecActionCommand` record. This record
includes properties such as `ProfileId`, `Active`, `EndpointId`,
`Type`, `HeaderQuery`, and `BodyQuery` to encapsulate the
necessary data for creating RecActions. Default values were
provided for `Active`, `Type`, and `BodyQuery` to streamline
initialization.
2025-12-01 15:14:56 +01:00
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
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
28 changed files with 579 additions and 143 deletions

View File

@ -14,4 +14,29 @@ public class ActionController(IMediator mediator) : ControllerBase
await mediator.InvokeBatchRecAction(profileId);
return Accepted();
}
[HttpPost]
public async Task<IActionResult> CreateAction([FromBody] CreateRecActionCommand command)
{
await mediator.Send(command);
return CreatedAtAction(nameof(CreateAction), null);
}
[HttpPost("fake")]
public async Task<IActionResult> CreateFakeAction(
string? endpointUri = null,
string type = "GET",
string bodyQuery = "SELECT NULL AS REQUEST_BODY;")
{
await mediator.Send(new CreateRecActionCommand()
{
ProfileId = 2,
EndpointUri = endpointUri,
Type = type,
BodyQuery = bodyQuery
});
return CreatedAtAction(nameof(CreateFakeAction), null);
}
}

View File

@ -9,5 +9,6 @@
"MediatRLicense": "eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx1Y2t5UGVubnlTb2Z0d2FyZUxpY2Vuc2VLZXkvYmJiMTNhY2I1OTkwNGQ4OWI0Y2IxYzg1ZjA4OGNjZjkiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2x1Y2t5cGVubnlzb2Z0d2FyZS5jb20iLCJhdWQiOiJMdWNreVBlbm55U29mdHdhcmUiLCJleHAiOiIxNzg0ODUxMjAwIiwiaWF0IjoiMTc1MzM2MjQ5MSIsImFjY291bnRfaWQiOiIwMTk4M2M1OWU0YjM3MjhlYmZkMzEwM2MyYTQ4NmU4NSIsImN1c3RvbWVyX2lkIjoiY3RtXzAxazB5NmV3MmQ4YTk4Mzg3aDJnbTRuOWswIiwic3ViX2lkIjoiLSIsImVkaXRpb24iOiIwIiwidHlwZSI6IjIifQ.ZqsFG7kv_-xGfxS6ACk3i0iuNiVUXX2AvPI8iAcZ6-z2170lGv__aO32tWpQccD9LCv5931lBNLWSblKS0MT3gOt-5he2TEftwiSQGFwoIBgtOHWsNRMinUrg2trceSp3IhyS3UaMwnxZDrCvx4-0O-kpOzVpizeHUAZNr5U7oSCWO34bpKdae6grtM5e3f93Z1vs7BW_iPgItd-aLvPwApbaG9VhmBTKlQ7b4Jh64y7UXJ9mKP7Qb_Oa97oEg0oY5DPHOWTZWeE1EzORgVr2qkK2DELSHuZ_EIUhODojkClPNAKtvEl_qEjpq0HZCIvGwfCCRlKlSkQqIeZdFkiXg",
"RecAction": {
"MaxConcurrentInvocations": 5
}
},
"AddedWho": "ReC.API"
}

View File

@ -12,15 +12,10 @@ public class BodyQueryBehavior<TRecAction>(IRecDbContext dbContext) : IPipelineB
{
if (action.BodyQuery is null)
return await next(cancel);
var result = await dbContext.BodyQueryResults.FromSqlRaw(action.BodyQuery).FirstOrDefaultAsync(cancel);
if (result?.RawBody is null)
throw new InvalidOperationException(
$"Body query did not return a result or returned a null REQUEST_BODY. " +
$"ProfileId: {action.ProfileId}, ActionId: {action.ActionId}.");
var result = await dbContext.BodyQueryResults.FromSqlRaw(action.BodyQuery).SingleOrDefaultAsync(cancel);
action.Body = result.RawBody;
action.Body = result?.RawBody;
return await next(cancel);
}

View File

@ -15,13 +15,11 @@ public class HeaderQueryBehavior<TRecAction>(IRecDbContext dbContext, ILogger<He
if (action.HeaderQuery is null)
return await next(cancel);
var result = await dbContext.HeaderQueryResults.FromSqlRaw(action.HeaderQuery).FirstOrDefaultAsync(cancel);
var result = await dbContext.HeaderQueryResults.FromSqlRaw(action.HeaderQuery).SingleOrDefaultAsync(cancel);
if(result?.RawHeader is null)
if (result?.RawHeader is null)
{
logger?.LogWarning("Header query did not return a result or returned a null REQUEST_HEADER. Profile ID: {ProfileId}, Action ID: {ActionId}", action.ProfileId, action.ActionId);
action.IsReturnedNoData.HeaderQuery = true;
logger?.LogWarning("Header query did not return a result or returned a null REQUEST_HEADER. Profile ID: {ProfileId}, Action ID: {Id}", action.ProfileId, action.Id);
return await next(cancel);
}
@ -31,10 +29,8 @@ public class HeaderQueryBehavior<TRecAction>(IRecDbContext dbContext, ILogger<He
if(headerDict is null)
{
logger?.LogWarning(
"Header JSON deserialization returned null. RawHeader: {RawHeader}, ProfileId: {ProfileId}, ActionId: {ActionId}",
result.RawHeader, action.ProfileId, action.ActionId);
action.IsReturnedNoData.HeaderQuery = true;
"Header JSON deserialization returned null. RawHeader: {RawHeader}, ProfileId: {ProfileId}, Id: {Id}",
result.RawHeader, action.ProfileId, action.Id);
return await next(cancel);
}

View File

@ -7,6 +7,6 @@ public class DtoMappingProfile : Profile
{
public DtoMappingProfile()
{
CreateMap<RecAction, RecActionDto>();
CreateMap<RecActionView, RecActionDto>();
}
}

View File

@ -2,7 +2,7 @@
public record RecActionDto
{
public long? ActionId { get; init; }
public required long Id { get; init; }
public long? ProfileId { get; init; }
@ -60,8 +60,6 @@ public record RecActionDto
public string? Body { get; set; }
public (bool BodyQuery, bool HeaderQuery) IsReturnedNoData = (false, false);
public string? PostprocessingQuery { get; init; }
public UriBuilder ToEndpointUriBuilder()

View File

@ -0,0 +1,8 @@
namespace ReC.Application.Common.Exceptions;
public class DataIntegrityException : Exception
{
public DataIntegrityException() { }
public DataIntegrityException(string message) : base(message) { }
}

View File

@ -7,7 +7,7 @@ public interface IRecDbContext
{
public DbSet<EndpointParam> EndpointParams { get; }
public DbSet<RecAction> Actions { get; }
public DbSet<RecActionView> Actions { get; }
public DbSet<OutRes> OutRes { get; }

View File

@ -0,0 +1,25 @@
using DigitalData.Core.Abstraction.Application.Repository;
using MediatR;
using Microsoft.EntityFrameworkCore;
using ReC.Domain.Entities;
namespace ReC.Application.Endpoints.Commands;
public class ObtainEndpointCommand : IRequest<Endpoint>
{
public string Uri { get; init; } = null!;
}
public class ObtainEndpointCommandHandler(IRepository<Endpoint> repo) : IRequestHandler<ObtainEndpointCommand, Endpoint>
{
public async Task<Endpoint> Handle(ObtainEndpointCommand request, CancellationToken cancel)
{
var endpoint = await repo.Where(e => e.Uri == request.Uri).FirstOrDefaultAsync(cancel);
if (endpoint is not null)
return endpoint;
endpoint = await repo.CreateAsync(request, cancel);
return endpoint;
}
}

View File

@ -0,0 +1,12 @@
using ReC.Application.Endpoints.Commands;
using ReC.Domain.Entities;
namespace ReC.Application.Endpoints;
public class MappingProfile : AutoMapper.Profile
{
public MappingProfile()
{
CreateMap<ObtainEndpointCommand, Endpoint>();
}
}

View File

@ -0,0 +1,23 @@
using DigitalData.Core.Abstraction.Application.Repository;
using MediatR;
namespace ReC.Application.OutResults.Commands;
public class CreateOutResCommand : IRequest
{
public required long ActionId { get; set; }
public string? Header { get; set; }
public string? Body { get; set; }
public string? AddedWho { get; set; }
}
public class CreateOutResCommandHandler(IRepository<CreateOutResCommand> repo) : IRequestHandler<CreateOutResCommand>
{
public Task Handle(CreateOutResCommand request, CancellationToken cancel)
{
return repo.CreateAsync(request, cancel);
}
}

View File

@ -0,0 +1,13 @@
using AutoMapper;
using ReC.Application.OutResults.Commands;
using ReC.Domain.Entities;
namespace ReC.Application.OutResults;
public class MappingProfiles : Profile
{
public MappingProfiles()
{
CreateMap<CreateOutResCommand, OutRes>();
}
}

View File

@ -0,0 +1,37 @@
using DigitalData.Core.Exceptions;
using MediatR;
using ReC.Application.Endpoints.Commands;
namespace ReC.Application.RecActions.Commands;
public record CreateRecActionCommand : IRequest
{
public long ProfileId { get; init; }
public bool Active { get; init; } = true;
public long? EndpointId { get; set; }
public string? EndpointUri { get; init; }
public string Type { get; init; } = null!;
public string? HeaderQuery { get; init; }
public string BodyQuery { get; init; } = null!;
}
public class CreateRecActionCommandHandler(ISender sender) : IRequestHandler<CreateRecActionCommand>
{
public async Task Handle(CreateRecActionCommand request, CancellationToken cancel)
{
if(request.EndpointId is null)
if(request.EndpointUri is string endpointUri)
{
var endpoint = await sender.Send(new ObtainEndpointCommand { Uri = endpointUri }, cancel);
request.EndpointId = endpoint.Id;
}
else
throw new BadRequestException("Either EndpointId or EndpointUri must be provided.");
}
}

View File

@ -0,0 +1,18 @@
using DigitalData.Core.Abstraction.Application.Repository;
using MediatR;
using ReC.Domain.Entities;
namespace ReC.Application.RecActions.Commands;
public class DeleteRecActionsCommand : IRequest
{
public long ProfileId { get; init; } = 2;
}
public class DeleteRecActionsCommandHandler(IRepository<RecAction> repo) : IRequestHandler<DeleteRecActionsCommand>
{
public Task Handle(DeleteRecActionsCommand request, CancellationToken cancel)
{
return repo.DeleteAsync(act => act.ProfileId == request.ProfileId, cancel);
}
}

View File

@ -33,9 +33,9 @@ public class InvokeRecActionsCommandHandler(ISender sender, IHttpClientFactory c
{
logger?.LogError(
ex,
"Error invoking Rec action. ProfileId: {ProfileId}, ActionId: {ActionId}",
"Error invoking Rec action. ProfileId: {ProfileId}, Id: {Id}",
action.ProfileId,
action.ActionId
action.Id
);
}
finally

View File

@ -1,68 +1,65 @@
using MediatR;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Configuration;
using ReC.Application.Common;
using ReC.Application.Common.Dto;
using ReC.Application.Common.Exceptions;
using ReC.Application.OutResults.Commands;
using System.Text.Json;
namespace ReC.Application.RecActions.Commands;
public record InvokeRecActionCommand : RecActionDto, IRequest
public record InvokeRecActionCommand : IRequest
{
public InvokeRecActionCommand(RecActionDto root) : base(root) { }
public InvokeRecActionCommand() { }
public RecActionDto Action { get; set; } = null!;
}
public static class InvokeRecActionCommandExtensions
{
public static InvokeRecActionCommand ToInvokeCommand(this RecActionDto dto) => new(dto);
public static InvokeRecActionCommand ToInvokeCommand(this RecActionDto dto) => new() { Action = dto };
}
public class InvokeRecActionCommandHandler(
IHttpClientFactory clientFactory,
ILogger<InvokeRecActionsCommandHandler>? logger = null
ISender sender,
IHttpClientFactory clientFactory,
IConfiguration? config = null
) : IRequestHandler<InvokeRecActionCommand>
{
public async Task Handle(InvokeRecActionCommand request, CancellationToken cancel)
{
var action = request.Action;
using var http = clientFactory.CreateClient();
if (request.RestType is null)
{
logger?.LogWarning(
"Rec action could not be invoked because the RestType value is null. ProfileId: {ProfileId}, ActionId: {ActionId}",
request.ProfileId,
request.ActionId
);
return;
}
if (action.RestType is null)
throw new DataIntegrityException(
$"Rec action could not be invoked because the RestType value is null. " +
$"ProfileId: {action.ProfileId}, " +
$"Id: {action.Id}"
);
using var httpReq = request.RestType
using var httpReq = action.RestType
.ToHttpMethod()
.ToHttpRequestMessage(request.EndpointUri);
.ToHttpRequestMessage(action.EndpointUri);
if(request.Body is not null)
if(action.Body is not null)
{
using var reqBody = new StringContent(request.Body);
using var reqBody = new StringContent(action.Body);
httpReq.Content = reqBody;
}
else if(request.BodyQuery is not null && !request.IsReturnedNoData.BodyQuery)
{
logger?.LogWarning(
"Although BodyQuery returns null, the IsReturnedNoData variable has not been set to TRUE. " +
"This indicates that BodyQueryBehavior has not been executed or that the relevant control step has been skipped. " +
"The relevant behavior must be verified to ensure that the process does not produce unexpected conditions. " +
"ProfileId: {ProfileId}, ActionId: {ActionId}",
request.ProfileId,
request.ActionId
);
}
if (request.Headers is not null)
foreach (var header in request.Headers)
if (action.Headers is not null)
foreach (var header in action.Headers)
httpReq.Headers.Add(header.Key, header.Value);
using var response = await http.SendAsync(httpReq, cancel);
var body = await response.Content.ReadAsStringAsync(cancel);
var headers = response.Headers.ToDictionary();
var resBody = await response.Content.ReadAsStringAsync(cancel);
var resHeaders = response.Headers.ToDictionary();
await sender.Send(new CreateOutResCommand
{
ActionId = action.Id,
Header = JsonSerializer.Serialize(resHeaders, options: new() { WriteIndented = false }),
Body = resBody,
AddedWho = config?["AddedWho"]
}, cancel);
}
}

View File

@ -0,0 +1,12 @@
using ReC.Application.RecActions.Commands;
using ReC.Domain.Entities;
namespace ReC.Application.RecActions;
public class MappingProfile : AutoMapper.Profile
{
public MappingProfile()
{
CreateMap<CreateRecActionCommand, RecAction>();
}
}

View File

@ -17,7 +17,7 @@ public record ReadRecActionQueryBase
public record ReadRecActionQuery(ReadRecActionQueryBase Root) : ReadRecActionQueryBase(Root), IRequest<IEnumerable<RecActionDto>>;
public class ReadRecActionQueryHandler(IRepository<RecAction> repo, IMapper mapper) : IRequestHandler<ReadRecActionQuery, IEnumerable<RecActionDto>>
public class ReadRecActionQueryHandler(IRepository<RecActionView> repo, IMapper mapper) : IRequestHandler<ReadRecActionQuery, IEnumerable<RecActionDto>>
{
public async Task<IEnumerable<RecActionDto>> Handle(ReadRecActionQuery request, CancellationToken cancel)
{

View File

@ -0,0 +1,53 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace ReC.Domain.Entities;
[Table("TBDD_CONNECTION")]
public class Connection
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")]
public short? Id { get; set; }
[Column("BEZEICHNUNG")]
public string? Bezeichnung { get; set; }
[Column("SQL_PROVIDER")]
public string? SqlProvider { get; set; }
[Column("SERVER")]
public string? Server { get; set; }
[Column("DATENBANK")]
public string? Datenbank { get; set; }
[Column("USERNAME")]
public string? Username { get; set; }
[Column("PASSWORD")]
public string? Password { get; set; }
[Column("BEMERKUNG")]
public string? Bemerkung { get; set; }
[Column("AKTIV")]
public bool? Aktiv { get; set; }
[Column("ERSTELLTWER")]
public string? ErstelltWer { get; set; }
[Column("ERSTELLTWANN")]
public DateTime? ErstelltWann { get; set; }
[Column("GEANDERTWER")]
public string? GeandertWer { get; set; }
[Column("GEAENDERTWANN")]
public DateTime? GeaendertWann { get; set; }
[Column("SYS_CONNECTION")]
public bool? SysConnection { get; set; }
}

View File

@ -0,0 +1,35 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace ReC.Domain.Entities;
[Table("TBREC_CFG_ENDPOINT")]
public class Endpoint
{
[Key]
[Column("GUID")]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
[Column("ACTIVE")]
public bool? Active { get; set; }
[Column("DESCRIPTION")]
public string? Description { get; set; }
[Column("URI")]
public string? Uri { get; set; }
[Column("ADDED_WHO")]
public string? AddedWho { get; set; }
[Column("ADDED_WHEN")]
public DateTime? AddedWhen { get; set; }
[Column("CHANGED_WHO")]
public string? ChangedWho { get; set; }
[Column("CHANGED_WHEN")]
public DateTime? ChangedWhen { get; set; }
}

View File

@ -0,0 +1,59 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace ReC.Domain.Entities;
[Table("TBREC_CFG_ENDPOINT_AUTH")]
public class EndpointAuth
{
[Key]
[Column("GUID")]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long? Id { get; set; }
[Column("ACTIVE")]
public bool? Active { get; set; }
[Column("DESCRIPTION")]
public string? Description { get; set; }
[Column("TYPE")]
public string? Type { get; set; }
[Column("API_KEY")]
public string? ApiKey { get; set; }
[Column("API_VALUE")]
public string? ApiValue { get; set; }
[Column("API_KEY_ADD_TO")]
public string? ApiKeyAddTo { get; set; }
[Column("TOKEN")]
public string? Token { get; set; }
[Column("USERNAME")]
public string? Username { get; set; }
[Column("PASSWORD")]
public string? Password { get; set; }
[Column("DOMAIN")]
public string? Domain { get; set; }
[Column("WORKSTATION")]
public string? Workstation { get; set; }
[Column("ADDED_WHO")]
public string? AddedWho { get; set; }
[Column("ADDED_WHEN")]
public DateTime? AddedWhen { get; set; }
[Column("CHANGED_WHO")]
public string? ChangedWho { get; set; }
[Column("CHANGED_WHEN")]
public DateTime? ChangedWhen { get; set; }
}

View File

@ -13,7 +13,7 @@ public class EndpointParam
{
[Key]
[Column("GUID")]
public long? Guid { get; set; }
public long? Id { get; set; }
[Column("ACTIVE")]
public bool? Active { get; set; }

View File

@ -15,10 +15,10 @@ public class OutRes
public long? ActionId { get; set; }
[Column("RESULT_HEADER")]
public string? ResultHeader { get; set; }
public string? Header { get; set; }
[Column("RESULT_BODY")]
public string? ResultBody { get; set; }
public string? Body { get; set; }
[Column("ADDED_WHO")]
public string? AddedWho { get; set; }

View File

@ -0,0 +1,47 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace ReC.Domain.Entities;
[Table("TBREC_CFG_PROFILE", Schema = "dbo")]
public class Profile
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")]
public short? Id { get; set; }
[Column("ACTIVE")]
public bool? Active { get; set; }
[Column("TYPE")]
public string? Type { get; set; }
[Column("MANDANTOR")]
public string? Mandantor { get; set; }
[Column("PROFILE_NAME")]
public string? Name { get; set; }
[Column("DESCRIPTION")]
public string? Description { get; set; }
[Column("LOG_LEVEL")]
public string? LogLevel { get; set; }
[Column("LANGUAGE")]
public string? Language { get; set; }
[Column("ADDED_WHO")]
public string? AddedWho { get; set; }
[Column("ADDED_WHEN")]
public DateTime? AddedWhen { get; set; }
[Column("CHANGED_WHO")]
public string? ChangedWho { get; set; }
[Column("CHANGED_WHEN")]
public DateTime? ChangedWhen { get; set; }
}

View File

@ -3,79 +3,36 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace ReC.Domain.Entities;
/// <summary>
/// Represents the VWREC_ACTION view from the database.
///
/// All properties are defined as nullable to provide flexibility in case the underlying view
/// changes in production (e.g., columns added, removed, or modified). This approach prevents
/// runtime mapping errors and ensures the application can handle schema changes without
/// requiring immediate code updates.
/// </summary>
[Table("VWREC_ACTION", Schema = "dbo")]
[Table("TBREC_CFG_ACTION")]
public class RecAction
{
[Column("ACTION_ID")]
public long? ActionId { get; set; }
[Key]
[Column("GUID")]
public long? Id { get; set; }
[Column("PROFILE_ID")]
public long? ProfileId { get; set; }
[Column("PROFILE_NAME")]
[MaxLength(100)]
public string? ProfileName { get; set; }
[ForeignKey("ProfileId")]
public Profile? Profile { get; set; }
[Column("PROFILE_TYPE")]
[MaxLength(20)]
public string? ProfileType { get; set; }
[Column("ACTIVE")]
public bool? Active { get; set; }
[Column("PROFILE_SEQUENCE")]
public byte? ProfileSequence { get; set; }
[Column("SEQUENCE")]
public byte? Sequence { get; set; }
[Column("ENDPOINT_ID")]
public long? EndpointId { get; set; }
[Column("ENDPOINT_URI")]
[MaxLength(4000)]
public string? EndpointUri { get; set; }
[ForeignKey("EndpointId")]
public Endpoint? Endpoint { get; set; }
[Column("ENDPOINT_AUTH_ID")]
public long? EndpointAuthId { get; set; }
[Column("ENDPOINT_AUTH_TYPE")]
[MaxLength(50)]
public string? EndpointAuthType { get; set; }
[Column("ENDPOINT_AUTH_API_KEY")]
[MaxLength(300)]
public string? EndpointAuthApiKey { get; set; }
[Column("ENDPOINT_AUTH_API_VALUE")]
[MaxLength(300)]
public string? EndpointAuthApiValue { get; set; }
[Column("ENDPOINT_AUTH_API_KEY_ADD_TO")]
[MaxLength(20)]
public string? EndpointAuthApiKeyAddTo { get; set; }
[Column("ENDPOINT_AUTH_TOKEN")]
[MaxLength(300)]
public string? EndpointAuthToken { get; set; }
[Column("ENDPOINT_AUTH_USERNAME")]
[MaxLength(200)]
public string? EndpointAuthUsername { get; set; }
[Column("ENDPOINT_AUTH_PASSWORD")]
[MaxLength(200)]
public string? EndpointAuthPassword { get; set; }
[Column("ENDPOINT_AUTH_DOMAIN")]
[MaxLength(100)]
public string? EndpointAuthDomain { get; set; }
[Column("ENDPOINT_AUTH_WORKSTATION")]
[MaxLength(100)]
public string? EndpointAuthWorkstation { get; set; }
[ForeignKey("EndpointAuthId")]
public EndpointAuth? EndpointAuth { get; set; }
[Column("ENDPOINT_PARAMS_ID")]
public short? EndpointParamsId { get; set; }
@ -83,25 +40,11 @@ public class RecAction
[Column("SQL_CONNECTION_ID")]
public short? SqlConnectionId { get; set; }
[Column("SQL_CONNECTION_SERVER")]
[MaxLength(150)]
public string? SqlConnectionServer { get; set; }
[ForeignKey("SqlConnectionId")]
public Connection? SqlConnection { get; set; }
[Column("SQL_CONNECTION_DB")]
[MaxLength(100)]
public string? SqlConnectionDb { get; set; }
[Column("SQL_CONNECTION_USERNAME")]
[MaxLength(100)]
public string? SqlConnectionUsername { get; set; }
[Column("SQL_CONNECTION_PASSWORD")]
[MaxLength(100)]
public string? SqlConnectionPassword { get; set; }
[Column("REST_TYPE")]
[MaxLength(20)]
public string? RestType { get; set; }
[Column("TYPE")]
public string? Type { get; set; }
[Column("PREPROCESSING_QUERY")]
public string? PreprocessingQuery { get; set; }
@ -114,4 +57,16 @@ public class RecAction
[Column("POSTPROCESSING_QUERY")]
public string? PostprocessingQuery { get; set; }
[Column("ADDED_WHO")]
public string? AddedWho { get; set; }
[Column("ADDED_WHEN")]
public DateTime? AddedWhen { get; set; }
[Column("CHANGED_WHO")]
public string? ChangedWho { get; set; }
[Column("CHANGED_WHEN")]
public DateTime? ChangedWhen { get; set; }
}

View File

@ -0,0 +1,117 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace ReC.Domain.Entities;
/// <summary>
/// Represents the VWREC_ACTION view from the database.
///
/// All properties are defined as nullable to provide flexibility in case the underlying view
/// changes in production (e.g., columns added, removed, or modified). This approach prevents
/// runtime mapping errors and ensures the application can handle schema changes without
/// requiring immediate code updates.
/// </summary>
[Table("VWREC_ACTION", Schema = "dbo")]
public class RecActionView
{
[Column("ACTION_ID")]
public required long Id { get; set; }
[Column("PROFILE_ID")]
public long? ProfileId { get; set; }
[Column("PROFILE_NAME")]
[MaxLength(100)]
public string? ProfileName { get; set; }
[Column("PROFILE_TYPE")]
[MaxLength(20)]
public string? ProfileType { get; set; }
[Column("PROFILE_SEQUENCE")]
public byte? ProfileSequence { get; set; }
[Column("ENDPOINT_ID")]
public long? EndpointId { get; set; }
[Column("ENDPOINT_URI")]
[MaxLength(4000)]
public string? EndpointUri { get; set; }
[Column("ENDPOINT_AUTH_ID")]
public long? EndpointAuthId { get; set; }
[Column("ENDPOINT_AUTH_TYPE")]
[MaxLength(50)]
public string? EndpointAuthType { get; set; }
[Column("ENDPOINT_AUTH_API_KEY")]
[MaxLength(300)]
public string? EndpointAuthApiKey { get; set; }
[Column("ENDPOINT_AUTH_API_VALUE")]
[MaxLength(300)]
public string? EndpointAuthApiValue { get; set; }
[Column("ENDPOINT_AUTH_API_KEY_ADD_TO")]
[MaxLength(20)]
public string? EndpointAuthApiKeyAddTo { get; set; }
[Column("ENDPOINT_AUTH_TOKEN")]
[MaxLength(300)]
public string? EndpointAuthToken { get; set; }
[Column("ENDPOINT_AUTH_USERNAME")]
[MaxLength(200)]
public string? EndpointAuthUsername { get; set; }
[Column("ENDPOINT_AUTH_PASSWORD")]
[MaxLength(200)]
public string? EndpointAuthPassword { get; set; }
[Column("ENDPOINT_AUTH_DOMAIN")]
[MaxLength(100)]
public string? EndpointAuthDomain { get; set; }
[Column("ENDPOINT_AUTH_WORKSTATION")]
[MaxLength(100)]
public string? EndpointAuthWorkstation { get; set; }
[Column("ENDPOINT_PARAMS_ID")]
public short? EndpointParamsId { get; set; }
[Column("SQL_CONNECTION_ID")]
public short? SqlConnectionId { get; set; }
[Column("SQL_CONNECTION_SERVER")]
[MaxLength(150)]
public string? SqlConnectionServer { get; set; }
[Column("SQL_CONNECTION_DB")]
[MaxLength(100)]
public string? SqlConnectionDb { get; set; }
[Column("SQL_CONNECTION_USERNAME")]
[MaxLength(100)]
public string? SqlConnectionUsername { get; set; }
[Column("SQL_CONNECTION_PASSWORD")]
[MaxLength(100)]
public string? SqlConnectionPassword { get; set; }
[Column("REST_TYPE")]
[MaxLength(20)]
public string? RestType { get; set; }
[Column("PREPROCESSING_QUERY")]
public string? PreprocessingQuery { get; set; }
[Column("HEADER_QUERY")]
public string? HeaderQuery { get; set; }
[Column("BODY_QUERY")]
public string? BodyQuery { get; set; }
[Column("POSTPROCESSING_QUERY")]
public string? PostprocessingQuery { get; set; }
}

View File

@ -21,7 +21,7 @@ public static class DependencyInjection
services.AddScoped<IRecDbContext>(provider => provider.GetRequiredService<TRecDbContext>());
services.AddDbRepository(opt => opt.RegisterFromAssembly<TRecDbContext>(typeof(RecAction).Assembly));
services.AddDbRepository(opt => opt.RegisterFromAssembly<TRecDbContext>(typeof(RecActionView).Assembly));
return services;
}

View File

@ -8,7 +8,7 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
{
public DbSet<EndpointParam> EndpointParams { get; set; }
public DbSet<RecAction> Actions { get; set; }
public DbSet<RecActionView> Actions { get; set; }
public DbSet<OutRes> OutRes { get; set; }
@ -16,14 +16,24 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
public DbSet<BodyQueryResult> BodyQueryResults { get; set; }
public DbSet<Connection> Connections { get; set; }
public DbSet<Endpoint> Endpoints { get; set; }
public DbSet<EndpointAuth> EndpointAuths { get; set; }
public DbSet<Profile> Profiles { get; set; }
public DbSet<RecAction> RecActions { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<RecAction>().HasNoKey();
modelBuilder.Entity<RecActionView>().HasNoKey();
modelBuilder.Entity<HeaderQueryResult>().HasNoKey();
modelBuilder.Entity<BodyQueryResult>().HasNoKey();
}
}
}