示例#1
0
        public void RelistItem()
        {
            Assert.IsNotNull(TestData.EndedItem);
            //
            RelistItemCall rviCall = new RelistItemCall(this.apiContext);
            ItemType item = new ItemType();
            item.ItemID = TestData.EndedItem.ItemID;
            item.StartPrice = new AmountType();
            item.StartPrice.Value = 1.98;
            item.StartPrice.currencyID = CurrencyCodeType.USD;
            //StringCollection modList = new StringCollection();
            //modList.Add("item.startPrice");
            //ModifiedFieldType[] mfList = eBayUtil.CopyModifiedList(modList, null);
            //rviCall.ModifiedFields = mfList;

            //verify first
            VerifyRelistItemCall vriCall = new VerifyRelistItemCall(this.apiContext);
            vriCall.Item = item;
            vriCall.Execute();
            FeeTypeCollection fees = vriCall.FeeList;
            Assert.IsNotNull(fees);

            GetItemCall getItem1 = new GetItemCall(this.apiContext);
            DetailLevelCodeType[] detailLevels1 = new DetailLevelCodeType[] {
            DetailLevelCodeType.ReturnAll
            };
            getItem1.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels1);
            ItemType returnedItem1 = getItem1.GetItem(item.ItemID);
            // Make sure it's relisted.
            /*
            Assert.AreEqual(returnedItem.ListingDetails.getRelistedItemID().Value,
            TestData.EndedItem);
            */
            Assert.AreNotEqual(returnedItem1.StartPrice.Value, item.StartPrice.Value);

            rviCall.Item = item;
            rviCall.RelistItem(item);

            // Let's wait for the server to "digest" the data.
            System.Threading.Thread.Sleep(1000);
            // Call GetItem and then compare the startPrice.
            GetItemCall getItem2 = new GetItemCall(this.apiContext);
            DetailLevelCodeType[] detailLevels2 = new DetailLevelCodeType[] {
            DetailLevelCodeType.ReturnAll
            };
            getItem2.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels2);
            ItemType returnedItem2 = getItem2.GetItem(item.ItemID);
            // Make sure it's relisted.
            /*
            Assert.AreEqual(returnedItem.ListingDetails.getRelistedItemID().Value,
            TestData.EndedItem);
            */
            Assert.AreEqual(returnedItem2.StartPrice.Value, item.StartPrice.Value);
            // End the new created item.
            EndItemCall api = new EndItemCall(this.apiContext);
            // Set the item to be ended.
            api.ItemID = item.ItemID;
            api.EndingReason = EndReasonCodeType.NotAvailable;
            api.Execute();
        }
		public void RelistItemFull()
		{

			Assert.IsNotNull(TestData.EndedItem2);
			
			TestData.EndedItem2.ApplicationData="this is new appilcation data which is specified by "+DateTime.Now.ToShortDateString();
			RelistItemCall rviCall = new RelistItemCall(this.apiContext);
			ItemType item = TestData.EndedItem2;
			item.CategoryMappingAllowed=true;
			item.CategoryMappingAllowed=true;

			rviCall.Item=item;
			StringCollection fields =new StringCollection();
			String field="Item.ApplicationData";
			fields.Add(field);
			rviCall.DeletedFieldList=fields;
			rviCall.Execute();

			//check whether the call is success.
			Assert.IsTrue(rviCall.AbstractResponse.Ack==AckCodeType.Success || rviCall.AbstractResponse.Ack==AckCodeType.Warning,"do not success!");
			Assert.IsNotNull(rviCall.FeeList,"the Fees is null");
			/*
			foreach(FeeType fee in rviCall.FeeList)
			{
				isTherePropertyNull=ReflectHelper.IsProperteValueNotNull(fee,out nullPropertyNums,out nullPropertyNames);
				Assert.IsTrue(isTherePropertyNull,"there are" +nullPropertyNums.ToString()+ " properties value is null. (" +nullPropertyNames+ ")");
			}*/
			Assert.IsNotNull(rviCall.ItemID,"the ItemID is null");
			Assert.IsNotNull(rviCall.StartTime ,"the StartTime is null");

			//Assert.IsTrue(false,"NewItem:"+TestData.NewItem.ItemID+";EndedItem:"+TestData.EndedItem.ItemID+";NewItem2:"+TestData.NewItem2.ItemID+";EndedItem2:"+TestData.EndedItem2.ItemID);

		}
