RequestBean getNextRequest() { Monitor.Enter(this); RequestBean bean = null; int modenId = -1; string portName = null; for (int i = 0; i < portNameDataGridView.RowCount - 1; i++) { if ("free" == (string)portNameDataGridView.Rows [i].Cells [1].Value) { portName = (string)portNameDataGridView.Rows [i].Cells [0].Value; modenId = i; break; } } bean = new RequestBean(); bean.modenId = modenId; bean.portName = portName; bean.batchId = 1; bean.mobileId = 1; bean.mobile = "18601345193"; Monitor.Exit(this); return(bean); if (modenId != -1 && portName != null) { MySQLConnection conn = getConn(); string sqlstr = "select * from ring_request where doing=0 order by priority desc,time limit 1"; MySQLCommand comm = new MySQLCommand(sqlstr, conn); MySQLDataReader dbReader = comm.ExecuteReaderEx(); if (dbReader.Read()) { portNameDataGridView.Rows [modenId].Cells [1].Value = "准备中....."; string sqlstr2 = "update ring_request set doing=1 where id=" + dbReader.GetInt32(0); MySQLCommand comm2 = new MySQLCommand(sqlstr2, conn); comm2.ExecuteNonQuery(); bean = new RequestBean(); bean.modenId = modenId; bean.portName = portName; bean.batchId = dbReader.GetInt32(1); bean.mobileId = dbReader.GetInt32(0); bean.mobile = dbReader.GetString(2); } dbReader.Close(); } Monitor.Exit(this); return(bean); }
private void reRing(RequestBean req) { MySQLConnection conn = getConn(); string sqlstr2 = "update ring_request set doing=0 where id=" + req.mobileId; MySQLCommand comm2 = new MySQLCommand(sqlstr2, conn); comm2.ExecuteNonQuery(); }
private void deleteRequest(RequestBean req) { MySQLConnection conn = getConn(); string sqlstr = "delete from ring_request where id=" + req.mobileId; MySQLCommand comm = new MySQLCommand(sqlstr, conn); comm.ExecuteNonQuery(); }
private void saveResult(RequestBean req, string ringState) { MySQLConnection conn = getConn(); string sqlstr = "insert into ring_state set " + "batch_id=" + req.batchId + ",mobile='" + req.mobile + "',status='" + ringState + "',moden_port='" + req.portName + "',time=now()"; MySQLCommand comm = new MySQLCommand(sqlstr, conn); comm.ExecuteNonQuery(); }
public void finishTestHandler(RequestBean req, string ringState, bool hasError) { Monitor.Enter(this); try { log(req.portName + "完成测试:" + req.mobile + " 状态:" + ringState); if (hasError) { reRing(req); log(req.mobile + "重回拨测队列。"); errorModenCount.Text = int.Parse(errorModenCount.Text) + 1 + ""; } else { saveResult(req, ringState); deleteRequest(req); log(req.mobile + "保存结果,从拨测队列删除。"); portNameDataGridView.Rows [req.modenId].Cells [1].Value = "free"; } //多余的显示 DataGridViewRow d = new DataGridViewRow(); d.CreateCells(ringStatusGridView, req.mobile, ringState, Environment.TickCount); ringStatusGridView.Rows.Insert(0, d); if (ringStatusGridView.Rows.Count - 1 > 500) { ringStatusGridView.Rows.RemoveAt(500); } if (ringStatusGridView.Rows.Count > 2) { Console.WriteLine(ringStatusGridView.Rows [ringStatusGridView.Rows.Count - 2].Cells [2].Value); long time = Environment.TickCount - long.Parse(ringStatusGridView.Rows [ringStatusGridView.Rows.Count - 2].Cells [2].Value.ToString()); double speed = (ringStatusGridView.Rows.Count - 1) / (time / 1000.00 / 60.00); speedLabel.Text = speed.ToString("0.00") + "条/分"; } } catch (Exception e) { log(e.Message); } Monitor.Exit(this); }
public void finishTestHandler(RequestBean req, string ringState, bool hasError) { Monitor.Enter (this); try { log (req.portName + "完成测试:" + req.mobile + " 状态:" + ringState); if (hasError) { reRing (req); log (req.mobile + "重回拨测队列。"); errorModenCount.Text = int.Parse (errorModenCount.Text) + 1 + ""; } else { saveResult (req, ringState); deleteRequest (req); log (req.mobile + "保存结果,从拨测队列删除。"); portNameDataGridView.Rows [req.modenId].Cells [1].Value = "free"; } //多余的显示 DataGridViewRow d = new DataGridViewRow (); d.CreateCells (ringStatusGridView, req.mobile, ringState, Environment.TickCount); ringStatusGridView.Rows.Insert (0, d); if (ringStatusGridView.Rows.Count - 1 > 500) { ringStatusGridView.Rows.RemoveAt (500); } if (ringStatusGridView.Rows.Count > 2) { Console.WriteLine (ringStatusGridView.Rows [ringStatusGridView.Rows.Count - 2].Cells [2].Value); long time = Environment.TickCount - long.Parse (ringStatusGridView.Rows [ringStatusGridView.Rows.Count - 2].Cells [2].Value.ToString ()); double speed = (ringStatusGridView.Rows.Count - 1) / (time / 1000.00 / 60.00); speedLabel.Text = speed.ToString ("0.00") + "条/分"; } } catch (Exception e) { log (e.Message); } Monitor.Exit (this); }
public RingThread(RequestBean bean, Form1 form1) { this.bean = bean; this.form1 = form1; }
public RingThread(RequestBean bean,Form1 form1) { this.bean = bean; this.form1 = form1; }
private void saveResult(RequestBean req, string ringState) { MySQLConnection conn = getConn (); string sqlstr = "insert into ring_state set " + "batch_id=" + req.batchId + ",mobile='" + req.mobile + "',status='" + ringState + "',moden_port='" + req.portName + "',time=now()"; MySQLCommand comm = new MySQLCommand (sqlstr, conn); comm.ExecuteNonQuery (); }
private void reRing(RequestBean req) { MySQLConnection conn = getConn (); string sqlstr2 = "update ring_request set doing=0 where id=" + req.mobileId; MySQLCommand comm2 = new MySQLCommand (sqlstr2, conn); comm2.ExecuteNonQuery (); }
RequestBean getNextRequest() { Monitor.Enter (this); RequestBean bean = null; int modenId = -1; string portName = null; for (int i = 0; i < portNameDataGridView.RowCount - 1; i++) { if ("free" == (string)portNameDataGridView.Rows [i].Cells [1].Value) { portName = (string)portNameDataGridView.Rows [i].Cells [0].Value; modenId = i; break; } } bean = new RequestBean (); bean.modenId = modenId; bean.portName = portName; bean.batchId = 1; bean.mobileId = 1; bean.mobile = "18601345193"; Monitor.Exit (this); return bean; if (modenId != -1 && portName != null) { MySQLConnection conn = getConn (); string sqlstr = "select * from ring_request where doing=0 order by priority desc,time limit 1"; MySQLCommand comm = new MySQLCommand (sqlstr, conn); MySQLDataReader dbReader = comm.ExecuteReaderEx (); if (dbReader.Read ()) { portNameDataGridView.Rows [modenId].Cells [1].Value = "准备中....."; string sqlstr2 = "update ring_request set doing=1 where id=" + dbReader.GetInt32 (0); MySQLCommand comm2 = new MySQLCommand (sqlstr2, conn); comm2.ExecuteNonQuery (); bean = new RequestBean (); bean.modenId = modenId; bean.portName = portName; bean.batchId = dbReader.GetInt32 (1); bean.mobileId = dbReader.GetInt32 (0); bean.mobile = dbReader.GetString (2); } dbReader.Close (); } Monitor.Exit (this); return bean; }
private void deleteRequest(RequestBean req) { MySQLConnection conn = getConn (); string sqlstr = "delete from ring_request where id=" + req.mobileId; MySQLCommand comm = new MySQLCommand (sqlstr, conn); comm.ExecuteNonQuery (); }