Refactor EnvelopeFinalizationWorker and Program.cs
Reorganized `EnvelopeFinalizationWorker` by changing its namespace from `EnvelopeGenerator.Server.Services` to `EnvelopeGenerator.Server.BackgroundServices` to better reflect its role as a background service. Added placeholder XML documentation comments to the class and its `ExecuteAsync` method. Simplified service registrations in `Program.cs` by removing fully qualified names for `IEnvelopeAuthService`, `EnvelopeReceiverAuthorizationService`, and `EnvelopeReceiverPageDataService`. Updated the `AddHostedService` call for `EnvelopeFinalizationWorker` to use the simplified class name. Replaced the fully qualified `PdfSharpFontResolver` assignment with a simplified reference. Removed unused `using` directives, including `DevExpress.Blazor` and others, to clean up the codebase. Added `using EnvelopeGenerator.Server.BackgroundServices` to reference the updated namespace. These changes improve code readability, reduce redundancy, and align the structure with best practices.
This commit is contained in:
@@ -4,14 +4,24 @@ using EnvelopeGenerator.Infrastructure;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EnvelopeGenerator.Server.Services;
|
||||
namespace EnvelopeGenerator.Server.BackgroundServices;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="scopeFactory"></param>
|
||||
/// <param name="logger"></param>
|
||||
public sealed class EnvelopeFinalizationWorker(
|
||||
IServiceScopeFactory scopeFactory,
|
||||
ILogger<EnvelopeFinalizationWorker> logger) : BackgroundService
|
||||
{
|
||||
private static readonly TimeSpan PollInterval = TimeSpan.FromMinutes(1);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="stoppingToken"></param>
|
||||
/// <returns></returns>
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
@@ -1,4 +1,3 @@
|
||||
using DevExpress.Blazor;
|
||||
using DigitalData.Auth.Claims;
|
||||
using DigitalData.Auth.Client;
|
||||
using DigitalData.Core.Abstractions;
|
||||
@@ -20,7 +19,6 @@ using EnvelopeGenerator.Server.Options;
|
||||
using EnvelopeGenerator.Server.Services;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
@@ -32,6 +30,7 @@ using Serilog.Ui.Web.Extensions;
|
||||
using Scalar.AspNetCore;
|
||||
using System.Globalization;
|
||||
using MudBlazor.Services;
|
||||
using EnvelopeGenerator.Server.BackgroundServices;
|
||||
|
||||
var tempConfig = new ConfigurationBuilder()
|
||||
.SetBasePath(AppContext.BaseDirectory)
|
||||
@@ -421,18 +420,17 @@ try
|
||||
builder.Services.AddScoped<DocReceiverElementService>();
|
||||
|
||||
// SSR Authentication Service (for Envelope Receiver pages)
|
||||
builder.Services.AddScoped<EnvelopeGenerator.Server.Services.IEnvelopeAuthService, EnvelopeGenerator.Server.Services.EnvelopeAuthService>();
|
||||
builder.Services.AddScoped<EnvelopeGenerator.Server.Services.EnvelopeReceiverAuthorizationService>();
|
||||
builder.Services.AddScoped<EnvelopeGenerator.Server.Services.EnvelopeReceiverPageDataService>();
|
||||
builder.Services.AddHostedService<EnvelopeGenerator.Server.Services.EnvelopeFinalizationWorker>();
|
||||
builder.Services.AddScoped<IEnvelopeAuthService, EnvelopeAuthService>();
|
||||
builder.Services.AddScoped<EnvelopeReceiverAuthorizationService>();
|
||||
builder.Services.AddScoped<EnvelopeReceiverPageDataService>();
|
||||
builder.Services.AddHostedService<EnvelopeFinalizationWorker>();
|
||||
|
||||
// DevExpress Server-Side Services (CRITICAL for DxPdfViewer)
|
||||
builder.Services.AddDevExpressBlazor();
|
||||
builder.Services.AddDevExpressServerSideBlazorPdfViewer();
|
||||
|
||||
// PdfSharp font resolver — required for .NET 8 (no system font access without it)
|
||||
PdfSharp.Fonts.GlobalFontSettings.FontResolver =
|
||||
EnvelopeGenerator.Server.Services.PdfSharpFontResolver.Instance;
|
||||
PdfSharp.Fonts.GlobalFontSettings.FontResolver = PdfSharpFontResolver.Instance;
|
||||
|
||||
// Configuration Options
|
||||
builder.Services.Configure<EnvelopeGenerator.Server.Client.Options.ApiOptions>(
|
||||
|
||||
Reference in New Issue
Block a user