コード例 #1
0
 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);
 }
コード例 #2
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);
            }
        }
コード例 #3
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>());
        }
コード例 #4
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));
        }
コード例 #5
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);
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
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);
        }
コード例 #8
0
        /// <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);
        }
コード例 #9
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);
        }
コード例 #10
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);
            }
        }
コード例 #11
0
        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);
            }
        }
コード例 #12
0
        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);
        }
コード例 #13
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);
            }
        }
コード例 #14
0
        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));
        }
コード例 #15
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;
            //}
        }
コード例 #16
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);
        }
コード例 #18
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);
        }
コード例 #19
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);
        }
コード例 #21
0
        /// <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);
        }
コード例 #22
0
        private ShoppingCartRuleResult CartItemAddedRuleHandler(ShoppingCart_V01 cart, ShoppingCartRuleResult result, string level)
        {
            var distributorId      = cart.DistributorID;
            var isAPFDueandNotPaid = APFDueProvider.IsAPFDueAndNotPaid(distributorId, Locale);

            if (isAPFDueandNotPaid && HLConfigManager.Configurations.DOConfiguration.IsChina)
            {
                string cacheKey   = string.Empty;
                bool   reloadAPFs = (null != cart && null != cart.CartItems) && isAPFDueandNotPaid &&
                                    !APFDueProvider.IsAPFSkuPresent(cart.CartItems);
                cart.APFEdited = false;
                DoApfDue(cart.DistributorID, cart, cacheKey, Locale, reloadAPFs, result, true);
            }

            try
            {
                var hlCart = cart as MyHLShoppingCart;
                if (null != hlCart)
                {
                    var isPlacing = !String.IsNullOrWhiteSpace(hlCart.SrPlacingForPcOriginalMemberId);
                    if (isPlacing)
                    {
                        var skuList = APFDueProvider.GetAPFSkuList();
                        if (skuList != null && skuList.Count > 0)
                        {
                            var items =
                                (from s in skuList
                                 from c in cart.CartItems
                                 where s == c.SKU
                                 select c.SKU).ToList();

                            if (null != items && items.Count > 0)
                            {
                                hlCart.DeleteItemsFromCart(items, true);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(
                    string.Format("APFRules.CartItemAddedRuleHandler DS:{0} locale:{2} ERR:{1}", cart.DistributorID,
                                  ex, Locale));
            }

            return(result);
        }
コード例 #23
0
 public virtual ServiceProvider.OrderSvc.OrderTotals_V01 CallDistributorPricing(ServiceProvider.OrderSvc.Order_V01 order, bool useHmsCalc)
 {
     try
     {
         string errorCode;
         return(ShoppingCartProvider.GetQuote(order, QuotePartType.Freight, useHmsCalc, out errorCode));
     }
     catch (Exception ex)
     {
         LoggerHelper.Error(
             string.Format(
                 "OrderService - InvoiceProvider: An error occured while Calling CallDistributorPricing service method {0}",
                 ex.Message));
     }
     return(null);
 }
コード例 #24
0
        public Dictionary <DateTime, DateTime> Load(string countryCode, DateTime localNow)
        {
            if (string.IsNullOrWhiteSpace(countryCode))
            {
                throw new ArgumentException("CountryCode is blank", "countryCode");
            }
            var fromDate = DateTimeUtils.GetFirstDayOfMonth(localNow);
            var toDate   = DateTimeUtils.GetLastDayOfMonth(localNow);

            var proxy = ServiceClientProvider.GetCatalogServiceProxy();

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

                var response =
                    circuitBreaker.Execute(() => proxy.GetDualMonthDates(new GetDualMonthDatesRequest1(new GetDualMonthDatesRequest_V01
                {
                    CountryCode = countryCode,
                    FromDate    = fromDate,
                    ToDate      = toDate
                })).GetDualMonthDatesResult as GetDualMonthDatesResponse_V01);
                if (response != null && response.Status == ServiceResponseStatusType.Success)
                {
                    return(GetDualMonthDictionary(response.DualMonth, localNow));
                }
            }
            catch
            {
                LoggerHelper.Error("Errored out in GetDualOrderMonth" + countryCode);
                if (null != proxy)
                {
                    proxy.Close();
                }
                throw;
            }
            finally
            {
                if (null != proxy)
                {
                    proxy.Close();
                }
            }
            LoggerHelper.Error("Errored out in GetDualOrderMonth Catalog service" + countryCode);
            return(null);
        }
コード例 #25
0
        /// <summary>
        /// The update customer order tags.
        /// </summary>
        /// <param name="customerOrderID">
        /// The customer order id.
        /// </param>
        /// <param name="orderTag">
        /// The order tag.
        /// </param>
        /// <returns>
        /// The update customer order tags.
        /// </returns>
        public static bool UpdateCustomerOrderTags(string customerOrderID, CustomerOrderStatusTag orderTag)
        {
            if (string.IsNullOrEmpty(customerOrderID))
            {
                return(false);
            }

            using (var proxy = ServiceClientProvider.GetCustomerOrderServiceProxy())
            {
                try
                {
                    var request = new SavePartialCustomerOrderRequest
                    {
                        OrderId = customerOrderID,
                        Updates =
                            new[]
                        {
                            new CustomerOrderPropertyValue
                            {
                                Property = CustomerOrderProperty.CustomerOrderStatusTag,
                                Value    =
                                    (int)
                                    Enum.Parse(
                                        typeof(CustomerOrderStatusTag),
                                        Enum.GetName(typeof(CustomerOrderStatusTag), orderTag))
                            }
                        }.ToList()
                    };

                    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("UpdateCustomerOrderTags OrderID:{0} ERR:{1}", customerOrderID, ex));
                    return(false);
                }
            }

            return(false);
        }
コード例 #26
0
        public static void SavePurchaseLimitsToStore(string country, string distributorId)
        {
            //2.CurrentOrderMonth
            if (HLConfigManager.Configurations.DOConfiguration.IsChina)
            {
                return;
            }
            var limits = getPurchasingLimitsFromCache(distributorId);

            if (null != limits && limits.Count > 0)
            {
                //var orderMonth = new OrderMonth(country);
                // orderMonth.ResolveOrderMonth();
                foreach (var limit in limits)
                {
                    var request = new SetPurchasingLimitsRequest_V01();
                    request.Country       = country;
                    request.DistributorId = distributorId;
                    request.OrderMonth    = limit.Key.ToString();

                    var purchasingLimit = limit.Value;
                    request.PurchasingLimits = purchasingLimit;

                    OrderServiceClient proxy = null;
                    try
                    {
                        proxy = ServiceClientProvider.GetOrderServiceProxy();
                        var response =
                            proxy.SetPurchasingLimits(new SetPurchasingLimitsRequest1(request)).SetPurchasingLimitsResult as SetPurchasingLimitsResponse_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));
                        }
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.Error(
                            string.Format("Save PurchasingLimits failed for Distributor {0}, country Code: {1} {2}",
                                          distributorId, country, ex));
                    }
                }
            }
        }
