From a37975fc3221d43ae7cd75b922b480755a5c10f7 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Thu, 30 Sep 2021 10:29:03 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=A0=B1=E8=A1=A8=E9=A0=81=E9=9D=A2=20?= =?UTF-8?q?=E6=A8=A3=E5=BC=8F=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Views/StationReport/Index.cshtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SolarPower/Views/StationReport/Index.cshtml b/SolarPower/Views/StationReport/Index.cshtml index 78af90b..2274b9a 100644 --- a/SolarPower/Views/StationReport/Index.cshtml +++ b/SolarPower/Views/StationReport/Index.cshtml @@ -303,7 +303,7 @@ var haveinvertName = []; var nowform; var xxx; - + var button; $(function () { //#region 預設初始值 $('#collapse').trigger("click"); @@ -533,7 +533,7 @@ } $(e).removeClass("btn-outline-success").addClass("btn-success"); if (nowform != null && nowform != 2) { - Dateform(nowform); + Dateform(nowform, button); } } //#endregion @@ -838,7 +838,7 @@ $(".btn-report").removeClass("btn-success").addClass("btn-primary"); } $(e).removeClass("btn-primary").addClass("btn-success"); - + button = e; $('#hiretable').hide(); From f52935c24f226e1ac5982f51b775130d2d9290db Mon Sep 17 00:00:00 2001 From: b110212000 Date: Thu, 30 Sep 2021 14:17:43 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=9B=B4=E6=94=B9=20=E9=9B=BB=E7=AB=99?= =?UTF-8?q?=E7=B8=BD=E6=94=AC(=E5=8D=B3=E6=99=82PR)=E5=90=8D=E7=A8=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Views/StationOverview/Index.cshtml | 4 ++-- SolarPower/Views/StationOverview/_UpToDate.cshtml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SolarPower/Views/StationOverview/Index.cshtml b/SolarPower/Views/StationOverview/Index.cshtml index 04221b5..b36ee6b 100644 --- a/SolarPower/Views/StationOverview/Index.cshtml +++ b/SolarPower/Views/StationOverview/Index.cshtml @@ -110,7 +110,7 @@
-

即時平均 PR 值

+

今日 PR 值

0.00

@@ -126,7 +126,7 @@
-

即時平均有效日照時數

+

今日有效日照時數(kwh/kwp)

0.00

diff --git a/SolarPower/Views/StationOverview/_UpToDate.cshtml b/SolarPower/Views/StationOverview/_UpToDate.cshtml index 542cbc3..d7e902a 100644 --- a/SolarPower/Views/StationOverview/_UpToDate.cshtml +++ b/SolarPower/Views/StationOverview/_UpToDate.cshtml @@ -55,7 +55,7 @@
-

即時平均 PR 值

+

今日 PR 值

0.00

@@ -71,7 +71,7 @@
-

即時平均有效日照時數

+

今日有效日照時數(kwh/kwp)

0.00

From 201ef521515ec0893d446290a3e97d8035414d50 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Fri, 1 Oct 2021 11:11:18 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E5=90=88=E4=BD=B5=E9=9B=BB=E7=AB=99--?= =?UTF-8?q?=E6=97=A5=E7=85=A7=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Models/AnalysisStationCombine.cs | 2 + .../AnalysisStationCombineRepository.cs | 88 ++++++++++++++++--- .../Views/AnalysisStationCombine/Index.cshtml | 25 +++++- SolarPower/Views/MapOverview/Index.cshtml | 10 +-- SolarPower/Views/StationOverview/Index.cshtml | 2 +- .../Views/StationOverview/_UpToDate.cshtml | 2 +- 6 files changed, 107 insertions(+), 22 deletions(-) diff --git a/SolarPower/Models/AnalysisStationCombine.cs b/SolarPower/Models/AnalysisStationCombine.cs index d78b9f0..174d1b3 100644 --- a/SolarPower/Models/AnalysisStationCombine.cs +++ b/SolarPower/Models/AnalysisStationCombine.cs @@ -17,6 +17,8 @@ namespace SolarPower.Models public double All_PR { get; set; }//總平均PR public double Now_Carbon { get; set; }//現減炭 public double All_Carbon { get; set; }//總減炭 + public double All_irradiance { get; set; } + public double Now_irradiance { get; set; } } public class ChartInput { diff --git a/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs b/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs index 7b40134..d6e6847 100644 --- a/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs +++ b/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs @@ -17,6 +17,8 @@ namespace SolarPower.Repository.Implement tableName = "power_station"; } + + public async Task GetPowerStationInfoList(ChartInput post) { var a = new AnalysisStationCombine(); @@ -32,7 +34,26 @@ namespace SolarPower.Repository.Implement { case 0: string timerange = Convert.ToDateTime(post.Timerange).ToString("yyyy-MM-dd"); - sql = $@"SELECT m.*,n.*,o.* FROM + var today = ""; + if(timerange == DateTime.Now.ToString("yyyy-MM-dd")) + { + today = @$" SELECT + AVG(a.today_irradiance) AS Now_irradiance + FROM + power_station a + WHERE a.Id IN @ids "; + } + else + { + today = $@" SELECT + AVG(a.Irradiance) AS Now_irradiance + FROM + sensor_history_day a + WHERE a.PowerStationId IN @ids AND DATE_FORMAT(a.TIMESTAMP,'%Y-%m-%d') = '{timerange}'"; + } + + + sql = $@"SELECT m.*,n.*,o.*,p.* FROM ( SELECT SUM(TOTALMONEY) AS All_money, @@ -60,15 +81,40 @@ namespace SolarPower.Repository.Implement ( SELECT AVG(avg_kwhkwp) AS All_KWH_KWP, - AVG(avg_PR) AS All_PR + AVG(avg_PR) AS All_PR, + AVG(avg_irradiance) as All_irradiance from power_station WHERE Id IN @ids ) - AS o"; + AS o, + ( + {today} + ) AS p"; break; case 1: var time = post.Timerange.Split('-'); - sql = $@"SELECT m.*,n.*,o.* FROM + var ttot = ""; + if(time[1].Replace(" ","") == DateTime.Now.ToString("yyyy/MM/dd")) + { + ttot = @$"SELECT + AVG(c.Now_irradiance) AS Now_irradiance + FROM + (SELECT AVG(a.today_irradiance) AS Now_irradiance FROM power_station a WHERE a.Id IN (1) + UNION + SELECT AVG(b.Irradiance) AS Now_irradiance FROM sensor_history_day b + WHERE b.PowerStationId IN (1) AND DATE_FORMAT(b.TIMESTAMP, '%Y/%m/%d') BETWEEN '{time[0].Replace(" ", "")}' AND '{Convert.ToDateTime(time[1].Replace(" ", "")).AddDays(-1).ToString("yyyy/MM/dd")}') c"; + } + else + { + ttot = @$" SELECT + AVG(a.Irradiance) AS Now_irradiance + FROM + sensor_history_day a + WHERE a.PowerStationId IN @ids AND DATE_FORMAT(a.TIMESTAMP, '%Y/%m/%d') BETWEEN '{time[0].Replace(" ", "")}' AND '{time[1].Replace(" ", "")}'"; + } + + + sql = $@"SELECT m.*,n.*,o.*,p.* FROM ( SELECT SUM(TOTALMONEY) AS All_money, @@ -92,14 +138,18 @@ namespace SolarPower.Repository.Implement ( SELECT AVG(avg_kwhkwp) AS All_KWH_KWP, - AVG(avg_PR) AS All_PR + AVG(avg_PR) AS All_PR, + AVG(avg_irradiance) as All_irradiance from power_station WHERE Id IN @ids ) - AS o"; + AS o, + ( + {ttot} + ) AS p"; break; case 2: - sql = $@"SELECT m.*,n.*,o.* FROM + sql = $@"SELECT m.*,n.*,o.*,p.* FROM ( SELECT SUM(TOTALMONEY) AS All_money, @@ -123,14 +173,21 @@ namespace SolarPower.Repository.Implement ( SELECT AVG(avg_kwhkwp) AS All_KWH_KWP, - AVG(avg_PR) AS All_PR + AVG(avg_PR) AS All_PR, + AVG(avg_irradiance) as All_irradiance from power_station WHERE Id IN @ids ) - AS o"; + AS o, + ( + SELECT + AVG(a.Irradiance) AS Now_irradiance + from sensor_history_month a + WHERE PowerStationId IN @ids AND DATE_FORMAT(TIMESTAMP, '%Y-%m') = '{post.Timerange}' + ) AS p"; break; case 3: - sql = $@"SELECT m.*,n.*,o.* FROM + sql = $@"SELECT m.*,n.*,o.*,p.* FROM ( SELECT SUM(TOTALMONEY) AS All_money, @@ -155,11 +212,18 @@ namespace SolarPower.Repository.Implement ( SELECT AVG(avg_kwhkwp) AS All_KWH_KWP, - AVG(avg_PR) AS All_PR + AVG(avg_PR) AS All_PR, + AVG(avg_irradiance) as All_irradiance from power_station WHERE Id IN @ids ) - AS o"; + AS o, + ( + SELECT + AVG(a.Irradiance) AS Now_irradiance + from sensor_history_month a + WHERE PowerStationId IN @ids AND DATE_FORMAT(TIMESTAMP, '%Y') = '{post.Timerange}' + ) AS p"; break; } diff --git a/SolarPower/Views/AnalysisStationCombine/Index.cshtml b/SolarPower/Views/AnalysisStationCombine/Index.cshtml index 5a5907b..bcde727 100644 --- a/SolarPower/Views/AnalysisStationCombine/Index.cshtml +++ b/SolarPower/Views/AnalysisStationCombine/Index.cshtml @@ -111,6 +111,25 @@
} + else + { +
+
+

日照度

+
k W/m2
+
+
+
+

當日日照度

+

0.00

+
+
+

平均日照度(30天)

+

0.00

+
+
+
+ }

PR值

@@ -309,7 +328,7 @@ $("#today_kwhkwp_label").html(timename + "有效日照時數"); $("#today_PR_label").html(timename + "PR值"); $("#today_carbon_label").html(timename + "減碳量"); - + $("#today_irradiance_label").html(timename + "日照度"); if (type == 1) { timerange = $('#DateGettext').val(); @@ -411,7 +430,7 @@ $('#total_kwhkwp').html(rel.data.all_KWH_KWP.toFixed(2)); $('#total_PR').html(rel.data.all_PR.toFixed(2)); $('#total_carbon').html(rel.data.all_Carbon.toFixed(2)); - $('#total_irradiance').html(rel.data.all_Carbon.toFixed(2)); + $('#total_irradiance').html(rel.data.all_irradiance.toFixed(2)); $('#today_kwh').html(rel.data.now_kwh.toFixed(2)); @@ -419,7 +438,7 @@ $('#today_kwhkwp').html(rel.data.now_KWH_KWP.toFixed(2)); $('#today_PR').html(rel.data.now_PR.toFixed(2)); $('#today_carbon').html(rel.data.now_Carbon.toFixed(2)); - $('#today_irradiance').html(rel.data.now_Carbon.toFixed(2)); + $('#today_irradiance').html(rel.data.now_irradiance.toFixed(2)); chart(); }) diff --git a/SolarPower/Views/MapOverview/Index.cshtml b/SolarPower/Views/MapOverview/Index.cshtml index 95e0bcb..79aea0f 100644 --- a/SolarPower/Views/MapOverview/Index.cshtml +++ b/SolarPower/Views/MapOverview/Index.cshtml @@ -36,7 +36,7 @@
-

