IAzureCosmosDb Interface

Azure Cosmos Db ORM (interface of singleton implementation).

This interface is used to interact with the Azure Cosmos Database.
It allows the programmer to create, modify or delete items derived from IIdLabel.

In some cases, such methods are only allowed if the user's RoleDto has the correct permissions.
To prevent users from accessing methods they shouldn't, the AccountDto and RoleDto of the user are required in many methods.
There the RoleDto's Permissions are checked against the method's requirements.
If the user doesn't have the permissions, this will be logged as a potential hacking attempt.
As per the guidelines for logging potential hacking attempts, this is why the user's IP Address is also required as a parameter.

This means that the IAzureCosmosDb interface is the last line of defense against unauthorized access.
Preceding code should already have prevented the user from being offered this feature.

In theory, no method should ever fail to execute. However, we're relying on an internet connection with Azure, and Azure in turn has a lot of moving parts. Because of this, Cosmos can sometimes be slow to respond, or even fail to respond because of things outside ours or Microsoft's control.
In such cases, we can we returned a CosmosException. The front-end should be able to inform the user of this issue.

Definition

Namespace: MobileTrack.DataContainers.Cosmos
Assembly: MobileTrack.DataContainers (in MobileTrack.DataContainers.dll) Version: 0.7+45c8d9adb5970d727cceec44a5ed61aea0016e50
public interface IAzureCosmosDb : IDisposable
Implements
IDisposable

Methods

