コード例 #1
0
ファイル: WeatherForm.cs プロジェクト: hanchao/LandMap
        /// <summary>
        /// 后天查询天气
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            WeatherWebService.WeatherWebServiceSoapClient w = new WeatherWebService.WeatherWebServiceSoapClient("WeatherWebServiceSoap");
            //把webservice当做一个类来操作
            //string[] s = new string[23];//声明string数组存放返回结果
            string city = this.textBoxCity.Text.Trim();//获得文本框录入的查询城市
            try
            {
                weatherInfo = w.getWeatherbyCityName(city);

                //以文本框内容为变量实现方法getWeatherbyCityName
                if (weatherInfo[8] == "")
                {
                    //MessageBox.Show("暂时不支持您查询的城市");
                }
                else
                {

                    //pictureBox1.Image = Image.FromFile(@"d:\image\" + s[8] + "");
                    //this.label4.Text = s[1] + " " + s[6];
                    //textBox2.Text = s[10];
                }
            }
            catch (System.Exception ex)
            {

            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: henrydem/yongfa365doc
        static void Main(string[] args)
        {
            ServiceReference1.WebService1SoapClient myClient = new ServiceReference1.WebService1SoapClient();
            string str = myClient.HelloWorld();
            Console.WriteLine(str);

            int a, b;
            a = 100;
            b = 200;
            Console.WriteLine("a:{0},b:{1}", a, b);
            myClient.Swap(ref a, ref b);
            Console.WriteLine("a:{0},b:{1}", a, b);
            /////////////////////////////////////////////////////////////////
            Console.WriteLine("==============DataTable===================");
            DataTable dt = myClient.GetDataTable();
            foreach (DataRow item in dt.Rows)
            {
                Console.WriteLine(item[1]);
            }
            /////////////////////////////////////////////////////////////////
            Console.WriteLine("==============GetListMyClass===================");
            ServiceReference1.MyClass[]  list = myClient.GetListMyClass();
            foreach (var item in list)
            {
                Console.WriteLine(item.姓名);
            }
            /////////////////////////////////////////////////////////////////
            Console.WriteLine("==============List===================");
            string[] list2 = myClient.GetList();
            foreach (var item in list2)
            {
                Console.WriteLine(item);
            }
            /////////////////////////////////////////////////////////////////
            Console.WriteLine("==============深圳天气===================");
            WeatherWebService.WeatherWebServiceSoapClient weather = new WeatherWebService.WeatherWebServiceSoapClient("WeatherWebServiceSoap12");
            string[] 深圳天气 = weather.getWeatherbyCityName("深圳");

            foreach (var item in 深圳天气)
            {
                Console.WriteLine(item);
            }
        }
コード例 #3
0
        public void loadWeather()
        {
            WeatherWebService.WeatherWebServiceSoapClient ws = new WeatherWebService.WeatherWebServiceSoapClient();
            string[] strWeather = ws.getWeatherbyCityName("上海");
            DirectoryInfo di = new DirectoryInfo(System.Environment.CurrentDirectory);
            string strPath = di.Parent.Parent.FullName;
            BitmapImage image = new BitmapImage(new Uri(strPath + @"/weatherlogo/a_" + strWeather[8], UriKind.RelativeOrAbsolute));
            w_image1.Source = image;
            w_label1.Content = strWeather[6];
            string str = (strWeather[10].Split(';'))[0];
            w_label2.Content = (str.Split(':'))[2];
            w_label3.Content = "上次监测:" + (strWeather[4].Split(' '))[1];
            w_label4.Content = (strWeather[10].Split(';'))[2];
            w_label5.Content = (strWeather[10].Split(';'))[1];
            w_label6.Content = (strWeather[10].Split(';'))[3];
            w_label7.Content = (strWeather[10].Split(';'))[4];

            w_label8.Content = (strWeather[6].Split(' '))[0];
            w_label9.Content = (strWeather[13].Split(' '))[0];
            w_label10.Content = (strWeather[18].Split(' '))[0];
            image = new BitmapImage(new Uri(strPath + @"/weatherlogo/b_" + strWeather[8], UriKind.RelativeOrAbsolute));
            w_image2.Source = image;
            image = new BitmapImage(new Uri(strPath + @"/weatherlogo/b_" + strWeather[15], UriKind.RelativeOrAbsolute));
            w_image3.Source = image;
            image = new BitmapImage(new Uri(strPath + @"/weatherlogo/b_" + strWeather[20], UriKind.RelativeOrAbsolute));
            w_image4.Source = image;
            w_label11.Content = strWeather[5];
            w_label12.Content = strWeather[12];
            w_label13.Content = strWeather[17];

            System.Net.WebClient wc = new System.Net.WebClient();

            DateTime nowtime = DateTime.Now;
            string timeStr = nowtime.ToString("yyyyMMddHHmm");
            string minute = DateTime.Now.Minute.ToString();
            int minuteInt = Convert.ToInt32(minute);
            int model = minuteInt - minuteInt % 6 + 2;
            string modelstr = model.ToString("D2");
            timeStr = timeStr.Substring(0, 10) + modelstr;
            string imgPath = @"http://www.soweather.com/PicFiles/wd" + timeStr + @".png";

            while (!RemoteFileExists(imgPath))
            {
                nowtime = nowtime.AddMinutes(-6);
                timeStr = nowtime.ToString("yyyyMMddHHmm");
                minute = nowtime.Minute.ToString();
                minuteInt = Convert.ToInt32(minute);
                model = minuteInt - minuteInt % 6 + 2;
                modelstr = model.ToString("D2");
                timeStr = timeStr.Substring(0, 10) + modelstr;
                imgPath = @"http://www.soweather.com/PicFiles/wd" + timeStr + @".png";
            }
            /*
            wc.DownloadFile(new Uri(imgPath), timeStr + @".png");
            FileInfo fileInfo = new FileInfo(timeStr + @".png");

            DirectoryInfo diDebug = new DirectoryInfo(System.Environment.CurrentDirectory);
            string strPath = diDebug.FullName;
            image1.Source = new BitmapImage(new Uri(diDebug+@"\"+timeStr+@".png", UriKind.RelativeOrAbsolute));
            */

            Uri uri = new Uri(imgPath, UriKind.Absolute);
            BitmapImage bmp = new BitmapImage(uri);
            w_imageWeather.Source = bmp;
            w_webBrowser1.Source = new Uri("http://flash.weather.com.cn/sk2/shikuang.swf?id=101020100");
        }