public void GetWeatherData(Geocode location)
        {
            // create a new proxy element from the NOAA WebReference
            var proxy = new ndfdXMLPortTypeClient();
            // get response data
            string data = proxy.NDFDgenByDay((decimal)location.Latitude, (decimal)location.Longitude, DateTime.Now.AddDays(-3).Date, "3",
                                             formatType.Item24hourly);

            StringReader reader = new StringReader(data);
            XDocument xmlDoc = XDocument.Load(reader);

            //using linq parse out the maximums and minimums
            var maximums = from tempvalue in xmlDoc.Descendants("temperature").Elements("value")
                           where tempvalue.Parent.Attribute("type").Value == "maximum"
                           select (string)tempvalue;

            var minimums = from tempvalue in xmlDoc.Descendants("temperature").Elements("value")
                           where tempvalue.Parent.Attribute("type").Value == "minimum"
                           select (string)tempvalue;

            // For now simply write out the lists to the console
            foreach (string max in maximums.ToList())
            {
                Console.WriteLine(max);
            }

            foreach (string min in minimums.ToList())
            {
                Console.WriteLine(min);
            }

            Console.WriteLine();
            Console.WriteLine(data);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var    soapService = new ndfdXMLPortTypeClient();
            string result      = soapService.LatLonListZipCode("97477");

            //string result = soapService.LatLonListCityNames("1");
            Console.WriteLine(result);
        }
        public async Task <string> GetCurrent(string zipCode)
        {
            try
            {
                string latlist = string.Empty;

                XmlDocument doc = new XmlDocument();

                ndfdXMLPortTypeClient NOAA = new ndfdXMLPortTypeClient();
                //NOAA = new ndfdXMLPortTypeClient(ndfdXMLPortTypeClient.EndpointConfiguration.ndfdXMLPort, NOAA.Endpoint.Address);

                await NOAA.OpenAsync();


                latlist = await NOAA.LatLonListZipCodeAsync(zipCode);

                doc.LoadXml(latlist);

                string latlong = doc.SelectSingleNode("dwml").SelectSingleNode("latLonList").InnerText;

                string[] split = latlong.Split(',');
                string   lat   = split[0];
                string   lon   = split[1];

                string forecast = await NOAA.NDFDgenAsync(Convert.ToDecimal(lat), Convert.ToDecimal(lon), NOAAServiceReference.productType.timeseries, DateTime.Now, DateTime.Now, NOAAServiceReference.unitType.e, null);

                doc.LoadXml(forecast);

                await NOAA.CloseAsync();

                string        appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                string        weatherFolder = string.Format(@"{0}\{1}", appDataFolder, "WeatherApp");
                DirectoryInfo directoryInfo = new DirectoryInfo(weatherFolder);
                if (!directoryInfo.Exists)
                {
                    Directory.CreateDirectory(weatherFolder);
                }

                string currentFileName = string.Format(@"{0}\Current{1}.xml", weatherFolder, latlong);


                FileInfo forecastFile = new FileInfo(currentFileName);
                if (forecastFile.Exists)
                {
                    File.Delete(currentFileName);
                }

                doc.Save(currentFileName);

                return(currentFileName);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
        public void GetWeatherData(Geocode location)
        {
            // create a new proxy element from the NOAA WebReference
            var proxy = new ndfdXMLPortTypeClient();
            // get response data
            string data = proxy.NDFDgenByDay((decimal)location.Latitude, (decimal)location.Longitude, DateTime.Now.AddDays(-3).Date, "3",
                                             formatType.Item24hourly);

            StringReader reader = new StringReader(data);
            XDocument    xmlDoc = XDocument.Load(reader);

            //using linq parse out the maximums and minimums
            var maximums = from tempvalue in xmlDoc.Descendants("temperature").Elements("value")
                           where tempvalue.Parent.Attribute("type").Value == "maximum"
                           select(string) tempvalue;

            var minimums = from tempvalue in xmlDoc.Descendants("temperature").Elements("value")
                           where tempvalue.Parent.Attribute("type").Value == "minimum"
                           select(string) tempvalue;



            // For now simply write out the lists to the console
            foreach (string max in maximums.ToList())
            {
                Console.WriteLine(max);
            }

            foreach (string min in minimums.ToList())
            {
                Console.WriteLine(min);
            }

            Console.WriteLine();
            Console.WriteLine(data);
        }
 public void Something()
 {
     ndfdXMLPortTypeClient client = new ndfdXMLPortTypeClient();
     string value= client.LatLonListZipCode("20912");
     Console.WriteLine(value);
 }
Esempio n. 6
0
        // string ftpNWS = "ftp://tgftp.nws.noaa.gov/SL.us008001/ST.expr/DF.gr2/DC.ndfd/AR.neast";
        public string ForecastWeather()
        {
            ndfdXMLPortTypeClient ndfdXmlClient = new ndfdXMLPortTypeClient();
            HttpTransportBindingElement transportBinding = new HttpTransportBindingElement();

            //https://stackoverflow.com/questions/7033442/using-iso-8859-1-encoding-between-wcf-and-oracle-linux
            CustomBinding binding = new CustomBinding(new CustomTextMessageBindingElement("iso-8859-1", "text/xml", MessageVersion.Soap11), transportBinding);
            ndfdXmlClient.Endpoint.Binding = binding;

            string client = ndfdXmlClient.NDFDgen(longitude, latitude, weatherForecastProductType, startTime, endTime, weatherUnit,
                forecastParametersType);

            return client;
        }