CsharpConsJobLib 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package CsharpConsJobLib --version 1.0.2                
NuGet\Install-Package CsharpConsJobLib -Version 1.0.2                
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="CsharpConsJobLib" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CsharpConsJobLib --version 1.0.2                
#r "nuget: CsharpConsJobLib, 1.0.2"                
#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 CsharpConsJobLib as a Cake Addin
#addin nuget:?package=CsharpConsJobLib&version=1.0.2

// Install CsharpConsJobLib as a Cake Tool
#tool nuget:?package=CsharpConsJobLib&version=1.0.2                

CsharpConsJob Library

CsharpConsJob is a lightweight C# Library written by Berka Ayowa that helps you create & schedule C# jobs

Latest version 1.0.3

##We recommended installing the latest library version 1.0.3 from Nuget, search CsharpConsJobLib from nuget, and install.

static void Main(string[] args)
{

    //Setting events
    //Setup a Function to call if any error occured 'OnException'
    JobRegistry.OnException += OnException;

    //This 'OnLogEvent' method is depreciated
    //JobRegistry.OnLogEvent += OnLog;

    //Setup a Function to print job activy on the console 'OnJobLog'
    JobRegistry.OnJobLogEvent += OnJobLog;

    //Adding job in chain
    JobRegistry.Instance

    //Every second
    //.Add<NotificationReport>("* * * ? * * *")

    //Every x seconds e.g every 30 seconds
    .Add<Email>("*/30 * * ? * * *")

    //Every mimutes
    //.Add<DaillyReport>("0 * * ? * * *")

    //Every x minutes e.g Every 2 minutes
    //.Add<SMS>("0 */1 * ? * * *")

    //Every Hour
    //.Add<BalanceStatement>("0 0 * ? * * *")

    //Every x hour e.g Every 2 hours
    //.Add<BalanceStatement>("0 0 */2 ? * * *")
    //.Add<NotificationReport>("0 0 14 19 * * *")

    //Every day at x hours e.g Every at 00:00
    //.Add<NotificationReport>("0 0 9 ? * * *")

    //Every day at x time e.g Every at 00:30
    //.Add<NotificationReport>("0 0 9:35 ? * * *")

    //Add a list of jobs , this functionality is available in version 1.0.2 up
    .Add("0 0 9:50 ? * * *", new List<Job>(){ new NotificationReport(), new BalanceStatement()})

    //CmdCommand.Execute is available in version 1.0.3 up
    //Run cmd command every x seconds e.g executing 'ipconfig' command every 10 seconds
    .Add("*/10 * * ? * * *", CmdCommand.Execute("ipconfig", (string result) =>
    {
        // Display the command output.
        Console.WriteLine(result);
    }))

    //Run cmd command every x seconds e.g cd in test folder and run git pull command every 10 seconds
    .Add("*/15 * * ? * * *", CmdCommand.Execute(@"cd C:\test&git pull", (string result) => {
        // Display the command output.
        Console.WriteLine(result);
    }))


    .Run();

}

public static void OnException(object source, Exception exception)
{
    //Disaply error if any occures
    Console.WriteLine(DateTime.Now.ToString() + " - Exception - " + exception.Message);
}

public static void OnLog(object obj)
{
    //You can alos log this to a file or just onscreen log
    Console.WriteLine(DateTime.Now.ToString() + " - " + obj.ToString());
}

public static void OnJobLog(LogType logType, object obj)
{
    //You can alos log this to a file or just onscreen log
    Console.WriteLine(DateTime.Now.ToString() + " - " + obj.ToString());
}
Property
Name Description Example
Add Add job class to the job to the registry . JobRegistry.Instance.Add<NotificationReport>("* * * ? * *", Job)
Events
Name Description Example
OnException This event get triggered when any error occures JobRegistry.OnException += OnException
OnLogEvent This event get triggered to notify current job actions JobRegistry.OnLogEvent += OnLog
Action
Name Description Example
Run This action starts runing the jobs availe in the job registry JobRegistry.Instance.Run();

For generating more cron expresions you can check here or email us on ayowaberka@gmail.com for assistance or just to say hello 😃

Click here to donate for supporting us to keep improving this library

Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.