Compare commits
86 Commits
feat/clien
...
3da16ba640
| Author | SHA1 | Date | |
|---|---|---|---|
| 3da16ba640 | |||
| 71a0220c3f | |||
| f53603083a | |||
| 92e7d44d3b | |||
| f8211e9e9d | |||
| 1782844543 | |||
| 2aa7cabcbd | |||
| 28f35101f9 | |||
| f8c5502905 | |||
| 961b87de3d | |||
| 6b036f4f91 | |||
| 46b7ae29cd | |||
| 84e403f411 | |||
| 3b77345aee | |||
| 6d04a4afd1 | |||
| 1f250d55b0 | |||
| c422de445d | |||
| f9a73fbe0c | |||
| 282ce3a0b7 | |||
| 26f2da1313 | |||
| bc700e2cd2 | |||
| ea5389df85 | |||
| 87e1bb9187 | |||
| 68cc919bad | |||
| 374365d250 | |||
| 8c79b3a156 | |||
| 0583d07f26 | |||
| fd7744e94e | |||
| a5aac1d0ec | |||
| 165152b7cf | |||
| f1f9e8d791 | |||
| 35171add0c | |||
| 030dcf8b58 | |||
| 71411d4027 | |||
| da1b05347e | |||
| d932fb522c | |||
| 134a808633 | |||
|
|
00efb14f2c | ||
| fe40cd001f | |||
| f96b73bf38 | |||
| c8f3b29329 | |||
| 07fca00344 | |||
| e4aec494c8 | |||
| 009bb623b5 | |||
| f8e7f8c974 | |||
| 959b56c4bb | |||
| 5a56125444 | |||
| 48039b8fd5 | |||
| 31d1d9d171 | |||
| 1419455b36 | |||
| a6111cdc66 | |||
| 3caa6b9bd3 | |||
| fb08a45c57 | |||
| 0588ba33d8 | |||
| 535fdbb7b4 | |||
| 4206a962ff | |||
| ae059e4416 | |||
| d771dbbc9e | |||
| 73ffaaab08 | |||
| b79fcf936b | |||
| 674c14dd7c | |||
| b326e7e1b3 | |||
| 3f8ba7d76c | |||
| 13346b610a | |||
| 8bc9b85049 | |||
| 141e77f315 | |||
| f9a4d93495 | |||
| 79f771b3ea | |||
| 8738c15804 | |||
| 70c07c9595 | |||
| 96fe9c99da | |||
| 1e62a70866 | |||
| f4aa0b5965 | |||
| 1700fe978d | |||
| 37c88812e1 | |||
| 34efb662ec | |||
| dcbff90ed8 | |||
| 404a1c4793 | |||
| 1cdd28738a | |||
| 45c7259ce8 | |||
| 6d9985051e | |||
| b9f5a3f10c | |||
| 243cc97aa2 | |||
| bb43bfa064 | |||
| b4966585ae | |||
| ae548d530f |
@@ -1,6 +1,7 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using ReC.API.Extensions;
|
using ReC.API.Extensions;
|
||||||
|
using ReC.Application.OutResults.Commands;
|
||||||
using ReC.Application.OutResults.Queries;
|
using ReC.Application.OutResults.Queries;
|
||||||
|
|
||||||
namespace ReC.API.Controllers;
|
namespace ReC.API.Controllers;
|
||||||
@@ -55,6 +56,34 @@ public class OutResController(IMediator mediator, IConfiguration config) : Contr
|
|||||||
_ => Ok(res),
|
_ => Ok(res),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes output results based on the provided criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">The command containing the deletion criteria, such as ActionId or ProfileId.</param>
|
||||||
|
/// <param name="cancel">A token to cancel the operation.</param>
|
||||||
|
/// <returns>An empty response indicating success.</returns>
|
||||||
|
[HttpDelete]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
public async Task<IActionResult> Delete([FromQuery] DeleteOutResCommand command, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
await mediator.Send(command, cancel);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes all output results for a fake/test profile.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cancel">A token to cancel the operation.</param>
|
||||||
|
/// <returns>An empty response indicating success.</returns>
|
||||||
|
[HttpDelete("fake")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
public async Task<IActionResult> Delete(CancellationToken cancel)
|
||||||
|
{
|
||||||
|
await mediator.Send(new DeleteOutResCommand() { ProfileId = config.GetFakeProfileId() }, cancel);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using ReC.API.Extensions;
|
using ReC.API.Extensions;
|
||||||
using ReC.API.Models;
|
using ReC.API.Models;
|
||||||
using ReC.Application.RecActions.Commands;
|
using ReC.Application.RecActions.Commands;
|
||||||
using ReC.Application.RecActions.Queries;
|
using ReC.Application.RecActionViews.Commands;
|
||||||
|
using ReC.Application.RecActionViews.Queries;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace ReC.API.Controllers;
|
namespace ReC.API.Controllers;
|
||||||
@@ -18,11 +19,11 @@ public class RecActionController(IMediator mediator, IConfiguration config) : Co
|
|||||||
/// <param name="profileId">The ID of the profile.</param>
|
/// <param name="profileId">The ID of the profile.</param>
|
||||||
/// <param name="cancel">A token to cancel the operation.</param>
|
/// <param name="cancel">A token to cancel the operation.</param>
|
||||||
/// <returns>An HTTP 202 Accepted response indicating the process has been started.</returns>
|
/// <returns>An HTTP 202 Accepted response indicating the process has been started.</returns>
|
||||||
[HttpPost("invoke/{cmd}")]
|
[HttpPost("invoke/{profileId}")]
|
||||||
[ProducesResponseType(StatusCodes.Status202Accepted)]
|
[ProducesResponseType(StatusCodes.Status202Accepted)]
|
||||||
public async Task<IActionResult> Invoke([FromRoute] int profileId, CancellationToken cancel)
|
public async Task<IActionResult> Invoke([FromRoute] int profileId, CancellationToken cancel)
|
||||||
{
|
{
|
||||||
await mediator.InvokeBatchRecAction(profileId, cancel);
|
await mediator.InvokeBatchRecActionView(profileId, cancel);
|
||||||
return Accepted();
|
return Accepted();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ public class RecActionController(IMediator mediator, IConfiguration config) : Co
|
|||||||
[ProducesResponseType(StatusCodes.Status202Accepted)]
|
[ProducesResponseType(StatusCodes.Status202Accepted)]
|
||||||
public async Task<IActionResult> Invoke(CancellationToken cancel)
|
public async Task<IActionResult> Invoke(CancellationToken cancel)
|
||||||
{
|
{
|
||||||
await mediator.InvokeBatchRecAction(config.GetFakeProfileId(), cancel);
|
await mediator.InvokeBatchRecActionView(config.GetFakeProfileId(), cancel);
|
||||||
return Accepted();
|
return Accepted();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,12 +44,12 @@ public class RecActionController(IMediator mediator, IConfiguration config) : Co
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets all RecActions for a given profile.
|
/// Gets all RecActions for a given profile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="profileId">The ID of the profile.</param>
|
/// <param name="query"></param>
|
||||||
/// <param name="cancel">A token to cancel the operation.</param>
|
/// <param name="cancel">A token to cancel the operation.</param>
|
||||||
/// <returns>A list of RecActions for the specified profile.</returns>
|
/// <returns>A list of RecActions for the specified profile.</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public async Task<IActionResult> Get([FromQuery] ReadRecActionQuery query, CancellationToken cancel) => Ok(await mediator.Send(query, cancel));
|
public async Task<IActionResult> Get([FromQuery] ReadRecActionViewQuery query, CancellationToken cancel) => Ok(await mediator.Send(query, cancel));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets all RecActions for a fake/test profile.
|
/// Gets all RecActions for a fake/test profile.
|
||||||
@@ -58,7 +59,7 @@ public class RecActionController(IMediator mediator, IConfiguration config) : Co
|
|||||||
/// <returns>A list of RecActions for the fake profile.</returns>
|
/// <returns>A list of RecActions for the fake profile.</returns>
|
||||||
[HttpGet("fake")]
|
[HttpGet("fake")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public async Task<IActionResult> Get(CancellationToken cancel, [FromQuery] bool invoked = false) => Ok(await mediator.Send(new ReadRecActionQuery()
|
public async Task<IActionResult> Get(CancellationToken cancel, [FromQuery] bool invoked = false) => Ok(await mediator.Send(new ReadRecActionViewQuery()
|
||||||
{
|
{
|
||||||
ProfileId = config.GetFakeProfileId(),
|
ProfileId = config.GetFakeProfileId(),
|
||||||
Invoked = invoked
|
Invoked = invoked
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
using Microsoft.AspNetCore.Rewrite;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NLog.Web;
|
using NLog.Web;
|
||||||
using ReC.API.Middleware;
|
using ReC.API.Middleware;
|
||||||
using ReC.Application;
|
using ReC.Application;
|
||||||
using ReC.Infrastructure;
|
using ReC.Infrastructure;
|
||||||
|
using System.Reflection;
|
||||||
using LogLevel = Microsoft.Extensions.Logging.LogLevel;
|
using LogLevel = Microsoft.Extensions.Logging.LogLevel;
|
||||||
|
|
||||||
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
||||||
@@ -48,7 +50,12 @@ try
|
|||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddSwaggerGen();
|
builder.Services.AddSwaggerGen(c =>
|
||||||
|
{
|
||||||
|
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||||
|
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
||||||
|
c.IncludeXmlComments(xmlPath);
|
||||||
|
});
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
@@ -57,10 +64,13 @@ try
|
|||||||
#pragma warning restore CS0618
|
#pragma warning restore CS0618
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment() || config.GetValue<bool>("UseSwagger"))
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI();
|
app.UseSwaggerUI();
|
||||||
|
|
||||||
|
var rewriteOptions = new RewriteOptions().AddRedirect("^$", "swagger");
|
||||||
|
app.UseRewriter(rewriteOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|||||||
@@ -10,13 +10,15 @@
|
|||||||
<Product>ReC.API</Product>
|
<Product>ReC.API</Product>
|
||||||
<PackageIcon>Assets\icon.ico</PackageIcon>
|
<PackageIcon>Assets\icon.ico</PackageIcon>
|
||||||
<PackageTags>digital data rest-caller rec api</PackageTags>
|
<PackageTags>digital data rest-caller rec api</PackageTags>
|
||||||
<Version>1.0.0-beta</Version>
|
<Version>1.0.3-beta</Version>
|
||||||
<AssemblyVersion>1.0.0.0</AssemblyVersion>
|
<AssemblyVersion>1.0.3.0</AssemblyVersion>
|
||||||
<FileVersion>1.0.0.0</FileVersion>
|
<FileVersion>1.0.3.0</FileVersion>
|
||||||
<InformationalVersion>1.0.0-beta</InformationalVersion>
|
<InformationalVersion>1.0.3-beta</InformationalVersion>
|
||||||
<Copyright>Copyright © 2025 Digital Data GmbH. All rights reserved.</Copyright>
|
<Copyright>Copyright © 2025 Digital Data GmbH. All rights reserved.</Copyright>
|
||||||
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.11" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.11" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"UseSwagger": true,
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"Default": "Server=SDD-VMP04-SQL19\\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;"
|
"Default": "Server=SDD-VMP04-SQL19\\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
namespace ReC.Application.Common.Behaviors;
|
namespace ReC.Application.Common.Behaviors;
|
||||||
|
|
||||||
public class BodyQueryBehavior<TRequest, TResponse>(IRecDbContext dbContext) : IPipelineBehavior<TRequest, TResponse>
|
public class BodyQueryBehavior<TRequest, TResponse>(IRecDbContext dbContext) : IPipelineBehavior<TRequest, TResponse>
|
||||||
where TRequest : RecActionDto
|
where TRequest : RecActionViewDto
|
||||||
where TResponse : notnull
|
where TResponse : notnull
|
||||||
{
|
{
|
||||||
public async Task<TResponse> Handle(TRequest action, RequestHandlerDelegate<TResponse> next, CancellationToken cancel)
|
public async Task<TResponse> Handle(TRequest action, RequestHandlerDelegate<TResponse> next, CancellationToken cancel)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using System.Text.Json;
|
|||||||
namespace ReC.Application.Common.Behaviors;
|
namespace ReC.Application.Common.Behaviors;
|
||||||
|
|
||||||
public class HeaderQueryBehavior<TRequest, TResponse>(IRecDbContext dbContext, ILogger<HeaderQueryBehavior<TRequest, TResponse>>? logger = null) : IPipelineBehavior<TRequest, TResponse>
|
public class HeaderQueryBehavior<TRequest, TResponse>(IRecDbContext dbContext, ILogger<HeaderQueryBehavior<TRequest, TResponse>>? logger = null) : IPipelineBehavior<TRequest, TResponse>
|
||||||
where TRequest : RecActionDto
|
where TRequest : RecActionViewDto
|
||||||
where TResponse : notnull
|
where TResponse : notnull
|
||||||
{
|
{
|
||||||
public async Task<TResponse> Handle(TRequest action, RequestHandlerDelegate<TResponse> next, CancellationToken cancel)
|
public async Task<TResponse> Handle(TRequest action, RequestHandlerDelegate<TResponse> next, CancellationToken cancel)
|
||||||
|
|||||||
6
src/ReC.Application/Common/Constants/Http.cs
Normal file
6
src/ReC.Application/Common/Constants/Http.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace ReC.Application.Common.Constants;
|
||||||
|
|
||||||
|
public static class Http
|
||||||
|
{
|
||||||
|
public static readonly string ClientName = "HttpClient-" + Guid.NewGuid().ToString();
|
||||||
|
}
|
||||||
32
src/ReC.Application/Common/Dto/ConnectionDto.cs
Normal file
32
src/ReC.Application/Common/Dto/ConnectionDto.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
namespace ReC.Application.Common.Dto;
|
||||||
|
|
||||||
|
public record ConnectionDto
|
||||||
|
{
|
||||||
|
public short? Id { get; set; }
|
||||||
|
|
||||||
|
public string? Bezeichnung { get; set; }
|
||||||
|
|
||||||
|
public string? SqlProvider { get; set; }
|
||||||
|
|
||||||
|
public string? Server { get; set; }
|
||||||
|
|
||||||
|
public string? Datenbank { get; set; }
|
||||||
|
|
||||||
|
public string? Username { get; set; }
|
||||||
|
|
||||||
|
public string? Password { get; set; }
|
||||||
|
|
||||||
|
public string? Bemerkung { get; set; }
|
||||||
|
|
||||||
|
public bool? Aktiv { get; set; }
|
||||||
|
|
||||||
|
public string? ErstelltWer { get; set; }
|
||||||
|
|
||||||
|
public DateTime? ErstelltWann { get; set; }
|
||||||
|
|
||||||
|
public string? GeandertWer { get; set; }
|
||||||
|
|
||||||
|
public DateTime? GeaendertWann { get; set; }
|
||||||
|
|
||||||
|
public bool? SysConnection { get; set; }
|
||||||
|
}
|
||||||
@@ -6,7 +6,15 @@ public class DtoMappingProfile : AutoMapper.Profile
|
|||||||
{
|
{
|
||||||
public DtoMappingProfile()
|
public DtoMappingProfile()
|
||||||
{
|
{
|
||||||
CreateMap<RecActionView, RecActionDto>();
|
CreateMap<RecActionView, RecActionViewDto>();
|
||||||
CreateMap<OutRes, OutResDto>();
|
CreateMap<OutRes, OutResDto>();
|
||||||
|
|
||||||
|
|
||||||
|
CreateMap<Connection, ConnectionDto>();
|
||||||
|
CreateMap<EndpointAuth, EndpointAuthDto>();
|
||||||
|
CreateMap<Endpoint, EndpointDto>();
|
||||||
|
CreateMap<EndpointParam, EndpointParamDto>();
|
||||||
|
CreateMap<Profile, ProfileDto>();
|
||||||
|
CreateMap<RecAction, RecActionDto>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
40
src/ReC.Application/Common/Dto/EndpointAuthDto.cs
Normal file
40
src/ReC.Application/Common/Dto/EndpointAuthDto.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using ReC.Domain.Constants;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace ReC.Application.Common.Dto;
|
||||||
|
|
||||||
|
[Table("TBREC_CFG_ENDPOINT_AUTH")]
|
||||||
|
public record EndpointAuthDto
|
||||||
|
{
|
||||||
|
public long? Id { get; set; }
|
||||||
|
|
||||||
|
public bool? Active { get; set; }
|
||||||
|
|
||||||
|
public string? Description { get; set; }
|
||||||
|
|
||||||
|
public EndpointAuthType? Type { get; set; }
|
||||||
|
|
||||||
|
public string? ApiKey { get; set; }
|
||||||
|
|
||||||
|
public string? ApiValue { get; set; }
|
||||||
|
|
||||||
|
public ApiKeyLocation? ApiKeyAddTo { get; set; }
|
||||||
|
|
||||||
|
public string? Token { get; set; }
|
||||||
|
|
||||||
|
public string? Username { get; set; }
|
||||||
|
|
||||||
|
public string? Password { get; set; }
|
||||||
|
|
||||||
|
public string? Domain { get; set; }
|
||||||
|
|
||||||
|
public string? Workstation { get; set; }
|
||||||
|
|
||||||
|
public string? AddedWho { get; set; }
|
||||||
|
|
||||||
|
public DateTime? AddedWhen { get; set; }
|
||||||
|
|
||||||
|
public string? ChangedWho { get; set; }
|
||||||
|
|
||||||
|
public DateTime? ChangedWhen { get; set; }
|
||||||
|
}
|
||||||
22
src/ReC.Application/Common/Dto/EndpointDto.cs
Normal file
22
src/ReC.Application/Common/Dto/EndpointDto.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace ReC.Application.Common.Dto;
|
||||||
|
|
||||||
|
public record EndpointDto
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
public bool? Active { get; set; }
|
||||||
|
|
||||||
|
public string? Description { get; set; }
|
||||||
|
|
||||||
|
public string? Uri { get; set; }
|
||||||
|
|
||||||
|
public string? AddedWho { get; set; }
|
||||||
|
|
||||||
|
public DateTime? AddedWhen { get; set; }
|
||||||
|
|
||||||
|
public string? ChangedWho { get; set; }
|
||||||
|
|
||||||
|
public DateTime? ChangedWhen { get; set; }
|
||||||
|
}
|
||||||
33
src/ReC.Application/Common/Dto/EndpointParamDto.cs
Normal file
33
src/ReC.Application/Common/Dto/EndpointParamDto.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace ReC.Application.Common.Dto;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the TBREC_CFG_ENDPOINT_PARAMS table.
|
||||||
|
/// All properties are nullable to provide flexibility on the database side,
|
||||||
|
/// preventing breaking changes if columns are altered to be nullable in production.
|
||||||
|
/// </summary>
|
||||||
|
public record EndpointParamDto
|
||||||
|
{
|
||||||
|
public long? Id { get; set; }
|
||||||
|
|
||||||
|
public bool? Active { get; set; }
|
||||||
|
|
||||||
|
public string? Description { get; set; }
|
||||||
|
|
||||||
|
public short? GroupId { get; set; }
|
||||||
|
|
||||||
|
public byte? Sequence { get; set; }
|
||||||
|
|
||||||
|
public string? Key { get; set; }
|
||||||
|
|
||||||
|
public string? Value { get; set; }
|
||||||
|
|
||||||
|
public string? AddedWho { get; set; }
|
||||||
|
|
||||||
|
public DateTime? AddedWhen { get; set; }
|
||||||
|
|
||||||
|
public string? ChangedWho { get; set; }
|
||||||
|
|
||||||
|
public DateTime? ChangedWhen { get; set; }
|
||||||
|
}
|
||||||
31
src/ReC.Application/Common/Dto/ProfileDto.cs
Normal file
31
src/ReC.Application/Common/Dto/ProfileDto.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace ReC.Application.Common.Dto;
|
||||||
|
|
||||||
|
[Table("TBREC_CFG_PROFILE", Schema = "dbo")]
|
||||||
|
public record ProfileDto
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
public bool? Active { get; set; }
|
||||||
|
|
||||||
|
public string? Type { get; set; }
|
||||||
|
|
||||||
|
public string? Mandantor { get; set; }
|
||||||
|
|
||||||
|
public string? Name { get; set; }
|
||||||
|
|
||||||
|
public string? Description { get; set; }
|
||||||
|
|
||||||
|
public string? LogLevel { get; set; }
|
||||||
|
|
||||||
|
public string? Language { get; set; }
|
||||||
|
|
||||||
|
public string? AddedWho { get; set; }
|
||||||
|
|
||||||
|
public DateTime? AddedWhen { get; set; }
|
||||||
|
|
||||||
|
public string? ChangedWho { get; set; }
|
||||||
|
|
||||||
|
public DateTime? ChangedWhen { get; set; }
|
||||||
|
}
|
||||||
@@ -1,76 +1,54 @@
|
|||||||
namespace ReC.Application.Common.Dto;
|
using ReC.Domain.Constants;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace ReC.Application.Common.Dto;
|
||||||
|
|
||||||
|
[Table("TBREC_CFG_ACTION")]
|
||||||
public record RecActionDto
|
public record RecActionDto
|
||||||
{
|
{
|
||||||
public required long Id { get; init; }
|
public long? Id { get; set; }
|
||||||
|
|
||||||
public long? ProfileId { get; init; }
|
public long? ProfileId { get; set; }
|
||||||
|
|
||||||
public string? ProfileName { get; init; }
|
public ProfileDto? Profile { get; set; }
|
||||||
|
|
||||||
public string? ProfileType { get; init; }
|
public bool? Active { get; set; }
|
||||||
|
|
||||||
public byte? ProfileSequence { get; init; }
|
public byte? Sequence { get; set; }
|
||||||
|
|
||||||
public long? EndpointId { get; init; }
|
public long? EndpointId { get; set; }
|
||||||
|
|
||||||
public string? EndpointUri { get; init; }
|
public EndpointDto? Endpoint { get; set; }
|
||||||
|
|
||||||
public long? EndpointAuthId { get; init; }
|
public long? EndpointAuthId { get; set; }
|
||||||
|
|
||||||
public string? EndpointAuthType { get; init; }
|
public EndpointAuthDto? EndpointAuth { get; set; }
|
||||||
|
|
||||||
public string? EndpointAuthApiKey { get; init; }
|
public short? EndpointParamsId { get; set; }
|
||||||
|
|
||||||
public string? EndpointAuthApiValue { get; init; }
|
public short? SqlConnectionId { get; set; }
|
||||||
|
|
||||||
public string? EndpointAuthApiKeyAddTo { get; init; }
|
public ConnectionDto? SqlConnection { get; set; }
|
||||||
|
|
||||||
public string? EndpointAuthToken { get; init; }
|
public string? Type { get; set; }
|
||||||
|
|
||||||
public string? EndpointAuthUsername { get; init; }
|
public string? PreprocessingQuery { get; set; }
|
||||||
|
|
||||||
public string? EndpointAuthPassword { get; init; }
|
public string? HeaderQuery { get; set; }
|
||||||
|
|
||||||
public string? EndpointAuthDomain { get; init; }
|
public string? BodyQuery { get; set; }
|
||||||
|
|
||||||
public string? EndpointAuthWorkstation { get; init; }
|
public string? PostprocessingQuery { get; set; }
|
||||||
|
|
||||||
public short? EndpointParamsId { get; init; }
|
public ErrorAction? ErrorAction { get; set; }
|
||||||
|
|
||||||
public short? SqlConnectionId { get; init; }
|
public string? AddedWho { get; set; }
|
||||||
|
|
||||||
public string? SqlConnectionServer { get; init; }
|
public DateTime? AddedWhen { get; set; }
|
||||||
|
|
||||||
public string? SqlConnectionDb { get; init; }
|
public string? ChangedWho { get; set; }
|
||||||
|
|
||||||
public string? SqlConnectionUsername { get; init; }
|
public DateTime? ChangedWhen { get; set; }
|
||||||
|
|
||||||
public string? SqlConnectionPassword { get; init; }
|
public OutResDto? OutRes { get; set; }
|
||||||
|
|
||||||
public string? RestType { get; init; }
|
|
||||||
|
|
||||||
public string? PreprocessingQuery { get; init; }
|
|
||||||
|
|
||||||
public string? HeaderQuery { get; init; }
|
|
||||||
|
|
||||||
public Dictionary<string, string>? Headers { get; set; }
|
|
||||||
|
|
||||||
public string? BodyQuery { get; init; }
|
|
||||||
|
|
||||||
public string? Body { get; set; }
|
|
||||||
|
|
||||||
public string? PostprocessingQuery { get; init; }
|
|
||||||
|
|
||||||
public UriBuilder ToEndpointUriBuilder()
|
|
||||||
{
|
|
||||||
var builder = EndpointUri is null ? new UriBuilder() : new UriBuilder(EndpointUri);
|
|
||||||
|
|
||||||
builder.Port = -1;
|
|
||||||
|
|
||||||
if (ProfileType is not null)
|
|
||||||
builder.Scheme = ProfileType;
|
|
||||||
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
80
src/ReC.Application/Common/Dto/RecActionViewDto.cs
Normal file
80
src/ReC.Application/Common/Dto/RecActionViewDto.cs
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
using ReC.Domain.Constants;
|
||||||
|
|
||||||
|
namespace ReC.Application.Common.Dto;
|
||||||
|
|
||||||
|
public record RecActionViewDto
|
||||||
|
{
|
||||||
|
public required long Id { get; init; }
|
||||||
|
|
||||||
|
public long? ProfileId { get; init; }
|
||||||
|
|
||||||
|
public string? ProfileName { get; init; }
|
||||||
|
|
||||||
|
public string? ProfileType { get; init; }
|
||||||
|
|
||||||
|
public byte? ProfileSequence { get; init; }
|
||||||
|
|
||||||
|
public long? EndpointId { get; init; }
|
||||||
|
|
||||||
|
public string? EndpointUri { get; init; }
|
||||||
|
|
||||||
|
public long? EndpointAuthId { get; init; }
|
||||||
|
|
||||||
|
public EndpointAuthType? EndpointAuthType { get; init; }
|
||||||
|
|
||||||
|
public string? EndpointAuthApiKey { get; init; }
|
||||||
|
|
||||||
|
public string? EndpointAuthApiValue { get; init; }
|
||||||
|
|
||||||
|
public ApiKeyLocation? EndpointAuthApiKeyAddTo { get; init; }
|
||||||
|
|
||||||
|
public string? EndpointAuthToken { get; init; }
|
||||||
|
|
||||||
|
public string? EndpointAuthUsername { get; init; }
|
||||||
|
|
||||||
|
public string? EndpointAuthPassword { get; init; }
|
||||||
|
|
||||||
|
public string? EndpointAuthDomain { get; init; }
|
||||||
|
|
||||||
|
public string? EndpointAuthWorkstation { get; init; }
|
||||||
|
|
||||||
|
public short? EndpointParamsId { get; init; }
|
||||||
|
|
||||||
|
public short? SqlConnectionId { get; init; }
|
||||||
|
|
||||||
|
public string? SqlConnectionServer { get; init; }
|
||||||
|
|
||||||
|
public string? SqlConnectionDb { get; init; }
|
||||||
|
|
||||||
|
public string? SqlConnectionUsername { get; init; }
|
||||||
|
|
||||||
|
public string? SqlConnectionPassword { get; init; }
|
||||||
|
|
||||||
|
public string? RestType { get; init; }
|
||||||
|
|
||||||
|
public string? PreprocessingQuery { get; init; }
|
||||||
|
|
||||||
|
public string? HeaderQuery { get; init; }
|
||||||
|
|
||||||
|
public Dictionary<string, string>? Headers { get; set; }
|
||||||
|
|
||||||
|
public string? BodyQuery { get; init; }
|
||||||
|
|
||||||
|
public string? Body { get; set; }
|
||||||
|
|
||||||
|
public string? PostprocessingQuery { get; init; }
|
||||||
|
|
||||||
|
public ErrorAction ErrorAction { get; init; }
|
||||||
|
|
||||||
|
public UriBuilder ToEndpointUriBuilder()
|
||||||
|
{
|
||||||
|
var builder = EndpointUri is null ? new UriBuilder() : new UriBuilder(EndpointUri);
|
||||||
|
|
||||||
|
builder.Port = -1;
|
||||||
|
|
||||||
|
if (ProfileType is not null)
|
||||||
|
builder.Scheme = ProfileType;
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,15 +5,25 @@ namespace ReC.Application.Common.Interfaces;
|
|||||||
|
|
||||||
public interface IRecDbContext
|
public interface IRecDbContext
|
||||||
{
|
{
|
||||||
public DbSet<EndpointParam> EndpointParams { get; }
|
public DbSet<EndpointParam> EndpointParams { get; set; }
|
||||||
|
|
||||||
public DbSet<RecActionView> Actions { get; }
|
public DbSet<RecActionView> RecActionViews { get; set; }
|
||||||
|
|
||||||
public DbSet<OutRes> OutRes { get; }
|
public DbSet<OutRes> OutRes { get; set; }
|
||||||
|
|
||||||
public DbSet<HeaderQueryResult> HeaderQueryResults { get; }
|
public DbSet<HeaderQueryResult> HeaderQueryResults { get; set; }
|
||||||
|
|
||||||
public DbSet<BodyQueryResult> BodyQueryResults { get; }
|
public DbSet<BodyQueryResult> BodyQueryResults { get; set; }
|
||||||
|
|
||||||
|
public DbSet<ConnectionDto> Connections { get; set; }
|
||||||
|
|
||||||
|
public DbSet<EndpointDto> Endpoints { get; set; }
|
||||||
|
|
||||||
|
public DbSet<EndpointAuthDto> EndpointAuths { get; set; }
|
||||||
|
|
||||||
|
public DbSet<ProfileDto> Profiles { get; set; }
|
||||||
|
|
||||||
|
public DbSet<RecActionDto> RecActions { get; set; }
|
||||||
|
|
||||||
public Task<int> SaveChangesAsync(CancellationToken cancel = default);
|
public Task<int> SaveChangesAsync(CancellationToken cancel = default);
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
using MediatR;
|
using FluentValidation;
|
||||||
|
using MediatR;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using ReC.Application.Common.Behaviors;
|
using ReC.Application.Common.Behaviors;
|
||||||
|
using ReC.Application.Common.Constants;
|
||||||
using ReC.Application.Common.Options;
|
using ReC.Application.Common.Options;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using FluentValidation;
|
|
||||||
|
|
||||||
namespace ReC.Application;
|
namespace ReC.Application;
|
||||||
|
|
||||||
@@ -35,7 +36,11 @@ public static class DependencyInjection
|
|||||||
cfg.LicenseKey = configOpt.LuckyPennySoftwareLicenseKey;
|
cfg.LicenseKey = configOpt.LuckyPennySoftwareLicenseKey;
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddHttpClient();
|
services.AddHttpClient(Http.ClientName)
|
||||||
|
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
|
||||||
|
{
|
||||||
|
UseDefaultCredentials = false
|
||||||
|
});
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ using ReC.Domain.Entities;
|
|||||||
|
|
||||||
namespace ReC.Application.Endpoints.Commands;
|
namespace ReC.Application.Endpoints.Commands;
|
||||||
|
|
||||||
public class ObtainEndpointCommand : IRequest<Endpoint>
|
public class ObtainEndpointCommand : IRequest<EndpointDto>
|
||||||
{
|
{
|
||||||
public string Uri { get; init; } = null!;
|
public string Uri { get; init; } = null!;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ObtainEndpointCommandHandler(IRepository<Endpoint> repo) : IRequestHandler<ObtainEndpointCommand, Endpoint>
|
public class ObtainEndpointCommandHandler(IRepository<EndpointDto> repo) : IRequestHandler<ObtainEndpointCommand, EndpointDto>
|
||||||
{
|
{
|
||||||
public async Task<Endpoint> Handle(ObtainEndpointCommand request, CancellationToken cancel)
|
public async Task<EndpointDto> Handle(ObtainEndpointCommand request, CancellationToken cancel)
|
||||||
{
|
{
|
||||||
var endpoint = await repo.Where(e => e.Uri == request.Uri).FirstOrDefaultAsync(cancel);
|
var endpoint = await repo.Where(e => e.Uri == request.Uri).FirstOrDefaultAsync(cancel);
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class MappingProfile : AutoMapper.Profile
|
|||||||
{
|
{
|
||||||
public MappingProfile()
|
public MappingProfile()
|
||||||
{
|
{
|
||||||
CreateMap<ObtainEndpointCommand, Endpoint>()
|
CreateMap<ObtainEndpointCommand, EndpointDto>()
|
||||||
.ForMember(e => e.Active, exp => exp.MapFrom(cmd => true))
|
.ForMember(e => e.Active, exp => exp.MapFrom(cmd => true))
|
||||||
.ForMember(e => e.AddedWhen, exp => exp.MapFrom(cmd => DateTime.UtcNow))
|
.ForMember(e => e.AddedWhen, exp => exp.MapFrom(cmd => DateTime.UtcNow))
|
||||||
.ForMember(e => e.AddedWho, exp => exp.MapFrom(cmd => "ReC.API"));
|
.ForMember(e => e.AddedWho, exp => exp.MapFrom(cmd => "ReC.API"));
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ public class CreateOutResCommand : IRequest
|
|||||||
{
|
{
|
||||||
public required long ActionId { get; set; }
|
public required long ActionId { get; set; }
|
||||||
|
|
||||||
|
public short? Status { get; set; }
|
||||||
|
|
||||||
|
public string? Message { get; set; }
|
||||||
|
|
||||||
public string? Header { get; set; }
|
public string? Header { get; set; }
|
||||||
|
|
||||||
public string? Body { get; set; }
|
public string? Body { get; set; }
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
using DigitalData.Core.Abstraction.Application.Repository;
|
||||||
|
using MediatR;
|
||||||
|
using ReC.Domain.Entities;
|
||||||
|
|
||||||
|
namespace ReC.Application.OutResults.Commands;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the command to delete output results based on specified criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Deletion can be performed by providing either an <see cref="ActionId"/> or a <see cref="ProfileId"/>.
|
||||||
|
/// At least one of these properties must be set for the operation to proceed.
|
||||||
|
/// </remarks>
|
||||||
|
public record DeleteOutResCommand : IRequest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the unique identifier for the action whose output results should be deleted.
|
||||||
|
/// </summary>
|
||||||
|
public long? ActionId { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the unique identifier for the profile whose associated action's output results should be deleted.
|
||||||
|
/// </summary>
|
||||||
|
public long? ProfileId { get; init; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the execution of the <see cref="DeleteOutResCommand"/>.
|
||||||
|
/// </summary>
|
||||||
|
public class DeleteOutResCommandHandler(IRepository<OutRes> repo) : IRequestHandler<DeleteOutResCommand>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the delete command by removing matching <see cref="OutRes"/> entities from the repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The command containing the deletion criteria.</param>
|
||||||
|
/// <param name="cancel">A cancellation token that can be used to cancel the work.</param>
|
||||||
|
/// <returns>A task that represents the asynchronous delete operation.</returns>
|
||||||
|
/// <remarks>
|
||||||
|
/// The handler deletes records where <c>OutRes.ActionId</c> matches <see cref="DeleteOutResCommand.ActionId"/>
|
||||||
|
/// or where the associated <c>Action.ProfileId</c> matches <see cref="DeleteOutResCommand.ProfileId"/>.
|
||||||
|
/// </remarks>
|
||||||
|
public Task Handle(DeleteOutResCommand request, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
return repo.DeleteAsync(x => x.ActionId == request.ActionId || x.Action!.ProfileId == request.ProfileId, cancel);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace ReC.Application.OutResults.Commands;
|
||||||
|
|
||||||
|
public class DeleteOutResCommandValidator : AbstractValidator<DeleteOutResCommand>
|
||||||
|
{
|
||||||
|
public DeleteOutResCommandValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x => x)
|
||||||
|
.Must(x => x.ActionId.HasValue || x.ProfileId.HasValue)
|
||||||
|
.WithMessage("At least one of ActionId or ProfileId must be provided.")
|
||||||
|
.WithName("Identifier");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using MediatR;
|
||||||
|
using ReC.Application.RecActionViews.Queries;
|
||||||
|
using ReC.Domain.Constants;
|
||||||
|
|
||||||
|
namespace ReC.Application.RecActionViews.Commands;
|
||||||
|
|
||||||
|
public record InvokeBatchRecActionViewsCommand : ReadRecActionQueryBase, IRequest;
|
||||||
|
|
||||||
|
public static class InvokeBatchRecActionViewsCommandExtensions
|
||||||
|
{
|
||||||
|
public static Task InvokeBatchRecActionView(this ISender sender, long profileId, CancellationToken cancel = default)
|
||||||
|
=> sender.Send(new InvokeBatchRecActionViewsCommand { ProfileId = profileId }, cancel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class InvokeRecActionViewsCommandHandler(ISender sender) : IRequestHandler<InvokeBatchRecActionViewsCommand>
|
||||||
|
{
|
||||||
|
public async Task Handle(InvokeBatchRecActionViewsCommand request, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
var actions = await sender.Send(request.ToReadQuery(q => q.Invoked = false), cancel);
|
||||||
|
|
||||||
|
foreach (var action in actions)
|
||||||
|
{
|
||||||
|
var ok = await sender.Send(action.ToInvokeCommand(), cancel);
|
||||||
|
if (!ok)
|
||||||
|
switch (action.ErrorAction)
|
||||||
|
{
|
||||||
|
case ErrorAction.Continue:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
using MediatR;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using ReC.Application.Common;
|
||||||
|
using ReC.Application.Common.Constants;
|
||||||
|
using ReC.Application.Common.Dto;
|
||||||
|
using ReC.Application.Common.Exceptions;
|
||||||
|
using ReC.Application.OutResults.Commands;
|
||||||
|
using ReC.Domain.Constants;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace ReC.Application.RecActionViews.Commands;
|
||||||
|
|
||||||
|
public record InvokeRecActionViewCommand : IRequest<bool>
|
||||||
|
{
|
||||||
|
public RecActionViewDto Action { get; set; } = null!;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class InvokeRecActionViewCommandExtensions
|
||||||
|
{
|
||||||
|
public static InvokeRecActionViewCommand ToInvokeCommand(this RecActionViewDto dto) => new() { Action = dto };
|
||||||
|
}
|
||||||
|
|
||||||
|
public class InvokeRecActionViewCommandHandler(
|
||||||
|
ISender sender,
|
||||||
|
IHttpClientFactory clientFactory,
|
||||||
|
IConfiguration? config = null
|
||||||
|
) : IRequestHandler<InvokeRecActionViewCommand, bool>
|
||||||
|
{
|
||||||
|
public async Task<bool> Handle(InvokeRecActionViewCommand request, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
var action = request.Action;
|
||||||
|
|
||||||
|
using var http = clientFactory.CreateClient(Http.ClientName);
|
||||||
|
|
||||||
|
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 = action.RestType
|
||||||
|
.ToHttpMethod()
|
||||||
|
.ToHttpRequestMessage(action.EndpointUri);
|
||||||
|
|
||||||
|
if (action.Body is not null)
|
||||||
|
{
|
||||||
|
using var reqBody = new StringContent(action.Body);
|
||||||
|
httpReq.Content = reqBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action.Headers is not null)
|
||||||
|
foreach (var header in action.Headers)
|
||||||
|
httpReq.Headers.Add(header.Key, header.Value);
|
||||||
|
|
||||||
|
switch (action.EndpointAuthType)
|
||||||
|
{
|
||||||
|
case EndpointAuthType.NoAuth:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EndpointAuthType.ApiKey:
|
||||||
|
if (action.EndpointAuthApiKey is string apiKey && action.EndpointAuthApiValue is string apiValue)
|
||||||
|
{
|
||||||
|
switch (action.EndpointAuthApiKeyAddTo)
|
||||||
|
{
|
||||||
|
case ApiKeyLocation.Header:
|
||||||
|
httpReq.Headers.Add(apiKey, apiValue);
|
||||||
|
break;
|
||||||
|
case ApiKeyLocation.Query:
|
||||||
|
var uriBuilder = new UriBuilder(httpReq.RequestUri!);
|
||||||
|
var query = System.Web.HttpUtility.ParseQueryString(uriBuilder.Query);
|
||||||
|
query[apiKey] = apiValue;
|
||||||
|
uriBuilder.Query = query.ToString();
|
||||||
|
httpReq.RequestUri = uriBuilder.Uri;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new DataIntegrityException(
|
||||||
|
$"The API key location '{action.EndpointAuthApiKeyAddTo}' is not supported. " +
|
||||||
|
$"ProfileId: {action.ProfileId}, " +
|
||||||
|
$"Id: {action.Id}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EndpointAuthType.BearerToken:
|
||||||
|
case EndpointAuthType.JwtBearer:
|
||||||
|
case EndpointAuthType.OAuth2:
|
||||||
|
if (action.EndpointAuthToken is string authToken)
|
||||||
|
httpReq.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authToken);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EndpointAuthType.BasicAuth:
|
||||||
|
if (action.EndpointAuthUsername is string authUsername && action.EndpointAuthPassword is string authPassword)
|
||||||
|
{
|
||||||
|
var basicAuth = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{authUsername}:{authPassword}"));
|
||||||
|
httpReq.Headers.Authorization = new AuthenticationHeaderValue("Basic", basicAuth);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EndpointAuthType.NtlmAuth:
|
||||||
|
if (!string.IsNullOrWhiteSpace(action.EndpointAuthUsername))
|
||||||
|
{
|
||||||
|
var credentials = new NetworkCredential(
|
||||||
|
action.EndpointAuthUsername,
|
||||||
|
action.EndpointAuthPassword,
|
||||||
|
action.EndpointAuthDomain);
|
||||||
|
var credentialCache = new CredentialCache { { httpReq.RequestUri!, "NTLM", credentials } };
|
||||||
|
httpReq.Options.Set(new HttpRequestOptionsKey<CredentialCache>("Credentials"), credentialCache);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EndpointAuthType.DigestAuth:
|
||||||
|
case EndpointAuthType.OAuth1:
|
||||||
|
case EndpointAuthType.AwsSignature:
|
||||||
|
// These authentication methods require more complex implementations,
|
||||||
|
// often involving multi-step handshakes or specialized libraries.
|
||||||
|
// They are left as placeholders for future implementation.
|
||||||
|
default:
|
||||||
|
throw new NotImplementedException(
|
||||||
|
$"The authentication type '{action.EndpointAuthType}' is not supported yet. " +
|
||||||
|
$"ProfileId: {action.ProfileId}, " +
|
||||||
|
$"Id: {action.Id}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
using var response = await http.SendAsync(httpReq, cancel);
|
||||||
|
var resBody = await response.Content.ReadAsStringAsync(cancel);
|
||||||
|
var resHeaders = response.Headers.ToDictionary();
|
||||||
|
|
||||||
|
var statusCode = (short)response.StatusCode;
|
||||||
|
|
||||||
|
await sender.Send(new CreateOutResCommand
|
||||||
|
{
|
||||||
|
Status = statusCode,
|
||||||
|
ActionId = action.Id,
|
||||||
|
Header = JsonSerializer.Serialize(resHeaders, options: new() { WriteIndented = false }),
|
||||||
|
Body = resBody,
|
||||||
|
AddedWho = config?["AddedWho"]
|
||||||
|
}, cancel);
|
||||||
|
|
||||||
|
return response.IsSuccessStatusCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ public class MappingProfile : AutoMapper.Profile
|
|||||||
{
|
{
|
||||||
public MappingProfile()
|
public MappingProfile()
|
||||||
{
|
{
|
||||||
CreateMap<CreateRecActionCommand, RecAction>()
|
CreateMap<CreateRecActionCommand, RecActionDto>()
|
||||||
.ForMember(e => e.Active, exp => exp.MapFrom(cmd => true))
|
.ForMember(e => e.Active, exp => exp.MapFrom(cmd => true))
|
||||||
.ForMember(e => e.AddedWhen, exp => exp.MapFrom(cmd => DateTime.UtcNow))
|
.ForMember(e => e.AddedWhen, exp => exp.MapFrom(cmd => DateTime.UtcNow))
|
||||||
.ForMember(e => e.AddedWho, exp => exp.MapFrom(cmd => "ReC.API"));
|
.ForMember(e => e.AddedWho, exp => exp.MapFrom(cmd => "ReC.API"));
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
using MediatR;
|
||||||
|
using DigitalData.Core.Abstraction.Application.Repository;
|
||||||
|
using ReC.Domain.Entities;
|
||||||
|
using AutoMapper;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using DigitalData.Core.Exceptions;
|
||||||
|
using ReC.Application.Common.Dto;
|
||||||
|
|
||||||
|
namespace ReC.Application.RecActionViews.Queries;
|
||||||
|
|
||||||
|
public record ReadRecActionQueryBase
|
||||||
|
{
|
||||||
|
public long ProfileId { get; init; }
|
||||||
|
|
||||||
|
public ReadRecActionViewQuery ToReadQuery(Action<ReadRecActionViewQuery> modify)
|
||||||
|
{
|
||||||
|
ReadRecActionViewQuery query = new(this);
|
||||||
|
modify(query);
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public record ReadRecActionViewQuery : ReadRecActionQueryBase, IRequest<IEnumerable<RecActionViewDto>>
|
||||||
|
{
|
||||||
|
public ReadRecActionViewQuery(ReadRecActionQueryBase root) : base(root) { }
|
||||||
|
|
||||||
|
public bool? Invoked { get; set; } = null;
|
||||||
|
|
||||||
|
public ReadRecActionViewQuery() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ReadRecActionViewQueryHandler(IRepository<RecActionView> repo, IMapper mapper) : IRequestHandler<ReadRecActionViewQuery, IEnumerable<RecActionViewDto>>
|
||||||
|
{
|
||||||
|
public async Task<IEnumerable<RecActionViewDto>> Handle(ReadRecActionViewQuery request, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
var query = repo.Where(act => act.ProfileId == request.ProfileId);
|
||||||
|
|
||||||
|
if (request.Invoked is bool invoked)
|
||||||
|
query = invoked ? query.Where(act => act.Root!.OutRes != null) : query.Where(act => act.Root!.OutRes == null);
|
||||||
|
|
||||||
|
var actions = await query.Include(act => act.EndpointAuth).ToListAsync(cancel);
|
||||||
|
|
||||||
|
if (actions.Count == 0)
|
||||||
|
throw new NotFoundException($"No actions found for the profile {request.ProfileId}.");
|
||||||
|
|
||||||
|
return mapper.Map<IEnumerable<RecActionViewDto>>(actions);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,7 +27,7 @@ public record CreateRecActionCommand : IRequest
|
|||||||
public long? EndpointAuthId { get; set; }
|
public long? EndpointAuthId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CreateRecActionCommandHandler(ISender sender, IRepository<RecAction> repo) : IRequestHandler<CreateRecActionCommand>
|
public class CreateRecActionCommandHandler(ISender sender, IRepository<RecActionDto> repo) : IRequestHandler<CreateRecActionCommand>
|
||||||
{
|
{
|
||||||
public async Task Handle(CreateRecActionCommand request, CancellationToken cancel)
|
public async Task Handle(CreateRecActionCommand request, CancellationToken cancel)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public class DeleteRecActionsCommand : IRequest
|
|||||||
public required long ProfileId { get; init; }
|
public required long ProfileId { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DeleteRecActionsCommandHandler(IRepository<RecAction> repo) : IRequestHandler<DeleteRecActionsCommand>
|
public class DeleteRecActionsCommandHandler(IRepository<RecActionDto> repo) : IRequestHandler<DeleteRecActionsCommand>
|
||||||
{
|
{
|
||||||
public async Task Handle(DeleteRecActionsCommand request, CancellationToken cancel)
|
public async Task Handle(DeleteRecActionsCommand request, CancellationToken cancel)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
using MediatR;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using ReC.Application.RecActions.Queries;
|
|
||||||
|
|
||||||
namespace ReC.Application.RecActions.Commands;
|
|
||||||
|
|
||||||
public record InvokeBatchRecActionsCommand : ReadRecActionQueryBase, IRequest;
|
|
||||||
|
|
||||||
public static class InvokeBatchRecActionsCommandExtensions
|
|
||||||
{
|
|
||||||
public static Task InvokeBatchRecAction(this ISender sender, long profileId, CancellationToken cancel = default)
|
|
||||||
=> sender.Send(new InvokeBatchRecActionsCommand { ProfileId = profileId }, cancel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class InvokeRecActionsCommandHandler(ISender sender, IServiceScopeFactory scopeFactory, IHttpClientFactory clientFactory, ILogger<InvokeRecActionsCommandHandler>? logger = null) : IRequestHandler<InvokeBatchRecActionsCommand>
|
|
||||||
{
|
|
||||||
public async Task Handle(InvokeBatchRecActionsCommand request, CancellationToken cancel)
|
|
||||||
{
|
|
||||||
var actions = await sender.Send(request.ToReadQuery(q => q.Invoked = false), cancel);
|
|
||||||
|
|
||||||
var http = clientFactory.CreateClient();
|
|
||||||
|
|
||||||
using var semaphore = new SemaphoreSlim(5);
|
|
||||||
|
|
||||||
var tasks = actions.Select(async action =>
|
|
||||||
{
|
|
||||||
await semaphore.WaitAsync(cancel);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var scope = scopeFactory.CreateScope();
|
|
||||||
var sender = scope.ServiceProvider.GetRequiredService<ISender>();
|
|
||||||
await sender.Send(action.ToInvokeCommand(), cancel);
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
logger?.LogError(
|
|
||||||
ex,
|
|
||||||
"Error invoking Rec action. ProfileId: {ProfileId}, Id: {Id}",
|
|
||||||
action.ProfileId,
|
|
||||||
action.Id
|
|
||||||
);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
semaphore.Release();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
await Task.WhenAll(tasks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
using MediatR;
|
|
||||||
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 : IRequest
|
|
||||||
{
|
|
||||||
public RecActionDto Action { get; set; } = null!;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class InvokeRecActionCommandExtensions
|
|
||||||
{
|
|
||||||
public static InvokeRecActionCommand ToInvokeCommand(this RecActionDto dto) => new() { Action = dto };
|
|
||||||
}
|
|
||||||
|
|
||||||
public class InvokeRecActionCommandHandler(
|
|
||||||
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 (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 = action.RestType
|
|
||||||
.ToHttpMethod()
|
|
||||||
.ToHttpRequestMessage(action.EndpointUri);
|
|
||||||
|
|
||||||
if(action.Body is not null)
|
|
||||||
{
|
|
||||||
using var reqBody = new StringContent(action.Body);
|
|
||||||
httpReq.Content = reqBody;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
using MediatR;
|
|
||||||
using DigitalData.Core.Abstraction.Application.Repository;
|
|
||||||
using ReC.Domain.Entities;
|
|
||||||
using AutoMapper;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using DigitalData.Core.Exceptions;
|
|
||||||
using ReC.Application.Common.Dto;
|
|
||||||
|
|
||||||
namespace ReC.Application.RecActions.Queries;
|
|
||||||
|
|
||||||
public record ReadRecActionQueryBase
|
|
||||||
{
|
|
||||||
public long ProfileId { get; init; }
|
|
||||||
|
|
||||||
public ReadRecActionQuery ToReadQuery(Action<ReadRecActionQuery> modify)
|
|
||||||
{
|
|
||||||
ReadRecActionQuery query = new(this);
|
|
||||||
modify(query);
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public record ReadRecActionQuery : ReadRecActionQueryBase, IRequest<IEnumerable<RecActionDto>>
|
|
||||||
{
|
|
||||||
public ReadRecActionQuery(ReadRecActionQueryBase root) : base(root) { }
|
|
||||||
|
|
||||||
public bool? Invoked { get; set; } = null;
|
|
||||||
|
|
||||||
public ReadRecActionQuery() { }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ReadRecActionQueryHandler(IRepository<RecActionView> repo, IMapper mapper) : IRequestHandler<ReadRecActionQuery, IEnumerable<RecActionDto>>
|
|
||||||
{
|
|
||||||
public async Task<IEnumerable<RecActionDto>> Handle(ReadRecActionQuery request, CancellationToken cancel)
|
|
||||||
{
|
|
||||||
var query = repo.Where(act => act.ProfileId == request.ProfileId);
|
|
||||||
|
|
||||||
if (request.Invoked is bool invoked)
|
|
||||||
query = invoked ? query.Where(act => act.Root!.OutRes != null) : query.Where(act => act.Root!.OutRes == null);
|
|
||||||
|
|
||||||
var actions = await query.ToListAsync(cancel);
|
|
||||||
|
|
||||||
if(actions.Count == 0)
|
|
||||||
throw new NotFoundException($"No actions found for the profile {request.ProfileId}.");
|
|
||||||
|
|
||||||
return mapper.Map<IEnumerable<RecActionDto>>(actions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
6
src/ReC.Domain/Attributes/MustConfiguredAttribute.cs
Normal file
6
src/ReC.Domain/Attributes/MustConfiguredAttribute.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace ReC.Domain.Attributes;
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
|
public class MustConfiguredAttribute : Attribute
|
||||||
|
{
|
||||||
|
}
|
||||||
7
src/ReC.Domain/Constants/ApiKeyLocation.cs
Normal file
7
src/ReC.Domain/Constants/ApiKeyLocation.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace ReC.Domain.Constants;
|
||||||
|
|
||||||
|
public enum ApiKeyLocation
|
||||||
|
{
|
||||||
|
Header = 0,
|
||||||
|
Query = 1
|
||||||
|
}
|
||||||
15
src/ReC.Domain/Constants/EndpointAuthType.cs
Normal file
15
src/ReC.Domain/Constants/EndpointAuthType.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
namespace ReC.Domain.Constants;
|
||||||
|
|
||||||
|
public enum EndpointAuthType
|
||||||
|
{
|
||||||
|
NoAuth = 0,
|
||||||
|
ApiKey = 1,
|
||||||
|
BearerToken = 2,
|
||||||
|
JwtBearer = 3,
|
||||||
|
BasicAuth = 4,
|
||||||
|
DigestAuth = 5,
|
||||||
|
OAuth1 = 6,
|
||||||
|
OAuth2 = 7,
|
||||||
|
AwsSignature = 8,
|
||||||
|
NtlmAuth = 9
|
||||||
|
}
|
||||||
7
src/ReC.Domain/Constants/ErrorAction.cs
Normal file
7
src/ReC.Domain/Constants/ErrorAction.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace ReC.Domain.Constants;
|
||||||
|
|
||||||
|
public enum ErrorAction
|
||||||
|
{
|
||||||
|
Stop = 0,
|
||||||
|
Continue = 1,
|
||||||
|
}
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
namespace ReC.Domain.Entities;
|
||||||
|
|
||||||
namespace ReC.Domain.Entities;
|
|
||||||
|
|
||||||
public class BodyQueryResult
|
public class BodyQueryResult
|
||||||
{
|
{
|
||||||
[Column("REQUEST_BODY")]
|
|
||||||
public string? RawBody { get; init; }
|
public string? RawBody { get; init; }
|
||||||
}
|
}
|
||||||
@@ -1,52 +1,35 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace ReC.Domain.Entities;
|
namespace ReC.Domain.Entities;
|
||||||
|
|
||||||
[Table("TBDD_CONNECTION")]
|
[Table("TBDD_CONNECTION")]
|
||||||
public class Connection
|
public class Connection
|
||||||
{
|
{
|
||||||
[Key]
|
|
||||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
||||||
[Column("GUID")]
|
|
||||||
public short? Id { get; set; }
|
public short? Id { get; set; }
|
||||||
|
|
||||||
[Column("BEZEICHNUNG")]
|
|
||||||
public string? Bezeichnung { get; set; }
|
public string? Bezeichnung { get; set; }
|
||||||
|
|
||||||
[Column("SQL_PROVIDER")]
|
|
||||||
public string? SqlProvider { get; set; }
|
public string? SqlProvider { get; set; }
|
||||||
|
|
||||||
[Column("SERVER")]
|
|
||||||
public string? Server { get; set; }
|
public string? Server { get; set; }
|
||||||
|
|
||||||
[Column("DATENBANK")]
|
|
||||||
public string? Datenbank { get; set; }
|
public string? Datenbank { get; set; }
|
||||||
|
|
||||||
[Column("USERNAME")]
|
|
||||||
public string? Username { get; set; }
|
public string? Username { get; set; }
|
||||||
|
|
||||||
[Column("PASSWORD")]
|
|
||||||
public string? Password { get; set; }
|
public string? Password { get; set; }
|
||||||
|
|
||||||
[Column("BEMERKUNG")]
|
|
||||||
public string? Bemerkung { get; set; }
|
public string? Bemerkung { get; set; }
|
||||||
|
|
||||||
[Column("AKTIV")]
|
|
||||||
public bool? Aktiv { get; set; }
|
public bool? Aktiv { get; set; }
|
||||||
|
|
||||||
[Column("ERSTELLTWER")]
|
|
||||||
public string? ErstelltWer { get; set; }
|
public string? ErstelltWer { get; set; }
|
||||||
|
|
||||||
[Column("ERSTELLTWANN")]
|
|
||||||
public DateTime? ErstelltWann { get; set; }
|
public DateTime? ErstelltWann { get; set; }
|
||||||
|
|
||||||
[Column("GEANDERTWER")]
|
|
||||||
public string? GeandertWer { get; set; }
|
public string? GeandertWer { get; set; }
|
||||||
|
|
||||||
[Column("GEAENDERTWANN")]
|
|
||||||
public DateTime? GeaendertWann { get; set; }
|
public DateTime? GeaendertWann { get; set; }
|
||||||
|
|
||||||
[Column("SYS_CONNECTION")]
|
|
||||||
public bool? SysConnection { get; set; }
|
public bool? SysConnection { get; set; }
|
||||||
}
|
}
|
||||||
@@ -1,34 +1,23 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace ReC.Domain.Entities;
|
namespace ReC.Domain.Entities;
|
||||||
|
|
||||||
[Table("TBREC_CFG_ENDPOINT")]
|
[Table("TBREC_CFG_ENDPOINT")]
|
||||||
public class Endpoint
|
public class Endpoint
|
||||||
{
|
{
|
||||||
[Key]
|
|
||||||
[Column("GUID")]
|
|
||||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
|
|
||||||
[Column("ACTIVE")]
|
|
||||||
public bool? Active { get; set; }
|
public bool? Active { get; set; }
|
||||||
|
|
||||||
[Column("DESCRIPTION")]
|
|
||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
|
|
||||||
[Column("URI")]
|
|
||||||
public string? Uri { get; set; }
|
public string? Uri { get; set; }
|
||||||
|
|
||||||
[Column("ADDED_WHO")]
|
|
||||||
public string? AddedWho { get; set; }
|
public string? AddedWho { get; set; }
|
||||||
|
|
||||||
[Column("ADDED_WHEN")]
|
|
||||||
public DateTime? AddedWhen { get; set; }
|
public DateTime? AddedWhen { get; set; }
|
||||||
|
|
||||||
[Column("CHANGED_WHO")]
|
|
||||||
public string? ChangedWho { get; set; }
|
public string? ChangedWho { get; set; }
|
||||||
|
|
||||||
[Column("CHANGED_WHEN")]
|
|
||||||
public DateTime? ChangedWhen { get; set; }
|
public DateTime? ChangedWhen { get; set; }
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using ReC.Domain.Constants;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace ReC.Domain.Entities;
|
namespace ReC.Domain.Entities;
|
||||||
@@ -6,53 +6,35 @@ namespace ReC.Domain.Entities;
|
|||||||
[Table("TBREC_CFG_ENDPOINT_AUTH")]
|
[Table("TBREC_CFG_ENDPOINT_AUTH")]
|
||||||
public class EndpointAuth
|
public class EndpointAuth
|
||||||
{
|
{
|
||||||
[Key]
|
|
||||||
[Column("GUID")]
|
|
||||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
||||||
public long? Id { get; set; }
|
public long? Id { get; set; }
|
||||||
|
|
||||||
[Column("ACTIVE")]
|
|
||||||
public bool? Active { get; set; }
|
public bool? Active { get; set; }
|
||||||
|
|
||||||
[Column("DESCRIPTION")]
|
|
||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
|
|
||||||
[Column("TYPE")]
|
public EndpointAuthType? Type { get; set; }
|
||||||
public string? Type { get; set; }
|
|
||||||
|
|
||||||
[Column("API_KEY")]
|
|
||||||
public string? ApiKey { get; set; }
|
public string? ApiKey { get; set; }
|
||||||
|
|
||||||
[Column("API_VALUE")]
|
|
||||||
public string? ApiValue { get; set; }
|
public string? ApiValue { get; set; }
|
||||||
|
|
||||||
[Column("API_KEY_ADD_TO")]
|
public ApiKeyLocation? ApiKeyAddTo { get; set; }
|
||||||
public string? ApiKeyAddTo { get; set; }
|
|
||||||
|
|
||||||
[Column("TOKEN")]
|
|
||||||
public string? Token { get; set; }
|
public string? Token { get; set; }
|
||||||
|
|
||||||
[Column("USERNAME")]
|
|
||||||
public string? Username { get; set; }
|
public string? Username { get; set; }
|
||||||
|
|
||||||
[Column("PASSWORD")]
|
|
||||||
public string? Password { get; set; }
|
public string? Password { get; set; }
|
||||||
|
|
||||||
[Column("DOMAIN")]
|
|
||||||
public string? Domain { get; set; }
|
public string? Domain { get; set; }
|
||||||
|
|
||||||
[Column("WORKSTATION")]
|
|
||||||
public string? Workstation { get; set; }
|
public string? Workstation { get; set; }
|
||||||
|
|
||||||
[Column("ADDED_WHO")]
|
|
||||||
public string? AddedWho { get; set; }
|
public string? AddedWho { get; set; }
|
||||||
|
|
||||||
[Column("ADDED_WHEN")]
|
|
||||||
public DateTime? AddedWhen { get; set; }
|
public DateTime? AddedWhen { get; set; }
|
||||||
|
|
||||||
[Column("CHANGED_WHO")]
|
|
||||||
public string? ChangedWho { get; set; }
|
public string? ChangedWho { get; set; }
|
||||||
|
|
||||||
[Column("CHANGED_WHEN")]
|
|
||||||
public DateTime? ChangedWhen { get; set; }
|
public DateTime? ChangedWhen { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace ReC.Domain.Entities;
|
namespace ReC.Domain.Entities;
|
||||||
|
|
||||||
@@ -11,37 +10,25 @@ namespace ReC.Domain.Entities;
|
|||||||
[Table("TBREC_CFG_ENDPOINT_PARAMS", Schema = "dbo")]
|
[Table("TBREC_CFG_ENDPOINT_PARAMS", Schema = "dbo")]
|
||||||
public class EndpointParam
|
public class EndpointParam
|
||||||
{
|
{
|
||||||
[Key]
|
|
||||||
[Column("GUID")]
|
|
||||||
public long? Id { get; set; }
|
public long? Id { get; set; }
|
||||||
|
|
||||||
[Column("ACTIVE")]
|
|
||||||
public bool? Active { get; set; }
|
public bool? Active { get; set; }
|
||||||
|
|
||||||
[Column("DESCRIPTION")]
|
|
||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
|
|
||||||
[Column("GROUP_ID")]
|
|
||||||
public short? GroupId { get; set; }
|
public short? GroupId { get; set; }
|
||||||
|
|
||||||
[Column("SEQUENCE")]
|
|
||||||
public byte? Sequence { get; set; }
|
public byte? Sequence { get; set; }
|
||||||
|
|
||||||
[Column("KEY")]
|
|
||||||
public string? Key { get; set; }
|
public string? Key { get; set; }
|
||||||
|
|
||||||
[Column("VALUE")]
|
|
||||||
public string? Value { get; set; }
|
public string? Value { get; set; }
|
||||||
|
|
||||||
[Column("ADDED_WHO")]
|
|
||||||
public string? AddedWho { get; set; }
|
public string? AddedWho { get; set; }
|
||||||
|
|
||||||
[Column("ADDED_WHEN")]
|
|
||||||
public DateTime? AddedWhen { get; set; }
|
public DateTime? AddedWhen { get; set; }
|
||||||
|
|
||||||
[Column("CHANGED_WHO")]
|
|
||||||
public string? ChangedWho { get; set; }
|
public string? ChangedWho { get; set; }
|
||||||
|
|
||||||
[Column("CHANGED_WHEN")]
|
|
||||||
public DateTime? ChangedWhen { get; set; }
|
public DateTime? ChangedWhen { get; set; }
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
namespace ReC.Domain.Entities;
|
||||||
|
|
||||||
namespace ReC.Domain.Entities;
|
|
||||||
|
|
||||||
public class HeaderQueryResult
|
public class HeaderQueryResult
|
||||||
{
|
{
|
||||||
[Column("REQUEST_HEADER")]
|
|
||||||
public string? RawHeader { get; init; }
|
public string? RawHeader { get; init; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +1,27 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace ReC.Domain.Entities;
|
namespace ReC.Domain.Entities;
|
||||||
|
|
||||||
[Table("TBREC_OUT_RESULT", Schema = "dbo")]
|
[Table("TBREC_OUT_RESULT", Schema = "dbo")]
|
||||||
public class OutRes
|
public class OutRes
|
||||||
{
|
{
|
||||||
[Key]
|
|
||||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
||||||
[Column("GUID")]
|
|
||||||
public long? Id { get; set; }
|
public long? Id { get; set; }
|
||||||
|
|
||||||
[Column("ACTION_ID")]
|
|
||||||
public long? ActionId { get; set; }
|
public long? ActionId { get; set; }
|
||||||
|
|
||||||
[ForeignKey("ActionId")]
|
|
||||||
public RecAction? Action { get; set; }
|
public RecAction? Action { get; set; }
|
||||||
|
|
||||||
[Column("RESULT_HEADER")]
|
public short? Status { get; set; }
|
||||||
|
|
||||||
public string? Header { get; set; }
|
public string? Header { get; set; }
|
||||||
|
|
||||||
[Column("RESULT_BODY")]
|
|
||||||
public string? Body { get; set; }
|
public string? Body { get; set; }
|
||||||
|
|
||||||
[Column("ADDED_WHO")]
|
|
||||||
public string? AddedWho { get; set; }
|
public string? AddedWho { get; set; }
|
||||||
|
|
||||||
[Column("ADDED_WHEN")]
|
|
||||||
public DateTime? AddedWhen { get; set; }
|
public DateTime? AddedWhen { get; set; }
|
||||||
|
|
||||||
[Column("CHANGED_WHO")]
|
|
||||||
public string? ChangedWho { get; set; }
|
public string? ChangedWho { get; set; }
|
||||||
|
|
||||||
[Column("CHANGED_WHEN")]
|
|
||||||
public DateTime? ChangedWhen { get; set; }
|
public DateTime? ChangedWhen { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,46 +1,31 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace ReC.Domain.Entities;
|
namespace ReC.Domain.Entities;
|
||||||
|
|
||||||
[Table("TBREC_CFG_PROFILE", Schema = "dbo")]
|
[Table("TBREC_CFG_PROFILE", Schema = "dbo")]
|
||||||
public class Profile
|
public class Profile
|
||||||
{
|
{
|
||||||
[Key]
|
|
||||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
||||||
[Column("GUID")]
|
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
|
|
||||||
[Column("ACTIVE")]
|
|
||||||
public bool? Active { get; set; }
|
public bool? Active { get; set; }
|
||||||
|
|
||||||
[Column("TYPE")]
|
|
||||||
public string? Type { get; set; }
|
public string? Type { get; set; }
|
||||||
|
|
||||||
[Column("MANDANTOR")]
|
|
||||||
public string? Mandantor { get; set; }
|
public string? Mandantor { get; set; }
|
||||||
|
|
||||||
[Column("PROFILE_NAME")]
|
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
|
|
||||||
[Column("DESCRIPTION")]
|
|
||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
|
|
||||||
[Column("LOG_LEVEL")]
|
|
||||||
public string? LogLevel { get; set; }
|
public string? LogLevel { get; set; }
|
||||||
|
|
||||||
[Column("LANGUAGE")]
|
|
||||||
public string? Language { get; set; }
|
public string? Language { get; set; }
|
||||||
|
|
||||||
[Column("ADDED_WHO")]
|
|
||||||
public string? AddedWho { get; set; }
|
public string? AddedWho { get; set; }
|
||||||
|
|
||||||
[Column("ADDED_WHEN")]
|
|
||||||
public DateTime? AddedWhen { get; set; }
|
public DateTime? AddedWhen { get; set; }
|
||||||
|
|
||||||
[Column("CHANGED_WHO")]
|
|
||||||
public string? ChangedWho { get; set; }
|
public string? ChangedWho { get; set; }
|
||||||
|
|
||||||
[Column("CHANGED_WHEN")]
|
|
||||||
public DateTime? ChangedWhen { get; set; }
|
public DateTime? ChangedWhen { get; set; }
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using ReC.Domain.Constants;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace ReC.Domain.Entities;
|
namespace ReC.Domain.Entities;
|
||||||
@@ -6,68 +6,48 @@ namespace ReC.Domain.Entities;
|
|||||||
[Table("TBREC_CFG_ACTION")]
|
[Table("TBREC_CFG_ACTION")]
|
||||||
public class RecAction
|
public class RecAction
|
||||||
{
|
{
|
||||||
[Key]
|
|
||||||
[Column("GUID")]
|
|
||||||
public long? Id { get; set; }
|
public long? Id { get; set; }
|
||||||
|
|
||||||
[Column("PROFILE_ID")]
|
|
||||||
public long? ProfileId { get; set; }
|
public long? ProfileId { get; set; }
|
||||||
|
|
||||||
[ForeignKey("ProfileId")]
|
|
||||||
public Profile? Profile { get; set; }
|
public Profile? Profile { get; set; }
|
||||||
|
|
||||||
[Column("ACTIVE")]
|
|
||||||
public bool? Active { get; set; }
|
public bool? Active { get; set; }
|
||||||
|
|
||||||
[Column("SEQUENCE")]
|
|
||||||
public byte? Sequence { get; set; }
|
public byte? Sequence { get; set; }
|
||||||
|
|
||||||
[Column("ENDPOINT_ID")]
|
|
||||||
public long? EndpointId { get; set; }
|
public long? EndpointId { get; set; }
|
||||||
|
|
||||||
[ForeignKey("EndpointId")]
|
|
||||||
public Endpoint? Endpoint { get; set; }
|
public Endpoint? Endpoint { get; set; }
|
||||||
|
|
||||||
[Column("ENDPOINT_AUTH_ID")]
|
|
||||||
public long? EndpointAuthId { get; set; }
|
public long? EndpointAuthId { get; set; }
|
||||||
|
|
||||||
[ForeignKey("EndpointAuthId")]
|
|
||||||
public EndpointAuth? EndpointAuth { get; set; }
|
public EndpointAuth? EndpointAuth { get; set; }
|
||||||
|
|
||||||
[Column("ENDPOINT_PARAMS_ID")]
|
|
||||||
public short? EndpointParamsId { get; set; }
|
public short? EndpointParamsId { get; set; }
|
||||||
|
|
||||||
[Column("SQL_CONNECTION_ID")]
|
|
||||||
public short? SqlConnectionId { get; set; }
|
public short? SqlConnectionId { get; set; }
|
||||||
|
|
||||||
[ForeignKey("SqlConnectionId")]
|
|
||||||
public Connection? SqlConnection { get; set; }
|
public Connection? SqlConnection { get; set; }
|
||||||
|
|
||||||
[Column("TYPE")]
|
|
||||||
public string? Type { get; set; }
|
public string? Type { get; set; }
|
||||||
|
|
||||||
[Column("PREPROCESSING_QUERY")]
|
|
||||||
public string? PreprocessingQuery { get; set; }
|
public string? PreprocessingQuery { get; set; }
|
||||||
|
|
||||||
[Column("HEADER_QUERY")]
|
|
||||||
public string? HeaderQuery { get; set; }
|
public string? HeaderQuery { get; set; }
|
||||||
|
|
||||||
[Column("BODY_QUERY")]
|
|
||||||
public string? BodyQuery { get; set; }
|
public string? BodyQuery { get; set; }
|
||||||
|
|
||||||
[Column("POSTPROCESSING_QUERY")]
|
|
||||||
public string? PostprocessingQuery { get; set; }
|
public string? PostprocessingQuery { get; set; }
|
||||||
|
|
||||||
[Column("ADDED_WHO")]
|
public ErrorAction? ErrorAction { get; set; }
|
||||||
|
|
||||||
public string? AddedWho { get; set; }
|
public string? AddedWho { get; set; }
|
||||||
|
|
||||||
[Column("ADDED_WHEN")]
|
|
||||||
public DateTime? AddedWhen { get; set; }
|
public DateTime? AddedWhen { get; set; }
|
||||||
|
|
||||||
[Column("CHANGED_WHO")]
|
|
||||||
public string? ChangedWho { get; set; }
|
public string? ChangedWho { get; set; }
|
||||||
|
|
||||||
[Column("CHANGED_WHEN")]
|
|
||||||
public DateTime? ChangedWhen { get; set; }
|
public DateTime? ChangedWhen { get; set; }
|
||||||
|
|
||||||
public OutRes? OutRes { get; set; }
|
public OutRes? OutRes { get; set; }
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using ReC.Domain.Constants;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace ReC.Domain.Entities;
|
namespace ReC.Domain.Entities;
|
||||||
@@ -14,110 +14,74 @@ namespace ReC.Domain.Entities;
|
|||||||
[Table("VWREC_ACTION", Schema = "dbo")]
|
[Table("VWREC_ACTION", Schema = "dbo")]
|
||||||
public class RecActionView
|
public class RecActionView
|
||||||
{
|
{
|
||||||
[Column("ACTION_ID")]
|
|
||||||
public required long Id { get; set; }
|
public required long Id { get; set; }
|
||||||
|
|
||||||
[ForeignKey("Id")]
|
[ForeignKey("Id")]
|
||||||
public RecAction? Root { get; set; }
|
public RecAction? Root { get; set; }
|
||||||
|
|
||||||
[Column("PROFILE_ID")]
|
|
||||||
public long? ProfileId { get; set; }
|
public long? ProfileId { get; set; }
|
||||||
|
|
||||||
[ForeignKey("ProfileId")]
|
[ForeignKey("ProfileId")]
|
||||||
public Profile? Profile { get; set; }
|
public Profile? Profile { get; set; }
|
||||||
|
|
||||||
[Column("PROFILE_NAME")]
|
|
||||||
[MaxLength(100)]
|
|
||||||
public string? ProfileName { get; set; }
|
public string? ProfileName { get; set; }
|
||||||
|
|
||||||
[Column("PROFILE_TYPE")]
|
|
||||||
[MaxLength(20)]
|
|
||||||
public string? ProfileType { get; set; }
|
public string? ProfileType { get; set; }
|
||||||
|
|
||||||
[Column("PROFILE_SEQUENCE")]
|
public byte? Sequence { get; set; }
|
||||||
public byte? ProfileSequence { get; set; }
|
|
||||||
|
|
||||||
[Column("ENDPOINT_ID")]
|
|
||||||
public long? EndpointId { get; set; }
|
public long? EndpointId { get; set; }
|
||||||
|
|
||||||
[Column("ENDPOINT_URI")]
|
[ForeignKey("EndpointId")]
|
||||||
[MaxLength(4000)]
|
public Endpoint? Endpoint { get; set; }
|
||||||
|
|
||||||
public string? EndpointUri { get; set; }
|
public string? EndpointUri { get; set; }
|
||||||
|
|
||||||
[Column("ENDPOINT_AUTH_ID")]
|
|
||||||
public long? EndpointAuthId { get; set; }
|
public long? EndpointAuthId { get; set; }
|
||||||
|
|
||||||
[Column("ENDPOINT_AUTH_TYPE")]
|
[ForeignKey("EndpointAuthId")]
|
||||||
[MaxLength(50)]
|
public EndpointAuth? EndpointAuth { get; set; }
|
||||||
public string? EndpointAuthType { get; set; }
|
|
||||||
|
public EndpointAuthType? EndpointAuthType { get; set; }
|
||||||
|
|
||||||
[Column("ENDPOINT_AUTH_API_KEY")]
|
|
||||||
[MaxLength(300)]
|
|
||||||
public string? EndpointAuthApiKey { get; set; }
|
public string? EndpointAuthApiKey { get; set; }
|
||||||
|
|
||||||
[Column("ENDPOINT_AUTH_API_VALUE")]
|
|
||||||
[MaxLength(300)]
|
|
||||||
public string? EndpointAuthApiValue { get; set; }
|
public string? EndpointAuthApiValue { get; set; }
|
||||||
|
|
||||||
[Column("ENDPOINT_AUTH_API_KEY_ADD_TO")]
|
public ApiKeyLocation? EndpointAuthApiKeyAddTo { get; set; }
|
||||||
[MaxLength(20)]
|
|
||||||
public string? EndpointAuthApiKeyAddTo { get; set; }
|
|
||||||
|
|
||||||
[Column("ENDPOINT_AUTH_TOKEN")]
|
|
||||||
[MaxLength(300)]
|
|
||||||
public string? EndpointAuthToken { get; set; }
|
public string? EndpointAuthToken { get; set; }
|
||||||
|
|
||||||
[Column("ENDPOINT_AUTH_USERNAME")]
|
|
||||||
[MaxLength(200)]
|
|
||||||
public string? EndpointAuthUsername { get; set; }
|
public string? EndpointAuthUsername { get; set; }
|
||||||
|
|
||||||
[Column("ENDPOINT_AUTH_PASSWORD")]
|
|
||||||
[MaxLength(200)]
|
|
||||||
public string? EndpointAuthPassword { get; set; }
|
public string? EndpointAuthPassword { get; set; }
|
||||||
|
|
||||||
[Column("ENDPOINT_AUTH_DOMAIN")]
|
|
||||||
[MaxLength(100)]
|
|
||||||
public string? EndpointAuthDomain { get; set; }
|
public string? EndpointAuthDomain { get; set; }
|
||||||
|
|
||||||
[Column("ENDPOINT_AUTH_WORKSTATION")]
|
|
||||||
[MaxLength(100)]
|
|
||||||
public string? EndpointAuthWorkstation { get; set; }
|
public string? EndpointAuthWorkstation { get; set; }
|
||||||
|
|
||||||
[Column("ENDPOINT_PARAMS_ID")]
|
|
||||||
public short? EndpointParamsId { get; set; }
|
public short? EndpointParamsId { get; set; }
|
||||||
|
|
||||||
[Column("SQL_CONNECTION_ID")]
|
|
||||||
public short? SqlConnectionId { get; set; }
|
public short? SqlConnectionId { get; set; }
|
||||||
|
|
||||||
[Column("SQL_CONNECTION_SERVER")]
|
[ForeignKey("SqlConnectionId")]
|
||||||
[MaxLength(150)]
|
public Connection? SqlConnection { get; set; }
|
||||||
|
|
||||||
public string? SqlConnectionServer { get; set; }
|
public string? SqlConnectionServer { get; set; }
|
||||||
|
|
||||||
[Column("SQL_CONNECTION_DB")]
|
|
||||||
[MaxLength(100)]
|
|
||||||
public string? SqlConnectionDb { get; set; }
|
public string? SqlConnectionDb { get; set; }
|
||||||
|
|
||||||
[Column("SQL_CONNECTION_USERNAME")]
|
|
||||||
[MaxLength(100)]
|
|
||||||
public string? SqlConnectionUsername { get; set; }
|
public string? SqlConnectionUsername { get; set; }
|
||||||
|
|
||||||
[Column("SQL_CONNECTION_PASSWORD")]
|
|
||||||
[MaxLength(100)]
|
|
||||||
public string? SqlConnectionPassword { get; set; }
|
public string? SqlConnectionPassword { get; set; }
|
||||||
|
|
||||||
[Column("REST_TYPE")]
|
|
||||||
[MaxLength(20)]
|
|
||||||
public string? RestType { get; set; }
|
public string? RestType { get; set; }
|
||||||
|
|
||||||
[Column("PREPROCESSING_QUERY")]
|
|
||||||
public string? PreprocessingQuery { get; set; }
|
public string? PreprocessingQuery { get; set; }
|
||||||
|
|
||||||
[Column("HEADER_QUERY")]
|
|
||||||
public string? HeaderQuery { get; set; }
|
public string? HeaderQuery { get; set; }
|
||||||
|
|
||||||
[Column("BODY_QUERY")]
|
|
||||||
public string? BodyQuery { get; set; }
|
public string? BodyQuery { get; set; }
|
||||||
|
|
||||||
[Column("POSTPROCESSING_QUERY")]
|
|
||||||
public string? PostprocessingQuery { get; set; }
|
public string? PostprocessingQuery { get; set; }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace ReC.Infrastructure.Exceptions;
|
||||||
|
|
||||||
|
public class DbModelConfigurationException : Exception
|
||||||
|
{
|
||||||
|
public DbModelConfigurationException(string message) : base(message)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public DbModelConfigurationException()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
23
src/ReC.Infrastructure/Options/DbModelOptions.cs
Normal file
23
src/ReC.Infrastructure/Options/DbModelOptions.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using ReC.Infrastructure.Exceptions;
|
||||||
|
using ReC.Infrastructure.Options.Shared;
|
||||||
|
|
||||||
|
namespace ReC.Infrastructure.Options;
|
||||||
|
|
||||||
|
public record DbModelOptions
|
||||||
|
{
|
||||||
|
public Dictionary<string, EntityOptions> Entities { get; init; } = [];
|
||||||
|
|
||||||
|
public Dictionary<string, VirtualEntityOptions> VirtualEntities { get; init; } = [];
|
||||||
|
|
||||||
|
public void EnsureEntity<T>(bool isVirtual)
|
||||||
|
{
|
||||||
|
var entities = isVirtual
|
||||||
|
? VirtualEntities.ToDictionary(kvp => kvp.Key, kvp => kvp.Value as EntityBaseOptions)
|
||||||
|
: Entities.ToDictionary(kvp => kvp.Key, kvp => kvp.Value as EntityBaseOptions);
|
||||||
|
|
||||||
|
if(entities.TryGetValue(nameof(T), out var entityOptions))
|
||||||
|
entityOptions.EnsureProperties<T>();
|
||||||
|
else
|
||||||
|
throw new DbModelConfigurationException($"Entity options for type '{typeof(T).FullName}' not found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
33
src/ReC.Infrastructure/Options/Shared/EntityBaseOptions.cs
Normal file
33
src/ReC.Infrastructure/Options/Shared/EntityBaseOptions.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using ReC.Domain.Attributes;
|
||||||
|
using ReC.Infrastructure.Exceptions;
|
||||||
|
|
||||||
|
namespace ReC.Infrastructure.Options.Shared;
|
||||||
|
|
||||||
|
public record EntityBaseOptions()
|
||||||
|
{
|
||||||
|
public Dictionary<string, string> ColumnMappings { get; init; } = [];
|
||||||
|
|
||||||
|
public IEnumerable<string> PropertyNames => ColumnMappings.Select(col => col.Key);
|
||||||
|
|
||||||
|
public IEnumerable<string> ColumnNames => ColumnMappings.Select(col => col.Value);
|
||||||
|
|
||||||
|
public void EnsureProperties(IEnumerable<string> propertyNames)
|
||||||
|
{
|
||||||
|
var missingProperties = propertyNames.Except(PropertyNames).ToList();
|
||||||
|
|
||||||
|
if (missingProperties.Count != 0)
|
||||||
|
throw new DbModelConfigurationException($"The following properties are not configured: {string.Join(", ", missingProperties)}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EnsureProperties(params string[] propertyNames)
|
||||||
|
=> EnsureProperties(propertyNames.AsEnumerable());
|
||||||
|
|
||||||
|
public void EnsureProperties<T>()
|
||||||
|
{
|
||||||
|
var propertyNames = typeof(T)
|
||||||
|
.GetProperties()
|
||||||
|
.Where(prop => Attribute.IsDefined(prop, typeof(MustConfiguredAttribute)))
|
||||||
|
.Select(prop => prop.Name);
|
||||||
|
EnsureProperties(propertyNames);
|
||||||
|
}
|
||||||
|
}
|
||||||
3
src/ReC.Infrastructure/Options/Shared/EntityOptions.cs
Normal file
3
src/ReC.Infrastructure/Options/Shared/EntityOptions.cs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
namespace ReC.Infrastructure.Options.Shared;
|
||||||
|
|
||||||
|
public record EntityOptions(TableOptions Table) : EntityBaseOptions;
|
||||||
3
src/ReC.Infrastructure/Options/Shared/TableOptions.cs
Normal file
3
src/ReC.Infrastructure/Options/Shared/TableOptions.cs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
namespace ReC.Infrastructure.Options.Shared;
|
||||||
|
|
||||||
|
public record TableOptions(string Name, string? Schema = null);
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace ReC.Infrastructure.Options.Shared;
|
||||||
|
|
||||||
|
public record VirtualEntityOptions : EntityBaseOptions;
|
||||||
@@ -8,7 +8,7 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
|
|||||||
{
|
{
|
||||||
public DbSet<EndpointParam> EndpointParams { get; set; }
|
public DbSet<EndpointParam> EndpointParams { get; set; }
|
||||||
|
|
||||||
public DbSet<RecActionView> Actions { get; set; }
|
public DbSet<RecActionView> RecActionViews { get; set; }
|
||||||
|
|
||||||
public DbSet<OutRes> OutRes { get; set; }
|
public DbSet<OutRes> OutRes { get; set; }
|
||||||
|
|
||||||
@@ -30,15 +30,216 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
|
|||||||
{
|
{
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity<RecActionView>().HasNoKey();
|
modelBuilder.Entity<Connection>(b =>
|
||||||
|
{
|
||||||
|
b.ToTable("TBDD_CONNECTION");
|
||||||
|
|
||||||
modelBuilder.Entity<HeaderQueryResult>().HasNoKey();
|
b.HasKey(e => e.Id);
|
||||||
|
|
||||||
modelBuilder.Entity<BodyQueryResult>().HasNoKey();
|
b.Property(e => e.Id)
|
||||||
|
.HasColumnName("GUID")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property(e => e.Bezeichnung).HasColumnName("BEZEICHNUNG");
|
||||||
|
b.Property(e => e.SqlProvider).HasColumnName("SQL_PROVIDER");
|
||||||
|
b.Property(e => e.Server).HasColumnName("SERVER");
|
||||||
|
b.Property(e => e.Datenbank).HasColumnName("DATENBANK");
|
||||||
|
b.Property(e => e.Username).HasColumnName("USERNAME");
|
||||||
|
b.Property(e => e.Password).HasColumnName("PASSWORD");
|
||||||
|
b.Property(e => e.Bemerkung).HasColumnName("BEMERKUNG");
|
||||||
|
b.Property(e => e.Aktiv).HasColumnName("AKTIV");
|
||||||
|
b.Property(e => e.ErstelltWer).HasColumnName("ERSTELLTWER");
|
||||||
|
b.Property(e => e.ErstelltWann).HasColumnName("ERSTELLTWANN");
|
||||||
|
b.Property(e => e.GeandertWer).HasColumnName("GEANDERTWER");
|
||||||
|
b.Property(e => e.GeaendertWann).HasColumnName("GEAENDERTWANN");
|
||||||
|
b.Property(e => e.SysConnection).HasColumnName("SYS_CONNECTION");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<Endpoint>(b =>
|
||||||
|
{
|
||||||
|
b.ToTable("TBREC_CFG_ENDPOINT");
|
||||||
|
|
||||||
|
b.HasKey(e => e.Id);
|
||||||
|
|
||||||
|
b.Property(e => e.Id)
|
||||||
|
.HasColumnName("GUID")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property(e => e.Active).HasColumnName("ACTIVE");
|
||||||
|
b.Property(e => e.Description).HasColumnName("DESCRIPTION");
|
||||||
|
b.Property(e => e.Uri).HasColumnName("URI");
|
||||||
|
b.Property(e => e.AddedWho).HasColumnName("ADDED_WHO");
|
||||||
|
b.Property(e => e.AddedWhen).HasColumnName("ADDED_WHEN");
|
||||||
|
b.Property(e => e.ChangedWho).HasColumnName("CHANGED_WHO");
|
||||||
|
b.Property(e => e.ChangedWhen).HasColumnName("CHANGED_WHEN");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<EndpointAuth>(b =>
|
||||||
|
{
|
||||||
|
b.ToTable("TBREC_CFG_ENDPOINT_AUTH");
|
||||||
|
|
||||||
|
b.HasKey(e => e.Id);
|
||||||
|
|
||||||
|
b.Property(e => e.Id)
|
||||||
|
.HasColumnName("GUID")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property(e => e.Active).HasColumnName("ACTIVE");
|
||||||
|
b.Property(e => e.Description).HasColumnName("DESCRIPTION");
|
||||||
|
b.Property(e => e.Type).HasColumnName("TYPE");
|
||||||
|
b.Property(e => e.ApiKey).HasColumnName("API_KEY");
|
||||||
|
b.Property(e => e.ApiValue).HasColumnName("API_VALUE");
|
||||||
|
b.Property(e => e.ApiKeyAddTo).HasColumnName("API_KEY_ADD_TO");
|
||||||
|
b.Property(e => e.Token).HasColumnName("TOKEN");
|
||||||
|
b.Property(e => e.Username).HasColumnName("USERNAME");
|
||||||
|
b.Property(e => e.Password).HasColumnName("PASSWORD");
|
||||||
|
b.Property(e => e.Domain).HasColumnName("DOMAIN");
|
||||||
|
b.Property(e => e.Workstation).HasColumnName("WORKSTATION");
|
||||||
|
b.Property(e => e.AddedWho).HasColumnName("ADDED_WHO");
|
||||||
|
b.Property(e => e.AddedWhen).HasColumnName("ADDED_WHEN");
|
||||||
|
b.Property(e => e.ChangedWho).HasColumnName("CHANGED_WHO");
|
||||||
|
b.Property(e => e.ChangedWhen).HasColumnName("CHANGED_WHEN");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<EndpointParam>(b =>
|
||||||
|
{
|
||||||
|
b.ToTable("TBREC_CFG_ENDPOINT_PARAMS", "dbo");
|
||||||
|
|
||||||
|
b.HasKey(e => e.Id);
|
||||||
|
|
||||||
|
b.Property(e => e.Id).HasColumnName("GUID");
|
||||||
|
b.Property(e => e.Active).HasColumnName("ACTIVE");
|
||||||
|
b.Property(e => e.Description).HasColumnName("DESCRIPTION");
|
||||||
|
b.Property(e => e.GroupId).HasColumnName("GROUP_ID");
|
||||||
|
b.Property(e => e.Sequence).HasColumnName("SEQUENCE");
|
||||||
|
b.Property(e => e.Key).HasColumnName("KEY");
|
||||||
|
b.Property(e => e.Value).HasColumnName("VALUE");
|
||||||
|
b.Property(e => e.AddedWho).HasColumnName("ADDED_WHO");
|
||||||
|
b.Property(e => e.AddedWhen).HasColumnName("ADDED_WHEN");
|
||||||
|
b.Property(e => e.ChangedWho).HasColumnName("CHANGED_WHO");
|
||||||
|
b.Property(e => e.ChangedWhen).HasColumnName("CHANGED_WHEN");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<OutRes>(b =>
|
||||||
|
{
|
||||||
|
b.ToTable("TBREC_OUT_RESULT", "dbo");
|
||||||
|
|
||||||
|
b.HasKey(e => e.Id);
|
||||||
|
|
||||||
|
b.Property(e => e.Id)
|
||||||
|
.HasColumnName("GUID")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property(e => e.ActionId).HasColumnName("ACTION_ID");
|
||||||
|
b.Property(e => e.Status).HasColumnName("STATUS");
|
||||||
|
b.Property(e => e.Header).HasColumnName("RESULT_HEADER");
|
||||||
|
b.Property(e => e.Body).HasColumnName("RESULT_BODY");
|
||||||
|
b.Property(e => e.AddedWho).HasColumnName("ADDED_WHO");
|
||||||
|
b.Property(e => e.AddedWhen).HasColumnName("ADDED_WHEN");
|
||||||
|
b.Property(e => e.ChangedWho).HasColumnName("CHANGED_WHO");
|
||||||
|
b.Property(e => e.ChangedWhen).HasColumnName("CHANGED_WHEN");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<Profile>(b =>
|
||||||
|
{
|
||||||
|
b.ToTable("TBREC_CFG_PROFILE", "dbo");
|
||||||
|
|
||||||
|
b.HasKey(e => e.Id);
|
||||||
|
|
||||||
|
b.Property(e => e.Id)
|
||||||
|
.HasColumnName("GUID")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property(e => e.Active).HasColumnName("ACTIVE");
|
||||||
|
b.Property(e => e.Type).HasColumnName("TYPE");
|
||||||
|
b.Property(e => e.Mandantor).HasColumnName("MANDANTOR");
|
||||||
|
b.Property(e => e.Name).HasColumnName("PROFILE_NAME");
|
||||||
|
b.Property(e => e.Description).HasColumnName("DESCRIPTION");
|
||||||
|
b.Property(e => e.LogLevel).HasColumnName("LOG_LEVEL");
|
||||||
|
b.Property(e => e.Language).HasColumnName("LANGUAGE");
|
||||||
|
b.Property(e => e.AddedWho).HasColumnName("ADDED_WHO");
|
||||||
|
b.Property(e => e.AddedWhen).HasColumnName("ADDED_WHEN");
|
||||||
|
b.Property(e => e.ChangedWho).HasColumnName("CHANGED_WHO");
|
||||||
|
b.Property(e => e.ChangedWhen).HasColumnName("CHANGED_WHEN");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<RecAction>(b =>
|
||||||
|
{
|
||||||
|
b.ToTable("TBREC_CFG_ACTION");
|
||||||
|
|
||||||
|
b.HasKey(e => e.Id);
|
||||||
|
|
||||||
|
b.Property(e => e.Id).HasColumnName("GUID");
|
||||||
|
b.Property(e => e.ProfileId).HasColumnName("PROFILE_ID");
|
||||||
|
b.Property(e => e.Active).HasColumnName("ACTIVE");
|
||||||
|
b.Property(e => e.Sequence).HasColumnName("SEQUENCE");
|
||||||
|
b.Property(e => e.EndpointId).HasColumnName("ENDPOINT_ID");
|
||||||
|
b.Property(e => e.EndpointAuthId).HasColumnName("ENDPOINT_AUTH_ID");
|
||||||
|
b.Property(e => e.EndpointParamsId).HasColumnName("ENDPOINT_PARAMS_ID");
|
||||||
|
b.Property(e => e.SqlConnectionId).HasColumnName("SQL_CONNECTION_ID");
|
||||||
|
b.Property(e => e.Type).HasColumnName("TYPE");
|
||||||
|
b.Property(e => e.PreprocessingQuery).HasColumnName("PREPROCESSING_QUERY");
|
||||||
|
b.Property(e => e.HeaderQuery).HasColumnName("HEADER_QUERY");
|
||||||
|
b.Property(e => e.BodyQuery).HasColumnName("BODY_QUERY");
|
||||||
|
b.Property(e => e.PostprocessingQuery).HasColumnName("POSTPROCESSING_QUERY");
|
||||||
|
b.Property(e => e.ErrorAction).HasColumnName("ERROR_ACTION");
|
||||||
|
b.Property(e => e.AddedWho).HasColumnName("ADDED_WHO");
|
||||||
|
b.Property(e => e.AddedWhen).HasColumnName("ADDED_WHEN");
|
||||||
|
b.Property(e => e.ChangedWho).HasColumnName("CHANGED_WHO");
|
||||||
|
b.Property(e => e.ChangedWhen).HasColumnName("CHANGED_WHEN");
|
||||||
|
|
||||||
|
b.HasOne(act => act.OutRes)
|
||||||
|
.WithOne(res => res.Action)
|
||||||
|
.HasForeignKey<OutRes>(res => res.ActionId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<RecActionView>(b =>
|
||||||
|
{
|
||||||
|
b.ToTable("VWREC_ACTION", "dbo");
|
||||||
|
b.HasNoKey();
|
||||||
|
|
||||||
|
b.Property(e => e.Id).HasColumnName("ACTION_ID");
|
||||||
|
b.Property(e => e.ProfileId).HasColumnName("PROFILE_ID");
|
||||||
|
b.Property(e => e.ProfileName).HasColumnName("PROFILE_NAME");
|
||||||
|
b.Property(e => e.ProfileType).HasColumnName("PROFILE_TYPE");
|
||||||
|
b.Property(e => e.Sequence).HasColumnName("SEQUENCE");
|
||||||
|
b.Property(e => e.EndpointId).HasColumnName("ENDPOINT_ID");
|
||||||
|
b.Property(e => e.EndpointUri).HasColumnName("ENDPOINT_URI");
|
||||||
|
b.Property(e => e.EndpointAuthId).HasColumnName("ENDPOINT_AUTH_ID");
|
||||||
|
b.Property(e => e.EndpointAuthType).HasColumnName("ENDPOINT_AUTH_TYPE");
|
||||||
|
b.Property(e => e.EndpointAuthApiKey).HasColumnName("ENDPOINT_AUTH_API_KEY");
|
||||||
|
b.Property(e => e.EndpointAuthApiValue).HasColumnName("ENDPOINT_AUTH_API_VALUE");
|
||||||
|
b.Property(e => e.EndpointAuthApiKeyAddTo).HasColumnName("ENDPOINT_AUTH_API_KEY_ADD_TO");
|
||||||
|
b.Property(e => e.EndpointAuthToken).HasColumnName("ENDPOINT_AUTH_TOKEN");
|
||||||
|
b.Property(e => e.EndpointAuthUsername).HasColumnName("ENDPOINT_AUTH_USERNAME");
|
||||||
|
b.Property(e => e.EndpointAuthPassword).HasColumnName("ENDPOINT_AUTH_PASSWORD");
|
||||||
|
b.Property(e => e.EndpointAuthDomain).HasColumnName("ENDPOINT_AUTH_DOMAIN");
|
||||||
|
b.Property(e => e.EndpointAuthWorkstation).HasColumnName("ENDPOINT_AUTH_WORKSTATION");
|
||||||
|
b.Property(e => e.EndpointParamsId).HasColumnName("ENDPOINT_PARAMS_ID");
|
||||||
|
b.Property(e => e.SqlConnectionId).HasColumnName("SQL_CONNECTION_ID");
|
||||||
|
b.Property(e => e.SqlConnectionServer).HasColumnName("SQL_CONNECTION_SERVER");
|
||||||
|
b.Property(e => e.SqlConnectionDb).HasColumnName("SQL_CONNECTION_DB");
|
||||||
|
b.Property(e => e.SqlConnectionUsername).HasColumnName("SQL_CONNECTION_USERNAME");
|
||||||
|
b.Property(e => e.SqlConnectionPassword).HasColumnName("SQL_CONNECTION_PASSWORD");
|
||||||
|
b.Property(e => e.RestType).HasColumnName("REST_TYPE");
|
||||||
|
b.Property(e => e.PreprocessingQuery).HasColumnName("PREPROCESSING_QUERY");
|
||||||
|
b.Property(e => e.HeaderQuery).HasColumnName("HEADER_QUERY");
|
||||||
|
b.Property(e => e.BodyQuery).HasColumnName("BODY_QUERY");
|
||||||
|
b.Property(e => e.PostprocessingQuery).HasColumnName("POSTPROCESSING_QUERY");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<HeaderQueryResult>(b =>
|
||||||
|
{
|
||||||
|
b.HasNoKey();
|
||||||
|
b.Property(e => e.RawHeader).HasColumnName("REQUEST_HEADER");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<BodyQueryResult>(b =>
|
||||||
|
{
|
||||||
|
b.HasNoKey();
|
||||||
|
b.Property(e => e.RawBody).HasColumnName("REQUEST_BODY");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<RecAction>()
|
|
||||||
.HasOne(act => act.OutRes)
|
|
||||||
.WithOne(res => res.Action)
|
|
||||||
.HasForeignKey<OutRes>(res => res.ActionId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user