diff --git a/CoreCms.Net.Configuration/AppSettingsConstVars.cs b/CoreCms.Net.Configuration/AppSettingsConstVars.cs
index a9a34ebb..3320ba23 100644
--- a/CoreCms.Net.Configuration/AppSettingsConstVars.cs
+++ b/CoreCms.Net.Configuration/AppSettingsConstVars.cs
@@ -119,6 +119,10 @@ namespace CoreCms.Net.Configuration
/// 登录密码
///
public static readonly string HangFirePassWord = AppSettingsHelper.GetContent("HangFire", "PassWord");
+ ///
+ /// 已经完成的任务过期时间,单位分钟(默认10080,7天时间)
+ ///
+ public static readonly int HangFireJobExpirationTimeOut = AppSettingsHelper.GetContent("HangFire", "JobExpirationTimeOut").ObjToInt(10080);
#endregion
@@ -146,7 +150,7 @@ namespace CoreCms.Net.Configuration
#endregion
- #region Swagger授权访问设置================================================================================
+ #region Swagger授权访问设置
///
/// Swagger文档默认访问路由地址
///
diff --git a/CoreCms.Net.Web.WebApi/CoreCms.Net.Web.WebApi.xml b/CoreCms.Net.Web.WebApi/CoreCms.Net.Web.WebApi.xml
index 8eae1e85..cce972d5 100644
--- a/CoreCms.Net.Web.WebApi/CoreCms.Net.Web.WebApi.xml
+++ b/CoreCms.Net.Web.WebApi/CoreCms.Net.Web.WebApi.xml
@@ -1571,6 +1571,41 @@
请求验证错误处理
+
+
+ 已完成的job设置过期,防止数据无限增长
+
+
+
+
+ 数据过期时间
+
+
+
+
+ 完成的项目过期状态处理
+
+
+
+
+
+ 状态名称
+
+
+
+
+ 应用状态
+
+
+
+
+
+
+ 不应用状态
+
+
+
+
微信公众号消息推送对接
diff --git a/CoreCms.Net.Web.WebApi/Infrastructure/SucceededStateExpireHandler.cs b/CoreCms.Net.Web.WebApi/Infrastructure/SucceededStateExpireHandler.cs
new file mode 100644
index 00000000..3360e5df
--- /dev/null
+++ b/CoreCms.Net.Web.WebApi/Infrastructure/SucceededStateExpireHandler.cs
@@ -0,0 +1,51 @@
+using Hangfire.States;
+using Hangfire.Storage;
+using System;
+
+namespace CoreCms.Net.Web.WebApi.Infrastructure
+{
+ ///
+ /// 已完成的job设置过期,防止数据无限增长
+ ///
+ public class SucceededStateExpireHandler : IStateHandler
+ {
+ ///
+ /// 数据过期时间
+ ///
+ public TimeSpan JobExpirationTimeout;
+
+ ///
+ /// 完成的项目过期状态处理
+ ///
+ ///
+ public SucceededStateExpireHandler(int jobExpirationTimeout)
+ {
+ JobExpirationTimeout = TimeSpan.FromMinutes(jobExpirationTimeout);
+ }
+
+ ///
+ /// 状态名称
+ ///
+ public string StateName => SucceededState.StateName;
+
+ ///
+ /// 应用状态
+ ///
+ ///
+ ///
+ public void Apply(ApplyStateContext context, IWriteOnlyTransaction transaction)
+ {
+ context.JobExpirationTimeout = JobExpirationTimeout;
+ }
+
+ ///
+ /// 不应用状态
+ ///
+ ///
+ ///
+ public void Unapply(ApplyStateContext context, IWriteOnlyTransaction transaction)
+ {
+ }
+ }
+
+}
diff --git a/CoreCms.Net.Web.WebApi/Program.cs b/CoreCms.Net.Web.WebApi/Program.cs
index 95d0192d..217d89e6 100644
--- a/CoreCms.Net.Web.WebApi/Program.cs
+++ b/CoreCms.Net.Web.WebApi/Program.cs
@@ -244,6 +244,10 @@ var hangfireOptions = new Hangfire.DashboardOptions
app.UseHangfireDashboard("/job", hangfireOptions); //可以改变Dashboard的url
HangfireDispose.HangfireService();
+//设置hangfire定时任务过期时间
+GlobalStateHandlers.Handlers.Add(new SucceededStateExpireHandler(AppSettingsConstVars.HangFireJobExpirationTimeOut));
+
+
#endregion
diff --git a/CoreCms.Net.Web.WebApi/appsettings.json b/CoreCms.Net.Web.WebApi/appsettings.json
index 35a7bb4b..b7be1943 100644
--- a/CoreCms.Net.Web.WebApi/appsettings.json
+++ b/CoreCms.Net.Web.WebApi/appsettings.json
@@ -10,8 +10,9 @@
},
//定时任务管理面板的账户密码
"HangFire": {
- "Login": "CoreShopProfessional",
- "PassWord": "uzmp0oq9wfbdeasygj647vr53"
+ "Login": "CoreShopProfessional", //登录账号
+ "PassWord": "uzmp0o3213217vr53", //登录密码
+ "JobExpirationTimeOut": "10080" //已经完成的任务过期时间,单位分钟(默认10080,7天时间)
},
//Swagger授权访问设置
"SwaggerConfig": {