重启调度任务
This commit is contained in:
parent
4b7920fc60
commit
bdae3f56af
@ -5,8 +5,9 @@
|
||||
|
||||
|
||||
<job name="EveryFiveMinuteJob" desc="30分钟抓取一次金蝶的采购订单" enabled="true" type="MyCode.Project.ScheduleTask.Jobs.EveryFiveMinuteJob,MyCode.Project.ScheduleTask" CronExpression="0 */30 * * * ?" />
|
||||
|
||||
|
||||
<job name="RetryTaskJob" desc="30分钟重新运行昨天之后失败的任务" enabled="true" type="MyCode.Project.ScheduleTask.Jobs.RetryTaskJobJob,MyCode.Project.ScheduleTask" CronExpression="0 */30 * * * ?" />
|
||||
|
||||
|
||||
</Jobs>
|
||||
<!--
|
||||
<job name="EveryTimeJob" desc="每3秒执行调度" enabled="true" type="MyCode.Project.ScheduleTask.Jobs.EveryJob,MyCode.Project.ScheduleTask" CronExpression="*/3 * * * * ?" />
|
||||
|
@ -1,17 +1,5 @@
|
||||
using Quartz;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using MyCode.Project.Services;
|
||||
using MyCode.Project.Infrastructure;
|
||||
using MyCode.Project.Infrastructure.UnityExtensions;
|
||||
using Microsoft.Practices.Unity;
|
||||
using System.Reflection;
|
||||
using MyCode.Project.Domain.Model;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using MyCode.Project.Services;
|
||||
using Quartz;
|
||||
|
||||
namespace MyCode.Project.ScheduleTask.Jobs
|
||||
{
|
||||
|
24
MyCode.Project.ScheduleTask/Jobs/RetryTaskJobJob.cs
Normal file
24
MyCode.Project.ScheduleTask/Jobs/RetryTaskJobJob.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using MyCode.Project.Services;
|
||||
using Quartz;
|
||||
|
||||
namespace MyCode.Project.ScheduleTask.Jobs
|
||||
{
|
||||
public class RetryTaskJobJob : IJob
|
||||
{
|
||||
private IWorkProcessService _workProcessService;
|
||||
|
||||
public RetryTaskJobJob(IPurchaseOrderService purchaseOrderService, IWorkProcessService workProcessService)
|
||||
{
|
||||
|
||||
_workProcessService = workProcessService;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void Execute(IJobExecutionContext context)
|
||||
{
|
||||
_workProcessService.RetryTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +92,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="JobsHelp.cs" />
|
||||
<Compile Include="Jobs\RetryTaskJobJob.cs" />
|
||||
<Compile Include="Jobs\EveryFiveMinuteJob.cs" />
|
||||
<Compile Include="Jobs\EveryPriority2Job.cs" />
|
||||
<Compile Include="Jobs\EveryOtherJob.cs" />
|
||||
|
@ -70,5 +70,10 @@ namespace MyCode.Project.Services
|
||||
/// 调度执行优先级=6的任务
|
||||
/// </summary>
|
||||
void ExecutePriority6();
|
||||
|
||||
/// <summary>
|
||||
/// 重试失败的任务
|
||||
/// </summary>
|
||||
void RetryTask();
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ using MyCode.Project.Domain.Message.Response.User;
|
||||
using MyCode.Project.Domain.Model;
|
||||
using MyCode.Project.Domain.Repositories;
|
||||
using MyCode.Project.Infrastructure.Common;
|
||||
using MyCode.Project.Infrastructure.Enumeration;
|
||||
using MyCode.Project.Infrastructure.Exceptions;
|
||||
using MyCode.Project.Infrastructure.Extensions;
|
||||
using MyCode.Project.OutSideService;
|
||||
@ -35,11 +36,13 @@ namespace MyCode.Project.Services.Implementation
|
||||
private IInvoiceOrderItemRepository _invoiceOrderItemRepository;
|
||||
private IInvoiceOrderRepository _invoiceOrderRepository;
|
||||
private ITiaoMaRepository _tiaoMaRepository;
|
||||
private ISysWorkProcessV2Repository _sysWorkProcessV2Repository;
|
||||
|
||||
public InvoiceOrderService(IPurchaseOrderRepository purchaseOrderRepository
|
||||
, IPurchaseOrderItemRepository purchaseOrderItemRepository
|
||||
, IInvoiceOrderItemRepository invoiceOrderItemRepository
|
||||
, IInvoiceOrderRepository invoiceOrderRepository
|
||||
, ISysWorkProcessV2Repository sysWorkProcessV2Repository
|
||||
, ITiaoMaRepository tiaoMaRepository
|
||||
, IWorkProcessService workProcessService
|
||||
, IKingDeeService kingDeeService)
|
||||
@ -48,6 +51,7 @@ namespace MyCode.Project.Services.Implementation
|
||||
_purchaseOrderRepository = purchaseOrderRepository;
|
||||
_invoiceOrderItemRepository = invoiceOrderItemRepository;
|
||||
_invoiceOrderRepository = invoiceOrderRepository;
|
||||
_sysWorkProcessV2Repository = sysWorkProcessV2Repository;
|
||||
_tiaoMaRepository = tiaoMaRepository;
|
||||
_workProcessService = workProcessService;
|
||||
_kingDeeService = kingDeeService;
|
||||
@ -354,5 +358,7 @@ namespace MyCode.Project.Services.Implementation
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -469,5 +469,23 @@ namespace MyCode.Project.Services.Implementation
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RetryTask(重试失败的任务)
|
||||
/// <summary>
|
||||
/// 重试失败的任务
|
||||
/// </summary>
|
||||
public void RetryTask()
|
||||
{
|
||||
DateTime today = DateTime.Now.Date.AddDays(-1);
|
||||
var list = _sysWorkProcessV2Repository.Queryable().Where(t => t.FuncStatus == 4 && t.RetryCount <= 10
|
||||
&& t.CreateTime >= today).OrderBy(t => t.EditTime).Take(20).ToList();
|
||||
list.ForEach(t =>
|
||||
{
|
||||
t.RetryCount = t.RetryCount + 1;
|
||||
t.FuncStatus = 0;
|
||||
});
|
||||
_sysWorkProcessV2Repository.Update(list);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user