OP-009: Retrieve and consume a stored web context¶
Get is invoked over the WebContext route on SAIF.Services.WCF.Services.WebContextService; this page documents the process end to end, from route dispatch to the message the caller receives.
Constructor resolves the SQL Server NETFRAMEWORK/APPM connection and opens a unit of work plus a Repository<WebContextItem> (BR-WCF-002).
Enforce.ArgumentNotNullOrEmpty on applicationName and sessionId (BR-WCF-014).
On failure: ArgumentNullException, logged and surfaced as a generic SOAP fault.
Query all WebContextItem rows for the application and session into a list, outside the unit of work.
Find the item named __SAIFPID; pass its value (or null) to CreateContext, which seeds the context id from that value or generates a new GUID (BR-WCF-015).
unitOfWork.Begin() opens the boundary for the delete loop.
For each item: copy it into the context unless its name is one of sourceApp, sourceView, targetApp, targetView (BR-WCF-016), then repository.Delete(x) unconditionally — including the excluded names and __SAIFPID (BR-WCF-017).
unitOfWork.Commit(); return the context.
On failure: logged by the installed error handler, surfaced as a generic SOAP fault; the transaction rolls back on Dispose, so the read items survive and the read is not idempotent across a failure.*
The following diagram visualizes this process's control flow.
flowchart TD
A["Resolve SQL connection and<br>open Repository<WebContextItem>"]
B["Validate applicationName and sessionId"]
C["Query stored context items for<br>application and session"]
D1{"__SAIFPID item present?"}
D2["Seed the context id from<br>the __SAIFPID item's value"]
D3["Generate a new GUID<br>for the context id"]
D["CreateContext constructs the context<br>with the seeded or generated id"]
E["Begin transaction for delete loop"]
F1{"Item name is one of<br>sourceApp, sourceView,<br>targetApp, targetView?"}
F2["Excluded: do not copy<br>the item into the context"]
F3["Not excluded: copy the<br>item into the context"]
F4["repository.Delete(x) unconditionally —<br>including the excluded names and __SAIFPID"]
G["unitOfWork.Commit(); return the context."]
A --> B
B --> C
C --> D1
D1 -->|"Present"| D2
D1 -->|"Absent"| D3
D2 --> D
D3 --> D
D --> E
E --> F1
F1 -->|"Yes"| F2
F1 -->|"No"| F3
F2 --> F4
F3 --> F4
F4 --> G
Note: Statements marked with * were inferred from code structure, naming
conventions, or contextual evidence where direct confirmation was not available
in source artifacts. Statements marked with ** could not be confirmed; treat
as unknown until verified.