using Abp.Hangfire;
using Abp.Hangfire.Configuration;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Abp.Modules;
using Abp.Reflection.Extensions;
using YGNT.Exam.Configuration;

namespace YGNT.Exam.Web.Host.Startup
{
    [DependsOn(
       typeof(ExamWebCoreModule),
       typeof(AbpHangfireAspNetCoreModule))]
    public class ExamWebHostModule : AbpModule
    {
        private readonly IWebHostEnvironment _env;
        private readonly IConfigurationRoot _appConfiguration;

        public ExamWebHostModule(IWebHostEnvironment env)
        {
            _env = env;
            _appConfiguration = env.GetAppConfiguration();
        }

        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(typeof(ExamWebHostModule).GetAssembly());
        }

        public override void PreInitialize()
        {
            //使用Hangfire代替原后台任务
            Configuration.BackgroundJobs.UseHangfire();
        }
    }
}