ActivateLicenseCompany Activate the company's license
CancelFourEyesRequestAccount Cancels four-eyes control for an AccountDto
CancelFourEyesRequestCompany Cancel four-eyes control request of an EnvironmentDto.
CancelFourEyesRequestDevice Request four-eyes control for a DeviceDto
CancelFourEyesRequestEnvironment Cancel four-eyes control request of an EnvironmentDto.
ConfirmEditAccount Confirm edit request of an AccountDto
ConfirmEditDevice Confirm edit request of an DeviceDto
ConfirmEditEnvironment Confirm edit request of an EnvironmentDto
ConnectorHasOutage Checks if any connector has an outage - the Heartbeat Monitor registers this in the redis cache.
CreateAccount Creates an account in the database
CreateAlertRuleProcessResult Logs the result of an alert rule execution to the database.
CreateCompany Creates a company in the database. This method can only be executed by MobileTrack employees.
CreateDevice Creates a Device in the database.
CreateDeviceMessage Creates a Device Message in the database. Can only be invoked by device receivers, not users!
CreateDevicePayload Creates a Device payload in the database.
CreateEnvironment Creates an environment in the database.
CreateForgotPasswordRequest Creates a 'forgotten password' request for the user.
CreateIpAddressStatusAutomatically Creates an IP Address Status in the database from Login.cshtml.cs
CreateMapMarker Creates a Map Marker in the database. Can only be invoked by device receivers, not users!
CreateMfa Creates a new mfa in the database
CreateNewPassword Creates a new password in the database and deactivates the old one.
CreateNotification Creates a NotificationDto in the database
CreateOrUpdateLocaleString Creates (or, if it already exists, updates) a localized string.
CreatePassword Creates a password in the database.
CreateRole Creates a new role in the database for a company.
CreateRoleAssignment Creates a role assignment for a scope.
CreateSettings Creates a Settings model in the database.
DeleteAccount Deletes AccountDto from the database.
DeleteActionFlow Deletes ActionFlowDefinitionDto from the database.
DeleteAlertRule Deletes AlertRuleDto from the database.
DeleteAlertType Deletes AlertTypeDto from the database.
DeleteCompany Deletes an entire company from the database; AccountDto's, EnvironmentDto's, the CompanyDto itself, etc.
DeleteConnectorState Deletes ConnectorStateDto from the database.
DeleteCustomPage Deletes CustomPageDto from the database.
DeleteDashboard Deletes DashboardDto from the database.
DeleteDevice Deletes a DeviceDto from the database
DeleteEnvironment Deletes an EnvironmentDto from the database
DeleteFourEyesRequestNotification Remove a four-eyes request notification from the database
DeleteIpAddressStatus Deletes a IpAddressStatusDto from the database
DeleteMapMarker Deletes a MapMarkerDto from the database
DeleteMfa Deletes MfaConnectionDto from the database.
DeleteNotification Deletes a NotificationDto from the database
DeletePersonalMfa User should be able to delete their own MfaConnectionDto from the database.
DeleteRole Deletes RoleDto from the database.
DeleteTemplate Deletes TemplateDto from the database.
DisableAccountTwoFactorAuthentication Disable two-factor authentication of an AccountDto
DisableCompanyTwoFactorAuthentication Disable the company's two-factor authentication. All accounts in the company will no longer be required to use two-factor authentication.
EnableAccountTwoFactorAuthentication Enable two-factor authentication of an AccountDto
EnableCompanyMfa Enables Multi-Factor Authentication (MFA) for all accounts within the specified company.
EnableCompanyTwoFactorAuthentication Enable the company's two-factor authentication. All accounts in the company will be required to use two-factor authentication.
ExpireLicenseCompany Expire the company's license
FourEyesRequestAccount Request four-eyes control for an AccountDto
FourEyesRequestCompany Performs a four-eyes control request for a CompanyDto.
FourEyesRequestDevice Request four-eyes control for a DeviceDto
FourEyesRequestEnvironment Request four-eyes control for an EnvironmentDto.
GetAccessibleAccountsForModification Receives the accounts that the user has access to based on ManageAccounts
GetAccountByEmailAddress Tries to find an AccountDto by its EmailAddress. This method is often used for login purposes and to ensure that for newly created accounts the email address is unique.
GetAccountByEmailAddressForLogin This is a duplicate of GetAccountByEmailAddress(IHasEmailAddress, Boolean, CancellationToken), but it is used for login purposes.
GetAccountById(Guid, CancellationToken) Retrieves an AccountDto by its accountId.
GetAccountById(CompanyDto, Guid, CancellationToken) Retrieves an AccountDto by its accountId. The company is used to verify that the AccountDto belongs to the CompanyDto. It also directs Azure to the correct container partition.
GetAccountMfaSettings Get mfa settings of an account
GetActionFlowById Retrieves a single action flow by its ID.
GetActionFlowDiagramsByCompanyId Retrieves a list of ActionFlowDefinitionDto by its companyId.
GetActionFlowOptionsByEvent Retrieves a series of action flow options, separated by event. Events without any options will return an empty array. This is used in the company settings tab, so action flows can be assigned to events for that particular company; therefore, the options contain the global action flows and the ones that are custom for that companyId. If companyId is , then only the global action flows will be returned.
GetActivePasswordOfUser Gets active password belonging to the user
GetAlertRules Retrieves a list of AlertRuleDto by its companyId
GetAlertRulesByDeviceAndEvent Retrieves a list of AlertRuleDto applicable to a specific device and event.
GetAlertType Retrieves a AlertTypeDto by its alertTypeId.
GetAlertTypes Retrieves a list of AlertTypeDto by its companyId.
GetAllAccounts Returns all AccountDtos in the database. Only to be used for maintenance.
GetAllCompanies Gets a list of all companies, whether deleted or not.
GetAllEnvironments Get all environments from all companies from the database. Should only be used for maintenance work and unit tests.
GetAllKmls Get all Kml files in the database. This method should only be used for maintenance purposes.
GetAllLocalizedStrings Gets all the available key/value pairs of the localization strings. Invoked by IStringLocalizer
GetAllLogs Retrieves all LogDto's in the database
GetAllMessages Retrieves all device messages from the database no matter who owns them or what Device they belong to. Should only be used for debugging purposes!
GetAllPasswords Gets all passwords from the database. Should only be used for maintenance work.
GetApiTokenByKey Retrieves an Api Token by its key
GetAssignableRolesOfUser Gets roles that the user can assign to other users.
GetAssignmentByCompanyAndEvent Retrieves the assignment of an action flow to the companyId and actionFlowEvent.
GetAssignmentsByCompany Retrieves the custom assignments company companyId has applied. If companyId is Empty, then the global action flow assignments will be returned.
GetAutoCompleteAccountsSearch Retrieves 3 accounts (maximum) based on the user query and permissions.
GetAutoCompleteCompaniesSearch Retrieves 5 companies (maximum) based on the user query and permissions.
GetAutoCompleteDeviceSearch Retrieves 3 devices (maximum) based on the user query and permissions.
GetAutoCompleteEnvironmentSearch Retrieves 3 environments (maximum) based on the user query and permissions.
GetAutoCompleteGeofencesSearch Retrieves 3 geofences (maximum) based on the user query and permissions.
GetBuiltInRoleAssignmentsOfEnvironment Retrieves automatically assigned role assignments from accounts residing in environment.
GetCompanies Gets a list of all deleted/non-deleted companies.
GetCompaniesListing Gets a listing of all deleted/non-deleted companies.
GetCompanyAccounts Get accounts belonging to company company
GetCompanyAccountsListing Returns a listing of all accounts belonging to a company.
GetCompanyById Gets CompanyDto data
GetCompanyByReference Gets CompanyDto data of the owner of item
GetCompanyDevices Get all Devices belonging to company
GetCompanyDevicesListing Get a simple ID/Label listing of all DeviceDto's belonging to company.
GetCompanyEnvironments Retrieves all non-deleted EnvironmentDtos owned by the company.
GetCompanyEnvironmentsListing Retrieves all non-deleted EnvironmentDtos owned by the company in a ID/Label listing
GetCompanyHierarchy Loads all assets of an CompanyDto and puts them into a usable tree, with the Main EnvironmentDto being the root node.
GetCompanyIpWhiteBlackList Retrieves the White/Blacklist of IpAddressStatusDtoes for company.
GetCompanyMapMarkersListing Retrieves the ID/Label listing of the map markers available for a company.
GetCompanyRolesListing Get Roles belonging to companyId
GetCompanyTemplatesListing Retrieves the listing of available templates for a company.
GetConnectorStateByAlertTypeId Gets the connector state for a specific alert type.
GetCustomPageById Retrieves a CustomPageDto by its customPageId.
GetCustomPages Retrieves a list of CustomPageDto
GetCustomPagesByLanguage Retrieves a list of CustomPageDto that have matching language.
GetDashboardsByAccountId Retrieves a list of DashboardDto by its accountId.
GetDeletedAccountById Get soft-deleted AccountDto's belonging to a CompanyDto.
GetDeletedAccounts Get soft-deleted AccountDto's belonging to a CompanyDto.
GetDeletedCustomPages Get soft-deleted CustomPageDto based on language string.
GetDeletedDashboards Get soft-deleted DashboardDto's belonging to a CompanyDto.
GetDeletedDevice Get soft-deleted DeviceDto's belonging to a CompanyDto.
GetDeletedDevices Get soft-deleted DeviceDto's belonging to a CompanyDto.
GetDeletedEnvironment Get a soft-deleted environment belonging to a company.
GetDeletedEnvironments Get soft-deleted environments belonging to a company.
GetDeviceByAlternateConnectionString Get a Device by its connectionString
GetDeviceById Retrieves a DeviceDto by its ID.
GetDeviceByImeiCode Retrieves a Device by its imeiNumber
GetDeviceByMacAddress Get a Device by its macAddress
GetDevicesAssociatedWithAccount Retrieves all devices that are AccountId for account
GetDevicesOfMapMarker Retrieves all devices associated with mapMarker.
GetEnvironmentById Retrieves an EnvironmentDto by its environmentId. The company is used to verify that the EnvironmentDto belongs to the CompanyDto. It also directs Azure to the correct container partition.
GetEnvironmentByReference Retrieves an EnvironmentDto by its environmentReference. The company is used to verify that the EnvironmentDto belongs to the CompanyDto. It also directs Azure to the correct container partition.
GetEnvironmentDevices Retrieves all Devices belonging to the environment and its sub-environments.
GetExceptionLogs(UserSessionData, CancellationToken) Retrieve Exception logs.
GetExceptionLogs(UserSessionData, IReadOnlyListFilterItem, IReadOnlyListSortingItem, UInt16, UInt16, CancellationToken) Retrieve Exception logs.
GetGeofencesOfCompany Get geofences of devices or environments belonging to a company.
GetGlobalAutoCompleteDeviceSearch Retrieves 3 devices (maximum) from any company based on the user query and permissions.
GetGlobalIpWhiteBlackList Retrieves the global White/Blacklist of IpAddressStatusDtoes shared between all companies and MT Support.
GetInactivePasswordsOfUser Gets inactive password belonging to user.
This is often used to ensure a new password is not the same as previous ones.
GetIpAddressStatuses Retrieves the white/blacklist of IpAddressStatusDtoes for company in a neat order.
If company is , we'll retrieve the global IP Address Status list.
GetIpAddressStatusOfUser Retrieves the status of an IP Address, if available in the database. If we're logging in on a location that the company the user belongs to never has been at, and if it doesn't appear on the global white/blacklist, the method will return .
GetLastDeviceMessageOfType Returns the most recently received DeviceMessageDto matching a given device and DeviceRequestType.
GetLatestExceptionLog Retrieve latest Exception log created by the user.
GetLocalizationStringsOfLocale Gets all the available key/value pairs of the localization strings of a specific locale.
GetLogsOfCompany Retrieves all LogDto's belonging to companyId.
GetLogsOfItemT Retrieves all the logs of an item (unsorted)
GetMapMarkerById Retrieve a MapMarkerDto by its markerId
GetMapMarkersOfCompany Retrieves the MapMarkerDtos belonging to company with company.
GetMessagesOfDevice Retrieves all device messages belonging to a Device.
GetMessagesOfUser Returns all read/unread/deleted messages of a user.
GetMfaById Get mfa by its ID
GetNotificationsOfUser Retrieves all notifications.
GetReplicationLayer Retrieves the replication layer interface.
GetRequestById Gets request by its Id.
GetRequestNotificationOfUserByType Gets request by AccountId.
GetRoleAssignmentsOfAccount Retrieves the role assignments, and the default role assignment in the user, based on parameter user/
GetRoleAssignmentsOfCompany Retrieves the Role Assignments belonging company.
GetRoleAssignmentsOfScope Retrieves role assignments of scope scopeId.
GetRoleById(Guid, CancellationToken) Gets role by ID, for use in the Mt Role Store.
GetRoleById(CompanyDto, Guid, CancellationToken) Get role by company and roleId
GetRolesOfCompany Get Roles belonging to company
GetSettingsById Gets settings model (regardless if it based on a CompanyDto or an AccountDto
GetSettingsOfUser Get the settings of a user. If none are found, one will be generated.
GetTemplateById Retrieves a template by its id.
GetTemplatesByCompanyId Retrieves a list of TemplateDto by its companyId. (or Empty for global templates)
IsEnvironmentEmpty Checks if environment is empty.
LockAccount Locks an AccountDto
LockCompany Locks an entire company, its AccountDto's, EnvironmentDto's, and the CompanyDto itself, etc.
LockDevice Locks a DeviceDto
LockEnvironment Locks an EnvironmentDto and its children.
LogAuthEvent Logs an event caused by a user during an authentication process (login, logout, MFA, forgotten password, etc.)
LogBackgroundProcessEventT Logs an event caused by automatic processes (e.g. a device event)
LogException Logs an exception
LogUserEvent(UserSessionData, EventId, IIdLabel, Guid, IIdLabel, CancellationToken) Logs an event caused by a user. (e.g. a user creating or deleting an object)
LogUserEventT(UserSessionData, EventId, T, IIdLabel, CancellationToken) Logs an event caused by a user. (e.g. a user creating or deleting an object)
MoveIpStatusToBlackList Moves a company-based item to the global IP blacklist. Can only be performed by MobileTrack support users.
MoveIpStatusToGlobal Moves a company-based item to the global IP white/blacklist. Can only be performed by MobileTrack support users.
MoveIpStatusToWhiteList Moves a company-based item to the whitelist. Can only be performed by MobileTrack support users.
NotificationSetRead Sets Read = and saves it to the database. Do not set Read to manually, as this will cause an InvalidOperationException to be thrown.
PurgeExpiredItems Purges all soft deleted items from the database whose time period has expired.
RedisSubscribe Subscribes to a Redis channel; mostly used to allow front-end users to receive updates from the Event Handler or the Device Receiver regarding events they need to know about.
RedisUnsubscribe Unsubscribes from a Redis channel.
RevertAccountDeletion Reverts the soft deletion of an account
RevertCustomPageDeletion Reverts the soft deletion of a CustomPageDto
RevertDashboardDeletion Reverts the soft deletion of a DashboardDto
RevertDeleteCompany Revert deletion of a company.
RevertDeviceDeletion Reverts the soft deletion of an account
RevertEnvironmentDeletion Reverts the soft deletion of an account
SendActionFlowExecutionUpdate When executing a specific action flow, this method is used by te Event Handler to send updates using the Redis pub/sub mechanism, so the front-end can inform the user.
SetRequestAsCompleted Sets a request as fulfilled.
UnlockAccount Unlocks an AccountDto and its environment (if locked)
UnlockCompany Unlocks an entire company, its AccountDto's, EnvironmentDto's, and the CompanyDto itself, etc.
UnlockDevice Unlocks a DeviceDto and its environment (if locked)
UnlockEnvironment Unlocks an EnvironmentDto and its children.
UpdateAccount Updates an original value in the database with the newValue
UpdateAccountFromAuth Updates an original value in the database if the update came from the user itself during authentication. (e.g. setting their MFA connection)
UpdateCompany Updates a CompanyDto value in the database
UpdateDevice Updates a DeviceDto value in the database
UpdateDeviceByDeviceReceiver Updates a DeviceDto value in the database
UpdateEnvironment Updates a EnvironmentDto value in the database
UpdateItemGeofencesT Updates the Geofences property of a DeviceDto or EnvironmentDto in the database, but not the other properties.
UpdateMapMarker Updates a MapMarkerDto value in the database
UpdateMfaConnection Updates an original value in the database with the newValue
UpdateOrCreateActionFlowAssignment Update or Creates an action flow assignment in the database. If an assignment with the same ActionFlowEvent> already exists for the company, it will be updated.
UpdateOrCreateActionFlowDefinition Update or Creates a action flow in the database
UpdateOrCreateAdminDashboard Creates an Admin Dashboard in the database
UpdateOrCreateAlertRule Creates or update an Alert rule in the database
UpdateOrCreateAlertType Creates or update an Alert type in the database
UpdateOrCreateConnectorState Creates or update an ConnectorStateDto in the database
UpdateOrCreateCustomPage Creates an CustomPageDto in the database
UpdateOrCreateDashboard Update or Creates a personal Dashboard in the database
UpdateOrCreateTemplate Update or Creates a template in the database
UpdateRole Updates a RoleDto value in the database
UpdateSettings Updates a SettingsDto value in the database

Extension Methods

CancelFourEyes Cancels a four-eyes request.
(Defined by FourEyesExtensions)
CancelFourEyesCompany Cancels a four-eyes request of a company.
(Defined by FourEyesExtensions)
ConfirmFourEyesRequest Confirm a 4-eyes request for a resource
(Defined by FourEyesExtensions)
CreateFourEyesRequestAccount Sends a 4-eyes request to alter an account
(Defined by FourEyesExtensions)
CreateFourEyesRequestCompany Sends a 4-eyes request to alter a Company
(Defined by FourEyesExtensions)
CreateFourEyesRequestDevice Sends a 4-eyes request to alter a Device
(Defined by FourEyesExtensions)
CreateFourEyesRequestEnvironment Sends a 4-eyes request to alter an environment
(Defined by FourEyesExtensions)
DeepCheckAccountCreateOrUpdate Checks if the new/edited account account can be added/updated to the database without conflicting with existing data.
(Defined by DeepChecks)
DeepCheckActionFlowAssignmentCreateOrUpdate Performs a deep check on the Action flow assignment assignment to ensure it can be added/updated to the database without conflicting with existing data.
(Defined by DeepChecks)
DeepCheckActionFlowDefinitionCreateOrUpdate Performs a deep check on the actionFlow to ensure it can be added/updated to the database without conflicting with existing data.
(Defined by DeepChecks)
DeepCheckDeviceCreateOrUpdate Deep checks the device to ensure it can be added/updated to the database without conflicting with existing data.
(Defined by DeepChecks)
DeepCheckEnvironmentCreateOrUpdate Deep checks the environment to ensure it can be added/updated to the database without conflicting with existing data.
(Defined by DeepChecks)
DeepCheckRoleCreateOrUpdate Checks if the new/edited role role can be added/updated to the database without conflicting with existing data.
(Defined by DeepChecks)
DenyFourEyesRequestResource Denies a 4-eyes request to alter a resource
(Defined by FourEyesExtensions)
ParseAllLogs Retrieves logs from the database for an item and parses them into a readable form.
(Defined by LogFactory)
ParseExceptionLogs Retrieves logs from the database for an item and parses them into a readable form.
(Defined by LogFactory)
ParseLogsOfCompany Retrieves logs from the database for an item and parses them into a readable form.
(Defined by LogFactory)
ParseLogsOfItemT Retrieves logs from the database for an item and parses them into a readable form.
(Defined by LogFactory)

Exceptions

CosmosOperationCanceledException Invoked if a CancellationToken was cancelled while an operation in any of the methods was going on.
CosmosObjectDisposedException Can be potentially invoked if the IAzureCosmosDb implementation was disposed while methods were running.
CosmosException Invoked if something went wrong in the communication between the service and the Azure Cosmos DB. (This may be because of a faulty internet connection)

See Also