Revize 293051ee
Přidáno uživatelem Alex Konig před více než 3 roky(ů)
Server/ServerApp/WeatherPredictionParser/JsonParser.cs | ||
---|---|---|
8 | 8 |
using ServerApp.Parser.OutputInfo; |
9 | 9 |
using System; |
10 | 10 |
using System.Collections.Generic; |
11 |
using System.Diagnostics; |
|
11 | 12 |
using System.Globalization; |
12 | 13 |
using System.Text.Json; |
13 | 14 |
using static System.Text.Json.JsonElement; |
... | ... | |
34 | 35 |
/// <summary> Sunset time of currently parsed day </summary> |
35 | 36 |
List<DateTime> sunsetTime; |
36 | 37 |
|
38 |
/// <summary> Last prediction </summary> |
|
39 |
private string data; |
|
40 |
/// <summary> Stopwatch for measuring time </summary> |
|
41 |
Stopwatch sw = new Stopwatch(); |
|
42 |
|
|
37 | 43 |
/// <summary> |
38 | 44 |
/// Constructor |
39 | 45 |
/// </summary> |
... | ... | |
42 | 48 |
{ |
43 | 49 |
this.downloader = downloader; |
44 | 50 |
this.loader = loader; |
51 |
data = null; |
|
52 |
sw.Start(); |
|
45 | 53 |
} |
46 | 54 |
|
47 | 55 |
/// <summary> |
... | ... | |
117 | 125 |
//string data = loader.LoadPredictionFile(file); |
118 | 126 |
|
119 | 127 |
// get data |
120 |
string data = downloader.DownloadWeatherPrediction(); |
|
128 |
if (data == null || data.Trim().Length == 0 || (int)((sw.ElapsedMilliseconds / 1000.0) / 60.0) >= 60) |
|
129 |
{ |
|
130 |
data = downloader.DownloadWeatherPrediction(); |
|
131 |
sw = new Stopwatch(); |
|
132 |
sw.Start(); |
|
133 |
} |
|
121 | 134 |
|
122 | 135 |
DateTime now = DateTime.Now; |
123 | 136 |
|
... | ... | |
166 | 179 |
_log.Error("Weather prediction file in incorrect format"); |
167 | 180 |
Current = new WeatherInfo(); |
168 | 181 |
Predictions = new List<WeatherInfo>(); |
182 |
data = null; |
|
169 | 183 |
} |
170 | 184 |
|
171 | 185 |
//TestConsoleOutput(); |
Také k dispozici: Unified diff
re #9036 Edit JsonParser so it downloads new weather only 1 per h