Example #1
0
        public void saveSpecific(Unit un)
        {
            LocationVars s = l.selectLocation();

            if (s != null)
            {
                using (StreamWriter objWritter = new StreamWriter("weather_info" + "_" + s.LocationName + ".xml"))
                {
                    objWritter.Write(returnXMLData(s, un));
                }
            }
        }
Example #2
0
        public string printLocationInfoOnline(LocationVars location) //prints all actual values if the user is online
        {
            //get request
            var request = new ForecastIORequest("d9b0a7d6636dad5856be677f4c19e4f2", Convert.ToSingle(location.Point.Latitude), Convert.ToSingle(location.Point.Longitude), DateTime.Now, Unit);
            //response that contains all the current values
            var response = request.Get();

            String s = "----  " + location.LocationName + "-Forecast  ----- \r\n" +
                       " Current temperature: " + response.currently.temperature + unitvalue(Unit) + "\r\n Precipitation: " + response.currently.precipIntensity +
                       "\r\n Humidity: " + response.currently.humidity + "\r\n Visibility: " + response.currently.visibility +
                       "\r\n summary: " + response.currently.summary;

            Console.WriteLine(s);
            return(s);
        }
Example #3
0
        public string returnXMLData(LocationVars loc, Unit un)
        {
            //get request
            var request = new ForecastIORequest("d9b0a7d6636dad5856be677f4c19e4f2", (float)loc.Point.Latitude, (float)loc.Point.Longitude, DateTime.Now, un);
            //response that contains all the current values
            var response = request.Get();

            Console.WriteLine("loc LAT:" + (float)loc.Point.Latitude + "  Long:" + (float)loc.Point.Longitude);
            var converted = new XElement("Weatherforecast", new XElement("Location",
                                                                         new XAttribute("Name", loc.LocationName),
                                                                         new XAttribute("Latitude", (float)loc.Point.Latitude),
                                                                         new XAttribute("Longitude", (float)loc.Point.Longitude),
                                                                         new XElement("Weather", new XElement("Temperature", response.currently.temperature + Location.unitvalue(un)),
                                                                                      new XElement("Precipitation", response.currently.precipIntensity),
                                                                                      new XElement("Humidity", response.currently.humidity),
                                                                                      new XElement("Visibility", response.currently.visibility),
                                                                                      new XElement("summary", response.currently.summary)
                                                                                      )));

            Console.WriteLine(converted);
            return(converted.ToString());
        }