Show / Hide Table of Contents

Class SoDatabaseContext

Container for the current database context/session

Inheritance
object
SoDatabaseContext
Implements
IComparable<SoDatabaseContext>
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SuperOffice
Assembly: SoCore.dll
Syntax
public class SoDatabaseContext : 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

CompareTo(SoDatabaseContext)

Container for the current database context/session

Declaration
public int CompareTo(SoDatabaseContext other)
Parameters
Type Name Description
SoDatabaseContext other
Returns
Type Description
int

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 IDatabaseContext EnterDatabaseContext(string contextIdentifier)
Parameters
Type Name Description
string contextIdentifier

Identifier of the context.

Returns
Type Description
IDatabaseContext

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
bool

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
bool

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, bool)

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
bool forceDisconnect

Force disconnect from database even if we are not in the same database context

Returns
Type Description
bool

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

Blank if the system is not in a runnable state; Default for on-site installations; and CustXXXXX context id in Online

Remarks

This method very carefully avoids using CreateRequired and other potentially avalache-triggering constructs, which would throw exceptions if we are in a state where startup/wireup/applicationBuilder etc have not finished

TryResolveContext(out string, IEnumerable<ClaimsIdentity>)

Container for the current database context/session

Declaration
public static bool TryResolveContext(out string context, IEnumerable<ClaimsIdentity> identites)
Parameters
Type Name Description
string context
IEnumerable<ClaimsIdentity> identites
Returns
Type Description
bool

TryResolveContext(out string, params ClaimsIdentity[])

Try to resolve context from a set of SecurityTokens

Declaration
public static bool TryResolveContext(out string context, params ClaimsIdentity[] identites)
Parameters
Type Name Description
string context

Name of context

ClaimsIdentity[] identites
Returns
Type Description
bool

True if context is resolved

TryResolveContext(out string, string)

Try to resolve context from a ticket

Declaration
public static bool TryResolveContext(out string context, string ticket)
Parameters
Type Name Description
string context

Name of context

string ticket

Ticket to resolve context from

Returns
Type Description
bool

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

Implements

IComparable<T>

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top