1. 每15歸檔加入log

This commit is contained in:
Kai 2022-03-17 09:40:37 +08:00
parent c7651dcd56
commit b02110c3c5
2 changed files with 45 additions and 36 deletions

View File

@ -57,7 +57,7 @@ namespace SolarPower.Quartz.Jobs
logger.LogInformation("【CalcInverter15minJob】【開始取得電站資料】"); logger.LogInformation("【CalcInverter15minJob】【開始取得電站資料】");
var powerStations = await powerStationRepository.GetAllAsync(); var powerStations = await powerStationRepository.GetAllAsync();
logger.LogInformation("【CalcInverter15minJob】【取得成功電站資料】"); logger.LogInformation("【CalcInverter15minJob】【取得成功電站資料】");
logger.LogInformation("【CalcInverter15minJob】【電站資料】 - {0}", System.Text.Json.JsonSerializer.Serialize(powerStations)); //logger.LogInformation("【CalcInverter15minJob】【電站資料】 - {0}", System.Text.Json.JsonSerializer.Serialize(powerStations));
#endregion #endregion
List<InverterHistory> calcInverter15mins = new List<InverterHistory>(); List<InverterHistory> calcInverter15mins = new List<InverterHistory>();
@ -78,7 +78,8 @@ namespace SolarPower.Quartz.Jobs
#region step2. DB及電站編號找出該電站的控制器 #region step2. DB及電站編號找出該電站的控制器
foreach (var powerStation in powerStations) foreach (var powerStation in powerStations)
{ {
try
{
//取得所有該電站的逆變器 //取得所有該電站的逆變器
logger.LogInformation("【CalcInverter15minJob】【開始取得電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateNowTime); logger.LogInformation("【CalcInverter15minJob】【開始取得電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateNowTime);
var controllers = await powerStationRepository.GetAllDeviceControllerId(powerStation.Id, powerStation.SiteDB); var controllers = await powerStationRepository.GetAllDeviceControllerId(powerStation.Id, powerStation.SiteDB);
@ -108,11 +109,12 @@ namespace SolarPower.Quartz.Jobs
} }
} }
} }
}
catch (Exception ex)
{
logger.LogError("【CalcInverter15minJob】【電站[{0}]計算失敗】 - {1}", powerStation.Code, ex.ToString());
}
#endregion #endregion
} }
#endregion #endregion
@ -127,7 +129,14 @@ namespace SolarPower.Quartz.Jobs
"KWHKWP", "KWHKWP",
}; };
try
{
await powerStationRepository.AddInverter15minHistory(calcInverter15mins, inverter_history_properties); await powerStationRepository.AddInverter15minHistory(calcInverter15mins, inverter_history_properties);
}
catch (Exception ex)
{
logger.LogError("【CalcInverter15minJob】【儲存15分鐘歷史紀錄失敗】 - {0}", ex.ToString());
}
#endregion #endregion
// } // }
//} //}

View File

@ -53,7 +53,7 @@ namespace SolarPower.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
//_log.LogError("【SendEmailSMSService】 " + noticeInfo.Recipient_email + "寄送信件失敗"); throw ex;
return false; return false;
} }