[Middleware] C#/.NET using GZY.Quartz.MUI to build a visual scheduled task panel

[Middleware] C#/.NET using GZY.Quartz.MUI to build a visual scheduled task panel

Help developers set scheduled tasks through a panel, mainly aiming to be like SwaggerUI, with minimal project intrusion, only requiring the UI component to be injected in Startup

Last updated 5/26/2022 8:17 PM
黑哥聊dotNet
2 min read
Category
.NET
Tags
.NET C#

Preface

GZY.Quartz.MUI is an open-source ASP.NET Core project hosted on GitHub. It aims to help developers set up scheduled tasks through a panel, much like SwaggerUI, with minimal project intrusion—just inject the UI component in Startup.

Official URL: https://www.cnblogs.com/GuZhenYin/p/15745002.html

Main Features

  1. Adds local JSON persistence for scheduled tasks, no database required.

  2. Allows direct invocation of local class methods without needing WebAPI endpoints.

How to Use?

Step 1: Open Visual Studio and create a new .NET project. Here, I'm using .NET Core Web API for demonstration.

Step 2: Install the GZY.Quartz.MUI package via NuGet:

Step 3: Add the GZY.Quartz.MUI service in ConfigureServices of StartUp.cs:

public void ConfigureServices(IServiceCollection services)
{

    services.AddControllers();
    services.AddQuartzUI();
    services.AddQuartzClassJobs(); // Add local scheduled task access
    //  services.AddSingleton<TestJob>(); // Injection
}

Step 4: Enable the middleware:

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }

    app.UseRouting();
    app.UseQuartz(); // Add this line
    app.UseEndpoints(endpoints =>
    {
        endpoints.MapGet("/", async context =>
        {
            await context.Response.WriteAsync("Hello World!");
        });
    });
}

Finally, run the project and navigate to [your domain]/QuartzUI in the browser. The project should be set up successfully.

Brief Explanation

There are two types of scheduled tasks:

  • One is to directly call an API endpoint

Enter the API you want to schedule. Here I'm using a test endpoint I wrote.

  • The other is to call a local class

By referencing a local DLL, create a class that inherits IJobService.

Summary

This blog post describes setting up a visual scheduled task panel with GZY.Quartz.MUI.

Keep Exploring

Related Reading

More Articles