Exemplo n.º 1
0
        public Task Execute(IJobExecutionContext context)
        {
            _aerisJobParams    = AerisJobParamsValueOf(context);
            _weatherRepository = _weatherRepositoryValueOf(_aerisJobParams);

            //Log.Information("\nWeather job starting...\n");

            //var clock = System.Diagnostics.Stopwatch.StartNew();

            //GatherWeatherData();
            //clock.Stop();

            //var t = clock.Elapsed;

            //Log.Error(t.ToString());

            _sPRegressionJob.Execute(context);

            //PopulateWthExpUsageTable();

            //Log.Information($"WeatherData gathered and WthExpUsage calculated for Readings going back to {fromDateStart.ToShortDateString()}");
            //Log.Information("\nWeather job finished.\n");

            //PopulateWthNormalParams();

            return(Task.FromResult(0));
        }
        public void GetCountries()
        {
            IWeatherRepository _iWeatherRepository = null;

            _iWeatherRepository = new WeatherRepository();
            List <Country> expectedCountries = new List <Country>()
            {
                new Country(1, "Australia"),
                new Country(2, "America"),
                new Country(3, "England")
            };
            List <Country>    actualCountries = null;
            WeatherController wc = new WeatherController(_iWeatherRepository);

            wc.Request = new HttpRequestMessage()
            {
                Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } }
            };

            HttpResponseMessage response = wc.GetCountries();

            response.TryGetContentValue <List <Country> >(out actualCountries);

            Assert.AreEqual(expectedCountries, actualCountries);
        }
Exemplo n.º 3
0
 public WeatherController(IWeatherRepository weatherRepo, ISettingsRepository settingsRepo, IMapper mapper, IConfiguration config)
 {
     _settingsRepo = settingsRepo;
     _config       = config;
     _mapper       = mapper;
     _weatherRepo  = weatherRepo;
 }
Exemplo n.º 4
0
        public void Execute(IJobExecutionContext context)
        {
            _aerisJobParams    = AerisJobParamsValueOf(context);
            _weatherRepository = _weatherRepositoryValueOf(_aerisJobParams);

            _aerisJob = new AerisJob();

            Log.Information("Starting WNRdngData01RegressionJob...\n");

            _aerisJob.ExecuteZipHistoryCheckOnlyForRegression(context);

            _aerisJob = null;

            ////_weatherRepository.ClearWthNormalParams();

            PopulateWthNormalParams();

            _aerisJob = new AerisJob();

            _aerisJob.PopulateWthExpUsageTableAfterRegression(context);

            _aerisJob = null;

            Log.Information("\nFinished WNRdngData01RegressionJob. \n");
        }
Exemplo n.º 5
0
 public WeatherHandler(
     IWeatherRepository repository,
     IWeatherCalculator weatherCalculator)
 {
     _repository        = repository;
     _weatherCalculator = weatherCalculator;
 }
Exemplo n.º 6
0
        public void PopulateWthExpUsageTableAfterRegression(IJobExecutionContext context)
        {
            _aerisJobParams    = AerisJobParamsValueOf(context);
            _weatherRepository = _weatherRepositoryValueOf(_aerisJobParams);

            PopulateWthExpUsageTable();
        }
        public void GetWeatherDataByCity()
        {
            IWeatherRepository _iWeatherRepository = null;
            int cityID = 1;

            _iWeatherRepository = new WeatherRepository();
            tblTemperature expectedTempData = new tblTemperature();

            expectedTempData.CityID           = 1;
            expectedTempData.Location         = "Paramatta";
            expectedTempData.Preasure         = 30;
            expectedTempData.RelativeHumidity = 50;
            expectedTempData.SkyCondition     = "Good";
            expectedTempData.Visibility       = 1;
            expectedTempData.DewPoint         = 1;


            List <Country>    actualTempData = null;
            WeatherController wc             = new WeatherController(_iWeatherRepository);

            wc.Request = new HttpRequestMessage()
            {
                Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } }
            };
            HttpResponseMessage response = wc.GetWeatherDataByCity(cityID);

            response.TryGetContentValue <List <Country> >(out actualTempData);

            Assert.AreEqual(expectedTempData, actualTempData);
        }
