diff --git a/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs b/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs index 2227643..0bebc3e 100644 --- a/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs +++ b/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs @@ -785,12 +785,13 @@ namespace SolarPower.Quartz.Jobs #region 補償機制 var gobackDay = this.Configuration.GetValue("GoBackDay"); //回推天數 + var Connection_string = Configuration.GetValue("mySql"); var start_date = DateTimeNow.AddDays(-1 * gobackDay); var end_date = DateTimeNow.AddDays(-1); logger.LogInformation("【CalcAvgPowerStationJob】【開始補償機制】"); - procSensorSvc sensorSvc = new procSensorSvc(); - procInvSvc invSvc = new procInvSvc(); - procStationSvc siteSvc = new procStationSvc(); + procSensorSvc sensorSvc = new procSensorSvc(Connection_string); + procInvSvc invSvc = new procInvSvc(Connection_string); + procStationSvc siteSvc = new procStationSvc(Connection_string); foreach (var powerStation in powerStations) { foreach (DateTime day in EachDay(start_date, end_date)) @@ -806,7 +807,10 @@ namespace SolarPower.Quartz.Jobs { logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Sensor補償機制】", powerStation.Code, day_str); logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message); - logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); + if (exception.InnerException != null) + { + logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); + } } try @@ -819,7 +823,10 @@ namespace SolarPower.Quartz.Jobs { logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str); logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message); - logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); + if (exception.InnerException != null) + { + logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); + } } try @@ -832,7 +839,10 @@ namespace SolarPower.Quartz.Jobs { logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str); logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message); - logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); + if (exception.InnerException != null) + { + logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); + } } } } @@ -1012,7 +1022,10 @@ namespace SolarPower.Quartz.Jobs catch (Exception exception) { logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message); - logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); + if(exception.InnerException != null) + { + logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); + } } } diff --git a/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs b/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs index 0cb6234..871e0d4 100644 --- a/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs +++ b/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs @@ -822,7 +822,10 @@ namespace SolarPower.Quartz.Jobs catch (Exception exception) { logger.LogError("【CalcPowerStationJob】[Exception] - {0}", exception.Message); - logger.LogError("【CalcPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); + if (exception.InnerException != null) + { + logger.LogError("【CalcPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); + } } } } diff --git a/SolarPower/appsettings.Development.json b/SolarPower/appsettings.Development.json index a4d925f..93f75ab 100644 --- a/SolarPower/appsettings.Development.json +++ b/SolarPower/appsettings.Development.json @@ -15,6 +15,7 @@ "Root": "mWlR2HshQNhRRE34jg4kdg==", "Password": "y4uPqlH9ncTgR/I07qpwaA==" }, + "mySql": "server=210.61.91.43;user=idafenweb;Database=solar_power_test;Port=10068;password=P@ssw0rd;charset='utf8';pooling=true;sslmode=none;", //"DBConfig": { // "Server": "AVXfxd+IRlLtJ0MCi9HU1g==", // "port": "CrEmevYrUsSo7Mkb7Gxn8A==", @@ -24,7 +25,7 @@ //}, "BackgroundServiceCron": { "CalcPowerStationJob": "0 5 * * * ?", - "CalcAvgPowerStationJob": "0 0 2 * * ?", + "CalcAvgPowerStationJob": "0/10 * * * * ?", "OperationScheduleJob": "0 0 2 * * ?", "CalcInverter15minJob": "0 2/15 * * * ?", "SendEmailJob": "0 0/5 * * * ?", @@ -36,7 +37,7 @@ "UserName": "shanghohui@gmail.com", "Password": "wswgnluvoodfexrb", "EnableSsl": true - }, + } //"SMTPConfig": { // "Host": "smtp.gmail.com", // "Port": 25, diff --git a/SolarPower/appsettings.json b/SolarPower/appsettings.json index f01e034..79e106d 100644 --- a/SolarPower/appsettings.json +++ b/SolarPower/appsettings.json @@ -8,6 +8,7 @@ }, "AllowedHosts": "*", "LoginExpireMinute": 60, //nJɶA() + "mySql": "server=60.251.164.103;user=webuser;Database=solar_master;Port=11306;password=FICadmin99;charset='utf8';pooling=true;sslmode=none;", //"DBConfig": { // "Server": "MVgHWzR3rGDgD57TUoFunA==", // "port": "r4AoXMUDodcQjIzofGNCcg==", diff --git a/solarApp/Service/procInvSvc.cs b/solarApp/Service/procInvSvc.cs index 3971c15..fb8adbf 100644 --- a/solarApp/Service/procInvSvc.cs +++ b/solarApp/Service/procInvSvc.cs @@ -11,7 +11,19 @@ namespace solarApp.Service { public class procInvSvc { - string Connection1 = ConfigurationManager.ConnectionStrings["mySql"].ConnectionString; + string Connection1 = string.Empty; + + public procInvSvc(string Connection_parame = null) + { + if (!string.IsNullOrEmpty(Connection_parame)) + { + Connection1 = Connection_parame; + } + else + { + Connection1 = ConfigurationManager.ConnectionStrings["mySql"].ConnectionString; + } + } public string _siteID { get; set; } public string _siteDB { get; set; } diff --git a/solarApp/Service/procSensorSvc.cs b/solarApp/Service/procSensorSvc.cs index 6ceab0e..60e9bea 100644 --- a/solarApp/Service/procSensorSvc.cs +++ b/solarApp/Service/procSensorSvc.cs @@ -11,7 +11,20 @@ namespace solarApp.Service { public class procSensorSvc { - string Connection1 = ConfigurationManager.ConnectionStrings["mySql"].ConnectionString; + string Connection1 = string.Empty; + + public procSensorSvc(string Connection_parame = null) + { + if (!string.IsNullOrEmpty(Connection_parame)) + { + Connection1 = Connection_parame; + } + else + { + Connection1 = ConfigurationManager.ConnectionStrings["mySql"].ConnectionString; + } + } + public string _siteID { get; set; } public string _siteDB { get; set; } diff --git a/solarApp/Service/procStationSvc.cs b/solarApp/Service/procStationSvc.cs index 3a84694..c932491 100644 --- a/solarApp/Service/procStationSvc.cs +++ b/solarApp/Service/procStationSvc.cs @@ -10,7 +10,19 @@ namespace solarApp.Service { public class procStationSvc { - string Connection1 = ConfigurationManager.ConnectionStrings["mySql"].ConnectionString; + string Connection1 = string.Empty; + + public procStationSvc(string Connection_parame = null) + { + if (!string.IsNullOrEmpty(Connection_parame)) + { + Connection1 = Connection_parame; + } + else + { + Connection1 = ConfigurationManager.ConnectionStrings["mySql"].ConnectionString; + } + } public string _siteID { get; set; } public string _siteDB { get; set; }