protected void lbPeople_SelectedIndexChanged(object sender, EventArgs e)
    {
        string ListBoxValue = lbPeople.SelectedItem.Value;

        string[] value = ListBoxValue.Split('|'); // value[0] has the id, value[1] has the city
        tbPersonCity.Text = value[1];

        WeatherService.WeatherServiceSoapClient weather = new WeatherService.WeatherServiceSoapClient();
        try
        {
            XElement xeWeather = weather.GetWeather(value[1]);
            if (xeWeather != null)
            {
                string xml = xeWeather.ToString();

                XmlDocument xmlWeather = new XmlDocument();
                xmlWeather.LoadXml(xml);

                XmlNode xn             = xmlWeather.SelectSingleNode(@"/current/temperature/@value");
                double  tempKelvin     = Convert.ToDouble(xn.Value);
                double  tempCelcius    = Math.Round(tempKelvin - 273.15, 2);
                double  tempFahrenheit = Math.Round(tempCelcius * 1.8 + 32, 2);

                string temp = tempCelcius.ToString() + "C" + "   " + tempFahrenheit.ToString() + "F";
                tbCityTemperature.Text = temp;
            }
        }
        catch (Exception ex)
        { }
    }
    protected void lbCity_SelectedIndexChanged(object sender, EventArgs e)
    {
        tbSunRise.Text = "";
        string city = lbCity.SelectedValue;

        WeatherService.WeatherServiceSoapClient weather = new WeatherService.WeatherServiceSoapClient();
        try
        {
            XElement xeWeather = weather.GetWeather(city);
            if (xeWeather != null)
            {
                string xml = xeWeather.ToString();

                XmlDocument xmlWeather = new XmlDocument();
                xmlWeather.LoadXml(xml);

                XmlNode  xn          = xmlWeather.SelectSingleNode(@"/current/city/sun/@rise");
                DateTime dt          = Convert.ToDateTime(xn.Value);
                string   timePortion = dt.ToShortTimeString();
                tbSunRise.Text = timePortion;
            }
        }
        catch (Exception ex)
        { }
    }
    protected void btnGetCityList_Click(object sender, EventArgs e)
    {
        WeatherService.WeatherServiceSoapClient weather = new WeatherService.WeatherServiceSoapClient();
        string   city      = "All";
        XElement xeWeather = weather.GetWeather(city);

        XmlDocument xmlWeather = new XmlDocument();
        string      xml        = xeWeather.ToString();

        xmlWeather.LoadXml(xml);

        XmlNodeList xnl = xmlWeather.SelectNodes(@"//city/@name");

        lbCity.Items.Clear();
        foreach (XmlNode node in xnl)
        {
            lbCity.Items.Add(new ListItem(node.Value));
        }
    }
