Beispiel #1
0
 public WeatherService(HttpClient client, IHttpContextAccessor context, IWeatherProvider provider, ILogger <WeatherService> logger)
 {
     _client   = client;
     _context  = context;
     _provider = provider;
     _logger   = logger;
 }
 public WeatherForecastController(
     ILogger <WeatherForecastController> logger,
     IWeatherProvider weatherProvider)
 {
     this.logger          = logger;
     this.weatherProvider = weatherProvider;
 }
Beispiel #3
0
        public WeatherModule(IWeatherProvider weatherProvider)
        {
            Get("/", args => "/current/{zip}");

            Get("/current/{zip}", args =>
            {
                var zip = args["zip"];
                try
                {
                    var serializedWeather = JsonConvert.SerializeObject(weatherProvider.GetCurrent(zip));
                    var weatherBytes      = Encoding.UTF8.GetBytes(serializedWeather);

                    return(new Response
                    {
                        StatusCode = HttpStatusCode.OK,
                        ContentType = "application/json",
                        Contents = s => s.Write(weatherBytes, 0, weatherBytes.Length)
                    });
                }
                catch (CommunicationException e)
                {
                    var exceptionMessageBytes = Encoding.UTF8.GetBytes(e.Message);

                    return(new Response
                    {
                        StatusCode = HttpStatusCode.ServiceUnavailable,
                        ContentType = "application/json",
                        Contents = s => s.Write(exceptionMessageBytes, 0, exceptionMessageBytes.Length)
                    });
                }
            });
        }
 public AveragetemperatureDisplay(IWeatherProvider wd)
 {
     weatherData = wd;
     temperatures = new List<float>();
     humidities = new List<float>();
     pressures = new List<float>();
 }
Beispiel #5
0
 public LightManager(ITelldus telldus, IWeatherProvider weatherProvider)
 {
     _telldus         = telldus;
     _weatherProvider = weatherProvider;
     _sections        = new Collection <LampSection>();
     SetupSections();
 }
 public CurrentConditionsDisplay(IWeatherProvider wd)
 {
     weatherData = wd;
     tempurature = 0.0F;
     humidity = 0.0F;
     pressure = 0.0F;
 }
Beispiel #7
0
 public void Add(IWeatherProvider provider)
 {
     if (!_providersList.Contains(provider))
     {
         _providersList.Add(provider);
     }
 }
 public TenDaysWeatherProvider(
     ICityInfoProvider cityInfoProvider,
     IWeatherProvider weatherProvider)
 {
     _cityInfoProvider = cityInfoProvider;
     _weatherProvider  = weatherProvider;
 }
Beispiel #9
0
        private async void BeginInitialize()
        {
            // Setup the database.
            db = new DatabaseHelper(this);
            // Use the intent values to bind to a specific network ID.
            long networkID = Intent.GetLongExtra(EXTRA_NETWORK_ID, -1);

            if (networkID != -1)
            {
                solarNetwork = await db.SolarNetworks.SelectByIdAsync(networkID);

                SupportActionBar.Title = solarNetwork.Name;
            }
            else
            {
                throw new InvalidProgramException();
            }

            // Get the weather service.
            weatherProvider = ServiceManager.Resolve <IWeatherProvider>();
            // Get the calculator service.
            powerCalculator = ServiceManager.Resolve <IPowerCalculator>();
            // Initialize the PVWatts Client.
            pvWattsApiClient = new PVWattsV5ApiClient(apiKey: Secrets.PVWattsApiKey);

            // Setup the network card
            InitializeCards();
        }
Beispiel #10
0
        /// <summary>
        /// Sends Weather.
        /// </summary>
        private static void Weather(Action <Packet> sender, IWeatherProvider provider)
        {
            var packet = new Packet(Op.Weather, MabiId.Broadcast);

            packet.PutByte(0);
            packet.PutInt(provider.RegionId);

            if (provider is IWeatherProviderTable)
            {
                var table = (IWeatherProviderTable)provider;

                packet.PutByte(0);
                packet.PutInt(table.GroupId);
                packet.PutByte(2);
                packet.PutByte(1);
                packet.PutString("table");
                packet.PutString(table.Name);
                packet.PutLong(0);
                packet.PutByte(0);
            }
            else if (provider is IWeatherProviderConstant)
            {
                var constant = (IWeatherProviderConstant)provider;

                // Packet structure is guessed, even though it works,
                // based on constant_smooth.
                packet.PutByte(2);
                packet.PutByte(0);
                packet.PutByte(1);
                packet.PutString("constant");
                packet.PutFloat(constant.Weather);
                packet.PutLong(0);
                packet.PutByte(0);
            }
            else if (provider is IWeatherProviderConstantSmooth)
            {
                var constantSmooth = (IWeatherProviderConstantSmooth)provider;

                packet.PutByte(2);
                packet.PutByte(0);
                packet.PutByte(1);
                packet.PutString("constant_smooth");
                packet.PutFloat(constantSmooth.Weather);
                packet.PutLong(DateTime.Now);                 // Start
                packet.PutLong(DateTime.MinValue);            // End
                packet.PutFloat(constantSmooth.WeatherBefore);
                packet.PutFloat(constantSmooth.WeatherBefore);
                packet.PutLong(constantSmooth.TransitionTime);
                packet.PutByte(false);                 // bool? Is table appended? byte? Appended type?
                packet.PutLong(DateTime.MinValue);     // End
                packet.PutInt(2);

                // Append a table packet here to go back to that after end

                packet.PutByte(0);
            }

            sender(packet);
        }
