Class ServerTaskFactory
The factory for retrieving an ITaskProcessor, ServerTaskParameter, or ITaskResultHandler, or their associated attributes to process and handle tasks (IServerTask)
See https://web.lemonedge.com/help/server-tasks/ for more information
Any task requires the following:- ServerTaskParameter: An optional parameters implementation holding the parameters for the task. Must be marked with the ServerTaskParametersAttribute if the associated ITaskProcessor is not accessible to the client.
- ITaskProcessor: The actual implementation of the task process itself. Marked with a ServerTaskAttribute describing it and linking to its associated ServerTaskParameter (if any).
- ServerTaskResult: An optional results implementation (marked with ServerTaskResultAttribute) for storing the results of the task for client viewing/loading/etc.
Inheritance
Inherited Members
Namespace: LemonEdge.API.Tasks
Assembly: API.dll
Syntax
public static class ServerTaskFactory
Methods
CanOnlyRunOnServer(Guid)
Indicates if the specified task type can only be processed on the server and can not run locally to a client
To be runnable on a client, the client needs the ITaskProcessor marked with the ServerTaskAttribute.
If we just have the parameters and the ServerTaskParametersAttribute then we can create the parameters but the task has no choice but to be processed on a serviceDeclaration
public static bool CanOnlyRunOnServer(Guid forTaskID)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | forTaskID | The globally unique id of this task type UniqueTaskID |
Returns
Type | Description |
---|---|
System.Boolean | If the specified task type can only be processed on the server and can not run locally to a client |
CreateTaskProcessor(ServerTaskAttribute)
Creates an instance of the Task Processor for the specified task type (UniqueTaskID)
Declaration
public static ITaskProcessor CreateTaskProcessor(ServerTaskAttribute forTaskType)
Parameters
Type | Name | Description |
---|---|---|
ServerTaskAttribute | forTaskType | The type of task to retrieve its associated task processor for |
Returns
Type | Description |
---|---|
ITaskProcessor | An instance of the Task Processor for the specified task type (UniqueTaskID) |
CreateTaskResultHandler(ServerTaskResultAttribute)
Creates an instance of the result handler for the specified task type
Declaration
public static ITaskResultHandler CreateTaskResultHandler(ServerTaskResultAttribute forTaskType)
Parameters
Type | Name | Description |
---|---|---|
ServerTaskResultAttribute | forTaskType | The attribute (either associated with the server or client handler) defining the ITaskResultHandler implementation to use |
Returns
Type | Description |
---|---|
ITaskResultHandler | An instance of the result handler for the specified task type |
CreateTaskResultHandler(Guid, ServerTaskResultType)
Creates an instance of the result handler for the specified task type
Declaration
public static ITaskResultHandler CreateTaskResultHandler(Guid forTaskID, ServerTaskResultType type)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | forTaskID | The globally unique id of this task type UniqueTaskID |
ServerTaskResultType | type | The type of handler required - either for the server or client |
Returns
Type | Description |
---|---|
ITaskResultHandler | An instance of the result handler for the specified task type |
GetDefaultSaveParameters(IHasSaveProcessingTask, IEntityUpdater)
If the specified forItem
has a current SavedTaskParam then it returns that as the current ServerTaskParameter
Otherwise it gets the default ServerTaskParameter from the ServerTaskParametersAttribute for this item type (definied with DefaultForHasSaveProcessingTask)
Declaration
public static ServerTaskParameter GetDefaultSaveParameters(IHasSaveProcessingTask forItem, IEntityUpdater context)
Parameters
Type | Name | Description |
---|---|---|
IHasSaveProcessingTask | forItem | The item to return its parameters (SavedTaskParam) or default parameter instances for |
IEntityUpdater | context | The context for querying and updating all data in the platform |
Returns
Type | Description |
---|---|
ServerTaskParameter | The specified items parameters (SavedTaskParam) or default parameter instance |
GetDefaultSaveParameters(ServerTaskParametersAttribute, IBaseEntity, IEntityUpdater)
Returns an instance of the default ServerTaskParameter from the specified attr
Declaration
public static ServerTaskParameter GetDefaultSaveParameters(ServerTaskParametersAttribute attr, IBaseEntity forItem, IEntityUpdater context)
Parameters
Type | Name | Description |
---|---|---|
ServerTaskParametersAttribute | attr | The attribute specifying the ParameterType to create an instance of |
IBaseEntity | forItem | The optional item to use when creating the default parameter for |
IEntityUpdater | context | A context for use when creating the default parameters |
Returns
Type | Description |
---|---|
ServerTaskParameter | An instance of the default ServerTaskParameter from the specified |
GetSaveServerTask(IHasSaveProcessingTask)
Retrieves the attribute specifying information on the default (DefaultForHasSaveProcessingTask) parameters for the task the specified item can automatically create
Declaration
public static ServerTaskParametersAttribute GetSaveServerTask(IHasSaveProcessingTask forItem)
Parameters
Type | Name | Description |
---|---|---|
IHasSaveProcessingTask | forItem | The item to retrieve the server task parameters attribute for |
Returns
Type | Description |
---|---|
ServerTaskParametersAttribute | The attribute specifying information on the default (DefaultForHasSaveProcessingTask) parameters for the task the specified item can automatically create |
GetSaveServerTask(Guid)
Retrieves the attribute specifying information on the parameters for the specified task type
Declaration
public static ServerTaskParametersAttribute GetSaveServerTask(Guid forTaskID)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | forTaskID | The globally unique id of this task type UniqueTaskID |
Returns
Type | Description |
---|---|
ServerTaskParametersAttribute | The attribute specifying information on the parameters for the specified task type |
GetServerTask(ITaskProcessor)
Retrieves the attribute specifying information on the parameters for the specified task type
Declaration
public static ServerTaskParametersAttribute GetServerTask(ITaskProcessor fromRunningProcessor)
Parameters
Type | Name | Description |
---|---|---|
ITaskProcessor | fromRunningProcessor | An instance of the task processor that we wanted the associated parameter info for |
Returns
Type | Description |
---|---|
ServerTaskParametersAttribute | The attribute specifying information on the parameters for the specified task type |
GetServerTaskParameterInfo(Guid)
Returns the type of the class used to contain the parameters for the specified task type
Declaration
public static Type GetServerTaskParameterInfo(Guid forTaskID)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | forTaskID | The globally unique id of this task type UniqueTaskID |
Returns
Type | Description |
---|---|
System.Type | The type of the class used to contain the parameters for the specified task type |
GetServerTaskResultHandler(Guid, ServerTaskResultType)
Returns the attribute defining the ITaskResultHandler implementation for handling the specified task associated ServerTaskResult
Declaration
public static ServerTaskResultAttribute GetServerTaskResultHandler(Guid forTaskID, ServerTaskResultType type)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | forTaskID | The globally unique id of this task type UniqueTaskID |
ServerTaskResultType | type | The type of handler required - either for the server or client |
Returns
Type | Description |
---|---|
ServerTaskResultAttribute | The attribute defining the ITaskResultHandler implementation for handling the specified task associated ServerTaskResult |
GetServerTasks()
Returns the attributes with information on all tasks in the system
Declaration
public static IEnumerable<ServerTaskParametersAttribute> GetServerTasks()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ServerTaskParametersAttribute> | A list of attributes with information on all tasks in the system |
GetUserFriendlyTaskInstanceIdentityInfo(IServerTask, IServerTaskData)
Returns the user friendly string for identifying the specified task
Calculated from the tasks GetUserFriendlyTaskInstanceIdentityInfo(IServerTask) or from its ServerTaskAttribute
Declaration
public static string GetUserFriendlyTaskInstanceIdentityInfo(IServerTask task, IServerTaskData data)
Parameters
Type | Name | Description |
---|---|---|
IServerTask | task | The task to return a user friendly string for |
IServerTaskData | data | An optional data record for the task to provide a more detailed description |
Returns
Type | Description |
---|---|
System.String | A user friendly string for identifying the specified task |