Interface ICustomFunctions
A set of custom functions that can be run against the IEntityUpdater
Namespace: LemonEdge.API.Core.Data
Assembly: LemonEdge.API.dll
Syntax
public interface ICustomFunctions
Methods
AllowsCLRSQLFunctions()
Returns true if the database is configured to allow custom .net framework clr functions to be loaded as assemblies
Declaration
Task<bool> AllowsCLRSQLFunctions()
Returns
Type | Description |
---|---|
Task<bool> | A task holding true if the database is configured to allow custom .net framework clr functions to be loaded as assemblies |
ApproveItemsFromCanvas(Guid, Guid, Guid)
Approves the specified canvas change for promotion
Declaration
Task<bool> ApproveItemsFromCanvas(Guid canvasID, Guid typeID, Guid id)
Parameters
Type | Name | Description |
---|---|---|
Guid | canvasID | The canvas you want to approve a change from |
Guid | typeID | The type of item you want to approve from the canvas |
Guid | id | The id of the item that has been changed in the canvas, and that you want approved |
Returns
Type | Description |
---|---|
Task<bool> | A task indicating the successful completion of the operation |
ClearItem(Guid, Guid, Guid, bool, bool)
Clears an item from the canvas.
Declaration
Task<bool> ClearItem(Guid canvasID, Guid typeid, Guid id, bool clearApprovalRejection, bool clearComment)
Parameters
Type | Name | Description |
---|---|---|
Guid | canvasID | The canvas you want to clear a change from |
Guid | typeid | The type of item you want to clear from the canvas |
Guid | id | The id of the item that has been changed in the canvas, and that you want to clear |
bool | clearApprovalRejection | Whether to clear any approval / rejection |
bool | clearComment | The comment to associate with it |
Returns
Type | Description |
---|---|
Task<bool> | A task indicating the successful completion of the operation |
DoesUserExist(string, Guid)
Indicates if the specified emailID
already exists as a user in the system
Declaration
Task<bool> DoesUserExist(string emailID, Guid ignore)
Parameters
Type | Name | Description |
---|---|---|
string | emailID | The email to check and see if it already exists in the database across accounts. Emails for users must be globally unique |
Guid | ignore | Indicates the specified user ID should be ignored. This way you can check for an email ignoring the email the user currently has |
Returns
Type | Description |
---|---|
Task<bool> | A task indicating if a user with the specified |
GetAuditData(Guid?, Guid, Guid, string)
Returns the audit history (IAuditData) of a specified particular item, including old values, new values, type of change, who made it and when
Declaration
Task<IEnumerable<IAuditData>> GetAuditData(Guid? canvasID, Guid typeID, Guid id, string base64SerializedQueryExecuter)
Parameters
Type | Name | Description |
---|---|---|
Guid? | canvasID | The id of any Canvas you want this query to run in. Null indicates the current main system |
Guid | typeID | The ID of the entity type you want to run this query against |
Guid | id | The id of the actual item you want the audit history of |
string | base64SerializedQueryExecuter | A QueryableExecuter<T> of type IAuditData with any custom query for further filtering the results |
Returns
Type | Description |
---|---|
Task<IEnumerable<IAuditData>> | A task holding an enumerable list of results detailing the entire audit history of a specified item |
Remarks
This type of functionality can also be achieved by creating a SQLWrapper that runs your own custom sql process, a type that can hold the results, and calling that using GetSQLResults<T>(Guid, string, string)
GetAuditDataCount(Guid?, Guid, Guid, string)
Returns the count of all audit changes (IAuditData) of a specified particular item
Declaration
Task<int> GetAuditDataCount(Guid? canvasID, Guid typeID, Guid id, string base64SerializedQueryExecuter)
Parameters
Type | Name | Description |
---|---|---|
Guid? | canvasID | The id of any Canvas you want this query to run in. Null indicates the current main system |
Guid | typeID | The ID of the entity type you want to run this query against |
Guid | id | The id of the actual item you want the audit history of |
string | base64SerializedQueryExecuter | A QueryableExecuter<T> of type IAuditData with any custom query for further filtering the results |
Returns
Type | Description |
---|---|
Task<int> | A task holding the count of results detailing the entire audit history of a specified item |
Remarks
This type of functionality can also be achieved by creating a SQLWrapper that runs your own custom sql process, a type that can hold the results, and calling that using GetSQLResultsCount<T>(Guid, string, string)
GetCacheLastModification()
Returns the last modified database date/time of any standing data item that is automatically cached by the client on loading
Declaration
Task<DateTimeOffset> GetCacheLastModification()
Returns
Type | Description |
---|---|
Task<DateTimeOffset> | A task holding the last modified database date/time of any standing data item that is automatically cached by the client on loading |
GetCurrentDBTime()
Returns the current database time from the database server
Declaration
Task<DateTimeOffset> GetCurrentDBTime()
Returns
Type | Description |
---|---|
Task<DateTimeOffset> | A task holding the current database time from the database server |
GetCurrentLoggedInUser()
Returns the current logged in user
Declaration
Task<IEnumerable<UserInfo>> GetCurrentLoggedInUser()
Returns
Type | Description |
---|---|
Task<IEnumerable<UserInfo>> |
GetFromDocumentStorage(IEnumerable<Guid>)
Returns the specified document from the configured IDocumentStorage.
Declaration
Task<byte[]> GetFromDocumentStorage(IEnumerable<Guid> ids)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Guid> | ids | The id of the IDocumentAttachment |
Returns
Type | Description |
---|---|
Task<byte[]> | A task holding a byte array of the specified document contents |
GetFromStorage(Guid, Guid?, string, string, bool, Guid?)
Returns the specifed file from the storage on the server. This storage is dependant on how LemonEdge is configured, it could be a network path, or azure blob container or other cloud storage system. This is needed to be known in order to retrieve the specified files.
The files are automatically stored by appropriate server tasks and can be accessed by client applications through this method
Files can be stored against entity types, and individual items
Declaration
Task<byte[]> GetFromStorage(Guid typeID, Guid? id, string fileName, string folder, bool restricted, Guid? taskId = null)
Parameters
Type | Name | Description |
---|---|---|
Guid | typeID | The type of entity the file is stored against |
Guid? | id | Optional - The id of the item the file is stored against |
string | fileName | The name of the file to retrieve |
string | folder | Any sub-folder path this file resides within |
bool | restricted | Indicates it is a file specific to this individual user. For instance the result of queries ( ISQLWrapper) are stored by user |
Guid? | taskId | An optional task ID to be used as part of the file path when locating the file |
Returns
Type | Description |
---|---|
Task<byte[]> | A task holding a byte array of the specified file contents |
GetItemInfo(Guid, Guid)
Returns a user description tooltip about the specified item in the system. You can use CustomFunctionsHelper to parse the results
This includes basic item information such as the item user friendly name, when it was created and by whom. Also when it was last updated and by whom.
Declaration
Task<string> GetItemInfo(Guid itemType, Guid itemID)
Parameters
Type | Name | Description |
---|---|---|
Guid | itemType | The type of item we want to retrieve user friendly information on |
Guid | itemID | The id of the item we want to retrieve user friendly information on |
Returns
Type | Description |
---|---|
Task<string> | A task holding a string |
Remarks
For example, this function can be used like so:
var (Created, Modified, createdBy, modifiedBy, createdByLabel, modifiedByLabel) =
LemonEdge.API.CustomFunctionsHelper.ParseItemInfo(await entityUpdateContext.GetCustomFunctions.GetItemInfo(typeID, item.ID));
Returns information about that item, where:
- entityUpdateContext: Holds an instance of IEntityUpdater
- typeID: Holds the id of the entity type we want to return information on
- item: Holds an instance of an item from IBaseEntity
See Also
GetLabelItems(Guid, string)
Returns a list of just the id and label of the results of the specified queryexecuter
Declaration
Task<IEnumerable<ILabelIDItem>> GetLabelItems(Guid typeID, string base64SerializedQueryExecuter)
Parameters
Type | Name | Description |
---|---|---|
Guid | typeID | |
string | base64SerializedQueryExecuter |
Returns
Type | Description |
---|---|
Task<IEnumerable<ILabelIDItem>> |
GetLabelItemsCount(Guid, string)
Returns count of the results of the specified queryexecuter
Declaration
Task<int> GetLabelItemsCount(Guid typeID, string base64SerializedQueryExecuter)
Parameters
Type | Name | Description |
---|---|---|
Guid | typeID | |
string | base64SerializedQueryExecuter |
Returns
Type | Description |
---|---|
Task<int> |
GetMatchingDataSources(Guid?, string, bool, Guid?, Guid?, string)
Executes a system function that searches across all datasources (IDataSource) for any matching
datasource with the specified searchID
Declaration
Task<IEnumerable<IDataSourceResult>> GetMatchingDataSources(Guid? canvasID, string searchID, bool matchExactly, Guid? dataSourceTypeID, Guid? entityTypeID, string base64SerializedQueryExecuter)
Parameters
Type | Name | Description |
---|---|---|
Guid? | canvasID | The id of any Canvas you want this query to run in. Null indicates the current main system |
string | searchID | The text you want to search for across all DataSources |
bool | matchExactly | Indicates the |
Guid? | dataSourceTypeID | The search can be restricted to a specific IDataSourceType, or can be run across all data sources by passing null |
Guid? | entityTypeID | The search can be restricted to only running on a particular type, and thus the datasources only associated with that type |
string | base64SerializedQueryExecuter | A QueryableExecuter<T> of type IDataSourceResult with any custom query for further filtering the results |
Returns
Type | Description |
---|---|
Task<IEnumerable<IDataSourceResult>> | A task holding an enumerable list of results detailing all datasources that match the specified search critera |
Remarks
This type of functionality can also be achieved by creating a SQLWrapper that runs your own custom sql process, a type that can hold the results, and calling that using GetSQLResults<T>(Guid, string, string)
GetMatchingDataSourcesCount(Guid?, string, bool, Guid?, Guid?, string)
Executes a system function that searches across all datasources (IDataSource) for any matching
datasource with the specified searchID
and returns the count of matching rows
Declaration
Task<int> GetMatchingDataSourcesCount(Guid? canvasID, string searchID, bool matchExactly, Guid? dataSourceTypeID, Guid? entityTypeID, string base64SerializedQueryExecuter)
Parameters
Type | Name | Description |
---|---|---|
Guid? | canvasID | The id of any Canvas you want this query to run in. Null indicates the current main system |
string | searchID | The text you want to search for across all DataSources |
bool | matchExactly | Indicates the |
Guid? | dataSourceTypeID | The search can be restricted to a specific IDataSourceType, or can be run across all data sources by passing null |
Guid? | entityTypeID | The search can be restricted to only running on a particular type, and thus the datasources only associated with that type |
string | base64SerializedQueryExecuter | A QueryableExecuter<T> of type IDataSourceResult with any custom query for further filtering the results |
Returns
Type | Description |
---|---|
Task<int> | A task holding the count of results detailing all datasources that match the specified search critera |
Remarks
This type of functionality can also be achieved by creating a SQLWrapper that runs your own custom sql process, a type that can hold the results, and calling that using GetSQLResultsCount<T>(Guid, string, string)
GetNextID(Guid, string)
Some integer properties are marked with the EntityAutoIncrementColumnAttribute which indicates whenever new items of this type are created the system should assign a unique auto-incrementing id
This function gets the next id for the specified type and column name. This is only called by the system within a save transaction. You won't see the values assigned to new items until they have been saved and refreshed.
Declaration
Task<long> GetNextID(Guid typeID, string columnName)
Parameters
Type | Name | Description |
---|---|---|
Guid | typeID | The type of item to get a unique next auto increment value for |
string | columnName | The name of the column to get the auto increment value for |
Returns
Type | Description |
---|---|
Task<long> | A task holding the unique new auto-increment value for this type of item |
GetNextUniqueID(string, string, string)
Returns the next id for the specified table/col name.
This is handled automatically by items with properties marked as autoinc, you shouldn't call that for these properties as the system automatically handles it and will increment the count anyway
You can use this for your own custom autop inc property values, that guarantees a unique auto inc number is returned each time,Declaration
Task<long> GetNextUniqueID(string tableName, string columnName, string defaultValue)
Parameters
Type | Name | Description |
---|---|---|
string | tableName | The table name, or key name for the id to return |
string | columnName | The column, or further key info, of the id to return |
string | defaultValue |
Returns
Type | Description |
---|---|
Task<long> |
GetNotificationData(Guid?, Guid?, Guid?, string)
Returns system notifications (INotification) for the current logged in user that have not been dismissed by them
Declaration
Task<IEnumerable<INotification>> GetNotificationData(Guid? canvasID, Guid? typeID, Guid? id, string base64SerializedQueryExecuter)
Parameters
Type | Name | Description |
---|---|---|
Guid? | canvasID | The id of any Canvas you want this query to run in. Null indicates the current main system |
Guid? | typeID | The ID of the entity type you want to run this query against if running against a specific item for notifications relating just to it. Null for all notifiactions. |
Guid? | id | The id of the actual item you want notifications related to. Null for all notifications. |
string | base64SerializedQueryExecuter | A QueryableExecuter<T> of type INotification with any custom query for further filtering the results |
Returns
Type | Description |
---|---|
Task<IEnumerable<INotification>> | A task holding all notifications for this user that have not been dismissed by them that relate to a particualr specified item, or globally |
Remarks
This type of functionality can also be achieved by creating a SQLWrapper that runs your own custom sql process, a type that can hold the results, and calling that using GetSQLResults<T>(Guid, string, string)
GetNotificationDataCount(Guid?, Guid?, Guid?, string)
Returns the count of system notifications (INotification) for the current logged in user that have not been dismissed by them
Declaration
Task<int> GetNotificationDataCount(Guid? canvasID, Guid? typeID, Guid? id, string base64SerializedQueryExecuter)
Parameters
Type | Name | Description |
---|---|---|
Guid? | canvasID | The id of any Canvas you want this query to run in. Null indicates the current main system |
Guid? | typeID | The ID of the entity type you want to run this query against if running against a specific item for notifications relating just to it. Null for all notifiactions. |
Guid? | id | The id of the actual item you want notifications related to. Null for all notifications. |
string | base64SerializedQueryExecuter | A QueryableExecuter<T> of type INotification with any custom query for further filtering the results |
Returns
Type | Description |
---|---|
Task<int> | A task holding the count of all notifications for this user that have not been dismissed by them that relate to a particualr specified item, or globally |
Remarks
This type of functionality can also be achieved by creating a SQLWrapper that runs your own custom sql process, a type that can hold the results, and calling that using GetSQLResultsCount<T>(Guid, string, string)
GetNuGetData(IEnumerable<string>, CancellationToken)
Requests nuget data for a specific add-in
Declaration
Task<IEnumerable<NuGetDependency>> GetNuGetData(IEnumerable<string> names, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<string> | names | The names |
CancellationToken | token | A cancellation token |
Returns
Type | Description |
---|---|
Task<IEnumerable<NuGetDependency>> | A dictionary of dependency names and binary file data |
GetSQLProcInfo(Guid, string)
Returns the schema of the specified sql function or stored procedure in the database.
The function, or stored procedure, must actually exist for this to return anything.
Declaration
Task<IEnumerable<ISQLTypeWrapper>> GetSQLProcInfo(Guid forID, string sqlProcName)
Parameters
Type | Name | Description |
---|---|---|
Guid | forID | The id of the ISQLWrapper this is being generated for |
string | sqlProcName | The name of the stored procedure or function you would like the call to return parameters (and results in the case of a function) for |
Returns
Type | Description |
---|---|
Task<IEnumerable<ISQLTypeWrapper>> | A task holding the schema of the specified sql function or stored procedure in the database |
Remarks
This enables you to create custom sql stored procedures, or functions, and just import them into LemonEdge for use by others, or our various integrated query tools
The ISQLWrapper tool uses this functionality to auto populate the schema of any custom sql you would like to use in the system
GetValidStorageTypes(CancellationToken)
Gets valid storage types from the service
Declaration
Task<IEnumerable<string>> GetValidStorageTypes(CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token |
Returns
Type | Description |
---|---|
Task<IEnumerable<string>> |
IsLicenseValid()
Indicates if the license for the account of the logged in user is valid or not
Declaration
Task<LicenseResult> IsLicenseValid()
Returns
Type | Description |
---|---|
Task<LicenseResult> | True if the license is valid |
PromoteItemsFromCanvas(Guid, Guid, Guid)
Taks the changes that have been made in a canvas from that canvas itself and applies them into the main system
A promotion can only occur if the change in the canvas was made later than any changes to that item in the main system itself
This will promote changes that have been made to related child items too
This method should only be called when running in the main system itself. You can not call this when running in a canvas. This is used by the system when viewing a canvas and the changes within it.
Declaration
Task<bool> PromoteItemsFromCanvas(Guid canvasID, Guid typeID, Guid id)
Parameters
Type | Name | Description |
---|---|---|
Guid | canvasID | The canvas you want to promote a change from |
Guid | typeID | The type of item you want to promote from the canvas |
Guid | id | The id of the item that has been changed in the canvas, and that you want promoted into the main system |
Returns
Type | Description |
---|---|
Task<bool> | A task indicating the successful completion of the operation |
RefreshServers()
Invalidates all local caches on the web and task services forcing them to reload on next requests
Declaration
Task<bool> RefreshServers()
Returns
Type | Description |
---|---|
Task<bool> | A task indicating the successful completion of the operation |
RejectItemsFromCanvas(Guid, Guid, Guid, string)
Reject the specified canvas change for promotion
Declaration
Task<bool> RejectItemsFromCanvas(Guid canvasID, Guid typeID, Guid id, string comment)
Parameters
Type | Name | Description |
---|---|---|
Guid | canvasID | The canvas you want to reject a change from |
Guid | typeID | The type of item you want to reject from the canvas |
Guid | id | The id of the item that has been changed in the canvas, and that you want reject |
string | comment |
Returns
Type | Description |
---|---|
Task<bool> | A task indicating the successful completion of the operation |
RemoveItemsFromCanvas(Guid, Guid, Guid)
Removes changes that have been made in a canvas from that canvas itself, reverting it to the copy of the original main system.
This does not delete the actual item (unless it was only created in the canvas and never existed in the main system), it simply removes the changes to that item that have been made in the canvas
This will remove changes that have been made to related child items too
This method should only be called when running in the main system itself. You can not call this when running in a canvas. This is used by the system when viewing a canvas and the changes within it.
Declaration
Task<bool> RemoveItemsFromCanvas(Guid canvasID, Guid typeID, Guid id)
Parameters
Type | Name | Description |
---|---|---|
Guid | canvasID | The canvas you want to remove a change from |
Guid | typeID | The type of item you want to remove from the canvas |
Guid | id | The id of the item that has been changed in the canvas, and that you wan removed from the canvas |
Returns
Type | Description |
---|---|
Task<bool> | A task indicating the successful completion of the operation |
ResetMyPassword(string, string)
Resets the current users password to a new password. The user does not need read-write permissions to their own user, this can be performed anyway as long as the current password matches
Declaration
Task<bool> ResetMyPassword(string hashedCurrentPassword, string hashedNewPassword)
Parameters
Type | Name | Description |
---|---|---|
string | hashedCurrentPassword | The current password for this user. If this does not not match the operation will fail. |
string | hashedNewPassword | The new password for this user. |
Returns
Type | Description |
---|---|
Task<bool> | A task indicating the successful completion of the operation |
ResetUserPassword(Guid, string)
Resets the specified users password to the new hashed password value
This operation can only be performed by someone with read-write access to the specified user
Declaration
Task<bool> ResetUserPassword(Guid userID, string hashedNewPassword)
Parameters
Type | Name | Description |
---|---|---|
Guid | userID | The user ID to reset the password for the specified user to |
string | hashedNewPassword | The new hashed password for the specified user |
Returns
Type | Description |
---|---|
Task<bool> | A task indicating the successful completion of the operation |
RestartAllServices()
Forces a restart of all web and task services, including this one
Declaration
Task<bool> RestartAllServices()
Returns
Type | Description |
---|---|
Task<bool> |
RunInCanvas(Guid?)
Updates the current canvas for the currently logged in user to the specified canvasID
. Null
indicates running in the main system.
Declaration
Task<bool> RunInCanvas(Guid? canvasID)
Parameters
Type | Name | Description |
---|---|---|
Guid? | canvasID | A canvas that the current logged in user can access, or null to indicate running in the main system again withut a canvas. |
Returns
Type | Description |
---|---|
Task<bool> | A task indicating if the operation was successful |
Remarks
This can only be a canvas that is private to them or public. Is used by the system when users simply switch canvases.
This process works even if the user doesn't have permissions to update their user, as it should always be allowed for them to switch to valid canvases
RunInSafe(Guid?)
Updates the current safe for the currently logged in user to the specified safeID
. Null
indicates running in the main system.
Declaration
Task<bool> RunInSafe(Guid? safeID)
Parameters
Type | Name | Description |
---|---|---|
Guid? | safeID | A safe that the current logged in user can access, or null to indicate running in the main system again withut a canvas. |
Returns
Type | Description |
---|---|
Task<bool> | A task indicating if the operation was successful |
SearchPackagesAsync(string, CancellationToken)
Searches the package sources for those matching the given filter, excluding any unwanted feeds, returning up to 10 results.
Declaration
Task<IEnumerable<IPackage>> SearchPackagesAsync(string filter, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
string | filter | The filter string |
CancellationToken | token | A cancellation token |
Returns
Type | Description |
---|---|
Task<IEnumerable<IPackage>> |
UpdateCurrentDefaultTeam(Guid)
Updates the current team for the currently logged in user to the specified teamID
Declaration
Task<bool> UpdateCurrentDefaultTeam(Guid teamID)
Parameters
Type | Name | Description |
---|---|---|
Guid | teamID | A team that the current logged in user is a member of |
Returns
Type | Description |
---|---|
Task<bool> | A task indicating if the operation was successful |
Remarks
This can only be a team they are a valid member of. Is used by the system when users simply switch teams.
This process works even if the user doesn't have permissions to update their user, as it should always be allowed for them to switch to valid teams they are members of
UpdateCurrentRole(Guid)
Updates the current role for the currently logged in user to the specified roleID
Declaration
Task<bool> UpdateCurrentRole(Guid roleID)
Parameters
Type | Name | Description |
---|---|---|
Guid | roleID | A role that the current logged in user is a member of |
Returns
Type | Description |
---|---|
Task<bool> | A task indicating if the operation was successful |
Remarks
This can only be a role they are a valid member of. Is used by the system when users simply switch roles.
This process works even if the user doesn't have permissions to update their user, as it should always be allowed for them to switch to valid roles they are members of
UpdateCurrentTheme(short)
Updates the current role for the currently logged in user to the specified roleID
Declaration
Task<bool> UpdateCurrentTheme(short theme)
Parameters
Type | Name | Description |
---|---|---|
short | theme |
Returns
Type | Description |
---|---|
Task<bool> | A task indicating if the operation was successful |
Remarks
This can only be a role they are a valid member of. Is used by the system when users simply switch roles.
This process works even if the user doesn't have permissions to update their user, as it should always be allowed for them to switch to valid roles they are members of
UpdateUserSettings(string, string, Theme)
Updates the current users name
, emailLogin
and theme
Declaration
Task<bool> UpdateUserSettings(string name, string emailLogin, Theme theme)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of this user |
string | emailLogin | The globally unique email address used for them to logon to the system |
Theme | theme | The colour theme the applications use |
Returns
Type | Description |
---|---|
Task<bool> | A task indicating the successful completion of the operation |