public override List <string> GetZipsForStreet(string country, string city, string suburb, string street) { try { string CacheKey = string.Format("{0}{1}_{2}_{3}", "ZIPCODE_HU_", city, suburb, street); const int ZIPCODE_HU_CACHE_MINUTES = 60; var zips = HttpRuntime.Cache[CacheKey] as List <string>; if (zips != null) { return(zips); } var proxy = ServiceClientProvider.GetShippingServiceProxy(); var request = new ZipsForStreetRequest_V01(); request.Country = country; request.State = city; request.City = suburb; request.Street = street; var response = proxy.GetZipsForStreet(new GetZipsForStreetRequest(request)).GetZipsForStreetResult as ZipsForStreetResponse_V01; if (response != null && response.Zips != null) { HttpRuntime.Cache.Insert(CacheKey, response.Zips, null, DateTime.Now.AddMinutes(ZIPCODE_HU_CACHE_MINUTES), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } return(response.Zips); } catch (Exception ex) { LoggerHelper.Error( string.Format("GetZipsForStreet error: Country {0}, error: {1}", country, ex)); } return(null); }
public virtual List <string> GetZipsForStreet(string country, string state, string city, string street) { try { var proxy = ServiceClientProvider.GetShippingServiceProxy(); var request = new ZipsForStreetRequest_V01(); request.Country = country; request.State = state; request.City = city; request.Street = street; var response = proxy.GetZipsForStreet(new GetZipsForStreetRequest(request)); var result = response.GetZipsForStreetResult as ZipsForStreetResponse_V01; return(result.Zips); } catch (Exception ex) { LoggerHelper.Error(string.Format("GetZipsForStreet error: Country {0}, error: {1}", country, ex.ToString())); } return(null); }