mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 17:13:26 +08:00
【新增】hangfire定时任务增加【已经完成的Job任务进行定时过期删除处理】。
This commit is contained in:
@@ -119,6 +119,10 @@ namespace CoreCms.Net.Configuration
|
|||||||
/// 登录密码
|
/// 登录密码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly string HangFirePassWord = AppSettingsHelper.GetContent("HangFire", "PassWord");
|
public static readonly string HangFirePassWord = AppSettingsHelper.GetContent("HangFire", "PassWord");
|
||||||
|
/// <summary>
|
||||||
|
/// 已经完成的任务过期时间,单位分钟(默认10080,7天时间)
|
||||||
|
/// </summary>
|
||||||
|
public static readonly int HangFireJobExpirationTimeOut = AppSettingsHelper.GetContent("HangFire", "JobExpirationTimeOut").ObjToInt(10080);
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -146,7 +150,7 @@ namespace CoreCms.Net.Configuration
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Swagger授权访问设置================================================================================
|
#region Swagger授权访问设置
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Swagger文档默认访问路由地址
|
/// Swagger文档默认访问路由地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1571,6 +1571,41 @@
|
|||||||
请求验证错误处理
|
请求验证错误处理
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="T:CoreCms.Net.Web.WebApi.Infrastructure.SucceededStateExpireHandler">
|
||||||
|
<summary>
|
||||||
|
已完成的job设置过期,防止数据无限增长
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="F:CoreCms.Net.Web.WebApi.Infrastructure.SucceededStateExpireHandler.JobExpirationTimeout">
|
||||||
|
<summary>
|
||||||
|
数据过期时间
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:CoreCms.Net.Web.WebApi.Infrastructure.SucceededStateExpireHandler.#ctor(System.Int32)">
|
||||||
|
<summary>
|
||||||
|
完成的项目过期状态处理
|
||||||
|
</summary>
|
||||||
|
<param name="jobExpirationTimeout"></param>
|
||||||
|
</member>
|
||||||
|
<member name="P:CoreCms.Net.Web.WebApi.Infrastructure.SucceededStateExpireHandler.StateName">
|
||||||
|
<summary>
|
||||||
|
状态名称
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:CoreCms.Net.Web.WebApi.Infrastructure.SucceededStateExpireHandler.Apply(Hangfire.States.ApplyStateContext,Hangfire.Storage.IWriteOnlyTransaction)">
|
||||||
|
<summary>
|
||||||
|
应用状态
|
||||||
|
</summary>
|
||||||
|
<param name="context"></param>
|
||||||
|
<param name="transaction"></param>
|
||||||
|
</member>
|
||||||
|
<member name="M:CoreCms.Net.Web.WebApi.Infrastructure.SucceededStateExpireHandler.Unapply(Hangfire.States.ApplyStateContext,Hangfire.Storage.IWriteOnlyTransaction)">
|
||||||
|
<summary>
|
||||||
|
不应用状态
|
||||||
|
</summary>
|
||||||
|
<param name="context"></param>
|
||||||
|
<param name="transaction"></param>
|
||||||
|
</member>
|
||||||
<member name="T:CoreCms.Net.Web.Controllers.WeChat.WeChatOffiaccountNotifyController">
|
<member name="T:CoreCms.Net.Web.Controllers.WeChat.WeChatOffiaccountNotifyController">
|
||||||
<summary>
|
<summary>
|
||||||
微信公众号消息推送对接
|
微信公众号消息推送对接
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
using Hangfire.States;
|
||||||
|
using Hangfire.Storage;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace CoreCms.Net.Web.WebApi.Infrastructure
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 已完成的job设置过期,防止数据无限增长
|
||||||
|
/// </summary>
|
||||||
|
public class SucceededStateExpireHandler : IStateHandler
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 数据过期时间
|
||||||
|
/// </summary>
|
||||||
|
public TimeSpan JobExpirationTimeout;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 完成的项目过期状态处理
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="jobExpirationTimeout"></param>
|
||||||
|
public SucceededStateExpireHandler(int jobExpirationTimeout)
|
||||||
|
{
|
||||||
|
JobExpirationTimeout = TimeSpan.FromMinutes(jobExpirationTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 状态名称
|
||||||
|
/// </summary>
|
||||||
|
public string StateName => SucceededState.StateName;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 应用状态
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <param name="transaction"></param>
|
||||||
|
public void Apply(ApplyStateContext context, IWriteOnlyTransaction transaction)
|
||||||
|
{
|
||||||
|
context.JobExpirationTimeout = JobExpirationTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 不应用状态
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <param name="transaction"></param>
|
||||||
|
public void Unapply(ApplyStateContext context, IWriteOnlyTransaction transaction)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -244,6 +244,10 @@ var hangfireOptions = new Hangfire.DashboardOptions
|
|||||||
app.UseHangfireDashboard("/job", hangfireOptions); //可以改变Dashboard的url
|
app.UseHangfireDashboard("/job", hangfireOptions); //可以改变Dashboard的url
|
||||||
HangfireDispose.HangfireService();
|
HangfireDispose.HangfireService();
|
||||||
|
|
||||||
|
//设置hangfire定时任务过期时间
|
||||||
|
GlobalStateHandlers.Handlers.Add(new SucceededStateExpireHandler(AppSettingsConstVars.HangFireJobExpirationTimeOut));
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,9 @@
|
|||||||
},
|
},
|
||||||
//定时任务管理面板的账户密码
|
//定时任务管理面板的账户密码
|
||||||
"HangFire": {
|
"HangFire": {
|
||||||
"Login": "CoreShopProfessional",
|
"Login": "CoreShopProfessional", //登录账号
|
||||||
"PassWord": "uzmp0oq9wfbdeasygj647vr53"
|
"PassWord": "uzmp0o3213217vr53", //登录密码
|
||||||
|
"JobExpirationTimeOut": "10080" //已经完成的任务过期时间,单位分钟(默认10080,7天时间)
|
||||||
},
|
},
|
||||||
//Swagger授权访问设置
|
//Swagger授权访问设置
|
||||||
"SwaggerConfig": {
|
"SwaggerConfig": {
|
||||||
|
|||||||
Reference in New Issue
Block a user