using System;
using System.Threading;
using System.Threading.Tasks;
using Hangfire;
using JiShe.CollectBus.Common.Consts;
using JiShe.CollectBus.ScheduledMeterReading;
using Microsoft.Extensions.Logging;
using Volo.Abp.BackgroundWorkers.Hangfire;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Uow;

namespace JiShe.CollectBus.Workers
{
    /// <summary>
    /// 构建待处理的下发指令任务处理
    /// </summary>
    public class CreateToBeIssueTaskWorker : HangfireBackgroundWorkerBase, ITransientDependency, ICollectWorker
    {
        private readonly ILogger<CreateToBeIssueTaskWorker> _logger;
        private readonly IScheduledMeterReadingService _scheduledMeterReadingService;

        /// <summary>
        /// Initializes a new instance of the <see cref="CreateToBeIssueTaskWorker"/> class.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="scheduledMeterReadingService">定时任务</param>
        public CreateToBeIssueTaskWorker(ILogger<CreateToBeIssueTaskWorker> logger, IScheduledMeterReadingService scheduledMeterReadingService)
        {
            _logger = logger;
            RecurringJobId = nameof(CreateToBeIssueTaskWorker);
            CronExpression = "0 0/1 * * * *";
            TimeZone = TimeZoneInfo.Local;
            this._scheduledMeterReadingService = scheduledMeterReadingService;
        }


        public override async Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
        {
            _logger.LogError($"{DateTime.Now}");
           // await _scheduledMeterReadingService.CreateToBeIssueTasks();
        }
    }
}
