Example #1
0
        public static Order_V02 GetOrderDetail(string orderNumber)
        {
            Order_V02 order = null;
            var       proxy = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                using (new OperationContextScope(proxy.InnerChannel))
                {
                    var req = new GetOrderDetailRequest_V01();
                    req.OrderNumber = orderNumber;
                    req.Locale      = Thread.CurrentThread.CurrentCulture.Name;
                    var response = proxy.GetOrderDetail(new GetOrderDetailRequest1(req)).GetOrderDetailResult as GetOrderDetailResponse_V01;
                    if (response != null)
                    {
                        return(response.Order);
                    }
                }
            }
            catch (Exception ex)
            {
                WebUtilities.LogServiceExceptionWithContext(ex, proxy);
            }
            finally
            {
                ServiceClientFactory.Dispose(proxy);
            }

            return(order);
        }
        /// <summary>
        /// Updates Alert on CustomerExtention table
        /// </summary>
        /// <remarks>Used only for China DO System</remarks>
        /// <param name="distributorId">The distributor identifier.</param>
        public static bool UpdateAlertCustomerExtention(string distributorId)
        {
            var result = false;
            var proxy  = ServiceClientProvider.GetDistributorServiceProxy();

            try
            {
                var request = new UpdateAlertCustomerExtentionRequest_V01
                {
                    DistributorId = distributorId,
                };
                var response = proxy.UpdateAlertCustomerExtention(new UpdateAlertCustomerExtentionRequest1(request)).UpdateAlertCustomerExtentionResult;
                if (response != null && response.Status == ServiceResponseStatusType.Success)
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(
                    new Exception(string.Format("Error in  DistributorProvider.UpdateAlertCustomerExtention, for DS id: {0}; error msg: {1}", distributorId, ex)),
                    ProviderPolicies.SYSTEM_EXCEPTION);
            }
            finally
            {
                ServiceClientFactory.Dispose(proxy);
            }

            return(result);
        }
Example #3
0
        public static List <Order_V02> GetOrders(string distributorId,
                                                 string distributorType,
                                                 DateTime?startDate,
                                                 DateTime?endDate,
                                                 bool isHapOrder,
                                                 string sortOrder)
        {
            GetOrdersResponse_V01 response;
            var proxy = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                //TODO: Remove scope? this is not being used... -Manuel Sauceda
                using (var scope = new OperationContextScope(proxy.InnerChannel))
                {
                    //var mhg = new MessageHeader<string>(authToken);
                    //var untyped = mhg.GetUntypedHeader("AuthToken", "ns");
                    //OperationContext.Current.OutgoingMessageHeaders.Add(untyped);

                    var sDate = (startDate == null) ? DateTime.Now.AddMonths(-3) : startDate.Value;
                    var eDate = (endDate == null) ? DateTime.Now : endDate.Value;

                    response = proxy.GetOrders(new GetOrdersRequest1(new GetOrdersRequest_V01
                    {
                        OrderFilter = new OrdersByDateRange
                        {
                            DistributorId   = distributorId,
                            DistributorType = distributorType,
                            StartDate       = sDate,
                            EndDate         = eDate,
                            IsHAPOrder      = isHapOrder
                        }
                    })).GetOrdersResult as GetOrdersResponse_V01;

                    if (response != null && response.Status == ServiceResponseStatusType.Success)
                    {
                        return(response.Orders);
                    }

                    string debugLine = " DistributorId=" + distributorId + "; DistributorType=" + distributorType +
                                       "; IsHAPOrder=" + isHapOrder;
                    throw new ApplicationException(
                              "OrderProvider.GetOrders() Error. Unsuccessful result from web service. Data: " + debugLine);
                }
            }
            catch (Exception ex)
            {
                WebUtilities.LogServiceExceptionWithContext(ex, proxy);
            }
            finally
            {
                ServiceClientFactory.Dispose(proxy);
            }

            return(null);
        }