From 866b47cd438a7e0dc91ef316dccb9e9bfa14bdfe Mon Sep 17 00:00:00 2001 From: Kai Date: Wed, 11 Aug 2021 18:39:01 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=83=8C=E6=99=AF=E5=9F=B7=E8=A1=8C=20bug=20?= =?UTF-8?q?fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Quartz/Jobs/CalcPowerStationJob.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs b/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs index a042ccd..73ebb94 100644 --- a/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs +++ b/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs @@ -363,7 +363,7 @@ namespace SolarPower.Quartz.Jobs calcPowerStation.TodayWeatherTemp = Convert.ToDouble(Location.WeatherElement[0].ElementValue); weatherObservation.PowerStationId = powerStation.Id; weatherObservation.Temp = Convert.ToDouble(Location.WeatherElement[0].ElementValue); - weatherObservation.ObsTime = Convert.ToInt32(Location.Time.ObsTime.Substring(0, 4)) < 1970 ? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : Location.Time.ObsTime; + weatherObservation.ObsTime = !string.IsNullOrEmpty(Location.Time.ObsTime)? Convert.ToInt32(Location.Time.ObsTime.Substring(0, 4)) >= 1971 ? Location.Time.ObsTime : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); calcPowerStation.WeathersStationId = powerStation.WeathersStationId; break; }