/// <summary> /// 根据元素节点,上级code 赋值对象 /// </summary> /// <param name="data"></param> /// <returns></returns> private AreaOutput GetAreaOutput(XElement data) { try { AreaOutput obj = new AreaOutput(); obj.Label = data.Attribute("Name").Value; obj.Code = data.Attribute("Code").Value; return(obj); } catch { return(null); } }
/// <summary> /// 获取省 /// </summary> /// <param name="token"></param> /// <returns></returns> public List <AreaOutput> GetProvinces(ProvincesQuery query) { DistrictListWS districtListWs = new DistrictListWS(query.Token, "", ""); List <AreaOutput> list = new List <AreaOutput>(); var ret = districtListWs.FetchAllProvincesAuth(); ret.ForEach((x) => { AreaOutput a = new AreaOutput { AllPinYin = x.AllPinYin, DistrictCode = x.DistrictCode, DistrictName = x.DistrictName, FirstPinYin = x.FirstPinYin, Label = x.DistrictName, Children = new object[] { } }; list.Add(a); }); return(list); }
/// <summary> /// 获取县数据 /// </summary> /// <param name="query"></param> /// <returns></returns> public List <AreaOutput> GetCounty(CountyQuery query) { DistrictListWS districtListWs = new DistrictListWS(query.Token, "", ""); List <AreaOutput> list = new List <AreaOutput>(); var ret = query.CityCodes == null?districtListWs.FetchCountyByCityCodeAuth(query.CityCode) : districtListWs.FetchByParentDistrictList(query.CityCodes); ret.ForEach((x) => { AreaOutput a = new AreaOutput { AllPinYin = x.AllPinYin, DistrictCode = x.DistrictCode, DistrictName = x.DistrictName, FirstPinYin = x.FirstPinYin, Label = x.DistrictName, Children = new object[] { } }; list.Add(a); }); return(list); }
/// <summary> /// 获取市数据 /// </summary> /// <param name="query"></param> /// <returns></returns> public List <AreaOutput> GetCity(CityQuery query) { DistrictListWS districtListWs = new DistrictListWS(query.Token, "", ""); string[] proviceCodes = new string[] { query.ProviceCode }; List <AreaOutput> list = new List <AreaOutput>(); var ret = districtListWs.FetchCityAuth(proviceCodes); ret.ForEach((x) => { AreaOutput a = new AreaOutput { AllPinYin = x.AllPinYin, DistrictCode = x.DistrictCode, DistrictName = x.DistrictName, FirstPinYin = x.FirstPinYin, Label = x.DistrictName, Children = new object[] { } }; list.Add(a); }); return(list); }