Persist context rows¶
Writes the current in-memory context hashtable to the SQL Server Context table so the destination application can retrieve it. The write is a full replace, not a merge — any prior rows for the application/session are cleared first.
| Field | Value |
|---|---|
| Operation ID | OP-MVC-08 |
| Trigger | Called by Navigate to a view on a genuine cross-application transition |
| Inputs | Application name, session ID, in-memory context hashtable |
| Outputs | Prior rows deleted, new rows inserted |
| Primary components | clsContext.SaveContext |
| Entry point | SAIF.Presentation.Web.MVC/clsContext.vb |
Steps¶
- Create a
clsContextRepositoryand callDelete(applicationName, sessionID)to clear prior rows for this app/session (SQL-004, BR-MVC-017). - Iterate every key in the in-memory
Hashtableand callSave(appName, sessionID, key, value), inserting one row per entry withCURRENT_TIMESTAMPas the update date (SQL-001, Context). - Each operation opens its own
SqlConnectionobtained fromclsConnection.getConnection(<NetFrameworkSqlServer setting>, "APPM", "NETFRAMEWORK", connection)(BR-MVC-019). - On failure: failures are wrapped as
ApplicationException("Context Repository Save Failed.", ex).
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([SaveContext]) --> S1[DELETE existing rows for app/session]
S1 --> S2{More keys in context hashtable?}
S2 -->|Yes| S3[INSERT one row for the key]
S3 --> S2
S2 -->|No| EndOk([Context persisted])
S1 -.->|Exception| EndErr([Wrap as ApplicationException])
S3 -.->|Exception| EndErr
Failure and edge-case behavior¶
- If the delete succeeds but a later insert fails partway through the key set, the application/session ends up with a partial context row set rather than the full replacement — no transaction wraps the delete-then-insert sequence.**
- Each context key/value pair opens its own
SqlConnection, so a large context hashtable results in one connection open/close per key rather than a single batched write.*
Related documentation¶
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.
Sources¶
- SAIF.Presentation.Web.MVC/clsContext.vb