Skip to content

SerbanApostol/Hangfire.RecurringJobAdmin

 
 

Repository files navigation

Hangfire.RecurringJobAdmin

dashboard

A simple dashboard to manage Hangfire's recurring jobs.

This repo is an extension for Hangfire based on Hangfire.RecurringJobAdmin package made by bamotav, thanks for your contribution to the community. It contains the following functionalities:

  • We can use RecurringJobAttribute stored in database and presented in the administrator.
public class RecurringJobTesting
{
    [RecurringJob("*/2 * * * *", "China Standard Time", "default", RecurringJobId = "Check-File-Exists")]
    public void CheckFileExists()
    {
       Console.WriteLine("Check File Exists");
    }
}
  • We can use DisableConcurrentlyJobExecution, this attribute allows you to not execute a task if it is already running.
public class RecurringJobTesting
{
    [DisableConcurrentlyJobExecution("CheckFileExists")]
    public void CheckFileExists()
    {
       Console.WriteLine("Check File Exists");
    }
    
    [DisableConcurrentlyJobExecution("ValidateProcess", 0, 10, "It is not allowed to perform multiple same tasks.")]
    [RecurringJob("*/2 * * * *", "China Standard Time", "default", RecurringJobId = "Validate-Process")]
    public void ValidateProcess()
    {
        Console.WriteLine("Validate Process");
    }
}
  • We can create, edit jobs.

create

  • We can start, stop jobs at runtime.

jobAgent

  • So we can also start or stop the job using JobAgent static class.
   JobAgent.StopBackgroundJob("Enter the Job Id");
   
   JobAgent.StartBackgroundJob("Enter the Job Id");
   
   JobAgent.RemoveBackgroundJob("Enter the Job Id");
   
   //Get all stopped jobs:
   var StoppedJobs = JobAgent.GetAllJobStopped();
   
  • We have a component to generate cron expression, inspired by the previous, Vue one made by @JossyDevers.

jobAgent

Instructions

Install a package from Nuget.

Install-Package RBC.Hangfire.RecurringJobAdmin

Then add this in your code:

For DotNetCore :

for service side:

services.AddHangfire(config => config.UseSqlServerStorage(Configuration.GetConnectionString("HangfireConnection"))
                                                 .UseRecurringJobAdmin(typeof(Startup).Assembly))

recommended:

services.AddHangfire(config => config.UseSqlServerStorage(Configuration.GetConnectionString("HangfireConnection"))
                                                 .UseRecurringJobAdmin(typeof(Startup).Assembly, typeof(Hangfire.Server.PerformContext).Assembly))

For NetFramework :

for startup side:

GlobalConfiguration.Configuration.UseSqlServerStorage("HangfireConnection").UseRecurringJobAdmin(typeof(Startup).Assembly)

recommended:

GlobalConfiguration.Configuration.UseSqlServerStorage("HangfireConnection").UseRecurringJobAdmin(typeof(Startup).Assembly, typeof(Hangfire.Server.PerformContext).Assembly)

Credits

  • Braulio Alvarez
  • Brayan Mota (bamotav)

Donation

If this project help you reduce time to develop, check out the fork source project: Hangfire.RecurringJobAdmin

License

Authored by: Serban Apostol (SerbanApostol)

This project is under MIT license. You can obtain the license copy here.

About

A dashboard to manage Hangfire's recurring jobs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 78.3%
  • HTML 21.7%