From 2b639f9382a734628ebc62fbc9f67ecf15ab3582 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Sun, 16 Jan 2022 00:30:11 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(tasks):=20=E6=88=90=E5=8A=9F=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E4=B8=80=E6=AC=A1=E4=BD=9C=E4=B8=9A=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E9=87=8D=E7=BD=AE=E9=87=8D=E8=AF=95=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LINGYUN/Abp/BackgroundTasks/Internal/JobExecutedEvent.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/Internal/JobExecutedEvent.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/Internal/JobExecutedEvent.cs index 1b461f2e9..c7862c176 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/Internal/JobExecutedEvent.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/Internal/JobExecutedEvent.cs @@ -70,6 +70,9 @@ public class JobExecutedEvent : JobEventBase, ITransientDepend } else { + // 成功一次重置重试次数 + job.TryCount = 0; + // 所有任务达到上限则标记已完成 if (job.MaxCount > 0 && job.TriggerCount >= job.MaxCount) { From c432343f5d0c42d063679f505031bc526c0ec1f3 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Sun, 16 Jan 2022 00:34:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(tasks):=20=E5=A2=9E=E5=8A=A0=E8=A2=AB?= =?UTF-8?q?=E5=BF=BD=E7=95=A5=E7=9A=84=E6=96=87=E6=9C=AC=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ptionHandlingTemplateDefinitionProvider.cs | 33 ++++++++++++ .../JobExceptionHandlingTemplates.cs | 7 +++ .../Templates/JobExceptionNotifier.tpl | 51 +++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/Templates/JobExceptionHandlingTemplateDefinitionProvider.cs create mode 100644 aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/Templates/JobExceptionHandlingTemplates.cs create mode 100644 aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/Templates/JobExceptionNotifier.tpl diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/Templates/JobExceptionHandlingTemplateDefinitionProvider.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/Templates/JobExceptionHandlingTemplateDefinitionProvider.cs new file mode 100644 index 000000000..350a4b5d1 --- /dev/null +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/Templates/JobExceptionHandlingTemplateDefinitionProvider.cs @@ -0,0 +1,33 @@ +using LINGYUN.Abp.BackgroundTasks.Localization; +using Volo.Abp.Localization; +using Volo.Abp.TextTemplating; + +namespace LINGYUN.Abp.BackgroundTasks.ExceptionHandling.Templates +{ + public class JobExceptionHandlingTemplateDefinitionProvider : TemplateDefinitionProvider + { + public override void Define(ITemplateDefinitionContext context) + { + context.Add(GetTemplateDefinitions()); + } + + private static TemplateDefinition[] GetTemplateDefinitions() + { + return new[] + { + new TemplateDefinition( + JobExceptionHandlingTemplates.JobExceptionNotifier, + displayName: L("TextTemplate:JobExceptionNotifier"), + localizationResource: typeof(BackgroundTasksResource) + ).WithVirtualFilePath( + "/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/Templates/JobExceptionNotifier.tpl", + isInlineLocalized: true) + }; + } + + private static ILocalizableString L(string name) + { + return LocalizableString.Create(name); + } + } +} diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/Templates/JobExceptionHandlingTemplates.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/Templates/JobExceptionHandlingTemplates.cs new file mode 100644 index 000000000..e84c51984 --- /dev/null +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/Templates/JobExceptionHandlingTemplates.cs @@ -0,0 +1,7 @@ +namespace LINGYUN.Abp.BackgroundTasks.ExceptionHandling.Templates +{ + public class JobExceptionHandlingTemplates + { + public const string JobExceptionNotifier = "Abp.BackgroundTasks.JobExceptionNotifier"; + } +} diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/Templates/JobExceptionNotifier.tpl b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/Templates/JobExceptionNotifier.tpl new file mode 100644 index 000000000..e840f3039 --- /dev/null +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/Templates/JobExceptionNotifier.tpl @@ -0,0 +1,51 @@ + + + + + {{ model.title }} + + + + + + + + + + + + + + + + + + +
+
+ {{ L "JobExecuteError" }} +
+
+
    + {{ if model.tenantname }} +
  • {{ L "TenantName" }} : {{ model.tenantname }}
  • + {{ end }} +
  • {{ L "JobGroup" }} : {{ model.group }}
  • +
  • {{ L "JobName" }} : {{ model.name }}
  • +
  • {{ L "JobId" }} : {{ model.id }}
  • +
  • {{ L "JobType" }} : {{ model.type }}
  • +
  • {{ L "TriggerTime" }} : {{ model.triggertime }}
  • +
+
+ {{ L "ErrorMessage" }} +
+
+
{{ model.message }}
+
+
+
+ {{ model.footer }} +
+
+ + \ No newline at end of file