Skip to content

Retrieve and consume context rows

Implements the read-then-delete pattern that makes cross-application context hand-off single-use: the destination application reads the source application's rows and immediately deletes them, so a page refresh cannot replay a completed hand-off.

Field Value
Operation ID OP-MVC-07
Trigger Called by Receive inbound cross-application context
Inputs Source app, current app, session ID
Outputs Hashtable of context values; source rows deleted
Primary components clsContext.RetrieveContext
Entry point SAIF.Presentation.Web.MVC/clsContext.vb

Steps

  1. Create a clsContextRepository and call Retrieve(sourceApp, currentApp, sessionID) — a parameterized SELECT over Context filtered by AppName, SessionID, and excluding the current application (SQL-002, Context).
  2. Copy each row's ContextName/ContextValue into a hashtable.
  3. Call CtxRep.Delete(sourceApp, sessionID) so context is consumed exactly once (SQL-004, BR-MVC-017).
  4. Return the hashtable.
  5. On failure: repository failures are wrapped as ApplicationException("Context Repository Retrieve Failed.", ex) after being traced.

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([RetrieveContext]) --> S1[SELECT rows for sourceApp/session, excluding currentApp]
    S1 --> S2[Copy ContextName/ContextValue pairs into hashtable]
    S2 --> S3[DELETE the source app's rows]
    S3 --> EndOk([Return hashtable])
    S1 -.->|Exception| EndErr([Wrap as ApplicationException])
    S3 -.->|Exception| EndErr

Failure and edge-case behavior

  • A retrieval or delete failure at any step is wrapped as ApplicationException("Context Repository Retrieve Failed.", ex), preserving the original exception as the inner exception.
  • Because the delete always follows the select within the same call, an abandoned navigation that never completes its retrieve simply leaves rows behind rather than corrupting state — no cleanup job for stale rows exists in this repository.**

Note: Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • SAIF.Presentation.Web.MVC/clsContext.vb