using System.Collections.Generic; using System.Text.Json.Serialization; using FrameworkDAL.DTO.Workflow; namespace FrameworkDAL.CustomCode.EntityViewer.DTOs { // ============================================================ // EntityViewerResultDTO — GetEntityViewer's composite response. // EntityData is the unwrapped Body of whatever the resolved MWEBSERVICE // GET call returned (e.g. GetTimeSlip's payload, envelope stripped) — // shape varies per entity, so it stays untyped. Workflow/Enrichment are // additive and can be empty when the entity has no workflow instance / // no OnDemand qualifiers configured — never block EntityData from returning. // ============================================================ public class EntityViewerResultDTO { public int ObjectTypeId { get; set; } public int ObjectId { get; set; } public string? EntityCode { get; set; } public object? EntityData { get; set; } // Only present when EntityData is null — explains exactly why (resolved URL, // status code, raw response body). Omitted entirely on success so a working // call isn't cluttered with a diagnostics block nobody needs to look at. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public EntityDataDiagnosticsDTO? EntityDataDiagnostics { get; set; } public IReadOnlyList Workflow { get; set; } = new List(); public IReadOnlyDictionary Enrichment { get; set; } = new Dictionary(); } // ============================================================ // EntityDataDiagnosticsDTO — exactly what GetEntityViewer did (or tried to do) // to resolve EntityData, so a null EntityData is always explained, never silent. // ============================================================ public class EntityDataDiagnosticsDTO { /// MWEBSERVICE.WEBSERVICEID matched for (ObjectTypeId, METHODTYPE=0/GET). Null if none. public int? WebServiceId { get; set; } /// Gateway/base host used to substitute {BaseURI} (from X-Forwarded-Host or Request.Host). public string? RequestHost { get; set; } /// The fully-resolved URL that was actually called (after {BaseURI}/{param} substitution). public string? ResolvedUrl { get; set; } /// HTTP status code returned by the resolved URL. Null if the call was never made. public int? StatusCode { get; set; } public bool Success { get; set; } /// Human-readable reason EntityData is null — e.g. "No GET MWEBSERVICE binding for /// ObjectTypeId=-1399999744", "HTTP 404 from resolved URL", or the caught exception's message. /// Null when Success is true. public string? Error { get; set; } /// Raw response body from the resolved URL, truncated to 2000 chars — present even on /// failure (e.g. a 404 page's body) so the actual upstream response is visible, not just the code. public string? RawResponseBody { get; set; } } }