예제 #1
0
        public List <FavouriteSKUItemResponseViewModel> GetFavouriteSKUs(GetFavouriteParam request)
        {
            List <FavouriteSKUItemResponseViewModel> result = null;


            if (string.IsNullOrWhiteSpace(request.Locale) || string.IsNullOrWhiteSpace(request.DistributorID))
            {
                return(result);
            }

            try
            {
                List <FavouriteSKU> SKUs = new List <FavouriteSKU>();
                SKUs = _favorLoader.GetDistributorFavouriteSKU(request.DistributorID, request.Locale);

                if (SKUs.Count > 0)
                {
                    result = ConvertToFavouriteItemViewModel(SKUs);
                }

                return(result);
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(string.Format("MobileFavouriteSKUProvider : {0}\n {1}\n", ex.Message, ex.StackTrace));
                return(result);
            }
        }
예제 #2
0
        private List <ItemTaxRate> GetItemTaxRatesFromCache(string countryCode)
        {
            var request = new GetTaxItemRateRequestV01 {
                CountryCode = countryCode
            };

            try
            {
                var proxy    = ServiceClientProvider.GetCustomerOrderServiceProxy();
                var response = proxy.GetTaxItemRate(new GetTaxItemRateRequest1(request)).GetTaxItemRateResult;
                if (null != response && response.Status == ServiceProvider.CustomerOrderSvc.ServiceResponseStatusType.Success)
                {
                    var responseV01 = response as GetTaxItemRateResponse_V01;
                    if (null != responseV01 && responseV01.ItemTaxRates.Any())
                    {
                        return(responseV01.ItemTaxRates);
                    }
                }
                LoggerHelper.Error("Invoice Customer pricing GetItemTaxRatesFromTableStorage return null");
                return(new List <ItemTaxRate>());
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(
                    string.Format(
                        "OrderService - InvoiceProvider: An error occured while Calling GetTaxDataForDwsFromVertex service method {0}",
                        ex.Message));
            }
            return(new List <ItemTaxRate>());
        }
예제 #3
0
        public bool SetFavouriteSKUs(SetFavouriteParam request, ref List <ValidationErrorViewModel> errors)
        {
            bool result = false;

            if (string.IsNullOrWhiteSpace(request.Locale) ||
                string.IsNullOrWhiteSpace(request.DistributorID) ||
                string.IsNullOrWhiteSpace(request.SKUList)
                )
            {
                return(result);
            }

            try
            {
                result = _favorLoader.SetFavouriteSKUList(request.DistributorID, request.Locale, request.SKUList);

                return(result);
            }
            catch (Exception ex)
            {
                errors.Add(
                    new ValidationErrorViewModel
                {
                    Code   = 999998,
                    Reason = string.Format("MobileFavouriteSKUProvider update error", ex.Message)
                });

                LoggerHelper.Error(string.Format("MobileFavouriteSKUProvider : {0}\n {1}\n", ex.Message, ex.StackTrace));
                return(result);
            }
        }
