private void ClickPushToDownloadImage(object sender, EventArgs e) { int countData = 0; var lstProductGroup = eventGetProductIDs(); var pa = new ProductAdapter(new SqlDb(QT.Entities.Server.ConnectionString)); MQPushDownloadImage mqPushDownloadImage = new MQPushDownloadImage(); for (int i = 0; i < lstProductGroup.Count; i++) { var lstProductIds = lstProductGroup.ElementAt(i).Value; foreach (var product in pa.GetProductEntitieBy(lstProductIds)) { countData++; mqPushDownloadImage.PushQueueChangeChangeImage(new ImageProductInfo(product.ID, product.Name, product.DetailUrl, product.ImageUrl, product.IsNews)); } } MessageBox.Show(string.Format("Pushed {0} message", countData)); }
private void btnFixImageLInk_Click(object sender, EventArgs e) { MQPushDownloadImage rabbitMqPushDownloadImage = new MQPushDownloadImage(RabbitMQManager.GetRabbitMQServer(ConfigRun.KeyRabbitMqProduct)); string strCompanyID = txtCompany.Text; Task.Factory.StartNew(new Action(() => { this.Invoke(new Action(() => { this.btnFixImageLInk.Visible = false; })); ProductAdapter productAdapter = new ProductAdapter(new SqlDb(QT.Entities.Server.ConnectionString)); DataTable tblCompany = productAdapter.GetCompanyCrawler(strCompanyID); for (int iRowCompany = 0; iRowCompany < tblCompany.Rows.Count; iRowCompany++) { DataRow rowCompany = tblCompany.Rows[iRowCompany]; long CompanyID = QT.Entities.Common.Obj2Int64(rowCompany["ID"]); string Domain = QT.Entities.Common.Obj2String(rowCompany["Domain"]); DataTable tblProduct = productAdapter.GetProductFixImage(CompanyID); foreach (DataRow rowInfo in tblProduct.Rows) { long ProductID = QT.Entities.Common.Obj2Int64(rowInfo["ID"]); string newImage = QT.Entities.Common.FixParalinkImage(rowInfo["ImageUrls"].ToString()); productAdapter.UpdateImageForProduct(ProductID, newImage); //rabbitMqPushDownloadImage.PushQueueChangeChangeImage(new Entities.MqChangeImage() //{ // ProductID = ProductID, // Type = 2 //}); } this.Invoke(new Action(() => { this.richTextBox1.AppendText(string.Format("\r\n Push {0} Product for Company {1} - {2}/{3}", tblProduct.Rows.Count, CompanyID , iRowCompany, tblCompany.Rows.Count)); })); } this.Invoke(new Action(() => { this.btnFixImageLInk.Visible = true; })); })); }