コード例 #1
0
ファイル: Program.cs プロジェクト: bakuuu/meteo
 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();
 }
コード例 #2
0
ファイル: MeteoSvc.cs プロジェクト: bakuuu/meteo
 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;
     }
 }