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

@@ -77,12 +77,12 @@ public class EmailProfile : BaseEntity, IAggregateRoot
public virtual ICollection<EmailHistory> EmailHistories { get; set; } = new List<EmailHistory>();
// Domain methods
public void UpdateLastPollTime() => LastPollTime = DateTime.UtcNow;
public void UpdateLastPollTime() => LastPollTime = DateTime.Now;
public bool ShouldPoll()
{
if (!IsActive) return false;
if (!LastPollTime.HasValue) return true;
return DateTime.UtcNow >= LastPollTime.Value.AddMinutes(PollIntervalMinutes);
return DateTime.Now >= LastPollTime.Value.AddMinutes(PollIntervalMinutes);
}
}