diff --git a/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs b/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs index 9d94efb..bde63d4 100644 --- a/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs +++ b/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs @@ -786,114 +786,114 @@ namespace SolarPower.Quartz.Jobs } #endregion // end from here - #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(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("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(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