private void button2_Click(object sender, EventArgs e) { //WeatherWebServiceSoapClient weather = new WeatherWebServiceSoapClient(); WeatherWebService weather = new WeatherWebService(); string[] s = new string[23]; string city = this.textBox4.Text.Trim(); s = weather.getWeatherbyCityName(city); if (s[8] == "") { MessageBox.Show("暂时不支持您查询的城市"); } else { //pictureBox1.Image = Image.FromFile(@"d:\image\" + s[8] + ""); //this.label4.Text = s[1] + " " + s[6]; textBox5.Text = s[10]; } //label2.Text = weather.getSupportCity(s).ToString(); //var json = weather.getWeatherbyCityName(s).ToString(); //label2.Text = weather.getWeatherbyCityName(s).ToString(); //label2.Text = json.ToString(); }
private void DisplayWeather(string cityName) { WeatherWebService service; try { service = new WeatherWebService(); //创建Web服务代理对象 } catch (Exception ex) { throw new Exception(ex.Message); } string[] weatherStatus = service.getWeatherbyCityName(cityName); //通过调用Web服务的getWeatherbyCityName()方法,传入城市名,得到该城市的天气情况, //并以字符串数组的形式存放在weatherStatus中 Label1.Text = weatherStatus[10]; Label2.Text = weatherStatus[6] + " " + weatherStatus[5] + " " + weatherStatus[7]; Label3.Text = weatherStatus[13] + " " + weatherStatus[12] + " " + weatherStatus[14]; Label4.Text = weatherStatus[18] + " " + weatherStatus[17] + " " + weatherStatus[19]; Label5.Text = weatherStatus[11].Replace("\n", "<br />"); //Label6.Text = weatherStatus[22].Replace(Chr[10], "<br />"); Label7.Text = Convert.ToDateTime(weatherStatus[4]).ToString("yyyy年MM月dd日 dddd HH:mm"); Label8.Text = weatherStatus[0] + " / " + weatherStatus[1]; Image1.ImageUrl = "images/weather/" + weatherStatus[8]; Image2.ImageUrl = "images/weather/" + weatherStatus[9]; Image3.ImageUrl = "images/weather/" + weatherStatus[15]; Image4.ImageUrl = "images/weather/" + weatherStatus[16]; Image5.ImageUrl = "images/weather/" + weatherStatus[20]; Image6.ImageUrl = "images/weather/" + weatherStatus[21]; }
/// <summary> /// 获得天气预报 /// </summary> public static Weather GetWeather(string CityName) { Yannyo.Cache.YannyoCache cache = Yannyo.Cache.YannyoCache.GetCacheService(); Weather w = cache.RetrieveObject("/Sys/Weather" + Utils.MD5(CityName)) as Weather; if (w == null) { w = WeatherWebService.getWeatherbyCityName(CityName);//接口获取天气数据 cache.AddObject("/Sys/Weather" + Utils.MD5(CityName), w); } return(w); }
public string[] GetWeatherString(string strCity) { string[] weatherInfo = null; try { WeatherWebService ws = new WeatherWebService(); weatherInfo = ws.getWeatherbyCityName(strCity); } catch { _result = ResultInfo.NetError; } return(weatherInfo); }
public static string[] Weather(string city) { //---返回23长度的字符串 WeatherWebService webc = null; string[] s = new string[23]; try { webc = new WeatherWebService(); s = webc.getWeatherbyCityName(city.Trim()); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(s); }
private void button7_Click(object sender, EventArgs e) { WeatherWebService w = new WeatherWebService(); string[] s = new string[23]; //声明string数组存放返回结果 string city = this.textBox1.Text.Trim(); //获得文本框录入的查询城市 s = w.getWeatherbyCityName(city); if (textBox1.Text == "") { //MessageBox.Show("输入错误,请重新输入", "提示", MessageBoxButton.OK, MessageBoxImage.Information); MessageBox.Show("城市输入错误,请重新输入"); } else { weatherDetail.Text = s[1] + "\n" + s[4] + s[10] + s[11]; } }
private void LoadCity(string provinceName) { WeatherWebService service; try { service = new WeatherWebService(); //创建Web服务代理对象 } catch (Exception ex) { throw new Exception(ex.Message); } string[] cities = service.getSupportCity(provinceName); //通过调用Web服务的getSupportCity()方法,传入省份/洲名,得到所有支持的城市名称, //并以字符串数组的形式存放在cities中 drpCity.DataSource = cities; //将字符串数组作为下拉菜单的数据源 drpCity.DataBind(); //调用城市下拉菜单的DataBind()方法,显示所有的省份/洲 }
void Start() { // icon = GameObject .Find("weather").GetComponent<Image>(); textP = provinceDp.GetComponentInChildren <Text>(); textC = cityDp.GetComponentInChildren <Text>(); try { Weather.WeatherWebService ww = new WeatherWebService(); strPr = ww.getSupportProvince(); foreach (string item in strPr) { province.Add(item); } provinceDp.AddOptions(province); isSearch = true; } catch (System.Exception ex) { text.text = ex.Message; } }
IEnumerator WeatherSear() { try { Weather.WeatherWebService ww = new WeatherWebService(); str = ww.getWeatherbyCityName(cityName); text.text = str[0] + " " + str[1] + "\r\n" + "\r\n" + str[10]; textweather.text = str[6] + str[5]; textray.text = str[11]; textfeng.text = str[7]; timeText.text = str[4]; string[] icons = str[8].Split('.'); Sprite sp = Resources.Load(icons[0], typeof(Sprite)) as Sprite; icon.sprite = sp; } catch (System.Exception ex) { text.text = ex.Message; } // text.text = cityName; yield return(0); }
private void LoadProvince() { WeatherWebService service; string[] provinces; //此字符串数组用于保存支持的所有省份/洲名称 try { service = new WeatherWebService(); //创建Web服务代理对象 } catch (Exception ex) { throw new Exception(ex.Message); } provinces = service.getSupportProvince(); //通过调用Web服务的getSupportProvince()方法,得到所有支持的省份/洲名称, //并以字符串数组的形式存放在provinces中 drpProvince.DataSource = provinces; //将字符串数组作为下拉菜单的数据源 drpProvince.DataBind(); //调用省份下拉菜单的DataBind()方法,显示所有的省份/洲 }
// Update is called once per frame void Update() { if (isSearch == false) { try { Weather.WeatherWebService ww = new WeatherWebService(); strPr = ww.getSupportProvince(); foreach (string item in strPr) { province.Add(item); } provinceDp.AddOptions(province); isSearch = true; text.text = ""; } catch (System.Exception ex) { text.text = ex.Message; return; } } }
IEnumerator CitySear() { try { str1 = null; city.Clear(); cityDp.ClearOptions(); Weather.WeatherWebService ww = new WeatherWebService(); str1 = ww.getSupportCity(provinceDp.GetComponentInChildren <Text>().text); city.Add("请选择城市"); foreach (string item in str1) { city.Add(item); } cityDp.AddOptions(city); } catch (System.Exception ex) { text.text = ex.Message; } yield return(0); }