Esempio n. 1
0
        private void EndActiveAuctions(IEnumerable <Article> articles)
        {
            try
            {
                GetSellerListRequestType request = new GetSellerListRequestType();

                request.Version = "0.1";

                request.GranularityLevelSpecified = true;
                request.GranularityLevel          = GranularityLevelCodeType.Coarse;

                // Setting the date-range filter. This call required either EndTimeFrom & EndTimeTo pair OR StartTimeFrom & StartTimeTo pair
                // as a required input parameter.
                request.EndTimeFromSpecified = true;
                request.EndTimeFrom          = DateTime.Now.ToUniversalTime();

                request.EndTimeToSpecified = true;
                request.EndTimeTo          = DateTime.Now.AddDays(14).ToUniversalTime();

                // Setting the Pagination which is a required input parameter for GetSellerList call
                PaginationType pagination = new PaginationType();
                pagination.EntriesPerPageSpecified = true;
                pagination.EntriesPerPage          = 200;
                pagination.PageNumberSpecified     = true;
                pagination.PageNumber = 1;

                request.Pagination = pagination;

                GetSellerListResponseType response    = new GetSellerListResponseType();
                GetSellerListCall         listApiCall = new GetSellerListCall(apiContext);
                response = (GetSellerListResponseType)listApiCall.ExecuteRequest(request);

                if (response.Ack == AckCodeType.Success)
                {
                    EndItemsCall endApiCall = new EndItemsCall(apiContext);
                    EndItemRequestContainerTypeCollection endItems = new EndItemRequestContainerTypeCollection();

                    foreach (ItemType item in response.ItemArray)
                    {
                        EndItemRequestContainerType endItem = new EndItemRequestContainerType();
                        endItem.EndingReason          = EndReasonCodeType.NotAvailable;
                        endItem.EndingReasonSpecified = true;
                        endItem.MessageID             = item.ItemID;
                        endItem.ItemID = item.ItemID;
                        endItems.Add(endItem);
                    }

                    if (endItems.Count > 0)
                    {
                        EndItemResponseContainerTypeCollection endResponse = endApiCall.EndItems(endItems);

                        String errMsg = String.Empty;
                        foreach (EndItemResponseContainerType item in endResponse)
                        {
                            errMsg += EvaluateErrorMessages(item.Errors);
                        }

                        if (errMsg != String.Empty)
                        {
                            Assert.Fail(errMsg);
                        }
                    }
                }
                else
                {
                    String errMsg = EvaluateErrorMessages(response.Errors);
                    if (errMsg != String.Empty)
                    {
                        Assert.Fail(errMsg);
                    }
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Check whether the recently added items exists and if they has the right, changed quantity
        /// </summary>
        /// <returns>ItemType object</returns>
        #region CheckRevicedItems
        private bool CheckRevicedItems()
        {
            Boolean ret    = false;
            String  errMsg = String.Empty;

            try
            {
                GetSellerListRequestType request = new GetSellerListRequestType();

                // Setting the date-range filter. This call required either EndTimeFrom & EndTimeTo pair OR StartTimeFrom & StartTimeTo pair
                // as a required input parameter.
                request.EndTimeFromSpecified = true;
                request.EndTimeFrom          = DateTime.Now.ToUniversalTime();
                request.EndTimeToSpecified   = true;
                request.EndTimeTo            = DateTime.Now.AddDays(14).ToUniversalTime();
                request.DetailLevel          = new DetailLevelCodeTypeCollection()
                {
                    DetailLevelCodeType.ReturnAll
                };

                // Setting the Pagination which is a required input parameter for GetSellerList call
                PaginationType pagination = new PaginationType();
                pagination.EntriesPerPageSpecified = true;
                pagination.EntriesPerPage          = 5;
                pagination.PageNumberSpecified     = true;
                pagination.PageNumber = 1;
                request.Pagination    = pagination;

                //Set SKUs we're looking for
                StringCollection skus = new StringCollection();
                foreach (Article article in articles)
                {
                    skus.Add(article.ArticleNumber);
                }
                request.SKUArray = skus;

                GetSellerListResponseType response    = new GetSellerListResponseType();
                GetSellerListCall         listApiCall = new GetSellerListCall(apiContext);
                response = (GetSellerListResponseType)listApiCall.ExecuteRequest(request);

                if (response.Ack == AckCodeType.Success)
                {
                    foreach (ItemType item in response.ItemArray)
                    {
                        if (item.Quantity != 88)
                        {
                            errMsg += "Wrong quantity of item no. " + item.ItemID;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            if (errMsg == String.Empty)
            {
                ret = true;
            }
            else
            {
                Assert.Fail("CheckRevicedItems failed: " + errMsg);
            }

            return(ret);
        }