ASP.NET MVC Hangfire Get Collection of Jobs with details

1.5k views Asked by At

I'm using Hangfire in my ASP.NET application to execute methodos in the background but I need to create my own process monitor, so I need to get (select) a collection of Jobs, making filters by date, status, etc ... How can I do this?

2

There are 2 answers

1
a-man On

Did you try to get jobs from database? Hangfire can store them if you configure it in your Startup class.

select * from [HangFire].[Job]
0
Simsons On

Use Hangfire JobStorage

var recurringJobs = Hangfire.JobStorage.Current.GetConnection().GetRecurringJobs();

You can use this to return from a controller.

public ActionResult Index()
        {
            var recurringJobs = Hangfire.JobStorage.Current.GetConnection().GetRecurringJobs();
            return View(recurringJobs);
        }

Then create your view (Right Click on Index > Add View). This will show the list of views.

Now you can write your script to sort/filter.