| | |
| | | |
| | | #region 获取天气部分 |
| | | /// <summary> |
| | | /// 获取指定经纬度的城市信息 |
| | | /// 获取指定经纬度的城市信息天气信息 |
| | | /// </summary> |
| | | public void GetCityInfo(string lon, string lat) |
| | | public void GetCityWeatherInfo(string lon, string lat) |
| | | { |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | |
| | | }); |
| | | }); |
| | | } |
| | | ///// <summary> |
| | | ///// 获取指定经纬度的城市信息 |
| | | ///// </summary> |
| | | ///// <param name="lon"></param> |
| | | ///// <param name="lat"></param> |
| | | //public void GetCityInfo() |
| | | //{ |
| | | // if (DB_ResidenceData.Instance.CurrentRegion.longitude == 0 && DB_ResidenceData.Instance.CurrentRegion.latitude == 0) |
| | | // { |
| | | // return; |
| | | // } |
| | | // string lon = DB_ResidenceData.Instance.CurrentRegion.longitude.ToString(); |
| | | // string lat = DB_ResidenceData.Instance.CurrentRegion.latitude.ToString(); |
| | | // System.Threading.Tasks.Task.Run(() => |
| | | // { |
| | | // while (true) |
| | | // { |
| | | // var webClient = new WebClient(); |
| | | // string url = $"https://developer.hdlcontrol.com/Weather/Weather/FindCity/?lon={lon}&lat={lat}"; |
| | | // string responseString = null; |
| | | // try |
| | | // { |
| | | // responseString = Encoding.UTF8.GetString(webClient.DownloadData(url)); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // MainPage.Log(ex.Message); |
| | | // } |
| | | |
| | | // if (responseString != null) |
| | | // { |
| | | // try |
| | | // { |
| | | // var revertObj = Newtonsoft.Json.JsonConvert.DeserializeObject<ResponsePack>(responseString); |
| | | // JObject jt = Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(revertObj.ResponseData.ToString()); |
| | | |
| | | // DB_ResidenceData.cityInfo.location = jt.GetValue("Location").ToString(); |
| | | // DB_ResidenceData.cityInfo.province = jt.GetValue("Province").ToString(); |
| | | // DB_ResidenceData.cityInfo.country = jt.GetValue("Country").ToString(); |
| | | // DB_ResidenceData.cityInfo.timeZone = jt.GetValue("TimeZone").ToString(); |
| | | // DB_ResidenceData.Instance.SaveResidenceData(); |
| | | |
| | | // return; |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // MainPage.Log($"get weather error : {ex.Message}"); |
| | | // } |
| | | // } |
| | | // } |
| | | // }); |
| | | //} |
| | | |
| | | |
| | | #endregion |
| | | |