public List <ProvinceStoreMapping> GetProvinceStoreMapping() { const string CacheKeyMapping = "ProvinceStoreMapping"; List <ProvinceStoreMapping> mappings = HttpRuntime.Cache[CacheKeyMapping] as List <ProvinceStoreMapping>; if (mappings != null) { return(mappings); } mappings = new List <ProvinceStoreMapping>(); var proxy = ServiceClientProvider.GetChinaShippingServiceProxy(); GetProvinceStoreMappingResponse result = proxy.GetProvinceStoreMapping(new GetProvinceStoreMappingRequest1(new GetProvinceStoreMappingRequest())).GetProvinceStoreMappingResult; if (result.Status == ServiceProvider.ShippingChinaSvc.ServiceResponseStatusType.Success && result.Mappings != null) { mappings = result.Mappings; HttpRuntime.Cache.Insert(CacheKeyMapping, mappings, null, DateTime.Now.AddMinutes(SHIPPINGINFO_CACHE_MINUTES), Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null); } return(mappings); }
public string GetUnsupportedExpressAddress(string province, string city, string district, string expressCompanyId) { var warning = string.Empty; try { var proxy = ServiceClientProvider.GetChinaShippingServiceProxy(); var response = proxy.GetUnsupportedExpressAddress(new GetUnsupportedExpressAddressRequest1(new GetUnsupportedExpressAddressRequest() { City = city, Province = province, District = district, ExpressCompany = expressCompanyId })).GetUnsupportedExpressAddressResult; if (response != null && response.Status == ServiceProvider.ShippingChinaSvc.ServiceResponseStatusType.Success) { return(response.WarningMessage); } } catch (Exception ex) { LoggerHelper.Error( string.Format("GetUnsupportedExpressAddress {0} {1} {2} {3} ERR:{4}", province, city, district, expressCompanyId, ex)); } return(warning); }
public string GetUnsupportedAddress(string province, string city, string district) { string warning = string.Empty; try { var proxy = ServiceClientProvider.GetChinaShippingServiceProxy(); GetUnsupportedAddressResponse response = proxy.GetUnsupportedAddress(new GetUnsupportedAddressRequest1(new GetUnsupportedAddressRequest { City = city, Province = province, District = district, })).GetUnsupportedAddressResult; if (response != null) { return(response.WarningMessage); } } catch (Exception ex) { LoggerHelper.Error( string.Format("GetUnsupportedAddress {0} {1} {2} ERR:{3}", province, city, district, ex)); } return(warning); }
public override List <DeliveryOption> GetDeliveryOptionsListForMobileShipping(string Country, string locale, ShippingAddress_V01 address, string memberId) { var proxy = ServiceClientProvider.GetChinaShippingServiceProxy(); var deliveryOptions = new List <DeliveryOption>(); var AddressID = 0; if (EnableCnsmsAndInternetCommerce) { // Line3 stores CNSMS addressID if (address == null || address.Address == null || string.IsNullOrEmpty(address.Address.Line3)) { return(deliveryOptions); } int.TryParse(address.Address.Line3, out AddressID); if (AddressID == 0) { return(deliveryOptions); } } else { AddressID = address.ID; } // bug: 131993 - to make the cache key factored by the address location (Cnty, Province, City, District), which should affect the express companies deliveryOptions = new List <DeliveryOption>(); var result = proxy.GetGetExpressCompany(new GetGetExpressCompanyRequest(new GetExpressCompanyRequest_V01() { DistributorID = memberId, AddressID = AddressID, IncludeFeeDetail = true, })).GetGetExpressCompanyResult as GetExpressCompanyResponse_V01; if (result != null && result.Status == ServiceProvider.ShippingChinaSvc.ServiceResponseStatusType.Success) { foreach (var express in result.ExpressCompanies) { var delivery = new DeliveryOption(); delivery.Name = delivery.Description = express.ExpressCompanyName; delivery.ID = delivery.Id = express.ExpressCompanyID; delivery.FreightCode = express.ExpressCompanyID.ToString(); delivery.Information = express.ExpressCompanyInfo; delivery.BasePrice = express.BasePrice; delivery.FirstPrice = express.FirstPrice; delivery.FirstWeight = express.FirstWeight; delivery.RenewalPrice = express.RenewalPrice; delivery.EstimatedFee = express.EstimatedFee; deliveryOptions.Add(delivery); } } return(deliveryOptions); }
public override string GetMapScript(ShippingMapType mapType) { string result = ""; switch (mapType) { case ShippingMapType.Baidu: try { if (ChinaShippingServiceProxy == null) { ChinaShippingServiceProxy = ServiceClientProvider.GetChinaShippingServiceProxy(); } var response = ChinaShippingServiceProxy.GetBaiduMapJavascript(new GetBaiduMapJavascriptRequest1(new GetBaiduMapJavascriptRequest_V01 { APIurl = HLConfigManager.Configurations.PickupOrDeliveryConfiguration.MapURL, })).GetBaiduMapJavascriptResult as GetBaiduMapJavascriptResponse_V01; if (response != null && response.Status == ServiceProvider.ShippingChinaSvc.ServiceResponseStatusType.Success) { result = response.Script; } } catch (Exception ex) { LoggerHelper.Error( string.Format("ShippingProvider_CN : GetMapScript ERR:{0}", ex)); } break; default: break; } return(result); }
public override List <DeliveryOption> GetDeliveryOptionsListForShipping(string country, string locale, ShippingAddress_V01 address) { StringBuilder perfMsg = new StringBuilder(); DateTime perf01 = DateTime.Now; perfMsg.AppendLine(string.Format("GetDeliveryOptionsListForShipping - start : {0}", perf01)); var proxy = ServiceClientProvider.GetChinaShippingServiceProxy(); List <DeliveryOption> deliveryOptions = new List <DeliveryOption>(); int AddressID = 0; if (EnableCnsmsAndInternetCommerce) { // Line3 stores CNSMS addressID if (address == null || address.Address == null || string.IsNullOrEmpty(address.Address.Line3)) { return(deliveryOptions); } int.TryParse(address.Address.Line3, out AddressID); if (AddressID == 0) { return(deliveryOptions); } } else { AddressID = address.ID; } var member = (MembershipUser <DistributorProfileModel>)Membership.GetUser(); if (member == null || member.Value == null) { return(deliveryOptions); } // bug: 131993 - to make the cache key factored by the address location (Cnty, Province, City, District), which should affect the express companies var addr = address.Address; string CacheKey = string.Format("{0}{1}_{2}_{3}_{4}_{5}", "CN_EXPRESS_COMPANY_", member.Value.Id, addr.Country, addr.StateProvinceTerritory, addr.City, addr.CountyDistrict); if (EmployExpressDdlCache) { //deliveryOptions = HttpRuntime.Cache[CacheKey] as List<DeliveryOption>; //if (deliveryOptions != null) //{ // if (TraceExpressDdlPerformance) // { // perfMsg.AppendLine(string.Format("GetDeliveryOptionsListForShipping - return cache : {0}", DateTime.Now.Subtract(perf01).Milliseconds)); // System.Diagnostics.Debug.WriteLine(perfMsg.ToString()); // } // return deliveryOptions; //} } deliveryOptions = new List <DeliveryOption>(); GetExpressCompanyResponse_V01 result = proxy.GetGetExpressCompany(new GetGetExpressCompanyRequest(new GetExpressCompanyRequest_V01 { DistributorID = member.Value.Id, AddressID = AddressID, IncludeFeeDetail = true, })).GetGetExpressCompanyResult as GetExpressCompanyResponse_V01; if (result != null && result.Status == ServiceProvider.ShippingChinaSvc.ServiceResponseStatusType.Success) { var selectText = (string)HttpContext.GetLocalResourceObject(HLConfigManager.Configurations.CheckoutConfiguration .CheckoutOptionsControl, "TextSelect", CultureInfo.CurrentCulture); deliveryOptions.Add(new DeliveryOption() { Name = selectText, Id = 0, FreightCode = "0", Information = selectText, Description = selectText }); foreach (var express in result.ExpressCompanies) { DeliveryOption delivery = new DeliveryOption(); delivery.Name = delivery.Description = express.ExpressCompanyName; delivery.ID = delivery.Id = express.ExpressCompanyID; delivery.FreightCode = express.ExpressCompanyID.ToString(); delivery.Information = express.ExpressCompanyInfo; delivery.BasePrice = express.BasePrice; delivery.FirstPrice = express.FirstPrice; delivery.FirstWeight = express.FirstWeight; delivery.RenewalPrice = express.RenewalPrice; delivery.EstimatedFee = express.EstimatedFee; deliveryOptions.Add(delivery); } if (EmployExpressDdlCache) { //HttpRuntime.Cache.Insert(CacheKey, // deliveryOptions, // null, // DateTime.Now.AddMinutes(SHIPPINGINFO_CACHE_MINUTES), // Cache.NoSlidingExpiration, // CacheItemPriority.NotRemovable, // null); } } if (TraceExpressDdlPerformance) { //perfMsg.AppendLine(string.Format("GetDeliveryOptionsListForShipping - hit db : {0}", DateTime.Now.Subtract(perf01).Milliseconds)); //System.Diagnostics.Debug.WriteLine(perfMsg.ToString()); } return(deliveryOptions); }