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.
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using DigitalData.EmailProfiler.Domain.Common;
|
||||
|
||||
namespace DigitalData.EmailProfiler.Domain.Entities;
|
||||
|
||||
[Table("TBEMLP_POLL_PROFILES")]
|
||||
public class EmailProfile : BaseEntity, IAggregateRoot
|
||||
{
|
||||
[Key]
|
||||
[Column("GUID", Order = 0)]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("PROFILE_NAME", TypeName = "varchar(100)")]
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string ProfileName { get; set; } = string.Empty;
|
||||
|
||||
[Column("POLL_TYPE", TypeName = "varchar(100)")]
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string PollType { get; set; } = "IMAP";
|
||||
|
||||
[Column("EMAIL_CONF_ID")]
|
||||
[Required]
|
||||
public int EmailAccountId { get; set; }
|
||||
|
||||
[Column("PROCESS_ID")]
|
||||
public int? ProcessId { get; set; }
|
||||
|
||||
// Polling Configuration
|
||||
[Column("POLL_INTERVAL")]
|
||||
public int PollIntervalMinutes { get; set; } = 5;
|
||||
|
||||
[Column("LAST_TICK")]
|
||||
public DateTime? LastPollTime { get; set; }
|
||||
|
||||
// Validation
|
||||
[Column("VALIDATION_SQL", TypeName = "nvarchar(1024)")]
|
||||
[MaxLength(1024)]
|
||||
public string? ValidationSql { get; set; }
|
||||
|
||||
// Status
|
||||
[Column("ACTIVE")]
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
[Column("SEQUENCE")]
|
||||
public int? Sequence { get; set; }
|
||||
|
||||
[Column("COMMENT", TypeName = "varchar(500)")]
|
||||
[MaxLength(500)]
|
||||
public string? Comment { get; set; }
|
||||
|
||||
// Audit fields
|
||||
[Column("ADDED_WHO", TypeName = "varchar(50)")]
|
||||
[MaxLength(50)]
|
||||
public string? AddedWho { get; set; }
|
||||
|
||||
[Column("ADDED_WHEN")]
|
||||
public DateTime? AddedWhen { get; set; }
|
||||
|
||||
[Column("CHANGED_WHO", TypeName = "varchar(50)")]
|
||||
[MaxLength(50)]
|
||||
public string? ChangedWho { get; set; }
|
||||
|
||||
[Column("CHANGED_WHEN")]
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
|
||||
// Navigation properties
|
||||
[ForeignKey("EmailAccountId")]
|
||||
public virtual EmailAccount? EmailAccount { get; set; }
|
||||
|
||||
[ForeignKey("ProcessId")]
|
||||
public virtual EmailProcess? EmailProcess { get; set; }
|
||||
|
||||
public virtual ICollection<EmailHistory> EmailHistories { get; set; } = new List<EmailHistory>();
|
||||
|
||||
// Domain methods
|
||||
public void UpdateLastPollTime() => LastPollTime = DateTime.UtcNow;
|
||||
|
||||
public bool ShouldPoll()
|
||||
{
|
||||
if (!IsActive) return false;
|
||||
if (!LastPollTime.HasValue) return true;
|
||||
return DateTime.UtcNow >= LastPollTime.Value.AddMinutes(PollIntervalMinutes);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user