public Searcher(Form1 f, ClickerModel clickerModel) { this.webBrowser = f.webBrowser1; this.statusLabel = f.statusLabel; this.clickerModel = clickerModel; string searchKey = clickerModel.KeyWord.Replace(" ", "+"); this.againSearchKey = clickerModel.KeyWord.Replace(" ", "_"); this.searchUrl = string.Format(BASE_URL, new String[] { searchKey }); this.searchFinished = false; this.clickedSuccess = false; this.isStop = false; }
public static void AddClicker(ClickerModel model) { string sql = "insert into clicker_list (product_id, operate, company_url, key_word, enabled,clicked_num,page_rank) values(@1, @2, @3, @4, @5, @6, @7)"; object[] parampters = new object[] { model.ProductId, model.Operate, model.CompanyUrl, model.KeyWord, model.Enabled, 0, 0 }; SQLiteHelper.ExecuteNonQuery(connectionString, sql, parampters); }
private void UpdateClickerModelList(DataGridView dataGridView) { DataTable dt = (DataTable)dataGridView.DataSource; for (int j = dt.Rows.Count - 1; j >= 0; j--) { DataRow dr = dt.Rows[j]; ClickerModel model = new ClickerModel(); model.Id = (Int64)dr[0]; model.Operate = (bool)dr[1]; model.CompanyUrl = (string)dr[2]; model.KeyWord = (string)dr[3]; model.ProductId = (string)dr[4]; model.Enabled = (bool)dr[5]; model.ClickedNum = (Int64)dr[6]; model.PageRank = (Int64)dr[7]; DAO.UpdateClicker(model); } }
private void addBtn_Click(object sender, EventArgs e) { ClickerModel model = new ClickerModel(); model.CompanyUrl = companyText.Text; model.KeyWord = keywordText.Text; model.ProductId = productidtext.Text; if ("".Equals(model.CompanyUrl.Trim()) || "".Equals(model.KeyWord.Trim()) || "".Equals(model.ProductId.Trim())) { MessageBox.Show("Company Site, KeyWord and Product Id is required."); return; } model.Operate = false; model.Enabled = true; DAO.AddClicker(model); ReadData(dataGridView1); Log.Debug("add new row to table."); model = null; }
public void UpdateDataView(DataTable kwDataTable, ClickerModel model) { foreach (DataRow dr in kwDataTable.Rows) { long id = (Int64)dr[0]; if (id == model.Id) { dr[6] = model.ClickedNum; dr[7] = model.PageRank; } } }
public static IList<ClickerModel> GetClickerModelList() { string sql = "select id,operate,company_url,key_word,product_id,enabled,clicked_num,page_rank from clicker_list"; DataSet ds = SQLiteHelper.ExecuteDataSet(connectionString, sql, null); IList<ClickerModel> list = new List<ClickerModel>(); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { ClickerModel model = null; foreach (DataRow dr in ds.Tables[0].Rows) { model = new ClickerModel(); model.Id = (Int64)dr[0]; model.Operate = (bool)dr[1]; model.CompanyUrl = (string)dr[2]; model.KeyWord = (string)dr[3]; model.ProductId = (string)dr[4]; model.Enabled = (bool)dr[5]; model.ClickedNum = (Int64)dr[6]; model.PageRank = (Int64)dr[7]; list.Add(model); } model = null; } return list; }
public static int UpdateClicker(ClickerModel model) { string sql = "update clicker_list set product_id = @product_id, company_url = @company_url, key_word = @key_word, enabled = @enabled ,clicked_num = @clicked_num ,page_rank = @page_rank where id= @id"; object[] parampters = new object[] { model.ProductId, model.CompanyUrl, model.KeyWord, model.Enabled, model.ClickedNum, model.PageRank, model.Id }; return SQLiteHelper.ExecuteNonQuery(connectionString, sql, parampters); }