Compare commits
21 Commits
b6000a56d6
...
d8d75829f0
| Author | SHA1 | Date | |
|---|---|---|---|
| d8d75829f0 | |||
| 5697eb3dd8 | |||
| 2cf4d73cf3 | |||
| 495a5247bc | |||
| 5ba012cc13 | |||
| 89879d0821 | |||
| d62175f6ec | |||
| a6cb0081ee | |||
| 7214b09640 | |||
| 21d09df037 | |||
| eab38f1e34 | |||
| e552658d2e | |||
| d902cfb756 | |||
| cae3ec31c4 | |||
| 1e22e4d851 | |||
| 163b5bc2f9 | |||
| b94a620389 | |||
| 2af140db96 | |||
| 304970f47a | |||
| c33144ad7b | |||
| 3be1d04a43 |
@ -1,15 +1,17 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ReC.Application.RecActions.Commands;
|
||||
|
||||
namespace ReC.API.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class ActionController : ControllerBase
|
||||
public class ActionController(IMediator mediator) : ControllerBase
|
||||
{
|
||||
[HttpPost("{profileId}")]
|
||||
public Task<IActionResult> Trigger([FromRoute] int profileId)
|
||||
public async Task<IActionResult> Invoke([FromRoute] int profileId)
|
||||
{
|
||||
// Implementation for retrieving actions would go here.
|
||||
throw new NotImplementedException();
|
||||
await mediator.InvokeRecAction(profileId);
|
||||
return Accepted();
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReC.Infrastructure;
|
||||
using ReC.Application;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddRecServices(options =>
|
||||
{
|
||||
options.LuckyPennySoftwareLicenseKey = builder.Configuration["LuckyPennySoftwareLicenseKey"];
|
||||
});
|
||||
|
||||
builder.Services.AddRecInfrastructure(options =>
|
||||
{
|
||||
options.ConfigureDbContext((dbContextOpt) =>
|
||||
{
|
||||
var connectionString = builder.Configuration.GetConnectionString("Default")
|
||||
?? throw new InvalidOperationException("Connection string is not found.");
|
||||
dbContextOpt.UseSqlServer(connectionString);
|
||||
});
|
||||
});
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
@ -7,7 +7,13 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.11" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ReC.Application\ReC.Application.csproj" />
|
||||
<ProjectReference Include="..\ReC.Infrastructure\ReC.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -5,5 +5,6 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
"AllowedHosts": "*",
|
||||
"MediatRLicense": "eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx1Y2t5UGVubnlTb2Z0d2FyZUxpY2Vuc2VLZXkvYmJiMTNhY2I1OTkwNGQ4OWI0Y2IxYzg1ZjA4OGNjZjkiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2x1Y2t5cGVubnlzb2Z0d2FyZS5jb20iLCJhdWQiOiJMdWNreVBlbm55U29mdHdhcmUiLCJleHAiOiIxNzg0ODUxMjAwIiwiaWF0IjoiMTc1MzM2MjQ5MSIsImFjY291bnRfaWQiOiIwMTk4M2M1OWU0YjM3MjhlYmZkMzEwM2MyYTQ4NmU4NSIsImN1c3RvbWVyX2lkIjoiY3RtXzAxazB5NmV3MmQ4YTk4Mzg3aDJnbTRuOWswIiwic3ViX2lkIjoiLSIsImVkaXRpb24iOiIwIiwidHlwZSI6IjIifQ.ZqsFG7kv_-xGfxS6ACk3i0iuNiVUXX2AvPI8iAcZ6-z2170lGv__aO32tWpQccD9LCv5931lBNLWSblKS0MT3gOt-5he2TEftwiSQGFwoIBgtOHWsNRMinUrg2trceSp3IhyS3UaMwnxZDrCvx4-0O-kpOzVpizeHUAZNr5U7oSCWO34bpKdae6grtM5e3f93Z1vs7BW_iPgItd-aLvPwApbaG9VhmBTKlQ7b4Jh64y7UXJ9mKP7Qb_Oa97oEg0oY5DPHOWTZWeE1EzORgVr2qkK2DELSHuZ_EIUhODojkClPNAKtvEl_qEjpq0HZCIvGwfCCRlKlSkQqIeZdFkiXg"
|
||||
}
|
||||
32
src/ReC.Application/DependencyInjection.cs
Normal file
32
src/ReC.Application/DependencyInjection.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ReC.Application;
|
||||
|
||||
public static class DependencyInjection
|
||||
{
|
||||
public static IServiceCollection AddRecServices(this IServiceCollection services, Action<ConfigurationOptions> options)
|
||||
{
|
||||
var configOpt = new ConfigurationOptions();
|
||||
options.Invoke(configOpt);
|
||||
|
||||
services.AddAutoMapper(cfg =>
|
||||
{
|
||||
cfg.AddMaps(Assembly.GetExecutingAssembly());
|
||||
cfg.LicenseKey = configOpt.LuckyPennySoftwareLicenseKey;
|
||||
});
|
||||
|
||||
services.AddMediatR(cfg =>
|
||||
{
|
||||
cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
|
||||
cfg.LicenseKey = configOpt.LuckyPennySoftwareLicenseKey;
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public class ConfigurationOptions
|
||||
{
|
||||
public string? LuckyPennySoftwareLicenseKey { get; set; }
|
||||
}
|
||||
}
|
||||
12
src/ReC.Application/Dto/DtoMappingProfile.cs
Normal file
12
src/ReC.Application/Dto/DtoMappingProfile.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using AutoMapper;
|
||||
using ReC.Domain.Entities;
|
||||
|
||||
namespace ReC.Application.Dto;
|
||||
|
||||
public class DtoMappingProfile : Profile
|
||||
{
|
||||
public DtoMappingProfile()
|
||||
{
|
||||
CreateMap<RecAction, RecActionDto>();
|
||||
}
|
||||
}
|
||||
60
src/ReC.Application/Dto/RecActionDto.cs
Normal file
60
src/ReC.Application/Dto/RecActionDto.cs
Normal file
@ -0,0 +1,60 @@
|
||||
namespace ReC.Application.Dto;
|
||||
|
||||
public class RecActionDto
|
||||
{
|
||||
public long? ActionId { 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 string? EndpointAuthType { get; init; }
|
||||
|
||||
public string? EndpointAuthApiKey { get; init; }
|
||||
|
||||
public string? EndpointAuthApiValue { get; init; }
|
||||
|
||||
public string? 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 string? BodyQuery { get; init; }
|
||||
|
||||
public string? PostprocessingQuery { get; init; }
|
||||
}
|
||||
@ -6,4 +6,13 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="15.1.0" />
|
||||
<PackageReference Include="MediatR" Version="13.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ReC.Domain\ReC.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
using MediatR;
|
||||
|
||||
namespace ReC.Application.RecActions.Commands;
|
||||
|
||||
public class InvokeRecActionCommand : IRequest
|
||||
{
|
||||
public int ProfileId { get; init; }
|
||||
}
|
||||
|
||||
public static class InvokeRecActionCommandExtensions
|
||||
{
|
||||
public static Task InvokeRecAction(this ISender sender, int profileId)
|
||||
=> sender.Send(new InvokeRecActionCommand { ProfileId = profileId });
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Dto;
|
||||
|
||||
namespace ReC.Application.RecActions.Queries;
|
||||
|
||||
public class ReadRecActionQuery : IRequest<IEnumerable<RecActionDto>>
|
||||
{
|
||||
public int ProfileId { get; init; }
|
||||
}
|
||||
47
src/ReC.Domain/Entities/EndpointParam.cs
Normal file
47
src/ReC.Domain/Entities/EndpointParam.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReC.Domain.Entities;
|
||||
|
||||
/// <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>
|
||||
[Table("TBREC_CFG_ENDPOINT_PARAMS", Schema = "dbo")]
|
||||
public class EndpointParam
|
||||
{
|
||||
[Key]
|
||||
[Column("GUID")]
|
||||
public long? Guid { get; set; }
|
||||
|
||||
[Column("ACTIVE")]
|
||||
public bool? Active { get; set; }
|
||||
|
||||
[Column("DESCRIPTION")]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[Column("GROUP_ID")]
|
||||
public short? GroupId { get; set; }
|
||||
|
||||
[Column("SEQUENCE")]
|
||||
public byte? Sequence { get; set; }
|
||||
|
||||
[Column("KEY")]
|
||||
public string? Key { get; set; }
|
||||
|
||||
[Column("VALUE")]
|
||||
public string? Value { get; set; }
|
||||
|
||||
[Column("ADDED_WHO")]
|
||||
public string? AddedWho { get; set; }
|
||||
|
||||
[Column("ADDED_WHEN")]
|
||||
public DateTime? AddedWhen { get; set; }
|
||||
|
||||
[Column("CHANGED_WHO")]
|
||||
public string? ChangedWho { get; set; }
|
||||
|
||||
[Column("CHANGED_WHEN")]
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
}
|
||||
34
src/ReC.Domain/Entities/OutRes.cs
Normal file
34
src/ReC.Domain/Entities/OutRes.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReC.Domain.Entities;
|
||||
|
||||
[Table("TBREC_OUT_RESULT", Schema = "dbo")]
|
||||
public class OutRes
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("GUID")]
|
||||
public long? Id { get; set; }
|
||||
|
||||
[Column("ACTION_ID")]
|
||||
public long? ActionId { get; set; }
|
||||
|
||||
[Column("RESULT_HEADER")]
|
||||
public string? ResultHeader { get; set; }
|
||||
|
||||
[Column("RESULT_BODY")]
|
||||
public string? ResultBody { get; set; }
|
||||
|
||||
[Column("ADDED_WHO")]
|
||||
public string? AddedWho { get; set; }
|
||||
|
||||
[Column("ADDED_WHEN")]
|
||||
public DateTime? AddedWhen { get; set; }
|
||||
|
||||
[Column("CHANGED_WHO")]
|
||||
public string? ChangedWho { get; set; }
|
||||
|
||||
[Column("CHANGED_WHEN")]
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
}
|
||||
117
src/ReC.Domain/Entities/RecAction.cs
Normal file
117
src/ReC.Domain/Entities/RecAction.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReC.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the VWREC_ACTION view from the database.
|
||||
///
|
||||
/// All properties are defined as nullable to provide flexibility in case the underlying view
|
||||
/// changes in production (e.g., columns added, removed, or modified). This approach prevents
|
||||
/// runtime mapping errors and ensures the application can handle schema changes without
|
||||
/// requiring immediate code updates.
|
||||
/// </summary>
|
||||
[Table("VWREC_ACTION", Schema = "dbo")]
|
||||
public class RecAction
|
||||
{
|
||||
[Column("ACTION_ID")]
|
||||
public long? ActionId { get; set; }
|
||||
|
||||
[Column("PROFILE_ID")]
|
||||
public long? ProfileId { get; set; }
|
||||
|
||||
[Column("PROFILE_NAME")]
|
||||
[MaxLength(100)]
|
||||
public string? ProfileName { get; set; }
|
||||
|
||||
[Column("PROFILE_TYPE")]
|
||||
[MaxLength(20)]
|
||||
public string? ProfileType { get; set; }
|
||||
|
||||
[Column("PROFILE_SEQUENCE")]
|
||||
public byte? ProfileSequence { get; set; }
|
||||
|
||||
[Column("ENDPOINT_ID")]
|
||||
public long? EndpointId { get; set; }
|
||||
|
||||
[Column("ENDPOINT_URI")]
|
||||
[MaxLength(4000)]
|
||||
public string? EndpointUri { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_ID")]
|
||||
public long? EndpointAuthId { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_TYPE")]
|
||||
[MaxLength(50)]
|
||||
public string? EndpointAuthType { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_API_KEY")]
|
||||
[MaxLength(300)]
|
||||
public string? EndpointAuthApiKey { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_API_VALUE")]
|
||||
[MaxLength(300)]
|
||||
public string? EndpointAuthApiValue { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_API_KEY_ADD_TO")]
|
||||
[MaxLength(20)]
|
||||
public string? EndpointAuthApiKeyAddTo { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_TOKEN")]
|
||||
[MaxLength(300)]
|
||||
public string? EndpointAuthToken { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_USERNAME")]
|
||||
[MaxLength(200)]
|
||||
public string? EndpointAuthUsername { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_PASSWORD")]
|
||||
[MaxLength(200)]
|
||||
public string? EndpointAuthPassword { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_DOMAIN")]
|
||||
[MaxLength(100)]
|
||||
public string? EndpointAuthDomain { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_WORKSTATION")]
|
||||
[MaxLength(100)]
|
||||
public string? EndpointAuthWorkstation { get; set; }
|
||||
|
||||
[Column("ENDPOINT_PARAMS_ID")]
|
||||
public short? EndpointParamsId { get; set; }
|
||||
|
||||
[Column("SQL_CONNECTION_ID")]
|
||||
public short? SqlConnectionId { get; set; }
|
||||
|
||||
[Column("SQL_CONNECTION_SERVER")]
|
||||
[MaxLength(150)]
|
||||
public string? SqlConnectionServer { get; set; }
|
||||
|
||||
[Column("SQL_CONNECTION_DB")]
|
||||
[MaxLength(100)]
|
||||
public string? SqlConnectionDb { get; set; }
|
||||
|
||||
[Column("SQL_CONNECTION_USERNAME")]
|
||||
[MaxLength(100)]
|
||||
public string? SqlConnectionUsername { get; set; }
|
||||
|
||||
[Column("SQL_CONNECTION_PASSWORD")]
|
||||
[MaxLength(100)]
|
||||
public string? SqlConnectionPassword { get; set; }
|
||||
|
||||
[Column("REST_TYPE")]
|
||||
[MaxLength(20)]
|
||||
public string? RestType { get; set; }
|
||||
|
||||
[Column("PREPROCESSING_QUERY")]
|
||||
public string? PreprocessingQuery { get; set; }
|
||||
|
||||
[Column("HEADER_QUERY")]
|
||||
public string? HeaderQuery { get; set; }
|
||||
|
||||
[Column("BODY_QUERY")]
|
||||
public string? BodyQuery { get; set; }
|
||||
|
||||
[Column("POSTPROCESSING_QUERY")]
|
||||
public string? PostprocessingQuery { get; set; }
|
||||
}
|
||||
39
src/ReC.Infrastructure/DependencyInjection.cs
Normal file
39
src/ReC.Infrastructure/DependencyInjection.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using DigitalData.Core.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ReC.Domain.Entities;
|
||||
|
||||
namespace ReC.Infrastructure;
|
||||
|
||||
public static class DependencyInjection
|
||||
{
|
||||
public static IServiceCollection AddRecInfrastructure<TRecDbContext>(this IServiceCollection services, Action<ConfigurationOptions> options)
|
||||
where TRecDbContext : RecDbContext
|
||||
{
|
||||
var configOpt = new ConfigurationOptions();
|
||||
options.Invoke(configOpt);
|
||||
|
||||
if(configOpt.DbContextOptionsAction is null)
|
||||
throw new InvalidOperationException("DbContextOptionsAction must be configured.");
|
||||
|
||||
services.AddDbContext<RecDbContext>(configOpt.DbContextOptionsAction);
|
||||
|
||||
services.AddDbRepository(opt => opt.RegisterFromAssembly<TRecDbContext>(typeof(RecAction).Assembly));
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddRecInfrastructure(this IServiceCollection services, Action<ConfigurationOptions> options)
|
||||
=> services.AddRecInfrastructure<RecDbContext>(options);
|
||||
|
||||
public class ConfigurationOptions
|
||||
{
|
||||
internal Action<DbContextOptionsBuilder>? DbContextOptionsAction { get; private set; }
|
||||
|
||||
public ConfigurationOptions ConfigureDbContext(Action<DbContextOptionsBuilder> optionsAction)
|
||||
{
|
||||
DbContextOptionsAction = optionsAction;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,4 +6,14 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DigitalData.Core.Infrastructure" Version="2.5.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.11" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ReC.Domain\ReC.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
20
src/ReC.Infrastructure/RecDbContext.cs
Normal file
20
src/ReC.Infrastructure/RecDbContext.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReC.Domain.Entities;
|
||||
|
||||
namespace ReC.Infrastructure;
|
||||
|
||||
public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(options)
|
||||
{
|
||||
public DbSet<EndpointParam> EndpointParams { get; set; }
|
||||
|
||||
public DbSet<RecAction> Actions { get; set; }
|
||||
|
||||
public DbSet<OutRes> OutRes { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.Entity<RecAction>().HasNoKey();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user