Class AssociateCache
Inherited Members
Namespace: SuperOffice.CRM.Cache
Assembly: SoDataBase.dll
Syntax
[CacheV2(0)]
public class AssociateCache : CacheBaseV2
Constructors
AssociateCache()
Declaration
public AssociateCache()
Properties
TableNames
Gets the names of the table data that are cached in this cache. When these tables are updated the cache will be disposed so a new cache instance can take its place.
Declaration
protected override IEnumerable<string> TableNames { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<string> |
Overrides
Methods
GetAllAssociateFullNames(bool)
Get all employees/users - the associate tooltip is set to the person's full name
Declaration
public Dictionary<int, string> GetAllAssociateFullNames(bool includeRetired)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | includeRetired | true if you want retired associates included |
Returns
| Type | Description |
|---|---|
| Dictionary<int, string> | Array of associate info |
GetAssociate(int)
Get an Associate based on it's associate Id
Declaration
public AssociateRecordData GetAssociate(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | Primary key for the Associate. |
Returns
| Type | Description |
|---|---|
| AssociateRecordData | Associate entity. |
GetAssociateContact(int)
Get the (cached) contact for an associate
Declaration
public ContactRecordData GetAssociateContact(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | The associate id of the user to get the contact for |
Returns
| Type | Description |
|---|---|
| ContactRecordData | ContactRow, or null if the associate does not have an owning contact (is a resource, for instance) |
GetAssociateContactId(int)
Get the ContactId for an associate.
Declaration
public int GetAssociateContactId(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | The associate id of the user to get the ContactId for. |
Returns
| Type | Description |
|---|---|
| int | ContactId for the user. |
GetAssociateCountry(int)
Get country id for the associate.
Declaration
public int GetAssociateCountry(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | AssociateId to get countryId for |
Returns
| Type | Description |
|---|---|
| int | Country id for the associate. |
GetAssociateDateOfBirth(int)
Get the date of birth of the associate (from person record that the associate belongs to)
Declaration
public DateTime GetAssociateDateOfBirth(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | Associate to look up |
Returns
| Type | Description |
|---|---|
| DateTime | Date of birth of the associate's person |
GetAssociateEjUserId(int)
Get the EjUserId for a given associate
Declaration
public int GetAssociateEjUserId(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId |
Returns
| Type | Description |
|---|---|
| int |
GetAssociateEjUserStatus(int)
Get UjUser EjUserStatus for the associates ejUser
Declaration
public EjUserStatus GetAssociateEjUserStatus(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId |
Returns
| Type | Description |
|---|---|
| EjUserStatus |
GetAssociateEmailAddress(int)
Get email-address, of rank 1, if it exists for an associate
Declaration
public string GetAssociateEmailAddress(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | Associate to look up |
Returns
| Type | Description |
|---|---|
| string | EmailAddress of rank 1 linked to associates' person; null is returned in any other case |
GetAssociateEmailId(int)
Get the email-id, of rank 1, if it exists for an associate
Declaration
public int GetAssociateEmailId(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | Associate to look up |
Returns
| Type | Description |
|---|---|
| int | email_id of rank 0 linked to associates' person; 0 is returned in any other case |
GetAssociateFirstName(int)
Get the first name of the associate (from person record that the associate belongs to)
Declaration
public string GetAssociateFirstName(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | Associate to look up |
Returns
| Type | Description |
|---|---|
| string | First name of the associate's person |
GetAssociateFormalName(int)
Get the formal name of an associate based on GetFormalName(string, string, string, int, string, string).
Declaration
public string GetAssociateFormalName(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | AssociateId of the person |
Returns
| Type | Description |
|---|---|
| string | Formal name according to GetFormalName(string, string, string, int, string, string). |
GetAssociateFullName(int)
Get the full name of an associate according to GetFullName(PersonRow).
Declaration
public string GetAssociateFullName(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | AssociateId of the person to get the full name for. |
Returns
| Type | Description |
|---|---|
| string | Full name according to GetFullName(PersonRow). |
GetAssociateId(string)
Get the associate id from a associate name
Declaration
public int GetAssociateId(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | name of the associate (e.g. user id) |
Returns
| Type | Description |
|---|---|
| int | Associate Id. -1 is returned if the the provided name is not a valid associate. |
GetAssociateIds()
Get all associate id's
Declaration
public IEnumerable<int> GetAssociateIds()
Returns
| Type | Description |
|---|---|
| IEnumerable<int> |
GetAssociateImageAsync(int, int, int)
Get and cache (if scaled) an associate image, in raw form
Declaration
public Task<Image> GetAssociateImageAsync(int associateId, int width = 0, int height = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | |
| int | width | |
| int | height |
Returns
| Type | Description |
|---|---|
| Task<Image> |
GetAssociateLastName(int)
Get the last name of the associate (from person record that the associate belongs to)
Declaration
public string GetAssociateLastName(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | Associate to look up |
Returns
| Type | Description |
|---|---|
| string | Last name of the associate's person |
GetAssociateMiddleName(int)
Get the middle name of the associate (from person record that the associate belongs to)
Declaration
public string GetAssociateMiddleName(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | Associate to look up |
Returns
| Type | Description |
|---|---|
| string | Middle name of the associate's person |
GetAssociateMrMrs(int)
Get the MrMrs field of the associate (from person record that the associate belongs to)
Declaration
public string GetAssociateMrMrs(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | Associate to look up |
Returns
| Type | Description |
|---|---|
| string | MrMrs field of the associate's person |
GetAssociateName(int)
Declaration
public string GetAssociateName(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId |
Returns
| Type | Description |
|---|---|
| string |
GetAssociateOwnerId(int)
Get the associate id for the owner of the contact that the person representing the associate belongs to. (associate.person.contact.associate)
Declaration
public int GetAssociateOwnerId(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | AssociateId of the person the get owner for. |
Returns
| Type | Description |
|---|---|
| int | AssociateId of the owner. |
GetAssociatePersonId(int)
Get the PersonId for an associate. 0 is returned if there is no valid associate with that id (or if the associate.PersonId actually is 0, which is the case for resources and some other special kinds of associates).
Declaration
public int GetAssociatePersonId(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | The associate id of the user to get the PersonId for. |
Returns
| Type | Description |
|---|---|
| int | PersonId for the user. |
GetAssociateRoleId(int)
Get the Role id for the Associate (Associate.UserRoleLink)
Declaration
public int GetAssociateRoleId(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId |
Returns
| Type | Description |
|---|---|
| int | Primary key of the user's role |
Remarks
Use RoleCache for additional, information about the role.
GetAssociateTitle(int)
Get the title field of the associate (from person record that the associate belongs to)
Declaration
public string GetAssociateTitle(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | Associate to look up |
Returns
| Type | Description |
|---|---|
| string | Title field of the associate's person |
GetAssociateType(int)
Get the AssociateType for a user.
Declaration
public AssociateType GetAssociateType(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | AssociateId for the user to check the AssociateType for. |
Returns
| Type | Description |
|---|---|
| AssociateType | Type of user. |
GetEjUserAssociateId(int)
Get the AssociateId for a given EjUser
Declaration
public int GetEjUserAssociateId(int ejUserId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ejUserId |
Returns
| Type | Description |
|---|---|
| int |
GetEncodedAssociateImageAsync(int, int, int)
Get and cache (if scaled) an associate image, in encoded form (PNG => CultureDataFormatter)
Declaration
public Task<string> GetEncodedAssociateImageAsync(int associateId, int width = 0, int height = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | |
| int | width | |
| int | height |
Returns
| Type | Description |
|---|---|
| Task<string> |
GetPersonAssociateId(int)
Get a AssociateId for a person, 0 is returned if the person is not an associate.
Declaration
public int GetPersonAssociateId(int personId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | personId | The person's id to get the AssociateId for. |
Returns
| Type | Description |
|---|---|
| int | The AssociateId of the user. If the person is not a user, '0' is returned. |
GetPersonImageAsync(int)
Declaration
public static Task<Image> GetPersonImageAsync(int personId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | personId |
Returns
| Type | Description |
|---|---|
| Task<Image> |
IsAssociateRetired(int)
Declaration
public bool IsAssociateRetired(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId |
Returns
| Type | Description |
|---|---|
| bool |
IsAssociateTypeAnonymous(int)
Determine whether this associate is anonymous, based on the AssociateType flag bits of the associate type.
Declaration
public bool IsAssociateTypeAnonymous(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | Associate to check |
Returns
| Type | Description |
|---|---|
| bool | true if the associate is anonymous |
IsAssociateTypeDiaryOwner(int)
Determine whether this associate has a diary, based on the NoCalenderBit flag bits of the associate type.
Declaration
public bool IsAssociateTypeDiaryOwner(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | Associate to check |
Returns
| Type | Description |
|---|---|
| bool | true if the associate has a diary (AssociateType.NoCalenderBit = 0) |
IsAssociateTypeNoSentry(int)
Determine whether this associate is exempt from Sentry checks, based on the AssociateType flag bits of the associate type.
Declaration
public bool IsAssociateTypeNoSentry(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | Associate to check |
Returns
| Type | Description |
|---|---|
| bool | true if the associate ignores the sentry system (a rare privilege) |
IsAssociateTypeResource(int)
Determine whether this associate is a resource based on the AssociateType flag bits of the associate type.
Declaration
public bool IsAssociateTypeResource(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | Associate to check |
Returns
| Type | Description |
|---|---|
| bool | true if the associate actually is a resource |
IsAssociateTypeSomeKindOfPerson(int)
Determine whether this associate is some kind of person (resource, for instance, are not), based on the AssociateType flag bits of the associate type.
Declaration
public bool IsAssociateTypeSomeKindOfPerson(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | Associate to check |
Returns
| Type | Description |
|---|---|
| bool | true if the associate is some kind of person |
IsCacheInvalidatedAsync(string, int, PrivateSave, CancellationToken)
Determine if cache actually needs to be flushed. The answer is no for changes to non-person associates
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
IsPersonAssociate(int, bool)
Is a given person an associate (e.g. user).
Declaration
public bool IsPersonAssociate(int personId, bool useFailSafeValidation = false)
Parameters
| Type | Name | Description |
|---|---|---|
| int | personId | PersonId of the person to check if it is an associate. |
| bool | useFailSafeValidation | If you have to be 100% sure that your database is consistent with the cache, this value should be true. Otherwise, use false or just omit the parameter all together. Setting this value true might refresh the cache and subsequently limits performance. Should only be used if consistency is vital |
Returns
| Type | Description |
|---|---|
| bool | True if the person is an associate. |
IsUserInSameContact(int)
Is the logged on user belonging to the same contact?
Declaration
public bool IsUserInSameContact(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | AssociateId for the user to check if belongs to same contact |
Returns
| Type | Description |
|---|---|
| bool | true if they belong to the same contact. |
IsUserInSameContact(int, int)
Is the two users belonging to the same contact?
Declaration
public bool IsUserInSameContact(int associateId1, int associateId2)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId1 | AssociateId for the 1st user to check if belongs to same contac. |
| int | associateId2 | AssociateId for the 2nd user to check if belongs to same contact. |
Returns
| Type | Description |
|---|---|
| bool | true if they belong to the same contact. |
OnLoad()
Actual cache loading method, to be implemented by derived class. Sentry is Ignored when this method is called
Declaration
protected override void OnLoad()
Overrides
OnLoadAsync(CancellationToken)
Actual cache loading method, to be implemented by derived class. Sentry is Ignored when this method is called
Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
protected override Task OnLoadAsync(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
Overrides
ValidateAndTestAssociate(int)
Validate that an associate exists. Refresh the cache if we're asking about the current logged-in user, since he may be freshly created and not in the cache. Keep a zombie list of known non-existent ones.
Declaration
public bool ValidateAndTestAssociate(int associateId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | Id of the associate to validate. |
Returns
| Type | Description |
|---|---|
| bool |