Class BatchTaskBase
Base class for tasks to be executed by the BatchTaskFactory.
Inheritance
Implements
Inherited Members
Namespace: SuperOffice.CRM.BatchProcessing.Tasks
Assembly: SoBatchProcessing.dll
Syntax
public abstract class BatchTaskBase : IBatchTask
Constructors
BatchTaskBase(IBatchData, IBatchServiceConfiguration, ILogger<BatchTaskBase>)
Base class for tasks to be executed by the BatchTaskFactory.
Declaration
public BatchTaskBase(IBatchData batchData, ConfigFile.IBatchServiceConfiguration batchServiceConfiguration, ILogger<BatchTaskBase> logger)
Parameters
| Type | Name | Description |
|---|---|---|
| IBatchData | batchData | |
| ConfigFile.IBatchServiceConfiguration | batchServiceConfiguration | |
| ILogger<BatchTaskBase> | logger |
Fields
_batchData
Base class for tasks to be executed by the BatchTaskFactory.
Declaration
protected readonly IBatchData _batchData
Field Value
| Type | Description |
|---|---|
| IBatchData |
_internalCompletionSource
Base class for tasks to be executed by the BatchTaskFactory.
Declaration
public readonly TaskCompletionSource<bool> _internalCompletionSource
Field Value
| Type | Description |
|---|---|
| TaskCompletionSource<bool> |
_isEnding
Base class for tasks to be executed by the BatchTaskFactory.
Declaration
protected bool _isEnding
Field Value
| Type | Description |
|---|---|
| bool |
_statusUpdateInterval
Base class for tasks to be executed by the BatchTaskFactory.
Declaration
protected long _statusUpdateInterval
Field Value
| Type | Description |
|---|---|
| long |
Properties
BatchTaskInfo
Base class for tasks to be executed by the BatchTaskFactory.
Declaration
protected BatchTaskInfo BatchTaskInfo { get; }
Property Value
| Type | Description |
|---|---|
| BatchTaskInfo |
Context
Context of the task
Declaration
public string Context { get; }
Property Value
| Type | Description |
|---|---|
| string |
Id
Base class for tasks to be executed by the BatchTaskFactory.
Declaration
protected int Id { get; }
Property Value
| Type | Description |
|---|---|
| int |
Name
Name of the task.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Result
Result of the task.
Declaration
public string Result { get; }
Property Value
| Type | Description |
|---|---|
| string |
State
State of the executing task.
Declaration
public BatchTaskState State { get; }
Property Value
| Type | Description |
|---|---|
| BatchTaskState |
Methods
EndTaskAsync(CancellationToken)
End the currently executing task.
Declaration
public Task EndTaskAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
EnsureUdefsAsync()
Base class for tasks to be executed by the BatchTaskFactory.
Declaration
protected Task EnsureUdefsAsync()
Returns
| Type | Description |
|---|---|
| Task |
GetTaskInfoAsync(CancellationToken)
Get information about the currently executing task.
Declaration
public Task<BatchTaskInfo> GetTaskInfoAsync(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<BatchTaskInfo> | Information about the currently executing task. |
ProgressCallbackAsync(int, int, CancellationToken)
Base class for tasks to be executed by the BatchTaskFactory.
Declaration
protected Task<bool> ProgressCallbackAsync(int total, int current, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | total | |
| int | current | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<bool> |
RunAsync(string, string, CancellationToken)
Run the task.
Declaration
protected abstract Task<bool> RunAsync(string name, string context, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the task. |
| string | context | Context for the task. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<bool> | True if the task succeeded. |
Remarks
Call SetResult(string) as needed.
RunTaskAsync(BatchTaskInfo, string, BatchTaskStatusChangedAsync, CancellationToken)
Run a batch task. Method is not completed before the task is executed.
Declaration
public Task RunTaskAsync(BatchTaskInfo batchTaskInfo, string context, BatchTaskStatusChangedAsync onBatchTaskStatusChanged, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| BatchTaskInfo | batchTaskInfo | Information about the task to start. |
| string | context | |
| BatchTaskStatusChangedAsync | onBatchTaskStatusChanged | Notify about changes to the batch task state. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task | Returns a BatchTaskInfo with information about the started task |
SaveStreamToBlobAsync(Stream, string, string, string, CancellationToken)
Base class for tasks to be executed by the BatchTaskFactory.
Declaration
protected Task<int> SaveStreamToBlobAsync(Stream stream, string description = null, string extraInfo = null, string linkComment = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | |
| string | description | |
| string | extraInfo | |
| string | linkComment | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<int> |
SetResult(string)
Set the result of the task.
Declaration
protected void SetResult(string result)
Parameters
| Type | Name | Description |
|---|---|---|
| string | result | Result to set on the executing task. |