private void btnDownloadByLink_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(iDTextEdit.Text)) { ImageProductInfo product = new ImageProductInfo(); product.Id = Common.Obj2Int64(iDTextEdit.Text); product.ImageUrls = imageUrlsTextEdit.Text; string message = string.Empty; if (CommonDownloadImage.DownloadImageProduct(product, _producerUpdateImageIdSql, ref message)) { rbMessage.AppendText(string.Format("ProductId {0} success", product.Id) + System.Environment.NewLine); } else { rbMessage.AppendText(string.Format("ProductId {0} success fails: {1}", product.Id, message) + System.Environment.NewLine); } } }
private void btnChooseFile_Click(object sender, EventArgs e) { DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { lblPath.Text = openFileDialog1.FileName; string path = openFileDialog1.FileName; if (!string.IsNullOrEmpty(path)) { ImageProductInfo product = new ImageProductInfo(); product.Id = Common.Obj2Int64(iDTextEdit.Text); string message = string.Empty; if (CommonDownloadImage.UploadImageProductByHand(path, product, _producerUpdateImageIdSql, ref message)) { rbMessage.AppendText(string.Format("ProductId {0} success", product.Id) + System.Environment.NewLine); } else { rbMessage.AppendText(string.Format("ProductId {0} success fails: {1}", product.Id, message) + System.Environment.NewLine); } } } }
private void DownloadImageWithCompany(long idCompany) { this.Invoke(new Action(() => { rbSuccess.AppendText(string.Format("Start get from Database with CompanyId = {0}", idCompany) + System.Environment.NewLine); })); try { if (idCompany == 6619858476258121218) { this.Invoke(new Action(() => { rbSuccess.AppendText("STOP download with ID = 6619858476258121218"); })); return; //productTableAdapter.FillBy_CompanyRootProductNotImageId(dBWss.Product); } else if (checkEditReloadAll.Checked) { productTableAdapter.FillAllBy_CompanyAndValid(dBWss.Product, idCompany, true); } else { productTableAdapter.FillBy_CompanyAndValidAndImageId(dBWss.Product, idCompany, true); } } catch (Exception ex) { this.Invoke(new Action(() => { rbFail.AppendText("Get data product from SQL error:" + System.Environment.NewLine + ex.ToString() + System.Environment.NewLine); })); } if (dBWss.Product.Rows.Count > 0) { this.Invoke(new Action(() => { lbCount.Text = dBWss.Product.Rows.Count.ToString(); rbSuccess.AppendText(string.Format("Get {1} product need download from Database with CompanyId = {0}", idCompany, dBWss.Product.Rows.Count) + System.Environment.NewLine); })); var producerUpdateImageIdSql = new ProducerBasic(_rabbitMqServer, ConfigImages.ImboExchangeImages, ConfigImages.ImboRoutingKeyUploadImageIdSql); int success = 0; int fail = 0; for (int i = 0; i < dBWss.Product.Rows.Count; i++) { ImageProductInfo product = new ImageProductInfo(); product.Id = Common.Obj2Int64(dBWss.Product.Rows[i]["ID"]); product.ImageUrls = dBWss.Product.Rows[i]["ImageUrls"].ToString(); string message = string.Empty; if (CommonDownloadImage.DownloadImageProduct(product, producerUpdateImageIdSql, ref message)) { success++; this.Invoke(new Action(() => { lbSuccess.Text = success.ToString(); rbSuccess.AppendText(string.Format("CompanyId = {0}: {1}/{2} success", idCompany, i, dBWss.Product.Count) + System.Environment.NewLine); })); } else { this.Invoke(new Action(() => { rbSuccess.AppendText(string.Format("CompanyId = {0}: {1}/{2} fails", idCompany, i, dBWss.Product.Count) + System.Environment.NewLine); })); fail++; this.Invoke(new Action(() => { if (rbFail.TextLength > 1000000) { rbFail.Clear(); } lbFails.Text = fail.ToString(); rbFail.AppendText(string.Format("CompanyId = {0}: {1}/{2} {4} fails: {3}", idCompany, i, dBWss.Product.Count, message, product.ImageUrls) + System.Environment.NewLine); rbListIdFails.AppendText(product.Id + System.Environment.NewLine); })); } } this.Invoke(new Action(() => { rbSuccess.AppendText(string.Format("CompanyId = {0} downloaded {1}/{2} image", idCompany, success, dBWss.Product.Count) + System.Environment.NewLine); })); } else { this.Invoke(new Action(() => { rbSuccess.AppendText(string.Format("CompanyId {0} 0 product download image", idCompany) + System.Environment.NewLine); })); } }