Class SoDatabaseContext
Container for the current database context/session
Implements
Namespace: SuperOffice
Assembly: SoCore.dll
Syntax
public class SoDatabaseContext : Object, IComparable<SoDatabaseContext>
Fields
DefaultContextIdentifier
Container for the current database context/session
Declaration
public const string DefaultContextIdentifier = "Default"
Field Value
Type | Description |
---|---|
String |
Properties
ContextIdentifier
Get the indentifer of the context (unique string for this context)
Declaration
public string ContextIdentifier { get; }
Property Value
Type | Description |
---|---|
String |
Methods
add_OnAfterLogOut(SoDatabaseLogOut)
Container for the current database context/session
Declaration
public void add_OnAfterLogOut(SoDatabaseLogOut value)
Parameters
Type | Name | Description |
---|---|---|
SoDatabaseLogOut | value |
add_OnBeforeLogOut(SoDatabaseLogOut)
Container for the current database context/session
Declaration
public void add_OnBeforeLogOut(SoDatabaseLogOut value)
Parameters
Type | Name | Description |
---|---|---|
SoDatabaseLogOut | value |
CompareTo(SoDatabaseContext)
Container for the current database context/session
Declaration
public int CompareTo(SoDatabaseContext other)
Parameters
Type | Name | Description |
---|---|---|
SoDatabaseContext | other |
Returns
Type | Description |
---|---|
Int32 |
DisconnectDatabase()
Dissconect from the database (formerly referred to as the database logout process)
Declaration
public void DisconnectDatabase()
EnterDatabaseContext(String)
Explicitly enter a particular database context, before performing operations on this database.
Declaration
public static SoDatabaseContext.DatabaseContext EnterDatabaseContext(string contextIdentifier)
Parameters
Type | Name | Description |
---|---|---|
String | contextIdentifier | Identifier of the context. |
Returns
Type | Description |
---|---|
SoDatabaseContext.DatabaseContext | Disposable object leaving the database context on Dispose() |
GetAllContextIdentifiers()
Get a list of all the context identifiers (customers) that is handled by this process
Declaration
public static string[] GetAllContextIdentifiers()
Returns
Type | Description |
---|---|
String[] | List of all context identifiers handled by this process. |
GetCurrent()
Get the current database context.
Declaration
public static SoDatabaseContext GetCurrent()
Returns
Type | Description |
---|---|
SoDatabaseContext | The current database context. Impersonated users will yield the context of the user impersonating - so it is not possible to impersonate a user in a different database. |
GetCurrentIgnoreUser()
Get current database context ignoring whomever logged in.
Declaration
public static SoDatabaseContext GetCurrentIgnoreUser()
Returns
Type | Description |
---|---|
SoDatabaseContext | The current database context. |
Remarks
Used during the authentication process
GetDatabaseContext(String)
Get the actual context from a context identifier.
Declaration
public static SoDatabaseContext GetDatabaseContext(string contextIdentifier)
Parameters
Type | Name | Description |
---|---|---|
String | contextIdentifier | Identifier of the dartabase context |
Returns
Type | Description |
---|---|
SoDatabaseContext | Database context |
HasDatabaseContext(String)
Check if a particular Database Context is known for NetServer.
Declaration
public static bool HasDatabaseContext(string contextIdentifier)
Parameters
Type | Name | Description |
---|---|---|
String | contextIdentifier |
Returns
Type | Description |
---|---|
Boolean |
remove_OnAfterLogOut(SoDatabaseLogOut)
Container for the current database context/session
Declaration
public void remove_OnAfterLogOut(SoDatabaseLogOut value)
Parameters
Type | Name | Description |
---|---|---|
SoDatabaseLogOut | value |
remove_OnBeforeLogOut(SoDatabaseLogOut)
Container for the current database context/session
Declaration
public void remove_OnBeforeLogOut(SoDatabaseLogOut value)
Parameters
Type | Name | Description |
---|---|---|
SoDatabaseLogOut | value |
RemoveDatabaseContext(String)
Remove the Database Context. A new will be initialized the next time it is required.
Declaration
public static bool RemoveDatabaseContext(string contextIdentifier)
Parameters
Type | Name | Description |
---|---|---|
String | contextIdentifier |
Returns
Type | Description |
---|---|
Boolean | True if the database context was removed |
Remarks
Call this method in a multi-tenant NetServer to revoke configuration for a tenant. It is not permitted to call this method providing the DefaultContextIdentifier database context. If this method is called in the same database context as the current, the logic falls back to DisconnectDatabase() to safely remove the database context for the logged in user.
Exceptions
Type | Condition |
---|---|
SoException | Thrown if we specify the DefaultContextIdentifier database context |
RemoveDatabaseContext(String, Boolean)
Remove the Database Context. A new will be initialized the next time it is required.
Declaration
public static bool RemoveDatabaseContext(string contextIdentifier, bool forceDisconnect)
Parameters
Type | Name | Description |
---|---|---|
String | contextIdentifier | |
Boolean | forceDisconnect | Force disconnect from database even if we are not in the same database context |
Returns
Type | Description |
---|---|
Boolean | True if the database context was removed |
Remarks
Call this method in a multi-tenant NetServer to revoke configuration for a tenant. It is not permitted to call this method providing the DefaultContextIdentifier database context. If this method is called in the same database context as the current, the logic falls back to DisconnectDatabase() to safely remove the database context for the logged in user. DisconnectDatabase() will dispose instance containers.
Exceptions
Type | Condition |
---|---|
SoException | Thrown if we specify the DefaultContextIdentifier database context |
TryGetCurrentContextIdentifier()
Try to see if we have a current, contextidentifier with the least possible amount of fuss and side effects. Used in logging situations, to avoid triggering the whole lazyload avalanche
Declaration
public static string TryGetCurrentContextIdentifier()
Returns
Type | Description |
---|---|
String |
TryResolveContext(out IContextResolver, out String, IEnumerable<ClaimsIdentity>)
Container for the current database context/session
Declaration
public static bool TryResolveContext(out IContextResolver contextResolver, out string context, IEnumerable<ClaimsIdentity> identites)
Parameters
Type | Name | Description |
---|---|---|
IContextResolver | contextResolver | |
String | context | |
IEnumerable<ClaimsIdentity> | identites |
Returns
Type | Description |
---|---|
Boolean |
TryResolveContext(out IContextResolver, out String, ClaimsIdentity[])
Try to resolve context from a set of SecurityTokens
Declaration
public static bool TryResolveContext(out IContextResolver contextResolver, out string context, params ClaimsIdentity[] identites)
Parameters
Type | Name | Description |
---|---|---|
IContextResolver | contextResolver | Instance of plugin resolving context |
String | context | Name of context |
ClaimsIdentity[] | identites |
Returns
Type | Description |
---|---|
Boolean | True if context is resolved |
TryResolveContext(out IContextResolver, out String, String)
Try to resolve context from a ticket
Declaration
public static bool TryResolveContext(out IContextResolver contextResolver, out string context, string ticket)
Parameters
Type | Name | Description |
---|---|---|
IContextResolver | contextResolver | Instance of plugin resolving context |
String | context | Name of context |
String | ticket | Ticket to resolve context from |
Returns
Type | Description |
---|---|
Boolean | True if context is resolved |
Events
OnAfterLogOut
Event raised after the database has been logged out/dissconected from.
Declaration
public event SoDatabaseLogOut OnAfterLogOut
Event Type
Type | Description |
---|---|
SoDatabaseLogOut |
OnBeforeLogOut
Event raised in the start of the database logout/dissconect process
Declaration
public event SoDatabaseLogOut OnBeforeLogOut
Event Type
Type | Description |
---|---|
SoDatabaseLogOut |