將 異常時間 拉出 單位為分鐘
This commit is contained in:
parent
7193826d63
commit
34891227ae
@ -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<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.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<int>("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)
|
||||
|
||||
@ -37,7 +37,9 @@
|
||||
"UserName": "shanghohui@gmail.com",
|
||||
"Password": "wswgnluvoodfexrb",
|
||||
"EnableSsl": true
|
||||
}
|
||||
},
|
||||
"ExceptionTimes": 240
|
||||
|
||||
//"SMTPConfig": {
|
||||
// "Host": "smtp.gmail.com",
|
||||
// "Port": 25,
|
||||
|
||||
@ -38,5 +38,6 @@
|
||||
"UserName": "ficgreen01@gmail.com",
|
||||
"Password": "qwe2015qwe",
|
||||
"EnableSsl": true
|
||||
}
|
||||
},
|
||||
"ExceptionTimes": 240
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user