public void GetSellerList() { Assert.IsNotNull(TestData.NewItem, "Failed because no item available -- requires successful AddItem test"); // GetSellerListCall gsl = new GetSellerListCall(this.apiContext); DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll }; gsl.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels); // Time filter System.DateTime calTo = System.DateTime.Now.AddHours(10); System.DateTime calFrom = System.DateTime.Now.AddHours(-20); TimeFilter tf = new TimeFilter(calFrom, calTo); gsl.EndTimeFilter = tf; // Pagination PaginationType pt = new PaginationType(); pt.EntriesPerPage = 100; pt.EntriesPerPageSpecified = true; pt.PageNumber = 1; pt.PageNumberSpecified = true; gsl.Pagination = pt; // gsl.Execute(); ItemTypeCollection items = gsl.ApiResponse.ItemArray; Assert.IsNotNull(items); Assert.IsTrue(items.Count > 0); ItemType foundItem = findItem(items, TestData.NewItem.ItemID); Assert.IsNotNull(foundItem, "item not found"); }
public static ItemType[] GetSellerList(ApiContext apiContext) { GetSellerListCall apiCall = new GetSellerListCall(apiContext); apiCall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); apiCall.Pagination = new PaginationType() { EntriesPerPage = 200, PageNumber = 1 }; apiCall.EndTimeFrom = new DateTime(2012, 9, 1); apiCall.EndTimeTo = new DateTime(2012, 9, 20); ItemTypeCollection items = apiCall.GetSellerList(); List <ItemType> result = new List <ItemType>(); foreach (ItemType i in items) { if (i.ListingType == ListingTypeCodeType.FixedPriceItem) { result.Add(i); apiContext.ApiLogManager.RecordMessage(String.Format("{0}: {1}", i.ItemID, i.Description), MessageType.Information, MessageSeverity.Informational); } } return(result.ToArray()); }
private void BtnGetSellerList_Click(object sender, System.EventArgs e) { try { LstItems.Items.Clear(); GetSellerListCall apicall = new GetSellerListCall(Context); apicall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); //Pagination is required apicall.Pagination = new PaginationType(); apicall.Pagination.PageNumber = 1; apicall.Pagination.EntriesPerPage = 200; if (TxtUserId.Text.Length > 0) { apicall.UserID = TxtUserId.Text; } if (OptStartTime.Checked == true) { apicall.StartTimeFilter = new TimeFilter(DatePickStartFrom.Value, DatePickStartTo.Value); } else if (OptEndTime.Checked == true) { apicall.EndTimeFilter = new TimeFilter(DatePickEndFrom.Value, DatePickEndTo.Value); } ItemTypeCollection sellerlist = apicall.GetSellerList(); foreach (ItemType item in sellerlist) { string[] listparams = new string[6]; listparams[0] = item.ItemID; listparams[1] = item.Title; listparams[2] = item.SellingStatus.CurrentPrice.Value.ToString(); listparams[3] = item.SellingStatus.QuantitySold.ToString(); listparams[4] = item.SellingStatus.BidCount.ToString(); if (item.BestOfferDetails != null) { listparams[5] = item.BestOfferDetails.BestOfferEnabled.ToString(); } else { listparams[5] = "False"; } ListViewItem vi = new ListViewItem(listparams); LstItems.Items.Add(vi); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public string GetInventory() { ApiContext context = eBayCall.GetContext(); try { GetSellerListCall oGetSellerListCall = new GetSellerListCall(context); // use GranularityLevel of Fine oGetSellerListCall.GranularityLevel = GranularityLevelCodeType.Fine; // get the first page, 200 items per page PaginationType oPagination = new PaginationType(); oPagination.EntriesPerPage = 200; oPagination.EntriesPerPageSpecified = true; oPagination.PageNumber = 1; oPagination.PageNumberSpecified = true; oGetSellerListCall.Pagination = oPagination; // ask for all items that are ending in the future (active items) oGetSellerListCall.EndTimeFilter = new TimeFilter(DateTime.Now, DateTime.Now.AddMonths(1)); // return items that end soonest first oGetSellerListCall.Sort = 2; ItemTypeCollection oItems = oGetSellerListCall.GetSellerList(); if (oItems != null) { if (oItems.Count > 0) { return(JsonConvert.SerializeObject(oItems, Formatting.Indented)); } else { return("No active inventory."); } } else { return("Inventory is null!"); } } catch (ApiException oApiEx) { return(oApiEx.Message); } catch (Exception ex) { return(ex.Message); } }
public void GetSellerListFull() { Assert.IsNotNull(TestData.NewItem2, "Failed because no item available -- requires successful AddItem test"); GetSellerListCall gsl = new GetSellerListCall(this.apiContext); DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll }; //specify information gsl.AdminEndedItemsOnly = false; gsl.CategoryID = int.Parse(TestData.NewItem2.PrimaryCategory.CategoryID); gsl.StartTimeFrom = DateTime.Now.AddDays(-2); gsl.StartTimeTo = DateTime.Now.AddDays(1); //gsl.GranularityLevel=GranularityLevelCodeType.Fine;//if specify GranularityLevel, the DetailLevelList is ignored. gsl.IncludeWatchCount = true; gsl.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels); // Pagination PaginationType pt = new PaginationType(); pt.EntriesPerPage = 100; pt.EntriesPerPageSpecified = true; pt.PageNumber = 1; pt.PageNumberSpecified = true; gsl.Pagination = pt; gsl.Sort = 1; //descending sort // gsl.Execute(); //check whether the call is success. Assert.IsTrue(gsl.AbstractResponse.Ack == AckCodeType.Success || gsl.AbstractResponse.Ack == AckCodeType.Warning, "do not success!"); ItemTypeCollection items = gsl.ApiResponse.ItemArray; Assert.IsNotNull(items); Assert.IsTrue(items.Count > 0); ItemType foundItem = findItem(items, TestData.NewItem2.ItemID); Assert.IsNotNull(foundItem, "item not found"); ItemType item = items[0]; Assert.IsNotNull(item.HitCount); Assert.IsNotNull(gsl.ApiResponse.PaginationResult); Assert.IsNotNull(gsl.ApiResponse.Seller); }
void AddItems() { try { ApiContext apiContext = GetApiContext(); AddFixedPriceItemCall addApiCall = new AddFixedPriceItemCall(apiContext); GetItemCall getApiCall = new GetItemCall(apiContext); GetSellerListCall listApiCall = new GetSellerListCall(apiContext); EndItemsCall endApiCall = new EndItemsCall(apiContext); ModelDataContext context = new ModelDataContext(); articles = (from current in context.Articles orderby current.ArticleNumber where current.AmountOnStock > 0 select current).Take(2); EndActiveAuctions(articles); System.Threading.Thread.Sleep(5000); foreach (Article article in articles) { try { //create a new ItemType object corresponding to article-backend data with fix quantity of 99 pieces an add it ItemType item = BuildItem(article); addApiCall.AddFixedPriceItem(item); } catch (Exception ex) { Assert.Fail(ex.Message); } } } catch (Exception ex) { Assert.Fail(ex.Message); } }
void GetSellerListOfItems() { ApiContext oContext = new ApiContext(); int nNumberofTotalListing = 0; int nNumberofSoldListing = 0; double nTotalAmount = 0; int nAlreadyRelistedCount = 0; int nEligibleItemForRelist = 0; string szShippingType; string szError = ""; string szInsertString = ""; string[] szArray = new string[30]; string[] szItemArray = new string[30]; int nCount = 0; string szHighBidder = ""; string szSubTitle = " "; string szTitle = " "; string szDescription = " "; string szSelectString = " "; DateTime jddate = new DateTime(); string szInventoryCategory = " "; string szInventoryCamera = " "; string szInventoryLocation = " "; string szInventorySource = " "; DateTime jdInvShipDate = new DateTime(); DateTime jdListedDate = new DateTime(); double dInvPrice = 0; int nQtyAvail = 0; int nQtySold = 0; int nLotSize = 0; //dataGridView1.Rows.Clear(); Cursor.Current = Cursors.WaitCursor; System.Data.OleDb.OleDbConnection conn_newdb = new System.Data.OleDb.OleDbConnection(); conn_newdb.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" + "Data source= " + txtbx_dbpath.Text; try { conn_newdb.Open(); } catch (Exception) { szError = "Failed"; } /*the inventory header database connection*/ System.Data.OleDb.OleDbConnection conn_newdb2 = new System.Data.OleDb.OleDbConnection(); conn_newdb2.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" + "Data source= " + txtbx_InvDBPath.Text; try { conn_newdb2.Open(); } catch (Exception) { szError = "Failed"; } txtResults.Text = " "; // set the dev,app,cert information oContext.ApiCredential.ApiAccount.Developer = ConfigurationManager.AppSettings["DevID"]; oContext.ApiCredential.ApiAccount.Application = ConfigurationManager.AppSettings["AppID"]; oContext.ApiCredential.ApiAccount.Certificate = ConfigurationManager.AppSettings["CertID"]; // set the AuthToken oContext.ApiCredential.eBayToken = ConfigurationManager.AppSettings["UserToken"]; // set the base SOAP URL .. use https://api.sandbox.ebay.com/wsapi for Sandbox calls //oContext.SoapApiServerUrl = "https://api.ebay.com/wsapi"; oContext.SoapApiServerUrl = ConfigurationManager.AppSettings["ServerUrl"]; // set the Site of the Context oContext.Site = eBay.Service.Core.Soap.SiteCodeType.US; // very important, let's setup the logging ApiLogManager oLogManager = new ApiLogManager(); oLogManager.ApiLoggerList.Add(new eBay.Service.Util.FileLogger("GetSellerList459NETSDK.log", true, true, true)); oLogManager.EnableLogging = true; oContext.ApiLogManager = oLogManager; // the WSDL Version used for this SDK build oContext.Version = "459"; // set the CallRetry properties CallRetry oCallRetry = new CallRetry(); // set the delay between each retry to 1 millisecond oCallRetry.DelayTime = 1; // set the maximum number of retries oCallRetry.MaximumRetries = 3; // set the error codes on which to retry StringCollection oErrorCodes = new StringCollection(); oErrorCodes.Add("10007"); // Internal error to the application ... general error oErrorCodes.Add("2"); // unsupported verb error oErrorCodes.Add("251"); // eBay Structured Exception ... general error oCallRetry.TriggerErrorCodes = oErrorCodes; // set the exception types on which to retry TypeCollection oExceptions = new TypeCollection(); oExceptions.Add(typeof(System.Net.ProtocolViolationException)); // the "Client found response content type of 'text/plain'" exception is of type SdkException, so let's add that to the list oExceptions.Add(typeof(SdkException)); oCallRetry.TriggerExceptions = oExceptions; // set CallRetry back to ApiContext oContext.CallRetry = oCallRetry; // set the timeout to 2 minutes oContext.Timeout = 120000; GetSellerListCall oGetSellerListCall = new GetSellerListCall(oContext); // set the Version used in the call oGetSellerListCall.Version = oContext.Version; // set the Site of the call oGetSellerListCall.Site = oContext.Site; // enable the compression feature oGetSellerListCall.EnableCompression = true; // use GranularityLevel of Fine //oGetSellerListCall.GranularityLevel = GranularityLevelCodeType.Fine; oGetSellerListCall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); // get the first page, 200 items per page PaginationType oPagination = new PaginationType(); oPagination.EntriesPerPage = 200; //oPagination.EntriesPerPageSpecified = true; oPagination.PageNumber = 1; //oPagination.PageNumberSpecified = true; oGetSellerListCall.Pagination = oPagination; oGetSellerListCall.UserID = txtbx_userid.Text; // ask for all items that are ending in the future (active items) //oGetSellerListCall.EndTimeFilter = new TimeFilter(DateTime.Now.AddDays(-3),DateTime.Now); //oGetSellerListCall.EndTimeFilter = new TimeFilter(dateTimePicker1.Value, DateTime.Now); oGetSellerListCall.EndTimeFilter = new TimeFilter(dateTimePicker1.Value, dateTimePicker2.Value); // return items that end soonest first oGetSellerListCall.Sort = 1; // see http://developer.ebay.com/DevZone/SOAP/docs/WSDL/xsd/1/element/1597.htm for Sort documentation try { ItemTypeCollection oItems = oGetSellerListCall.GetSellerList(); // output some of the data nNumberofTotalListing = 0; nNumberofSoldListing = 0; int pagenumber = 1; while (pagenumber <= oGetSellerListCall.PaginationResult.TotalNumberOfPages) { if (pagenumber > 1) { oGetSellerListCall.Pagination.PageNumber = pagenumber; //oGetSellerListCall.Execute(); oItems = oGetSellerListCall.GetSellerList(); } foreach (ItemType oItem in oItems) { if (oItem.SKU != null) { szArray = oItem.SKU.Split(' '); } else { szArray[0] = "BLANK"; } nQtySold = oItem.SellingStatus.QuantitySold; nQtyAvail = oItem.Quantity - nQtySold; nLotSize = oItem.LotSize; szItemArray = szArray[0].Split(','); szItemArray = szItemArray[0].Split('.'); if (oItem.SellingStatus.HighBidder != null) { szHighBidder = oItem.SellingStatus.HighBidder.UserID; } else { szHighBidder = " "; } if (oItem.SubTitle != null) { szSubTitle = oItem.SubTitle.Replace('\"', ' '); } else { szSubTitle = " "; } if (oItem.Title != null) { szTitle = oItem.Title.Replace('\"', ' '); } else { szTitle = " "; } //ShippingServiceOptionsTypeCollection shippingCol = new ShippingServiceOptionsTypeCollection(); //shippingCol = oItem.ShippingDetails.ShippingServiceOptions; ShippingServiceOptionsType[] opt = new ShippingServiceOptionsType[10]; if (oItem.ShippingDetails.ShippingServiceOptions.Count == 0) { szShippingType = "NOTKNOWN"; } else { opt[0] = oItem.ShippingDetails.ShippingServiceOptions[0]; if (opt[0].ShippingServiceCost == null) { szShippingType = "FREE"; } else { if (opt[0].ShippingServiceCost.Value > 0) { szShippingType = "NOT FREE"; } else { szShippingType = "FREE"; } } } nNumberofTotalListing = nNumberofTotalListing + 1; //oItem.ShippingDetails.ShippingServiceOptions. //if (oItem.ShippingDetails.ShippingServiceOptions.IndexO == ShippingTypeCodeType.Free) //if (oItem.ShippingDetails.ShippingType == ShippingTypeCodeType.Free) // szShippingType = "FREE"; if (oItem.SellingStatus.HighBidder != null) { /*if (!(chkbx_OnlyRelistOnes.Checked)) * { * dataGridView1.Rows.Add(oItem.ItemID, oItem.ListingType, oItem.Title, oItem.SubTitle, oItem.ListingDetails.StartTime.ToShortDateString(), oItem.ListingDetails.EndTime.ToShortDateString(), oItem.SellingStatus.CurrentPrice.Value, oItem.SellingStatus.HighBidder.UserID); * }*/ nNumberofSoldListing = nNumberofSoldListing + 1; nTotalAmount = nTotalAmount + Convert.ToDouble(oItem.SellingStatus.CurrentPrice.Value); } else { if (oItem.ListingDetails.RelistedItemID == null) { // dataGridView1.Rows.Add(oItem.ItemID, oItem.ListingType, oItem.Title, oItem.SubTitle, oItem.ListingDetails.StartTime.ToShortDateString(), oItem.ListingDetails.EndTime.ToShortDateString(), oItem.SellingStatus.CurrentPrice.Value, "DNS"); nEligibleItemForRelist += 1; } else { nAlreadyRelistedCount += 1; } } /**/ /*Get the data from the inventory header so that we can load this main db*/ /*************************************************************************/ szSelectString = " "; int outnumber = 0; //jdInvShipDate = new DateTime(0); if (int.TryParse(szItemArray[0].ToString(), out outnumber)) //if (int.TryParse(szItemArray[0].ToString()), out value) { szSelectString = "Select * from InventoryHeader where INVITEM = " + szItemArray[0]; OleDbCommand cmd_InvMon = new OleDbCommand(szSelectString, conn_newdb2); OleDbDataReader reader_InvMon = cmd_InvMon.ExecuteReader(); while (reader_InvMon.Read()) { if (reader_InvMon != null) { if ((reader_InvMon["INVDATE"].ToString() != null) && reader_InvMon["INVDATE"].ToString() != " " && reader_InvMon["INVDATE"].ToString() != "") { jddate = Convert.ToDateTime(reader_InvMon["INVDATE"].ToString()); } if ((reader_InvMon["INVSOLDDATE"].ToString() != null) && reader_InvMon["INVSOLDDATE"].ToString() != " " && reader_InvMon["INVSOLDDATE"].ToString() != "") { jdInvShipDate = Convert.ToDateTime(reader_InvMon["INVSOLDDATE"].ToString()); } else { jdInvShipDate = Convert.ToDateTime("01/01/1974"); } if ((reader_InvMon["INVLISTEDDATE"].ToString() != null) && reader_InvMon["INVLISTEDDATE"].ToString() != " " && reader_InvMon["INVLISTEDDATE"].ToString() != "") { jdListedDate = Convert.ToDateTime(reader_InvMon["INVLISTEDDATE"].ToString()); } szInventoryCamera = reader_InvMon["INVCAMERA"].ToString(); szInventoryCategory = reader_InvMon["INVHEADER"].ToString(); szInventoryLocation = reader_InvMon["INVLOCATION"].ToString(); szInventorySource = reader_InvMon["INVCHECKINDATE"].ToString(); dInvPrice = Convert.ToDouble(reader_InvMon["INVPRICE"].ToString()); } break; } } /*************************************************************************/ szDescription = ""; //szDescription = oItem.Description; //szDescription = szDescription.Replace("\"", "\"\""); if (CheckRecordExistence(szItemArray[0], oItem.ItemID)) { //Update szInsertString = ""; szInsertString = "Update EbayAnalysis Set " + "SoldDate = " + "\"" + oItem.ListingDetails.EndTime.AddHours(-7) + "\"," + "ListedDate = " + "\"" + oItem.ListingDetails.StartTime.AddHours(-7) + "\"," + "HighBidder = " + "\"" + szHighBidder + "\"," + "SoldPrice = " + oItem.SellingStatus.CurrentPrice.Value + "," + "Description = " + "\"" + szDescription + "\"," + "Category = " + "\"" + oItem.PrimaryCategory.CategoryID + "\"," + "CategoryDescription = " + "\"" + oItem.PrimaryCategory.CategoryName + "\"," + "ShippingType = " + "\"" + szShippingType + "\"," + "InventoryDate = " + "\"" + jddate + "\"," + "InventoryShipDate = " + "\"" + jdInvShipDate + "\"," + //"InventoryListedDate = " + "\"" + jdListedDate + "\"," + "InventoryCategory = " + "\"" + szInventoryCategory + "\"," + "InventoryCamera = " + "\"" + szInventoryCamera + "\"," + "InventoryLocation = " + "\"" + szInventoryLocation + "\"," + "InventorySource = " + "\"" + szInventorySource + "\"," + "InventoryPrice = " + dInvPrice + "," + "QtySold = " + nQtySold + "," + "QtyAvailable = " + nQtyAvail + "," + "LotSize = " + nLotSize + " Where ( CustomItemNumber = " + "\"" + szItemArray[0] + "\"" + "AND " + "EbayItemNumber = " + "\"" + oItem.ItemID + "\"" + ")"; } else { szInsertString = ""; szInsertString = "insert into EbayAnalysis (" + "CustomItemNumber," + "EbayItemNumber," + "SoldDate," + "ListedDate," + "HighBidder," + "StartingPrice," + "SoldPrice," + "NumberOfDays," + "Title," + "SubTitle," + "Description," + "Category," + "CategoryDescription," + "ShippingType," + "InventoryDate," + "InventoryShipDate," + "InventoryListedDate," + "InventoryCategory," + "InventoryCamera," + "InventoryLocation," + "InventorySource," + "InventoryPrice," + "QtySold," + "QtyAvailable," + "LotSize" + ") VALUES ( " + "\"" + szItemArray[0] + "\"," + oItem.ItemID + "," + "\"" + oItem.ListingDetails.EndTime.AddHours(-7) + "\"," + "\"" + oItem.ListingDetails.StartTime.AddHours(-7) + "\"," + "\"" + szHighBidder + "\"," + oItem.StartPrice.Value + "," + oItem.SellingStatus.CurrentPrice.Value + "," + "0" + "," + "\"" + szTitle + "\"" + "," + "\"" + szSubTitle + "\"" + "," + "\"" + szDescription + "\"," + "\"" + oItem.PrimaryCategory.CategoryID + "\"," + "\"" + oItem.PrimaryCategory.CategoryName + "\"," + "\"" + szShippingType + "\"," + "\"" + jddate + "\"," + "\"" + jdInvShipDate + "\"," + "\"" + jdListedDate + "\"," + "\"" + szInventoryCategory + "\"," + "\"" + szInventoryCamera + "\"," + "\"" + szInventoryLocation + "\"," + "\"" + szInventorySource + "\"," + dInvPrice + "," + nQtySold + "," + nQtyAvail + "," + nLotSize + ")"; } OleDbCommand cmd6 = new OleDbCommand(szInsertString, conn_newdb); cmd6.ExecuteNonQuery(); nCount++; label1.Text = nCount.ToString(); label1.Refresh(); } pagenumber += 1; } conn_newdb.Close(); conn_newdb2.Close(); //pagenumber += 1; } catch (ApiException oApiEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oApiEx.Message; return; } catch (SdkException oSdkEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oSdkEx.Message; return; } catch (Exception oEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oEx.Message; return; } Cursor.Current = Cursors.Default; }
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); } }
/// <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); }
public IHttpActionResult GetSellerItems() { //[Step 1] Initialize eBay ApiContext object apiContext = GetApiContext(); GetSellerListCall call = new GetSellerListCall(apiContext); call.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); call.Pagination = new PaginationType() { EntriesPerPage = 200 }; call.EndTimeFrom = DateTime.UtcNow.AddDays(-1); call.EndTimeTo = DateTime.UtcNow.AddDays(30); call.IncludeWatchCount = true; ItemTypeCollection items = call.GetSellerList(); foreach (ItemType item in items) { try { List <ZohoLead> leads = new List <ZohoLead>(); GetMemberMessagesCall messages = new GetMemberMessagesCall(apiContext); messages.GetMemberMessages(item.ItemID, MessageTypeCodeType.AskSellerQuestion, MessageStatusTypeCodeType.Unanswered); foreach (MemberMessageExchangeType message in messages.MemberMessageList) { leads = GetMemberMessageLead(leads, item, message); } if (item.BestOfferEnabled) { GetBestOffersCall boCall = new GetBestOffersCall(apiContext); boCall.GetBestOffers(item.ItemID, null, BestOfferStatusCodeType.All, new PaginationType() { EntriesPerPage = 200 }); foreach (BestOfferType offer in boCall.BestOfferList) { leads = GetBestOfferLead(leads, item, offer); } } GetAllBiddersCall bidderCall = new GetAllBiddersCall(apiContext); var bidders = bidderCall.GetAllBidders(item.ItemID, GetAllBiddersModeCodeType.ViewAll); foreach (OfferType bidder in bidders) { leads = GetBidderLead(leads, item, bidder); } if (leads.Count > 0) { leads = GetLeadInformation(leads); InsertZohoLeads(leads); } } catch (Exception ex) { Trace.TraceError(ex.Message); } } return(Ok()); }
public ItemType[] GeteBaySellerListBySKUs(GeteBaySellerListBySKUsRequest request) { try { if (string.IsNullOrEmpty(request.SellerID)) { throw new Exception("No Seller ID"); } var apiContext = _eBayAPIContextProvider.GetAPIContextBySellerID(request.SellerID); var getItemCall = new GetItemCall(apiContext); getItemCall.DetailLevelList.Add(DetailLevelCodeType.ItemReturnDescription); var lstSellerListing = new List <ItemType>(); var getSellerListCall = new GetSellerListCall(apiContext); getSellerListCall.EndTimeFrom = DateTime.Now.ToUniversalTime(); getSellerListCall.EndTimeTo = DateTime.Now.AddDays(90).ToUniversalTime(); getSellerListCall.SKUArrayList = new StringCollection(); foreach (var sku in request.SKUs) { getSellerListCall.SKUArrayList.Add(sku.ToUpper()); } int pageNumber = 1; int pageSize = 50; int totalPage = 1; PaginationType pageInfo = new PaginationType(); do { pageInfo.PageNumber = pageNumber; pageInfo.EntriesPerPage = pageSize; getSellerListCall.Pagination = pageInfo; getSellerListCall.GetSellerList(); if (getSellerListCall.PaginationResult != null) { totalPage = getSellerListCall.PaginationResult.TotalNumberOfPages; } if (getSellerListCall.ItemList != null) { foreach (var listItem in getSellerListCall.ItemList.ToArray()) { try { var item = getItemCall.GetItem(listItem.ItemID); if (item != null) { lstSellerListing.Add(item); } } catch (Exception ex) { LogManager.Instance.Error(ex.Message); } } } pageNumber++; }while (pageNumber <= totalPage); return(lstSellerListing.ToArray()); } catch (Exception ex) { throw ex; } }
void GetSellerListOfItems() { ApiContext oContext = new ApiContext(); int nNumberofTotalListing = 0; int nNumberofSoldListing = 0; double nTotalAmount = 0; int nAlreadyRelistedCount = 0; int nEligibleItemForRelist = 0; string szShippingType; dataGridView1.Rows.Clear(); Cursor.Current = Cursors.WaitCursor; txtResults.Text = " "; // set the dev,app,cert information oContext.ApiCredential.ApiAccount.Developer = ConfigurationManager.AppSettings["DevID"]; oContext.ApiCredential.ApiAccount.Application = ConfigurationManager.AppSettings["AppID"]; oContext.ApiCredential.ApiAccount.Certificate = ConfigurationManager.AppSettings["CertID"]; // set the AuthToken oContext.ApiCredential.eBayToken = ConfigurationManager.AppSettings["UserToken"]; // set the base SOAP URL .. use https://api.sandbox.ebay.com/wsapi for Sandbox calls //oContext.SoapApiServerUrl = "https://api.ebay.com/wsapi"; oContext.SoapApiServerUrl = ConfigurationManager.AppSettings["ServerUrl"]; // set the Site of the Context oContext.Site = eBay.Service.Core.Soap.SiteCodeType.US; // very important, let's setup the logging ApiLogManager oLogManager = new ApiLogManager(); oLogManager.ApiLoggerList.Add(new eBay.Service.Util.FileLogger("GetSellerList459NETSDK.log", true, true, true)); oLogManager.EnableLogging = true; oContext.ApiLogManager = oLogManager; // the WSDL Version used for this SDK build oContext.Version = "459"; // set the CallRetry properties CallRetry oCallRetry = new CallRetry(); // set the delay between each retry to 1 millisecond oCallRetry.DelayTime = 1; // set the maximum number of retries oCallRetry.MaximumRetries = 3; // set the error codes on which to retry StringCollection oErrorCodes = new StringCollection(); oErrorCodes.Add("10007"); // Internal error to the application ... general error oErrorCodes.Add("2"); // unsupported verb error oErrorCodes.Add("251"); // eBay Structured Exception ... general error oCallRetry.TriggerErrorCodes = oErrorCodes; // set the exception types on which to retry TypeCollection oExceptions = new TypeCollection(); oExceptions.Add(typeof(System.Net.ProtocolViolationException)); // the "Client found response content type of 'text/plain'" exception is of type SdkException, so let's add that to the list oExceptions.Add(typeof(SdkException)); oCallRetry.TriggerExceptions = oExceptions; // set CallRetry back to ApiContext oContext.CallRetry = oCallRetry; // set the timeout to 2 minutes oContext.Timeout = 120000; GetSellerListCall oGetSellerListCall = new GetSellerListCall(oContext); // set the Version used in the call oGetSellerListCall.Version = oContext.Version; // set the Site of the call oGetSellerListCall.Site = oContext.Site; // enable the compression feature oGetSellerListCall.EnableCompression = true; // use GranularityLevel of Fine oGetSellerListCall.GranularityLevel = GranularityLevelCodeType.Fine; // get the first page, 200 items per page PaginationType oPagination = new PaginationType(); oPagination.EntriesPerPage = 200; //oPagination.EntriesPerPageSpecified = true; oPagination.PageNumber = 1; //oPagination.PageNumberSpecified = true; oGetSellerListCall.Pagination = oPagination; oGetSellerListCall.UserID = txtUserID.Text; // ask for all items that are ending in the future (active items) //oGetSellerListCall.EndTimeFilter = new TimeFilter(DateTime.Now.AddDays(-3),DateTime.Now); //oGetSellerListCall.EndTimeFilter = new TimeFilter(dateTimePicker1.Value, DateTime.Now); oGetSellerListCall.EndTimeFilter = new TimeFilter(dateTimePicker1.Value, dateTimePicker2.Value); // return items that end soonest first oGetSellerListCall.Sort = 1; // see http://developer.ebay.com/DevZone/SOAP/docs/WSDL/xsd/1/element/1597.htm for Sort documentation try { ItemTypeCollection oItems = oGetSellerListCall.GetSellerList(); // output some of the data nNumberofTotalListing = 0; nNumberofSoldListing = 0; int pagenumber = 1; while (pagenumber <= oGetSellerListCall.PaginationResult.TotalNumberOfPages) { if (pagenumber > 1) { oGetSellerListCall.Pagination.PageNumber = pagenumber; //oGetSellerListCall.Execute(); oItems = oGetSellerListCall.GetSellerList(); } foreach (ItemType oItem in oItems) { nNumberofTotalListing = nNumberofTotalListing + 1; if (oItem.ShippingDetails.ShippingType == ShippingTypeCodeType.Free) { szShippingType = "FREE"; } if (oItem.SellingStatus.HighBidder != null) { if (!(chkbx_OnlyRelistOnes.Checked)) { dataGridView1.Rows.Add(oItem.ItemID, oItem.ListingType, oItem.Title, oItem.SubTitle, oItem.ListingDetails.StartTime.ToShortDateString(), oItem.ListingDetails.EndTime.ToShortDateString(), oItem.SellingStatus.CurrentPrice.Value, oItem.SellingStatus.HighBidder.UserID); } nNumberofSoldListing = nNumberofSoldListing + 1; nTotalAmount = nTotalAmount + Convert.ToDouble(oItem.SellingStatus.CurrentPrice.Value); } else { if (oItem.ListingDetails.RelistedItemID == null) { dataGridView1.Rows.Add(oItem.ItemID, oItem.ListingType, oItem.Title, oItem.SubTitle, oItem.ListingDetails.StartTime.ToShortDateString(), oItem.ListingDetails.EndTime.ToShortDateString(), oItem.SellingStatus.CurrentPrice.Value, "DNS"); nEligibleItemForRelist += 1; } else { nAlreadyRelistedCount += 1; } } //Console.WriteLine("ItemID is " + oItem.ItemID); //Console.WriteLine("This item is of type " + oItem.ListingType.ToString()); //if (0 < oItem.SellingStatus.BidCount) //{ // The HighBidder element is valid only if there is at least 1 bid // Console.WriteLine("High Bidder is " + oItem.SellingStatus.HighBidder.UserID); //} //Console.WriteLine("Current Price is " + oItem.SellingStatus.CurrentPrice.currencyID.ToString() + " " + oItem.SellingStatus.CurrentPrice.Value.ToString()); //Console.WriteLine("End Time is " + oItem.ListingDetails.EndTime.ToLongDateString() + " " + oItem.ListingDetails.EndTime.ToLongTimeString()); //Console.WriteLine(""); // the data that is accessible through the item object // for different GranularityLevel and DetailLevel choices // can be found at the following URL: // http://developer.ebay.com/DevZone/SOAP/docs/WebHelp/GetSellerListCall-GetSellerList_Best_Practices.html } pagenumber += 1; } //pagenumber += 1; // // // //Console.WriteLine("Done"); txtbx_AmountSold.Text = nTotalAmount.ToString(); txtbx_NumberOfListing.Text = nNumberofTotalListing.ToString(); txtbx_NumberofSold.Text = nNumberofSoldListing.ToString(); txtbx_AlreadyListed.Text = nAlreadyRelistedCount.ToString(); txtbx_relistEligible.Text = nEligibleItemForRelist.ToString(); } catch (ApiException oApiEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oApiEx.Message; return; } catch (SdkException oSdkEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oSdkEx.Message; return; } catch (Exception oEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oEx.Message; return; } Cursor.Current = Cursors.Default; }