Galosys.Foundation.AspNetCore.Quartz 26.5.15.1

dotnet add package Galosys.Foundation.AspNetCore.Quartz --version 26.5.15.1
                    
NuGet\Install-Package Galosys.Foundation.AspNetCore.Quartz -Version 26.5.15.1
                    
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="Galosys.Foundation.AspNetCore.Quartz" Version="26.5.15.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Galosys.Foundation.AspNetCore.Quartz" Version="26.5.15.1" />
                    
Directory.Packages.props
<PackageReference Include="Galosys.Foundation.AspNetCore.Quartz" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Galosys.Foundation.AspNetCore.Quartz --version 26.5.15.1
                    
#r "nuget: Galosys.Foundation.AspNetCore.Quartz, 26.5.15.1"
                    
#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.
#:package Galosys.Foundation.AspNetCore.Quartz@26.5.15.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Galosys.Foundation.AspNetCore.Quartz&version=26.5.15.1
                    
Install as a Cake Addin
#tool nuget:?package=Galosys.Foundation.AspNetCore.Quartz&version=26.5.15.1
                    
Install as a Cake Tool

Galosys.Foundation.AspNetCore.Quartz

成熟度: 🟡 可用 — 功能完整,测试或文档可能不完善

简介

Galosys.Foundation.AspNetCore.Quartz 是 ASP.NET Core 集成的 Quartz 定时任务调度模块,提供 RESTful API 接口来管理定时任务的生命周期,支持动态暂停、恢复、触发和调度更新。

功能特性

  • 任务管理 API - 通过 HTTP 接口管理定时任务
  • 暂停/恢复 - 动态暂停和恢复任务执行
  • 立即触发 - 手动触发任务执行一次
  • 调度更新 - 动态修改 Cron 表达式
  • 任务删除 - 移除不需要的任务
  • 任务列表 - 查询所有已注册的任务

安装

<PackageReference Include="Galosys.Foundation.AspNetCore.Quartz" Version="x.x.x" />

使用

注册服务

// Program.cs
services.AddQuartz(); // 注册 Quartz 调度服务

创建定时任务

using Quartz;

public class DataSyncJob : QuartzJob
{
    public DataSyncJob(ILoggerFactory loggerFactory) : base(loggerFactory) { }

    protected override async Task ExecuteAsync(IJobExecutionContext context)
    {
        // 同步数据逻辑
        await Task.Delay(1000);
    }
}

配置任务(appsettings.json)

{
  "Job": {
    "Configs": [
      {
        "Id": "1",
        "Type": "DataSyncJob",
        "Assembly": "MyApp.Jobs",
        "Name": "数据同步任务",
        "Cron": "0 0/5 * * * ?"
      }
    ]
  }
}

REST API 接口

模块自动注册 QuartzService 控制器,提供以下接口:

方法 路径 说明
POST /api/quartz/pause 暂停任务
POST /api/quartz/resume 恢复任务
POST /api/quartz/runonce 立即执行一次
POST /api/quartz/reschedule 更新调度时间
POST /api/quartz/delete 删除任务
GET /api/quartz/list 获取任务列表
暂停任务
POST /api/quartz/pause
Content-Type: application/json

{
  "jobName": "MyApp.Jobs.DataSyncJob"
}
恢复任务
POST /api/quartz/resume
Content-Type: application/json

{
  "jobName": "MyApp.Jobs.DataSyncJob"
}
立即触发
POST /api/quartz/runonce
Content-Type: application/json

{
  "jobName": "MyApp.Jobs.DataSyncJob"
}
更新调度
POST /api/quartz/reschedule
Content-Type: application/json

{
  "jobName": "MyApp.Jobs.DataSyncJob",
  "cron": "0 0/10 * * * ?"
}

核心类

说明
QuartzService REST API 控制器,提供任务管理接口
QuartzJob 任务基类,继承此类实现具体业务逻辑

依赖项目

  • Galosys.Foundation.AspNetCore
  • Galosys.Foundation.AspNetCore.DynamicApi
  • Galosys.Foundation.Quartz

目录结构

Galosys.Foundation.AspNetCore.Quartz/
├── Base/
│   └── Application/
│       └── QuartzService.cs    # REST API 控制器
├── Galosys.Foundation.AspNetCore.Quartz.csproj
└── README.md

注意事项

  • 任务名称格式为 {Assembly}.{TypeName}
  • Cron 表达式遵循 Quartz 标准格式
  • API 接口默认允许匿名访问
  • 任务执行日志通过 ILogger 记录
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Galosys.Foundation.AspNetCore.Quartz:

Package Downloads
Galosys.AspNetCore.Application

Galosys.Foundation快速开发库

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
26.5.15.1 30 5/15/2026
26.5.12.3 73 5/12/2026
26.5.12.2 77 5/12/2026
26.4.27.1-rc1 92 4/26/2026
26.4.25.1-rc1 85 4/25/2026
26.4.22.2-rc7 89 4/22/2026
26.4.22.2-rc6 85 4/22/2026
26.4.22.2-rc4 90 4/22/2026
26.4.22.2-rc3 91 4/22/2026
26.4.19.1-rc1 96 4/19/2026
26.1.30.1-rc1 159 1/30/2026
26.1.29.1 165 1/29/2026
26.1.28.5 178 1/28/2026
26.1.28.4 166 1/28/2026
26.1.28.2 179 1/28/2026
26.1.23.6 175 1/23/2026
26.1.21.1 162 1/21/2026
26.1.2.1 175 1/2/2026
26.1.1.1 175 1/1/2026
25.12.12.4 210 12/12/2025
Loading failed