Beispiel #1
0
        public static List <Order> GetOrders(string userName, string password, DateTime fromDate)
        {
            var apiKey    = EkmConnector.GetApiKey(userName, password);
            var myBinding = new BasicHttpBinding()
            {
                Name = PartnerEndpointName
            };
            var shopClient = new PartnerAPISoapClient(myBinding, new EndpointAddress(apiKey.EndPoint));

            var getOrdersRequest = new GetOrdersRequest();

            // Your unique APIKey must be passed with each request
            getOrdersRequest.APIKey     = apiKey.Key;
            getOrdersRequest.PartnerKey = PartnerKey;
            getOrdersRequest.ToDate     = GetToday();
            getOrdersRequest.FromDate   = Get00Format(fromDate);
            var Orders = new List <Order>();

            getOrdersRequest.ItemsPerPage = 100;
            int          iPage = 0;
            OrdersObject getOrdersResponse;

            do
            {
                iPage++;
                getOrdersRequest.PageNumber = iPage;
                getOrdersResponse           = shopClient.GetOrders(getOrdersRequest);
                if (getOrdersResponse.Orders != null)
                {
                    Orders.AddRange(getOrdersResponse.Orders);
                }
            } while (getOrdersResponse.Status != StatusCodes.Failure);

            return(Orders);
        }
Beispiel #2
0
        }         // RetrieveCustomerSecurityInfo

        protected override ElapsedTimeInfo RetrieveAndAggregate(
            IDatabaseCustomerMarketPlace databaseCustomerMarketPlace,
            MP_CustomerMarketplaceUpdatingHistory historyRecord
            )
        {
            // Retrieve data from EKM API
            var ordersList = EkmConnector.GetOrders(
                databaseCustomerMarketPlace.DisplayName,
                Encrypted.Decrypt(databaseCustomerMarketPlace.SecurityData),
                Helper.GetEkmDeltaPeriod(databaseCustomerMarketPlace)
                );

            var ekmOrderList = new List <EkmOrderItem>();

            foreach (var order in ordersList)
            {
                try {
                    ekmOrderList.Add(order.ToEkmOrderItem());
                } catch (Exception e) {
                    log.Error(e, "Failed to create EKMOrderItem from the original order {0}", order);
                    throw;
                }
            }             // for

            var elapsedTimeInfo = new ElapsedTimeInfo();

            var newOrders = new EkmOrdersList(DateTime.UtcNow, ekmOrderList);

            ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(
                elapsedTimeInfo,
                databaseCustomerMarketPlace.Id,
                ElapsedDataMemberType.StoreDataToDatabase,
                () => Helper.StoreEkmOrdersData(databaseCustomerMarketPlace, newOrders, historyRecord)
                );

            return(elapsedTimeInfo);
        }         // RetrieveAndAggregate