Commit Graph

126 Commits

Author SHA1 Message Date
5e8e6a06fe feat(infrastructure): Add RabbitMQ Command Bus integration
- Add RabbitMQ.Client 7.2.1, Microsoft.Extensions.Hosting 10.0.9
- Implement ICommandPublisher interface for async command publishing
- Create RabbitMqCommandPublisher with persistent message delivery
- Create RabbitMqCommandConsumer BackgroundService for command processing
- Add RabbitMqConfiguration with appsettings.json binding
- Configure Infrastructure DI with RabbitMQ services
- Update Program.cs to support appsettings.Secrets.json
- Server: 172.24.12.56:5672, Exchange: emailprofiler.commands
2026-07-14 16:36:23 +02:00
50c21ee628 Refactor MediatR commands and update solution structure
- Consolidated commands and handlers into single files for better organization.
- Updated file naming conventions for commands and queries.
- Added explicit Git operation rules to prevent automatic commits/pushes.
- Introduced new projects and restructured solution file (`legacy` folder).
- Refactored `CreateEmailAccountCommand`, `ProcessEmailCommand`, and others to use `IUnitOfWork`.
- Enhanced `ProcessEmailCommandHandler` with attachment validation and error handling.
- Removed redundant handler files after consolidation.
- Improved code consistency and added `TODO` comments for future enhancements.
2026-07-09 14:37:12 +02:00
45654796b7 feat(application): add MediatR commands and handlers with exception improvements
MediatR Commands (CQRS Pattern):
- CreateEmailProfileCommand + Handler
- UpdateEmailProfileCommand + Handler
- DeleteEmailProfileCommand + Handler
- CreateEmailAccountCommand + Handler
- ProcessEmailCommand + Handler (core email processing logic)

Command Handlers:
- Create/Update/Delete operations for EmailProfile
- Create operation for EmailAccount
- ProcessEmail: Complete email processing workflow including:
  * Duplicate detection using MessageId hash
  * Email history creation
  * PDF attachment validation
  * windream DMS archiving support (placeholder)
  * Domain event publishing (EmailProcessedEvent)
  * Error handling and status tracking

Exception Improvements:
- Added ErrorCode property to DomainException
- Added ErrorCode overload to ValidationException
- Simplified AttachmentProcessingException to use base ErrorCode

Field Mappings Fixed:
- EmailProfile: ProcessId (not EmailProcessId), ValidationSql (not SenderFilter/SubjectFilter)
- EmailAccount: Username, EncryptedPassword, UseOAuth2, EncryptedClientSecret
- EmailHistory: SenderAddress, EmailDate, OriginalMessageId, EmailBodyText/Html
- EmailAttachment: OriginalFileName, SavedFileName, FilePath, FileSize
- Audit fields: AddedWhen/AddedWho, ChangedWhen/ChangedWho (not CreatedDate/By, ModifiedDate/By)

All commands follow Clean Architecture and use UnitOfWork pattern.
Build successful with 1 minor warning (dmsService marked for future implementation).
2026-07-08 15:51:51 +02:00
3778c0b338 feat(application): add repository and service interfaces
Repository Interfaces (Clean Architecture - Application Layer):
- IRepository<T>: Base repository interface with common CRUD operations
- IEmailAccountRepository: Email account operations (GetActive, GetByName, GetWithProfiles)
- IEmailProfileRepository: Profile operations (GetActive, GetDueForPolling, GetWithRelated)
- IEmailProcessRepository: Process operations (GetWithSteps, GetByType)
- IEmailHistoryRepository: History operations (pagination, duplicate detection, date range queries)
- IEmailOutboxRepository: Outbox operations (GetPending, GetForRetry, MarkAsSent/Failed)
- IUnitOfWork: Transaction management and repository aggregation

