示例#1
0
 private void frmOutKeyTouch_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (fThread != null)
     {
         fThread.Abort();
     }
     OpticalDriver.mxCancelGetImage(0);
 }
示例#2
0
 private void frmPutKeyTouch_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (fThread != null)
     {
         fThread.Abort();
     }
     OpticalDriver.mxCancelGetImage(0);
     clsFormStatic.frmPutKey1.RefreshBtn();
 }
示例#3
0
        private void VerifyFinger_Thread()
        {
            while (true)
            {
                int    lRV         = 0;
                byte[] FingerBuf   = new byte[304 * 256]; //图像缓冲区
                byte[] tzBuf       = new byte[345];
                byte[] mbBuf       = new byte[345];
                string strFileName = "";
                try
                {
                    lRV = OpticalDriver.mxGetImage(0, FingerBuf, 5000, 1);
                    if (lRV != 0)
                    {
                        label1.Text = GetErrorInfo(lRV);
                    }
                    else
                    {
                        strFileName += "image1.bmp";
                        //图像数据流保存成bmp

                        OpticalDriver.mxSaveBMP(strFileName, FingerBuf, 256, 304);
                        //显示图像
                        // this.pictureBox1.Image = Image.FromFile(strFileName);
                        lRV = OpticalDriver.mxGetTzBase64(FingerBuf, tzBuf);
                        if (lRV != 0)
                        {
                            label1.Text = "获取指纹特征失败";
                            // return;
                        }
                        threadT = new Thread(new ThreadStart(threadA));
                        threadT.Start();
                        DataSet XiangMu2 = new SqlFile.clsSql().RunProcedure(sSqlTouch, "chaxunyundongyuanzhiwenxinxipipei", new IDataParameter[] { }, "db");
                        if (frmLoading1.InvokeRequired)                  //判断是否有其他线程想访问
                        {
                            Action act = () => { frmLoading1.Close(); }; //封装一个窗体关闭的方法
                            frmLoading1.Invoke(act);                     //在拥有该控件的线程上执行该方法
                        }
                        if (threadT != null)
                        {
                            threadT.Abort();//关闭进程释
                        }
                        threadT1 = new Thread(new ThreadStart(threadB));
                        threadT1.Start();

                        int i;
                        for (i = 0; i < XiangMu2.Tables[0].Rows.Count; i++)
                        {
                            if (XiangMu2.Tables[0].Rows[i][2].ToString().Equals("") == false)
                            {
                                mbBuf = (byte[])XiangMu2.Tables[0].Rows[i][2];
                                //验证指纹
                                lRV = OpticalDriver.mxFingerMatchBase64(mbBuf, tzBuf, 3);
                                if (lRV == 0)
                                {
                                    txtName.Text   = XiangMu2.Tables[0].Rows[i][1].ToString();
                                    txtNumber.Text = XiangMu2.Tables[0].Rows[i][0].ToString();
                                    label1.Text    = "指纹比对成功";
                                    btnOK.Enabled  = true;
                                    break;
                                }
                            }
                            if (XiangMu2.Tables[0].Rows[i][3].ToString().Equals("") == false)
                            {
                                mbBuf = (byte[])XiangMu2.Tables[0].Rows[i][3];
                                //验证指纹
                                lRV = OpticalDriver.mxFingerMatchBase64(mbBuf, tzBuf, 3);
                                if (lRV == 0)
                                {
                                    txtName.Text   = XiangMu2.Tables[0].Rows[i][1].ToString();
                                    txtNumber.Text = XiangMu2.Tables[0].Rows[i][0].ToString();
                                    label1.Text    = "指纹比对成功";
                                    btnOK.Enabled  = true;
                                    break;
                                }
                            }
                            if (XiangMu2.Tables[0].Rows[i][4].ToString().Equals("") == false)
                            {
                                mbBuf = (byte[])XiangMu2.Tables[0].Rows[i][4];
                                //验证指纹
                                lRV = OpticalDriver.mxFingerMatchBase64(mbBuf, tzBuf, 3);
                                if (lRV == 0)
                                {
                                    txtName.Text   = XiangMu2.Tables[0].Rows[i][1].ToString();
                                    txtNumber.Text = XiangMu2.Tables[0].Rows[i][0].ToString();
                                    label1.Text    = "指纹比对成功";
                                    btnOK.Enabled  = true;
                                    break;
                                }
                            }
                            if (XiangMu2.Tables[0].Rows[i][5].ToString().Equals("") == false)
                            {
                                mbBuf = (byte[])XiangMu2.Tables[0].Rows[i][5];
                                //验证指纹
                                lRV = OpticalDriver.mxFingerMatchBase64(mbBuf, tzBuf, 3);
                                if (lRV == 0)
                                {
                                    txtName.Text   = XiangMu2.Tables[0].Rows[i][1].ToString();
                                    txtNumber.Text = XiangMu2.Tables[0].Rows[i][0].ToString();
                                    label1.Text    = "指纹比对成功";
                                    btnOK.Enabled  = true;
                                    break;
                                }
                            }
                        }
                        if (i == XiangMu2.Tables[0].Rows.Count)
                        {
                            label1.Text            = "指纹比对失败";
                            txtClass.Text          = null;
                            txtName.Text           = null;
                            txtNumber.Text         = null;
                            btnOK.Enabled          = false;
                            this.pictureBox1.Image = null;
                        }
                        //pictureBox1.Image = Image.FromFile(strFileName);
                        if (frmLoading1.InvokeRequired)                  //判断是否有其他线程想访问
                        {
                            Action act = () => { frmLoading1.Close(); }; //封装一个窗体关闭的方法
                            frmLoading1.Invoke(act);                     //在拥有该控件的线程上执行该方法
                        }
                        if (threadT1 != null)
                        {
                            threadT1.Abort();//关闭进程释
                        }
                    }
                }
                catch (Exception e)
                {
                    //MessageBox.Show(this, e.Message, "异常");
                }
                finally
                {
                    lRV = OpticalDriver.mxCancelGetImage(0);
                    btnTouch.Enabled = true;
                    DataSet ds = new SqlFile.clsSql().sqlSelect3(sSqlTouch, "XueSheng", "XueHao", txtNumber.Text);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        String sClassID = ds.Tables[0].Rows[0][6].ToString();
                        pictureBox1.Image = new Bitmap(new MemoryStream((byte[])ds.Tables[0].Rows[0][1]));
                        DataSet ds1 = new SqlFile.clsSql().sqlSelect3(sSqlTouch, "BanJi", "BanJiID", sClassID);
                        txtClass.Text = ds1.Tables[0].Rows[0][1].ToString();
                        label1.Text   = null;
                    }
                    fThread.Abort();
                    // EnabledButton(true); ;
                }
            }
        }