refactor(infrastructure): Improve service implementations and remove legacy references
**Services Refactored:**
- DevExpressPdfProcessingService: Remove unnecessary try-catch (lines 80-87), add stream position validation
- WindreamDmsService: Mark as [Obsolete] - application now only provides email sending functionality
- MailKitEmailService: Keep MailKit implementation (Limilabs DLL to be added separately)
**Custom Exceptions Added:**
- AuthenticationFailedException: OAuth2/IMAP/SMTP authentication failures
- DmsNotAvailableException: windream COM unavailable
- InvalidPdfException: Invalid PDF stream
- NotFoundException: Entity not found in Repository operations
**Legacy Cleanup:**
- Remove legacy VB.NET projects from solution (EmailProfiler.Common, EmailProfiler.Service)
- Delete legacy/ folder reference
- Clean solution file structure
**Stream Validation:**
- All PDF processing methods now validate stream position (reset to 0 if needed)
- Add CanSeek validation for stream-based operations
**Build Status:** ✅ Successful (0 errors, 15 warnings - all acceptable)
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
using DigitalData.EmailProfiler.Application.Common.Interfaces;
|
||||
using DigitalData.EmailProfiler.Infrastructure.Messaging;
|
||||
using DigitalData.EmailProfiler.Infrastructure.Persistence;
|
||||
using DigitalData.EmailProfiler.Infrastructure.Queue;
|
||||
using DigitalData.EmailProfiler.Infrastructure.Repositories;
|
||||
using DigitalData.EmailProfiler.Infrastructure.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
@@ -17,16 +22,46 @@ public static class DependencyInjection
|
||||
this IServiceCollection services,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
// Register RabbitMQ configuration
|
||||
// --- Database Context ---
|
||||
services.AddDbContext<EmailProfilerDbContext>(options =>
|
||||
options.UseSqlServer(
|
||||
configuration.GetConnectionString("DefaultConnection"),
|
||||
sqlOptions => sqlOptions.EnableRetryOnFailure()));
|
||||
|
||||
// --- Generic Repository ---
|
||||
services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
|
||||
|
||||
// --- External Services ---
|
||||
// Email Service (using MailKit/MimeKit with OAuth2)
|
||||
services.AddScoped<IEmailService, MailKitEmailService>();
|
||||
|
||||
// PDF Processing Service (using DevExpress.Pdf)
|
||||
services.AddScoped<IPdfProcessingService, DevExpressPdfProcessingService>();
|
||||
|
||||
// DMS Service (using windream COM Interop)
|
||||
services.AddScoped<IDmsService, WindreamDmsService>();
|
||||
|
||||
// Encryption Service (using Data Protection API)
|
||||
services.AddScoped<IEncryptionService, DataProtectionEncryptionService>();
|
||||
|
||||
// --- Email Queue ---
|
||||
services.AddSingleton<IEmailQueue, InMemoryEmailQueue>();
|
||||
|
||||
// --- RabbitMQ Configuration ---
|
||||
services.Configure<RabbitMqConfiguration>(
|
||||
configuration.GetSection(RabbitMqConfiguration.SectionName));
|
||||
|
||||
// Register RabbitMQ command publisher
|
||||
// --- RabbitMQ Command Publisher ---
|
||||
services.AddSingleton<ICommandPublisher, RabbitMqCommandPublisher>();
|
||||
|
||||
// Register RabbitMQ command consumer as hosted service
|
||||
// --- RabbitMQ Command Consumer (Background Service) ---
|
||||
services.AddHostedService<RabbitMqCommandConsumer>();
|
||||
|
||||
// --- Data Protection (for encryption) ---
|
||||
services.AddDataProtection();
|
||||
// .PersistKeysToFileSystem(new DirectoryInfo(@"C:\ProgramData\EmailProfiler\Keys"))
|
||||
// .SetApplicationName("EmailProfiler");
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user