Beispiel #1
0
        private string addItem(MySQLWrapper.eBayItem ebayItem)
        {
            string        listedItemId    = "-1";
            StringBuilder htmlDescription = new StringBuilder();
            TextReader    tr = new StreamReader("template.txt");

            htmlDescription.Insert(0, tr.ReadToEnd());
            tr.Close();
            htmlDescription.Replace("{0}", ebayItem.Title);
            htmlDescription.Replace("{1}", ebayItem.Author);
            htmlDescription.Replace("{2}", ebayItem.Publisher);
            htmlDescription.Replace("{3}", ebayItem.publishDate);
            htmlDescription.Replace("{4}", ebayItem.Binding);
            htmlDescription.Replace("{5}", ebayItem.ISBN);
            if (ebayItem.UPC != "")
            {
                htmlDescription.Replace("{6}", "<b>UPC : </b>" + ebayItem.UPC + "</br>");
            }
            else
            {
                htmlDescription.Replace("{6}", "");
            }
            htmlDescription.Replace("{7}", ebayItem.Weight.ToString());
            htmlDescription.Replace("{8}", ebayItem.Notes);
            htmlDescription.Replace("{9}", ebayItem.Description);

            ItemType item = new ItemType();


            item.InventoryTrackingMethod = InventoryTrackingMethodCodeType.SKU;
            item.SKU = ebayItem.SKU;

            // Title max length 55 chars
            if (ebayItem.Title.Length > 55)
            {
                item.Title = ebayItem.Title.Substring(0, 54);
            }
            else
            {
                item.Title = ebayItem.Title;
            }

            if (ebayItem.Image != "")
            {
                item.PictureDetails = new PictureDetailsType();
                item.PictureDetails.PictureURL.Add(ebayItem.Image);
            }

            item.Description     = htmlDescription.ToString();
            item.Currency        = CurrencyCodeType.INR;
            item.ListingType     = ListingTypeCodeType.FixedPriceItem;
            item.Quantity        = ebayItem.Quantity;
            item.PostalCode      = eBayLister.UserSettings.Default.itemPincode;
            item.Location        = eBayLister.UserSettings.Default.itemCityState;
            item.Country         = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), eBayLister.UserSettings.Default.itemCountry, true);
            item.ListingDuration = getListingDuration();
            item.PrimaryCategory = new CategoryType();
            if (eBayLister.UserSettings.Default.ListInCategory.Equals("Other Books"))
            {
                item.PrimaryCategory.CategoryID = "268";
            }
            else
            {
                item.PrimaryCategory.CategoryID = "37558";
            }
            item.StartPrice            = new AmountType();
            item.StartPrice.currencyID = CurrencyCodeType.INR;
            item.StartPrice.Value      = ebayItem.Price *
                                         Convert.ToDouble(eBayLister.UserSettings.Default.ConversionRate);
            item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection();
            item.PaymentMethods.Add(BuyerPaymentMethodCodeType.PaisaPayAccepted);
            item.ShippingDetails = this.getShippingDetails();
            item.ReturnPolicy    = this.getReturnPolicy();
            string handlingTime = eBayLister.UserSettings.Default.handlingTime;

            handlingTime         = handlingTime.Remove(handlingTime.IndexOf(' '));
            item.DispatchTimeMax = Convert.ToInt32(handlingTime);

            AttributeType conditionAttribute = new AttributeType();

            conditionAttribute.attributeLabel = "Condition";
            ValTypeCollection valueCollection = new ValTypeCollection();
            ValType           valueType       = new ValType();

            if (ebayItem.bookCondition.Contains("Used"))
            {
                valueType.ValueLiteral = "Used";
            }
            else
            {
                valueType.ValueLiteral = "New";
            }
            valueCollection.Add(valueType);
            conditionAttribute.Value = valueCollection;
            item.AttributeArray      = new AttributeTypeCollection();
            item.AttributeArray.Add(conditionAttribute);
            AddItemCall apiCall = new AddItemCall(context);


            FeeTypeCollection fees = apiCall.AddItem(item);

            foreach (FeeType fee in fees)
            {
                if (fee.Name == "ListingFee")
                {
                    addLogStatus("Success!     Listing Fee : " + Convert.ToString(fee.Fee.Value));
                }
            }

            listedItemId = apiCall.ItemID;
            return(listedItemId);
        }
