feat(GdPictureOptions): Created to configure parameters related to GdPicture.
- Configure the GdPicture license key via a third-party module entity.
This commit is contained in:
parent
23d4b2f31e
commit
187f4a42fc
@ -36,7 +36,7 @@ public class MappingProfile : Profile
|
||||
CreateMap<Domain.Entities.Receiver, ReceiverDto>();
|
||||
CreateMap<Domain.Entities.EnvelopeReceiverReadOnly, EnvelopeReceiverReadOnlyDto>();
|
||||
CreateMap<ElementAnnotation, AnnotationDto>();
|
||||
CreateMap<ThirdPartyModuleDto, ThirdPartyModule>();
|
||||
CreateMap<ThirdPartyModule, ThirdPartyModuleDto>();
|
||||
|
||||
// DTO to Entity mappings
|
||||
CreateMap<ConfigDto, Config>();
|
||||
|
||||
@ -79,7 +79,7 @@ public static class ReadThirdPartyModuleQueryExtensions
|
||||
/// <param name="active"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<string?> ReadThirdPartyModuleLicense(this IMediator mediator, string name, bool active = true, CancellationToken cancel = default)
|
||||
public static async Task<string?> ReadThirdPartyModuleLicenseAsync(this IMediator mediator, string name, bool active = true, CancellationToken cancel = default)
|
||||
{
|
||||
var modules = await mediator.Send(new ReadThirdPartyModuleQuery()
|
||||
{
|
||||
|
||||
9
EnvelopeGenerator.Finalizer/Models/GdPictureOptions.cs
Normal file
9
EnvelopeGenerator.Finalizer/Models/GdPictureOptions.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace EnvelopeGenerator.Finalizer.Models;
|
||||
|
||||
public class GdPictureOptions
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string License { get; set; } = null!;
|
||||
}
|
||||
@ -1,7 +1,11 @@
|
||||
using EnvelopeGenerator.Application.ThirdPartyModules.Queries;
|
||||
using EnvelopeGenerator.DependencyInjection;
|
||||
using EnvelopeGenerator.Finalizer;
|
||||
using EnvelopeGenerator.Finalizer.Models;
|
||||
using EnvelopeGenerator.Infrastructure;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Serilog;
|
||||
|
||||
// Load Serilog from appsettings.json
|
||||
@ -61,7 +65,20 @@ try
|
||||
);
|
||||
#endregion Add DB Context, EG Inf. and Services
|
||||
|
||||
builder.Services.AddOptions<GdPictureOptions>()
|
||||
.Configure((GdPictureOptions opt, IServiceProvider sp) =>
|
||||
{
|
||||
var licenseKey = "GDPICTURE";
|
||||
using var scope = sp.CreateScope();
|
||||
var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
|
||||
opt.License = mediator.ReadThirdPartyModuleLicenseAsync(licenseKey).GetAwaiter().GetResult()
|
||||
?? throw new InvalidOperationException($"License record not found for key: {licenseKey}");
|
||||
});
|
||||
|
||||
var host = builder.Build();
|
||||
|
||||
var licence = host.Services.GetRequiredService<IOptions<GdPictureOptions>>().Value;
|
||||
|
||||
host.Run();
|
||||
|
||||
Log.Information("The worker was stopped.");
|
||||
|
||||
@ -79,6 +79,8 @@ public abstract class EGDbContextBase : DbContext
|
||||
|
||||
public DbSet<ClientUser> ClientUsers { get; set; }
|
||||
|
||||
public DbSet<ThirdPartyModule> ThirdPartyModules { get; set; }
|
||||
|
||||
private readonly DbTriggerParams _triggers;
|
||||
|
||||
private readonly ILogger
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user