1. 背景執行日月報表 迴圈加 try catch

This commit is contained in:
Kai 2021-09-24 10:09:15 +08:00
parent 082850213d
commit 458dff0078

View File

@ -8,6 +8,7 @@ using SolarPower.Models.PowerStation;
using SolarPower.Repository.Interface;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
@ -870,9 +871,17 @@ namespace SolarPower.Quartz.Jobs
#region
var users = userRepository.GetAllAsync();
var ttt = new List<string>() {
"s506488@gmail.com",
"cesarliuc@gmail.com"
};
foreach (var user in users.Result)
{
try
{
logger.LogInformation("【CalcAvgPowerStationJob】【開始產生使用者[{0}({1})]的日月報】", user.Account, user.Name);
List<OperationPersonnel> powerstations = new List<OperationPersonnel>();
powerstations = await noticeScheduleRepository.GetPowerStationOperationPersonnel(user.Id);
if (powerstations.Count == 0)
@ -1032,6 +1041,21 @@ namespace SolarPower.Quartz.Jobs
}
}
logger.LogInformation("【CalcAvgPowerStationJob】【產生完成使用者[{0}({1})]的日月報】", user.Account, user.Name);
}
catch (Exception exception)
{
logger.LogError("【CalcAvgPowerStationJob】【產生失敗使用者[{0}({1})]的日月報】", user.Account, user.Name);
logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message);
if (exception.InnerException != null)
{
logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
}
var line = new StackTrace(exception, true).GetFrame(0).GetFileLineNumber();
logger.LogError("【CalcAvgPowerStationJob】[錯誤行數] - {0}", line);
}
}
#endregion