예제 #4
0
        public List <DiscontinuedSkuItemResponseViewModel> GetDiscontinuedSkuRequest(GetDiscontinuedSkuParam request)
        {
            List <DiscontinuedSkuItemResponseViewModel> result = null;


            if (string.IsNullOrWhiteSpace(request.Locale) || string.IsNullOrWhiteSpace(request.DistributorId))
            {
                return(null);
            }

            try
            {
                var list = _discontinuedSkuLoader.GetDiscontinuedSkuList(request.DistributorId, request.Locale, request.ShoppingCartItemToCheck);

                if (list.Count > 0)
                {
                    result = ConvertToFavouriteItemViewModel(list);
                }

                return(result);
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(string.Format("MobileDiscontinuedSkuProvider : {0}\n {1}\n", ex.Message, ex.StackTrace));
                return(result);
            }
        }
        public static AnnouncementInfoList GetChinaAnnouncementInfo(DateTime?fromDate, DateTime?toDate, string locale)
        {
            var proxy = ServiceClientProvider.GetCatalogServiceProxy();

            try
            {
                var request = new AnnouncementInfoRequest_V01
                {
                    BeginDate = fromDate,
                    EndDate   = toDate,
                    Locale    = locale
                };

                var response =
                    proxy.GetAnnouncementInfo(new GetAnnouncementInfoRequest(request)).GetAnnouncementInfoResult as AnnouncementInfoResponse_V01;

                // Check response for error.
                if (response == null || response.Status != ServiceResponseStatusType.Success)
                {
                    throw new ApplicationException("CatalogProvider.GetChinaAnnouncementInfo error.");
                }
                return(response.Announcements);
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(
                    string.Format("China GetChinaAnnouncementInfo error: {0} ", ex));
            }
            return(null);
        }
        public static void ClearCache(string storeID)
        {
            string cachekey = string.Format("{0}{1}", INVENTORY_CACHE_PREFIX, storeID);

            HttpRuntime.Cache.Remove(cachekey);
            var catalog = Providers.CatalogProvider.GetCatalog("CN");

            if (catalog == null)
            {
                LoggerHelper.Info("Clear Cache : No catalog");
                return;
            }
            var productCatalog = Providers.CatalogProvider.GetProductInfoCatalog("zh-CN");

            if (productCatalog == null)
            {
                LoggerHelper.Info("Clear Cache : No productCatalog");
                return;
            }
            var varSKU = productCatalog.AllSKUs;

            LoggerHelper.Info(string.Format("CN ClearCache {0}", storeID));
            foreach (var sku in varSKU)
            {
                if (catalog.Items.ContainsKey(sku.Value.SKU))
                {
                    sku.Value.CatalogItem = catalog.Items[sku.Value.SKU] as CatalogItem_V01;
                }
            }
        }
        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 bool SendInvoiceEmail(InvoiceModel invoice)
        {
            var proxy = ServiceClientProvider.GetCommunicationServiceProxy();

            try
            {
                if (null != proxy)
                {
                    var dataToSend = ConvertInvoiceToSendData(invoice);
                    var request    = new TriggeredSendRequestRequest_V01();
                    request.Data = dataToSend;
                    var response = proxy.SendTriggeredMessage(new SendTriggeredMessageRequest(request)).SendTriggeredMessageResult;
                    if (response.Status == ServiceResponseStatusType.Success)
                    {
                        return(true);
                    }
                    else
                    {
                        LoggerHelper.Error(string.Format("CommunicationSvcProvider: Error sending Invoice Email invoice: {0}, member id: {1} status:{2}.", invoice.DisplayMemberInvoiceNumber, invoice.MemberId, response.Status));
                        return(false);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(string.Format("CommunicationSvcProvider: Error sending Invoice Email invoice: {0}, member id: {1} Exception Message:{2}.", invoice.DisplayMemberInvoiceNumber, invoice.MemberId, ex.Message));
                return(false);
            }
        }
예제 #9
0
        protected override ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart, ShoppingCartRuleReason reason,
                                                               ShoppingCartRuleResult Result)
        {
            if (reason == ShoppingCartRuleReason.CartItemsBeingAdded)
            {
                var myhlCart = cart as MyHLShoppingCart;

                if (null == myhlCart)
                {
                    LoggerHelper.Error(
                        string.Format("{0} myhlCart is null {1}", Locale, cart.DistributorID));
                    Result.Result = RulesResult.Failure;
                    return(Result);
                }
                // to set purchasing limit type
                var theLimits     = GetPurchasingLimits(cart.DistributorID, myhlCart.SelectedDSSubType ?? string.Empty);
                var currentLimits = theLimits[PurchasingLimitProvider.GetOrderMonth()];
                if (currentLimits.PurchaseLimitType == PurchaseLimitType.Earnings)
                {
                    var itemsToCalc = new List <ShoppingCartItem_V01>();
                    itemsToCalc.AddRange(myhlCart.CartItems);
                    if (myhlCart.CurrentItems != null && myhlCart.CurrentItems.Count > 0)
                    {
                        itemsToCalc.Add(myhlCart.CurrentItems[0]);
                    }
                    OrderTotals_V01 orderTotals = myhlCart.Calculate(itemsToCalc) as OrderTotals_V01;
                    if (orderTotals != null && orderTotals.DiscountPercentage != 0.0M)
                    {
                        myhlCart.SetDiscountForLimits(orderTotals.DiscountPercentage);
                        myhlCart.Totals = orderTotals;
                    }
                }
            }
            return(base.PerformRules(cart, reason, Result));
        }
        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);
        }
예제 #11
0
        /// <summary>
        /// The get available discounts.
        /// </summary>
        /// <param name="distributorId">
        /// The distributor id.
        /// </param>
        /// <returns>
        /// List of customer discounts
        /// </returns>
        public static List <CustomerDiscountDefinition> GetAvailableDiscounts(string distributorId)
        {
            if (string.IsNullOrEmpty(distributorId))
            {
                return(null);
            }

            using (var proxy = ServiceClientProvider.GetCustomerOrderServiceProxy())
            {
                try
                {
                    var request = new GetCustomerDiscountsByDistributor {
                        DistributorID = distributorId
                    };
                    var response = proxy.GetCustomerDiscounts(new GetCustomerDiscountsRequest1(request)).GetCustomerDiscountsResult as GetCustomerDiscountsResponse_V01;
                    if (response.Status == ServiceResponseStatusType.Success)
                    {
                        return(response.Discounts.ToList());
                    }
                }
                catch (Exception ex)
                {
                    WebUtilities.LogServiceExceptionWithContext(ex, proxy);

                    // ExceptionPolicy.HandleException(ex, ProviderPolicies.SYSTEM_EXCEPTION);
                    LoggerHelper.Error(string.Format("GetAvailableDiscounts DS:{0} ERR:{1}", distributorId, ex));
                    return(null);
                }
            }

            return(null);
        }
        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);
        }
