Files

57 lines
1.9 KiB
C#
Raw Permalink Normal View History

namespace QYZH.InteractiveMagazine.Models.Settings;
/// <summary>
/// Hangfire 定时任务配置集合(对应 appsettings.json 中的 "HangfireJobs" 节点)
/// </summary>
public class HangfireJobSettings
{
/// <summary>
/// 定时任务列表,每一项对应一个 Hangfire RecurringJob
/// </summary>
public List<HangfireJobConfig> Jobs { get; set; } = new();
}
/// <summary>
/// 单个定时任务配置
/// </summary>
public class HangfireJobConfig
{
/// <summary>
/// 任务名称Hangfire Dashboard 中展示的唯一标识,建议英文短横线命名,如 "sample-job"
/// </summary>
public string Name { get; set; } = "";
/// <summary>
/// Job 类的完整类型名称(含命名空间,如 "QYZH.InteractiveMagazine.WorkService.Jobs.SampleJob"
/// </summary>
public string JobType { get; set; } = "";
/// <summary>
/// 要调用的方法名称(默认 "ExecuteAsync",方法必须为 public 无参 Task
/// </summary>
public string MethodName { get; set; } = "ExecuteAsync";
/// <summary>
/// Cron 表达式,控制执行频率。常用示例:
/// "* * * * *" 每分钟
/// "*/5 * * * *" 每5分钟
/// "0 * * * *" 每小时整点
/// "0 0 * * *" 每天午夜
/// "0 9 * * *" 每天上午9点
/// "0 9 * * 1" 每周一上午9点
/// "0 0 1 * *" 每月1号午夜
/// 格式:分 时 日 月 星期5位不支持秒和年
/// </summary>
public string Cron { get; set; } = "";
/// <summary>
/// 是否启用此任务(设为 false 将从 Hangfire 中移除该任务)
/// </summary>
public bool Enabled { get; set; } = true;
/// <summary>
/// 备注说明(仅供阅读理解,不参与运行逻辑)
/// </summary>
public string? Description { get; set; }
}