namespace ZB.MOM.WW.ScadaBridge.Commons.Messages.Audit;
///
/// Outcome of a Site Call Audit Retry/Discard relay — distinguishes the
/// three cases the Central UI Site Calls page must surface differently.
///
///
/// The "site unreachable" case is deliberately separate from
/// : central is an eventually-consistent mirror,
/// not the source of truth, so a relay that never reaches the owning site is a
/// transient transport condition the operator can retry — not a failed
/// operation. The UI shows "site unreachable" rather than a generic error.
///
public enum SiteCallRelayOutcome
{
///
/// The owning site received the relay command and applied the action to its
/// Store-and-Forward buffer (the parked cached call was reset to retry, or
/// discarded). The corrected state reaches central later via telemetry.
///
Applied,
///
/// The owning site received the relay command but found nothing to do — no
/// parked row matched the tracked id (already delivered/discarded, or no
/// longer Parked). A definitive answer from the site, not a failure.
///
NotParked,
///
/// The owning site could not be reached (offline / no route to the site /
/// relay timed out). The action was NOT applied; the operator may retry once
/// the site is back online.
///
SiteUnreachable,
///
/// The owning site was reached but reported it could not apply the action
/// (its parked-message handler was unavailable or its store faulted).
///
OperationFailed,
}
///
/// Central UI → Site Call Audit: relay a Retry of a parked cached call to its
/// owning site. The owning site performs the actual retry on its
/// Store-and-Forward buffer — central never mutates the central SiteCalls
/// mirror row. Mirrors
///
/// but carries (the relay target) and answers with a
/// distinct site-unreachable outcome.
///
/// Request correlation id, echoed on the response.
///
/// The cached operation to retry — the PK of the central SiteCalls row
/// and the S&F buffer message id at the owning site.
///
///
/// The owning site (SiteCall.SourceSite) the relay is routed to.
///
///
/// The authenticated operator who initiated the retry, stamped as the Actor
/// on the central direct-write audit row the relay emits — recording *who asked*.
/// Additive; null where no identity is available.
///
public sealed record RetrySiteCallRequest(
string CorrelationId,
Guid TrackedOperationId,
string SourceSite,
string? RequestedBy = null);
///
/// Site Call Audit → Central UI: result of a .
///
/// Echoed request correlation id.
///
/// The relay outcome — ,
/// ,
/// or
/// .
///
///
/// Convenience flag — true only for .
///
///
/// false only for ; lets
/// the UI distinguish "site offline" from "operation failed" without switching
/// on the enum.
///
///
/// Human-readable detail for a non-applied outcome; null on success.
///
public sealed record RetrySiteCallResponse(
string CorrelationId,
SiteCallRelayOutcome Outcome,
bool Success,
bool SiteReachable,
string? ErrorMessage);
///
/// Central UI → Site Call Audit: relay a Discard of a parked cached call to its
/// owning site. See for the source-of-truth
/// and routing rationale.
///
public sealed record DiscardSiteCallRequest(
string CorrelationId,
Guid TrackedOperationId,
string SourceSite,
string? RequestedBy = null);
///
/// Site Call Audit → Central UI: result of a .
/// Same shape as .
///
public sealed record DiscardSiteCallResponse(
string CorrelationId,
SiteCallRelayOutcome Outcome,
bool Success,
bool SiteReachable,
string? ErrorMessage);