diff --git a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs index 01967dd..217919f 100644 --- a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs +++ b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; using Quartz; using SolarPower.Models; @@ -21,24 +22,27 @@ namespace SolarPower.Quartz.Jobs private readonly INoticeScheduleRepository noticeScheduleRepository; private readonly IUserRepository userRepository; private readonly IPowerStationRepository powerStationRepository; + private readonly IConfiguration Configuration; - public ExceptionSchedule(ILogger logger, IOverviewRepository overviewRepository,INoticeScheduleRepository noticeScheduleRepository,IUserRepository userRepository,IPowerStationRepository powerStationRepository) + public ExceptionSchedule(ILogger logger, IOverviewRepository overviewRepository,INoticeScheduleRepository noticeScheduleRepository,IUserRepository userRepository,IPowerStationRepository powerStationRepository, IConfiguration Configuration) { this.logger = logger; this.overviewRepository = overviewRepository; this.noticeScheduleRepository = noticeScheduleRepository; this.userRepository = userRepository; this.powerStationRepository = powerStationRepository; + this.Configuration = Configuration; } public async Task Execute(IJobExecutionContext context) { try { + var ExceptionTimes = this.Configuration.GetValue("ExceptionTimes"); var ExceptionList = await overviewRepository.GetEmailExceptionList(); if(ExceptionList.Count > 0 ) { - var ExceptionListex = ExceptionList.Where(x => x.normalTime == "1970-01-01 08:00:00" && DateTime.Now.Subtract(DateTime.Parse(x.dev_time)).Hours >= 4).ToList(); + var ExceptionListex = ExceptionList.Where(x => x.normalTime == "1970-01-01 08:00:00" && DateTime.Now.Subtract(DateTime.Parse(x.dev_time)).Minutes >= ExceptionTimes).ToList(); foreach (var Exception in ExceptionListex) diff --git a/SolarPower/appsettings.Development.json b/SolarPower/appsettings.Development.json index a4eacb3..241b221 100644 --- a/SolarPower/appsettings.Development.json +++ b/SolarPower/appsettings.Development.json @@ -37,7 +37,9 @@ "UserName": "shanghohui@gmail.com", "Password": "wswgnluvoodfexrb", "EnableSsl": true - } + }, + "ExceptionTimes": 240 + //"SMTPConfig": { // "Host": "smtp.gmail.com", // "Port": 25, diff --git a/SolarPower/appsettings.json b/SolarPower/appsettings.json index ef0a5ff..5b53310 100644 --- a/SolarPower/appsettings.json +++ b/SolarPower/appsettings.json @@ -38,5 +38,6 @@ "UserName": "ficgreen01@gmail.com", "Password": "qwe2015qwe", "EnableSsl": true - } + }, + "ExceptionTimes": 240 }