Пример #1
0
 public static bool UpdateAPFDuePaid(string distributorID, DateTime apfDue)
 {
     if (string.IsNullOrEmpty(distributorID))
     {
         return(false);
     }
     else
     {
         try
         {
             var proxy    = ServiceClientProvider.GetCatalogServiceProxy();
             var response =
                 proxy.UpdateAPFDue(new UpdateAPFDueRequest(new UpdateAPFPaidRequest_V01 {
                 DistributorID = distributorID, DueDate = apfDue
             })).UpdateAPFDueResult as
                 UpdateAPFPaidResponse_V01;
             if (response != null && response.Status == ServiceResponseStatusType.Success)
             {
                 clearAPFDuePaidFromCache(getCacheKey(distributorID));
                 return(true);
             }
         }
         catch (Exception ex)
         {
             ExceptionPolicy.HandleException(ex, ProviderPolicies.SYSTEM_EXCEPTION);
         }
     }
     return(false);
 }
        private static void SaveMobileQuoteResponse(QuoteResponseViewModel model, int shoppingCartId)
        {
            CatalogInterfaceClient proxy = null;

            using (proxy = ServiceClientProvider.GetCatalogServiceProxy())
            {
                try
                {
                    var request = new InsertMobileOrderDetailRequest_V01();

                    MobileOrderDetail mobileOrderDetail =
                        MobileOrderProvider.ModelConverter.ConvertOrderViewModelToMobileOrderDetail(model.Order,
                                                                                                    shoppingCartId);
                    mobileOrderDetail.AddressId = model.Order.Shipping != null && model.Order.Shipping.Address != null
                        ? model.Order.Shipping.Address.CloudId
                        : Guid.Empty;
                    mobileOrderDetail.CustomerId  = model.Order.CustomerId;
                    mobileOrderDetail.OrderStatus = "Quoted";

                    request.MobileOrderDetail = mobileOrderDetail;
                    InsertMobileOrderDetailResponse response = proxy.InsertMobileOrderDetail(new InsertMobileOrderDetailRequest1(request)).InsertMobileOrderDetailResult;
                    // Check response for error.
                    if (response == null || response.Status != ServiceResponseStatusType.Success)
                    {
                        LoggerHelper.Error(string.Format("SaveMobileQuoteResponse error Order: {0} Message: {1}",
                                                         model.Order.OrderNumber, response));
                    }
                }
                catch (Exception ex)
                {
                    LoggerHelper.Error(string.Format("SaveMobileQuoteResponse Exception Order: {0} Message: {1}",
                                                     model.Order.OrderNumber, ex));
                }
            }
        }
        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);
        }
Пример #4
0
 private static bool loadAPFDuePaidFromService(string distributorID, DateTime dueDate)
 {
     if (string.IsNullOrEmpty(distributorID))
     {
         return(false);
     }
     else
     {
         try
         {
             var proxy    = ServiceClientProvider.GetCatalogServiceProxy();
             var response =
                 proxy.GetAPFDue(new GetAPFDueRequest(new GetAPFPaidRequest_V01 {
                 DistributorID = distributorID, DueDate = dueDate
             })).GetAPFDueResult as GetAPFPaidResponse_V01;
             if (response != null)
             {
                 return(response.ReturnCode);
             }
         }
         catch (Exception ex)
         {
             ExceptionPolicy.HandleException(ex, ProviderPolicies.SYSTEM_EXCEPTION);
         }
     }
     return(false);
 }
Пример #5
0
        private static Catalog_V01 LoadCatalogFromService(string isoCountryCode)
        {
            if (string.IsNullOrEmpty(isoCountryCode))
            {
                return(null);
            }

            Catalog_V01 catalog = null;

            using (var proxy = ServiceClientProvider.GetCatalogServiceProxy())
            {
                try
                {
                    var response = proxy.GetCatalog(new GetCatalogRequest1(new GetCatalogRequest_V01(isoCountryCode))).GetCatalogResult as GetCatalogResponse_V01;

                    if (response == null || response.Status != ServiceResponseStatusType.Success || response.Catalog == null)
                    {
                        throw new ApplicationException(
                                  "CatalogProvider.LoadCatalogFromService error. GetCatalogResponse indicates error.");
                    }
                    catalog = response.Catalog;
                }
                catch (Exception ex)
                {
                    LoggerHelper.Error(string.Format("LoadCatalogFromService error, country Code: {0} {1}",
                                                     isoCountryCode, ex));
                }
            }
            return(catalog);
        }
