1. 逆變器補償加入log

This commit is contained in:
Kai 2021-11-05 18:33:11 +08:00
parent 8c8a64bb39
commit a16468f22c

View File

@ -48,18 +48,35 @@ namespace solarApp.Service
using (MySqlConnection conn = new MySqlConnection(Connection1))
{
conn.Open();
if (_logger != null)
{
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器清除資料表的資料", _siteID, _date1);
}
string sql = @"
delete from inverter_history_15min where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
delete from inverter_history_hour where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
delete from inverter_history_day where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
delete from inverter_history_month where powerstationID = @powerStationID and left(`TIMESTAMP`, 7) = left(@date1, 7) ;";
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
if (_logger != null)
{
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器清除資料表的資料", _siteID, _date1);
}
conn.Close();
}
result = true;
}
catch (Exception ex)
{
if (_logger != null)
{
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器清除資料表的資料", _siteID, _date1);
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器清除資料表的資料 - [Exception]{2}", _siteID, _date1, ex.ToString());
}
throw ex;
}
return result;
@ -91,6 +108,12 @@ namespace solarApp.Service
using (MySqlConnection conn = new MySqlConnection(Connection1))
{
conn.Open();
if (_logger != null)
{
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器取得電站編號", _siteID, _date1);
}
#region PowerStationID
string sql = @" select id , `code` siteID, siteDB, `name` siteName
from solar_master.power_station where `code` = @siteID";
@ -101,6 +124,12 @@ namespace solarApp.Service
_siteDB = item.SiteDB;
_siteID01 = item.SiteID + "01";
}
if (_logger != null)
{
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器取得電站編號 - {2}", _siteID, _date1, _powerStationID);
}
#endregion
conn.Close();
}
@ -108,6 +137,12 @@ namespace solarApp.Service
}
catch (Exception ex)
{
if (_logger != null)
{
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器取得電站編號", _siteID, _date1);
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器取得電站編號 - [Exception]{2}", _siteID, _date1, ex.ToString());
}
throw ex;
}
return result;