Teani.Helper 1.0.4

dotnet add package Teani.Helper --version 1.0.4                
NuGet\Install-Package Teani.Helper -Version 1.0.4                
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="Teani.Helper" Version="1.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Teani.Helper --version 1.0.4                
#r "nuget: Teani.Helper, 1.0.4"                
#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 Teani.Helper as a Cake Addin
#addin nuget:?package=Teani.Helper&version=1.0.4

// Install Teani.Helper as a Cake Tool
#tool nuget:?package=Teani.Helper&version=1.0.4                

What is Generic.Helpers?

Generic.Helpers is a simple little library build to ease a bit the development by gaining some results without the boring part of writing all the time the same lines of codes.

What it contains?

  • A simple logger class which can write log items into the harddrive;
  • Azure Blob Storage Manager (List, Upload, Download and Size);
  • Job engine (sequenced and parallel);
  • IOExtensions;

(Here more will be added).

Where can I get it?

First, install NuGet. Then, install Teani.Helper from the package manager console.

Examples:

Logger

It adds elements into a queue and write them to the harddrive as soon is possible.

//Initialization
Log.Start();

//Writing some messages
Log.Write(eMessageType.Debug, "Debug not stored");
Log.Write(eMessageType.Information, "Some information");
Log.Write(eMessageType.Success, "Some success");
Log.Write(eMessageType.Error, "Some error");
Log.Write(eMessageType.Warning, "Some warning");

Log.Write(new Exception("Some exception, no stack"));

//Declaring that debug messages should also be stored.
Log.StoreDebugMessages = true;
Log.Write(Tni.Helper.Entities.eMessageType.Debug, "Debug stored");
Output of the logs
{"RecordedAt":"2022-11-04T10:33:22.1985371+02:00","MessageType":5,"Message":"Debug not stored"}
{"RecordedAt":"2022-11-04T10:33:22.203045+02:00","MessageType":1,"Message":"Some information"}
{"RecordedAt":"2022-11-04T10:33:22.2030473+02:00","MessageType":4,"Message":"Some success"}
{"RecordedAt":"2022-11-04T10:33:22.2030477+02:00","MessageType":2,"Message":"Some error"}
{"RecordedAt":"2022-11-04T10:33:22.2030479+02:00","MessageType":3,"Message":"Some warning"}
{"RecordedAt":"2022-11-04T10:33:22.2031597+02:00","MessageType":2,"Message":"Some exception, no stack"}
{"RecordedAt":"2022-11-04T10:33:22.2032215+02:00","MessageType":5,"Message":"Debug stored"}

Azure Blob Storage Manager

var asm = new AzureStorageManager("{YourAzureConnectionString}");

//Specifying each time the container.
var container = "YourWorkingContainer";
var list = await asm.GetList(container);
var size = await asm.GetSize(container);

await asm.UploadFile(new FileInfo(@"d:\temp\testfile.json"), true, container);
FileInfo downloadedFile = await asm.DownloadFile(new FileInfo(@"c:\temp\testfile.json"), container);

//Specifying the work container
asm.WorkContainer = container;
list = await asm.GetList();
size = await asm.GetSize();

await asm.UploadFile(new FileInfo(@"d:\temp\testfile.json"), true);
FileInfo downloadedFile = await asm.DownloadFile(new FileInfo(@"c:\temp\testfile.json"));

Job engine sequenced

Initialization of the job engine
Job.Start(new JobProfile()
{
    //How many lanes to be available for execution on parallel mode.
    NoLanes = 10,

    //How many lanes to be served for fast parallel jobs to be executed.
    ReservedLanesForPriorities = 2,

    //Seconds to await on signaling stop before clearing collections
    StopTimeout = 30,

    //If the job store should create some feedback logs of the execution using Helper.Log engine.
    Debug = true,
});
Sequenced mode

This will receive various job items, in a sequenced way, that are to execute an callback when their time comes.

///Add elements to standard queue list
Job.AddSequenced(new JobItem()
{
    Name = "Standard 1",
    Executor = SomeMethodThatWillBeRequestedOnTimeOfJob
});
Job.AddSequenced(new JobItem()
{
    Name = "Standard 2",
    Executor = SomeMethodThatWillBeRequestedOnTimeOfJob
});
Job.AddSequenced(new JobItem()
{
    Name = "Standard 3",
    Executor = SomeMethodThatWillBeRequestedOnTimeOfJob
});

