CodeAround.FluentBatch 1.0.12

dotnet add package CodeAround.FluentBatch --version 1.0.12                
NuGet\Install-Package CodeAround.FluentBatch -Version 1.0.12                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CodeAround.FluentBatch" Version="1.0.12" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CodeAround.FluentBatch --version 1.0.12                
#r "nuget: CodeAround.FluentBatch, 1.0.12"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CodeAround.FluentBatch as a Cake Addin
#addin nuget:?package=CodeAround.FluentBatch&version=1.0.12

// Install CodeAround.FluentBatch as a Cake Tool
#tool nuget:?package=CodeAround.FluentBatch&version=1.0.12                

Codearound.FluentBatch

NuGet Code Coverage Supported Platform Test Number

The library allows to create complex batch / workflow using fluent syntax. The library is .Net Standard 2.0 and included more common work tasks like Database source and destination, text source and destination, xml source and destination, loop work task, conditional work task, Excel source, json source.

Otherwise you can implements a custom work task easly and at the end you can develop a extended module for the engine

Setup

you can download the package from Nuget : CodeAround.FluentBatch

Description

Fluent Batch is an engine to create a batch based on fluent syntax

Main features are

  • .Net Standard 2.0 (.Net core ready)
  • Compatibility with all relational database (powered by Dapper)
  • Create you custom work task for each kind of custom implementation
  • Implements a Microsoft.Extension.Logging to allow choosing of common log library (NLog, Serilog etc)
  • Creating a extension of engine to included new type of work task
  • Available +12 several work task type

Work Task Type

The engine support 3 kind of work task

  1. Source Tasks
  2. Generic or Base Tasks
  3. Destination Tasks

Source Tasks

The source task contains all tasks that grab anything information and transform these to proprietary structure used in the later tasks. In few words these task represents a Input Task type The default source tasks are:

Destination Tasks

The destination task contains all tasks that wirte anything of informations received in input. These are a Output Task type The default destination tasks are:

  • Sql Destination: Allow to persist some information in any type of relational database any type of relational database (powered by Dapper)
  • Text Destination: Allow to persist some information in text file included csv and fixed lenght file
  • Xml Destination: Allow to persist some information in xml file

Generic or Base Tasks

There are a kind of tasks that are used to enrich the power of engine, in particular you can create add a loop behavior or a conditions behaviour of your flow.

the generic tasks are:

How to use

This is an example to create a batch that grab data from excel and put into sql server database.

The excel has one sheet with this information

PersonId Name Surname Age
1 George Best 23
2 Paul Blend 44

The code to implement this task is :


  var builder = new FlowBuilder(_logger);
  var flow = builder.Create("Excel Source")
                    .Then(task => task.Name("ExcelWorkTask")
                                      .CreateExcelSource()
                                      .FromFile("[PUT_YOUR_FILE_PATH]")
                                      .UseHeader(true)
                                      .Use(() => "PersonId")
                                      .Use(() => "Name")
                                      .Use(() => "Surname")
                                      .Use(() => "Age")
                                      .Build()
                                      )
                    .Then(task => task.Name("insert rows").Create<InsertCustomExcelTask>()
                                  .Build())
                     .Then(task => task.CreateSqlDestination()
                                       .UseConnection([PUT_YOUR_CONNECTION_STRING])
                                       .Table("PersonDetail")
                                       .Schema("dbo")
                                       .Map(() => "PersonId", () => "PersonId", true)
                                       .Map(() => "Name", () => "Name", false)
                                       .Map(() => "Surname", () => "Surname", false)
                                       .Specify(() => "BirthdayDate", () => DateTime.Now)
                     .Build())
                    .Build();

  flow.Run();

First of all I create a FlowBuilder instance passing an instance of Microsoft.Extension.Logging then :

  • Create a Excel Source Task, specifying the excel file path, if there is an header and the map of fields
  • Create a custom task called InsertCustomExcelTask that mark each transformed rows as to Insert

