public AreaService(IClientProvider iClientProvider) { var json = JsonFile(); var regionData = JsonConvert.DeserializeObject <GetRegionDataResponse>(json); var areas = regionData?.Areas ?? new List <RegionList>(); areas = areas.OrderBy(x => x.Version).ToList(); var currentVersion = areas.LastOrDefault()?.Version ?? "V0_SN"; if (iClientProvider != null) { //读取公共服务最新地址库 var result = iClientProvider.GetRegionData(new GetRegionDataRequest { Version = currentVersion }).Result; if (result.success && result.data != null) { regionData = JsonConvert.DeserializeObject <GetRegionDataResponse>(result.data.ToString()); if (regionData?.Areas?.Count > 0) { var areasList = regionData.Areas.OrderBy(x => x.Version).ToList(); if (currentVersion != areasList.LastOrDefault()?.Version) { areas.AddRange(regionData.Areas); var data = new GetRegionDataResponse { Areas = areas }; JsonFile(false, data.ToJsonString()); } } } } _areas = areas.OrderBy(x => x.Version).LastOrDefault(); _regions = areas.SelectMany(x => x.Regions).Distinct().ToList(); var provinces = _areas.Regions.Where(x => x.Level == Level.Province).Distinct().ToList(); ProvinceCodes = provinces.Select(x => x.Version + x.Code).Distinct().ToList(); ProvinceNames = provinces.Select(x => x.Name).Distinct().ToList(); }