Service Interfaces (Abstraction for Infrastructure):
- IEmailService: IMAP/SMTP operations with OAuth2 support (MailKit wrapper)
- IPdfProcessingService: PDF validation, embedded file extraction, ZUGFeRD support
- IDmsService: windream DMS integration (archive, search, update index fields)
- IEncryptionService: Data protection for passwords and OAuth tokens
- IEmailQueue: Async email queue (in-memory Channel, future: RabbitMQ)

Dependencies:
- Added MimeKit 4.17.0 for email service interface definitions

All interfaces follow Clean Architecture principles:
- Interfaces in Application layer
- Implementations will be in Infrastructure layer
2026-07-08 10:39:16 +02:00
111d2bf264 fix(domain): use DateTime.Now instead of DateTime.UtcNow for legacy compatibility
CRITICAL FIX: Replace all DateTime.UtcNow with DateTime.Now throughout the application.

Reason: Legacy VB.NET system uses local server time, and database stores all
timestamps as local time. Using UTC breaks compatibility and causes incorrect
time comparisons.

Changes:
- EmailProcessedEvent: ProcessedDate now uses DateTime.Now
- EmailHistory.MarkAsProcessed(): ProcessedDate now uses DateTime.Now
- EmailHistory.MarkAsFailed(): ProcessedDate now uses DateTime.Now
- EmailProfile.UpdateLastPollTime(): LastPollTime now uses DateTime.Now
- EmailProfile.ShouldPoll(): Poll interval comparison now uses DateTime.Now

Documentation:
- Added critical note to agents.md about DateTime usage
- Includes examples and detailed explanation for future developers

This ensures all date/time operations remain compatible with legacy database.
2026-07-08 10:36:13 +02:00
c9251fa622 Add "Solution Items" folder with project documentation
A new "Solution Items" folder has been added to the solution, represented by the GUID `{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}`.

This folder includes the following files:
- `agents.md`
- `IMPLEMENTATION_GUIDE.md`
- `README.md`
- `STATUS.md`

These files are now part of the solution structure, providing better organization and accessibility for project-related documentation.
2026-07-07 19:29:30 +02:00
2393b2649a docs: add project status tracking document
Current implementation status:
-  Phase 1 Complete: Domain Layer (100%)
- 🚧 Phase 2 In Progress: Application Layer (5%)
-  Phases 3-6 Pending

Detailed tracking:
- All completed entities, value objects, enums, services
- All pending repository interfaces, commands, queries
- All pending infrastructure implementations
- All pending API controllers and workers
- Build status confirmation
- Progress visualization (~15% complete)
- Prioritized next steps for future agents

