Esempio n. 1
0
 static void Main(string[] args)
 {
     IDbContext context = new MeteoContext();
     IRepository<Location> locationRepository = new EfRepository<Location>(context);
     IRepository<WeatherForecast> weatherForecastRepository = new EfRepository<WeatherForecast>(context);
     IMeteoService meteoService = new MeteoService(locationRepository, weatherForecastRepository);
     //Weather prognoza = meteoService.GetWeather("Bydgoszcz", "205-07-12");
     //Console.WriteLine(prognoza);
     IXmlService xmlService = new XmlService();
     List<string> cities = meteoService.GetCities("cities.xml", xmlService);
     foreach (var city in cities)
     {
         Console.WriteLine(city);
     }
     Console.ReadLine();
 }
Esempio n. 2
0
 private void GetMeteoInfo()
 {
     try
     {
         IXmlService xmlService = new XmlService();
         WebClientService webClientService = new WebClientService();
         OpenWeatherService openWeatherService = new OpenWeatherService();
         IDbContext context = new MeteoContext();
         IRepository<Location> locationRepository = new EfRepository<Location>(context);
         IRepository<WeatherForecast> weatherForecastRepository = new EfRepository<WeatherForecast>(context);
         IMeteoService meteoService = new MeteoService(locationRepository, weatherForecastRepository);
         List<string> cities = meteoService.GetCities(AppDomain.CurrentDomain.BaseDirectory + @"\cities.xml", xmlService);
         List<WeatherForecast> weatherList = meteoService.GetWeatherList(cities, 16, webClientService, xmlService, openWeatherService);
         meteoService.SaveWeatherList(weatherList);
         LogHelper.WriteToLog(logName, string.Format("forecast weather {0} saved", DateTime.Now));
     }
     catch(Exception ex)
     {
         LogHelper.WriteToLog(logName, ex.Message);
         throw;
     }
 }