using AipGateway.API.Services;
using Quartz;

namespace AipGateway.API.Job
{
    public class AipFileJob : BaseJob
    {
        public override string cron => "* 10/30 * * * ?"; // 30분/00분 주기 작업 실행

        private readonly ILogger<AipFileJob> _log;
        public AipFileJob()
        {
            _log = LoggerFactory.Create(options => { }).CreateLogger<AipFileJob>();
        }

        public override Task Execute(IJobExecutionContext context)
        {
            try
            {
                AipFileApiService? aipFileService = ContainerService.provider.GetService<AipFileApiService>();
                if (aipFileService == null)
                {
                    _log.LogInformation("Not Found AipFileApiService...");
                }
                else
                {
                    _log.LogInformation("... Found AipFileApiService...Start.");
                    aipFileService.DownloadAipFileInformations();
                    _log.LogInformation("... Found AipFileApiService.....End.");
                }

                _log.LogInformation("AipFileJob:Execute");
            }
            catch (Exception ex)
            {
                _log.LogInformation("AipFileJob:Execute, {0}", ex.Message);
            }
            return Task.CompletedTask;
        }
    }

}
