Class DataUpdater
EntityContext saves the changes/etc of everything it is passed "as is" Data Updater is responsible for taking inserts/updates/deletes/transatcions/etc and applying any custom process work, then sending to EntityContext in save order already.
Implements
Inherited Members
Namespace: LemonEdge.Connections.Database
Assembly: LemonEdge.Database.Connector.dll
Syntax
public class DataUpdater : EntityContext, ICustomServiceQueryHelper, ICustomFunctions, ICustomUpgradeVersionHandler, IDataUpdater, IEntityUpdater, IEntityRetriever, IDisposable, IAsyncDisposable, ICanvasItemAction, ISaveContextPrior, ISaveContextAfter, ISaveContext
Constructors
DataUpdater(UserInfo, IDataAccessor, IEntityCreator, IApplicationDbContextFactory, IDataSetProcessorFactory, IDatabaseCacheFactory, IDatabaseConnectorServiceContext, ISaveExtenderRepository, IStorageServiceFactory, IOptions<TaskServiceSettings>, INuGetPackageManager, IEntityContextFactory)
Declaration
public DataUpdater(UserInfo user, IDataAccessor accessor, IEntityCreator entityCreator, IApplicationDbContextFactory dbContextFactory, IDataSetProcessorFactory dataSetProcessorFactory, IDatabaseCacheFactory cacheFactory, IDatabaseConnectorServiceContext dbConnectorServices, ISaveExtenderRepository saveExtenderRepository, IStorageServiceFactory storageServiceFactory, IOptions<TaskServiceSettings> taskServiceSettings, INuGetPackageManager nuGetPackageManager, IEntityContextFactory entityContext)
Parameters
Type | Name | Description |
---|---|---|
UserInfo | user | |
IDataAccessor | accessor | |
IEntityCreator | entityCreator | |
IApplicationDbContextFactory | dbContextFactory | |
IDataSetProcessorFactory | dataSetProcessorFactory | |
IDatabaseCacheFactory | cacheFactory | |
IDatabaseConnectorServiceContext | dbConnectorServices | |
ISaveExtenderRepository | saveExtenderRepository | |
IStorageServiceFactory | storageServiceFactory | |
IOptions<TaskServiceSettings> | taskServiceSettings | |
INuGetPackageManager | nuGetPackageManager | |
IEntityContextFactory | entityContext |
Properties
ClientCache
Declaration
public virtual IReadOnlyCache ClientCache { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCache |
EntityCreator
The IEntityCreator for creating new entities.
Declaration
public IEntityCreator EntityCreator { get; }
Property Value
Type | Description |
---|---|
IEntityCreator |
GetCustomFunctions
Returns a set of custom functions that can be run against this context taking into account any current changes it may have
Declaration
public ICustomFunctions GetCustomFunctions { get; }
Property Value
Type | Description |
---|---|
ICustomFunctions |
HasChanges
Declaration
public override bool HasChanges { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
IgnoreProcessorsOnSave
Declaration
public bool IgnoreProcessorsOnSave { get; set; }
Property Value
Type | Description |
---|---|
bool |
IsSaving
Indicates the context is currently busy processing a Save operation and can not be queried or commit another Save at the same time
Declaration
public bool IsSaving { get; }
Property Value
Type | Description |
---|---|
bool |
Processors
An enumeration of all processors that are active with this context. Those inheriting from IBaseDataSetProcessorWithDBSave will be called as part of the save process
Declaration
public IEnumerable<IBaseDataSetProcessor> Processors { get; }
Property Value
Type | Description |
---|---|
IEnumerable<IBaseDataSetProcessor> |
SaveCompleted
Details whether the save completed successfully or not
Declaration
public bool SaveCompleted { get; }
Property Value
Type | Description |
---|---|
bool |
SaveError
If an error occurs during a save process, the exception will be stored in this property
Declaration
public Exception SaveError { get; }
Property Value
Type | Description |
---|---|
Exception |
Methods
AddNewItem(Type)
Creates a new IBaseEntity of the provided that will be added to the current context.
Declaration
public Task<IBaseEntity> AddNewItem(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type |
Returns
Type | Description |
---|---|
Task<IBaseEntity> |
AddNewItem<T>()
Creates a new IBaseEntity of type T that will be added to the current context.
Declaration
public Task<T> AddNewItem<T>() where T : IBaseEntity
Returns
Type | Description |
---|---|
Task<T> |
Type Parameters
Name | Description |
---|---|
T |
AddPendingExistingExtendedItem(IBaseEntity, Guid)
Adds the specified pending item (that exists but could be updated) to a pending list on the context. Any changes mean the item is removed from pending and automatically added to logchange. This is used for extended items in views, those items are created but a change isn't logged for new items unless a user makes a propertty change. Also this ensures the same loaded item is used across multiple possible views of it. This also returns the actual pending instance to use for that extended item id incase another thread/view has already added one to use first
Declaration
public IBaseEntity AddPendingExistingExtendedItem(IBaseEntity pendingItem, Guid extendedItemID)
Parameters
Type | Name | Description |
---|---|---|
IBaseEntity | pendingItem | The pending item to add to the context to be logged as a change if any property changes |
Guid | extendedItemID | The parent id of the type the item is extending |
Returns
Type | Description |
---|---|
IBaseEntity |
AddPendingExtendedItem(IBaseEntity, Guid)
Adds the specified pending item (that is newly created) to a pending list on the context. Any changes mean the item is removed from pending and automatically added to logchange. This is used for extended items in views, those items are created but a change isn't logged for new items unless a user makes a propertty change This also returns the actual new pending instance to use for that extended item id incase another thread/view has already added one to use first
Declaration
public IBaseEntity AddPendingExtendedItem(IBaseEntity pendingItem, Guid extendedItemID)
Parameters
Type | Name | Description |
---|---|---|
IBaseEntity | pendingItem | The pending item to add to the context to be logged as a change if any property changes |
Guid | extendedItemID | The parent id of the type the item is extending |
Returns
Type | Description |
---|---|
IBaseEntity |
AllowsCLRSQLFunctions()
Returns true if the database is configured to allow custom .net framework clr functions to be loaded as assemblies
Declaration
public 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 |
AppendCustomSqlScriptToSave(string)
Declaration
public void AppendCustomSqlScriptToSave(string script)
Parameters
Type | Name | Description |
---|---|---|
string | script |
ApproveItemsFromCanvas(ICanvas, Guid, Guid[])
Declaration
public Task<bool> ApproveItemsFromCanvas(ICanvas canvas, Guid typeID, Guid[] ids)
Parameters
Type | Name | Description |
---|---|---|
ICanvas | canvas | |
Guid | typeID | |
Guid[] | ids |
Returns
Type | Description |
---|---|
Task<bool> |
ApproveItemsFromCanvas(Guid, Guid, Guid)
Approves the specified canvas change for promotion
Declaration
public 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 |
ClearCachedTypes(long, IEnumerable<Type>)
Declaration
protected virtual Task ClearCachedTypes(long accountID, IEnumerable<Type> types)
Parameters
Type | Name | Description |
---|---|---|
long | accountID | |
IEnumerable<Type> | types |
Returns
Type | Description |
---|---|
Task |
ClearChange(IBaseEntity)
Clears log in this context that the specified item
has pending changes to be saved
Declaration
public void ClearChange(IBaseEntity item)
Parameters
Type | Name | Description |
---|---|---|
IBaseEntity | item | The item to clear from the log in this context that it has pending changes |
ClearChanges()
Declaration
public override void ClearChanges()
Overrides
ClearItem(Guid, Guid, Guid, bool, bool)
Clears an item from the canvas.
Declaration
public 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 | |
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 |
CreateNew()
Creates a new entityupdater in the same way this one was created
Declaration
public virtual Task<IEntityUpdater> CreateNew()
Returns
Type | Description |
---|---|
Task<IEntityUpdater> |
CreateProcessor(ServerTaskAttribute)
Creates the task processor ITaskProcessor for the specified ServerTaskAttribute. If the task processor inherits from API.Processors.IBaseDataSetProcessor, it is added to the processor collection for this updater and will be run as part of the save process if it inherits IBaseDataSetProcessorWithDBSave
Declaration
public ITaskProcessor CreateProcessor(ServerTaskAttribute forTaskType)
Parameters
Type | Name | Description |
---|---|---|
ServerTaskAttribute | forTaskType | Returns the ITaskProcessor associated with the specified
|
Returns
Type | Description |
---|---|
ITaskProcessor | The task processor ITaskProcessor for the specified ServerTaskAttribute. |
Dispose(bool)
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing |
Overrides
DoesUserExist(string, Guid)
Indicates if the specified emailID
already exists as a user in the system
Declaration
public 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 |
ExecuteQuery(QueryableExecuter)
Takes a QueryableExecuter and executes the query against the database (possibly via a web service) and returns the results
If this context contains any changes of the query entity type then those changes won't be overwritten by the results, they will be included if they match the QueryableExecuter filter
Declaration
public override Task<IEnumerable<IBaseEntity>> ExecuteQuery(QueryableExecuter items)
Parameters
Type | Name | Description |
---|---|---|
QueryableExecuter | items | The queryable executer containing the definition of the query to execute. Can be created from GetItems(Type) |
Returns
Type | Description |
---|---|
Task<IEnumerable<IBaseEntity>> | A task holding the result set of the query as an enumeration |
Overrides
GetAccountGlobalSystemValue<T>(string, T)
Returns the value of the specified key for the whole database
Declaration
public Task<T> GetAccountGlobalSystemValue<T>(string key, T defaultValue)
Parameters
Type | Name | Description |
---|---|---|
string | key | The unique key of the value to return. Typically the name of a custom AddIn module for custom upgrade processes. |
T | defaultValue | The default value to return if there is no value currently |
Returns
Type | Description |
---|---|
Task<T> | A task holding the result of the specified setting in the database |
Type Parameters
Name | Description |
---|---|
T | The type of value to return. Typically an int if dealing with incrementing version numbers. |
GetAllChanges()
Returns all current changes in the context
Declaration
public (List<IBaseEntity> NewItems, List<IBaseEntity> UpdatedItems, List<IBaseEntity> DeletedItems) GetAllChanges()
Returns
Type | Description |
---|---|
(List<IBaseEntity> NewItems, List<IBaseEntity> UpdatedItems, List<IBaseEntity> DeletedItems) |
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
public 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
public 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
public 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 |
GetChange(IBaseEntity)
Returns the type of change this context currently is recording against the specified item
Declaration
public EntityOperation GetChange(IBaseEntity item)
Parameters
Type | Name | Description |
---|---|---|
IBaseEntity | item | The item this context has a change recorded for |
Returns
Type | Description |
---|---|
EntityOperation | The type of change this context currently is recording against the specified |
GetChangedItem(Type, Guid)
Declaration
protected override IBaseEntity GetChangedItem(Type t, Guid id)
Parameters
Type | Name | Description |
---|---|---|
Type | t | |
Guid | id |
Returns
Type | Description |
---|---|
IBaseEntity |
Overrides
GetChanges(EntityOperation, Type)
Returns an enumeration of all current changes of a particular change type
and for am optional
specified type of item (changeType
)
Declaration
public IEnumerable<IBaseEntity> GetChanges(EntityOperation ofType, Type itemType = null)
Parameters
Type | Name | Description |
---|---|---|
EntityOperation | ofType | |
Type | itemType |
Returns
Type | Description |
---|---|
IEnumerable<IBaseEntity> | An enumeration of all current changes of a particular change |
GetChanges<T>(EntityOperation, Func<T, bool>)
Returns an enumeration of all current changes of a particular type (either the interface or class type works) held in the context.
This allows you to specify the type
of change and an optional filter for the changes
Declaration
public IEnumerable<T> GetChanges<T>(EntityOperation ofType, Func<T, bool> filter = null) where T : IBaseEntity
Parameters
Type | Name | Description |
---|---|---|
EntityOperation | ofType | |
Func<T, bool> | filter | An optional filter which will filter the changes returned |
Returns
Type | Description |
---|---|
IEnumerable<T> | An enumeration of all current changes of a particular type (either the interface or class type works) held in the context. |
Type Parameters
Name | Description |
---|---|
T | The type of items you want to see any current changes for. This can be an interface or class type. |
GetChanges<T>(Func<T, bool>)
Returns an enumeration of all current changes of a particular type T (either the interface or class type works) along with the associated change type, held in the context
Declaration
public IEnumerable<(EntityOperation Type, T Item)> GetChanges<T>(Func<T, bool> filter = null) where T : IBaseEntity
Parameters
Type | Name | Description |
---|---|---|
Func<T, bool> | filter | An optional filter which will filter the changes returned |
Returns
Type | Description |
---|---|
IEnumerable<(EntityOperation Type, T Item)> | An enumeration of all current changes of a particular type T (either the interface or class type works) along with the associated change type, held in the context |
Type Parameters
Name | Description |
---|---|
T | The type of items you want to see any current changes for. This can be an interface or class type. |
GetCurrentDBTime()
Returns the current database time from the database server
Declaration
public 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
public Task<IEnumerable<UserInfo>> GetCurrentLoggedInUser()
Returns
Type | Description |
---|---|
Task<IEnumerable<UserInfo>> |
GetDefaultNewUpdater()
Declaration
protected Task<IEntityUpdater> GetDefaultNewUpdater()
Returns
Type | Description |
---|---|
Task<IEntityUpdater> |
GetDefaultProcessor(IBaseEntity)
Returns the default processor for the specified forItem
.
If the item is a member of an existing instance of the processor already that instance is returned by the context. If it is not then a new processor is created, the item added to it, and the processor returned
Declaration
public IBaseDataSetProcessor GetDefaultProcessor(IBaseEntity forItem)
Parameters
Type | Name | Description |
---|---|---|
IBaseEntity | forItem | The item that the system finds the default processor for |
Returns
Type | Description |
---|---|
IBaseDataSetProcessor | The default processor for the specified |
GetFromDocumentStorage(IEnumerable<Guid>)
Returns the specified document from the configured IDocumentStorage.
Declaration
public 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 |
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
public 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
GetItems(EntityOperation)
Returns all IBaseEntity stored against the context via the given EntityOperation
Declaration
public IEnumerable<IBaseEntity> GetItems(EntityOperation operation)
Parameters
Type | Name | Description |
---|---|---|
EntityOperation | operation |
Returns
Type | Description |
---|---|
IEnumerable<IBaseEntity> |
GetItems(EntityOperation, Type)
Returns all IBaseEntity stored against the context via the given EntityOperation and of the provided type
Declaration
public IEnumerable<IBaseEntity> GetItems(EntityOperation operation, Type type)
Parameters
Type | Name | Description |
---|---|---|
EntityOperation | operation | |
Type | type |
Returns
Type | Description |
---|---|
IEnumerable<IBaseEntity> |
GetItems<T>(EntityOperation)
Returns all entities stored against the context via the given EntityOperation and of the type T
Declaration
public IEnumerable<T> GetItems<T>(EntityOperation operation) where T : IBaseEntity
Parameters
Type | Name | Description |
---|---|---|
EntityOperation | operation |
Returns
Type | Description |
---|---|
IEnumerable<T> |
Type Parameters
Name | Description |
---|---|
T |
GetLabelItems(Guid, string)
Returns a list of just the id and label of the results of the specified queryexecuter
Declaration
public 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
public Task<int> GetLabelItemsCount(Guid typeID, string base64SerializedQueryExecuter)
Parameters
Type | Name | Description |
---|---|---|
Guid | typeID | |
string | base64SerializedQueryExecuter |
Returns
Type | Description |
---|---|
Task<int> |
GetLabelItemsCountGeneric<T>(Guid, string)
Declaration
public Task<int> GetLabelItemsCountGeneric<T>(Guid typeID, string base64SerializedQueryExecuter) where T : IBaseEntity
Parameters
Type | Name | Description |
---|---|---|
Guid | typeID | |
string | base64SerializedQueryExecuter |
Returns
Type | Description |
---|---|
Task<int> |
Type Parameters
Name | Description |
---|---|
T |
GetLabelItemsGeneric<T>(Guid, string)
Declaration
public Task<IEnumerable<ILabelIDItem>> GetLabelItemsGeneric<T>(Guid typeID, string base64SerializedQueryExecuter) where T : IBaseEntity
Parameters
Type | Name | Description |
---|---|---|
Guid | typeID | |
string | base64SerializedQueryExecuter |
Returns
Type | Description |
---|---|
Task<IEnumerable<ILabelIDItem>> |
Type Parameters
Name | Description |
---|---|
T |
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
public 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
public 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)
GetModifiedItems(EntityOperation)
Returns all IBaseEntity, including subitems etc, stored against the context via the given EntityOperation
Declaration
public IEnumerable<IBaseEntity> GetModifiedItems(EntityOperation operation)
Parameters
Type | Name | Description |
---|---|---|
EntityOperation | operation |
Returns
Type | Description |
---|---|
IEnumerable<IBaseEntity> |
GetModifiedItems(EntityOperation, Type)
Returns all IBaseEntity, including subitems etc, stored against the context via the given EntityOperation and of the provided type
Declaration
public IEnumerable<IBaseEntity> GetModifiedItems(EntityOperation operation, Type type)
Parameters
Type | Name | Description |
---|---|---|
EntityOperation | operation | |
Type | type |
Returns
Type | Description |
---|---|
IEnumerable<IBaseEntity> |
GetModifiedItems<T>(EntityOperation)
Returns all entities, including subitems etc, stored against the context via the given EntityOperation and of the type T
Declaration
public IEnumerable<T> GetModifiedItems<T>(EntityOperation operation) where T : IBaseEntity
Parameters
Type | Name | Description |
---|---|---|
EntityOperation | operation |
Returns
Type | Description |
---|---|
IEnumerable<T> |
Type Parameters
Name | Description |
---|---|
T |
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
public 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
public 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
public 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
public 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
public 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 |
GetOrAddPendedExtendedItem(EntityDescriptor, Guid)
Retrieves the specified pending item that has been previously added, or creates a new one, adds that, and returns it.
Declaration
public Task<(IBaseEntity Item, EntityOperation Operation)> GetOrAddPendedExtendedItem(EntityDescriptor extendedType, Guid extendedItemID)
Parameters
Type | Name | Description |
---|---|---|
EntityDescriptor | extendedType | The descriptor for the extended item type |
Guid | extendedItemID | The id of the item with the extended type |
Returns
Type | Description |
---|---|
Task<(IBaseEntity Item, EntityOperation Operation)> |
GetProcessor<T>(IBaseEntity)
Returns the processor of type T for the specified forItem
.
If the item is a member of an existing instance of the processor already that instance is returned by the context if it is of the correct type. If it is not then a new processor is created, the item added to it, and the processor returned
Declaration
public T GetProcessor<T>(IBaseEntity forItem) where T : IBaseDataSetProcessor
Parameters
Type | Name | Description |
---|---|---|
IBaseEntity | forItem | The item that the system finds the default processor for |
Returns
Type | Description |
---|---|
T | The processor of type T for the specified |
Type Parameters
Name | Description |
---|---|
T | Forces to return this processor type, even if it is not standard processor for this object |
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
public 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
public Task<IEnumerable<string>> GetValidStorageTypes(CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token |
Returns
Type | Description |
---|---|
Task<IEnumerable<string>> |
HasChange(IBaseEntity)
Indicates if the specified item
is currently marked as having changes associated with it in
this context
Declaration
public bool HasChange(IBaseEntity item)
Parameters
Type | Name | Description |
---|---|---|
IBaseEntity | item | The item to check if it has been marked as changed in this context |
Returns
Type | Description |
---|---|
bool | True if the specified |
HasChange(Type, Guid)
Indicates if the specified item (via its unique type
and id
) is currently
marked as having changes associated with it in this context
Declaration
public bool HasChange(Type type, Guid id)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type of item to find and check if it has been marked as changed in this context |
Guid | id | The id of the item to find and check if it has been marked as changed in this context |
Returns
Type | Description |
---|---|
bool | True if the specified item (found through its unique |
IsLicenseValid()
Indicates if the license for the account of the logged in user is valid or not
Declaration
public Task<LicenseResult> IsLicenseValid()
Returns
Type | Description |
---|---|
Task<LicenseResult> | True if the license is valid |
LogChange(IBaseEntity, EntityOperation)
Logs in this context that the specified item has been changed along with in what way it has been changed (Inserted, Updated or Deleted)
Declaration
public void LogChange(IBaseEntity item, EntityOperation op)
Parameters
Type | Name | Description |
---|---|---|
IBaseEntity | item | The actual item that has changes to be logged in this context |
EntityOperation | op | The type of change recorded against this |
MergeResults(QueryableExecuter, IEnumerable<IBaseEntity>)
Declaration
public IEnumerable<IBaseEntity> MergeResults(QueryableExecuter executer, IEnumerable<IBaseEntity> items)
Parameters
Type | Name | Description |
---|---|---|
QueryableExecuter | executer | |
IEnumerable<IBaseEntity> | items |
Returns
Type | Description |
---|---|
IEnumerable<IBaseEntity> |
MergeResults(QueryableExecuter, List<IBaseEntity>, List<IBaseEntity>, List<IBaseEntity>, IQueryable<IBaseEntity>, IEnumerable<IBaseEntity>)
Declaration
public IEnumerable<IBaseEntity> MergeResults(QueryableExecuter executer, List<IBaseEntity> newItems, List<IBaseEntity> updatedItems, List<IBaseEntity> deletedItems, IQueryable<IBaseEntity> localItems, IEnumerable<IBaseEntity> items)
Parameters
Type | Name | Description |
---|---|---|
QueryableExecuter | executer | |
List<IBaseEntity> | newItems | |
List<IBaseEntity> | updatedItems | |
List<IBaseEntity> | deletedItems | |
IQueryable<IBaseEntity> | localItems | |
IEnumerable<IBaseEntity> | items |
Returns
Type | Description |
---|---|
IEnumerable<IBaseEntity> |
OnSaveComplete()
Declaration
public override Task OnSaveComplete()
Returns
Type | Description |
---|---|
Task |
Overrides
PromoteItemsFromCanvas(ICanvas, Guid, Guid[], bool)
Declaration
public Task<bool> PromoteItemsFromCanvas(ICanvas canvas, Guid typeID, Guid[] ids, bool saveChanges)
Parameters
Type | Name | Description |
---|---|---|
ICanvas | canvas | |
Guid | typeID | |
Guid[] | ids | |
bool | saveChanges |
Returns
Type | Description |
---|---|
Task<bool> |
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
public 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
public 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
public 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(ICanvas, Guid, Guid[], bool)
Declaration
public Task<bool> RemoveItemsFromCanvas(ICanvas canvas, Guid typeID, Guid[] ids, bool saveChanges)
Parameters
Type | Name | Description |
---|---|---|
ICanvas | canvas | |
Guid | typeID | |
Guid[] | ids | |
bool | saveChanges |
Returns
Type | Description |
---|---|
Task<bool> |
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
public 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
public 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 |
ResetSystemRoles(BusyProgressReporter)
Declaration
public Task<bool> ResetSystemRoles(BusyProgressReporter reporter)
Parameters
Type | Name | Description |
---|---|---|
BusyProgressReporter | reporter |
Returns
Type | Description |
---|---|
Task<bool> |
ResetSystemRoles(BusyProgressReporter, Guid, string, string)
Declaration
public Task<bool> ResetSystemRoles(BusyProgressReporter reporter, Guid accountID, string resetAdminName, string resetAdminPassword)
Parameters
Type | Name | Description |
---|---|---|
BusyProgressReporter | reporter | |
Guid | accountID | |
string | resetAdminName | |
string | resetAdminPassword |
Returns
Type | Description |
---|---|
Task<bool> |
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
public 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
public 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
public 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
public 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 |
RunProcessorsForSave(List<IBaseDataSetProcessorWithDBSave>)
Declaration
public Task<IEnumerable<IHasSaveProcessingTask>> RunProcessorsForSave(List<IBaseDataSetProcessorWithDBSave> saveProcessors)
Parameters
Type | Name | Description |
---|---|---|
List<IBaseDataSetProcessorWithDBSave> | saveProcessors |
Returns
Type | Description |
---|---|
Task<IEnumerable<IHasSaveProcessingTask>> |
SaveChanges(CancellationToken, bool, bool, DbTransaction, bool)
Commits all pending changed logged against this context as one batch transaction to the database.
This first collects all changes and runs any custom processes that in turn may create new changes, such as cascade deletes or transactional logic
Next all changes are validated including running your custom validations (certain database validations are only performed on the services)
Finally all changes are verified for permissions, audited and committed as one transaction
If any failures are encountered that are reported back and the whole transaction fails to save any changes
Declaration
public Task<(IEnumerable<IHasSaveProcessingTask> createdTasks, IEnumerable<Guid> newTaskIDs)> SaveChanges(CancellationToken cancel = default, bool bypassValidation = false, bool bypassProcessors = false, DbTransaction transaction = null, bool validateDeleteOnImport = false)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancel | A cancellation token allowing the save process to be cancelled |
bool | bypassValidation | Indicates the validation should be bypassed if you know the data conforms to the validation rules. Such as if the system has created the changes. Only works directly connected to the database. |
bool | bypassProcessors | |
DbTransaction | transaction | Runs the save process in the specified existing transaction |
bool | validateDeleteOnImport | Indicates the validation should not bypass validation rules on importing delete item. Only works directly connected to the database. |
Returns
Type | Description |
---|---|
Task<(IEnumerable<IHasSaveProcessingTask> createdTasks, IEnumerable<Guid> newTaskIDs)> | A task indicating the completion of the save along with an enumeration of all items that were created during the save that have a task processing on the server associated with them |
SaveChangesForCanvasPromotion(CancellationToken, bool, DbTransaction)
Declaration
public Task SaveChangesForCanvasPromotion(CancellationToken cancel = default, bool bypassValidation = false, DbTransaction transaction = null)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancel | |
bool | bypassValidation | |
DbTransaction | transaction |
Returns
Type | Description |
---|---|
Task |
SearchPackagesAsync(string, CancellationToken)
Searches the package sources for those matching the given filter, excluding any unwanted feeds, returning up to 10 results.
Declaration
public 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>> |
SetAccountGlobalSystemValue<T>(string, T)
Sets the new value of the specified key for the whole database
Declaration
public Task SetAccountGlobalSystemValue<T>(string key, T value)
Parameters
Type | Name | Description |
---|---|---|
string | key | The unique key of the value to update. Typically the name of a custom AddIn module for custom upgrade processes. |
T | value | The new value to set the database setting too |
Returns
Type | Description |
---|---|
Task | A task representing the completion of the operation |
Type Parameters
Name | Description |
---|---|
T | The type of value to update. Typically an int if dealing with incrementing version numbers. |
SetNewCreator(Func<Task<IEntityUpdater>>)
Declaration
public void SetNewCreator(Func<Task<IEntityUpdater>> newCreator)
Parameters
Type | Name | Description |
---|---|---|
Func<Task<IEntityUpdater>> | newCreator |
SetUpgradingGlobalSystemValue(string, bool)
Declaration
public Task<short> SetUpgradingGlobalSystemValue(string key, bool reset)
Parameters
Type | Name | Description |
---|---|---|
string | key | |
bool | reset |
Returns
Type | Description |
---|---|
Task<short> |
TryGetChange(Type, Guid, out EntityOperation, out IBaseEntity)
Returns the change type and item for a specified entityType
and id
if it
exists in the set of changes in this context
Declaration
public bool TryGetChange(Type entityType, Guid id, out EntityOperation Type, out IBaseEntity Item)
Parameters
Type | Name | Description |
---|---|---|
Type | entityType | The type of entity we want to see if this context holds any changes for |
Guid | id | The id f the specific entity we want to find the changes for |
EntityOperation | Type | If the specified item of type |
IBaseEntity | Item | If the specified item of type |
Returns
Type | Description |
---|---|
bool | True if the specified item of type |
UpdateAllPermissions(bool)
Declaration
public Task UpdateAllPermissions(bool addChangesToSet)
Parameters
Type | Name | Description |
---|---|---|
bool | addChangesToSet |
Returns
Type | Description |
---|---|
Task |
UpdateCurrentDefaultTeam(Guid)
Updates the current team for the currently logged in user to the specified teamID
Declaration
public 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
public 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
public 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
UpdateItemProperty(IBaseEntity, string, object)
Updates the property of the item and all inherited items to the specified value for entities undergoing an Insert or Update operation. Delete operations will be ignored
Declaration
public void UpdateItemProperty(IBaseEntity item, string propertyName, object value)
Parameters
Type | Name | Description |
---|---|---|
IBaseEntity | item | The IBaseEntity entity to update |
string | propertyName | The property name as a string |
object | value | The value to assign to the property |
UpdateUserSettings(string, string, Theme)
Updates the current users name
, emailLogin
and theme
Declaration
public 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 |