Search Results for

    Show / Hide Table of Contents

    Class AdbTransactionActionWorker

    A worker which creates and opens an AdbKeepOpenConnection and a single local AdbTransaction, runs a user supplied delegate that performs database commands inside the transaction, commits or rolls back the transaction on success or failure, and finally disposes the transaction and connection. The delegate typically creates Adb child database workers that automatically participates in the transaction, which will be rolled back if any of these child workers (or the callback) fails.

    This construct is very useful for running multiple database commands and database workers inside a single transaction, and have them collectively either committed or rolled back, while correctly handling any exceptions that might occur.

    As with any transaction, keep the duration of the work short, where possible moving work outside the transaction (i.e. outside this worker), and avoiding delays inside it. Furthermore, do ensure that the volume of modified data does not exceed the database server's capacity to handle it, as it will accumulate until the final commit or roll-back.

    AddStartingCallback(Func<WorkerBase, Task<ProgressStatus>>) can be used. Note however, that the connection and transaction are only created and opened if and when the worker is run.

    See AdbTransactionActionWorker Example for how to use this worker.

    Inheritance
    Object
    WorkerParent
    WorkerBase
    WorkerBase<AdbTransactionActionWorker>
    AdbTransactionActionWorker
    Implements
    IDisposeOnFinished
    Inherited Members
    WorkerBase<AdbTransactionActionWorker>.AddCompletedCallback(Func<AdbTransactionActionWorker, OutcomeStatus, Task<OutcomeStatus>>)
    WorkerBase<AdbTransactionActionWorker>.AddRanCallback(Func<AdbTransactionActionWorker, OutcomeStatus, WorkerParentChildrenState, Task<OutcomeStatus>>)
    WorkerBase<AdbTransactionActionWorker>.AddStartingCallback(Func<AdbTransactionActionWorker, Task<ProgressStatus>>)
    WorkerBase.AddCompletedCallback(Func<WorkerBase, OutcomeStatus, Task<OutcomeStatus>>)
    WorkerBase.AddRanCallback(Func<WorkerBase, OutcomeStatus, WorkerParentChildrenState, Task<OutcomeStatus>>)
    WorkerBase.AddStartingCallback(Func<WorkerBase, Task<ProgressStatus>>)
    WorkerBase.DefaultIsStartable()
    WorkerBase.ErroredPortErrorsWorkerProtected
    WorkerBase.ErrorOutputs
    WorkerBase.EscalateError
    WorkerBase.Inputs
    WorkerBase.IsStartable
    WorkerBase.Outputs
    WorkerBase.Parent
    WorkerBase.SucceededSequence<TLastWorker>(WorkerBase, WorkerBase, WorkerBase, WorkerBase, WorkerBase, TLastWorker)
    WorkerBase.SucceededSequence<TLastWorker>(WorkerBase, WorkerBase, WorkerBase, WorkerBase, TLastWorker)
    WorkerBase.SucceededSequence<TLastWorker>(WorkerBase, WorkerBase, WorkerBase, TLastWorker)
    WorkerBase.SucceededSequence<TLastWorker>(WorkerBase, WorkerBase, TLastWorker)
    WorkerBase.SucceededSequence<TLastWorker>(WorkerBase, TLastWorker)
    WorkerBase.SucceededSequence<TLastWorker>(TLastWorker)
    WorkerParent.AddChildCompletedCallback(Action<WorkerBase>)
    WorkerParent.AddStartingChildrenCallback(Func<WorkerParent, Task<ProgressStatus>>)
    WorkerParent.Children
    WorkerParent.DisposeOnFinished<TDisposable>(TDisposable)
    WorkerParent.GetDownstreamFactory<TInput>()
    WorkerParent.HasChildren
    WorkerParent.IsCanceled
    WorkerParent.IsCompleted
    WorkerParent.IsCreated
    WorkerParent.IsError
    WorkerParent.IsFailed
    WorkerParent.IsFatal
    WorkerParent.IsRunning
    WorkerParent.IsSucceeded
    WorkerParent.KeepChildrenLevels
    WorkerParent.Locator
    WorkerParent.LogFactory
    WorkerParent.Logger
    WorkerParent.MaxRunningChildren
    WorkerParent.Name
    WorkerParent.RemoveChildren()
    WorkerParent.RescheduleChildren()
    WorkerParent.RunChildrenAsync(Boolean)
    WorkerParent.RunChildrenAsync()
    WorkerParent.Status
    WorkerParent.Item[String]
    WorkerParent.ToString()
    WorkerParent.WorkerSystem
    WorkerParent.DebugCommands
    WorkerParent.AggregateErrorOutputRows
    WorkerParent.AggregateOutputRows
    WorkerParent.AggregateWorkersCompleted
    WorkerParent.InstantCompleted
    WorkerParent.InstantCreated
    WorkerParent.InstantStarted
    WorkerParent.RunningDuration
    Namespace: actionETL.Adb
    Assembly: actionETL.dll
    Syntax
    public class AdbTransactionActionWorker : WorkerBase<AdbTransactionActionWorker>, IDisposeOnFinished

    Constructors

    AdbTransactionActionWorker(WorkerParent, String, AdbKeepOpenConnectionBuilder, Action<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder>)

    Initializes a new instance of the AdbTransactionActionWorker worker that creates and opens an AdbKeepOpenConnection and a single local AdbTransaction, runs a user supplied delegate that performs database commands inside the transaction (often via creating child workers), commits or rolls back the transaction on success or failure, and finally disposes the transaction and connection.

    Declaration
    public AdbTransactionActionWorker(WorkerParent workerParent, string workerName, AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder, Action<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder> action)
    Parameters
    Type Name Description
    WorkerParent workerParent

    The parent worker or worker system that the new child worker will be added to. Cannot be null.

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder

    A keep-open connection builder.

    Action<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder> action

    The synchronous action to execute, optionally creating child workers. It receives the worker itself and adbKeepOpenConnectionBuilder as parameters.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException

    workerParent - All workers must have a parent. The top level workers have the worker system as parent.

    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    AdbTransactionActionWorker(WorkerParent, String, AdbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, OutcomeStatus>)

    Initializes a new instance of the AdbTransactionActionWorker worker that creates and opens an AdbKeepOpenConnection and a single local AdbTransaction, runs a user supplied delegate that performs database commands inside the transaction (often via creating child workers), commits or rolls back the transaction on success or failure, and finally disposes the transaction and connection.

    Declaration
    public AdbTransactionActionWorker(WorkerParent workerParent, string workerName, AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, OutcomeStatus> func)
    Parameters
    Type Name Description
    WorkerParent workerParent

    The parent worker or worker system that the new child worker will be added to. Cannot be null.

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder

    A keep-open connection builder.

    Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, OutcomeStatus> func

    The synchronous function to execute, optionally creating child workers. It receives the worker itself and adbKeepOpenConnectionBuilder as parameters, and should It returns OutcomeStatus success or failure.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException

    workerParent - All workers must have a parent. The top level workers have the worker system as parent.

    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    AdbTransactionActionWorker(WorkerParent, String, AdbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task<OutcomeStatus>>)

    Initializes a new instance of the AdbTransactionActionWorker worker that creates and opens an AdbKeepOpenConnection and a single local AdbTransaction, runs a user supplied delegate that performs database commands inside the transaction (often via creating child workers), commits or rolls back the transaction on success or failure, and finally disposes the transaction and connection.

    Declaration
    public AdbTransactionActionWorker(WorkerParent workerParent, string workerName, AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task<OutcomeStatus>> funcAsync)
    Parameters
    Type Name Description
    WorkerParent workerParent

    The parent worker or worker system that the new child worker will be added to. Cannot be null.

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder

    A keep-open connection builder.

    Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task<OutcomeStatus>> funcAsync

    The asynchronous function to execute, optionally creating child workers. It receives the worker itself and adbKeepOpenConnectionBuilder as parameters, and should It returns OutcomeStatus success or failure.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException

    workerParent - All workers must have a parent. The top level workers have the worker system as parent.

    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    AdbTransactionActionWorker(WorkerParent, String, AdbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task>)

    Initializes a new instance of the AdbTransactionActionWorker worker that creates and opens an AdbKeepOpenConnection and a single local AdbTransaction, runs a user supplied delegate that performs database commands inside the transaction (often via creating child workers), commits or rolls back the transaction on success or failure, and finally disposes the transaction and connection.

    Declaration
    public AdbTransactionActionWorker(WorkerParent workerParent, string workerName, AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task> actionAsync)
    Parameters
    Type Name Description
    WorkerParent workerParent

    The parent worker or worker system that the new child worker will be added to. Cannot be null.

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder

    A keep-open connection builder.

    Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task> actionAsync

    The asynchronous action to execute, optionally creating child workers. It receives the worker itself and adbKeepOpenConnectionBuilder as parameters.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException

    workerParent - All workers must have a parent. The top level workers have the worker system as parent.

    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    AdbTransactionActionWorker(WorkerParent, String, Func<Boolean>, AdbKeepOpenConnectionBuilder, Action<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder>)

    Initializes a new instance of the AdbTransactionActionWorker worker that creates and opens an AdbKeepOpenConnection and a single local AdbTransaction, runs a user supplied delegate that performs database commands inside the transaction (often via creating child workers), commits or rolls back the transaction on success or failure, and finally disposes the transaction and connection.

    Declaration
    public AdbTransactionActionWorker(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder, Action<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder> action)
    Parameters
    Type Name Description
    WorkerParent workerParent

    The parent worker or worker system that the new child worker will be added to. Cannot be null.

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    Func<Boolean> isStartableFunc

    Function to calculate the worker start constraint; it should return true for startable and false for not startable. Defaults to startable if null.

    AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder

    A keep-open connection builder.

    Action<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder> action

    The synchronous action to execute, optionally creating child workers. It receives the worker itself and adbKeepOpenConnectionBuilder as parameters.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException

    workerParent - All workers must have a parent. The top level workers have the worker system as parent.

    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    AdbTransactionActionWorker(WorkerParent, String, Func<Boolean>, AdbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, OutcomeStatus>)

    Initializes a new instance of the AdbTransactionActionWorker worker that creates and opens an AdbKeepOpenConnection and a single local AdbTransaction, runs a user supplied delegate that performs database commands inside the transaction (often via creating child workers), commits or rolls back the transaction on success or failure, and finally disposes the transaction and connection.

    Declaration
    public AdbTransactionActionWorker(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, OutcomeStatus> func)
    Parameters
    Type Name Description
    WorkerParent workerParent

    The parent worker or worker system that the new child worker will be added to. Cannot be null.

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    Func<Boolean> isStartableFunc

    Function to calculate the worker start constraint; it should return true for startable and false for not startable. Defaults to startable if null.

    AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder

    A keep-open connection builder.

    Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, OutcomeStatus> func

    The synchronous function to execute, optionally creating child workers. It receives the worker itself and adbKeepOpenConnectionBuilder as parameters, and should It returns OutcomeStatus success or failure.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException

    workerParent - All workers must have a parent. The top level workers have the worker system as parent.

    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    AdbTransactionActionWorker(WorkerParent, String, Func<Boolean>, AdbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task<OutcomeStatus>>)

    Initializes a new instance of the AdbTransactionActionWorker worker that creates and opens an AdbKeepOpenConnection and a single local AdbTransaction, runs a user supplied delegate that performs database commands inside the transaction (often via creating child workers), commits or rolls back the transaction on success or failure, and finally disposes the transaction and connection.

    Declaration
    public AdbTransactionActionWorker(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task<OutcomeStatus>> funcAsync)
    Parameters
    Type Name Description
    WorkerParent workerParent

    The parent worker or worker system that the new child worker will be added to. Cannot be null.

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    Func<Boolean> isStartableFunc

    Function to calculate the worker start constraint; it should return true for startable and false for not startable. Defaults to startable if null.

    AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder

    A keep-open connection builder.

    Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task<OutcomeStatus>> funcAsync

    The asynchronous function to execute, optionally creating child workers. It receives the worker itself and adbKeepOpenConnectionBuilder as parameters, and should It returns OutcomeStatus success or failure.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException

    workerParent - All workers must have a parent. The top level workers have the worker system as parent.

    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    AdbTransactionActionWorker(WorkerParent, String, Func<Boolean>, AdbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task>)

    Initializes a new instance of the AdbTransactionActionWorker worker that creates and opens an AdbKeepOpenConnection and a single local AdbTransaction, runs a user supplied delegate that performs database commands inside the transaction (often via creating child workers), commits or rolls back the transaction on success or failure, and finally disposes the transaction and connection.

    Declaration
    public AdbTransactionActionWorker(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task> actionAsync)
    Parameters
    Type Name Description
    WorkerParent workerParent

    The parent worker or worker system that the new child worker will be added to. Cannot be null.

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    Func<Boolean> isStartableFunc

    Function to calculate the worker start constraint; it should return true for startable and false for not startable. Defaults to startable if null.

    AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder

    A keep-open connection builder.

    Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task> actionAsync

    The asynchronous action to execute, optionally creating child workers. It receives the worker itself and adbKeepOpenConnectionBuilder as parameters.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException

    workerParent - All workers must have a parent. The top level workers have the worker system as parent.

    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    Methods

    RunAsync()

    This method can be overridden to add custom functionality to the derived worker that runs before and after the row processing, but after AddStartingCallback(Func<WorkerBase, Task<ProgressStatus>>) and before AddCompletedCallback(Func<WorkerBase, OutcomeStatus, Task<OutcomeStatus>>) callbacks. In this case, the base class base.RunAsync() must be called for the worker to function correctly.

    Typically, this worker is used without overriding this method.

    Declaration
    protected override Task<OutcomeStatus> RunAsync()
    Returns
    Type Description
    Task<OutcomeStatus>

    A Task describing the success or failure of the worker. An asynchronous async implementation would e.g. return OutcomeStatus.Succeeded on success, while a synchronous implementation would return OutcomeStatus.SucceededTask.

    Overrides
    WorkerParent.RunAsync()

    Implements

    IDisposeOnFinished

    See Also

    AdbTransactionActionWorker Example
    AdbTransaction
    AdbKeepOpenConnectionBuilder
    In This Article
    Back to top Copyright © 2021 Envobi Ltd