From fb242f4aaed238ad515fb5f5afb990362978a4c7 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Fri, 17 Sep 2021 16:35:50 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=B7=A1=E6=AA=A2=E5=85=A7=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Models/Operation.cs | 1 + SolarPower/Models/Overview.cs | 1 + SolarPower/Quartz/Jobs/OperationScheduleJob.cs | 6 ++++-- SolarPower/Repository/Implement/OverviewRepository.cs | 2 +- SolarPower/Views/Operation/OperationRecord.cshtml | 9 ++++++++- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/SolarPower/Models/Operation.cs b/SolarPower/Models/Operation.cs index 47ef2c1..fcbb6c9 100644 --- a/SolarPower/Models/Operation.cs +++ b/SolarPower/Models/Operation.cs @@ -121,6 +121,7 @@ namespace SolarPower.Models public int WorkType { get; set; } public string StartTime { get; set; } public string EndTime { get; set; } + public string Notice { get; set; } } public class OperationRecord : UserInfo diff --git a/SolarPower/Models/Overview.cs b/SolarPower/Models/Overview.cs index c066e52..7e12750 100644 --- a/SolarPower/Models/Overview.cs +++ b/SolarPower/Models/Overview.cs @@ -185,6 +185,7 @@ namespace SolarPower.Models public double Temp { get; set; } public double DiffSOLARHOUR { get; set; } public string TOTALTIME { get; set; } + public double KWHKWP { get; set; } } public class ExceptionEmailInfo diff --git a/SolarPower/Quartz/Jobs/OperationScheduleJob.cs b/SolarPower/Quartz/Jobs/OperationScheduleJob.cs index b0c8935..c527148 100644 --- a/SolarPower/Quartz/Jobs/OperationScheduleJob.cs +++ b/SolarPower/Quartz/Jobs/OperationScheduleJob.cs @@ -105,7 +105,8 @@ namespace SolarPower.Quartz.Jobs PowerStationId = a.PowerStationId, StartTime = a.StartTime, CreatedBy = a.CreatedBy, - EndTime = endtime + EndTime = endtime, + Notice = a.Description }; List properties2 = new List() { @@ -113,7 +114,8 @@ namespace SolarPower.Quartz.Jobs "PowerStationId", "StartTime", "CreatedBy", - "EndTime" + "EndTime", + "Notice" }; await operationRepository.AddToRecord(record, properties2); diff --git a/SolarPower/Repository/Implement/OverviewRepository.cs b/SolarPower/Repository/Implement/OverviewRepository.cs index 9ddb72e..d239653 100644 --- a/SolarPower/Repository/Implement/OverviewRepository.cs +++ b/SolarPower/Repository/Implement/OverviewRepository.cs @@ -634,7 +634,7 @@ namespace SolarPower.Repository.Implement ( SELECT DENSE_RANK() OVER(ORDER BY C.TIMESTAMP) AS ROWID , (DENSE_RANK() OVER(ORDER BY C.TIMESTAMP)) - 1 AS PreROWID, - C.TIMESTAMP,{kwh} AS KWH,C.SOLARHOUR,C.PR,P.Irradiance,P.Temperature AS Temp + C.TIMESTAMP,{kwh} AS KWH,C.SOLARHOUR,C.PR,P.Irradiance,P.Temperature AS Temp ,C.KWHKWP FROM {usedb} C LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP,'{timeGroup}') = DATE_FORMAT(C.TIMESTAMP,'{timeGroup}') AND P.PowerStationId = C.PowerStationId WHERE C.PowerStationId = {post.PowerstationId}{range2} GROUP BY C.TIMESTAMP ORDER BY C.TIMESTAMP diff --git a/SolarPower/Views/Operation/OperationRecord.cshtml b/SolarPower/Views/Operation/OperationRecord.cshtml index 9d053aa..d1c0204 100644 --- a/SolarPower/Views/Operation/OperationRecord.cshtml +++ b/SolarPower/Views/Operation/OperationRecord.cshtml @@ -214,7 +214,7 @@
- +
@@ -682,6 +682,10 @@ $("#record-form").trigger("reset"); $("input[name=status_modal][value='" + 0 + "']").prop('checked', true); //狀態 $("#record_files_div > .row").empty(); + + + + $("#record-form-modal").modal(); } @@ -1009,6 +1013,9 @@ CreateRecordFileBox(RecordFileBox, value, true); }); + + + $("#record-form-modal").modal(); }, 'json'); }); From f0f68951bc47fa417d3f51084426cb6f2d2b5829 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Fri, 17 Sep 2021 16:53:51 +0800 Subject: [PATCH 2/3] =?UTF-8?q?linetoken=20=E5=82=B3=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Quartz/Jobs/ExceptionSchedule.cs | 41 ++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs index 0468504..06fa4b6 100644 --- a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs +++ b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs @@ -1,10 +1,13 @@ using Microsoft.Extensions.Logging; +using Newtonsoft.Json.Linq; using Quartz; using SolarPower.Models; using SolarPower.Repository.Interface; using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Net; using System.Threading; using System.Threading.Tasks; @@ -17,13 +20,15 @@ namespace SolarPower.Quartz.Jobs private readonly IOverviewRepository overviewRepository; private readonly INoticeScheduleRepository noticeScheduleRepository; private readonly IUserRepository userRepository; + private readonly IPowerStationRepository powerStationRepository; - public ExceptionSchedule(ILogger logger, IOverviewRepository overviewRepository,INoticeScheduleRepository noticeScheduleRepository,IUserRepository userRepository) + public ExceptionSchedule(ILogger logger, IOverviewRepository overviewRepository,INoticeScheduleRepository noticeScheduleRepository,IUserRepository userRepository,IPowerStationRepository powerStationRepository) { this.logger = logger; this.overviewRepository = overviewRepository; this.noticeScheduleRepository = noticeScheduleRepository; this.userRepository = userRepository; + this.powerStationRepository = powerStationRepository; } public async Task Execute(IJobExecutionContext context) @@ -71,6 +76,12 @@ namespace SolarPower.Quartz.Jobs "ExceptionId" }; await noticeScheduleRepository.AddOneAsync(DaySchedule, properties); + + var powerstation = await powerStationRepository.GetOneAsync(Exception.PowerStationId); + if(powerstation.line_token != null) + { + CallLineToken(Content, powerstation.line_token); + } } } } @@ -80,5 +91,33 @@ namespace SolarPower.Quartz.Jobs logger.LogError("【{0}】{1}", nameof(logger), exception.Message); } } + + public string CallLineToken(string message, string LineToken) + { + try + { + HttpWebRequest Postrequest = (HttpWebRequest)WebRequest.Create("https://notify-api.line.me/api/notify?message=" + message); + Postrequest.Method = "POST"; + Postrequest.Headers.Add("Authorization", "Bearer " + LineToken); + Postrequest.PreAuthenticate = true; + HttpWebResponse response = (HttpWebResponse)Postrequest.GetResponse(); + var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); + var final = JObject.Parse(responseString); + var get = final["status"].ToString(); + if (get != "200") + { + logger.LogError("【{0}】CallLineToken發送Line接收失敗: {1}", nameof(logger), ex.Message); + //Logger.LogError("【" + controllerName + "/" + actionName + "】" + "CallLineToken發送Line接收失敗"); + } + return get; + } + catch (Exception ex) + { + logger.LogError("【{0}】CallLineToken: {1}", nameof(logger), ex.Message); + //Logger.LogError("【" + controllerName + "/" + actionName + "】" + "CallLineToken:" + ex); + throw ex; + } + } + } } \ No newline at end of file From 75708e4ee70bd8c1fc9dcbf411c6167e57da4387 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Fri, 17 Sep 2021 16:57:16 +0800 Subject: [PATCH 3/3] =?UTF-8?q?linetoken=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Quartz/Jobs/ExceptionSchedule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs index 06fa4b6..80f7107 100644 --- a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs +++ b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs @@ -106,7 +106,7 @@ namespace SolarPower.Quartz.Jobs var get = final["status"].ToString(); if (get != "200") { - logger.LogError("【{0}】CallLineToken發送Line接收失敗: {1}", nameof(logger), ex.Message); + logger.LogError("CallLineToken發送Line接收失敗"); //Logger.LogError("【" + controllerName + "/" + actionName + "】" + "CallLineToken發送Line接收失敗"); } return get;