コード例 #27
0
        /// <summary>
        /// The save discount.
        /// </summary>
        /// <param name="coupon">
        /// The coupon.
        /// </param>
        /// <param name="distributorId">
        /// The distributor id.
        /// </param>
        /// <returns>
        /// The save discount.
        /// </returns>
        /// <exception cref="ArgumentException">
        /// </exception>
        public static bool SaveDiscount(CustomerDiscountDefinition coupon, string distributorId)
        {
            if (coupon == null)
            {
                return(false);
            }

            using (var proxy = ServiceClientProvider.GetCustomerOrderServiceProxy())
            {
                try
                {
                    var request = new SaveCustomerDiscountRequest_V01
                    {
                        Discount      = coupon,
                        DistributorID = distributorId
                    };
                    var response = proxy.SaveCustomerDiscount(new SaveCustomerDiscountRequest1(request));
                    if (response.SaveCustomerDiscountResult.Status == ServiceResponseStatusType.Success)
                    {
                        return(true);
                    }

                    if (response.SaveCustomerDiscountResult.Status.ToString() == "Failure, ClientFault")
                    {
                        foreach (var parameterError in response.SaveCustomerDiscountResult.ParameterErrorList)
                        {
                            if (parameterError.Name.Equals("Discount Code"))
                            {
                                throw new ArgumentException("Duplicate coupon code");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (ex.GetType().Equals(typeof(ArgumentException)))
                    {
                        throw;
                    }
                    LoggerHelper.Error(string.Format("SaveDiscount DS ID:{0} ERR:{1}", distributorId, ex));
                    return(false);
                }
            }

            return(false);
        }
コード例 #28
0
        private static string SerializeObject(Object pObject, Type objectType)
        {
            try
            {
                var ser    = new XmlSerializer(objectType);
                var sb     = new StringBuilder();
                var writer = new System.IO.StringWriter(sb);
                ser.Serialize(writer, pObject);

                return(sb.ToString());
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(string.Format("ThreeDPaymentProvider serializeObject error:  {0}", ex.Message));
                return(string.Empty);
            }
        }
コード例 #29
0
 private void ClearShoppingCartModuleCache()
 {
     try
     {
         if (SessionInfo != null)
         {
             SessionInfo.IsFirstTimeSpainPopup = false;
         }
         var cartWidgetSource = new CartWidgetSource();
         cartWidgetSource.ExpireShoppingCartCache(DistributorID, Locale);
     }
     catch (Exception ex)
     {
         LoggerHelper.Error(
             string.Format("Error occurred ClearMyHL3ShoppingCartCache. Id is {0}-{1}.\r\n{2}", DistributorID, Locale,
                           ex.Message));
     }
 }
コード例 #30
0
 public void ReloadPurchasingLimits(string distributorID)
 {
     try
     {
         if (PurchasingLimitProvider.IsRestrictedByMarketingPlan(distributorID))
         {
             CreatePurchasingLimits(GetDistributorPurchasingLimitsCollection());
         }
         if (PurchasingLimits != null)
         {
             SaveToCache();
         }
     }
     catch (Exception ex)
     {
         LoggerHelper.Error(ex.ToString());
     }
 }