Exemplo n.º 8
0
        public WeatherViewModel()
        {
            repository        = new OpenWeatherApiRepository();
            GetWeatherCommand = new Command(GetWeather);

            GetWeatherByCurrentLocationAsync();
        }
Exemplo n.º 9
0
        public SensorDataController()
        {
            _mqtt       = new Mqtt();
            _repository = new WeatherRepository(MongoDBConnector.GetInstance());
            HttpClient httpClient = new HttpClient();

            httpClient.PostAsync("http://sensoranalyticsservice/api/SensorAnalytics/CreateAnalyticsService", null);
        }
Exemplo n.º 10
0
 public WeatherListViewModel(IWeatherRepository weather)
 {
     _weather = weather;
     foreach (var entity in _weather.GetData())
     {
         Weathers.Add(new WeatherListViewModelWeather(entity));
     }
 }
        public WeatherController(ILogger <WeatherController> logger, IWeatherRepository weatherRepository)
        {
            _logger = logger ??
                      throw new ArgumentNullException(nameof(logger));

            _weatherRepository = weatherRepository ??
                                 throw new ArgumentNullException(nameof(weatherRepository));
        }
Exemplo n.º 12
0
 public CityAppService(ICityRepository cityRepository, IWeatherRepository weatherRepository, IMapper mapper, IRestClient restClient
                       )
 {
     _cityRepository    = cityRepository;
     _weatherRepository = weatherRepository;
     _mapper            = mapper;
     _restClient        = restClient;
 }
Exemplo n.º 13
0
        public WeatherService(IWeatherRepository weatherRepository)
        {
            if (ReferenceEquals(weatherRepository, null))
            {
                throw new ArgumentNullException("weatherRepository");
            }

            this._weatherRepository = weatherRepository;
        }
Exemplo n.º 14
0
 public WeatherForecastController(
     IWeatherRepository repository,
     IWeatherCacheRepository cacheRepository,
     ILogger <WeatherForecastController> logger)
 {
     this.repository      = repository;
     this.cacheRepository = cacheRepository;
     this.logger          = logger;
 }
Exemplo n.º 15
0
        private async Task InitDatabaseAsync(IWeatherRepository weatherRepository)
        {
            var cites = await weatherRepository.CityListAsyc();

            if (!cites.Any())
            {
                await weatherRepository.LoadStaticCityData();
            }
        }
Exemplo n.º 16
0
 public WeatherForecastController(ILogger <WeatherForecastController> logger, IWeatherRepository weatherRepository,
                                  IHubContext <WeatherHub, IWeatherHub> WeatherHub,
                                  IHubContext <NotificationHub, INotificationHub> notificationHub)
 {
     _logger = logger;
     this.weatherRepository = weatherRepository;
     this._weatherHub       = WeatherHub;
     this._notificationHub  = notificationHub;
 }
Exemplo n.º 17
0
 public OpenWeatherService(HttpClient httpClient,
                           IOptions <OpenWeatherSettings> options,
                           IWeatherRepository weatherRepository,
                           IMediatorHandler mediator) : base(mediator)
 {
     _appSettings           = options.Value;
     httpClient.BaseAddress = new Uri(_appSettings.WeatherBaseAddress);
     _httpClient            = httpClient;
     _weatherRepository     = weatherRepository;
 }
