#region << 版 本 注 释 >>
/*----------------------------------------------------------------
* 命名空间:WIDESEAWCS_QuartzJob
* 创建者:胡童庆
* 创建时间:2024/8/2 16:13:36
* 版本:V1.0.0
* 描述:调度服务自动开启
*
* ----------------------------------------------------------------
* 修改人:
* 修改时间:
* 版本:V1.0.1
* 修改说明:
*
*----------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_QuartzJob.DeviceBase;
using WIDESEAWCS_QuartzJob.DTO;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.QuartzNet;
using WIDESEAWCS_QuartzJob.Service;
namespace WIDESEAWCS_QuartzJob.QuartzExtensions
{
///
/// 启动程序自动开启调度服务
///
public class QuartzJobHostedService : IHostedService
{
private readonly ISchedulerCenter _schedulerCenter;
private readonly ILogger _logger;
private readonly IDeviceInfoService _deviceInfoService;
private readonly IDispatchInfoService _dispatchInfoService;
private readonly IDeviceProtocolDetailService _deviceProtocolDetailService;
private readonly QuartzNetExtension _quartzNetExtension;
///
/// 启动程序自动开启调度服务
///
public QuartzJobHostedService(ILogger logger, IDeviceInfoService deviceInfoService, IDispatchInfoService dispatchInfoService, ISchedulerCenter schedulerCenter, IDeviceProtocolDetailService deviceProtocolDetailService, QuartzNetExtension quartzNetExtension)
{
_logger = logger;
_deviceInfoService = deviceInfoService;
_dispatchInfoService = dispatchInfoService;
_schedulerCenter = schedulerCenter;
_deviceProtocolDetailService = deviceProtocolDetailService;
_quartzNetExtension = quartzNetExtension;
}
///
/// 启动程序自动开启调度服务
///
///
///
public async Task StartAsync(CancellationToken cancellationToken)
{
await _quartzNetExtension.StartAsync();
}
///
/// 启动程序自动开启调度服务
///
public Task StopAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("Stop QuartzJob Service!");
return Task.CompletedTask;
}
}
}