示例#1
0
 public void SetUp()
 {
     openWeatherService = new OpenWeatherService();
     xmlService = new XmlService();
     weatherString = File.ReadAllText(StaticPath.daily);
     weatherDocument = xmlService.GetXmlDoc(weatherString);
 }
示例#2
0
        List<Weather> IOpenWeatherService.GetWeathers(IOpenWeatherService openWeatherService, IXmlService xmlService, XDocument weatherDocument, WeatherForecast weatherForecast)
        {
            List<Weather> weathers =
                   (from w in weatherDocument.Descendants("time")

                    select new Weather
                    {
                        ForecastDaysPlus = (int)(Convert.ToDateTime(w.Attribute("day").Value) - DateTime.Now.Date).TotalDays,
                        Date = Convert.ToDateTime(w.Attribute("day").Value),
                        Symbol = w.Element("symbol").Attribute("name").Value,
                        WeatherForecast = weatherForecast,
                        Clouds = CreateClouds(xmlService, w),
                        Humidity = CreateHumidity(xmlService, w),
                        Precipitation = CreatePrecipitation(xmlService, w),
                        Pressure = CreatePressure(xmlService, w),
                        Temperature = new Temperature
                                        {
                                            Day = Convert.ToDecimal(w.Element("temperature").Attribute("day").Value, CultureInfo.InvariantCulture),
                                            Morn = Convert.ToDecimal(w.Element("temperature").Attribute("morn").Value, CultureInfo.InvariantCulture),
                                            Eve = Convert.ToDecimal(w.Element("temperature").Attribute("eve").Value, CultureInfo.InvariantCulture),
                                            Night = Convert.ToDecimal(w.Element("temperature").Attribute("night").Value, CultureInfo.InvariantCulture),
                                            Max = Convert.ToDecimal(w.Element("temperature").Attribute("max").Value, CultureInfo.InvariantCulture),
                                            Min = Convert.ToDecimal(w.Element("temperature").Attribute("min").Value, CultureInfo.InvariantCulture)
                                        },
                        Wind = CreateWind(xmlService, w),
                    }).ToList<Weather>();

            return weathers;
        }
 public HomeController(IOpenWeatherService service, ICloudQueueService queueCommunicator, IMapService mapServices, IImageHelper imageHelper, ICloudBlobService cloudBlobService)
 {
     this.service            = service;
     this._queueCommunicator = queueCommunicator;
     this.mapServices        = mapServices;
     this.imageHelper        = imageHelper;
     this._cloudBlobService  = cloudBlobService;
 }
示例#4
0
 public MeteoService(IRepository<Location> locationRepository, IRepository<WeatherForecast> weatherForecastRepository)
 {
     _locationRepository = locationRepository;
     _weatherForecastRepository = weatherForecastRepository;
     _xmlService = new XmlService();
     _webClientService = new WebClientService();
     _openWeatherService = new OpenWeatherService();
     _worldWeatherOnlineService = new WorldWeatherOnlineService();
 }
示例#5
0
 public List<WeatherForecast> GetHistoricalWeatherList(string apiKey, List<string> cityNameList, string date, string endDate, IWebClientService webClientService, IXmlService xmlService, IOpenWeatherService openWeatherService)
 {
     List<WeatherForecast> weatherHistoricalForecast = new List<WeatherForecast>();
     foreach (string cityName in cityNameList)
     {
         List<WeatherForecast> weatherHistoricalForecastByCity = GetHistoricalWeatherList(apiKey, cityName, date, endDate, webClientService, xmlService, openWeatherService);
         weatherHistoricalForecast.AddRange(weatherHistoricalForecastByCity);
     }
     return weatherHistoricalForecast;
 }
示例#6
0
 public GenerateBeerReportCommandHandler(ICloudQueueService queueCommunicator, ICloudBlobService cloudBlobService,
                                         IMapService mapServices, IOpenWeatherService openWeatherService,
                                         IImageHelper imageHelper, ITemperatureConverter temperatureConverter)
 {
     this._queueCommunicator    = queueCommunicator;
     this._mapServices          = mapServices;
     this._openWeatherService   = openWeatherService;
     this._imageHelper          = imageHelper;
     this._temperatureConverter = temperatureConverter;
     this._cloudBlobService     = cloudBlobService;
 }
