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.Receiver, ReceiverDto>();
|
||||||
CreateMap<Domain.Entities.EnvelopeReceiverReadOnly, EnvelopeReceiverReadOnlyDto>();
|
CreateMap<Domain.Entities.EnvelopeReceiverReadOnly, EnvelopeReceiverReadOnlyDto>();
|
||||||
CreateMap<ElementAnnotation, AnnotationDto>();
|
CreateMap<ElementAnnotation, AnnotationDto>();
|
||||||
CreateMap<ThirdPartyModuleDto, ThirdPartyModule>();
|
CreateMap<ThirdPartyModule, ThirdPartyModuleDto>();
|
||||||
|
|
||||||
// DTO to Entity mappings
|
// DTO to Entity mappings
|
||||||
CreateMap<ConfigDto, Config>();
|
CreateMap<ConfigDto, Config>();
|
||||||
|
|||||||
@ -79,7 +79,7 @@ public static class ReadThirdPartyModuleQueryExtensions
|
|||||||
/// <param name="active"></param>
|
/// <param name="active"></param>
|
||||||
/// <param name="cancel"></param>
|
/// <param name="cancel"></param>
|
||||||
/// <returns></returns>
|
/// <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()
|
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.DependencyInjection;
|
||||||
using EnvelopeGenerator.Finalizer;
|
using EnvelopeGenerator.Finalizer;
|
||||||
|
using EnvelopeGenerator.Finalizer.Models;
|
||||||
using EnvelopeGenerator.Infrastructure;
|
using EnvelopeGenerator.Infrastructure;
|
||||||
|
using MediatR;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
// Load Serilog from appsettings.json
|
// Load Serilog from appsettings.json
|
||||||
@ -61,7 +65,20 @@ try
|
|||||||
);
|
);
|
||||||
#endregion Add DB Context, EG Inf. and Services
|
#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 host = builder.Build();
|
||||||
|
|
||||||
|
var licence = host.Services.GetRequiredService<IOptions<GdPictureOptions>>().Value;
|
||||||
|
|
||||||
host.Run();
|
host.Run();
|
||||||
|
|
||||||
Log.Information("The worker was stopped.");
|
Log.Information("The worker was stopped.");
|
||||||
|
|||||||
@ -79,6 +79,8 @@ public abstract class EGDbContextBase : DbContext
|
|||||||
|
|
||||||
public DbSet<ClientUser> ClientUsers { get; set; }
|
public DbSet<ClientUser> ClientUsers { get; set; }
|
||||||
|
|
||||||
|
public DbSet<ThirdPartyModule> ThirdPartyModules { get; set; }
|
||||||
|
|
||||||
private readonly DbTriggerParams _triggers;
|
private readonly DbTriggerParams _triggers;
|
||||||
|
|
||||||
private readonly ILogger
|
private readonly ILogger
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user