Пример #6
0
        private static ProductInfoCatalog_V01 LoadProductInfoFromService(string locale)
        {
            if (string.IsNullOrEmpty(locale))
            {
                return(null);
            }

            ProductInfoCatalog_V01 productInfo = null;

            using (var proxy = ServiceClientProvider.GetCatalogServiceProxy())
            {
                try
                {
                    var request  = new GetProductInfoRequest_V01(Settings.GetRequiredAppSetting("DWSCatalogPlatformKey", "dws_default"), locale);
                    var response = proxy.GetProductInfo(new GetProductInfoRequest1(request)).GetProductInfoResult as GetProductInfoResponse_V01;

                    if (response == null || response.Status != ServiceResponseStatusType.Success ||
                        response.ProductCatalog == null)
                    {
                        throw new ApplicationException(
                                  "CatalogProvider.LoadProductInfoFromService error. GetProductInfoResponse indicates error. Locale : " +
                                  locale);
                    }

                    productInfo = response.ProductCatalog;
                }
                catch (Exception ex)
                {
                    LoggerHelper.Error(string.Format("LoadProductInfoFromService error, locale: {0} {1}", locale, ex));
                }
            }

            return(productInfo);
        }
        private static Dictionary <string, string> loadWebClientAuthCodeFromService()
        {
            var proxy    = ServiceClientProvider.GetCatalogServiceProxy();
            var response = proxy.GetWebClientAuthKey(new GetWebClientAuthKeyRequest(new GetWebAuthKeyRequest_V01())).GetWebClientAuthKeyResult as GetWebAuthKeyResponse_V01;

            if (response != null && response.Status == ServiceResponseStatusType.Success)
            {
                return(response.WebAuthKey);
            }
            return(null);
        }
        /// <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);
        }
        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);
        }
Пример #10
0
 public static void UpdateAPFDue(string distributorID, DateTime due, ShoppingCartItemList cartItems)
 {
     if (IsAPFSkuPresent(cartItems))
     {
         using (var proxy = ServiceClientProvider.GetCatalogServiceProxy())
         {
             var response =
                 proxy.UpdateAPFDue(new UpdateAPFDueRequest(new UpdateAPFPaidRequest_V01 {
                 DistributorID = distributorID, DueDate = due
             })).UpdateAPFDueResult as
                 UpdateAPFPaidResponse_V01;
             if (response.Status == ServiceResponseStatusType.Success)
             {
                 saveAPFDuePaidToCache(getCacheKey(distributorID), true);
             }
         }
     }
 }
Пример #11
0
        public List <TopSellerProductModel> GetTopSellerProductsFromSource(string id, string countryCode, string locale)
        {
            var proxy = ServiceClientProvider.GetCatalogServiceProxy();

            try
            {
                var circuitBreaker =
                    CircuitBreakerFactory.GetFactory().GetCircuitBreaker <GetTopSellersResponse_V01>();
                var response =
                    circuitBreaker.Execute(() => proxy.GetTopSellers(new GetTopSellersRequest1(new GetTopSellersRequest_V01
                {
                    CountryCode   = countryCode,
                    Locale        = locale,
                    DistributorId = id
                })).GetTopSellersResult as GetTopSellersResponse_V01);

                if (response != null && response.Status == MyHerbalife3.Ordering.ServiceProvider.CatalogSvc.ServiceResponseStatusType.Success)
                {
                    return(GetTopSellerProductModel(response.Skus, id, locale));
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.Exception("Error", ex,
                                       "Errored out in TopSellerSource" + id + countryCode);
                if (null != proxy)
                {
                    proxy.Close();
                }
                throw;
            }
            finally
            {
                if (null != proxy)
                {
                    proxy.Close();
                }
            }

            return(null);
        }
        public static GetSlowMovingSkuList GetSlowmovingskuDetail()
        {
            string cachekey = string.Format("{0}{1}", SLOWMOVING_CACHE_PREFIX, "CN");

            CatalogInterfaceClient proxy = null;

            using (proxy = ServiceClientProvider.GetCatalogServiceProxy())
            {
                try
                {
                    var response =
                        proxy.GetSlowMovingSkuInfo(new GetSlowMovingSkuInfoRequest(new GetSlowMovingSkuRequest_V01 {
                        CountryCode = "CN"
                    })).GetSlowMovingSkuInfoResult as
                        GetSlowMovingSkuResponse_V01;

                    // Check response for error.
                    if (response == null || response.Status != ServiceResponseStatusType.Success)
                    {
                        throw new ApplicationException(
                                  "ChinaCatalogProvider.GetSlowMoving error. GetSlowMovingSkuResponse indicates error. ");
                    }
                    //HttpRuntime.Cache.Insert(cachekey,
                    //                         response.GetSlowMovingSkuList,
                    //                         null,
                    //                         DateTime.Now.AddMinutes(INVENTORY_CACHE_MINUTES),
                    //                         Cache.NoSlidingExpiration,
                    //                         CacheItemPriority.NotRemovable,
                    //                         null);


                    return(response.GetSlowMovingSkuList);
                }
                catch (Exception ex)
                {
                    LoggerHelper.Error(
                        string.Format("ChinaCatalogProvider Slowmoving error,{0}", ex));
                }
            }
            return(null);
        }
        private static AnnouncementInfoList GetAnnouncementInfoFromService()
        {
            var proxy = ServiceClientProvider.GetCatalogServiceProxy();

            try
            {
                var response =
                    proxy.GetAnnouncementInfo(new GetAnnouncementInfoRequest(new AnnouncementInfoRequest_V01())).GetAnnouncementInfoResult as AnnouncementInfoResponse_V01;

                // Check response for error.
                if (response == null || response.Status != ServiceResponseStatusType.Success)
                {
                    throw new ApplicationException("CatalogProvider.GetAnnouncementInfo error.");
                }
                return(response.Announcements);
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(
                    string.Format("China GetAnnouncementInfo error: {0} ", ex));
            }
            return(null);
        }