1. bug fix
This commit is contained in:
parent
ab0aa1ee1d
commit
2ef57ba44d
@ -212,16 +212,29 @@ namespace SolarPower.Quartz.Jobs
|
||||
var dateNowDay = DateTimeNow.AddDays(-1).ToString("yyyy-MM-dd");
|
||||
var dateNowMonth = DateTimeNow.AddDays(-1).ToString("yyyy-MM");
|
||||
|
||||
Root2 observation = null;
|
||||
|
||||
#region 氣象觀測(取資料)
|
||||
try
|
||||
{
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始取得氣象觀測】");
|
||||
var client = new HttpClient();
|
||||
var UVUri = "https://opendata.cwb.gov.tw/api/v1/rest/datastore/F-C0032-001?Authorization=CWB-EA24220B-DDCC-4188-84E5-AD37A0E03F80&elementName=Wx,PoP&sort=time";
|
||||
HttpResponseMessage response = client.GetAsync(UVUri).Result;
|
||||
String jsonUVs = response.Content.ReadAsStringAsync().Result.ToString();
|
||||
Root2 observation = JsonConvert.DeserializeObject<Root2>(jsonUVs);
|
||||
observation = JsonConvert.DeserializeObject<Root2>(jsonUVs);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【取得成功氣象觀測】");
|
||||
#endregion
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError("【CalcAvgPowerStationJob】【取得失敗氣象觀測】");
|
||||
logger.LogError("【{0}】{1}", "CalcPowerStationJob", ex.Message);
|
||||
observation = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
if (observation != null)
|
||||
{
|
||||
foreach (var location in observation.Records.Location)
|
||||
{
|
||||
WeatherForecast weatherForecast = new WeatherForecast();
|
||||
@ -283,6 +296,8 @@ namespace SolarPower.Quartz.Jobs
|
||||
}
|
||||
weatherForecasts.AddRange(SubweatherForecasts);
|
||||
}
|
||||
}
|
||||
|
||||
List<string> weather_forecast_properties = new List<string>()
|
||||
{
|
||||
"LocationName",
|
||||
|
||||
@ -40,6 +40,8 @@ namespace SolarPower.Quartz.Jobs
|
||||
var DateTimeNow = DateTime.Now;
|
||||
var dateTime = DateTimeNow.AddHours(-1).ToString("yyyy-MM-dd HH");
|
||||
|
||||
var hasException = false;
|
||||
|
||||
Root2 observation = null;
|
||||
|
||||
if (this.environment.IsDevelopment())
|
||||
@ -87,6 +89,8 @@ namespace SolarPower.Quartz.Jobs
|
||||
|
||||
#region step2. 從電站的DB及電站編號找出該電站的控制器
|
||||
foreach (var powerStation in powerStations)
|
||||
{
|
||||
try
|
||||
{
|
||||
var calcPowerStation = new PowerStation();
|
||||
calcPowerStation.Id = powerStation.Id;
|
||||
@ -391,9 +395,11 @@ namespace SolarPower.Quartz.Jobs
|
||||
calcPowerStation.TodayWeather = weather.WeatherKey;
|
||||
calcPowerStation.RateOfRain = weather.PoP;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError("【{0}】{1}", "CalcPowerStationJob", exception.Message);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user