Compare commits
45 Commits
3da16ba640
...
39fcee2b50
| Author | SHA1 | Date | |
|---|---|---|---|
| 39fcee2b50 | |||
| d0597e28e8 | |||
| d8d77652ac | |||
| 62612897bd | |||
| 99c50fb348 | |||
| 8aaf11f39d | |||
| 152189fefd | |||
| 5a4b8427be | |||
| e4a644a636 | |||
| 25c6c41b26 | |||
| c672a10c97 | |||
| 1e21218f31 | |||
| 68e7ee54f9 | |||
| 2a749267b3 | |||
| edc1de2034 | |||
| ae79a60605 | |||
| 6b8286a386 | |||
| 1fabc29e4f | |||
| 56fb34d987 | |||
| 47ddde239e | |||
| 5a4d2d8553 | |||
| 4e209e29fc | |||
| 78aaea67e6 | |||
| 98261f4e21 | |||
| aab8174500 | |||
| fb6d6af12b | |||
| f82f4d2c65 | |||
| 90ee3f6a5d | |||
| a24ec1ab3e | |||
| b8c30d520e | |||
| f69f323542 | |||
| 3621820060 | |||
| 0e0f27c124 | |||
| 5404530785 | |||
| 289b6109e4 | |||
| 679c065aaa | |||
| a02cac8778 | |||
| 42fd176fad | |||
| e529027587 | |||
| cc2adab5e5 | |||
| a0233fd876 | |||
| 0afe9870c0 | |||
| 784b4b1f05 | |||
| 1634b4b7b1 | |||
| 576b2d59d9 |
@@ -6,6 +6,7 @@ using ReC.Application.OutResults.Queries;
|
||||
|
||||
namespace ReC.API.Controllers;
|
||||
|
||||
[Obsolete("This controller is deprecated and will be removed in future versions. Use the new ResultViewController instead.")]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class OutResController(IMediator mediator, IConfiguration config) : ControllerBase
|
||||
|
||||
40
src/ReC.API/Controllers/ResultViewController.cs
Normal file
40
src/ReC.API/Controllers/ResultViewController.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ReC.API.Extensions;
|
||||
using ReC.Application.ResultViews.Queries;
|
||||
|
||||
namespace ReC.API.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class ResultViewController(IMediator mediator, IConfiguration config) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> Get([FromQuery] ReadResultViewQuery query, CancellationToken cancel) => Ok(await mediator.Send(query, cancel));
|
||||
|
||||
[HttpGet("fake")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> Get(CancellationToken cancel) => Ok(await mediator.Send(new ReadResultViewQuery()
|
||||
{
|
||||
ProfileId = config.GetFakeProfileId()
|
||||
}, cancel));
|
||||
|
||||
[HttpGet("fake/{actionId}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> Get([FromRoute] long actionId, CancellationToken cancel, ResultType resultType = ResultType.Full)
|
||||
{
|
||||
var res = (await mediator.Send(new ReadResultViewQuery()
|
||||
{
|
||||
ProfileId = config.GetFakeProfileId(),
|
||||
ActionId = actionId
|
||||
}, cancel)).First();
|
||||
|
||||
return resultType switch
|
||||
{
|
||||
ResultType.Body => res.Body is null ? Ok(new object { }) : Ok(res.Body.JsonToDynamic()),
|
||||
ResultType.Header => res.Header is null ? Ok(new object { }) : Ok(res.Header.JsonToDynamic()),
|
||||
_ => Ok(res),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,13 @@ try
|
||||
|
||||
var config = builder.Configuration;
|
||||
|
||||
Directory
|
||||
.GetFiles(builder.Environment.ContentRootPath, "appsettings.*.json", SearchOption.TopDirectoryOnly)
|
||||
.Where(file => Path.GetFileName(file) != $"appsettings.Development.json")
|
||||
.Where(file => Path.GetFileName(file) != $"appsettings.migration.json")
|
||||
.ToList()
|
||||
.ForEach(file => config.AddJsonFile(file, true, true));
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddRecServices(options =>
|
||||
{
|
||||
|
||||
59
src/ReC.API/appsettings.Logging.json
Normal file
59
src/ReC.API/appsettings.Logging.json
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"NLog": {
|
||||
"throwConfigExceptions": true,
|
||||
"variables": {
|
||||
"logDirectory": "E:\\LogFiles\\Digital Data\\Rec.API",
|
||||
"logFileNamePrefix": "${shortdate}.Rec.API"
|
||||
},
|
||||
"targets": {
|
||||
"infoLogs": {
|
||||
"type": "File",
|
||||
"fileName": "${logDirectory}\\${logFileNamePrefix}-Info.log",
|
||||
"maxArchiveDays": 30
|
||||
},
|
||||
"warningLogs": {
|
||||
"type": "File",
|
||||
"fileName": "${logDirectory}\\${logFileNamePrefix}-Warning.log",
|
||||
"maxArchiveDays": 30
|
||||
},
|
||||
"errorLogs": {
|
||||
"type": "File",
|
||||
"fileName": "${logDirectory}\\${logFileNamePrefix}-Error.log",
|
||||
"maxArchiveDays": 30
|
||||
},
|
||||
"criticalLogs": {
|
||||
"type": "File",
|
||||
"fileName": "${logDirectory}\\${logFileNamePrefix}-Critical.log",
|
||||
"maxArchiveDays": 30
|
||||
}
|
||||
},
|
||||
"rules": [
|
||||
{
|
||||
"logger": "*",
|
||||
"level": "Info",
|
||||
"writeTo": "infoLogs"
|
||||
},
|
||||
{
|
||||
"logger": "*",
|
||||
"level": "Warn",
|
||||
"writeTo": "warningLogs"
|
||||
},
|
||||
{
|
||||
"logger": "*",
|
||||
"level": "Error",
|
||||
"writeTo": "errorLogs"
|
||||
},
|
||||
{
|
||||
"logger": "*",
|
||||
"level": "Fatal",
|
||||
"writeTo": "criticalLogs"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,4 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"UseSwagger": true,
|
||||
"ConnectionStrings": {
|
||||
"Default": "Server=SDD-VMP04-SQL19\\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;"
|
||||
@@ -15,56 +9,5 @@
|
||||
"MaxConcurrentInvocations": 5
|
||||
},
|
||||
"AddedWho": "ReC.API",
|
||||
"FakeProfileId": 2,
|
||||
"NLog": {
|
||||
"throwConfigExceptions": true,
|
||||
"variables": {
|
||||
"logDirectory": "E:\\LogFiles\\Digital Data\\Rec.API",
|
||||
"logFileNamePrefix": "${shortdate}.Rec.API"
|
||||
},
|
||||
"targets": {
|
||||
"infoLogs": {
|
||||
"type": "File",
|
||||
"fileName": "${logDirectory}\\${logFileNamePrefix}-Info.log",
|
||||
"maxArchiveDays": 30
|
||||
},
|
||||
"warningLogs": {
|
||||
"type": "File",
|
||||
"fileName": "${logDirectory}\\${logFileNamePrefix}-Warning.log",
|
||||
"maxArchiveDays": 30
|
||||
},
|
||||
"errorLogs": {
|
||||
"type": "File",
|
||||
"fileName": "${logDirectory}\\${logFileNamePrefix}-Error.log",
|
||||
"maxArchiveDays": 30
|
||||
},
|
||||
"criticalLogs": {
|
||||
"type": "File",
|
||||
"fileName": "${logDirectory}\\${logFileNamePrefix}-Critical.log",
|
||||
"maxArchiveDays": 30
|
||||
}
|
||||
},
|
||||
"rules": [
|
||||
{
|
||||
"logger": "*",
|
||||
"level": "Info",
|
||||
"writeTo": "infoLogs"
|
||||
},
|
||||
{
|
||||
"logger": "*",
|
||||
"level": "Warn",
|
||||
"writeTo": "warningLogs"
|
||||
},
|
||||
{
|
||||
"logger": "*",
|
||||
"level": "Error",
|
||||
"writeTo": "errorLogs"
|
||||
},
|
||||
{
|
||||
"logger": "*",
|
||||
"level": "Fatal",
|
||||
"writeTo": "criticalLogs"
|
||||
}
|
||||
]
|
||||
}
|
||||
"FakeProfileId": 2
|
||||
}
|
||||
@@ -16,5 +16,8 @@ public class DtoMappingProfile : AutoMapper.Profile
|
||||
CreateMap<EndpointParam, EndpointParamDto>();
|
||||
CreateMap<Profile, ProfileDto>();
|
||||
CreateMap<RecAction, RecActionDto>();
|
||||
|
||||
CreateMap<ResultView, ResultViewDto>();
|
||||
CreateMap<ProfileView, ProfileViewDto>();
|
||||
}
|
||||
}
|
||||
|
||||
42
src/ReC.Application/Common/Dto/ProfileViewDto.cs
Normal file
42
src/ReC.Application/Common/Dto/ProfileViewDto.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
namespace ReC.Application.Common.Dto;
|
||||
|
||||
public class ProfileViewDto
|
||||
{
|
||||
public long Id { get; init; }
|
||||
|
||||
public IEnumerable<RecActionViewDto>? RecActions { get; set; }
|
||||
|
||||
public bool Active { get; init; }
|
||||
|
||||
public byte TypeId { get; init; }
|
||||
|
||||
public string? Type { get; init; }
|
||||
|
||||
public string? Mandantor { get; init; }
|
||||
|
||||
public string? ProfileName { get; init; }
|
||||
|
||||
public string? Description { get; init; }
|
||||
|
||||
public byte LogLevelId { get; init; }
|
||||
|
||||
public string? LogLevel { get; init; }
|
||||
|
||||
public short LanguageId { get; init; }
|
||||
|
||||
public string? Language { get; init; }
|
||||
|
||||
public string? AddedWho { get; init; }
|
||||
|
||||
public DateTime AddedWhen { get; init; }
|
||||
|
||||
public string? ChangedWho { get; init; }
|
||||
|
||||
public DateTime? ChangedWhen { get; init; }
|
||||
|
||||
public DateTime? FirstRun { get; init; }
|
||||
|
||||
public DateTime? LastRun { get; init; }
|
||||
|
||||
public string? LastResult { get; init; }
|
||||
}
|
||||
@@ -10,9 +10,9 @@ public record RecActionViewDto
|
||||
|
||||
public string? ProfileName { get; init; }
|
||||
|
||||
public string? ProfileType { get; init; }
|
||||
public ProfileType? ProfileType { get; init; }
|
||||
|
||||
public byte? ProfileSequence { get; init; }
|
||||
public byte? Sequence { get; init; }
|
||||
|
||||
public long? EndpointId { get; init; }
|
||||
|
||||
@@ -22,12 +22,16 @@ public record RecActionViewDto
|
||||
|
||||
public EndpointAuthType? EndpointAuthType { get; init; }
|
||||
|
||||
public string? EndpointAuthTypeName { get; init; }
|
||||
|
||||
public string? EndpointAuthApiKey { get; init; }
|
||||
|
||||
public string? EndpointAuthApiValue { get; init; }
|
||||
|
||||
public ApiKeyLocation? EndpointAuthApiKeyAddTo { get; init; }
|
||||
|
||||
public string? EndpointAuthApiKeyAddToName { get; init; }
|
||||
|
||||
public string? EndpointAuthToken { get; init; }
|
||||
|
||||
public string? EndpointAuthUsername { get; init; }
|
||||
@@ -50,7 +54,9 @@ public record RecActionViewDto
|
||||
|
||||
public string? SqlConnectionPassword { get; init; }
|
||||
|
||||
public string? RestType { get; init; }
|
||||
public RestType? RestType { get; init; }
|
||||
|
||||
public string? RestTypeName { get; init; }
|
||||
|
||||
public string? PreprocessingQuery { get; init; }
|
||||
|
||||
@@ -64,7 +70,9 @@ public record RecActionViewDto
|
||||
|
||||
public string? PostprocessingQuery { get; init; }
|
||||
|
||||
public ErrorAction ErrorAction { get; init; }
|
||||
public ErrorAction? ErrorAction { get; init; }
|
||||
|
||||
public string? ErrorActionName { get; init; }
|
||||
|
||||
public UriBuilder ToEndpointUriBuilder()
|
||||
{
|
||||
@@ -72,8 +80,8 @@ public record RecActionViewDto
|
||||
|
||||
builder.Port = -1;
|
||||
|
||||
if (ProfileType is not null)
|
||||
builder.Scheme = ProfileType;
|
||||
if (ProfileType is ProfileType type)
|
||||
builder.Scheme = type.ToUriBuilderScheme();
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
34
src/ReC.Application/Common/Dto/ResultViewDto.cs
Normal file
34
src/ReC.Application/Common/Dto/ResultViewDto.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
namespace ReC.Application.Common.Dto;
|
||||
|
||||
public record ResultViewDto
|
||||
{
|
||||
public long Id { get; init; }
|
||||
|
||||
public OutResDto? Root { get; init; }
|
||||
|
||||
public long? ActionId { get; init; }
|
||||
|
||||
public RecActionViewDto? Action { get; init; }
|
||||
|
||||
public long? ProfileId { get; init; }
|
||||
|
||||
public ProfileViewDto? Profile { get; init; }
|
||||
|
||||
public string? ProfileName { get; init; }
|
||||
|
||||
public short? StatusCode { get; init; }
|
||||
|
||||
public string? StatusName { get; init; }
|
||||
|
||||
public string? Header { get; init; }
|
||||
|
||||
public string? Body { get; init; }
|
||||
|
||||
public string? AddedWho { get; init; }
|
||||
|
||||
public DateTime? AddedWhen { get; init; }
|
||||
|
||||
public string? ChangedWho { get; init; }
|
||||
|
||||
public DateTime? ChangedWhen { get; init; }
|
||||
}
|
||||
@@ -1,25 +1,28 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ReC.Domain.Constants;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace ReC.Application.Common;
|
||||
|
||||
public static class HttpExtensions
|
||||
{
|
||||
private static readonly Dictionary<string, HttpMethod> _methods = new(StringComparer.OrdinalIgnoreCase)
|
||||
private static readonly Dictionary<RestType, HttpMethod> _methods = new()
|
||||
{
|
||||
["GET"] = HttpMethod.Get,
|
||||
["POST"] = HttpMethod.Post,
|
||||
["PUT"] = HttpMethod.Put,
|
||||
["DELETE"] = HttpMethod.Delete,
|
||||
["PATCH"] = HttpMethod.Patch,
|
||||
["HEAD"] = HttpMethod.Head,
|
||||
["OPTIONS"] = HttpMethod.Options,
|
||||
["TRACE"] = HttpMethod.Trace,
|
||||
["CONNECT"] = HttpMethod.Connect
|
||||
[RestType.Get] = HttpMethod.Get,
|
||||
[RestType.Post] = HttpMethod.Post,
|
||||
[RestType.Put] = HttpMethod.Put,
|
||||
[RestType.Delete] = HttpMethod.Delete,
|
||||
[RestType.Patch] = HttpMethod.Patch,
|
||||
[RestType.Head] = HttpMethod.Head,
|
||||
[RestType.Options] = HttpMethod.Options,
|
||||
[RestType.Trace] = HttpMethod.Trace,
|
||||
[RestType.Connect] = HttpMethod.Connect
|
||||
};
|
||||
|
||||
public static HttpMethod ToHttpMethod(this string method) => _methods.TryGetValue(method, out var httpMethod)
|
||||
? httpMethod
|
||||
: new HttpMethod(method);
|
||||
public static HttpMethod ToHttpMethod(this RestType method) => !method.IsValid()
|
||||
? throw new ArgumentOutOfRangeException(nameof(method), $"The RestType value '{method}' is not valid.")
|
||||
: _methods.TryGetValue(method, out var httpMethod)
|
||||
? httpMethod
|
||||
: new HttpMethod(method.ToHttpMethodName());
|
||||
|
||||
public static HttpRequestMessage ToHttpRequestMessage(this HttpMethod method, [StringSyntax(StringSyntaxAttribute.Uri)] string? requestUri)
|
||||
=> new(method, requestUri);
|
||||
|
||||
@@ -15,15 +15,15 @@ public interface IRecDbContext
|
||||
|
||||
public DbSet<BodyQueryResult> BodyQueryResults { get; set; }
|
||||
|
||||
public DbSet<ConnectionDto> Connections { get; set; }
|
||||
public DbSet<Connection> Connections { get; set; }
|
||||
|
||||
public DbSet<EndpointDto> Endpoints { get; set; }
|
||||
public DbSet<Endpoint> Endpoints { get; set; }
|
||||
|
||||
public DbSet<EndpointAuthDto> EndpointAuths { get; set; }
|
||||
public DbSet<EndpointAuth> EndpointAuths { get; set; }
|
||||
|
||||
public DbSet<ProfileDto> Profiles { get; set; }
|
||||
public DbSet<Profile> Profiles { get; set; }
|
||||
|
||||
public DbSet<RecActionDto> RecActions { get; set; }
|
||||
public DbSet<RecAction> RecActions { get; set; }
|
||||
|
||||
public Task<int> SaveChangesAsync(CancellationToken cancel = default);
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReC.Application.Common.Dto;
|
||||
using ReC.Domain.Entities;
|
||||
|
||||
namespace ReC.Application.Endpoints.Commands;
|
||||
@@ -10,16 +12,16 @@ public class ObtainEndpointCommand : IRequest<EndpointDto>
|
||||
public string Uri { get; init; } = null!;
|
||||
}
|
||||
|
||||
public class ObtainEndpointCommandHandler(IRepository<EndpointDto> repo) : IRequestHandler<ObtainEndpointCommand, EndpointDto>
|
||||
public class ObtainEndpointCommandHandler(IRepository<Endpoint> repo, IMapper mapper) : IRequestHandler<ObtainEndpointCommand, EndpointDto>
|
||||
{
|
||||
public async Task<EndpointDto> Handle(ObtainEndpointCommand request, CancellationToken cancel)
|
||||
{
|
||||
var endpoint = await repo.Where(e => e.Uri == request.Uri).FirstOrDefaultAsync(cancel);
|
||||
|
||||
if (endpoint is not null)
|
||||
return endpoint;
|
||||
return mapper.Map<EndpointDto>(endpoint);
|
||||
|
||||
endpoint = await repo.CreateAsync(request, cancel);
|
||||
return endpoint;
|
||||
return mapper.Map<EndpointDto>(endpoint);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using ReC.Application.Endpoints.Commands;
|
||||
using ReC.Domain.Entities;
|
||||
using ReC.Application.Common.Dto;
|
||||
|
||||
namespace ReC.Application.Endpoints;
|
||||
|
||||
|
||||
@@ -4,7 +4,10 @@ using ReC.Domain.Constants;
|
||||
|
||||
namespace ReC.Application.RecActionViews.Commands;
|
||||
|
||||
public record InvokeBatchRecActionViewsCommand : ReadRecActionQueryBase, IRequest;
|
||||
public record InvokeBatchRecActionViewsCommand : IRequest
|
||||
{
|
||||
public long ProfileId { get; init; }
|
||||
}
|
||||
|
||||
public static class InvokeBatchRecActionViewsCommandExtensions
|
||||
{
|
||||
@@ -16,7 +19,7 @@ public class InvokeRecActionViewsCommandHandler(ISender sender) : IRequestHandle
|
||||
{
|
||||
public async Task Handle(InvokeBatchRecActionViewsCommand request, CancellationToken cancel)
|
||||
{
|
||||
var actions = await sender.Send(request.ToReadQuery(q => q.Invoked = false), cancel);
|
||||
var actions = await sender.Send(new ReadRecActionViewQuery() { ProfileId = request.ProfileId, Invoked = false }, cancel);
|
||||
|
||||
foreach (var action in actions)
|
||||
{
|
||||
|
||||
@@ -35,14 +35,14 @@ public class InvokeRecActionViewCommandHandler(
|
||||
|
||||
using var http = clientFactory.CreateClient(Http.ClientName);
|
||||
|
||||
if (action.RestType is null)
|
||||
if (action.RestType is not RestType restType)
|
||||
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
|
||||
using var httpReq = restType
|
||||
.ToHttpMethod()
|
||||
.ToHttpRequestMessage(action.EndpointUri);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using ReC.Application.RecActions.Commands;
|
||||
using ReC.Domain.Entities;
|
||||
using ReC.Application.Common.Dto;
|
||||
using ReC.Application.RecActions.Commands;
|
||||
|
||||
namespace ReC.Application.RecActions;
|
||||
namespace ReC.Application.RecActionViews;
|
||||
|
||||
// TODO: update to inject AddedWho from the current host/user contex
|
||||
public class MappingProfile : AutoMapper.Profile
|
||||
|
||||
@@ -8,32 +8,21 @@ using ReC.Application.Common.Dto;
|
||||
|
||||
namespace ReC.Application.RecActionViews.Queries;
|
||||
|
||||
public record ReadRecActionQueryBase
|
||||
public record ReadRecActionViewQuery : IRequest<IEnumerable<RecActionViewDto>>
|
||||
{
|
||||
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 long? ProfileId { get; init; } = null;
|
||||
|
||||
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);
|
||||
var query = repo.Query;
|
||||
|
||||
if (request.ProfileId is long profileId)
|
||||
query = repo.Where(act => act.ProfileId == profileId);
|
||||
|
||||
if (request.Invoked is bool invoked)
|
||||
query = invoked ? query.Where(act => act.Root!.OutRes != null) : query.Where(act => act.Root!.OutRes == null);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using DigitalData.Core.Exceptions;
|
||||
using MediatR;
|
||||
using ReC.Application.Endpoints.Commands;
|
||||
using ReC.Domain.Entities;
|
||||
using ReC.Application.Endpoints.Commands;
|
||||
|
||||
namespace ReC.Application.RecActions.Commands;
|
||||
|
||||
@@ -27,7 +27,7 @@ public record CreateRecActionCommand : IRequest
|
||||
public long? EndpointAuthId { get; set; }
|
||||
}
|
||||
|
||||
public class CreateRecActionCommandHandler(ISender sender, IRepository<RecActionDto> repo) : IRequestHandler<CreateRecActionCommand>
|
||||
public class CreateRecActionCommandHandler(ISender sender, IRepository<RecAction> repo) : IRequestHandler<CreateRecActionCommand>
|
||||
{
|
||||
public async Task Handle(CreateRecActionCommand request, CancellationToken cancel)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ public class DeleteRecActionsCommand : IRequest
|
||||
public required long ProfileId { get; init; }
|
||||
}
|
||||
|
||||
public class DeleteRecActionsCommandHandler(IRepository<RecActionDto> repo) : IRequestHandler<DeleteRecActionsCommand>
|
||||
public class DeleteRecActionsCommandHandler(IRepository<RecAction> repo) : IRequestHandler<DeleteRecActionsCommand>
|
||||
{
|
||||
public async Task Handle(DeleteRecActionsCommand request, CancellationToken cancel)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using DigitalData.Core.Exceptions;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReC.Application.Common.Dto;
|
||||
using ReC.Domain.Entities;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ReC.Application.ResultViews.Queries;
|
||||
|
||||
public record ReadResultViewQuery : IRequest<IEnumerable<ResultViewDto>>
|
||||
{
|
||||
public long? Id { get; init; } = null;
|
||||
|
||||
public long? ActionId { get; init; } = null;
|
||||
|
||||
public long? ProfileId { get; init; } = null;
|
||||
}
|
||||
|
||||
public class ReadResultViewQueryHandler(IRepository<ResultView> repo, IMapper mapper) : IRequestHandler<ReadResultViewQuery, IEnumerable<ResultViewDto>>
|
||||
{
|
||||
public async Task<IEnumerable<ResultViewDto>> Handle(ReadResultViewQuery request, CancellationToken cancel)
|
||||
{
|
||||
var q = repo.Query;
|
||||
|
||||
if(request.Id is long id)
|
||||
q = q.Where(rv => rv.Id == id);
|
||||
|
||||
if(request.ActionId is long actionId)
|
||||
q = q.Where(rv => rv.ActionId == actionId);
|
||||
|
||||
if(request.ProfileId is long profileId)
|
||||
q = q.Where(rv => rv.ProfileId == profileId);
|
||||
|
||||
var entities = await q.ToListAsync(cancel);
|
||||
|
||||
if (entities.Count == 0)
|
||||
throw new NotFoundException($"No result views found for the given criteria. Criteria: {
|
||||
JsonSerializer.Serialize(request, options: new()
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
WriteIndented = true
|
||||
})}"
|
||||
);
|
||||
|
||||
return mapper.Map<IEnumerable<ResultViewDto>>(entities);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace ReC.Domain.Constants;
|
||||
|
||||
public enum ApiKeyLocation
|
||||
public enum ApiKeyLocation : byte
|
||||
{
|
||||
Header = 0,
|
||||
Query = 1
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace ReC.Domain.Constants;
|
||||
|
||||
public enum EndpointAuthType
|
||||
public enum EndpointAuthType : byte
|
||||
{
|
||||
NoAuth = 0,
|
||||
ApiKey = 1,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace ReC.Domain.Constants;
|
||||
|
||||
public enum ErrorAction
|
||||
public enum ErrorAction : byte
|
||||
{
|
||||
Stop = 0,
|
||||
Continue = 1,
|
||||
|
||||
12
src/ReC.Domain/Constants/ProfileType.cs
Normal file
12
src/ReC.Domain/Constants/ProfileType.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace ReC.Domain.Constants;
|
||||
|
||||
public enum ProfileType : byte
|
||||
{
|
||||
Http = 1,
|
||||
Https = 2
|
||||
}
|
||||
|
||||
public static class ProfileTypeExtensions
|
||||
{
|
||||
public static string ToUriBuilderScheme(this ProfileType profileType) => profileType.ToString().ToLower();
|
||||
}
|
||||
28
src/ReC.Domain/Constants/RestType.cs
Normal file
28
src/ReC.Domain/Constants/RestType.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace ReC.Domain.Constants;
|
||||
|
||||
public enum RestType : byte
|
||||
{
|
||||
None = 0,
|
||||
Get = 1,
|
||||
Post = 2,
|
||||
Put = 3,
|
||||
Patch = 4,
|
||||
Delete = 5,
|
||||
Head = 6,
|
||||
Options = 7,
|
||||
Connect = 8,
|
||||
Trace = 9,
|
||||
}
|
||||
|
||||
public static class RestTypeExtensions
|
||||
{
|
||||
public static string ToHttpMethodName(this RestType restType)
|
||||
{
|
||||
return restType.ToString().ToUpper();
|
||||
}
|
||||
|
||||
public static bool IsValid(this RestType restType)
|
||||
{
|
||||
return restType != RestType.None;
|
||||
}
|
||||
}
|
||||
42
src/ReC.Domain/Entities/ProfileView.cs
Normal file
42
src/ReC.Domain/Entities/ProfileView.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using ReC.Domain.Constants;
|
||||
|
||||
namespace ReC.Domain.Entities;
|
||||
|
||||
public record ProfileView
|
||||
{
|
||||
public long Id { get; init; }
|
||||
|
||||
public bool Active { get; init; }
|
||||
|
||||
public ProfileType TypeId { get; init; }
|
||||
|
||||
public string? Type { get; init; }
|
||||
|
||||
public string? Mandantor { get; init; }
|
||||
|
||||
public string? ProfileName { get; init; }
|
||||
|
||||
public string? Description { get; init; }
|
||||
|
||||
public byte LogLevelId { get; init; }
|
||||
|
||||
public string? LogLevel { get; init; }
|
||||
|
||||
public short LanguageId { get; init; }
|
||||
|
||||
public string? Language { get; init; }
|
||||
|
||||
public string? AddedWho { get; init; }
|
||||
|
||||
public DateTime AddedWhen { get; init; }
|
||||
|
||||
public string? ChangedWho { get; init; }
|
||||
|
||||
public DateTime? ChangedWhen { get; init; }
|
||||
|
||||
public DateTime? FirstRun { get; init; }
|
||||
|
||||
public DateTime? LastRun { get; init; }
|
||||
|
||||
public string? LastResult { get; init; }
|
||||
}
|
||||
@@ -22,11 +22,11 @@ public class RecActionView
|
||||
public long? ProfileId { get; set; }
|
||||
|
||||
[ForeignKey("ProfileId")]
|
||||
public Profile? Profile { get; set; }
|
||||
public ProfileView? Profile { get; set; }
|
||||
|
||||
public string? ProfileName { get; set; }
|
||||
|
||||
public string? ProfileType { get; set; }
|
||||
public ProfileType? ProfileType { get; set; }
|
||||
|
||||
public byte? Sequence { get; set; }
|
||||
|
||||
@@ -44,12 +44,16 @@ public class RecActionView
|
||||
|
||||
public EndpointAuthType? EndpointAuthType { get; set; }
|
||||
|
||||
public string? EndpointAuthTypeName { get; set; }
|
||||
|
||||
public string? EndpointAuthApiKey { get; set; }
|
||||
|
||||
public string? EndpointAuthApiValue { get; set; }
|
||||
|
||||
public ApiKeyLocation? EndpointAuthApiKeyAddTo { get; set; }
|
||||
|
||||
public string? EndpointAuthApiKeyAddToName { get; set; }
|
||||
|
||||
public string? EndpointAuthToken { get; set; }
|
||||
|
||||
public string? EndpointAuthUsername { get; set; }
|
||||
@@ -75,7 +79,9 @@ public class RecActionView
|
||||
|
||||
public string? SqlConnectionPassword { get; set; }
|
||||
|
||||
public string? RestType { get; set; }
|
||||
public RestType? RestType { get; set; }
|
||||
|
||||
public string? RestTypeName { get; set; }
|
||||
|
||||
public string? PreprocessingQuery { get; set; }
|
||||
|
||||
@@ -84,4 +90,8 @@ public class RecActionView
|
||||
public string? BodyQuery { get; set; }
|
||||
|
||||
public string? PostprocessingQuery { get; set; }
|
||||
|
||||
public ErrorAction? ErrorAction { get; set; }
|
||||
|
||||
public string? ErrorActionName { get; set; }
|
||||
}
|
||||
37
src/ReC.Domain/Entities/ResultView.cs
Normal file
37
src/ReC.Domain/Entities/ResultView.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReC.Domain.Entities;
|
||||
|
||||
public class ResultView
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
[ForeignKey("Id")]
|
||||
public OutRes? Root { get; set; }
|
||||
|
||||
public long? ActionId { get; set; }
|
||||
|
||||
public RecActionView? Action { get; set; }
|
||||
|
||||
public long? ProfileId { get; set; }
|
||||
|
||||
public ProfileView? Profile { get; set; }
|
||||
|
||||
public string? ProfileName { get; set; }
|
||||
|
||||
public short? StatusCode { get; set; }
|
||||
|
||||
public string? StatusName { get; set; }
|
||||
|
||||
public string? Header { get; set; }
|
||||
|
||||
public string? Body { get; set; }
|
||||
|
||||
public string? AddedWho { get; set; }
|
||||
|
||||
public DateTime? AddedWhen { get; set; }
|
||||
|
||||
public string? ChangedWho { get; set; }
|
||||
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
}
|
||||
@@ -10,6 +10,10 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
|
||||
|
||||
public DbSet<RecActionView> RecActionViews { get; set; }
|
||||
|
||||
public DbSet<ProfileView> ProfileViews { get; set; }
|
||||
|
||||
public DbSet<ResultView> RecResultViews { get; set; }
|
||||
|
||||
public DbSet<OutRes> OutRes { get; set; }
|
||||
|
||||
public DbSet<HeaderQueryResult> HeaderQueryResults { get; set; }
|
||||
@@ -131,7 +135,7 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property(e => e.ActionId).HasColumnName("ACTION_ID");
|
||||
b.Property(e => e.Status).HasColumnName("STATUS");
|
||||
b.Property(e => e.Status).HasColumnName("STATUS_ID");
|
||||
b.Property(e => e.Header).HasColumnName("RESULT_HEADER");
|
||||
b.Property(e => e.Body).HasColumnName("RESULT_BODY");
|
||||
b.Property(e => e.AddedWho).HasColumnName("ADDED_WHO");
|
||||
@@ -163,6 +167,31 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
|
||||
b.Property(e => e.ChangedWhen).HasColumnName("CHANGED_WHEN");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ProfileView>(b =>
|
||||
{
|
||||
b.ToView("VWREC_PROFILE", "dbo");
|
||||
b.HasKey(e => e.Id);
|
||||
|
||||
b.Property(e => e.Id).HasColumnName("PROFILE_GUID");
|
||||
b.Property(e => e.Active).HasColumnName("ACTIVE");
|
||||
b.Property(e => e.TypeId).HasColumnName("TYPE_ID");
|
||||
b.Property(e => e.Type).HasColumnName("TYPE");
|
||||
b.Property(e => e.Mandantor).HasColumnName("MANDANTOR");
|
||||
b.Property(e => e.ProfileName).HasColumnName("PROFILE_NAME");
|
||||
b.Property(e => e.Description).HasColumnName("DESCRIPTION");
|
||||
b.Property(e => e.LogLevelId).HasColumnName("LOG_LEVEL_ID");
|
||||
b.Property(e => e.LogLevel).HasColumnName("LOG_LEVEL");
|
||||
b.Property(e => e.LanguageId).HasColumnName("LANGUAGE_ID");
|
||||
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");
|
||||
b.Property(e => e.FirstRun).HasColumnName("FIRST_RUN");
|
||||
b.Property(e => e.LastRun).HasColumnName("LAST_RUN");
|
||||
b.Property(e => e.LastResult).HasColumnName("LAST_RESULT");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<RecAction>(b =>
|
||||
{
|
||||
b.ToTable("TBREC_CFG_ACTION");
|
||||
@@ -196,21 +225,23 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
|
||||
|
||||
modelBuilder.Entity<RecActionView>(b =>
|
||||
{
|
||||
b.ToTable("VWREC_ACTION", "dbo");
|
||||
b.HasNoKey();
|
||||
b.ToView("VWREC_ACTION", "dbo");
|
||||
b.HasKey(e => e.Id);
|
||||
|
||||
b.Property(e => e.Id).HasColumnName("ACTION_ID");
|
||||
b.Property(e => e.Id).HasColumnName("ACTION_GUID");
|
||||
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.ProfileType).HasColumnName("PROFILE_TYPE_ID");
|
||||
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.EndpointAuthType).HasColumnName("ENDPOINT_AUTH_TYPE_ID");
|
||||
b.Property(e => e.EndpointAuthTypeName).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.EndpointAuthApiKeyAddTo).HasColumnName("ENDPOINT_AUTH_API_KEY_ADD_TO_ID");
|
||||
b.Property(e => e.EndpointAuthApiKeyAddToName).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");
|
||||
@@ -222,11 +253,33 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
|
||||
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.RestType).HasColumnName("REST_TYPE_ID");
|
||||
b.Property(e => e.RestTypeName).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");
|
||||
b.Property(e => e.ErrorAction).HasColumnName("ERROR_ACTION_ID");
|
||||
b.Property(e => e.ErrorActionName).HasColumnName("ERROR_ACTION");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ResultView>(b =>
|
||||
{
|
||||
b.ToView("VWREC_RESULT", "dbo");
|
||||
b.HasKey(e => e.Id);
|
||||
|
||||
b.Property(e => e.Id).HasColumnName("RESULT_GUID");
|
||||
b.Property(e => e.ActionId).HasColumnName("ACTION_ID");
|
||||
b.Property(e => e.ProfileId).HasColumnName("PROFILE_ID");
|
||||
b.Property(e => e.ProfileName).HasColumnName("PROFILE_NAME");
|
||||
b.Property(e => e.StatusCode).HasColumnName("STATUS_ID");
|
||||
b.Property(e => e.StatusName).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<HeaderQueryResult>(b =>
|
||||
|
||||
Reference in New Issue
Block a user