private void PushAllCompany() { DataTable tblCompany = productAdapter.GetCompanyCrawler(); foreach (DataRow rowCompany in tblCompany.Rows) { long CompanyID = QT.Entities.Common.Obj2Int64(rowCompany["ID"]); string Domain = QT.Entities.Common.Obj2String(rowCompany["Domain"]); PushCacheForCompany(CompanyID, Domain); } }
public void Run() { ProductAdapter productAdapter = new ProductAdapter(new SqlDb(QT.Entities.Server.ConnectionString)); Queue <long> queueCompany = new Queue <long>(); DataTable tblCompany = productAdapter.GetCompanyCrawler(); foreach (DataRow rowCom in tblCompany.Rows) { queueCompany.Enqueue(Convert.ToInt64(rowCom["ID"])); } for (int i = 0; i < 30; i++) { } }
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; })); })); }
private void btnPushCheckDumplicate_Click(object sender, EventArgs e) { string strDomain = this.txtCompanyID.Text; ProductAdapter productAdapter = new ProductAdapter(new SqlDb(QT.Entities.Server.ConnectionString)); Task.Factory.StartNew(new Action(() => { this.Invoke(new Action(() => { try { richTextBox1.AppendText("\r\nStart push!"); } catch (Exception ex01) { } })); SqlDb sqldb = new SqlDb(QT.Entities.Server.ConnectionString); DataTable comTable = productAdapter.GetCompanyCrawler(strDomain); DataTable proTable = new DataTable(); for (int i = 0; i < comTable.Rows.Count; i++) { long CompanyID = QT.Entities.Common.Obj2Int64(comTable.Rows[i]["ID"].ToString()); string Domain = QT.Entities.Common.Obj2String(comTable.Rows[i]["Domain"]).ToString(); long lastProduct = 0; do { for (int j = 0; j < proTable.Rows.Count; j++) { try { long ProductID = QT.Entities.Common.Obj2Int64(proTable.Rows[j]["ID"].ToString()); lastProduct = ProductID; int InStock = QT.Entities.Common.Obj2Int(proTable.Rows[j]["InStock"].ToString()); bool Valid = QT.Entities.Common.Obj2Bool(proTable.Rows[j]["Valid"].ToString()); long Price = QT.Entities.Common.Obj2Int64(proTable.Rows[j]["Price"].ToString()); string Name = QT.Entities.Common.Obj2String(proTable.Rows[j]["Name"].ToString()); bool IsNew = QT.Entities.Common.Obj2Bool(proTable.Rows[j]["IsNews"]); string ImageUrl = proTable.Rows[j]["ImageUrls"].ToString(); bool IsDeal = QT.Entities.Common.Obj2Bool(proTable.Rows[j]["IsDeal"].ToString()); long CategoryID = QT.Entities.Common.Obj2Int64(proTable.Rows[j]["ClassificationID"].ToString()); QT.Moduls.CrawlerProduct.Cache.RedisCheckDuplicateAdapter.Instace().SetCheckDuplicate(CompanyID, ProductID, Domain, Price, Name, ImageUrl, Valid); } catch (Exception ex01) { log.Error(ex01); } } this.Invoke(new Action(() => { try { richTextBox1.AppendText(string.Format("\r\nPushed {0} item for company {1} :", proTable.Rows.Count, CompanyID.ToString())); } catch (Exception ex01) { } })); proTable = sqldb.GetTblData(@"SELECT 50000 InStock, ID, ClassificationID, Status, Valid, Price, Name, ImageUrls, IsDeal, IsNews FROM Product WHERE (Company = @CompanyID) AND (ID > @IDBegin) AND Valid = 1 ORDER BY ID" , CommandType.Text, new System.Data.SqlClient.SqlParameter[] { SqlDb.CreateParamteterSQL("CompanyID", CompanyID, SqlDbType.BigInt), SqlDb.CreateParamteterSQL("IDBegin", lastProduct, SqlDbType.BigInt) }, null, true); } while (proTable.Rows.Count > 0); this.Invoke(new Action(() => { try { richTextBox1.AppendText(string.Format("\r\n Success compnay:{0} {1}/{2}", CompanyID, i, comTable.Rows.Count)); } catch (Exception ex01) { } })); log.Info(CompanyID); } MessageBox.Show("Done"); })); }