コード例 #1
0
 /// <summary>
 /// 关闭窗体
 /// </summary>
 private bool FormClose()
 {
     if (b)
     {
         threadLoading = new Thread(new ThreadStart(s));
         threadLoading.IsBackground = true;
         threadLoading.Start();
         String str = new SqlFile.clsSql().sqlOpen1(sSqlTouch);
         if (frmLoading1.InvokeRequired)                  //判断是否有其他线程想访问
         {
             Action act = () => { frmLoading1.Close(); }; //封装一个窗体关闭的方法
             frmLoading1.Invoke(act);                     //在拥有该控件的线程上执行该方法
         }
         if (threadLoading != null)
         {
             threadLoading.Abort();
         }
         if (str == "")
         {
             b = false;
         }
         else
         {
             MessageBox.Show(str);
             return(false);
         }
     }
     if (clsFormStatic.frmInfo1 != null)
     {
         clsFormStatic.frmInfo1.Close();
         clsFormStatic.frmInfo1 = null;
     }
     if (clsFormStatic.frmPhoto1 != null)
     {
         clsFormStatic.frmPhoto1.Close();
         clsFormStatic.frmPhoto1 = null;
     }
     if (clsFormStatic.frmTouch1 != null)
     {
         clsFormStatic.frmTouch1.Close();
         clsFormStatic.frmTouch1 = null;
     }
     return(true);
 }
