半夜歸檔部分註解掉,保留winfrom的歸檔動作

This commit is contained in:
wanling040@gmail.com 2022-08-24 10:31:10 +08:00
parent be9b7880d3
commit b591fca836

View File

@ -786,114 +786,114 @@ namespace SolarPower.Quartz.Jobs
}
#endregion
// end from here
#region
var gobackDay = this.Configuration.GetValue<int>("GoBackDay"); //回推天數
var Connection_string = Configuration.GetValue<string>("mySql");
var start_date = DateTimeNow.AddDays(-1 * gobackDay);
var end_date = DateTimeNow.AddDays(-1);
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行補償機制】");
procSensorSvc sensorSvc = new procSensorSvc(Connection_string);
procInvSvc invSvc = new procInvSvc(Connection_string, logger);
procStationSvc siteSvc = new procStationSvc(Connection_string);
foreach (var powerStation in powerStations)
{
start_date = DateTimeNow.AddDays(-1 * gobackDay);
for (; start_date <= end_date; start_date = start_date.AddDays(1))
{
var day_str = start_date.ToString("yyyy-MM-dd");
#region Sensor
try
{
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Sensor補償機制】", powerStation.Code, day_str);
sensorSvc.archiveData(powerStation.Code, day_str);
logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Sensor補償機制】", powerStation.Code, day_str);
}
catch (Exception exception)
{
logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Sensor補償機制】", powerStation.Code, day_str);
logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message);
if (exception.InnerException != null)
{
logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
}
}
#endregion
//#region 補償機
//var gobackDay = this.Configuration.GetValue<int>("GoBackDay"); //回推天數
//var Connection_string = Configuration.GetValue<string>("mySql");
//var start_date = DateTimeNow.AddDays(-1 * gobackDay);
//var end_date = DateTimeNow.AddDays(-1);
//logger.LogInformation("【CalcAvgPowerStationJob】【開始執行補償機制】");
//procSensorSvc sensorSvc = new procSensorSvc(Connection_string);
//procInvSvc invSvc = new procInvSvc(Connection_string, logger);
//procStationSvc siteSvc = new procStationSvc(Connection_string);
//foreach (var powerStation in powerStations)
//{
// start_date = DateTimeNow.AddDays(-1 * gobackDay);
// for (; start_date <= end_date; start_date = start_date.AddDays(1))
// {
// var day_str = start_date.ToString("yyyy-MM-dd");
// #region 歸檔 Sensor
// try
// {
// logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Sensor補償機制】", powerStation.Code, day_str);
// sensorSvc.archiveData(powerStation.Code, day_str);
// logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Sensor補償機制】", powerStation.Code, day_str);
// }
// catch (Exception exception)
// {
// logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Sensor補償機制】", powerStation.Code, day_str);
// logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message);
// if (exception.InnerException != null)
// {
// logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
// }
// }
// #endregion
#region
try
{
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Meter補償機制】", powerStation.Code, day_str);
sensorSvc.archiveMeterData(powerStation.Code, day_str);
logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Meter補償機制】", powerStation.Code, day_str);
}
catch (Exception exception)
{
logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Meter補償機制】", powerStation.Code, day_str);
logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message);
if (exception.InnerException != null)
{
logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
}
}
#endregion
// #region 歸檔 電錶
// try
// {
// logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Meter補償機制】", powerStation.Code, day_str);
// sensorSvc.archiveMeterData(powerStation.Code, day_str);
// logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Meter補償機制】", powerStation.Code, day_str);
// }
// catch (Exception exception)
// {
// logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Meter補償機制】", powerStation.Code, day_str);
// logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message);
// if (exception.InnerException != null)
// {
// logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
// }
// }
// #endregion
#region Inv
try
{
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str);
invSvc.archiveData(powerStation.Code, day_str);
logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str);
}
catch (Exception exception)
{
logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str);
logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message);
if (exception.InnerException != null)
{
logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
}
}
#endregion
// #region 歸檔 Inv
// try
// {
// logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str);
// invSvc.archiveData(powerStation.Code, day_str);
// logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str);
// }
// catch (Exception exception)
// {
// logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str);
// logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message);
// if (exception.InnerException != null)
// {
// logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
// }
// }
// #endregion
#region Station hour
try
{
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str);
siteSvc.archiveData(powerStation.Code, day_str);
logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str);
}
catch (Exception exception)
{
logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str);
logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message);
if (exception.InnerException != null)
{
logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
}
}
#endregion
// #region 歸檔 Station hour
// try
// {
// logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str);
// siteSvc.archiveData(powerStation.Code, day_str);
// logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str);
// }
// catch (Exception exception)
// {
// logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str);
// logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message);
// if (exception.InnerException != null)
// {
// logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
// }
// }
// #endregion
#region
try
{
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的 日報表製作】", powerStation.Code, day_str);
invSvc.report_invDay(powerStation.Code, day_str);
logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的 日報表製作】", powerStation.Code, day_str);
}
catch (Exception exception)
{
logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的 日報表製作】", powerStation.Code, day_str);
logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message);
if (exception.InnerException != null)
{
logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
}
}
#endregion
}
}
logger.LogInformation("【CalcAvgPowerStationJob】【執行完成補償機制】");
#endregion
// #region 製作日報表
// try
// {
// logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的 日報表製作】", powerStation.Code, day_str);
// invSvc.report_invDay(powerStation.Code, day_str);
// logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的 日報表製作】", powerStation.Code, day_str);
// }
// catch (Exception exception)
// {
// logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的 日報表製作】", powerStation.Code, day_str);
// logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message);
// if (exception.InnerException != null)
// {
// logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
// }
// }
// #endregion
// }
//}
//logger.LogInformation("【CalcAvgPowerStationJob】【執行完成補償機制】");
//#endregion