Beispiel #11
0
 public WeatherService(ILogger <WeatherService> logger,
                       WeatherServiceSettings settings,
                       IWeatherProvider weatherProvider)
 {
     _logger          = logger;
     _settings        = settings;
     _weatherProvider = weatherProvider;
 }
Beispiel #12
0
 public IEnumerable <WeatherForecast> GetForeCast(string location, IWeatherProvider weatherProvider)
 {
     if (weatherProvider == null)
     {
         throw new ArgumentNullException(nameof(weatherProvider));
     }
     return(weatherProvider.GetForecastOfLocation(location));
 }
Beispiel #13
0
 public WeatherController(ILogger logger, IStorage storage, IWeatherProvider provider, IWeatherDisplayer displayer)
 {
     _logger             = logger;
     _storage            = storage;
     _provider           = provider;
     _displayer          = displayer;
     _storage.DataSaved += _displayer.Display;
 }
Beispiel #14
0
        /// <summary>
        // Gets the Weather Information for given cityId
        /// </summary>
        /// <param name="cityId"></param>
        /// <returns>WheatheInfo</returns>
        public async Task <WeatherInfo> Get(string cityId)
        {
            var WeatherProvider          = new WeatherProvider();
            IWeatherProvider Weather     = WeatherProvider.FactoryMethod(_WeatherInfoProvider);
            WeatherInfo      WeatherInfo = await Weather.GetWeatherInfo(cityId);

            return(WeatherInfo);
        }
Beispiel #15
0
 public InputParserEntryPoint(IInteractionStrategy sender, DatabaseWorkerProxy proxy, string owmToken)
 {
     sender.Incoming += Incoming;
     _database        = proxy;
     _parser          = new InputParser();
     _directSender    = new OutcomingSender();
     _weather         = new OpenWeatherMap(owmToken);
 }
 public WeatherFinder(
     [Dependency("Bbc")]IWeatherProvider bbcWeatherProvider,
     [Dependency("Accu")]IWeatherProvider accuWeatherProvider
     )
 {
     _bbcWeatherProvider = bbcWeatherProvider;
     _accuWeatherProvider = accuWeatherProvider;
 }
 public WeatherFinder(
     [Dependency("Bbc")] IWeatherProvider bbcWeatherProvider,
     [Dependency("Accu")] IWeatherProvider accuWeatherProvider
     )
 {
     _bbcWeatherProvider  = bbcWeatherProvider;
     _accuWeatherProvider = accuWeatherProvider;
 }
Beispiel #18
0
		/// <summary>
		/// Sends Weather.
		/// </summary>
		private static void Weather(Action<Packet> sender, IWeatherProvider provider)
		{
			var packet = new Packet(Op.Weather, MabiId.Broadcast);
			packet.PutByte(0);
			packet.PutInt(provider.RegionId);

			if (provider is IWeatherProviderTable)
			{
				var table = (IWeatherProviderTable)provider;

				packet.PutByte(0);
				packet.PutInt(table.GroupId);
				packet.PutByte(2);
				packet.PutByte(1);
				packet.PutString("table");
				packet.PutString(table.Name);
				packet.PutLong(0);
				packet.PutByte(0);
			}
			else if (provider is IWeatherProviderConstant)
			{
				var constant = (IWeatherProviderConstant)provider;

				// Packet structure is guessed, even though it works,
				// based on constant_smooth.
				packet.PutByte(2);
				packet.PutByte(0);
				packet.PutByte(1);
				packet.PutString("constant");
				packet.PutFloat(constant.Weather);
				packet.PutLong(0);
				packet.PutByte(0);
			}
			else if (provider is IWeatherProviderConstantSmooth)
			{
				var constantSmooth = (IWeatherProviderConstantSmooth)provider;

				packet.PutByte(2);
				packet.PutByte(0);
				packet.PutByte(1);
				packet.PutString("constant_smooth");
				packet.PutFloat(constantSmooth.Weather);
				packet.PutLong(DateTime.Now); // Start
				packet.PutLong(DateTime.MinValue); // End
				packet.PutFloat(constantSmooth.WeatherBefore);
				packet.PutFloat(constantSmooth.WeatherBefore);
				packet.PutLong(constantSmooth.TransitionTime);
				packet.PutByte(false); // bool? Is table appended? byte? Appended type?
				packet.PutLong(DateTime.MinValue); // End
				packet.PutInt(2);

				// Append a table packet here to go back to that after end

				packet.PutByte(0);
			}

			sender(packet);
		}
 public WeatherForecastController(
     IForecastProvider forecastProvider,
     IWeatherProvider weatherProvider,
     IOptions <WeatherForecastProviderSettings> weatherForecastProviderSettingsAccessor)
 {
     _forecastProvider = forecastProvider;
     _weatherProvider  = weatherProvider;
     _weatherForecastProviderSettings = weatherForecastProviderSettingsAccessor.Value;
 }
