Пример #1
0
        private void resolve_Click(object sender, EventArgs e)
        {
            startTimer();

            var serviceClient = new ServiceResolve.P2GeoSoapClient("IP2GeoSoap");
            var ipData        = serviceClient.ResolveIP(txtResolveInput.Text, "0");

            txtResolveOutput.Text = ipData.Country;

            calculateTime(resolveTime);
        }
Пример #2
0
        private async void StartTasksAsync()
        {
            var clientQuote = new ServiceReferenceQuotes.DelayedStockQuoteSoapClient("DelayedStockQuoteSoap");

            taskQuote = clientQuote.GetQuickQuoteAsync(txtQuotesInput.Text, "0");

            var clientResolve = new ServiceResolve.P2GeoSoapClient("IP2GeoSoap");

            taskResolve = clientResolve.ResolveIPAsync(txtResolveInput.Text, "0");


            var clientTime = new ServiceTime.ServiceSoapClient("ServiceSoap");

            taskTime = clientTime.GetTimeAsync();

            var clientEcho = new ServiceEcho.ServiceSoapClient("ServiceSoap1");

            taskEcho = clientEcho.EchoAsync(txtEchoInput.Text);


            using (WebClient client = new WebClient())
            {
                Uri uri1 = new Uri("http://api.openweathermap.org/data/2.5/weather?q=" + txtWeatherInput.Text + "&mode=xml&appid=714329f613c83cfa729591a7ceac291d");

                taskTemperature = await client.DownloadStringTaskAsync(uri1);

                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.LoadXml(taskTemperature);

                XmlNode      temp_node  = xmlDocument.SelectSingleNode("//temperature");
                XmlAttribute temp_value = temp_node.Attributes["value"];

                double temperature = double.Parse(temp_value.Value, System.Globalization.CultureInfo.InvariantCulture);
                temperature = temperature - 273.15; // kelvin to celcius conversion

                txtWeatherOutputTemperature.Text = temperature.ToString("N2");

                if (temperature < 0)
                {
                    txtWeatherOutputTemperature.BackColor = Color.Red;
                }
                else if (temperature >= 0 && temperature <= 5)
                {
                    txtWeatherOutputTemperature.BackColor = Color.Blue;
                }
                else
                {
                    txtWeatherOutputTemperature.BackColor = Color.Green;
                }
            }
        }