即時平均日照度

+

即時日照度

0.00

@@ -52,7 +52,7 @@
-

即時平均 PR 值

+

今日 PR 值

0.00

@@ -68,7 +68,7 @@
-

即時平均有效日照時數

+

今日有效日照時數(kwh/kwp)

0.00

@@ -279,8 +279,8 @@ '
' + '
' + '
今日發電量(kW h):' + item.today_kWh + '
'+ - '
今日日照度(k W/m2):' + item.today_irradiance + '
'+ - '
今日發電小時(hr):' + item.solarHour + '
' + + '
即時日照度(k W/m2):' + item.today_irradiance + '
'+ + '
有效日照時數(kwh/kwp):' + item.today_kwhkwp.toFixed(2) + '
' + '
裝置容量(kWp):' + item.generatingCapacity.toFixed(3) + '
' + '
掛錶日期:' + item.electricityMeterAt + '
' + '
天氣:' + item.wx + '
'+ diff --git a/SolarPower/Views/StationOverview/Index.cshtml b/SolarPower/Views/StationOverview/Index.cshtml index b36ee6b..ede80d0 100644 --- a/SolarPower/Views/StationOverview/Index.cshtml +++ b/SolarPower/Views/StationOverview/Index.cshtml @@ -94,7 +94,7 @@
-

