Browse Source

Merge pull request #473 from colinin/5.1.1

fix(tasks): 成功执行一次作业需要重置重试次数
pull/474/head
yx lin 4 years ago
committed by GitHub
parent
commit
6aec6d86d3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 33
      aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/Templates/JobExceptionHandlingTemplateDefinitionProvider.cs
  2. 7
      aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/Templates/JobExceptionHandlingTemplates.cs
  3. 51
      aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/Templates/JobExceptionNotifier.tpl
  4. 3
      aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/Internal/JobExecutedEvent.cs

33
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<BackgroundTasksResource>(name);
}
}
}

7
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";
}
}

51
aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/Templates/JobExceptionNotifier.tpl

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>{{ model.title }}</title>
</head>
<body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4" offset="0">
<table width="95%" cellpadding="0" cellspacing="0" style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">
<tr>
<td>
<br />
<b><font color="#0B610B">{{ L "JobExecuteError" }}</font></b>
<hr size="2" width="100%" align="center" />
</td>
</tr>
<tr>
<td>
<ul>
{{ if model.tenantname }}
<li>{{ L "TenantName" }}&nbsp;:&nbsp;{{ model.tenantname }}</li>
{{ end }}
<li>{{ L "JobGroup" }}&nbsp;:&nbsp;{{ model.group }}</li>
<li>{{ L "JobName" }}&nbsp;:&nbsp;{{ model.name }}</li>
<li>{{ L "JobId" }}&nbsp;:&nbsp;{{ model.id }}</li>
<li>{{ L "JobType" }}&nbsp;:&nbsp;{{ model.type }}</li>
<li>{{ L "TriggerTime" }}&nbsp;:&nbsp;{{ model.triggertime }}</li>
</ul>
</td>
</tr>
<tr>
<td>
<b><font color="#0B610B">{{ L "ErrorMessage" }}</font></b>
<hr size="2" width="100%" align="center" />
</td>
</tr>
<tr>
<td>
<pre style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">{{ model.message }}</pre>
<br />
</td>
</tr>
<tr>
<td>
<br />
<b style="float: right"><font color="#0B610B">{{ model.footer }}</font></b>
<hr size="2" width="100%" align="center" />
</td>
</tr>
</table>
</body>
</html>

3
aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/Internal/JobExecutedEvent.cs

@ -70,6 +70,9 @@ public class JobExecutedEvent : JobEventBase<JobExecutedEvent>, ITransientDepend
}
else
{
// 成功一次重置重试次数
job.TryCount = 0;
// 所有任务达到上限则标记已完成
if (job.MaxCount > 0 && job.TriggerCount >= job.MaxCount)
{

Loading…
Cancel
Save