/// <summary> /// 初始化资源,所有要用的资源都在这里加载,防止内存泄露 /// </summary> private void initResouces() { //加载页面 new ResourceInitialise().LoadForm(); try { //上送版本号 WtPayAccess.insertVersion(); //设置系统时间 SysBLL.SetSystemTime(BroadCasAccess.getSystemTime()); //设备签到 string mechineNo = ConfigurationManager.AppSettings["MechineNo"]; SysBLL.MechineSign(mechineNo); //万通拉卡拉签到 PayAccess.LklWtSign(); //燃气注册表 SysBLL.RunBat(System.AppDomain.CurrentDomain.BaseDirectory + SysConfigHelper.readerNode("regist")); } catch (Exception ex) { log.Write("error:MainWindow:weatherWorker_DoWork:" + ex.Message); } }
/// <summary> /// 天气查询 /// </summary> void weather() { try { if ((DateTime.Now.Hour % SysBLL.WeatherQuerystate) == 0) { if (DateTime.Now.Hour != SysBLL.WeatherHour) { //上送版本 WtPayAccess.insertVersion(); SysBLL.WeatherHour = DateTime.Now.Hour; SysBLL.WeatherQuerystate = 4; //PM2.5 PmInfo pmInfo = WeatherAccess.QueryPm(); //天气预报 WeatherInfo weatherInfo = WeatherAccess.QueryWeather(); //温度 SysBLL.temp = weatherInfo.data.retData.today.lowtemp + "~" + weatherInfo.data.retData.today.hightemp; this.tempLbl.Dispatcher.Invoke(new setTextBlockTextDelegate(setTextBlockText), tempLbl, SysBLL.temp); //风向 SysBLL.fengxiang = weatherInfo.data.retData.today.fengxiang + "(" + weatherInfo.data.retData.today.fengli + ")"; this.fengxiangLbl.Dispatcher.Invoke(new setTextBlockTextDelegate(setTextBlockText), fengxiangLbl, SysBLL.fengxiang); //AQI SysBLL.AQI = "AQI " + pmInfo.data.aqi; this.AQILbl.Dispatcher.Invoke(new setTextBlockTextDelegate(setTextBlockText), this.AQILbl, SysBLL.AQI); //污染程度 SysBLL.quality = pmInfo.data.quality; this.qualityLbl.Dispatcher.Invoke(new setTextBlockTextDelegate(setTextBlockText), qualityLbl, SysBLL.quality); //天气状况 SysBLL.WeatherState = weatherInfo.data.retData.today.type; //设置天气图片 this.weatherPct.Dispatcher.Invoke(new setImagePct(getWeatherImage), weatherPct, SysBLL.WeatherState); } } } catch (Exception ex) { log.Write("error:天气查询异常:" + ex.Message); } }