Exemple #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string         cityIp   = WebToolsHelper.GetIp();
         TerminalStatus terminal = TerminalOnlineMonitorThread.GetTerminal(cityIp);
         string         cityCode = string.Empty;
         if (terminal != null)
         {
             cityCode = terminal.CityCode;
         }
         else
         {
             cityCode = "101010100";
         }
         if (cityCode != null && cityCode.Length > 0)
         {
             WeatherObject weather = null;
             try
             {
                 weather = WeatherHelper.GetCityWeather(cityCode);
             }
             catch
             {
             }
             if (weather != null)
             {
                 this.lbCity.Text         = weather.weatherinfo.city;
                 this.lbDate.Text         = System.DateTime.Now.ToString("M月d日");
                 this.lbTemp.Text         = weather.weatherinfo.temp1;
                 this.lbTrafficLimit.Text = this.GetTrafficLimitInfo(cityCode);
                 this.lbWeek.Text         = weather.weatherinfo.week;
                 this.lbWind.Text         = weather.weatherinfo.wind1;
                 this.img1.Visible        = true;
                 this.img1.ImageUrl       = weather.weatherinfo.img1;
             }
             else
             {
                 this.lbCity.Text         = "预报出错";
                 this.lbDate.Text         = System.DateTime.Now.ToString("M月d日");
                 this.lbTemp.Text         = string.Empty;
                 this.lbTrafficLimit.Text = this.GetTrafficLimitInfo(cityCode);
                 this.lbWeek.Text         = DateTimeHelper.GetChineseXq(System.DateTime.Now);
                 this.lbWind.Text         = string.Empty;
                 this.img1.Visible        = false;
                 // this.img1.ImageUrl = weather.weatherinfo.img1;
             }
         }
     }
 }