using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums; namespace ZB.MOM.WW.ScadaBridge.StoreAndForward; /// /// Represents a single store-and-forward message as stored in SQLite. /// Maps to the sf_messages table. /// public class StoreAndForwardMessage { /// Unique message ID (GUID). public string Id { get; set; } = string.Empty; /// Category: ExternalSystem, Notification, or CachedDbWrite. public StoreAndForwardCategory Category { get; set; } /// Target system name (external system, notification list, or DB connection). public string Target { get; set; } = string.Empty; /// JSON-serialized payload containing the call details. public string PayloadJson { get; set; } = string.Empty; /// /// Number of retry-sweep attempts performed so far. The initial (immediate or /// caller-made) delivery attempt is attempt 0 and is not counted here; this /// field counts only background retry attempts. /// public int RetryCount { get; set; } /// /// Maximum retry-sweep attempts before the message is parked. /// 0 = no limit — the message is retried on every sweep until delivered /// and is never parked for exhausting retries. This is not a "never retry" /// value; a positive value is required to bound delivery attempts. /// public int MaxRetries { get; set; } /// Retry interval in milliseconds. public long RetryIntervalMs { get; set; } /// When this message was first enqueued. public DateTimeOffset CreatedAt { get; set; } /// When delivery was last attempted (null if never attempted). public DateTimeOffset? LastAttemptAt { get; set; } /// Current status of the message. public StoreAndForwardMessageStatus Status { get; set; } /// Last error message from a failed delivery attempt. public string? LastError { get; set; } /// /// Instance that originated this message (for S&F-survives-delete behavior). /// public string? OriginInstanceName { get; set; } /// /// The originating script execution's /// per-run correlation id, threaded from ScriptRuntimeContext through /// the cached-call enqueue path. Carried so the store-and-forward retry loop /// can stamp it onto the per-attempt / terminal cached-call audit rows /// (ApiCallCached/DbWriteCached Attempted, CachedResolve). /// null for non-cached-call categories (notifications) and for rows /// buffered before this field existed — back-compat with old persisted rows /// (the column is added by an additive migration and read as null when absent). /// public Guid? ExecutionId { get; set; } /// /// The originating script identifier, /// threaded alongside from the cached-call enqueue /// path so the retry-loop audit rows carry the same SourceScript /// provenance the script-side cached rows already carry. null when not /// known (non-cached categories, pre-migration rows). /// public string? SourceScript { get; set; } /// /// The ExecutionId of the /// inbound-API request that spawned the originating script execution, /// threaded alongside from the cached-call enqueue /// path. Carried so the store-and-forward retry loop can stamp it onto the /// per-attempt / terminal cached-call audit rows /// (ApiCallCached/DbWriteCached Attempted, CachedResolve), /// keeping them correlated with the cross-execution chain. null for a /// non-routed run, for non-cached-call categories (notifications), and for /// rows buffered before this field existed — back-compat with old persisted /// rows (the column is added by an additive migration and read as null when /// absent). /// public Guid? ParentExecutionId { get; set; } }