Beispiel #2
0
        private bool verifyAddItem(MySQLWrapper.eBayItem ebayItem)
        {
            bool          itemListing     = false;
            TextReader    tr              = new StreamReader("template.txt");
            StringBuilder htmlDescription = new StringBuilder();

            htmlDescription.Insert(0, tr.ReadToEnd());
            tr.Close();
            htmlDescription.Replace("{0}", ebayItem.Title);
            htmlDescription.Replace("{1}", ebayItem.Author);
            htmlDescription.Replace("{2}", ebayItem.Publisher);
            htmlDescription.Replace("{3}", ebayItem.publishDate);
            htmlDescription.Replace("{4}", ebayItem.Binding);
            htmlDescription.Replace("{5}", ebayItem.ISBN);
            if (ebayItem.UPC != "")
            {
                htmlDescription.Replace("{6}", "<b>UPC : </b>" + ebayItem.UPC + "</br>");
            }
            else
            {
                htmlDescription.Replace("{6}", "");
            }
            htmlDescription.Replace("{7}", ebayItem.Weight.ToString());
            htmlDescription.Replace("{8}", ebayItem.Notes);
            htmlDescription.Replace("{9}", ebayItem.Description);

            ItemType item = new ItemType();

            item.SKU             = ebayItem.SKU;
            item.Title           = ebayItem.Title;
            item.Description     = htmlDescription.ToString();
            item.Currency        = CurrencyCodeType.INR;
            item.Country         = CountryCodeType.IN;
            item.ListingType     = ListingTypeCodeType.FixedPriceItem;
            item.Quantity        = ebayItem.Quantity;
            item.Location        = eBayLister.UserSettings.Default.itemCityState;
            item.ListingDuration = getListingDuration();
            item.PrimaryCategory = new CategoryType();
            if (eBayLister.UserSettings.Default.ListInCategory.Equals("Other Books"))
            {
                item.PrimaryCategory.CategoryID = "268";
            }
            else
            {
                item.PrimaryCategory.CategoryID = "37558";
            }
            item.StartPrice            = new AmountType();
            item.StartPrice.currencyID = CurrencyCodeType.INR;
            item.StartPrice.Value      = ebayItem.Price *
                                         Convert.ToDouble(eBayLister.UserSettings.Default.ConversionRate);

            item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection();
            item.PaymentMethods.Add(BuyerPaymentMethodCodeType.PaisaPayAccepted);
            item.ShippingDetails = this.getShippingDetails();
            item.ReturnPolicy    = this.getReturnPolicy();

            string handlingTime = eBayLister.UserSettings.Default.handlingTime;

            handlingTime         = handlingTime.Remove(handlingTime.IndexOf(' '));
            item.DispatchTimeMax = Convert.ToInt32(handlingTime);

            AttributeType conditionAttribute = new AttributeType();

            conditionAttribute.attributeLabel = "Condition";
            ValTypeCollection valueCollection = new ValTypeCollection();
            ValType           valueType       = new ValType();

            if (ebayItem.bookCondition.Contains("Used"))
            {
                valueType.ValueLiteral = "Used";
            }
            else
            {
                valueType.ValueLiteral = "New";
            }
            valueCollection.Add(valueType);
            conditionAttribute.Value = valueCollection;
            item.AttributeArray      = new AttributeTypeCollection();
            item.AttributeArray.Add(conditionAttribute);

            VerifyAddItemCall apiCall = new VerifyAddItemCall(context);

            try
            {
                FeeTypeCollection fees = apiCall.VerifyAddItem(item);
                foreach (FeeType fee in fees)
                {
                    if (fee.Name == "ListingFee")
                    {
                        addLogStatus("Success!     Listing Fee : " + Convert.ToString(fee.Fee.Value));
                    }
                }
                itemListing = true;
            }
            catch (ApiException ex)
            {
                itemListing = false;
                MessageBox.Show(ex.Message);
                Console.WriteLine(ex.Message);
            }
            return(itemListing);
        }