Beispiel #1
0
 public ServiceAppSettings(Dictionary <string, string> cStrings, Dictionary <string, double> intervals, OpenCageData openCageData, OpenWeatherData openWeatherData, DefaultLocation defaultLocation)
 {
     ConnectionStrings = cStrings;
     Intervals         = intervals;
     OpenCageData      = openCageData;
     OpenWeatherData   = openWeatherData;
     DefaultLocation   = defaultLocation;
 }
Beispiel #2
0
        /// <summary>
        /// Extension method for extracting defaults and apikeys from iconfiguration instance
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static ServiceAppSettings ExtractWeatherSettings(this IConfiguration config)
        {
            Dictionary <string, string> cStrings  = config.GetSection("ConnectionStrings").Get <Dictionary <string, string> >();
            Dictionary <string, double> intervals = config.GetSection("DefaultIntervals").Get <Dictionary <string, double> >();
            OpenCageData    openCageData          = config.GetSection("OpenCageData").Get <OpenCageData>();
            OpenWeatherData openWeatherData       = config.GetSection("OpenWeatherData").Get <OpenWeatherData>();
            DefaultLocation defaultLocation       = config.GetSection("DefaultLocation").Get <DefaultLocation>();

            return(new ServiceAppSettings(cStrings, intervals, openCageData, openWeatherData, defaultLocation));
        }
Beispiel #3
0
        // GET: api/Weather2
        public string Get()
        {
            IWeatherData wd    = new OpenWeatherData();
            string       error = string.Empty;
            var          data  = wd.GetWeatherData(out error);

            if (data != null)
            {
                return(data.main.temp.ToString());
            }
            return(error);
        }
Beispiel #4
0
        protected override void OnPostExecute(string result)
        {
            base.OnPostExecute(result);
            if (result == null)
            {
                return;
            }
            weatherData = JsonConvert.DeserializeObject <OpenWeatherData>(result);

            TownWeather tw = new TownWeather()
            {
                Name        = weatherData.city.name,
                Temp        = weatherData.list[0].main.temp,
                Temp_min    = weatherData.list[0].main.temp_min,
                Temp_max    = weatherData.list[0].main.temp_max,
                Pressure    = weatherData.list[0].main.pressure,
                Humidity    = weatherData.list[0].main.humidity,
                Sea_level   = weatherData.list[0].main.sea_level,
                Grnd_level  = weatherData.list[0].main.grnd_level,
                Main        = weatherData.list[0].weather[0].main,
                Description = weatherData.list[0].weather[0].description,

                Tommorow_temp        = weatherData.list[1].main.temp,
                Tommorow_main        = weatherData.list[1].weather[0].main,
                Tommorow_description = weatherData.list[1].weather[0].description,

                After_tmr_temp        = weatherData.list[2].main.temp,
                After_tmr_main        = weatherData.list[2].weather[0].main,
                After_tmr_description = weatherData.list[2].weather[0].description,

                After2_tmr_temp        = weatherData.list[3].main.temp,
                After2_tmr_main        = weatherData.list[3].weather[0].main,
                After2_tmr_description = weatherData.list[3].weather[0].description,
            };

            activity.dbAdapter.UpdateByName(tw);

            activity.LoadData();
        }
Beispiel #5
0
 public WeatherTask(MainActivity activity)
 {
     this.activity    = activity;
     this.weatherData = new OpenWeatherData();
 }