public override TaskResult Execute()
{
    if (_rows != null && _rows.Count() > 0)
    {
        foreach (var row in _rows)
        {
            row.Operation = OperationType.Insert;
        }
    }
    return new TaskResult(true, _rows);
}

  • Create a Sql Destination Task specifying a destination table, schema, connection string and the mapping of fields

you can found a complete code in the test called excelSource_should_retun_completed_status_with_header_in_sql_destination in the ExcelSourceTest.cs test file

Create Custom Task

Go Create Custom Task Wiki page

Extensions

FluentBatch allow to create an extension of engine to create a specific and reusable task type in easly mode.

Now 2 extensions are available:

Go Create New Extension Wiki page

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on CodeAround.FluentBatch:

Package Downloads
Codearound.FluentBatch.SqlScript

Extension of CodeAround.FluentBatch library (https://www.nuget.org/packages/CodeAround.FluentBatch/) to add an sql script destination work task. This work task allows to create a script for insert, update and delete statement

CodeAround.FluentBatch.Email

Extension of CodeAround.FluentBatch library (https://www.nuget.org/packages/CodeAround.FluentBatch/) to add an email destination work task

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.12 532 9/17/2021
1.0.11 356 9/17/2021
1.0.10 316 8/14/2021
1.0.9 339 8/9/2021
1.0.8 376 8/6/2021
1.0.7 378 8/6/2021
1.0.6 348 8/4/2021
1.0.5 362 8/4/2021
1.0.4 449 11/15/2020
1.0.3 514 4/5/2020
1.0.2 1,087 10/24/2019
1.0.1 791 10/21/2019
1.0.0 531 10/20/2019

Release 1.0.11
- Add task count in flow context
Release 1.0.10
- Fix Loop Task on parallel
Release 1.0.9
- Add execute async and callback in customworktask
- Fix issue on loop task
Release 1.0.7
- Fix issue on loop task
Release 1.0.5
- Add parallel support on loop task
- Add func support to collection in loop task
Release 1.0.4
- Fix on sql destination

Release 1.0.3

This Release include:
Fix sql destination in update statement. Now it's able to update only the mapped fields. You can force update all fields call UpdateAllFields() method in sql destination task

Release 1.0.2

This Release include:
- Removed unsed WithName
- Add Name in extension task mechanism


Release 1.0.1

This Release include:
- Add command timeout on sql source
- Add command timeout on sql destination
- Fix Sql Destination - Generate command

Release 1.0.0

This release included :
- Engine to create a flow
- .Net Standard 2.0 (.Net core ready)
- Compatibility with all relational database (powered by Dapper Dapper)
- Create you custom work task for each kind of custom implementation
- Implements a Microsoft.Extension.Logging to allow choosing of common log library (NLog, Serilog etc)
- Creating a extension of engine to included new type of work task
Now 1 extension is available:
Codearound.FluentBatch.Email (https://github.com/CodearoundHub/Codearound.FluentBatch.Email) that allow to send an email in your flow (Powered by FluentEmail FluentEmail.Core)
- Set of default work task
- Sql Destination: Allow to persist some information in your database
- Text Destination: Allow to persist some information in text file included csv and fixed lenght file
- Xml Destination: Allow to persist some information in xml file
- Loop Work Task: Allow to implement a loop behavior in your workflow
- Condition Wor Task: Allow to implement a condition behavior in your workflow
- Sql Work Task: Allow to implement a common database work task to execute db command
- Excel Source: Allow to grab the information from a Excel file (powered by ExcelDataReader  ExcelDataReader)
- Json Source: Allow to grab the information from a Json (powered by Newtonsoft.Json Newtonsoft.Json)
- Object Source: Allow to grab the information from a .net object
- Sql Source: Allow to grab the information from any type of relational database (powered by Dapper Dapper)
- Text Source: Allow to grab the information from any type of Text file included csv and fixed lenght file
- Xml Source: Allow to grab the information from Xml