示例#7
0
        public void InitTest()
        {
            xmlServiceMock = new Mock<IXmlService>();
            webClientServiceMock = new Mock<IWebClientService>();
            openWeatherServiceMock = new Mock<IOpenWeatherService>();
            xmlService = new XmlService();
            webClientService = new WebClientService();
            openWeatherService = new OpenWeatherService();

            IDbContext dbContext = new MeteoContext();
            IRepository<Location> locationRepository = new EfRepository<Location>(dbContext);
            IRepository<WeatherForecast> weatherForecastRepository = new EfRepository<WeatherForecast>(dbContext);
            meteoService = new MeteoService(locationRepository, weatherForecastRepository);
        }
        public ConfiguracoesPageViewModel(INavigationService navigationService,
                                          IOpenWeatherService openWeatherService,
                                          IFirebaseService firebaseService,
                                          IPageDialogService pageDialogService) : base(navigationService)
        {
            _openWeatherService = openWeatherService;
            _firebaseService    = firebaseService;
            _pageDialogService  = pageDialogService;

            ClimaAtual = new ClimaAtual();

            Title = "Configurações";

            SalvarConfiguracoesCommand = new DelegateCommand(async() => await SalvarConfiguracoes(), PodeExecutarSalvarConfiguracoesCommand);
        }
示例#9
0
 public List<WeatherForecast> GetHistoricalWeatherList(string apiKey, string cityName, string date, string endDate, IWebClientService webClientService, IXmlService xmlService, IOpenWeatherService openWeatherService)
 {
     //string url = @"http://api.worldweatheronline.com/free/v2/past-weather.ashx?key={apiKey}&q={cityName}&format=xml&includeLocation=yes&date={date}&enddate={endDate}";
     string url = ConfigurationManager.AppSettings["historicalWeatherUrl"];
     url = url.Replace("{apiKey}", apiKey);
     url = url.Replace("{cityName}", cityName);
     url = url.Replace("{date}", date);
     url = url.Replace("{endDate}", endDate);
     LogHelper.WriteToLog("meteo.log", url);
     string weatherString = webClientService.Get(url);
     XDocument weatherDocument = xmlService.GetXmlDoc(weatherString);
     Location location = GetLocation(cityName);
     List<WeatherForecast> weatherHistoricalForecast = _worldWeatherOnlineService.GetWeatherHistoricalForecast(_worldWeatherOnlineService, xmlService, weatherDocument, location);
     return weatherHistoricalForecast;
 }
示例#10
0
        public WeatherForecast GetWeatherForecast(IOpenWeatherService openWeatherService, IXmlService xmlService, XDocument weatherDocument, List<Location> currentLocations, int forecastDaysCount)
        {
            Location location = openWeatherService.GetLocation(weatherDocument, currentLocations);

            WeatherForecast weatherForecast = new WeatherForecast()
            {
                Location = location,
                Time = DateTime.Now,
                ForecastDaysQuantity = forecastDaysCount
            };

            List<Weather> weathers = openWeatherService.GetWeathers(openWeatherService, xmlService, weatherDocument, weatherForecast);
            weatherForecast.Weathers = weathers;
            return weatherForecast;
        }
示例#11
0
        public MainPageViewModel(INavigationService navigationService, IBattutaService battutaService, IOpenWeatherService openWeatherService, IPageDialogService pageDialogService) : base(navigationService)
        {
            _navigationService  = navigationService;
            _battutaService     = battutaService;
            _openWeatherService = openWeatherService;
            _pageDialogService  = pageDialogService;
            Title = "Busca";

            Paises  = new ObservableCollection <Pais>();
            Estados = new ObservableCollection <Estado>();
            Cidades = new ObservableCollection <Cidade>();

            AtualizarListaEstadosCommand = new DelegateCommand(async() => await PreencherEstados());
            AtualizarListaCidadesCommand = new DelegateCommand(async() => await PreencherCidades());
            IrParaConfiguracoesCommand   = new DelegateCommand(async() => await IrParaConfiguracoes(), PodeExecutarIrParaConfiguracoesCommand);
        }