///Add multiple elements at once into queue list
Job.AddSequenced(new List<JobItem>()
{
    new JobItem()
    {
        Name = "Standard 1.1",
        Executor = SomeMethodThatWillBeRequestedOnTimeOfJob
    },
    new JobItem()
    {
        Name = "Standard 2.1",
        Executor = SomeMethodThatWillBeRequestedOnTimeOfJob
    },
    new JobItem()
    {
        Name = "Standard 3.1",
        Executor = SomeMethodThatWillBeRequestedOnTimeOfJob
    }
});
Parallel mode

This will receive various job items, in a parallel way, that are to be executed on determined lanes of execution.

///Add elements to parallel executions
Job.AddParallel(new JobItem()
{
    Name = "Parallel 1",
    LanePriority = eLanePriority.Standard,
    Executor = SomeMethodThatWillBeRequestedOnTimeOfJob
});
Job.AddParallel(new JobItem()
{
    Name = "Parallel 2",
    LanePriority = eLanePriority.Standard,
    Executor = SomeMethodThatWillBeRequestedOnTimeOfJob
});
Job.AddParallel(new JobItem()
{
    Name = "Parallel 3",
    LanePriority = eLanePriority.Standard,
    Executor = SomeMethodThatWillBeRequestedOnTimeOfJob
});

