增加同步时间
This commit is contained in:
52
src/WMS.Web.Domain/QuartzJob/BoxQuartzJob.cs
Normal file
52
src/WMS.Web.Domain/QuartzJob/BoxQuartzJob.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Quartz;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Domain.IService;
|
||||
|
||||
namespace WMS.Web.Domain.QuartzJob
|
||||
{
|
||||
public class BoxQuartzJob : IJob
|
||||
{
|
||||
private readonly ILogger<BoxQuartzJob> _logger;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
private readonly IBoxService _boxService;
|
||||
|
||||
public BoxQuartzJob(ILogger<BoxQuartzJob> logger,
|
||||
IServiceScopeFactory serviceScopeFactory, IBoxService boxService)
|
||||
{
|
||||
this._logger = logger;
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
_boxService = boxService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行方法
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
//2.记录:开始时间
|
||||
var begindatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
_logger.LogInformation($"出库单-同步金蝶入库单数据:执行开始时间->{begindatetime}");
|
||||
//3.同步数据
|
||||
var result = await _boxService.Sync();
|
||||
//5.记录:结束时间
|
||||
var enddatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
_logger.LogInformation($"出库单-同步金蝶入库单数据:执行结束时间->{begindatetime}");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogInformation($"同步金蝶入库单数据:定时任务执行失败->{ex.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user