示例#12
0
 public SettingsPresenter(ISettingsView view)
 {
     this.view = view;
     try
     {
         xmlService = new XmlService();
         webClientService = new WebClientService();
         openWeatherService = new OpenWeatherService();
         dbContext = new MeteoContext();
         locationRepository = new EfRepository<Location>(dbContext);
         weatherForecastRepository = new EfRepository<WeatherForecast>(dbContext);
         meteoService = new MeteoService(locationRepository, weatherForecastRepository);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
示例#13
0
 public UserInfoService(IUserInfoRepository userInfoRepository,
                        IMapper mapper,
                        IValidateUserInfo validateUserInfo,
                        IOpenWeatherService openWeatherService,
                        IRecommendedSpotifyPlaylistService recommendedSpotifyPlaylistService,
                        IUserInfoHistoryRepository userInfoHistoryRepository,
                        IIdentityService identityService,
                        IEntityHistoryFactory entityHistoryFactory)
 {
     _userInfoRepository = userInfoRepository;
     _mapper             = mapper;
     _validateUserInfo   = validateUserInfo;
     _openWeatherService = openWeatherService;
     _recommendedSpotifyPlaylistService = recommendedSpotifyPlaylistService;
     _userInfoHistoryRepository         = userInfoHistoryRepository;
     _identityService      = identityService;
     _entityHistoryFactory = entityHistoryFactory;
 }
 public WeatherForecastController(ILogger <WeatherForecastController> logger, IOpenWeatherService weatherService)
 {
     _logger         = logger;
     _weatherService = weatherService;
 }
 public WeatherController(IOpenWeatherService openWeatherService, IWeatherForecastRepository weatherForecastRepository)
 {
     _openWeatherService        = openWeatherService;
     _weatherForecastRepository = weatherForecastRepository;
 }
 public WeatherController(IOpenWeatherService weatherService)
 {
     _weatherService = weatherService;
 }
示例#17
0
 public WeatherController(IOpenWeatherService openWeatherService,
                          INotificationHandler <Notification> notifications,
                          IMediatorHandler mediatorHandler) : base(notifications, mediatorHandler)
 {
     _openWeatherService = openWeatherService;
 }
示例#18
0
 public WeatherForecast GetWeather(string city, int forecastDaysCount, IWebClientService webClientService, IXmlService xmlService, IOpenWeatherService openWeatherService, List<Location> currentLocations)
 {
     string url = "http://api.openweathermap.org/data/2.5/forecast/daily?q=city&mode=xml&units=metric&cnt=forecastDaysCount";
     url = url.Replace("city", city);
     url = url.Replace("forecastDaysCount", forecastDaysCount.ToString());
     string weatherString = webClientService.Get(url);
     XDocument weatherDocument = xmlService.GetXmlDoc(weatherString);
     WeatherForecast weatherForecast = openWeatherService.GetWeatherForecast(openWeatherService, xmlService, weatherDocument, currentLocations, forecastDaysCount);
     return weatherForecast;
 }
示例#19
0
 public CalendarService(IOpenWeatherService openWeatherService)
 {
     _openWeatherService = openWeatherService;
 }
示例#20
0
 public ForecastController(IOpenWeatherService openWeatherService)
 {
     this.openWeatherService = openWeatherService;
 }
 public ForecastController(IOpenWeatherService service)
 {
     _service = service;
 }
示例#22
0
 public List<WeatherForecast> GetWeatherList(List<string> cityList, int forecastDaysCount, IWebClientService webClientService, IXmlService xmlService, IOpenWeatherService openWeatherService)
 {
     List<WeatherForecast> weatherForecasts = new List<WeatherForecast>();
     List<Location> currentLocations = GetLocations();
     foreach (string city in cityList)
     {
         WeatherForecast weatherForecast = GetWeather(city, forecastDaysCount, webClientService, xmlService, openWeatherService, currentLocations);
         weatherForecasts.Add(weatherForecast);
     }
     return weatherForecasts;
 }
示例#23
0
 public ImportarTemperaturaJob(IOpenWeatherService openWeatherService, ILogger <ImportarTemperaturaJob> logger, ITemperaturaService temperaturaService)
 {
     _openWeatherService = openWeatherService;
     _logger             = logger;
     _temperaturaService = temperaturaService;
 }
示例#24
0
 public WeatherDetailsApiController(IOpenWeatherService webApiService, ILogger logger)
 {
     _openWeatherService = webApiService;
     _logger             = logger;
 }
示例#25
0
 public WeatherQueryService(IWeatherCityRepository weatherCityRepository,
                            IOpenWeatherService weatherCityService)
 {
     _weatherCityRepository = weatherCityRepository;
     _weatherCityService    = weatherCityService;
 }
示例#26
0
 public GetCurrentWeatherForecastQueryHandler(IOpenWeatherService openWeatherService, IMapper mapper)
 {
     _openWeatherService = openWeatherService;
     _mapper             = mapper;
 }
 public UpdateSunriseSunsetHandler(IOpenWeatherService openWeatherService)
 {
     _openWeatherService = openWeatherService;
 }
示例#28
0
 /// <summary>
 ///     Initializes a new instance of the weather service
 /// </summary>
 /// <param name="apiKey">The API key to use.</param>
 /// <param name="handler">the http message handler. If null use the default one.</param>
 public OpenWeatherWrapper(string apiKey, HttpMessageHandler handler)
 {
     _service = new OpenWeatherService(apiKey, handler);
 }
示例#29
0
 public WeatherController(IOpenWeatherService openWeatherService)
 {
     _openWeatherService = openWeatherService;
 }