///Add multiple elements to parallel executions
Job.AddParallel(new List<JobItem>()
{
    new JobItem()
    {
        Name = "Parallel 1.1",
        LanePriority = eLanePriority.Standard,
        Executor = SomeMethodThatWillBeRequestedOnTimeOfJob
    },
    new JobItem()
    {
        Name = "Parallel 2.1",
        LanePriority = eLanePriority.Standard,
        Executor = SomeMethodThatWillBeRequestedOnTimeOfJob
    },
    new JobItem()
    {
        Name = "Parallel 3.1",
        LanePriority = eLanePriority.Standard,
        Executor = SomeMethodThatWillBeRequestedOnTimeOfJob
    }
});
Sample output from loggins based on the execution
{"RecordedAt":"2022-11-05T20:41:47.2017126+02:00","MessageType":5,"Message":"Sequenced [Standard 1] called for execution."}
{"RecordedAt":"2022-11-05T20:41:47.2137014+02:00","MessageType":5,"Message":"Job [Standard 1] was executed on sequenced mode. Started: 11/5/2022 8:41:43 PM, Ended: 11/5/2022 8:41:47 PM, Duration: 00:00:04.0677905"}
{"RecordedAt":"2022-11-05T20:41:49.2230388+02:00","MessageType":5,"Message":"Sequenced [Standard 2] called for execution."}
{"RecordedAt":"2022-11-05T20:41:49.2230812+02:00","MessageType":5,"Message":"Job [Standard 2] was executed on sequenced mode. Started: 11/5/2022 8:41:47 PM, Ended: 11/5/2022 8:41:49 PM, Duration: 00:00:02.0093420"}
{"RecordedAt":"2022-11-05T20:41:51.2264558+02:00","MessageType":5,"Message":"Sequenced [Standard 3] called for execution."}
{"RecordedAt":"2022-11-05T20:41:51.2265682+02:00","MessageType":5,"Message":"Job [Standard 3] was executed on sequenced mode. Started: 11/5/2022 8:41:49 PM, Ended: 11/5/2022 8:41:51 PM, Duration: 00:00:02.0033988"}
{"RecordedAt":"2022-11-05T20:41:53.2408863+02:00","MessageType":5,"Message":"Sequenced [Standard 1.1] called for execution."}
{"RecordedAt":"2022-11-05T20:41:53.2409667+02:00","MessageType":5,"Message":"Job [Standard 1.1] was executed on sequenced mode. Started: 11/5/2022 8:41:51 PM, Ended: 11/5/2022 8:41:53 PM, Duration: 00:00:02.0143312"}
{"RecordedAt":"2022-11-05T20:41:55.252604+02:00","MessageType":5,"Message":"Sequenced [Standard 2.1] called for execution."}
{"RecordedAt":"2022-11-05T20:41:55.2526366+02:00","MessageType":5,"Message":"Job [Standard 2.1] was executed on sequenced mode. Started: 11/5/2022 8:41:53 PM, Ended: 11/5/2022 8:41:55 PM, Duration: 00:00:02.0116451"}
{"RecordedAt":"2022-11-05T20:41:57.2620415+02:00","MessageType":5,"Message":"Sequenced [Standard 3.1] called for execution."}
{"RecordedAt":"2022-11-05T20:41:57.2621311+02:00","MessageType":5,"Message":"Job [Standard 3.1] was executed on sequenced mode. Started: 11/5/2022 8:41:55 PM, Ended: 11/5/2022 8:41:57 PM, Duration: 00:00:02.0094199"}
{"RecordedAt":"2022-11-05T20:41:58.1445221+02:00","MessageType":5,"Message":"Lane [10] as assigned to [Parallel 1]"}
{"RecordedAt":"2022-11-05T20:41:58.1445804+02:00","MessageType":5,"Message":"Lane [9] as assigned to [Parallel 2]"}
{"RecordedAt":"2022-11-05T20:41:58.1445836+02:00","MessageType":5,"Message":"Lane [8] as assigned to [Parallel 3]"}
{"RecordedAt":"2022-11-05T20:41:58.1447566+02:00","MessageType":5,"Message":"Lane [7] as assigned to [Parallel 1.1]"}
{"RecordedAt":"2022-11-05T20:41:58.1447588+02:00","MessageType":5,"Message":"Lane [6] as assigned to [Parallel 2.1]"}
{"RecordedAt":"2022-11-05T20:41:58.1447602+02:00","MessageType":5,"Message":"Lane [5] as assigned to [Parallel 3.1]"}
{"RecordedAt":"2022-11-05T20:42:00.3852472+02:00","MessageType":5,"Message":"Sequenced [Parallel 3.1] called for execution."}
{"RecordedAt":"2022-11-05T20:42:00.3852546+02:00","MessageType":5,"Message":"Sequenced [Parallel 2] called for execution."}
{"RecordedAt":"2022-11-05T20:42:00.3852547+02:00","MessageType":5,"Message":"Sequenced [Parallel 1] called for execution."}
{"RecordedAt":"2022-11-05T20:42:00.3852726+02:00","MessageType":5,"Message":"Sequenced [Parallel 2.1] called for execution."}
{"RecordedAt":"2022-11-05T20:42:00.3852768+02:00","MessageType":5,"Message":"Sequenced [Parallel 3] called for execution."}
{"RecordedAt":"2022-11-05T20:42:00.385442+02:00","MessageType":5,"Message":"Job [Parallel 2] was executed on lane [9]. Started: 11/5/2022 8:41:58 PM, Ended: 11/5/2022 8:42:00 PM, Duration: 00:00:02.0079354"}
{"RecordedAt":"2022-11-05T20:42:00.3855727+02:00","MessageType":5,"Message":"Job [Parallel 1] was executed on lane [10]. Started: 11/5/2022 8:41:58 PM, Ended: 11/5/2022 8:42:00 PM, Duration: 00:00:02.0079728"}
{"RecordedAt":"2022-11-05T20:42:00.3856681+02:00","MessageType":5,"Message":"Job [Parallel 3.1] was executed on lane [5]. Started: 11/5/2022 8:41:58 PM, Ended: 11/5/2022 8:42:00 PM, Duration: 00:00:02.0084814"}
{"RecordedAt":"2022-11-05T20:42:00.3856844+02:00","MessageType":5,"Message":"Job [Parallel 2.1] was executed on lane [6]. Started: 11/5/2022 8:41:58 PM, Ended: 11/5/2022 8:42:00 PM, Duration: 00:00:02.0079332"}
{"RecordedAt":"2022-11-05T20:42:00.3857071+02:00","MessageType":5,"Message":"Job [Parallel 3] was executed on lane [8]. Started: 11/5/2022 8:41:58 PM, Ended: 11/5/2022 8:42:00 PM, Duration: 00:00:02.0080272"}
{"RecordedAt":"2022-11-05T20:42:00.4329664+02:00","MessageType":5,"Message":"Sequenced [Parallel 1.1] called for execution."}
{"RecordedAt":"2022-11-05T20:42:00.433013+02:00","MessageType":5,"Message":"Job [Parallel 1.1] was executed on lane [7]. Started: 11/5/2022 8:41:58 PM, Ended: 11/5/2022 8:42:00 PM, Duration: 00:00:02.0087997"}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.4 377 11/5/2022
1.0.3 342 11/4/2022
1.0.2 332 11/4/2022
1.0.1 342 11/4/2022
1.0.0 349 11/4/2022