예제 #1
0
        public DayTemperature GetHistoryTemps(string oCiudad, string unit)
        {
            PositionCity oPosCity = GetPositionCity(oCiudad);

            if (oPosCity.lat != 0 && oPosCity.lon != 0)
            {
                string AnswerJSon = GetTempDaysFromWeather(15, unit, oPosCity);
                return(ConvertStringToListObject(AnswerJSon));
            }
            return(new DayTemperature());
        }
예제 #2
0
 public string GetTempDaysFromWeather(int days, string unit, PositionCity posCity)
 {
     try
     {
         string         queryRequest = "https://api.weatherbit.io/v2.0/forecast/daily?lat=" + posCity.lat + "&lon=" + posCity.lon + "&days=" + days + "&units=" + unit + "&key=a6514ef14da74157b9a1822a45ea30e3";
         HttpWebRequest request      = (HttpWebRequest)WebRequest.Create(queryRequest);
         request.Method = "GET";
         HttpWebResponse response   = (HttpWebResponse)request.GetResponse();
         Stream          dataStream = response.GetResponseStream();
         StreamReader    reader     = new StreamReader(dataStream);
         return(reader.ReadToEnd());
     }
     catch
     {
         return("");
         //throw new ArgumentException("No get data from weather service.");
     }
 }