Beispiel #20
0
        public WeatherSkypnetModule(IWeatherProvider weatherProvider)
        {
            if (weatherProvider == null)
            {
                throw new ArgumentNullException("weatherProvider");
            }

            this.weatherProvider = weatherProvider;
        }
Beispiel #21
0
        public WeatherSkypnetModule(IWeatherProvider weatherProvider)
        {
            if (weatherProvider == null)
            {
                throw new ArgumentNullException("weatherProvider");
            }

            this.weatherProvider = weatherProvider;
        }
Beispiel #22
0
        public PVOutput(IAppSettings appSettings, ILogger logger, IWeatherProvider weatherProvider)
        {
            apiKey               = appSettings.PVOutputApiKey;
            systemId             = appSettings.PVOutputSystemId;
            this.logger          = logger;
            this.weatherProvider = weatherProvider;

            logger.WriteLine($"Use PVOutput: {systemId}");
        }
Beispiel #23
0
        public static IWeatherProvider get()
        {
            if (_self == null)
            {
                _self = new WeatherProviderNGS();
            }

            _refcounter++;
            return(_self);
        }
Beispiel #24
0
        public static IWeatherProvider get(IWeatherReader reader = null)
        {
            if (_self == null)
            {
                _self = new WeatherProviderYandex(reader);
            }

            _refcounter++;
            return(_self);
        }
        public async Task <IEnumerable <DailyWeatherBE> > GetWeatherForecasts(WeatherProviderType providerType, WeatherParamsData model)
        {
            IWeatherProvider provider = _providers.FirstOrDefault(x => x.ProviderType == providerType);

            if (provider == null)
            {
                throw new NotSupportedException(nameof(providerType));
            }

            return(await provider.GetWeatherForecasts(model));
        }
 public CachedWeatherProvider(
     ILogger <IWeatherProvider> logger,
     IWeatherProviderFactory weatherProviderFactory,
     IMemoryCache memoryCache,
     IOptions <CachedWeatherProviderSettings> settings)
 {
     _internalProvider = weatherProviderFactory.GetWeatherProvider(settings.Value.InternalType);
     _logger           = logger;
     _memoryCache      = memoryCache;
     _settings         = settings;
 }
        public JsonResult Get(string provider, decimal latitude, decimal longitude)
        {
            var weatherDashboardModel = new WeatherDashboardModel();

            weatherProvider       = DependencyConfig.Container.GetInstance <IWeatherProvider>(provider);
            weatherDashboardModel = weatherProvider.GetForecast(latitude, longitude);

            var model = mapper.Map(weatherDashboardModel);

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
        public ModifyWeatherController(IWeatherProvider provider)
        {
            _provider       = provider;
            HighTextControl = new TextControl();

            var conditions = provider.GetCurrentWeatherConditions();

            _currentConditions   = conditions;
            Condition            = conditions.Condition;
            HighTextControl.Text = conditions.High.ToString();
            Low = conditions.Low;
        }
Beispiel #29
0
 public DashboardController(
     ILogger <HomeController> logger,
     IPhotoProvider photoProvider,
     IWeatherProvider weatherProvider,
     IQuoteRepository quoteRepository,
     UserManager <ApplicationUser> userManager)
 {
     _logger          = logger;
     _photoProvider   = photoProvider;
     _weatherProvider = weatherProvider;
     _quoteRepository = quoteRepository;
     _userManager     = userManager;
 }
Beispiel #30
0
 public WeatherService(IWeatherProvider weatherProvider)
 {
     _weatherProvider = weatherProvider;
     _weatherIdsMap   = new Dictionary <int, Weather>()
     {
         { 200, Weather.ThunderStorm },
         { 300, Weather.Drizzle },
         { 500, Weather.Rain },
         { 600, Weather.Snow },
         { 800, Weather.Sunny },
         { 802, Weather.Cloudy }
     };
 }
        private void update_Humidity(IWeatherProvider provider, WeatherPeriod period)
        {
            double hum;

            if (provider.get_humidity(period, out hum))
            {
                Humidity = hum;
                Weather_Status_Humidity = true;
            }
            else
            {
                Weather_Status_Humidity = false;
            }
        }
        private void update_Pressure(IWeatherProvider provider, WeatherPeriod period)
        {
            double press;

            if (provider.get_pressure(period, out press))
            {
                Pressure = press;
                Weather_Status_Pressure = true;
            }
            else
            {
                Weather_Status_Pressure = false;
            }
        }
Beispiel #33
0
 private static void SetupServices()
 {
     weatherProvider = new WeatherProvider(new List <IApiService>
     {
         new BbcWeather()
         {
             Location = LocationInput
         },
         new AccWeather()
         {
             Where = LocationInput
         }
     });
 }
Beispiel #34
0
        public void Init()
        {
            apis = new List <IApiService>
            {
                new AccWeather {
                    TemperatureFahrenheit = 68, WindSpeedMph = 10
                },
                new BbcWeather {
                    TemperatureCelsius = 10, WindSpeedKph = 8
                }
            };

            apiServices = new WeatherProvider(apis);
        }
Beispiel #35
0
        /// <summary>
        /// Gets the Weather Information for all the cities from master city.json file
        /// </summary>
        /// <returns></returns>
        public async Task <HttpResponseMessage> GetAll()
        {
            var WeatherProvider      = new WeatherProvider();
            IWeatherProvider Weather = WeatherProvider.FactoryMethod(_WeatherInfoProvider);
            bool             success = await Weather.GetBulkWeatherInfo();

            if (success)
            {
                return(new HttpResponseMessage(System.Net.HttpStatusCode.OK));
            }
            else
            {
                return(new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError));
            }
        }
 public void Initialize()
 {
     this.weatherProvider = new GismeteoProvider(new HtmlWeb());
 }
 public HomeController(IRepository repository, IWeatherProvider weatherProvider, IUnitConverter unitConverter)
 {
     _repository      = repository;
     _weatherProvider = weatherProvider;
     _unitConverter   = unitConverter;
 }
