Exemplo n.º 1
0
        private void GetDBProducts()
        {
            try
            {
                var con = DBConnection.Instance();
                con.DatabaseName = con.DatabaseName;
                if (con.IsConnect(conModel))
                {
                    string query  = "SELECT p.product_id, gg_id, quantity, price FROM " + conModel.productTable + " p LEFT JOIN " + conModel.ggProductTable + " ggp ON (p.product_id = ggp.product_id)";
                    var    cmd    = new MySqlCommand(query, con.Connection);
                    var    reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        ProductGG p = new ProductGG();
                        p.ProductId = reader["product_id"].ToString();
                        p.GgId      = reader["gg_id"].ToString();
                        p.Price     = double.Parse(reader["price"].ToString());
                        p.Quantity  = int.Parse(reader["quantity"].ToString());

                        productsFromDB.Add(p);
                    }
                }

                lblDbProductCount.Text = productsFromDB.Count.ToString();
                lblReadDataStatus.Text = "Completed";

                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error no: 11 - Get products from db. Message: " + ex.Message);
            }
        }
Exemplo n.º 2
0
        private void GetGGProducts()
        {
            try
            {
                List <string> listOfCategories = new List <string>();

                int pageSize         = 100;
                int currentPageCount = 0;

                var productService = ServiceProvider.getProductService();
                while (true)
                {
                    /*
                     * A - Aktif Şatışlar
                     * L - Yeni Listelenenler
                     * S - Satılan Ürünler
                     * U - Satılmayan Ürünler
                     * R - Yeniden Listelenenler
                     */
                    List <productDetailType> pDetailsResult = productService.getProducts(currentPageCount * pageSize, pageSize, "A", true, "tr").products.ToList();

                    foreach (productDetailType item in pDetailsResult)
                    {
                        ProductGG p = new ProductGG();
                        p.GgId     = item.productId.ToString();
                        p.Quantity = item.product.productCount;
                        p.Price    = item.product.buyNowPrice;

                        // Update UI
                        UpdateCurrentGGProduct(item.product.title);

                        productsFromGG.Add(p);
                    }

                    if (pDetailsResult.Count < 100)
                    {
                        break;
                    }
                    else
                    {
                        currentPageCount++;
                    }

                    // Update UI
                    UpdateGgProductCount(productsFromGG.Count.ToString());
                }

                // Update UI for last time
                UpdateGgProductCount(productsFromGG.Count.ToString());

                // Fetch products from db
                GetDBProducts();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error no: 10 - Get products from gg. Message: " + ex.Message);
            }
        }
Exemplo n.º 3
0
        private void BtnUpdatePrice_Click(object sender, System.EventArgs e)
        {
            if (productsFromDB.Count == 0 || productsFromGG.Count == 0)
            {
                MessageBox.Show("Error no: 14 - Please go to 2.Read Data first!");
            }
            else
            {
                btnUpdatePrice.Enabled = false;
                foreach (ProductGG item in productsFromGG)
                {
                    ProductGG pon = productsFromDB.Find(p => p.GgId == item.GgId);
                    if (pon != null)
                    {
                        if (pon.Price != item.Price) // fiyat değişmisse güncellenecekler listesine ekle
                        {
                            productsWillPriceUpdate.Add(pon);
                        }
                    }
                }

                if (productsWillPriceUpdate.Count > 0)
                {
                    // show total count
                    lblPriceCount.Text = productsWillPriceUpdate.Count.ToString();

                    threadUpdatePrices = new Thread(new ThreadStart(UpdatePrices));
                    threadUpdatePrices.Start();
                }
                else
                {
                    lblUpdatePriceStatus.Text = "All products are up-to-date : )";
                    MessageBox.Show("All products are up-to-date : )");
                }
            }
        }