Beispiel #1
0
        private static CallRetry GetCallRetry()
        {
            if (retry != null)
            {
                return(retry);
            }

            try {
                mRetry.WaitOne();
                if (retry != null)
                {
                    return(retry);
                }

                retry                = new CallRetry();
                retry.DelayTime      = 1000;                    // 1 second
                retry.MaximumRetries = 2;
                // retry.TriggerErrorCodes
                // retry.TriggerExceptions
                return(retry);
            }
            finally {
                mRetry.ReleaseMutex();
            }
        }
Beispiel #2
0
        private static CallRetry GetCallRetry()
        {
            CallRetry retry = new CallRetry();

            retry.DelayTime              = 1000;                // 1 second
            retry.MaximumRetries         = 2;
            retry.TriggerHttpStatusCodes = new Int32Collection();
            retry.TriggerHttpStatusCodes.Add(502);
            retry.TriggerHttpStatusCodes.Add(404);
            return(retry);
        }
Beispiel #3
0
        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;
        }
Beispiel #4
0
        void RelistEbayItem(string szItem, double dNewStartingPrice, double dNewBuyNowPrice, string szNewCategory, string szNumberofDays, string szListingType)
        {
            txtResults.Text = " ";
            ApiContext oContext = new ApiContext();

            // 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;

            RelistItemCall oRelistItemCall = new RelistItemCall(oContext);

            // set the Version used in the call
            oRelistItemCall.Version = oContext.Version;

            // set the Site of the call
            oRelistItemCall.Site = oContext.Site;

            // enable the compression feature
            oRelistItemCall.EnableCompression = true;


            ItemType item = new ItemType();

            item.ItemID                             = szItem;
            item.BuyItNowPrice                      = new AmountType();
            item.BuyItNowPrice.Value                = dNewBuyNowPrice;
            item.StartPrice                         = new AmountType();
            item.StartPrice.Value                   = dNewStartingPrice;
            item.StartPrice.currencyID              = CurrencyCodeType.USD;
            item.BuyItNowPrice.currencyID           = CurrencyCodeType.USD;
            item.ListingType                        = new ListingTypeCodeType();
            item.ListingType                        = ListingTypeCodeType.Chinese;
            item.DispatchTimeMax                    = 2;
            item.ReturnPolicy                       = new ReturnPolicyType();
            item.ReturnPolicy.ReturnsAcceptedOption = "ReturnsAccepted";
            //item.ReturnPolicy.ReturnsWithin = "Days_3";
            item.ReturnPolicy.ShippingCostPaidBy  = "Buyer";
            item.ReturnPolicy.ReturnsWithinOption = "Days_3";
            item.ReturnPolicy.RefundOption        = "Exchange";
            item.ReturnPolicy.Description         = "Retund policy applies to item that are sold with Guaranteed or Warranty.  Refund policy does not apply to anything that is being sold AS-IS with no warranty.  Please read item description carefully.  If you have any questions about warranty please do not hesitate to call us at 303-521-3869 or email us";

            //item.ListingDuration =szNumberofDays;
            //item.ListingDuration = "Days_7";


            try
            {
                oRelistItemCall.RelistItem(item);
            }

            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;
            }

            DataGridViewRow theRow = dataGridView1.Rows[dataGridView1.SelectedRows[0].Index];

            theRow.DefaultCellStyle.BackColor = Color.Red;

            Cursor.Current = Cursors.Default;
        }
Beispiel #5
0
        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;
        }