public string GetData(String Zipcode, DateTime date)
        {
            weather.ndfdXML myWeather = new weather.ndfdXML();
            String          xml       = myWeather.LatLonListZipCode(Zipcode);
            //service that retunrs latitude and longitude in an XML string
            String s = "";

            //to extract required data in string format from XML string
            using (XmlReader reader = XmlReader.Create(new StringReader(xml)))
            {
                reader.ReadToFollowing("latLonList");
                s = reader.ReadElementContentAsString();
            }
            //Separating latitude and longitude
            String[] arr   = s.Split(',');
            String   lati  = arr[0];
            String   longi = arr[1];

            Decimal lat = Convert.ToDecimal(arr[0]);
            Decimal lon = Convert.ToDecimal(arr[1]);
            //the funtion returns a string with Weather data we are appending latitude and longitude
            String st = lati + "|" + longi + "|" + myWeather.NDFDgenByDay(lat, lon, date, "6", "e", "24 hourly");

            System.Threading.Thread.Sleep(2000);
            return(st);
        }
 private void zipBtn_Click(object sender, EventArgs e)
 {
     String ZIP = zipBox.Text;
     weather.ndfdXML weatherServ = new weather.ndfdXML();
     String XML = weatherServ.LatLonListZipCode(ZIP);
     XML = XML.Substring(XML.IndexOf("<latLonList>") + "<latLonList>".Length, XML.IndexOf("</latLonList>") - XML.IndexOf("<latLonList>") - "<latLonList>".Length);
     coBox.Text = XML;
 }
Exemple #3
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            weather.ndfdXML currentweather = new weather.ndfdXML(); // creating onbject currentweather of class weather.ndfdXML
            //Console.WriteLine(currentweather); //printing on console for debugging and tracing data
            decimal lat = Convert.ToDecimal(TextBox1.Text);
            decimal lng = Convert.ToDecimal(TextBox2.Text);
            // lat = 32.7452M;
            Console.WriteLine(lat); //printing on console for debugging and tracing data
            //decimal lng = -117.1979M;
            Console.WriteLine(lng); //printing on console for debugging and tracing data
            weather.weatherParametersType Paramtype = new weather.weatherParametersType();
            //Console.WriteLine(wtp);//printing on console for debugging and tracing data
            //Label2.Text =Convert.ToString(Paramtype);
            Paramtype.temp = true;                                                                                                                 //parameter required from the web service
            // wind speed
            Paramtype.wspd = true;                                                                                                                 //parameter required from the web service
            //wind Direction
            Paramtype.wdir = true;                                                                                                                 //parameter required from the web service
            //Wave height
            Paramtype.waveh = true;                                                                                                                //parameter required from the web service
            //dew precipitation
            Paramtype.dew = true;                                                                                                                  //parameter required from the web service
            //ice accumulation
            Paramtype.iceaccum = true;                                                                                                             //parameter required from the web service
            //max temperature
            Paramtype.maxt = true;                                                                                                                 //parameter required from the web service
            // min temperature
            Paramtype.mint = true;                                                                                                                 //parameter required from the web service

            xmlstmt = currentweather.NDFDgen(lat, lng, weather.productType.timeseries, DateTime.Now, DateTime.Now, weather.unitType.e, Paramtype); //calling web service
            Console.WriteLine(xmlstmt);                                                                                                            //printing on console for debugging and tracing data
            Console.WriteLine("SOAP RESPONSE");                                                                                                    //printing on console for debugging and tracing data
            Label1.Text = xmlstmt;
            string xmlstmt1 = xmlstmt.Substring(xmlstmt.IndexOf("Temperature"));                                                                   //stripping required responses from the response string
            Label2.Text = xmlstmt1;
        }
        catch (Exception ee)
        {
            Console.WriteLine(ee);
        }
    }