Exemplo n.º 1
0
        public static void SetShipmentTrackingInfo(
            String ebayOrderLineItemId,
            Boolean isPaid,
            String trackingNumber,
            ShippingMethods shippingMethod,
            DateTime dateOfShipping)
        {
            try
            {
                CompleteSaleRequestType request = new CompleteSaleRequestType();
                request.OrderLineItemID                  = ebayOrderLineItemId;
                request.Paid                             = isPaid;
                request.Shipped                          = true;
                request.Shipment                         = new ShipmentType();
                request.Shipment.ShippedTime             = dateOfShipping;
                request.Shipment.ShipmentTrackingDetails = new ShipmentTrackingDetailsTypeCollection();
                request.Shipment.ShipmentTrackingDetails.Add(new ShipmentTrackingDetailsType()
                {
                    ShipmentTrackingNumber = trackingNumber,
                    ShippingCarrierUsed    = shippingMethod.ToString()
                });

                CompleteSaleCall call = new CompleteSaleCall(EbayController.GetApiContext());
                call.ExecuteRequest(request);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(String.Format("TrackingNumber can't be set. Ebay says: {0}", ex.Message));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a list of ebay transaction types matching a specified time period
        /// </summary>
        /// <param name="from">Start date and time of the requiered time period</param>
        /// <param name="until">End date and time of the requiered time period</param>
        /// <returns></returns>
        public static List <TransactionType> LoadEbayTransactions(DateTime from, DateTime until)
        {
            List <TransactionType> result = new List <TransactionType>();

            //Get all sales
            GetSellerTransactionsCall transactionCall = new GetSellerTransactionsCall(EbayController.GetApiContext());

            transactionCall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
            transactionCall.IncludeContainingOrder = true;
            transactionCall.Site       = SiteCodeType.Germany;
            transactionCall.Pagination = new PaginationType();
            transactionCall.Pagination.EntriesPerPage = 200;

            Int32 pageNumber = 1;

            do
            {
                transactionCall.Pagination.PageNumber = pageNumber;
                TransactionTypeCollection transactionPage = transactionCall.GetSellerTransactions(from, until);

                result.AddRange(transactionPage.ToArray());

                pageNumber++;
            }while (transactionCall.HasMoreTransactions);

            //Get all orders for the loaded sales
            var           orderIds  = from current in result where current.ContainingOrder != null select current.ContainingOrder.OrderID;
            GetOrdersCall orderCall = new GetOrdersCall(EbayController.GetApiContext());

            orderCall.OrderIDList = new StringCollection(orderIds.ToArray());
            orderCall.Execute();

            //Assign orders to sales
            List <OrderType> orders = new List <OrderType>(orderCall.OrderList.ToArray());

            foreach (TransactionType current in result)
            {
                if (current.ContainingOrder != null)
                {
                    current.ContainingOrder = orders.FirstOrDefault(x => x.OrderID == current.ContainingOrder.OrderID);
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        public static SellingManagerProductTypeCollection LoadEbaySellingManagerProducts()
        {
            GetSellingManagerInventoryCall call = new GetSellingManagerInventoryCall(EbayController.GetApiContext());

            call.Site = SiteCodeType.Germany;
            call.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
            call.Pagination = new PaginationType();
            call.Pagination.EntriesPerPage = 200;

            Int32 pageNumber = 0;
            SellingManagerProductTypeCollection result = new SellingManagerProductTypeCollection();

            do
            {
                call.Pagination.PageNumber = pageNumber++;
                call.Execute();

                result.AddRange(call.SellingManagerProductList);
            }while (result.Count < call.PaginationResult.TotalNumberOfEntries);

            return(result);
        }
Exemplo n.º 4
0
        public static void ReviseSellingManagerTemplates(SellingManagerProductTypeCollection products)
        {
            Console.WriteLine("Start writing EAN...");
            Int32 productIndex = 0;

            foreach (SellingManagerProductType productRunner in products)
            {
                Console.WriteLine(String.Format("Writing {0} of {1} with Id={2}....", productIndex, products.Count, productRunner.SellingManagerProductDetails.CustomLabel));
                var article = Article.LoadByArticleNumber(productRunner.SellingManagerProductDetails.CustomLabel);

                if (article != null && article.SupplierId != 1)
                {
                    foreach (SellingManagerTemplateDetailsType templateRunner in productRunner.SellingManagerTemplateDetailsArray)
                    {
                        try
                        {
                            ReviseSellingManagerTemplateCall call = new ReviseSellingManagerTemplateCall(EbayController.GetApiContext());
                            call.SaleTemplateID                 = Convert.ToInt64(templateRunner.SaleTemplateID);
                            call.Item                           = new ItemType();
                            call.Item.ProductListingDetails     = new ProductListingDetailsType();
                            call.Item.ProductListingDetails.EAN = article.EAN;
                            call.Execute();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Skipped. No article or supplier is 1");
                }
                productIndex++;
            }
            Console.ReadKey();
        }
Exemplo n.º 5
0
        private static SellingManagerProductType GetSellingManagerProductTypeByArticle(String articleNumber)
        {
            SellingManagerProductType result = null;

            try
            {
                GetSellingManagerInventoryCall c2 = new GetSellingManagerInventoryCall(EbayController.GetApiContext());
                c2.Search             = new SellingManagerSearchType();
                c2.Search.SearchType  = SellingManagerSearchTypeCodeType.CustomLabel;
                c2.Search.SearchValue = articleNumber;
                c2.Execute();

                result =
                    c2.SellingManagerProductList.Count > 0 ?
                    c2.SellingManagerProductList[0] :
                    null;
            }
            catch (Exception ex)
            {
                throw new Exception("Can read ebay product by article id " + articleNumber, ex);
            }

            return(result);
        }
Exemplo n.º 6
0
        public static void SetAvailiableQuantity(Article article, Int32 quantity)
        {
            try
            {
                var articleNumber = article.MasterArticle == null ? article.ArticleNumber : article.MasterArticle.ArticleNumber;
                SellingManagerProductType ebayProduct = EbayController.GetSellingManagerProductTypeByArticle(articleNumber);

                if (ebayProduct != null)
                {
                    ReviseSellingManagerProductRequestType request = new ReviseSellingManagerProductRequestType();
                    request.SellingManagerProductDetails = ebayProduct.SellingManagerProductDetails;
                    request.SellingManagerProductDetails.QuantityAvailable = quantity;
                    request.SellingManagerProductSpecifics = new SellingManagerProductSpecificsType();

                    ReviseSellingManagerProductCall call = new ReviseSellingManagerProductCall(EbayController.GetApiContext());
                    call.ExecuteRequest(request);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Can set ebay quantity availiable for " + article.ArticleNumber, ex);
            }
        }