public static int GetRegionId(string street, string country, string city, string province) { int regionId = RegionHelper.GetRegionId(country, city, province); if (regionId <= 0 || string.IsNullOrEmpty(street)) { return(regionId); } IList <Hidistro.Entities.Store.RegionInfo> regionChildList = RegionHelper.GetRegionChildList(regionId, true); try { Hidistro.Entities.Store.RegionInfo regionInfo = RegionHelper.FindNodeByRegionName(regionChildList, street); return(regionInfo?.RegionId ?? 0); } catch (Exception ex) { IDictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary.Add("Province", province.ToNullString()); dictionary.Add("city", city.ToNullString()); dictionary.Add("county", country.ToNullString()); dictionary.Add("street", country.ToNullString()); Globals.WriteExceptionLog(ex, dictionary, "GetRegionId"); } return(0); }
public static int GetRegionId(string county, string city, string province) { try { Hidistro.Entities.Store.RegionInfo regionInfo = RegionHelper.FindNodeByRegionName(province.Replace("市", ""), 1); if (regionInfo == null) { regionInfo = RegionHelper.FindNodeByRegionName(province + "省", 1); } if (regionInfo != null) { int regionId = regionInfo.RegionId; if (string.IsNullOrEmpty(city)) { return(regionId); } IList <Hidistro.Entities.Store.RegionInfo> regionChildList = RegionHelper.GetRegionChildList(regionId, true); regionInfo = RegionHelper.FindNodeByRegionName(regionChildList, city); if (regionInfo == null) { regionInfo = RegionHelper.FindNodeByRegionName(regionChildList, city + "市"); } if (regionInfo != null) { if (string.IsNullOrEmpty(county)) { return(regionId); } regionId = regionInfo.RegionId; IList <Hidistro.Entities.Store.RegionInfo> regionChildList2 = RegionHelper.GetRegionChildList(regionId, true); regionInfo = RegionHelper.FindNodeByRegionName(regionChildList2, county); if (regionInfo != null) { regionId = regionInfo.RegionId; } } return(regionId); } } catch (Exception ex) { IDictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary.Add("Province", province.ToNullString()); dictionary.Add("city", city.ToNullString()); dictionary.Add("county", county.ToNullString()); Globals.WriteExceptionLog(ex, dictionary, "GetRegionId"); } return(0); }