Ejemplo n.º 1
0
        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);
        }