示例#3
0
        public void relistItems()
        {
            MySQLWrapper s = null;

            try
            {
                changeStatus("Initializing...");
                addLogStatus("Initializing...");
                if (!initialize())
                    throw new Exception("ERROR : Unable to connect to eBay Service");
                s = new MySQLWrapper();
                GetMyeBaySellingCall eBaySelling = new GetMyeBaySellingCall(context);
                PaginatedItemArrayType pArr = new PaginatedItemArrayType();
                eBaySelling.UnsoldList = new ItemListCustomizationType();
                eBaySelling.UnsoldList.Include = true;
                eBaySelling.GetMyeBaySelling();
                ItemTypeCollection unsoldItems = new ItemTypeCollection();
                pArr = eBaySelling.UnsoldListReturn;
                if (pArr != null)
                {
                    string sku = "";
                    unsoldItems = pArr.ItemArray;
                    RelistItemCall relistItem = new RelistItemCall(context);
                    StringCollection deleteFieldList = new StringCollection();
                    ItemType tItem = new ItemType();
                    changeStatus("ReListing...");
                    addLogStatus("Total Unsold items : " + unsoldItems.Count);
                    for (int i = 0; i < unsoldItems.Count; i++)
                    {
                        tItem.ItemID = unsoldItems[i].ItemID;
                        sku = s.getSKU(unsoldItems[i].ItemID);
                        if(sku != ""){
                            relistItem.RelistItem(tItem);
                            s.updateReListedItem(sku, relistItem.ItemID);
                            s.addToLogs(sku, "Re-Listed with Item Id : " + relistItem.ItemID);
                            addLogStatus("Item : " + unsoldItems[i].ItemID + " relisted with Item ID : " + relistItem.ItemID);
                        }
                        else{
                            throw new Exception("ItemId : " + unsoldItems[i].ItemID + " not found in database!");
                        }
                    }
                    addLogStatus("Done!");
                }
                else {
                    addLogStatus("No Unsold Items!");
                }
            }
            catch (Exception ex)
            {
                addLogStatus("ERROR : " + ex.Message);
            }
            finally {
                s.destroy();
                destroy();
            }
        }
		private void BtnRelistItem_Click(object sender, System.EventArgs e)
		{
			try
			{
				TxtItemId.Text = "";
				TxtListingFee.Text = "";
				BtnGetItem.Visible = false;
				
				// Populate the Item
				ItemType item = new ItemType();
			
			
				item.ItemID = TxtRelistItemId.Text;
		

				if (TxtTitle.Text.Length > 0)
				{
					item.Title = this.TxtTitle.Text;
				}
			
				if (TxtDescription.Text.Length > 0)
				{
					item.Description =  this.TxtDescription.Text;
				}

				if (CboDuration.SelectedIndex != -1)
				{
					item.ListingDuration = CboDuration.SelectedItem.ToString();
				}

				CurrencyCodeType currencyCode = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);

				if (TxtStartPrice.Text.Length > 0)
				{
					item.StartPrice = new AmountType();
					item.StartPrice.currencyID = currencyCode;
					item.StartPrice.Value = Double.Parse(this.TxtStartPrice.Text, NumberStyles.Currency);
				}
				if (TxtReservePrice.Text.Length > 0)
				{
					item.ReservePrice = new AmountType();
					item.ReservePrice.currencyID = currencyCode;
					item.ReservePrice.Value = Double.Parse(this.TxtReservePrice.Text, NumberStyles.Currency);
				}
				if (TxtBuyItNowPrice.Text.Length > 0)
				{
					item.BuyItNowPrice = new AmountType();
					item.BuyItNowPrice.currencyID = currencyCode;
					item.BuyItNowPrice.Value = Double.Parse(this.TxtBuyItNowPrice.Text, NumberStyles.Currency);
				}

				if (CboEnableBestOffer.SelectedIndex != -1)
				{
					item.BestOfferDetails = new BestOfferDetailsType();
					item.BestOfferDetails.BestOfferEnabled = Boolean.Parse(CboEnableBestOffer.SelectedItem.ToString());
				}

				StringCollection deletedFields = new StringCollection();
				//drop tag action
				if (ChkCategory2.Checked)
					deletedFields.Add("item.secondaryCategory");

				if (ChkPayPalEmailAddress.Checked)
					deletedFields.Add("item.payPalEmailAddress");

				if (ChkApplicationData.Checked)
					deletedFields.Add("item.applicationData");
		
				
				RelistItemCall apicall = new RelistItemCall(Context);

				if (ListPictures.Items.Count > 0)
				{
					apicall.PictureFileList = new StringCollection();
					item.PictureDetails = new PictureDetailsType();
					item.PictureDetails.PhotoDisplay = (PhotoDisplayCodeType) Enum.Parse(typeof(PhotoDisplayCodeType), CboPicDisplay.SelectedItem.ToString());
				}

				foreach (string pic in ListPictures.Items)
				{
					apicall.PictureFileList.Add(pic);
				}

				apicall.DeletedFieldList = deletedFields;

				FeeTypeCollection fees = apicall.RelistItem(item);

				TxtItemId.Text = item.ItemID;
				BtnGetItem.Visible = true;
					
				foreach (FeeType fee in fees)
				{
					if (fee.Name == "ListingFee")
					{
						TxtListingFee.Text = fee.Fee.Value.ToString();
						break;
					}
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}

		}
        public async Task <ItemType> RelistItem(CommerceContext commerceContext, SellableItem sellableItem)
        {
            using (CommandActivity.Start(commerceContext, this))
            {
                var apiCall = new eBay.Service.Call.RelistItemCall(await this.GetEbayContext(commerceContext));

                if (sellableItem.HasComponent <EbayItemComponent>())
                {
                    var ebayItemComponent = sellableItem.GetComponent <EbayItemComponent>();

                    try
                    {
                        var item = await this.PrepareItem(commerceContext, sellableItem);

                        item.ItemID = ebayItemComponent.EbayId;

                        // Send the call to eBay and get the results
                        var feeResult = apiCall.RelistItem(item, new StringCollection());

                        ebayItemComponent.EbayId = item.ItemID;

                        ebayItemComponent.Status = "Listed";
                        sellableItem.GetComponent <TransientListMembershipsComponent>().Memberships.Add("Ebay_Listed");

                        foreach (var feeItem in feeResult)
                        {
                            var fee = feeItem as FeeType;
                            ebayItemComponent.Fees.Add(new AwardedAdjustment {
                                Adjustment = new Money(fee.Fee.currencyID.ToString(), System.Convert.ToDecimal(fee.Fee.Value)), AdjustmentType = "Fee", Name = fee.Name
                            });
                        }

                        ebayItemComponent.History.Add(new HistoryEntryModel {
                            EventMessage = "Listing Relisted", EventUser = commerceContext.CurrentCsrId()
                        });

                        return(item);
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.Contains("It looks like this listing is for an item you already have on eBay"))
                        {
                            var existingId = ex.Message.Substring(ex.Message.IndexOf("(") + 1);
                            existingId = existingId.Substring(0, existingId.IndexOf(")"));
                            await commerceContext.AddMessage("Warn", "Ebay.RelistItem", new object[] { }, $"ExistingId:{existingId}-ComponentId:{ebayItemComponent.EbayId}");

                            ebayItemComponent.EbayId = existingId;
                            ebayItemComponent.Status = "Listed";
                            sellableItem.GetComponent <TransientListMembershipsComponent>().Memberships.Add("Ebay_Listed");
                        }
                        else
                        {
                            commerceContext.Logger.LogError($"Ebay.RelistItem.Exception: Message={ex.Message}");
                            await commerceContext.AddMessage("Error", "Ebay.RelistItem.Exception", new object[] { ex }, ex.Message);
                        }
                    }
                }
                else
                {
                    commerceContext.Logger.LogError("EbayCommand.RelistItem.Exception: Message=ebayCommand.RelistItem.NoEbayItemComponent");
                    await commerceContext.AddMessage("Error", "Ebay.RelistItem.Exception", new object[] { }, "ebayCommand.RelistItem.NoEbayItemComponent");
                }

                return(new ItemType());
            }
        }