예제 #13
0
        public static List <InvoiceSKU> GetInvoiceSKU(string distributorID, Int64 invoiceID)
        {
            var proxy = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                var request = new GetInvoiceSkuRequest_V01
                {
                    DistributorID = distributorID,
                    InvoiceID     = invoiceID
                };
                var response = proxy.GetInvoiceSku(new GetInvoiceSkuRequest1(request)).GetInvoiceSkuResult as GetInvoiceSkuResponse_V01;
                if (response != null && response.Status == ServiceResponseStatusType.Success &&
                    null != response.InvoiceSkus && response.InvoiceSkus.Count > 0)
                {
                    return(response.InvoiceSkus);
                }
                return(null);
            }
            catch (Exception ex)
            {
                WebUtilities.LogExceptionWithContext(ex);

                LoggerHelper.Exception("System.Exception", new Exception("OrderService: GetInvoiceSKU\n", ex));
            }
            finally
            {
                if (proxy.State != CommunicationState.Closed)
                {
                    proxy.Close();
                }
                proxy = null;
            }
            return(null);
        }
예제 #14
0
        /// <summary>
        /// The save customer order.
        /// </summary>
        /// <param name="customerOrder">
        /// The customer order.
        /// </param>
        /// <returns>
        /// The save customer order.
        /// </returns>
        public static bool SaveCustomerOrder(CustomerOrder_V01 customerOrder)
        {
            if (customerOrder == null)
            {
                return(false);
            }

            using (var proxy = ServiceClientProvider.GetCustomerOrderServiceProxy())
            {
                try
                {
                    var request = new SaveCustomerOrderRequest_V01 {
                        Order = customerOrder
                    };
                    var response = proxy.SaveOrder(new SaveOrderRequest(request)).SaveOrderResult as SaveCustomerOrderResponse_V01;
                    if (response.Status == ServiceResponseStatusType.Success)
                    {
                        return(true);
                    }
                }
                catch (Exception ex)
                {
                    WebUtilities.LogServiceExceptionWithContext(ex, proxy);

                    // ExceptionPolicy.HandleException(ex, ProviderPolicies.SYSTEM_EXCEPTION);
                    LoggerHelper.Error(string.Format("SaveCustomerOrder OrderID:{0} ERR:{1}", customerOrder.OrderID, ex));
                    return(false);
                }
            }
            return(false);
        }
예제 #15
0
        /// <summary>
        ///     Gets the next valid invoice number for the given distributor
        /// </summary>
        /// <param name="distributorID">The ID of the distributor</param>
        /// <returns>The next valid invoice number</returns>
        public static Int64 GetNextDistributorInvoiceNumber(string distributorID)
        {
            var proxy = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                var request = new GetNextDistributorInvoiceNumberRequest_V01
                {
                    DistributorID = distributorID
                };
                var response =
                    proxy.GetNextDistributorInvoiceNumber(new GetNextDistributorInvoiceNumberRequest1(request)).GetNextDistributorInvoiceNumberResult as GetNextDistributorInvoiceNumberResponse_V01;
                if (response != null && response.Status == ServiceResponseStatusType.Success &&
                    response.InvoiceNumber > 0)
                {
                    return(response.InvoiceNumber);
                }
            }
            catch (Exception ex)
            {
                WebUtilities.LogExceptionWithContext(ex);

                LoggerHelper.Exception("System.Exception", new Exception("OrderService: GetNextDistributorInvoiceNumber\n", ex));
            }
            finally
            {
                if (proxy.State != CommunicationState.Closed)
                {
                    proxy.Close();
                }
                proxy = null;
            }
            return(0);
        }
예제 #16
0
        /// <summary>
        ///     method to get the check payment details response from service
        /// </summary>
        /// <param name="distributorID"></param>
        /// <returns></returns>
        private static GetInvoicesResponse_V01 getInvoicesResponse(string distributorID)
        {
            var proxy = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                var request = new GetInvoicesRequest_V01
                {
                    DistributorID = distributorID,
                };
                var response = proxy.GetInvoices(new GetInvoicesRequest1(request)).GetInvoicesResult as GetInvoicesResponse_V01;
                return(response);
            }
            catch (Exception ex)
            {
                WebUtilities.LogExceptionWithContext(ex);

                LoggerHelper.Exception("System.Exception", new Exception("OrderService: getInvoicesResponse\n", ex));
            }
            finally
            {
                if (proxy.State != CommunicationState.Closed)
                {
                    proxy.Close();
                }
                proxy = null;
            }
            return(null);
        }
