Show / Hide Table of Contents

Class BatchData

BatchData handles all batch database access.

Inheritance
object
BatchData
Implements
IBatchData
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SuperOffice.CRM.BatchProcessing
Assembly: SoBatchProcessing.dll
Syntax
public class BatchData : IBatchData

Constructors

BatchData(IBatchTaskFactory, ILogger<BatchData>)

BatchData handles all batch database access.

Declaration
public BatchData(IBatchTaskFactory batchTaskFactory, ILogger<BatchData> logger)
Parameters
Type Name Description
IBatchTaskFactory batchTaskFactory
ILogger<BatchData> logger

Methods

AquireTaskAsync(BatchTaskInfo, CancellationToken)

When a task is retrieved from the batch task system and is ready to be started, we need a mechanism that will ensure a task is not started by two or more instances of a batch service. Before starting a task, try to aquire it with this method.

Declaration
public Task<bool> AquireTaskAsync(BatchTaskInfo batchTaskInfo, CancellationToken cancellationToken = default)
Parameters
Type Name Description
BatchTaskInfo batchTaskInfo
CancellationToken cancellationToken
Returns
Type Description
Task<bool>

True if the task was aquired, false if someone else had aquired it before we got to do it.

DeleteBatchTasksAsync(params int[])

Delete batch tasks from the database.

Declaration
public Task<bool> DeleteBatchTasksAsync(params int[] ids)
Parameters
Type Name Description
int[] ids

Array of ids to delete.

Returns
Type Description
Task<bool>

DeserializeFromBinaryObjectRowToParameterObjectAsync(int, CancellationToken)

Deserialize an entry in BinaryObjectRow to a object.

Declaration
protected Task<StringDictionary> DeserializeFromBinaryObjectRowToParameterObjectAsync(int id, CancellationToken cancellationToken = default)
Parameters
Type Name Description
int id

Id of the row to deserialize

CancellationToken cancellationToken
Returns
Type Description
Task<StringDictionary>

The deserialized object.

GetBatchTaskInfoAsync(int, CancellationToken)

Get information about a specified task.

Declaration
public Task<BatchTaskInfo> GetBatchTaskInfoAsync(int id, CancellationToken cancellationToken = default)
Parameters
Type Name Description
int id

batch task id.

CancellationToken cancellationToken
Returns
Type Description
Task<BatchTaskInfo>

GetBatchTasksAsync(int[], BatchTaskState, DateTime, DateTime, CancellationToken)

Get all tasks for a specified user and state in a specified time period.

Declaration
public Task<BatchTaskInfo[]> GetBatchTasksAsync(int[] associateIds, BatchTaskState state, DateTime fromDate, DateTime toDate, CancellationToken cancellationToken)
Parameters
Type Name Description
int[] associateIds
BatchTaskState state
DateTime fromDate

Do not get task created before this date. Use DateTime.MinValue for no restriction.

DateTime toDate

Do not get task created after this date. Use DateTime.MaxValue for no restriction.

CancellationToken cancellationToken
Returns
Type Description
Task<BatchTaskInfo[]>

An array of BatchTaskInfo

GetBatchTasksAsync(string, int[], BatchTaskState, DateTime, DateTime, CancellationToken)

BatchData handles all batch database access.

Declaration
public Task<BatchTaskInfo[]> GetBatchTasksAsync(string batchDefinitionName, int[] associateIds, BatchTaskState state, DateTime fromDate, DateTime toDate, CancellationToken cancellationToken)
Parameters
Type Name Description
string batchDefinitionName
int[] associateIds
BatchTaskState state
DateTime fromDate
DateTime toDate
CancellationToken cancellationToken
Returns
Type Description
Task<BatchTaskInfo[]>

PopulateBatchTaskInfoFromRowAsync(BatchTaskRow, CancellationToken)

Take a BatchTaskRow and return a SuperOffice.CRM.Services.BatchTaskInfo object

Declaration
protected Task<BatchTaskInfo> PopulateBatchTaskInfoFromRowAsync(BatchTaskRow row, CancellationToken cancellationToken = default)
Parameters
Type Name Description
BatchTaskRow row
CancellationToken cancellationToken
Returns
Type Description
Task<BatchTaskInfo>

RegisterPluginAsync(string)

Register a plugin to the BatchTaskDefinition table

Declaration
public Task<int> RegisterPluginAsync(string name)
Parameters
Type Name Description
string name
Returns
Type Description
Task<int>

SaveBatchTaskInfoAsync(BatchTaskInfo)

Save a new BatchTaskInfo to the database

Declaration
public Task<int> SaveBatchTaskInfoAsync(BatchTaskInfo batchTaskInfo)
Parameters
Type Name Description
BatchTaskInfo batchTaskInfo
Returns
Type Description
Task<int>

SaveBatchTaskInfoAsync(BatchTaskInfo, StringDictionary)

Save a new BatchTaskInfo to the database a parameter object saved to BinaryObject table.

Declaration
public Task<int> SaveBatchTaskInfoAsync(BatchTaskInfo batchTaskInfo, StringDictionary parameterObject)
Parameters
Type Name Description
BatchTaskInfo batchTaskInfo
StringDictionary parameterObject

A serializable object. Will be saved to BinaryObject table. The link will be set using DetailsTable and DetailsRecord in object BatchTaskInfo.

Returns
Type Description
Task<int>

SerializeParameterObjectToBinaryObjectRowAsync(StringDictionary)

Serialize a StringDictionary to a row in BinaryObjectRow

Declaration
protected Task<BinaryObjectRow> SerializeParameterObjectToBinaryObjectRowAsync(StringDictionary stringDictionary)
Parameters
Type Name Description
StringDictionary stringDictionary

StringDictionary to serialize

Returns
Type Description
Task<BinaryObjectRow>

A BinaryObjectRow

Remarks

The object must be serializable.

SetBatchTaskInfoStateAsync(BatchTaskInfo, BatchTaskState)

Update state on a BatchTaskInfo row

Declaration
public Task SetBatchTaskInfoStateAsync(BatchTaskInfo batchTaskInfo, BatchTaskState state)
Parameters
Type Name Description
BatchTaskInfo batchTaskInfo
BatchTaskState state
Returns
Type Description
Task

UpdateBatchTaskAsync(BatchTaskInfo)

Update information about a BatchTask. Only the following properties can be updated: State, Description, Response and Request

Declaration
public Task<BatchTaskInfo> UpdateBatchTaskAsync(BatchTaskInfo batchTaskInfo)
Parameters
Type Name Description
BatchTaskInfo batchTaskInfo

The updated information to save.

Returns
Type Description
Task<BatchTaskInfo>

The updated BatchTaskInfo

Implements

IBatchData

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
IBatchDataTicketExtensions.CreateTicketBatchReplyTaskAsync(IBatchData, TicketBatchReplyData)
IBatchDataTicketExtensions.CreateTicketForwarTaskAsync(IBatchData, TicketBatchPluginBase.TicketForwardSettings)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top