This document provides quick overview of what's done and what's next.
2026-07-07 19:00:07 +02:00
331b73000e docs: add critical notes and future enhancements for agents
Important notes:
- Database schema must NEVER be modified
- MessageId hash algorithm must match legacy system exactly
- No git commits without explicit permission
- Naming conventions (SNAKE_CASE DB, PascalCase C#)

Future enhancements:
- RabbitMQ queue implementation plan (replacing in-memory queue)
- Complete migration path and configuration examples
- Pending implementation tasks for each phase
- Known issues and limitations (PdfSharp, windream COM)

Architecture decisions:
- Clean Architecture with DDD
- CQRS pattern with MediatR
- Repository pattern

Development guidelines:
- Code style conventions
- Logging with Serilog
- Configuration management
- Error handling strategies
- Deployment scenarios (IIS/Windows Service)
2026-07-07 18:59:57 +02:00
e789afe26a docs: add comprehensive implementation guide for AI agents
Step-by-step guide covering all remaining phases:
- Phase 2: Application Layer (Repositories, Services, Commands, Queries, Validators)
- Phase 3: Infrastructure Layer (DbContext, Repositories, External Services)
- Phase 4: API Layer (Controllers, Workers, Middleware)
- Phase 5: Configuration (appsettings, Serilog, Scalar)
- Phase 6: Testing (Unit tests, Integration tests)
- Phase 7: Documentation (README.md in German)
- Phase 8: Build and deployment

Includes complete code examples, best practices, and verification steps.
Future AI agents can follow this guide to continue development systematically.
2026-07-07 18:59:46 +02:00
dd04cd6cba docs: add legacy system analysis documentation
Comprehensive analysis of the VB.NET legacy system:
- Complete database schema documentation
- All table structures (TBDD_*, TBEMLP_* tables)
- Legacy business logic analysis
- VB.NET code patterns and conventions
- Migration considerations

This documentation ensures new implementation maintains compatibility
with existing database and business rules.
2026-07-07 18:59:37 +02:00
43101a6e61 feat(application): add DTOs and application layer dependencies
DTOs:
- EmailProfileDto: Profile data transfer object
- EmailAccountDto: Email account data transfer object
- EmailHistoryDto: Email history data transfer object
- EmailAttachmentDto: Attachment data transfer object

Dependencies:
- MediatR 14.2.0 for CQRS (Commands/Queries)
- AutoMapper 12.0.1 for entity-DTO mapping
- FluentValidation 12.1.1 for input validation

This provides the foundation for the application layer implementation.
2026-07-07 18:59:31 +02:00
146b56ff85 build(domain): add MediatR dependency for domain events
- Add MediatR 12.2.0 package for event-driven architecture
- Enables domain events like EmailProcessedEvent
2026-07-07 18:59:22 +02:00
721603bb47 feat(domain): add domain services and events
- MessageIdGenerator: Generates unique message IDs using legacy-compatible SHA256 hash
  Algorithm matches VB.NET system for duplicate detection
- EmailProcessedEvent: MediatR domain event for email processing completion

Domain services encapsulate business logic that doesn't belong to entities.
2026-07-07 18:59:17 +02:00
c97073775b feat(domain): add all domain entities with legacy database mapping
Entities mapped to legacy database tables using [Table] and [Column] attributes:
- EmailAccount → TBDD_EMAIL_ACCOUNT (OAuth2 and password auth support)
- EmailProfile → TBEMLP_POLL_PROFILES (polling configuration)
- EmailProcess → TBEMLP_POLL_PROCESS (process definitions)
- ProcessStep → TBEMLP_POLL_STEPS (indexing steps)
- IndexingStep → TBEMLP_POLL_INDEXING_STEPS (DMS indexing fields)
- EmailHistory → TBEMLP_HISTORY (processed emails)
- EmailAttachment → TBEMLP_HISTORY_ATTACHMENT (email attachments)
- EmailOutbox → TBEMLP_EMAIL_OUT (outgoing email queue)

All entities follow Clean Architecture and DDD principles.
Database schema is read-only - no migrations will modify existing tables.
SNAKE_CASE columns mapped to PascalCase properties.
2026-07-07 18:59:10 +02:00
18bb07cd93 feat(domain): add domain exception hierarchy
- DomainException: Base exception for all domain errors
- ValidationException: Business rule validation failures
- AttachmentProcessingException: Attachment-specific processing errors

Exceptions maintain error code compatibility with legacy system.
2026-07-07 18:58:59 +02:00
f6946d812a feat(domain): add value objects for email domain
- MessageId: Unique message identifier with SHA256 hash
  Uses same algorithm as legacy system for duplicate detection compatibility
  Hash format: SHA256({originalMessageId}|{sender}|{date}|{subject})
- EmailAddress: Email address validation and parsing with name support

Value objects ensure immutability and value-based equality.
2026-07-07 18:58:54 +02:00
6098112bb4 feat(domain): add domain enumerations
- ErrorCode: All error codes from legacy system (10001-10010)
- ProcessType: Email process types (ProcessManager, AttachmentSniffer, ZugFeRDParser)
- AuthenticationType: Authentication methods (UsernamePassword, OAuth2)
- EmailStatus: Email processing status tracking
- AttachmentStatus: Attachment validation status

These enums maintain compatibility with the legacy VB.NET system.
2026-07-07 18:58:18 +02:00
05a36e8045 feat(domain): add common base classes and interfaces
- Add BaseEntity with audit fields (CreatedDate, CreatedBy, ModifiedDate, ModifiedBy)
- Add IAggregateRoot marker interface for DDD aggregate roots
- Add ValueObject base class with equality comparison by value

These classes provide the foundation for all domain entities and value objects.
2026-07-07 18:58:10 +02:00
915d01fc03 Add project references and fix encoding issue in tests
Added project references to establish dependencies between
the API, Application, Domain, and Infrastructure projects.
Updated `DigitalData.EmailProfiler.Tests.csproj` to include
references to all layers for testing purposes. Fixed a BOM
encoding issue in the test project file. Added xUnit usage
directive to ensure proper test framework integration.
2026-07-07 14:38:55 +02:00
a88702d9e2 Update .gitignore to exclude specific files and paths
Updated the .gitignore file to ignore the following files and directories:
- `FodyWeavers.xsd`
- `/EnvelopeGenerator.Tests.Application/annotations.json`
- `/EnvelopeGenerator.Server/EnvelopeGenerator.Server/TekH - SoftHSM Test.md`
- `/EnvelopeGenerator.Server/EnvelopeGenerator.Server/tekh_softHSM_test.md`
- `/EnvelopeGenerator.Server/EnvelopeGenerator.Server/publish-output`
- `/EnvelopeGenerator.Server/EnvelopeGenerator.Server/tekh_softHSM_test.md+/legacy/App`

These changes ensure that unnecessary or sensitive files are excluded from version control.
2026-07-07 13:36:37 +02:00
1144f58ebb Add DigitalData.EmailProfiler.Tests project
A new test project, `DigitalData.EmailProfiler.Tests`, has been added to the solution. The project is configured as a .NET 8.0 test project with xUnit as the testing framework. It includes necessary NuGet dependencies such as `coverlet.collector`, `Microsoft.NET.Test.Sdk`, and `xunit.runner.visualstudio`.

The solution file has been updated to include the new project, along with its build configurations (`Debug|Any CPU` and `Release|Any CPU`). A new solution folder, `tests`, has been added, and the test project is nested under it.
2026-07-07 13:34:08 +02:00
690aee02dd Update solution and add new projects targeting .NET 8.0
Updated Visual Studio version in the solution file to 17.14.36717.8.
Added three new projects: Infrastructure, Domain, and Application,
all targeting .NET 8.0. Enabled implicit global usings and nullable
reference types in the new projects. Updated solution configuration
and nested the new projects under the `src` folder.
2026-07-07 13:31:56 +02:00
f3552dbdaa Add background service and update project configuration
Added a `Worker` class as a hosted background service to log
periodic messages. Updated `DigitalData.EmailProfiler.API.csproj`
to include `UserSecretsId` for secure development storage and
added `Microsoft.Extensions.Hosting` package. Replaced the
`Controllers` folder reference with `Properties`. Updated
`Program.cs` to register the `Worker` service, enable API
exploration, and retain Swagger configuration.
2026-07-07 13:25:58 +02:00
8a19a8a8bb init API 2026-07-07 13:18:24 +02:00
34baa6fbd9 Update .gitattributes and .gitignore for repo consistency
Improved repository configuration by updating `.gitattributes` to:
- Normalize line endings automatically.
- Define diff behavior for C# files and common document formats.
- Add optional merge driver settings for Visual Studio project files.
- Treat image files as binary.

Enhanced `.gitignore` to:
- Exclude Visual Studio-specific files, build outputs, and temporary files.
- Ignore files generated by add-ons, testing frameworks, and tools.
- Add project-specific exclusions for `EnvelopeGenerator`.

These changes enhance maintainability, reduce clutter, and prevent unnecessary files from being committed.
2026-07-07 13:18:15 +02:00
b87472db3e Initial commit 2026-07-07 13:09:04 +02:00