예제 #17
0
        public static Int64 SetInvoice(Invoice invoice)
        {
            var proxy = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                var request = new SetInvoiceRequest_V01
                {
                    Invoice = invoice
                };
                var response = proxy.SetInvoice(new SetInvoiceRequest1(request)).SetInvoiceResult as SetInvoiceResponse_V01;
                if (response != null && response.Status == ServiceResponseStatusType.Success)
                {
                    ExpireInvoicesCache(invoice.DistributorID);
                    return(response.InvoiceID);
                }
                return(0);
            }
            catch (Exception ex)
            {
                WebUtilities.LogExceptionWithContext(ex);

                LoggerHelper.Exception("System.Exception", new Exception("OrderService: SetInvoice\n", ex));
            }
            finally
            {
                if (proxy.State != CommunicationState.Closed)
                {
                    proxy.Close();
                }
                proxy = null;
            }
            return(0);
        }
        public PurchasingLimits ReloadPurchasingLimits(int orderMonth)
        {
            PurchasingLimits_V01 purchasingLimitsV01 = null;

            try
            {
                if (PurchasingLimitProvider.RequirePurchasingLimits(_distributorId, _currentLoggedInCountry))
                {
                    CreatePurchasingLimits(GetDistributorPurchasingLimitsCollection());
                }
                if (PurchasingLimits == null)
                {
                    return(purchasingLimitsV01);
                }
                if (orderMonth > 0)
                {
                    SetPurchasingLimits(orderMonth);
                }
                SaveToCache();
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(ex.ToString());
            }
            if (PurchasingLimits != null)
            {
                PurchasingLimits.TryGetValue(orderMonth, out purchasingLimitsV01);
            }
            return(purchasingLimitsV01);
        }
        /// <summary>
        /// The get customer order by order id.
        /// </summary>
        /// <param name="orderId">
        /// The order id.
        /// </param>
        /// <returns>
        /// Customer Order Object
        /// </returns>
        public static CustomerOrder_V01 GetCustomerOrderByOrderID(string orderId)
        {
            if (string.IsNullOrEmpty(orderId))
            {
                return(null);
            }

            using (var proxy = ServiceClientProvider.GetCustomerOrderServiceProxy())
            {
                try
                {
                    var request = new GetCustomerOrderRequest_V01();
                    var filter  = new CustomerOrderById {
                        CustomerOrderId = orderId
                    };
                    request.Filter = filter;
                    var response = proxy.GetOrders(new GetOrdersRequest(request)).GetOrdersResult as GetCustomerOrderResponse_V01;
                    if (response != null && response.Status == ServiceResponseStatusType.Success)
                    {
                        return(response.Orders.ToList().Cast <CustomerOrder_V01>().ToList().FirstOrDefault());
                    }
                }
                catch (Exception ex)
                {
                    WebUtilities.LogServiceExceptionWithContext(ex, proxy);

                    // ExceptionPolicy.HandleException(ex, ProviderPolicies.SYSTEM_EXCEPTION);
                    LoggerHelper.Error(string.Format("GetCustomerOrderByOrderID OrderID:{0} ERR:{1}", orderId, ex));
                    return(null);
                }
            }

            return(null);
        }
        private static void Save3DPaymentAfterEnrollment(string orderNumber, string distributorId, string locale, ThreeDSecuredCreditCard threeDCard)
        {
            if (null == threeDCard)
            {
                return;
            }

            var data = SerializeObject(threeDCard, typeof(ThreeDSecuredCreditCard));

            if (threeDCard.IsErrored)
            {
                OrderProvider.InsertPaymentGatewayRecord(orderNumber, distributorId, "3DSecuredEnrollmentAuthentication", "3D credit card Enrollment Check has error -- Declined", locale);
                OrderProvider.UpdatePaymentGatewayRecord(orderNumber, string.Concat("3D credit card Enrollment Check has error -- Declined", data),
                                                         PaymentGatewayLogEntryType.Response, PaymentGatewayRecordStatusType.InError);
                LoggerHelper.Error(string.Format("Order payment error when calling 3D Payment Enrollment service:{0} Error : {1}",
                                                 orderNumber, "3D Payment Enrollment service rturned invalid status"));
            }
            else if (threeDCard.IsDeclined)
            {
                OrderProvider.InsertPaymentGatewayRecord(orderNumber, distributorId, "3DSecuredEnrollmentAuthentication", "3D credit card Enrollment Check received Declined", locale);
                OrderProvider.UpdatePaymentGatewayRecord(orderNumber, string.Concat("3D credit card Enrollment Check received Declined", data),
                                                         PaymentGatewayLogEntryType.Response, PaymentGatewayRecordStatusType.Declined);
            }
            else if (threeDCard.IsEnrolled)
            {
                OrderProvider.InsertPaymentGatewayRecord(orderNumber, distributorId, "3DSecuredEnrollmentAuthentication", "3D credit card enrolled; Will send for 3D password authentication.", locale);
                OrderProvider.UpdatePaymentGatewayRecord(orderNumber, string.Concat("3D credit card enrolled; Will send for 3D password authentication.", data),
                                                         PaymentGatewayLogEntryType.Response, PaymentGatewayRecordStatusType.ApprovalPending);
            }
            else // 3D card is Not Enrolled, and has no issue, should submit this order
            {
                OrderProvider.InsertPaymentGatewayRecord(orderNumber, distributorId, "3DSecuredEnrollmentAuthentication", "3D credit card NOT enrolled. Will submit order to BizTalk for Authorization.", locale);
            }
        }
 private static Dictionary <int, PurchasingLimits_V01> GetPurchasingLimitsFromRulesEngine(string distributorId,
                                                                                          string TIN)
 {
     if (string.IsNullOrEmpty(distributorId))
     {
         return(null);
     }
     else
     {
         try
         {
             var purchasingLimits =
                 HLRulesManager.Manager.GetPurchasingLimits(distributorId, TIN);
             if (purchasingLimits != null)
             {
                 savePurchasingLimitsToCache(purchasingLimits, distributorId);
             }
             return(purchasingLimits);
         }
         catch (Exception ex)
         {
             LoggerHelper.Error(
                 string.Format("Error updating Purchasing Limits for distributor: {0}\r\n{1}", distributorId,
                               ex.Message));
         }
     }
     return(null);
 }
        public static DistributorPurchasingLimitsSourceType GetDistributorPurchasingLimitsSource(string country,
                                                                                                 string distributorId)
        {
            if (HLConfigManager.Configurations.DOConfiguration.IsChina)
            {
                return(DistributorPurchasingLimitsSourceType.HMS);
            }

            var    source    = DistributorPurchasingLimitsSourceType.Unknown;
            string cacheKey  = string.Format("{0}_{1}_{2}", "PLSOURCE", country, distributorId);
            string useFusion = HttpRuntime.Cache[cacheKey] as string;

            if (useFusion == null)
            {
                if (!string.IsNullOrEmpty(distributorId) && !string.IsNullOrEmpty(country))
                {
                    try
                    {
                        OrderServiceClient proxy = null;
                        proxy = ServiceClientProvider.GetOrderServiceProxy();
                        var request =
                            new GetDistributorPurchasingLimitsSourceRequest_V01();
                        request.DistributorID = distributorId;
                        request.CountryCode   = country;
                        // RS exception in country for request
                        if (country.Equals("RS"))
                        {
                            request.CountryCode = HL.Common.ValueObjects.CountryType.RS.HmsCountryCodes.FirstOrDefault();
                        }

                        var response =
                            proxy.GetDistributorPurchasingLimitsSource(new GetDistributorPurchasingLimitsSourceRequest(request)).GetDistributorPurchasingLimitsSourceResult as
                            GetDistributorPurchasingLimitsSourceResponse_V01;
                        if (response.Status != ServiceProvider.OrderSvc.ServiceResponseStatusType.Success)
                        {
                            LoggerHelper.Error(
                                string.Format("Save Purchasing Limits failed for Distributor {0}, Country {1}, Status{2}",
                                              distributorId, country, response.Status));
                        }
                        if (null != response)
                        {
                            source    = response.Source;
                            useFusion = source == DistributorPurchasingLimitsSourceType.HMS ? Boolean.TrueString : Boolean.FalseString;
                            HttpRuntime.Cache.Insert(cacheKey, useFusion, null, DateTime.Now.AddMinutes(15), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
                        }
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.Error(
                            string.Format(
                                "Error retrieving OutstandingOrders Status from BPEL service for: DS:{0} - Country:{1}, {2}",
                                distributorId, country, ex));
                    }
                }
            }

            return(source = string.IsNullOrEmpty(useFusion) ? DistributorPurchasingLimitsSourceType.InternetOrdering : (useFusion.Equals(Boolean.TrueString) ? DistributorPurchasingLimitsSourceType.HMS : DistributorPurchasingLimitsSourceType.InternetOrdering));
        }
예제 #23
0
        /// <summary>Initialize this object</summary>
        private void Initialize()
        {
            _CreateDateTime = DateUtils.GetCurrentLocalTime(_CountryCode);
            var orderMonth = _CreateDateTime;
            var fromDate   = DateTimeUtils.GetFirstDayOfMonth(orderMonth);
            var from       = new DateTime(fromDate.Year, fromDate.Month, fromDate.Day);
            var toDate     = DateTimeUtils.GetLastDayOfMonth(orderMonth);
            var to         = new DateTime(toDate.Year, toDate.Month, toDate.Day, 23, 59, 59);

            _MonthEndDate = _DualOrderMonthDate = to;
            //List<DualMonthPair> dualMonth = ShoppingCartProvider.GetDualOrderMonthDatesFromService(from, to, _CountryCode);
            if (!isPC())
            {
                var dualMonth = ShoppingCartProvider.GetDualOrderMonthDates(from, to, _CountryCode);
                if (null != dualMonth)
                {
                    foreach (DualMonthPair dmp in dualMonth)
                    {
                        if (_CreateDateTime < dmp.MonthEndDate)
                        {
                            // when MonthEndDate is 2014-12-31 23:59:59.000,  _CreateDateTime is 12/31, _CreateDateTime.Day is 31 and OrderMonth is 11 => exception
                            int year    = Convert.ToInt32(dmp.OrderMonth.Substring(0, 4));
                            int month   = Convert.ToInt32(dmp.OrderMonth.Substring(4, 2));
                            var lastDay = DateTimeUtils.GetLastDayOfMonth(new DateTime(year, month, 1));
                            _DualOrderMonthDate = dmp.MonthEndDate;
                            _MonthEndDate       = new DateTime(year, month, lastDay.Day, 23, 59, 59);

                            //    _MonthEndDate = new DateTime(Convert.ToInt32(dmp.OrderMonth.Substring(0, 4)),
                            //                                 Convert.ToInt32(dmp.OrderMonth.Substring(4, 2)),
                            //                                 _CreateDateTime.Day, 23, 59, 59);
                        }
                        break;
                    }

                    if (HLConfigManager.Configurations.DOConfiguration.ExtendDualOrderMonth > 0)
                    {
                        _DualOrderMonthDate =
                            _DualOrderMonthDate.AddHours(
                                HLConfigManager.Configurations.DOConfiguration.ExtendDualOrderMonth);
                    }
                }
                else
                {
                    LoggerHelper.Error("Failed to get Dual Month info from the Catalog Service");
                }
            }
            _OrderMonthData.CurrentOrderMonth = OrderMonthNumber;

            //Account for any EOM grace period
            //if (_MonthEndGracePeriod.Ticks  > 0)
            //{
            //    _MonthEndDate = to + _MonthEndGracePeriod;
            //    _DualOrderMonthDate += _MonthEndGracePeriod;
            //}
        }
예제 #24
0
        private static List <VolumeModel> GetVolumeViewModel(IEnumerable <DistributorVolume_V01> volumePoints,
                                                             string countryCode, string id)
        {
            if (null == volumePoints)
            {
                LoggerHelper.Error(string.Format("volumePoints is null in the method GetVolumeViewModel  {0}\n{1}",
                                                 id, countryCode));
                return(null);
            }
            try
            {
                var distributorProvider = new Core.DistributorProvider.DistributorProfileLoader();
                var distributorModel    = distributorProvider.Load(new GetDistributorProfileById {
                    Id = id
                });
                var currentMonth = DateUtils.GetCurrentLocalTime(countryCode).Month;
                var volumeModels = volumePoints.Select(distributorVolumeV01 =>
                {
                    var volumeMonth = GetVolumeMonth(distributorVolumeV01.VolumeMonth);
                    return(new VolumeModel
                    {
                        DV = ExtractValue(distributorVolumeV01.DownlineVolume, 0.0M),
                        GV = ExtractValue(distributorVolumeV01.GroupVolume, 0.0M),
                        PPV = ExtractValue(distributorVolumeV01.PersonallyPurchasedVolume, 0.0M),
                        PV = ExtractValue(distributorVolumeV01.Volume, 0.0M),
                        TV = ExtractValue(distributorVolumeV01.TotalVolume, 0.0M),
                        HeaderVolume = GetHeaderVolume(distributorVolumeV01, distributorModel.TypeCode),
                        VolumeMonth = volumeMonth,
                        IsCurrentMonth = currentMonth == volumeMonth,
                        PPVText = _localization.GetGlobalString("HrblUI", "VolumePPVText"),
                        DVText = _localization.GetGlobalString("HrblUI", "VolumeDVText"),
                        TVText = _localization.GetGlobalString("HrblUI", "VolumePVText"),
                        PVText = _localization.GetGlobalString("HrblUI", "VolumePVText"),
                        GVText = _localization.GetGlobalString("HrblUI", "VolumeGVText")
                    });
                }).ToList();


                ILoader <Dictionary <DateTime, DateTime>, string, DateTime> dualMonthLoader = new DualOrderMonthLoader();
                var settings = new DualOrderMonthProvider(new DualOrderMonthLoader());
                var localNow = DateUtils.GetCurrentLocalTime(countryCode);

                var isDualOrderMonth = settings.IsDualOrderMonth(countryCode, localNow);
                return(!isDualOrderMonth
                           ? volumeModels.Where(v => v.VolumeMonth == currentMonth).ToList()
                           : volumeModels);
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(string.Format("Exception occured GetVolumeViewModel method {0}\n{1}",
                                                 id, ex));
                throw;
            }
        }
        /// <summary>
        /// Gets the details of the event for a member qualified
        /// </summary>
        /// <param name="eventId">The event Id</param>
        /// <param name="distributorId">The member Id</param>
        /// <param name="locale">The locale</param>
        /// <returns></returns>
        public static ServiceProvider.EventRestSvc.Event GetEventDetails(int eventId, string distributorId, string locale, bool isPublished = true)
        {
            if (eventId <= 0 || string.IsNullOrEmpty(distributorId) || string.IsNullOrEmpty(locale))
            {
                return(null);
            }

            ServiceProvider.EventRestSvc.Event result = null;
            var memberCacheKey   = string.Format("Member_EventDetails{0}", eventId);
            var eventDetailsList = HttpRuntime.Cache[memberCacheKey] as Dictionary <string, ServiceProvider.EventRestSvc.Event>;

            if (eventDetailsList == null || !eventDetailsList.Any() || !eventDetailsList.ContainsKey(distributorId))
            {
                if (eventDetailsList == null)
                {
                    eventDetailsList = new Dictionary <string, ServiceProvider.EventRestSvc.Event>();
                }
                var proxy = ServiceClientProvider.GetEventDetailServiceProxy();
                try
                {
                    var request = new ServiceProvider.EventRestSvc.GetEventDetailsRequest()
                    {
                        EventId = eventId, LocaleCode = locale, MemberId = distributorId, isPublished = isPublished
                    };
                    var response = proxy.GetEventDetails(request);
                    if (response != null && response.GetEventDetailsResult != null && response.GetEventDetailsResult.errorCode == 0 && response.GetEventDetailsResult.Event != null)
                    {
                        result = response.GetEventDetailsResult.Event;
                        eventDetailsList.Add(distributorId, result);
                    }
                }
                catch (Exception ex)
                {
                    LoggerHelper.Error(
                        string.Format("GetEventDetails error calling service EventId:{0} ERR:{1}",
                                      eventId, ex.ToString()));
                }

                if (eventDetailsList.Any())
                {
                    HttpRuntime.Cache.Insert(memberCacheKey, eventDetailsList, null,
                                             DateTime.Now.AddMinutes(EventCacheMinutes),
                                             Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
                }
            }

            if (eventDetailsList != null && eventDetailsList.ContainsKey(distributorId) && result == null)
            {
                result = eventDetailsList.FirstOrDefault(e => e.Key == distributorId).Value;
            }

            return(result);
        }
예제 #26
0
        internal List <VolumeModel> LoadFromService(string distributorId)
        {
            var proxy = GetProxy();

            try
            {
                var circuitBreaker =
                    CircuitBreakerFactory.GetFactory().GetCircuitBreaker <GetDistributorVolumeResponse_V01>();

                var countryCode      = Thread.CurrentThread.CurrentUICulture.Name.Substring(3);
                var currentLocalTime = DateUtils.GetCurrentLocalTime(countryCode);
                var getVolumeRequest = new GetDistributorVolumeRequest_V01
                {
                    DistributorID = distributorId,
                    StartDate     = DateTimeUtils.GetFirstDayOfMonth(currentLocalTime.AddMonths(-1)),
                    EndDate       = DateTimeUtils.GetLastDayOfMonth(currentLocalTime)
                };
                var response =
                    circuitBreaker.Execute(
                        () => proxy.GetDistributorVolumePoints(new GetDistributorVolumePointsRequest(getVolumeRequest)).GetDistributorVolumePointsResult as GetDistributorVolumeResponse_V01);

                if (response == null)
                {
                    LoggerHelper.Error("Null response was returned for " + distributorId);
                    return(null);
                }

                if (response.Status == ServiceResponseStatusType.Success)
                {
                    return(GetVolumeViewModel(response.VolumePoints, countryCode, distributorId));
                }

                LoggerHelper.Error(
                    string.Format(
                        "VolumeProvider.LoadFromService Error. Unsuccessful result from web service. Status: {0}",
                        response.Status));
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(string.Format("Exception occured Load Volume method {0}\n{1}",
                                                 distributorId, ex));
                throw;
            }
            finally
            {
                if (null != proxy)
                {
                    proxy.Close();
                }
            }
            return(null);
        }
예제 #27
0
        private bool IsElegibleForPromo(ShoppingCart_V02 cart, MyHLShoppingCart hlCart, out decimal volume)
        {
            var isElegible = false;

            volume = 0;

            LoggerHelper.Info(
                string.Format("CheckPromoInCart.ShoppingCart V02 items {0}",
                              string.Concat(cart.CartItems.Select(i => string.Format("{0},", i.SKU)))));
            LoggerHelper.Info(
                string.Format("CheckPromoInCart.MyHLShoppingCart items {0}",
                              string.Concat(hlCart.CartItems.Select(i => string.Format("{0},", i.SKU)))));
            LoggerHelper.Info(
                string.Format("AllowedSKUToAddPromoSKU {0}",
                              string.Concat(AllowedSKUToAddPromoSKU.Select(i => string.Format("{0},", i)))));

            var cartItemsV02 = (from a in AllowedSKUToAddPromoSKU
                                join b in cart.CartItems on a equals b.SKU
                                select
                                new
            {
                Sku = b.SKU,
                Qty = b.Quantity,
                Volume = CatalogProvider.GetCatalogItem(b.SKU, "IT").VolumePoints
            }).ToList();

            if (cartItemsV02.Any())
            {
                isElegible = true;
                volume     = cartItemsV02.Sum(oi => oi.Qty * oi.Volume);
            }
            else
            {
                var shoppingcartItemsV02 = (from a in AllowedSKUToAddPromoSKU
                                            join b in hlCart.ShoppingCartItems on a equals b.SKU
                                            select
                                            new { Sku = b.SKU, Qty = b.Quantity, Volume = b.CatalogItem.VolumePoints })
                                           .ToList();

                if (shoppingcartItemsV02.Any())
                {
                    isElegible = true;
                    volume     = shoppingcartItemsV02.Sum(oi => oi.Qty * oi.Volume);
                }
                else
                {
                    LoggerHelper.Info("No Items in Cart or MyHLCart. Rule fails");
                }
            }

            return(isElegible);
        }
예제 #28
0
        private ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart,
                                                    ShoppingCartRuleReason reason,
                                                    ShoppingCartRuleResult Result)
        {
            if (reason == ShoppingCartRuleReason.CartItemsBeingAdded)
            {
                List <string> codes = new List <string>(CountryType.KZ.HmsCountryCodes);
                codes.Add(CountryType.KZ.Key);
                bool isCOPKZ = codes.Contains(DistributorProfileModel.ProcessingCountryCode);
                if (!isCOPKZ)
                {
                    return(Result);
                }

                if (!HasActiveAppTinCode(cart.DistributorID))
                {
                    try
                    {
                        var cartVolume  = 0m;
                        var currentItem = CatalogProvider.GetCatalogItem(cart.CurrentItems[0].SKU, Country);
                        var myCart      = cart as MyHLShoppingCart;
                        if (myCart != null && !string.IsNullOrEmpty(myCart.VolumeInCart.ToString()))
                        {
                            cartVolume = myCart.VolumeInCart;
                        }
                        var newVolumePoints = currentItem.VolumePoints * cart.CurrentItems[0].Quantity;

                        if (cartVolume + newVolumePoints > MaxVolPoints)
                        {
                            Result.AddMessage(
                                string.Format(
                                    HttpContext.GetGlobalResourceObject(
                                        string.Format("{0}_Rules", HLConfigManager.Platform), "VolumePointExceeds")
                                    .ToString(), cart.CurrentItems[0].SKU));
                            Result.Result = RulesResult.Failure;
                            cart.RuleResults.Add(Result);
                            return(Result);
                        }
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.Error(
                            string.Format(
                                "Error while performing Add to Cart Rule for Belarus distributor: {0}, Cart Id:{1}, \r\n{2}",
                                cart.DistributorID, cart.ShoppingCartID, ex.ToString()));
                    }
                }
            }


            return(Result);
        }
        /// <summary>
        /// Gets the list of qualifiers for an event.
        /// </summary>
        /// <param name="eventId">The event Id.</param>
        /// <returns></returns>
        public static List <ServiceProvider.EventSvc.EventQualifier_V01> GetEventQualifierList(int eventId)
        {
            if (eventId <= 0)
            {
                return(null);
            }

            var memberCacheKey     = string.Format("MemberList_Event{0}", eventId);
            var eventQualifierList = HttpRuntime.Cache[memberCacheKey] as List <ServiceProvider.EventSvc.EventQualifier_V01>;

            if (eventQualifierList == null || !eventQualifierList.Any())
            {
                eventQualifierList = new List <ServiceProvider.EventSvc.EventQualifier_V01>();
                using (var proxy = ServiceClientProvider.GetEventServiceProxy())
                {
                    try
                    {
                        var request    = new ServiceProvider.EventSvc.GetEventQualifierListRequest();
                        var requestV01 = new ServiceProvider.EventSvc.GetEventQualifierRequest_V01
                        {
                            EventID = eventId,
                            //EventIDSpecified = true
                        };
                        request.request = requestV01;
                        var response   = proxy.GetEventQualifierList(request);
                        var response01 = response.GetEventQualifierListResult as ServiceProvider.EventSvc.GetEventQualifierResponse_V01;
                        if (response01 != null && response01.EventQualifiers != null)
                        {
                            eventQualifierList = response01.EventQualifiers.ToList();
                        }
                    }
                    catch (Exception ex)
                    {
                        eventQualifierList = new List <ServiceProvider.EventSvc.EventQualifier_V01>();
                        LoggerHelper.Error(
                            string.Format("GetEventQualifierList error calling service EventId:{0} ERR:{1}",
                                          eventId, ex.ToString()));
                    }
                }

                if (eventQualifierList.Any())
                {
                    HttpRuntime.Cache.Insert(memberCacheKey, eventQualifierList, null,
                                             DateTime.Now.AddMinutes(EventCacheMinutes),
                                             Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
                }
            }

            return(eventQualifierList);
        }
        /// <summary>
        /// get inventory for china store
        /// </summary>
        /// <param name="storeID"></param>
        /// <returns></returns>
        public static Inventory_V01 GetInventory(string storeID)
        {
            string cachekey = string.Format("{0}{1}", INVENTORY_CACHE_PREFIX, storeID);

            CatalogInterfaceClient proxy = null;

            using (proxy = ServiceClientProvider.GetCatalogServiceProxy())
            {
                try
                {
                    var response =
                        proxy.GetInventory(new GetInventoryRequest1(new GetInventoryRequest_V01 {
                        CountryCode = "CN", StoreID = storeID
                    })).GetInventoryResult as
                        GetInventoryResponse_V01;

                    // Check response for error.
                    if (response == null || response.Status != ServiceResponseStatusType.Success ||
                        response.Inventory == null)
                    {
                        throw new ApplicationException(
                                  "CatalogProvider.GetInventory error. GetInventoryResponse indicates error. storeID : " +
                                  storeID);
                    }
                    HttpRuntime.Cache.Insert(cachekey,
                                             response.Inventory,
                                             null,
                                             DateTime.Now.AddMinutes(INVENTORY_CACHE_MINUTES),
                                             Cache.NoSlidingExpiration,
                                             CacheItemPriority.NotRemovable,
                                             null);

                    if (Settings.GetRequiredAppSetting("LogCatalogCN", "false").ToLower() == "true")
                    {
                        LogRequest(string.Format("Store ID: {0}", storeID));
                        LogRequest(string.Format("GetInventory service response: {0}",
                                                 OrderCreationHelper.Serialize(response.Inventory)));
                    }

                    return(response.Inventory);
                }
                catch (Exception ex)
                {
                    LoggerHelper.Error(
                        string.Format("ChinaGetInventory error, storeID: {0} {1}", storeID, ex));
                }
            }
            return(null);
        }