Esempio n. 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;
 }
Esempio n. 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>();
 }
Esempio n. 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;
 }
Esempio n. 7
0
 public void Add(IWeatherProvider provider)
 {
     if (!_providersList.Contains(provider))
     {
         _providersList.Add(provider);
     }
 }
Esempio n. 8
0
 public TenDaysWeatherProvider(
     ICityInfoProvider cityInfoProvider,
     IWeatherProvider weatherProvider)
 {
     _cityInfoProvider = cityInfoProvider;
     _weatherProvider  = weatherProvider;
 }
Esempio n. 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();
        }
Esempio n. 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);
        }
Esempio n. 11
0
 public WeatherService(ILogger <WeatherService> logger,
                       WeatherServiceSettings settings,
                       IWeatherProvider weatherProvider)
 {
     _logger          = logger;
     _settings        = settings;
     _weatherProvider = weatherProvider;
 }
Esempio n. 12
0
 public IEnumerable <WeatherForecast> GetForeCast(string location, IWeatherProvider weatherProvider)
 {
     if (weatherProvider == null)
     {
         throw new ArgumentNullException(nameof(weatherProvider));
     }
     return(weatherProvider.GetForecastOfLocation(location));
 }
Esempio n. 13
0
 public WeatherController(ILogger logger, IStorage storage, IWeatherProvider provider, IWeatherDisplayer displayer)
 {
     _logger             = logger;
     _storage            = storage;
     _provider           = provider;
     _displayer          = displayer;
     _storage.DataSaved += _displayer.Display;
 }
Esempio n. 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);
        }
Esempio n. 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);
 }
Esempio n. 16
0
 public WeatherFinder(
     [Dependency("Bbc")]IWeatherProvider bbcWeatherProvider,
     [Dependency("Accu")]IWeatherProvider accuWeatherProvider
     )
 {
     _bbcWeatherProvider = bbcWeatherProvider;
     _accuWeatherProvider = accuWeatherProvider;
 }
Esempio n. 17
0
 public WeatherFinder(
     [Dependency("Bbc")] IWeatherProvider bbcWeatherProvider,
     [Dependency("Accu")] IWeatherProvider accuWeatherProvider
     )
 {
     _bbcWeatherProvider  = bbcWeatherProvider;
     _accuWeatherProvider = accuWeatherProvider;
 }
Esempio n. 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;
 }
Esempio n. 20
0
        public WeatherSkypnetModule(IWeatherProvider weatherProvider)
        {
            if (weatherProvider == null)
            {
                throw new ArgumentNullException("weatherProvider");
            }

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

            this.weatherProvider = weatherProvider;
        }
Esempio n. 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}");
        }
Esempio n. 23
0
        public static IWeatherProvider get()
        {
            if (_self == null)
            {
                _self = new WeatherProviderNGS();
            }

            _refcounter++;
            return(_self);
        }
Esempio n. 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;
 }
Esempio n. 27
0
        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;
        }
Esempio n. 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;
 }
Esempio n. 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;
            }
        }
Esempio n. 33
0
 private static void SetupServices()
 {
     weatherProvider = new WeatherProvider(new List <IApiService>
     {
         new BbcWeather()
         {
             Location = LocationInput
         },
         new AccWeather()
         {
             Where = LocationInput
         }
     });
 }
Esempio n. 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);
        }
Esempio n. 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());
 }
Esempio n. 37
0
 public HomeController(IRepository repository, IWeatherProvider weatherProvider, IUnitConverter unitConverter)
 {
     _repository      = repository;
     _weatherProvider = weatherProvider;
     _unitConverter   = unitConverter;
 }
Esempio n. 38
0
		/// <summary>
		/// Sends Weather to creature's client.
		/// </summary>
		public static void Weather(Creature creature, IWeatherProvider provider)
		{
			Send.Weather(creature.Client.Send, provider);
		}
Esempio n. 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);
		}
Esempio n. 40
0
		/// <summary>
		/// Broadcasts Weather in region.
		/// </summary>
		public static void Weather(Region region, IWeatherProvider provider)
		{
			Send.Weather(region.Broadcast, provider);
		}
Esempio n. 41
0
 public void OnInitialize()
 {
     WeatherProvider = new FF14AnglerWeatherProvider();
 }
Esempio n. 42
0
 public void OnShutdown()
 {
     WeatherProvider = null;
 }
Esempio n. 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());
 }
Esempio n. 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;
 }
Esempio n. 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;
 }