Add DI registrations for FinalizeDocumentJob services
Expanded AddFinalizeDocumentJob to register ActionService, TempFiles, PDFBurner, PDFMerger, ReportModel, State, MSSQLServer, GdViewer, and LicenseManager with appropriate lifetimes. Added a placeholder DbConfig registration. Marked the method as [Obsolete] and updated using directives for new dependencies.
This commit is contained in:
@@ -1,15 +1,39 @@
|
||||
using DigitalData.Modules.Database;
|
||||
using EnvelopeGenerator.ServiceHost.Jobs;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using EnvelopeGenerator.ServiceHost.Jobs.FinalizeDocument;
|
||||
using GdPicture14;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace EnvelopeGenerator.ServiceHost.Extensions;
|
||||
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
[Obsolete("Check obsoleted services")]
|
||||
public static IServiceCollection AddFinalizeDocumentJob(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.Configure<WorkerOptions>(configuration.GetSection(nameof(WorkerOptions)));
|
||||
services.AddSingleton<FinalizeDocumentJob>();
|
||||
services.AddScoped<ActionService>();
|
||||
services.AddSingleton<TempFiles>();
|
||||
services.AddScoped<PDFBurner>();
|
||||
services.AddScoped<PDFMerger>();
|
||||
services.AddScoped<ReportModel>();
|
||||
services.AddSingleton<State>();
|
||||
services.AddScoped<MSSQLServer>();
|
||||
|
||||
services.AddSingleton<DbConfig>(_ => throw new NotImplementedException());
|
||||
|
||||
//TODO: Check lifetime of services. They might be singeton.
|
||||
services.AddTransient<GdViewer>();
|
||||
// Add LicenseManager
|
||||
services.AddTransient(provider =>
|
||||
{
|
||||
var options = provider.GetRequiredService<IOptions<WorkerOptions>>().Value;
|
||||
var licenseManager = new LicenseManager();
|
||||
licenseManager.RegisterKEY(options.GdPictureLicenseKey);
|
||||
return licenseManager;
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user