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:
@@ -0,0 +1,48 @@
|
||||
using System.Threading.Channels;
|
||||
using DigitalData.EmailProfiler.Application.Common.Interfaces;
|
||||
using DigitalData.EmailProfiler.Domain.Entities;
|
||||
|
||||
namespace DigitalData.EmailProfiler.Infrastructure.Queue;
|
||||
|
||||
/// <summary>
|
||||
/// In-memory email queue implementation using System.Threading.Channels.
|
||||
/// Thread-safe, high-performance queue for outgoing emails.
|
||||
/// TODO: Replace with RabbitMQ for production (see AGENTS.md Section 7).
|
||||
/// </summary>
|
||||
public class InMemoryEmailQueue : IEmailQueue
|
||||
{
|
||||
private readonly Channel<EmailOutbox> _channel;
|
||||
|
||||
public InMemoryEmailQueue()
|
||||
{
|
||||
var options = new BoundedChannelOptions(1000)
|
||||
{
|
||||
FullMode = BoundedChannelFullMode.Wait
|
||||
};
|
||||
|
||||
_channel = Channel.CreateBounded<EmailOutbox>(options);
|
||||
}
|
||||
|
||||
public async Task EnqueueAsync(EmailOutbox email, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await _channel.Writer.WriteAsync(email, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<EmailOutbox?> DequeueAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (await _channel.Reader.WaitToReadAsync(cancellationToken))
|
||||
{
|
||||
if (_channel.Reader.TryRead(out var email))
|
||||
{
|
||||
return email;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Task<int> GetQueueDepthAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return Task.FromResult(_channel.Reader.Count);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user