void FetchNewForecasts(Station station, ForecastDataSource source, bool force = false) { if (!(force || source.IsNewDataReady(station))) { return; } Weather weather = null; try { weather = source.GetWeatherForecasts(station); OnFetchingSucceeded(station, source, weather.FetchedTime); } catch (ResponseParsingException e) { Trace.TraceError(String.Format("Response parsing error when fetching {0} forecast from {1}: {2}", station, source.Id, e.Message)); OnFetchingFailed(station, source, "ответ сервера не разобран"); failedCases.Add(new Tuple <ForecastDataSource, Station>(source, station)); } catch (StationQueryNotFoundException e) { Trace.TraceError(String.Format("Station query not found for {0} in station {1}. {2}", source.Id, station, e.Message)); OnFetchingFailed(station, source, "требуется строка запроса станции"); } catch (NoLatLongException e) { Trace.TraceError(String.Format("Coordinates of {0} needed for {1}. {2}", station, source.Id, e.Message)); OnFetchingFailed(station, source, "требуются координаты станции"); } catch (NoStationOffsetException e) { Trace.TraceError(String.Format("UTC offset of {0} needed for {1}. {2}", station, source.Id, e.Message)); OnFetchingFailed(station, source, "требуется часовой пояс станции"); } if (weather != null) { ForecastsDatabase.Save(weather); } return; }
void FetchRealData(Station station, RealDataSource source, bool force = false) { if (!(force || !source.IsNewDataReady(station))) { return; } Weather weather = null; try { weather = source.GetWeatherReal(station); OnFetchingSucceeded(station, source, weather.FetchedTime); } catch (ResponseParsingException e) { Trace.TraceError(String.Format("Response parsing error when fetching {0} forecast from {1}: {2}", station, source.Id, e.Message)); OnFetchingFailed(station, source, "ответ сервера не разобран"); } catch (NoLatLongException e) { Trace.TraceError(String.Format("Coordinates of {0} needed for {1}. {2}", station, source.Id, e.Message)); OnFetchingFailed(station, source, "требуются координаты станции"); } catch (NoStationOffsetException e) { Trace.TraceError(String.Format("UTC offset of {0} needed for {1}. {2}", station, source.Id, e.Message)); OnFetchingFailed(station, source, "требуется часовой пояс станции"); } if (weather != null) { ForecastsDatabase.Save(weather); } return; }