Exemplo n.º 18
0
        public WeatherLatestViewModel(IWeatherRepository weather, IAreaRepository areas)
        {
            _weather = weather;
            _areas   = areas;

            foreach (var area in _areas.Getdata())
            {
                Areas.Add(new AreaEntity(area.AreaID, area.AreaName));
            }
        }
        public MainWindowViewModel(
            ICountryRepository countryRepository,
            IWeatherRepository weatherRepository
            )
        {
            this.countryRepository = countryRepository;
            this.weatherRepository = weatherRepository;

            Countries = new ObservableCollection <Country>();
            LoadCountriesAsync();
        }
        public WeatherLatestViewModel(IWeatherRepository weather,
                                      IAreasRepository areas)  //テストコード用 モックを指定する
        {
            _weather = weather;
            _areas   = areas;

            foreach (var area in areas.GetData())
            {
                Areas.Add(new AreaEntity(area.AreaId, area.AreaName));
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// コンストラクター(引数あり)
        /// 呼び出し時に引数で指定し呼ばれる
        /// 評価と本番の切替ができる
        /// </summary>
        /// <param name="weather"></param>
        public WeathrLatestViewModel(IWeatherRepository weather, IAreasRepository areas)
        {
            // 引数ありも引数なしも、どちらからも呼ばれる
            _weather = weather;
            _areas   = areas;

            foreach (var area in _areas.GetData())
            {
                Areas.Add(new AreaEntity(area.AreaId, area.AreaName));
            }
        }
Exemplo n.º 22
0
 private async Task CreateRepositories(string cityCode)
 {
     HistoricalDataRepository = null;
     CurrentWeatherRepository =
         new AccuWeatherCurrentWeatherRepository(_restClient, $"currentconditions/v1/{cityCode}", _apiKey, _provider);
     HourlyForecastsRepository =
         new AccuWeatherHourlyForecastRepository(_restClient, $"forecasts/v1/hourly/12hour/{cityCode}", _apiKey, _provider);
     DailyForecastsRepository =
         new AccuWeatherDailyForecastRepository(_restClient, $"forecasts/v1/daily/5day/{cityCode}", _apiKey, _provider);
     await ChangeLanguage(Language);
 }
Exemplo n.º 23
0
        public WeatherLatestViewModel(IWeatherRepository weather,
                                      IAreasRepository areas)
        {
            _weather = weather;                    //weatherを _weatherに代入
            _areas   = areas;                      //areasを _areasに代入

            foreach (var area in _areas.GetData()) //foreachループ
            {
                Areas.Add(new AreaEntity(area.AreaId, area.AreaName));
            }
        }
Exemplo n.º 24
0
 private void CreateRepositories()
 {
     CurrentWeatherRepository =
         new OpenWeatherMapCurrentWeatherRepository(_restClient, "", _apiKey, _dateProvider, _coordinates);
     DailyForecastsRepository =
         new OpenWeatherMapDailyForecastsRepository(_restClient, "", _apiKey, _dateProvider, _coordinates);
     HourlyForecastsRepository =
         new OpenWeatherMapHourlyForecastsRepository(_restClient, "", _apiKey, _dateProvider, _coordinates);
     HistoricalDataRepository = null;
     ChangeLanguage(_language);
 }
Exemplo n.º 25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HomeController"/> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="geoCodeRepository">The geo code repository.</param>
 /// <param name="weatherRepository">The weather repository.</param>
 /// <param name="configuration">The configuration.</param>
 public HomeController(
     ILogger <HomeController> logger,
     IGeoCodeRepository geoCodeRepository,
     IWeatherRepository weatherRepository,
     IConfiguration configuration)
 {
     this.logger            = logger;
     this.geoCodeRepository = geoCodeRepository;
     this.weatherRepository = weatherRepository;
     this.configuration     = configuration;
 }
Exemplo n.º 26
0
 public WeatherForecastService(
     ICityRepository cityRepository,
     ICityToCityContractTranslator cityToCityContractTranslator,
     IWeatherRepository weatherRepository,
     IWeatherToWeatherContractTranslator weatherToWeatherContractTranslator)
 {
     _cityRepository = cityRepository;
     _cityToCityContractTranslator       = cityToCityContractTranslator;
     _weatherRepository                  = weatherRepository;
     _weatherToWeatherContractTranslator = weatherToWeatherContractTranslator;
 }
 public WeatherApiController(IMemoryCache cache,
                             IHttpClientFactory httpClientFactory,
                             IWeatherRepository weatherRepository,
                             INotificationDispatcher notificationDispatcher
                             )
 {
     _memoryCache            = cache;
     _httpClientFactory      = httpClientFactory;
     _weatherRepository      = weatherRepository;
     _notificationDispatcher = notificationDispatcher;
 }
Exemplo n.º 28
0
 public WeatherQueryApplicationService(
     IMapper mapper
     , IWeatherRepository weatherRepository
     , IJuHeApiRepository juHeApiRepository
     , IRedisCache redisCache
     )
 {
     this.mapper            = mapper;
     this.weatherRepository = weatherRepository;
     this.juHeApiRepository = juHeApiRepository;
     this.redisCache        = redisCache;
 }
Exemplo n.º 29
0
 public WeatherServiceTests()
 {
     CreateScope();
     _options = Options.Create(new OpenWeatherSettings()
     {
         WeatherAppId       = "a20bc11389c24a4d67419a201d95b798",
         WeatherBaseAddress = "http://api.openweathermap.org"
     });
     _weatherRepository = GetInstance <IWeatherRepository>();
     _mediatorHandler   = GetInstance <IMediatorHandler>();
     _notifications     = (NotificationHandler)GetInstance <INotificationHandler <Notification> >();
 }
Exemplo n.º 30
0
        public void ExecuteZipHistoryCheckOnlyForRegression(IJobExecutionContext context)
        {
            _aerisJobParams    = AerisJobParamsValueOf(context);
            _weatherRepository = _weatherRepositoryValueOf(_aerisJobParams);


            Log.Information("Checking if Historical WeatherData is needed...");

            try
            {
                _allZips = _weatherRepository.GetDistinctZipCodes();

                GatherHistoricalWeatherData(_allZips);

                //int difZip = 0;
                //List<WthNormalParams> allParams = _weatherRepository.GetAllParams();
                //foreach (WthNormalParams param in allParams)
                //{
                //    string bZip = _weatherRepository.GetBZip(param.AccID, 0, 0);

                //    if (bZip.Length > 0)
                //    {
                //        if (!bZip.Equals(param.ZipW))
                //        {
                //            difZip++;
                //            Log.Information("Different Zip. bZip: {0}, wnpZip: {1}", bZip, param.ZipW);
                //        }
                //    }
                //}
                //Log.Information("Different zips: {0}", difZip);

                if (newZipsDailyGatherNeededForRegression)
                {
                    GatherDailyWeatherData(-3, _allZips);

                    _actualZipDateEntriesTotal = _weatherRepository.GetZipDateRowCount();
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message + " " + ex.StackTrace);
            }

            if (newZipsDailyGatherNeededForRegression)
            {
                Log.Information($"Finished GatherWeatherData(). " +
                                $"Expected Total ZipDates Entries: {_expectedZipDateEntriesTotal}.. Actual: {_actualZipDateEntriesTotal}.\n");
            }

            _expectedZipDateEntriesTotal = 0;
            _actualZipDateEntriesTotal   = 0;
        }
Exemplo n.º 31
0
        public MyDayViewModel(IWeatherRepository weatherRepository, IProgressService progressService)
        {
            _weatherRepository = weatherRepository;

            _refreshCommand = new LoadingRelayCommand(Refresh);

            Forecasts = _weatherRepository.GetForecasts();
            if (!IsInDesignMode)
            {
                if (_refreshCommand.CanExecute(null))
                    _refreshCommand.Execute(null);
            }
        }
Exemplo n.º 32
0
 public WeatherAggregatorService(IWeatherRepository weatherRepository, IWeatherServiceStore weatherServiceStore, IWeatherUnitConverterService weatherUnitConverterService)
 {
     _weatherRepository = weatherRepository;
     _weatherServiceStore = weatherServiceStore;
     _weatherUnitConverterService = weatherUnitConverterService;
 }
 public WeatherController() {
     _repository = new Repository();
 }
Exemplo n.º 34
0
 public WeatherService(IWeatherRepository weatherRepository, ICityService cityService)
 {
     WeatherRepository = weatherRepository;
     CityService = cityService;
 }
Exemplo n.º 35
0
 public WeatherService(IWeatherRepository repo)
 {
     _repository = repo;
 }
 public GeonamesController(IWeatherRepository repo)
 {
     _repository = repo;
 }
Exemplo n.º 37
0
 public WeatherService(IWeatherRepository repository)
 {
     this._repository = repository;
 }
Exemplo n.º 38
0
 public WeatherService(IWeatherUnderGroundAdapter weatherUnderGroundAdapter, IWeatherRepository weatherRepository, ITypedConfiguration typedConfiguration)
 {
     _weatherUnderGroundAdapter = weatherUnderGroundAdapter;
     _weatherRepository = weatherRepository;
     _typedConfiguration = typedConfiguration;
 }