using Hotline.Orders;
using Microsoft.AspNetCore.Http;
using Quartz;

namespace Hotline.Application.Jobs
{
    /// <summary>
    /// 自动派单
    /// </summary>
    public class SendOrderJob : IJob, IDisposable
    {
        private readonly IOrderDomainService _orderDomainService;

        public SendOrderJob(IOrderDomainService orderDomainService)
        {
            _orderDomainService = orderDomainService;
        }
        
        public async Task Execute(IJobExecutionContext context)
        {
            Console.WriteLine($"{nameof(SendOrderJob)} 执行, {DateTime.Now}");

            await _orderDomainService.TriggerAverageOrder(context.CancellationToken);
        }

        /// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
        public void Dispose()
        {
        }
    }
}
