/// <summary> /// Updates Alert on CustomerExtention table /// </summary> /// <remarks>Used only for China DO System</remarks> /// <param name="distributorId">The distributor identifier.</param> public static bool UpdateAlertCustomerExtention(string distributorId) { var result = false; var proxy = ServiceClientProvider.GetDistributorServiceProxy(); try { var request = new UpdateAlertCustomerExtentionRequest_V01 { DistributorId = distributorId, }; var response = proxy.UpdateAlertCustomerExtention(new UpdateAlertCustomerExtentionRequest1(request)).UpdateAlertCustomerExtentionResult; if (response != null && response.Status == ServiceResponseStatusType.Success) { result = true; } } catch (Exception ex) { ExceptionPolicy.HandleException( new Exception(string.Format("Error in DistributorProvider.UpdateAlertCustomerExtention, for DS id: {0}; error msg: {1}", distributorId, ex)), ProviderPolicies.SYSTEM_EXCEPTION); } finally { ServiceClientFactory.Dispose(proxy); } return(result); }
public static void GetHAPSettings(DistributorOrderingProfile distributor) { if (!distributor.HAPExpiryDateSpecified || distributor.HAPExpiryDate == null) { using (var proxy = ServiceClientProvider.GetDistributorServiceProxy()) { try { var response = proxy.GetBasicDistributor(new GetBasicDistributorRequest( new GetBasicDistributorRequest_V01() { DistributorID = distributor.Id, CountryCode = distributor.CurrentLoggedInCountry, RequiresTin = false })).GetBasicDistributorResult as GetBasicDistributorResponse_V01; if (response.Status == ServiceResponseStatusType.Success && response.Distributor != null) { distributor.HAPExpiryDateSpecified = response.Distributor.HAPExpiryDateFieldSpecified; distributor.HAPExpiryDate = response.Distributor.HAPExpiryDateField; } } catch (Exception ex) { LoggerHelper.Warn( string.Format("MyHerbalife3.Ordering.Providers.DistributorOrderingProfileProvider.GetHAPSettings - distributorId: {0} - country: {1} - Exception: {2}", distributor.Id, distributor.CurrentLoggedInCountry, ex.Message)); } } } }
public static Scheme CheckDsLevelType(string distributorID, string countryCode) { //string DsLevel =new LevelGroupType(); //List<DistributorTraining_V01> trainings = new List<DistributorTraining_V01>(); using (var proxy = ServiceClientProvider.GetDistributorServiceProxy()) { try { var response = proxy.GetBasicDistributor(new GetBasicDistributorRequest( new GetBasicDistributorRequest_V01() { DistributorID = distributorID, CountryCode = countryCode, RequiresTin = false })).GetBasicDistributorResult as GetBasicDistributorResponse_V01; if (response.Status == ServiceResponseStatusType.Success && response.Distributor != null) { return(response.Distributor.Scheme); } } catch (Exception ex) { LoggerHelper.Warn( string.Format("MyHerbalife3.Ordering.Providers.DistributorOrderingProfileProvider - distributorId: {0} - Exception: {1}", distributorID, ex.Message)); } } return(Scheme.Distributor); }
public static GetBasicDistributorResponse_V01 GetDistributorProfileforEmail(string distributorID, string countryCode) { var response = new GetBasicDistributorResponse_V01(); using (var proxy = ServiceClientProvider.GetDistributorServiceProxy()) { try { response = proxy.GetBasicDistributor(new GetBasicDistributorRequest( new GetBasicDistributorRequest_V01() { DistributorID = distributorID, CountryCode = countryCode, RequiresTin = false })).GetBasicDistributorResult as GetBasicDistributorResponse_V01; if (response.Status == ServiceResponseStatusType.Success && response.Distributor != null) { } } catch (Exception ex) { LoggerHelper.Warn( string.Format("MyHerbalife3.Ordering.Providers.DistributorOrderingProfileProvider - distributorId: {0} - country: {1} - Exception: {2}", distributorID, countryCode, ex.Message)); } } return(response); }
public static List <FavouriteSKU> LoadFromService(string distributorID, string locale) { List <FavouriteSKU> SKUs = new List <FavouriteSKU>(); GetDistributorFavouriteSKURequest request = new GetDistributorFavouriteSKURequest() { DistributorID = distributorID, Locale = locale }; if (string.IsNullOrEmpty(request.DistributorID)) { return(SKUs); } else { try { var proxy = ServiceClientProvider.GetDistributorServiceProxy(); var response = proxy.GetDistributorFavouriteSKUs(new GetDistributorFavouriteSKUsRequest(request)).GetDistributorFavouriteSKUsResult as GetDistributorFavouriteSKUResponse_V01; if (response != null && response.Status == ServiceResponseStatusType.Success) { SKUs = response.FavouriteSKUs; } } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ProviderPolicies.SYSTEM_EXCEPTION); } } return(SKUs); }
private static MyHerbalife3.Ordering.ServiceProvider.DistributorSvc.GetDistributorVolumeResponse_V01 getVolumePoints(string distributorId) { var cacheKey = "VOLAPFExempt_" + distributorId; // tries to get object from cache var result = HttpRuntime.Cache[cacheKey]; if (null != result) { return(result as MyHerbalife3.Ordering.ServiceProvider.DistributorSvc.GetDistributorVolumeResponse_V01); } try { var proxy = ServiceClientProvider.GetDistributorServiceProxy(); var circuitBreaker = CircuitBreakerFactory.GetFactory().GetCircuitBreaker <MyHerbalife3.Ordering.ServiceProvider.DistributorSvc.GetDistributorVolumeResponse_V01>(); var getVolumeRequest = new MyHerbalife3.Ordering.ServiceProvider.DistributorSvc.GetDistributorVolumeRequest_V01 { DistributorID = distributorId, StartDate = DateTimeUtils.GetFirstDayOfMonth(DateTime.UtcNow.AddMonths(-1)), EndDate = DateTimeUtils.GetLastDayOfMonth(DateTime.UtcNow) }; var response = circuitBreaker.Execute( () => proxy.GetDistributorVolumePoints(new MyHerbalife3.Ordering.ServiceProvider.DistributorSvc.GetDistributorVolumePointsRequest(getVolumeRequest)).GetDistributorVolumePointsResult as MyHerbalife3.Ordering.ServiceProvider.DistributorSvc.GetDistributorVolumeResponse_V01); HttpRuntime.Cache.Insert(cacheKey, response, null, DateTime.Now.AddMinutes(APFDUE_CACHE_MINUTES), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); return(response); } catch (Exception ex) { HL.Common.Logging.LoggerHelper.Error("APFDueProvider.IsAPFExemptOn200VP() Error \n" + ex.StackTrace); } return(null); }
public static bool ClearDistributorCache(string distributorID, string type) { bool IsCleared = false; try { var proxy = ServiceClientProvider.GetDistributorServiceProxy(); IsCleared = proxy.ClearCache(new ServiceProvider.DistributorSvc.ClearCacheRequest(distributorID, type)).ClearCacheResult; } catch (Exception ex) { LoggerHelper.Warn( string.Format("MyHerbalife3.Ordering.Providers.ClearDistributorCache - distributorId: {0} - type: {1} - Exception: {2}", distributorID, type, ex.Message)); } return(IsCleared); }
/// <summary> /// Gets the distrubutor notes from service if needed and save them in the object /// </summary> /// <param name="distributor">The distributor</param> /// <param name="noteType">The note type</param> /// <param name="noteCode">The note code</param> public static void GetDistributorNotes(DistributorOrderingProfile distributor, string noteType, string noteCode) { if (distributor.DistributorNotes == null) { var request = new GetDistributorNotesRequest_V01 { DistributorId = distributor.Id, NoteType = noteType, NoteCode = noteCode }; var response = new GetDistributorNotesResponse_V01(); var proxy = ServiceClientProvider.GetDistributorServiceProxy(); response = proxy.GetDistributorNotes(new GetDistributorNotesRequest(request)).GetDistributorNotesResult as GetDistributorNotesResponse_V01; if (response.Status == ServiceResponseStatusType.Success) { distributor.DistributorNotes = response.DistibutorNotes; } } }
public static void CheckForMPCFraud(DistributorOrderingProfile distributor) { string errorResxKey = string.Empty; try { if (distributor != null && distributor.IsMPCFraud == null) { using (var proxyDs = ServiceClientProvider.GetDistributorServiceProxy()) { var requestV01 = new GetBasicDistributorRequest_V01 { DistributorID = distributor.Id }; var circuitBreaker = CircuitBreakerFactory.GetFactory().GetCircuitBreaker <GetBasicDistributorResponse_V01>(); var responseV01 = circuitBreaker.Execute(() => proxyDs.GetBasicDistributor(new GetBasicDistributorRequest(requestV01))).GetBasicDistributorResult as GetBasicDistributorResponse_V01; if (responseV01 != null && responseV01.Status == ServiceResponseStatusType.Success) { if (responseV01.Distributor != null) { distributor.IsMPCFraud = responseV01.Distributor.IsMPCFraud; } } } } } catch (Exception ex) { LoggerHelper.Exception("System.Exception", new Exception( string.Format( "Error retrieving MPC Fraud from Distributor service for: DS:{0} - Country:{1}, {2}", distributor.Id, distributor.CurrentLoggedInCountry, ex))); } }
public static bool SetFavouriteSKU(string distributorID, int productID, string productSKU, string locale, int DEL = 0) { ServiceProvider.DistributorSvc.SetDistributorFavouriteRequest request = new ServiceProvider.DistributorSvc.SetDistributorFavouriteRequest { DistributorId = distributorID, ProductID = productID, ProductSKU = productSKU, Locale = locale, Delete = (DEL > 0 ? true : false) }; if (string.IsNullOrEmpty(request.DistributorId) || string.IsNullOrEmpty(request.ProductSKU) || string.IsNullOrEmpty(request.Locale)) { return(false); } else { try { var proxy = ServiceClientProvider.GetDistributorServiceProxy(); var response = proxy.SetDistributorFavouriteSKU(new ServiceProvider.DistributorSvc.SetDistributorFavouriteSKURequest(request)).SetDistributorFavouriteSKUResult as ServiceProvider.DistributorSvc.SetDistributorFavouriteResponse; if (response != null && response.Status == ServiceProvider.DistributorSvc.ServiceResponseStatusType.Success) { ISimpleCache _cache = CacheFactory.Create(); var cacheKey = string.Format("Favour_{0}_{1}", distributorID.ToUpper(), Thread.CurrentThread.CurrentUICulture.Name); _cache.Expire(typeof(List <FavouriteSKU>), cacheKey); //HttpContext.Current.Session[cacheKey] = null; return(true); } } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ProviderPolicies.SYSTEM_EXCEPTION); return(false); } } return(false); }
public static string CheckForDRFraud(DistributorOrderingProfile distributor, string zipCode) { string errorResxKey = string.Empty; var fraudStatus = DRFraudStatusType.None; bool isBlocked, isSponsorBlocked, isDsFound; isBlocked = isSponsorBlocked = isDsFound = false; using (var proxy = ServiceClientProvider.GetOrderServiceProxy()) { try { if (distributor != null && distributor.FraudStatus == null) { using (var proxyDs = ServiceClientProvider.GetDistributorServiceProxy()) { var requestV01 = new GetBasicDistributorRequest_V01 { DistributorID = distributor.Id }; var circuitBreaker = CircuitBreakerFactory.GetFactory().GetCircuitBreaker <GetBasicDistributorResponse_V01>(); var responseV01 = circuitBreaker.Execute(() => proxyDs.GetBasicDistributor(new GetBasicDistributorRequest(requestV01))).GetBasicDistributorResult as GetBasicDistributorResponse_V01; if (responseV01 != null && responseV01.Status == ServiceResponseStatusType.Success) { if (responseV01.Distributor != null) { isBlocked = responseV01.Distributor.DRFraudStatusFlags.IsDistributorblocked; isSponsorBlocked = responseV01.Distributor.DRFraudStatusFlags.IsSponsorBlocked; isDsFound = true; } } } } else if (distributor != null && distributor.FraudStatus != null) { isBlocked = distributor.FraudStatus.IsDistributorblocked; isSponsorBlocked = distributor.FraudStatus.IsSponsorBlocked; isDsFound = true; } if (isDsFound) { var request = new GetDRFraudStatusRequest_V01(); request.DistributorID = distributor.Id; request.CountryCode = distributor.CurrentLoggedInCountry; request.PostalCode = zipCode; request.DistributorIsBlocked = isBlocked; request.SponsorIsBlocked = isSponsorBlocked; var response = proxy.GetDRFraudStatus(new GetDRFraudStatusRequest(request)).GetDRFraudStatusResult as GetDRFraudStatusResponse_V01; if (response.Status == ServiceProvider.OrderSvc.ServiceResponseStatusType.Success) { fraudStatus = response.FraudStatus; } } else { LoggerHelper.Exception("System.Exception", new Exception( string.Format( "Error retrieving DS DRFraudStatusFlags from Cache and Distributor service for: DS:{0} - Country:{1}", distributor.Id, distributor.CurrentLoggedInCountry))); fraudStatus = DRFraudStatusType.None; } } catch (Exception ex) { LoggerHelper.Exception("System.Exception", new Exception( string.Format( "Error retrieving DRFraud Status from Order service for: DS:{0} - Country:{1}, {2}", distributor.Id, distributor.CurrentLoggedInCountry, ex))); fraudStatus = DRFraudStatusType.None; } } if (fraudStatus == DRFraudStatusType.DistributorIsBlocked) { errorResxKey = "BlockedDS"; } else if (fraudStatus == DRFraudStatusType.PostalCodeIsBlocked) { errorResxKey = "BlockedZip"; } return(errorResxKey); }