Beispiel #1
0
        public void loadDataFromFTP()
        {
            string[]     fileList = null;
            MySQLWrapper s;

            try
            {
                fileList = getFileList();
                if (fileList != null)
                {
                    s = new MySQLWrapper();
                    foreach (String fileName in fileList)
                    {
                        downloadFile(fileName);
                        deleteFile(fileName);
                        s.loadDataFromFile(fileName);
                    }
                    s.destroy();
                    changeStatus("Done!");
                    addLogStatus("Done!");
                }
                else
                {
                    addLogStatus("No valid files found at FTP!");
                }
            }
            catch (Exception ex)
            {
                addLogStatus("ERROR : " + ex.Message);
            }
        }
Beispiel #2
0
 public void loadDataFromFTP()
 {
     string[] fileList = null;
     MySQLWrapper s;
     try
     {
         fileList = getFileList();
         if (fileList != null)
         {
             s = new MySQLWrapper();
             foreach (String fileName in fileList)
             {
                 downloadFile(fileName);
                 deleteFile(fileName);
                 s.loadDataFromFile(fileName);
             }
             s.destroy();
             changeStatus("Done!");
             addLogStatus("Done!");
         }
         else {
             addLogStatus("No valid files found at FTP!");
         }
     }
     catch (Exception ex)
     {
         addLogStatus("ERROR : " + ex.Message);
     }
 }
Beispiel #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();
            }
        }
Beispiel #4
0
 private void btnTestMySQLConnection_Click(object sender, EventArgs e)
 {
     MySQLWrapper.testConnection(txtHost.Text, txtUsername.Text,
                                 txtPassword.Text, txtDatabase.Text);
 }
Beispiel #5
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();
            }
        }
Beispiel #6
0
        public void startListing()
        {
            int          itemCount = 0;
            string       eBayItems = "0";
            MySQLWrapper s         = null;

            try
            {
                s         = new MySQLWrapper();
                eBayItems = s.getItemCount();
                if (eBayItems == "0")
                {
                    throw new Exception("No items found in database");
                }
                reportTotalItems(eBayItems);
                changeStatus("Initializing...");
                addLogStatus("Initializing...");

                if (!initialize())
                {
                    throw new Exception("ERROR : Unable to connect to eBay Service");
                }
                MySQLWrapper.eBayData ebayData = new MySQLWrapper.eBayData();
                MySQLWrapper.eBayItem item;
                string listedItemId    = "-1";
                string generatedItemId = "-1";
                while (ebayData.hasNext() && eBayLister.Program.mainForm.listingContinue)
                {
                    listedItemId    = "-1";
                    generatedItemId = "-1";
                    itemCount++;
                    reportProgress(itemCount.ToString());


                    item         = ebayData.getItem();
                    listedItemId = s.checkIfListed(item.SKU);
                    if (listedItemId != "-1")
                    {
                        if (item.Quantity == 0)
                        {
                            addLogStatus("Removing item " + item.SKU);
                            removeItem(listedItemId, item.SKU);
                            s.deleteTempItem(item.SKU);
                            s.deleteListedItem(item.SKU);
                            s.addToLogs(item.SKU, "Deleted");
                        }
                        else
                        {
                            addLogStatus("Modifying item " + item.SKU);
                            modifyItem(listedItemId, item.SKU, item.Quantity);
                            s.deleteTempItem(item.SKU);
                            s.addToLogs(item.SKU, "Quantity changed to " + item.Quantity);
                        }
                    }
                    else
                    {
                        addLogStatus("Listing item " + item.SKU);
                        generatedItemId = addItem(item);
                        if (generatedItemId != "-1")
                        {
                            s.deleteTempItem(item.SKU);
                            s.addListedItem(item.SKU, generatedItemId);
                            s.addToLogs(item.SKU, "Listed with Item Id : " + generatedItemId);
                        }
                    }
                }
                if (eBayLister.Program.mainForm.listingContinue)
                {
                    addLogStatus("Done!");
                }
            }
            catch (Exception ex) {
                addLogStatus("ERROR : " + ex.Message);
            }
            finally{
                s.destroy();
                destroy();
            }
        }
Beispiel #7
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;
        }
Beispiel #8
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 #9
0
        public void startListing()
        {
            int itemCount = 0;
            string eBayItems = "0";
            MySQLWrapper s = null;
            try
            {
                s = new MySQLWrapper();
                eBayItems = s.getItemCount();
                if (eBayItems == "0")
                    throw new Exception("No items found in database");
                reportTotalItems(eBayItems);
                changeStatus("Initializing...");
                addLogStatus("Initializing...");

                if (!initialize())
                    throw new Exception("ERROR : Unable to connect to eBay Service");
                MySQLWrapper.eBayData ebayData = new MySQLWrapper.eBayData();
                MySQLWrapper.eBayItem item;
                string listedItemId = "-1";
                string generatedItemId = "-1";
                while (ebayData.hasNext() && eBayLister.Program.mainForm.listingContinue)
                {
                    listedItemId = "-1";
                    generatedItemId = "-1";
                    itemCount++;
                    reportProgress(itemCount.ToString());

                    item = ebayData.getItem();
                    listedItemId = s.checkIfListed(item.SKU);
                    if (listedItemId != "-1")
                    {
                        if (item.Quantity == 0)
                        {
                            addLogStatus("Removing item " + item.SKU);
                            removeItem(listedItemId, item.SKU);
                            s.deleteTempItem(item.SKU);
                            s.deleteListedItem(item.SKU);
                            s.addToLogs(item.SKU, "Deleted");
                        }
                        else
                        {
                            addLogStatus("Modifying item " + item.SKU);
                            modifyItem(listedItemId, item.SKU, item.Quantity);
                            s.deleteTempItem(item.SKU);
                            s.addToLogs(item.SKU, "Quantity changed to " + item.Quantity);
                        }
                    }
                    else
                    {
                        addLogStatus("Listing item " + item.SKU);
                        generatedItemId = addItem(item);
                        if (generatedItemId != "-1")
                        {
                            s.deleteTempItem(item.SKU);
                            s.addListedItem(item.SKU, generatedItemId);
                            s.addToLogs(item.SKU, "Listed with Item Id : " + generatedItemId);
                        }
                    }

                }
                if(eBayLister.Program.mainForm.listingContinue)
                    addLogStatus("Done!");
            }
            catch (Exception ex) {
                addLogStatus("ERROR : " + ex.Message);
            }
            finally{
                s.destroy();
                destroy();
            }
        }