using Masuit.Tools;
|
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Logging;
|
using System.Net.Mail;
|
using System.Net;
|
using System.Text;
|
using WIDESEA_Cache;
|
using WIDESEA_Core.Const;
|
using WIDESEA_DTO.WMS;
|
using WIDESEA_IServices;
|
using WIDESEAWCS_BasicInfoRepository;
|
|
namespace WIDESEA_StorageTaskServices
|
{
|
public class MyBackgroundService : IHostedService, IDisposable
|
{
|
private readonly ILogger<MyBackgroundService> _logger;
|
private readonly IStockInfoRepository _stockInfoRepository;
|
private readonly IDt_AreaInfoRepository _areaInfoRepository; //区域
|
private readonly IDt_TaskRepository _taskRepository;
|
private readonly IDt_StationManagerRepository _stationManagerRepository;
|
private readonly ISys_ConfigService _configService;
|
private readonly ILocationInfoRepository _locationRepository;
|
|
private Timer _timer;
|
|
public MyBackgroundService(ILogger<MyBackgroundService> logger, ILocationInfoRepository locationRepository, IStockInfoRepository stockInfoRepository, IDt_AreaInfoRepository areaInfoRepository, IDt_TaskRepository taskRepository, IDt_StationManagerRepository stationManagerRepository, ISys_ConfigService configService)
|
{
|
_logger = logger;
|
_locationRepository = locationRepository;
|
_stockInfoRepository = stockInfoRepository;
|
_areaInfoRepository = areaInfoRepository;
|
_taskRepository = taskRepository;
|
_stationManagerRepository = stationManagerRepository;
|
_configService = configService;
|
}
|
|
public Task StartAsync(CancellationToken cancellationToken)
|
{
|
_timer = new Timer(DoWork, null, TimeSpan.Zero, TimeSpan.FromMinutes(5));
|
return Task.CompletedTask;
|
}
|
|
private void DoWork(object state)
|
{
|
try
|
{
|
|
}
|
catch (Exception ex)
|
{
|
ConsoleHelper.WriteErrorLine($"错误信息:" + ex.Message);
|
}
|
}
|
|
public Task StopAsync(CancellationToken cancellationToken)
|
{
|
_logger.LogInformation("MyBackgroundService is stopping.");
|
_timer?.Change(Timeout.Infinite, 0);
|
return Task.CompletedTask;
|
}
|
|
public void Dispose()
|
{
|
_timer?.Dispose();
|
}
|
}
|
}
|