using GB5Shared.DTO.Framework.Login; using System; using System.Collections.Generic; namespace FrameworkDAL.DTO.EIPConversation { /// /// Internal execution context used by engine phases. /// Carries state between Phase 1–6. /// public class EIPExecutionContextDTO { // =============================== // Identity // =============================== public int ConversationId { get; set; } // 🔹 Use fully qualified name to avoid namespace conflict public System.Guid CorrelationId { get; set; } = System.Guid.NewGuid(); public int? TenantId { get; set; } public int UserId { get; set; } // 🔹 Security Context public LoginDTO LoginDTO { get; set; } = default!; // =============================== // Channel Information // =============================== public EIPChannelType ChannelType { get; set; } /// /// Channel as string (WHATSAPP, SMS, POSTMAN, etc.) used by handlers /// public string Channel { get; set; } = string.Empty; public string UserIdentifier { get; set; } = string.Empty; public string RawPayload { get; set; } = string.Empty; // =============================== // Message Information // =============================== public int SystemUserId { get; set; } public string ExternalUserIdentifier { get; set; } = string.Empty; public string OriginalMessage { get; set; } = string.Empty; public string NormalizedMessage { get; set; } = string.Empty; public string? Message { get; set; } // =============================== // Flow State // =============================== public string? FlowCode { get; set; } public string? CurrentStepCode { get; set; } public string? NextStepCode { get; set; } /// TEIPINTERACTIONSESSION.INTERACTIONSESSIONID for this conversation thread — /// set by EIPConversationEngine once resolved; 0 means observability logging is unavailable /// for this turn (e.g. the interaction-session lookup itself failed) and should be skipped. public int InteractionSessionId { get; set; } /// TEIPCONVERSATION.CONVERSATIONID for this conversation thread — companion to /// InteractionSessionId, used to log inbound/outbound TEIPCONVERSATIONDETAIL rows. public int ConversationLogId { get; set; } // =============================== // Execution Flags // =============================== public bool IsCompleted { get; set; } = false; public bool IsSuccess { get; set; } = true; // =============================== // Response // =============================== public string? ResponseMessage { get; set; } // =============================== // Timing // =============================== public DateTime ReceivedAtUtc { get; set; } = DateTime.UtcNow; public DateTime? CompletedAtUtc { get; set; } // =============================== // Runtime Data (Shared Between Phases) // =============================== public Dictionary Variables { get; set; } = new Dictionary(); // 🔹 Payload for capability layer public Dictionary Payload { get; set; } = new Dictionary(); // =============================== // Engine Tracing // =============================== /// /// Tracks execution phase progress (PHASE1..PHASE6) /// public List? PhaseTrace { get; set; } /// /// Metadata dictionary to store contextual info like last sent timestamp, recipient, response status /// public Dictionary Metadata { get; set; } = new Dictionary(); } /// /// Supported communication channels. /// IMPORTANT: Do not change numeric values (used for persistence). /// public enum EIPChannelType { PostMan = 0, WhatsApp = 1, Teams = 2, Telegram = 3, Slack = 4, SMS = 5, AppChat = 6, Voice = 7, /// Stateless, token-authenticated HTML stepper used by DirectAction's /// NeedsInput=1 conversational handoff (GET/POST /Action/Conversation*) — the /// recipient clicked an email link, isn't logged in, and has no messaging channel. DirectActionWeb = 8 } }