即時平均日照度

+

即時日照度

0.00

diff --git a/SolarPower/Views/StationOverview/_UpToDate.cshtml b/SolarPower/Views/StationOverview/_UpToDate.cshtml index d7e902a..0002ad9 100644 --- a/SolarPower/Views/StationOverview/_UpToDate.cshtml +++ b/SolarPower/Views/StationOverview/_UpToDate.cshtml @@ -39,7 +39,7 @@
-

即時平均日照度

+

即時日照度

0.00

From b1a62fde79ebf9d8e3a572e7cbe1f76c9e5efa2c Mon Sep 17 00:00:00 2001 From: b110212000 Date: Fri, 1 Oct 2021 11:38:55 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E9=9B=BB=E7=AB=99=E7=AE=A1=E7=90=86=20-=20?= =?UTF-8?q?=E7=8D=A8=E7=AB=8B=E7=A7=BB=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Views/Company/Index.cshtml | 3 + SolarPower/Views/PowerStation/Index.cshtml | 2 +- SolarPower/Views/Shared/_Layout.cshtml | 162 +++++++++++---------- 3 files changed, 89 insertions(+), 78 deletions(-) diff --git a/SolarPower/Views/Company/Index.cshtml b/SolarPower/Views/Company/Index.cshtml index d46f785..3aee15d 100644 --- a/SolarPower/Views/Company/Index.cshtml +++ b/SolarPower/Views/Company/Index.cshtml @@ -250,6 +250,9 @@ 'render': function (data, type, full, meta) { return ''; } + },{ + 'targets': 8, + 'visible': false }], "language": { "emptyTable": "查無資料", diff --git a/SolarPower/Views/PowerStation/Index.cshtml b/SolarPower/Views/PowerStation/Index.cshtml index d1cb700..cd0b781 100644 --- a/SolarPower/Views/PowerStation/Index.cshtml +++ b/SolarPower/Views/PowerStation/Index.cshtml @@ -1,5 +1,5 @@ @{ - ViewData["MainNum"] = "6"; + ViewData["MainNum"] = "8"; ViewData["SubNum"] = "1"; ViewData["Title"] = "電站管理"; } diff --git a/SolarPower/Views/Shared/_Layout.cshtml b/SolarPower/Views/Shared/_Layout.cshtml index 731544d..e98362d 100644 --- a/SolarPower/Views/Shared/_Layout.cshtml +++ b/SolarPower/Views/Shared/_Layout.cshtml @@ -154,12 +154,12 @@ --> } @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin - || ViewBag.auths.Contains("AnalysisStationCombine") - || ViewBag.auths.Contains("AnalysisStationInfo") - || ViewBag.auths.Contains("AnalysisInverter")) + || ViewBag.auths.Contains("AnalysisStationCombine") + || ViewBag.auths.Contains("AnalysisStationInfo") + || ViewBag.auths.Contains("AnalysisInverter")) {
  • @@ -282,10 +282,10 @@
  • } @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin - || ViewBag.auths.Contains("StationReport") - || ViewBag.auths.Contains("ElectricitySoldRecord") - || ViewBag.auths.Contains("PowerGeneration") - || ViewBag.auths.Contains("NoticeSchedule")) + || ViewBag.auths.Contains("StationReport") + || ViewBag.auths.Contains("ElectricitySoldRecord") + || ViewBag.auths.Contains("PowerGeneration") + || ViewBag.auths.Contains("NoticeSchedule")) {
  • @@ -295,38 +295,38 @@
  • @@ -348,8 +348,23 @@ } - - @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStation") || ViewBag.auths.Contains("Operation") || ViewBag.auths.Contains("OperationRecord")) + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStation")) + { +
  • + + + 電站管理 + + +
  • + } + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("Operation") || ViewBag.auths.Contains("OperationRecord")) {
  • @@ -357,14 +372,7 @@ 運維管理
      - @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStation")) - { -
    • - - 電站管理 - -
    • - } + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("Operation")) {
    • @@ -410,21 +418,21 @@
    • } @*@if (ViewBag.auths.Contains("User")) - { -
    • - - 功能清單 - -
    • - } - @if (ViewBag.auths.Contains("User")) - { -
    • - - 定時任務設定 - -
    • - }*@ + { +
    • + + 功能清單 + +
    • + } + @if (ViewBag.auths.Contains("User")) + { +
    • + + 定時任務設定 + +
    • + }*@
  • } From 7193826d636f65eb1ea5b5d87dce1aaa3aeb881d Mon Sep 17 00:00:00 2001 From: b110212000 Date: Fri, 1 Oct 2021 17:05:05 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E9=80=86=E8=AE=8A=E5=99=A8=E8=A8=88?= =?UTF-8?q?=E7=AE=97---=E9=80=BE=E6=99=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Controllers/AnalysisInverterController.cs | 9 ++++++++- SolarPower/Models/ErrorCode.cs | 9 +++++---- .../Repository/Implement/PowerStationRepository.cs | 2 +- .../Repository/Implement/StationReportRepository.cs | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/SolarPower/Controllers/AnalysisInverterController.cs b/SolarPower/Controllers/AnalysisInverterController.cs index 5676990..2539ff3 100644 --- a/SolarPower/Controllers/AnalysisInverterController.cs +++ b/SolarPower/Controllers/AnalysisInverterController.cs @@ -914,7 +914,14 @@ namespace SolarPower.Controllers } catch (Exception exception) { - apiResult.Code = "9999"; + if(exception.Message == "Fatal error encountered during command execution.") + { + apiResult.Code = "9984"; + } + else + { + apiResult.Code = "9999"; + } Logger.LogError("【" + controllerName + "/" + actionName + "】"); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } diff --git a/SolarPower/Models/ErrorCode.cs b/SolarPower/Models/ErrorCode.cs index bb221c5..3b83845 100644 --- a/SolarPower/Models/ErrorCode.cs +++ b/SolarPower/Models/ErrorCode.cs @@ -17,10 +17,11 @@ namespace SolarPower.Models { { "0000", "OK" }, { "0001", "傳入參數錯誤。" }, - { "0002","請先刪除相關逆變器"}, - { "0003","請先刪除相關設備"}, - { "0004","請先移除相關逆變器綁定"}, - { "9985","該電站尚無逆變器資料"}, + { "0002", "請先刪除相關逆變器"}, + { "0003", "請先刪除相關設備"}, + { "0004", "請先移除相關逆變器綁定"}, + { "9984", "連線逾時"}, + { "9985", "該電站尚無逆變器資料"}, { "9986", "該帳號已被註冊,請重新輸入"}, { "9987", "查無該運維作業記錄檔案"}, { "9988", "查無該資料紀錄"}, diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index 32d5cf8..10acb47 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -4475,7 +4475,7 @@ namespace SolarPower.Repository.Implement } sql = "SELECT * FROM (" + string.Join(" UNION ", sql_perSiteDB) + ") a ORDER BY a.TIMESTAMP ASC"; - result = (await conn.QueryAsync(sql, new { NowDay = nowDay })).ToList(); + result = (await conn.QueryAsync(sql, new { NowDay = nowDay }, commandTimeout: 300)).ToList(); } catch (Exception exception) { diff --git a/SolarPower/Repository/Implement/StationReportRepository.cs b/SolarPower/Repository/Implement/StationReportRepository.cs index 3feab29..0097d0d 100644 --- a/SolarPower/Repository/Implement/StationReportRepository.cs +++ b/SolarPower/Repository/Implement/StationReportRepository.cs @@ -243,7 +243,7 @@ namespace SolarPower.Repository.Implement break; } - a = await conn.QueryAsync(sql,commandTimeout: 300); + a = await conn.QueryAsync(sql, commandTimeout: 300); } catch (Exception exception) { From 34891227ae17da697bb3d52d0fdc7743b607032f Mon Sep 17 00:00:00 2001 From: b110212000 Date: Fri, 1 Oct 2021 17:36:48 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=B0=87=20=E7=95=B0=E5=B8=B8=E6=99=82?= =?UTF-8?q?=E9=96=93=20=E6=8B=89=E5=87=BA=20=E5=96=AE=E4=BD=8D=E7=82=BA?= =?UTF-8?q?=E5=88=86=E9=90=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Quartz/Jobs/ExceptionSchedule.cs | 10 +++++++--- SolarPower/appsettings.Development.json | 4 +++- SolarPower/appsettings.json | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) 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 } From aab64ffa9034e6c0192291e75146e6f444b51aca Mon Sep 17 00:00:00 2001 From: b110212000 Date: Fri, 1 Oct 2021 17:38:40 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A8=BB=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/appsettings.Development.json | 2 +- SolarPower/appsettings.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SolarPower/appsettings.Development.json b/SolarPower/appsettings.Development.json index 241b221..a50b12a 100644 --- a/SolarPower/appsettings.Development.json +++ b/SolarPower/appsettings.Development.json @@ -38,7 +38,7 @@ "Password": "wswgnluvoodfexrb", "EnableSsl": true }, - "ExceptionTimes": 240 + "ExceptionTimes": 240 //`qɶA() //"SMTPConfig": { // "Host": "smtp.gmail.com", diff --git a/SolarPower/appsettings.json b/SolarPower/appsettings.json index 5b53310..e8efcfa 100644 --- a/SolarPower/appsettings.json +++ b/SolarPower/appsettings.json @@ -39,5 +39,5 @@ "Password": "qwe2015qwe", "EnableSsl": true }, - "ExceptionTimes": 240 + "ExceptionTimes": 240 //`qɶA() }