將 異常時間 拉出 單位為分鐘

This commit is contained in:
b110212000 2021-10-01 17:36:48 +08:00
parent 7193826d63
commit 34891227ae
3 changed files with 12 additions and 5 deletions

View File

@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Quartz; using Quartz;
using SolarPower.Models; using SolarPower.Models;
@ -21,24 +22,27 @@ namespace SolarPower.Quartz.Jobs
private readonly INoticeScheduleRepository noticeScheduleRepository; private readonly INoticeScheduleRepository noticeScheduleRepository;
private readonly IUserRepository userRepository; private readonly IUserRepository userRepository;
private readonly IPowerStationRepository powerStationRepository; private readonly IPowerStationRepository powerStationRepository;
private readonly IConfiguration Configuration;
public ExceptionSchedule(ILogger<ExceptionSchedule> logger, IOverviewRepository overviewRepository,INoticeScheduleRepository noticeScheduleRepository,IUserRepository userRepository,IPowerStationRepository powerStationRepository) public ExceptionSchedule(ILogger<ExceptionSchedule> logger, IOverviewRepository overviewRepository,INoticeScheduleRepository noticeScheduleRepository,IUserRepository userRepository,IPowerStationRepository powerStationRepository, IConfiguration Configuration)
{ {
this.logger = logger; this.logger = logger;
this.overviewRepository = overviewRepository; this.overviewRepository = overviewRepository;
this.noticeScheduleRepository = noticeScheduleRepository; this.noticeScheduleRepository = noticeScheduleRepository;
this.userRepository = userRepository; this.userRepository = userRepository;
this.powerStationRepository = powerStationRepository; this.powerStationRepository = powerStationRepository;
this.Configuration = Configuration;
} }
public async Task Execute(IJobExecutionContext context) public async Task Execute(IJobExecutionContext context)
{ {
try try
{ {
var ExceptionTimes = this.Configuration.GetValue<int>("ExceptionTimes");
var ExceptionList = await overviewRepository.GetEmailExceptionList(); var ExceptionList = await overviewRepository.GetEmailExceptionList();
if(ExceptionList.Count > 0 ) 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) foreach (var Exception in ExceptionListex)

View File

@ -37,7 +37,9 @@
"UserName": "shanghohui@gmail.com", "UserName": "shanghohui@gmail.com",
"Password": "wswgnluvoodfexrb", "Password": "wswgnluvoodfexrb",
"EnableSsl": true "EnableSsl": true
} },
"ExceptionTimes": 240
//"SMTPConfig": { //"SMTPConfig": {
// "Host": "smtp.gmail.com", // "Host": "smtp.gmail.com",
// "Port": 25, // "Port": 25,

View File

@ -38,5 +38,6 @@
"UserName": "ficgreen01@gmail.com", "UserName": "ficgreen01@gmail.com",
"Password": "qwe2015qwe", "Password": "qwe2015qwe",
"EnableSsl": true "EnableSsl": true
} },
"ExceptionTimes": 240
} }