Show / Hide Table of Contents

Class SentryPreferenceCache

Caches preferences in the "Rights-*" section. Cache is manually flushed when SoPreference sets a "Rights-" preference value, or every 10 minutes.

Inheritance
object
CacheBaseV2
SentryPreferenceCache
Inherited Members
CacheBaseV2.InstanceDispose()
CacheBaseV2.BeginDisableAutoUpdate()
CacheBaseV2.LoadAsync(CancellationToken)
CacheBaseV2.Load()
CacheBaseV2.Disposed
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SuperOffice.CRM.Security
Assembly: SoDataBase.dll
Syntax
[CacheV2(0)]
public class SentryPreferenceCache : CacheBaseV2

Constructors

SentryPreferenceCache()

Caches preferences in the "Rights-*" section. Cache is manually flushed when SoPreference sets a "Rights-" preference value, or every 10 minutes.

Declaration
public SentryPreferenceCache()

Properties

TableNames

Caches preferences in the "Rights-*" section. Cache is manually flushed when SoPreference sets a "Rights-" preference value, or every 10 minutes.

Declaration
protected override IEnumerable<string> TableNames { get; }
Property Value
Type Description
IEnumerable<string>
Overrides
CacheBaseV2.TableNames
Remarks

Although we read from table "UserPreference" we shouldn't add it to TableNames for this cache because there's too much traffic on that table. Invoking flush on every table change would be expensive, so we implement a custom IsCacheInvalidated to only trigger when it sees Rights-* changes or updates to known sentry preferences.

Methods

GetFieldRights(int, int, int)

Get the field rights from the preference system for a user.

Declaration
public FieldRight GetFieldRights(int sentryTable, int fieldId, int rowId)
Parameters
Type Name Description
int sentryTable

TableNumber for the main sentry table.

int fieldId

FieldNumber (TableNumber [left shift] 8 + FieldNumber) for the field to look up

int rowId

Primary key of the row. 0 if the row is new.

Returns
Type Description
FieldRight

Field rights from the preference system.

GetFieldRights(int, int, int, int, int)

Get the field rights from the preference system for a user.

Declaration
public FieldRight GetFieldRights(int sentryTable, int fieldId, int associateId, int groupId, int rowId)
Parameters
Type Name Description
int sentryTable

TableNumber for the main sentry table.

int fieldId

FieldNumber (TableNumber [left shift] 8 + FieldNumber) for the field to look up

int associateId

AssociateId for the user to get the rights for.

int groupId

Group id for the user to get the rights for

int rowId

Primary key of the row. 0 if the row is new.

Returns
Type Description
FieldRight

Field rights from the preference system.

GetFieldRights(int, int, int, ClaimsPrincipal)

Get the field rights from the preference system for a user.

Declaration
public FieldRight GetFieldRights(int sentryTable, int fieldId, int rowId, ClaimsPrincipal principal)
Parameters
Type Name Description
int sentryTable

TableNumber for the main sentry table.

int fieldId

FieldNumber (TableNumber [left shift] 8 + FieldNumber) for the field to look up

int rowId

Primary key of the row. 0 if the row is new.

ClaimsPrincipal principal

Providing the princpial for optimization

Returns
Type Description
FieldRight

Field rights from the preference system.

GetTableRights(int, int)

Get table rights from the preference system for the logged in user.

Declaration
public TableRight GetTableRights(int sentryTable, int rowId)
Parameters
Type Name Description
int sentryTable

TableNumber for the main sentry table.

int rowId

Primary key of the row. 0 if the row is new.

Returns
Type Description
TableRight

Table rights from the preference system.

GetTableRights(int, int, int, int)

Get table rights from the preference system for a user.

Declaration
public TableRight GetTableRights(int sentryTable, int associateId, int groupId, int rowId)
Parameters
Type Name Description
int sentryTable

TableNumber for the main sentry table.

int associateId

AssociateId for the user to get the rights for.

int groupId

Group id for the user to get the rights for

int rowId

Primary key of the row. 0 if the row is new.

Returns
Type Description
TableRight

Table rights from the preference system.

IsCacheInvalidatedAsync(string, int, PrivateSave, CancellationToken)

Determine if cache was actually invalidated by this change - much of the traffic on the userpreference table does not affect us here

Declaration
protected override Task<bool> IsCacheInvalidatedAsync(string tableName, int primaryKey, PrivateSave save, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string tableName
int primaryKey
PrivateSave save
CancellationToken cancellationToken
Returns
Type Description
Task<bool>
Overrides
CacheBaseV2.IsCacheInvalidatedAsync(string, int, PrivateSave, CancellationToken)
Remarks

This cache is invalidated if one of the previously known rows is deleted, OR if a row with a section name starting with Rights- is created or updated.

OnLoad()

Caches preferences in the "Rights-*" section. Cache is manually flushed when SoPreference sets a "Rights-" preference value, or every 10 minutes.

Declaration
protected override void OnLoad()
Overrides
CacheBaseV2.OnLoad()

OnLoadAsync(CancellationToken)

Caches preferences in the "Rights-*" section. Cache is manually flushed when SoPreference sets a "Rights-" preference value, or every 10 minutes.

Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
protected override Task OnLoadAsync(CancellationToken cancellationToken)
Parameters
Type Name Description
CancellationToken cancellationToken
Returns
Type Description
Task
Overrides
CacheBaseV2.OnLoadAsync(CancellationToken)

Extension Methods

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