Exemple #1
0
    private WeekWeatherAnalysis Search(PlaceModel province, PlaceModel city, PlaceModel district)
    {
        WeekWeatherAnalysis detail = new WeekWeatherAnalysis(province.ID, city.ID, district.ID);

        detail.HandleWeather();
        return(detail);
    }
Exemple #2
0
    private void buttonSearch_Click()
    {
        PlaceModel province = null, city = null, district = null;

        if (provinces != null && provinces.Length > comboBoxProvince.value)
        {
            province = provinces[comboBoxProvince.value];
        }

        if (citys != null && citys.Length > comboBoxCity.value)
        {
            city = citys[comboBoxCity.value];
        }

        if (districts != null && districts.Length > comboBoxDistrict.value)
        {
            district = districts[comboBoxDistrict.value];
        }

        if (province != null && city != null && district != null)
        {
            this.InvokeToForm(() =>
            {
                lblStatus.text = "查询中";
                province       = provinces[comboBoxProvince.value];
                city           = citys[comboBoxCity.value];
                district       = districts[comboBoxDistrict.value];
                ThreadPool.QueueUserWorkItem((x) =>
                {
                    WeekWeatherAnalysis detail = this.Search(province, city, district);
                    this.InvokeToForm(new Action(() =>
                    {
                        if (detail != null)
                        {
                            this.SetWeather(detail);
                            lblStatus.text = "已完成";
                        }
                        else
                        {
                            lblStatus.text = "查询错误,请确保联网正确";
                        }
                    }));
                }, null);
            });
        }
        else
        {
            lblStatus.text = "地区加载错误,请确保联网正确";
        }
    }
Exemple #3
0
 private void SetWeather(WeekWeatherAnalysis detail)
 {
     Debug.Assert(detail != null, "detail == null");
     for (int i = 0; i < weatherDays.Length; i++)
     {
         weatherDays[i].Day           = detail.Day_1To7[i] ?? "";
         weatherDays[i].Info          = detail.Info_1To7[i] ?? "";
         weatherDays[i].Temperature   = detail.Temperature_1To7[i] ?? "";
         weatherDays[i].Wind          = detail.Wind_1To7[i] ?? "";
         weatherDays[i].WeatherStatus = detail.WeatherStatus_1To7[i];
     }
     for (int i = 0; i < weatherDaysMore.Length; i++)
     {
         weatherDaysMore[i].Day           = detail.Day_7To15[i] ?? "";
         weatherDaysMore[i].Info          = detail.Info_7To15[i] ?? "";
         weatherDaysMore[i].Temperature   = detail.Temperature_7To15[i] ?? "";
         weatherDaysMore[i].Wind1         = detail.Wind1_7To15[i] ?? "";
         weatherDaysMore[i].Wind2         = detail.Wind2_7To15[i] ?? "";
         weatherDaysMore[i].WeatherStatus = detail.WeatherStatus_7To15[i];
     }
 }