예제 #4
0
 static void Main(string[] args)
 {
     WeatherService.WeatherServiceSoapClient client = new WeatherService.WeatherServiceSoapClient("WeatherServiceSoap");
     double longitude, latitude;
     string s;
     while (true)
     {
         Console.WriteLine("Input geo location,'0' to quit");
         s = Console.ReadLine();
         if (s.Equals("0"))
         {
             break;
         }
         string[] temp = s.Split(new char[] { ',' });
         longitude = double.Parse(temp[0]);
         latitude = double.Parse(temp[1]);
         WeatherService.WeatherInfo info = client.GetWeatherByGeo(longitude, latitude);
         if (info != null)
         {
             Console.WriteLine(string.Format("Output\nSuccessOrNot:{0}\nAreaId:{1}\nAreaName:{2}\nRefreshTime:{3}\nWeatherInfo(please refrence the api document in the Doc folder to deserialize):\n{4}",info.Success,info.AreaId,info.AreaName,info.RefreshTime.ToString(),info.WeatherJson));
         }
     }
 }
    protected void lbClients_SelectedIndexChanged(object sender, EventArgs e)
    {
        //Place the code to call the PeopleService to GET the specific Client selected
        //      Use XPath to find the City in the first WorkLocation
        //      Use XPath to find the Address in the first Work Location
        //      Use XPath to find the Encounters
        //          Add each encounter into the listbox
        //          Clear out the encounter textbox
        //Place the code to call the Weather Service to obtain the temperature and precipitation based on the city of the client
        //      You will need to use XPath to locate the information in the weather information returned
        //If a Field Rep is also selected, call the DistanceService to obtain the distance between them using the first WorkLocation in each

        string id  = lbClients.SelectedItem.Value;
        string url = @"http://*****:*****@type")?.InnerXml;
            string EncounterDescription = xnEncounter.InnerXml;
            lbClientEncounters.Items.Add(new ListItem(EncounterType + ": " + EncounterDescription));
        }


        tbClientPrecipitation.Text = "";
        tbClientTemperature.Text   = "";
        WeatherService.WeatherServiceSoapClient weather = new WeatherService.WeatherServiceSoapClient();
        try
        {
            XElement xeWeather = weather.GetWeather(ClientCity);
            if (xeWeather != null)
            {
                string xml = xeWeather.ToString();

                XmlDocument xmlWeather = new XmlDocument();
                xmlWeather.LoadXml(xml);

                XmlNode xn             = xmlWeather.SelectSingleNode(@"/current/temperature/@value");
                double  tempKelvin     = Convert.ToDouble(xn.Value);
                double  tempCelcius    = Math.Round(tempKelvin - 273.15, 2);
                double  tempFahrenheit = Math.Round(tempCelcius * 1.8 + 32, 2);
                string  temp           = tempCelcius.ToString() + "C" + "   " + tempFahrenheit.ToString() + "F";
                tbClientTemperature.Text = temp;

                xn = xmlWeather.SelectSingleNode(@"/current/precipitation");
                string precipitation = xn.InnerXml;
                tbClientPrecipitation.Text = precipitation;
            }
        }
        catch (Exception ex)
        { }

        if (tbFieldRepAddress.Text != "") // A field rep has been selected and the address saved off
        {
            string addressClient   = tbClientAddress.Text;
            string addressFieldRep = tbFieldRepAddress.Text;

            MapService.MapServiceSoapClient mapService = new MapService.MapServiceSoapClient();
            XElement    xeAddressAutoComplete          = mapService.AddressAutoComplete(addressClient);
            XmlDocument xmlAddressAutoComplete         = new XmlDocument();
            xmlAddressAutoComplete.LoadXml(xeAddressAutoComplete.ToString());
            XmlNode xnPlaceID      = xmlAddressAutoComplete.SelectSingleNode("//place_id");
            string  sPlaceIDClient = xnPlaceID.InnerXml;

            xeAddressAutoComplete  = mapService.AddressAutoComplete(addressFieldRep);
            xmlAddressAutoComplete = new XmlDocument();
            xmlAddressAutoComplete.LoadXml(xeAddressAutoComplete.ToString());
            xnPlaceID = xmlAddressAutoComplete.SelectSingleNode("//place_id");
            string sPlaceIDFieldRep = xnPlaceID.InnerXml;


            XElement    xePlaceDetails  = mapService.PlaceDetails(sPlaceIDClient);
            XmlDocument xmlPlaceDetails = new XmlDocument();
            xmlPlaceDetails.LoadXml(xePlaceDetails.ToString());
            string ClientLat = xmlPlaceDetails.SelectSingleNode("//geometry/location/lat")?.InnerXml;
            string ClientLng = xmlPlaceDetails.SelectSingleNode("//geometry/location/lng")?.InnerXml;

            xePlaceDetails  = mapService.PlaceDetails(sPlaceIDFieldRep);
            xmlPlaceDetails = new XmlDocument();
            xmlPlaceDetails.LoadXml(xePlaceDetails.ToString());
            string FieldRepLat = xmlPlaceDetails.SelectSingleNode("//geometry/location/lat")?.InnerXml;
            string FieldRepLng = xmlPlaceDetails.SelectSingleNode("//geometry/location/lng")?.InnerXml;


            DistanceService.DistanceServiceClient distanceService = new DistanceService.DistanceServiceClient();
            double dblDistance = distanceService.DistanceBetweenTwoPoints(double.Parse(ClientLat), double.Parse(ClientLng), double.Parse(FieldRepLat), double.Parse(FieldRepLng));
            tbDistance.Text = Math.Round(dblDistance, 2).ToString();
        }
    }
    protected void lbFieldReps_SelectedIndexChanged(object sender, EventArgs e)
    {
        //Place the code to call the PeopleService to GET the specific Field Rep selected
        //      Use XPath to find the City in the first WorkLocation
        //      Use XPath to find the Address in the first Work Location
        //Place the code to call the Weather Service to obtain the temperature and humidity based on the city of the Field Rep
        //      You will need to use XPath to locate the information in the weather information returned
        //If a Client is also selected, call the DistanceService to obtain the distance between them using the first WorkLocation in each

        string id  = lbFieldReps.SelectedItem.Value;
        string url = @"http://*****:*****@"/current/temperature/@value");
                double  tempKelvin     = Convert.ToDouble(xn.Value);
                double  tempCelcius    = Math.Round(tempKelvin - 273.15, 2);
                double  tempFahrenheit = Math.Round(tempCelcius * 1.8 + 32, 2);
                string  temp           = tempCelcius.ToString() + "C" + "   " + tempFahrenheit.ToString() + "F";
                tbFieldRepsTemperature.Text = temp;

                xn = xmlWeather.SelectSingleNode(@"/current/humidity/@value");
                string humidity = xn.InnerXml;
                xn        = xmlWeather.SelectSingleNode(@"/current/humidity/@unit");
                humidity += xn.InnerXml;
                tbFieldRepsHumidity.Text = humidity;
            }
        }
        catch (Exception ex)
        { }

        if (tbClientAddress.Text != "") // A Client has been selected and the address saved off
        {
            string addressClient   = tbClientAddress.Text;
            string addressFieldRep = tbFieldRepAddress.Text;

            MapService.MapServiceSoapClient mapService = new MapService.MapServiceSoapClient();
            XElement    xeAddressAutoComplete          = mapService.AddressAutoComplete(addressClient);
            XmlDocument xmlAddressAutoComplete         = new XmlDocument();
            xmlAddressAutoComplete.LoadXml(xeAddressAutoComplete.ToString());
            XmlNode xnPlaceID      = xmlAddressAutoComplete.SelectSingleNode("//place_id");
            string  sPlaceIDClient = xnPlaceID.InnerXml;

            xeAddressAutoComplete  = mapService.AddressAutoComplete(addressFieldRep);
            xmlAddressAutoComplete = new XmlDocument();
            xmlAddressAutoComplete.LoadXml(xeAddressAutoComplete.ToString());
            xnPlaceID = xmlAddressAutoComplete.SelectSingleNode("//place_id");
            string sPlaceIDFieldRep = xnPlaceID.InnerXml;


            XElement    xePlaceDetails  = mapService.PlaceDetails(sPlaceIDClient);
            XmlDocument xmlPlaceDetails = new XmlDocument();
            xmlPlaceDetails.LoadXml(xePlaceDetails.ToString());
            string ClientLat = xmlPlaceDetails.SelectSingleNode("//geometry/location/lat")?.InnerXml;
            string ClientLng = xmlPlaceDetails.SelectSingleNode("//geometry/location/lng")?.InnerXml;

            xePlaceDetails  = mapService.PlaceDetails(sPlaceIDFieldRep);
            xmlPlaceDetails = new XmlDocument();
            xmlPlaceDetails.LoadXml(xePlaceDetails.ToString());
            string FieldRepLat = xmlPlaceDetails.SelectSingleNode("//geometry/location/lat")?.InnerXml;
            string FieldRepLng = xmlPlaceDetails.SelectSingleNode("//geometry/location/lng")?.InnerXml;


            DistanceService.DistanceServiceClient distanceService = new DistanceService.DistanceServiceClient();
            double dblDistance = distanceService.DistanceBetweenTwoPoints(double.Parse(ClientLat), double.Parse(ClientLng), double.Parse(FieldRepLat), double.Parse(FieldRepLng));
            tbDistance.Text = Math.Round(dblDistance, 2).ToString();
        }
    }
    protected void lbClients_SelectedIndexChanged(object sender, EventArgs e)
    {
        string id = lbClients.SelectedItem.Value;

        if (id.Contains("|"))
        {
            string[] ClientStuff = id.Split('|');
            id = ClientStuff[0];
        }
        string url = @"http://*****:*****@type")?.InnerXml;
            string EncounterDescription = xnEncounter.InnerXml;
            lbClientEncounters.Items.Add(new ListItem(EncounterType + ": " + EncounterDescription));
        }


        tbClientPrecipitation.Text = "";
        tbClientTemperature.Text   = "";

        //**Making the SOAP Weather Service Call**

        WeatherService.WeatherServiceSoapClient weather = new WeatherService.WeatherServiceSoapClient();
        try
        {
            XElement xeWeather = weather.GetWeather(ClientCity);
            if (xeWeather != null)
            {
                string xml = xeWeather.ToString();

                XmlDocument xmlWeather = new XmlDocument();
                xmlWeather.LoadXml(xml);

                XmlNode xn             = xmlWeather.SelectSingleNode(@"/current/temperature/@value");
                double  tempKelvin     = Convert.ToDouble(xn.Value);
                double  tempCelcius    = Math.Round(tempKelvin - 273.15, 2);
                double  tempFahrenheit = Math.Round(tempCelcius * 1.8 + 32, 2);
                string  temp           = tempCelcius.ToString() + "C" + "   " + tempFahrenheit.ToString() + "F";
                tbClientTemperature.Text = temp;

                xn = xmlWeather.SelectSingleNode(@"/current/precipitation");
                string precipitation = xn.InnerXml;
                tbClientPrecipitation.Text = precipitation;
            }
        }
        catch (Exception ex)
        { }

        if (tbFieldRepAddress.Text != "") // A field rep has been selected and the address saved off
        {
            string addressClient   = tbClientAddress.Text;
            string addressFieldRep = tbFieldRepAddress.Text;

            //**Making the SOAP Map Service Call**

            MapService.MapServiceSoapClient mapService = new MapService.MapServiceSoapClient();
            XElement    xeAddressAutoComplete          = mapService.AddressAutoComplete(addressClient);
            XmlDocument xmlAddressAutoComplete         = new XmlDocument();
            xmlAddressAutoComplete.LoadXml(xeAddressAutoComplete.ToString());
            XmlNode xnPlaceID      = xmlAddressAutoComplete.SelectSingleNode("//place_id");
            string  sPlaceIDClient = xnPlaceID.InnerXml;

            xeAddressAutoComplete  = mapService.AddressAutoComplete(addressFieldRep);
            xmlAddressAutoComplete = new XmlDocument();
            xmlAddressAutoComplete.LoadXml(xeAddressAutoComplete.ToString());
            xnPlaceID = xmlAddressAutoComplete.SelectSingleNode("//place_id");
            string sPlaceIDFieldRep = xnPlaceID.InnerXml;


            XElement    xePlaceDetails  = mapService.PlaceDetails(sPlaceIDClient);
            XmlDocument xmlPlaceDetails = new XmlDocument();
            xmlPlaceDetails.LoadXml(xePlaceDetails.ToString());
            string ClientLat = xmlPlaceDetails.SelectSingleNode("//geometry/location/lat")?.InnerXml;
            string ClientLng = xmlPlaceDetails.SelectSingleNode("//geometry/location/lng")?.InnerXml;

            xePlaceDetails  = mapService.PlaceDetails(sPlaceIDFieldRep);
            xmlPlaceDetails = new XmlDocument();
            xmlPlaceDetails.LoadXml(xePlaceDetails.ToString());
            string FieldRepLat = xmlPlaceDetails.SelectSingleNode("//geometry/location/lat")?.InnerXml;
            string FieldRepLng = xmlPlaceDetails.SelectSingleNode("//geometry/location/lng")?.InnerXml;


            DistanceService.DistanceServiceClient distanceService = new DistanceService.DistanceServiceClient();
            double dblDistance = distanceService.DistanceBetweenTwoPoints(double.Parse(ClientLat), double.Parse(ClientLng), double.Parse(FieldRepLat), double.Parse(FieldRepLng));
            tbDistance.Text = Math.Round(dblDistance, 2).ToString();
        }
        FillInClientMarkers();
    }