コード例 #2
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;
                        }
                        DataSet XiangMu4 = null;
                        if (!clsFormStatic.frmTouch1.sBanji.Equals(""))
                        {
                            threadT = new Thread(new ThreadStart(threadA));
                            threadT.Start();
                            SqlParameter jj = new SqlParameter("@BanjiID", clsFormStatic.frmTouch1.sBanji);
                            XiangMu4 = new SqlFile.clsSql().RunProcedure(sSqlTouch, "chaxunyundongyuanzhiwenxinxipipeibanji", new IDataParameter[] { jj }, "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;
                        if (XiangMu4 != null)
                        {
                            for (i = 0; i < XiangMu4.Tables[0].Rows.Count; i++)
                            {
                                if (XiangMu4.Tables[0].Rows[i][2].ToString().Equals("") == false)
                                {
                                    mbBuf = (byte[])XiangMu4.Tables[0].Rows[i][2];
                                    //验证指纹
                                    lRV = OpticalDriver.mxFingerMatchBase64(mbBuf, tzBuf, 3);
                                    if (lRV == 0)
                                    {
                                        label1.Text       = "  指纹比对成功!";
                                        lblNumber.Text    = XiangMu4.Tables[0].Rows[i][0].ToString();
                                        lblName.Text      = XiangMu4.Tables[0].Rows[i][1].ToString();
                                        pictureBox1.Image = Image.FromFile(strFileName);
                                        SelectImage(XiangMu4.Tables[0].Rows[i][0].ToString());
                                        goto gg;
                                    }
                                }
                                if (XiangMu4.Tables[0].Rows[i][3].ToString().Equals("") == false)
                                {
                                    mbBuf = (byte[])XiangMu4.Tables[0].Rows[i][3];
                                    //验证指纹
                                    lRV = OpticalDriver.mxFingerMatchBase64(mbBuf, tzBuf, 3);
                                    if (lRV == 0)
                                    {
                                        label1.Text       = "  指纹比对成功!";
                                        lblNumber.Text    = XiangMu4.Tables[0].Rows[i][0].ToString();
                                        lblName.Text      = XiangMu4.Tables[0].Rows[i][1].ToString();
                                        pictureBox1.Image = Image.FromFile(strFileName);
                                        SelectImage(XiangMu4.Tables[0].Rows[i][0].ToString());
                                        goto gg;
                                    }
                                }
                                if (XiangMu4.Tables[0].Rows[i][4].ToString().Equals("") == false)
                                {
                                    mbBuf = (byte[])XiangMu4.Tables[0].Rows[i][4];
                                    //验证指纹
                                    lRV = OpticalDriver.mxFingerMatchBase64(mbBuf, tzBuf, 3);
                                    if (lRV == 0)
                                    {
                                        label1.Text       = "  指纹比对成功!";
                                        lblNumber.Text    = XiangMu4.Tables[0].Rows[i][0].ToString();
                                        lblName.Text      = XiangMu4.Tables[0].Rows[i][1].ToString();
                                        pictureBox1.Image = Image.FromFile(strFileName);
                                        SelectImage(XiangMu4.Tables[0].Rows[i][0].ToString());
                                        goto gg;
                                    }
                                }
                                if (XiangMu4.Tables[0].Rows[i][5].ToString().Equals("") == false)
                                {
                                    mbBuf = (byte[])XiangMu4.Tables[0].Rows[i][5];
                                    //验证指纹
                                    lRV = OpticalDriver.mxFingerMatchBase64(mbBuf, tzBuf, 3);
                                    if (lRV == 0)
                                    {
                                        label1.Text       = "  指纹比对成功!";
                                        lblNumber.Text    = XiangMu4.Tables[0].Rows[i][0].ToString();
                                        lblName.Text      = XiangMu4.Tables[0].Rows[i][1].ToString();
                                        pictureBox1.Image = Image.FromFile(strFileName);
                                        SelectImage(XiangMu4.Tables[0].Rows[i][0].ToString());
                                        goto gg;
                                    }
                                }
                            }
                        }
                        if (frmLoading1.InvokeRequired)                  //判断是否有其他线程想访问
                        {
                            Action act = () => { frmLoading1.Close(); }; //封装一个窗体关闭的方法
                            frmLoading1.Invoke(act);                     //在拥有该控件的线程上执行该方法
                        }
                        if (threadT1 != null)
                        {
                            threadT1.Abort();//关闭进程释
                        }
                        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();//关闭进程释
                        }
                        threadT = new Thread(new ThreadStart(threadB));
                        threadT.Start();
                        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)
                                {
                                    label1.Text       = "  指纹比对成功!";
                                    lblNumber.Text    = XiangMu2.Tables[0].Rows[i][0].ToString();
                                    lblName.Text      = XiangMu2.Tables[0].Rows[i][1].ToString();
                                    pictureBox1.Image = Image.FromFile(strFileName);
                                    SelectImage(XiangMu2.Tables[0].Rows[i][0].ToString());
                                    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)
                                {
                                    label1.Text       = "  指纹比对成功!";
                                    lblNumber.Text    = XiangMu2.Tables[0].Rows[i][0].ToString();
                                    lblName.Text      = XiangMu2.Tables[0].Rows[i][1].ToString();
                                    pictureBox1.Image = Image.FromFile(strFileName);
                                    SelectImage(XiangMu2.Tables[0].Rows[i][0].ToString());
                                    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)
                                {
                                    label1.Text       = "  指纹比对成功!";
                                    lblNumber.Text    = XiangMu2.Tables[0].Rows[i][0].ToString();
                                    lblName.Text      = XiangMu2.Tables[0].Rows[i][1].ToString();
                                    pictureBox1.Image = Image.FromFile(strFileName);
                                    SelectImage(XiangMu2.Tables[0].Rows[i][0].ToString());
                                    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)
                                {
                                    label1.Text       = "  指纹比对成功!";
                                    lblNumber.Text    = XiangMu2.Tables[0].Rows[i][0].ToString();
                                    lblName.Text      = XiangMu2.Tables[0].Rows[i][1].ToString();
                                    pictureBox1.Image = Image.FromFile(strFileName);
                                    SelectImage(XiangMu2.Tables[0].Rows[i][0].ToString());
                                    break;
                                }
                            }
                        }

                        if (i == XiangMu2.Tables[0].Rows.Count)
                        {
                            label1.Text            = "指纹比对失败";
                            this.pictureBox1.Image = Image.FromFile(strFileName);
                            lblNumber.Text         = "Null";
                            lblName.Text           = "Null";
                            lblClass.Text          = "Null";
                            lblImage.Visible       = true;
                            pictureBox2.Image      = null;
                        }
                        else
                        {
                            pictureBox1.Image = Image.FromFile(strFileName);
                        }
                        gg :;
                        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);
                    btnSelect.Enabled = true;
                    fThread.Abort();
                    // EnabledButton(true); ;
                }
            }
        }