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.
This commit is contained in:
2026-07-08 10:36:13 +02:00
parent c9251fa622
commit 111d2bf264
4 changed files with 33 additions and 20 deletions

View File

@@ -3,20 +3,11 @@ using DigitalData.EmailProfiler.Domain.Enums;
namespace DigitalData.EmailProfiler.Domain.Events;
public class EmailProcessedEvent : INotification
public class EmailProcessedEvent(int emailHistoryId, int profileId, string messageId, EmailStatus status) : INotification
{
public int EmailHistoryId { get; }
public int ProfileId { get; }
public string MessageId { get; }
public EmailStatus Status { get; }
public DateTime ProcessedDate { get; }
public EmailProcessedEvent(int emailHistoryId, int profileId, string messageId, EmailStatus status)
{
EmailHistoryId = emailHistoryId;
ProfileId = profileId;
MessageId = messageId;
Status = status;
ProcessedDate = DateTime.UtcNow;
}
public int EmailHistoryId { get; } = emailHistoryId;
public int ProfileId { get; } = profileId;
public string MessageId { get; } = messageId;
public EmailStatus Status { get; } = status;
public DateTime ProcessedDate { get; } = DateTime.Now;
}