Beispiel #38
0
		/// <summary>
		/// Sends Weather to creature's client.
		/// </summary>
		public static void Weather(Creature creature, IWeatherProvider provider)
		{
			Send.Weather(creature.Client.Send, provider);
		}
Beispiel #39
0
		/// <summary>
		/// Sets provider for region and updates clients in it.
		/// </summary>
		/// <param name="regionId"></param>
		/// <param name="provider"></param>
		public void SetProviderAndUpdate(int regionId, IWeatherProvider provider)
		{
			_providers[regionId] = provider;
			this.Update(provider.RegionId);
		}
Beispiel #40
0
		/// <summary>
		/// Broadcasts Weather in region.
		/// </summary>
		public static void Weather(Region region, IWeatherProvider provider)
		{
			Send.Weather(region.Broadcast, provider);
		}
Beispiel #41
0
 public void OnInitialize()
 {
     WeatherProvider = new FF14AnglerWeatherProvider();
 }
Beispiel #42
0
 public void OnShutdown()
 {
     WeatherProvider = null;
 }
Beispiel #43
0
 /// <summary>
 /// Creates a new <see cref="WeatherRegionForecast"/> instance using an
 /// explicit weather provider.
 /// </summary>
 /// <param name="weatherProvider">Override the default Weather provider.</param>
 public WeatherRegionForecast(IWeatherProvider weatherProvider)
 {
     this._weatherProvider = weatherProvider;
 }
 public void Initialize()
 {
     this.weatherProvider = new SinoptikProvider(new HtmlWeb());
 }
Beispiel #45
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WeatherModule" /> class.
 /// </summary>
 /// <param name="ircClient">The irc client.</param>
 /// <param name="weatherProvider">The weather provider.</param>
 public WeatherModule(IIrcClient ircClient, IWeatherProvider weatherProvider)
     : base(ircClient)
 {
     this.weatherProvider = weatherProvider;
 }
Beispiel #46
0
 /// <summary>
 /// Creates a new <see cref="WeatherRegionForecast"/> instance using an
 /// explicit weather provider.
 /// </summary>
 /// <param name="weatherProvider">Weather provider.</param>
 /// <param name="locationID">Location ID.</param>
 /// <param name="description">Description.</param>
 public WeatherRegionForecast(IWeatherProvider weatherProvider, string locationID, string description)
     : this(_defaultWeatherProvider)
 {
     this.LocationId = locationID;
     this.Description = description;
 }