Files
coreshoppro/CoreCms.Net.Task/HangfireDispose.cs

81 lines
5.2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/***********************************************************************
* Project: CoreCms.Net *
* Web: https://CoreCms.Net *
* ProjectName: 核心内容管理系统 *
* Author: 大灰灰 *
* Email: JianWeie@163.com *
* CreateTime: 2020-08-27 2:09:38
* Description: 暂无
***********************************************************************/
using System;
using Hangfire;
namespace CoreCms.Net.Task
{
public class HangfireDispose
{
#region
public static void HangfireService()
{
//Fire - And - forget发布 / 订阅)
//这是一个主要的后台任务类型,持久化消息队列会去处理这个任务。当你创建了一个发布 / 订阅任务,该任务会被保存到默认队列里面(默认队列是"Default"但是支持使用多队列。多个专注的工作者Worker会监听这个队列并且从中获取任务并且完成任务。
//BackgroundJob.Enqueue(() => Console.WriteLine("Fire-and-forget"));
//延迟
//如果想要延迟某些任务的执行,可以是用以下任务。在给定延迟时间后,任务会被排入队列,并且和发布 / 订阅任务一样执行。
//BackgroundJob.Schedule(() => Console.WriteLine("Delayed"), TimeSpan.FromDays(1));
//循环
//按照周期性小时天等来调用方法请使用RecurringJob类。在复杂的场景您可以使用CRON表达式指定计划时间来处理任务。
//RecurringJob.AddOrUpdate(() => Console.WriteLine("Daily Job"), Cron.Daily);
//连续
//连续性允许您通过将多个后台任务链接在一起来定义复杂的工作流。
//var id = BackgroundJob.Enqueue(() => Console.WriteLine("Hello, "));
//BackgroundJob.ContinueWith(id, () => Console.WriteLine("world!"));
//这里呢就是需要触发的方法 "0/10 * * * * ? " 可以自行搜索cron表达式 代表循环的规律很简单
//CancelOrderJob代表你要触发的类 Execute代表你要触发的方法
//自动取消订单任务
RecurringJob.AddOrUpdate<AutoCancelOrderJob>("AutoCancelOrderJob", s => s.Execute(), "0 0/5 * * * ? ", new RecurringJobOptions { TimeZone = TimeZoneInfo.Local }); // 每5分钟取消一次订单
//自动完成订单任务
RecurringJob.AddOrUpdate<CompleteOrderJob>("CompleteOrderJob", s => s.Execute(), "0 0 0/1 * * ? ", new RecurringJobOptions { TimeZone = TimeZoneInfo.Local }); // 每小时自动完成订单
//自动评价订单任务
RecurringJob.AddOrUpdate<EvaluateOrderJob>("EvaluateOrderJob", s => s.Execute(), "0 0 0/1 * * ? ", new RecurringJobOptions { TimeZone = TimeZoneInfo.Local }); // 每小时自动完成订单
//自动签收订单任务
RecurringJob.AddOrUpdate<AutoSignOrderJob>("AutoSignOrderJob", s => s.Execute(), "0 0 0/1 * * ? ", new RecurringJobOptions { TimeZone = TimeZoneInfo.Local }); // 每小时自动完成订单
//催付款订单
RecurringJob.AddOrUpdate<RemindOrderPayJob>("RemindOrderPayJob", s => s.Execute(), "0 0/5 * * * ? ", new RecurringJobOptions { TimeZone = TimeZoneInfo.Local }); // 每5分钟催付款订单
//拼团自动取消到期团(每分钟执行一次)
RecurringJob.AddOrUpdate<AutoCanclePinTuanJob>("AutoCanclePinTuanJob", s => s.Execute(), "0 0/2 * * * ? ", new RecurringJobOptions { TimeZone = TimeZoneInfo.Local }); // 每分钟取消一次订单
//每天凌晨5点定期清理7天前操作日志
RecurringJob.AddOrUpdate<RemoveOperationLogJob>("RemoveOperationLogJob", s => s.Execute(), "0 0 5 * * ? ", new RecurringJobOptions { TimeZone = TimeZoneInfo.Local }); // 每天5点固定时间清理一次
//定时刷新获取微信AccessToken
RecurringJob.AddOrUpdate<RefreshWeChatAccessTokenJob>("RefreshWeChatAccessTokenJob", s => s.Execute(), "0 0/4 * * * ? ", new RecurringJobOptions { TimeZone = TimeZoneInfo.Local }); // 每2分钟刷新获取微信AccessToken
//定时清理用户连续签到信息
RecurringJob.AddOrUpdate<ClearUserContinuousCheckInJob>("ClearUserContinuousCheckInJob", s => s.Execute(), "0 0 0 */1 * ? ", new RecurringJobOptions { TimeZone = TimeZoneInfo.Local }); // 每天0点执行。
//自动取消服务器订单任务
RecurringJob.AddOrUpdate<AutoCancelServiceOrderJob>("AutoCancelServiceOrderJob", s => s.Execute(), "0 0/5 * * * ? ", new RecurringJobOptions { TimeZone = TimeZoneInfo.Local }); // 每5分钟取消一次订单
//定时更新微信支付平台证书
RecurringJob.AddOrUpdate<AutoRefreshPlatformCertificateJob>("AutoRefreshPlatformCertificateJob", s => s.Execute(), "0 0 6 * * ? ", new RecurringJobOptions { TimeZone = TimeZoneInfo.Local }); // 每天凌晨6点执行首次可以自主进入定时任务页面手动执行一次
}
#endregion
}
}