Ejemplo n.º 1
0
        //删除当前指纹
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count == 0)
            {
                return;
            }
            else
            {
                string autoid = listView1.SelectedItems[0].Text;
                //string type = listView1.SelectedItems[0].SubItems[1].Text;
                if (MessageBox.Show("确定删除该指纹" + autoid + "?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    var s = ldb.DelFingerprint("template", int.Parse(autoid));
                    if (s)
                    {
                        MessageBox.Show("删除成功", "提示");
                        this.listView1.Items.Remove(this.listView1.SelectedItems[0]);
                    }
                    else
                    {
                        MessageBox.Show("删除失败", "提示");
                    }
                }
            }


            return;
        }
Ejemplo n.º 2
0
        protected override void DefWndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case MESSAGE_CAPTURED_OK:
            {
                MemoryStream ms = new MemoryStream();
                BitmapFormat.GetBitmap(FPBuffer, mfpWidth, mfpHeight, ref ms);
                Bitmap bmp        = new Bitmap(ms);
                bool   IsRegister = frm2.GetIsRegister();
                if (IsRegister)
                {
                    frm2.SetImg(bmp);
                    textTips.Text = "开始注册";
                    if (IsRegister)
                    {
                        int ret = zkfp.ZKFP_ERR_OK;
                        int fid = 0, score = 0;
                        ret = zkfp2.DBIdentify(mDBHandle, CapTmp, ref fid, ref score);
                        if (zkfp.ZKFP_ERR_OK == ret)
                        {
                            frm2.SetTips("当前手指已录入成功 " + fid + "!");
                            return;
                        }

                        int    userid   = frm2.GetUserId();
                        string realname = frm2.GetRealName();
                        if (userid == 0 || realname == "")
                        {
                            MessageBox.Show("请先填写学生的ID和真实姓名,Id可以从排课系统后台看到!", "提示");
                            return;
                        }

                        int fingerindex = frm2.GetFingerIndex();

                        if (RegisterCount > 0 && zkfp2.DBMatch(mDBHandle, CapTmp, RegTmps[RegisterCount - 1]) <= 0)
                        {
                            //将手指放在指纹感应器上,使用同一手指的不同区块重复此操作,直到指纹成功录入
                            frm2.SetTips("使用同一手指的不同区块重复此操作");
                            playVoice("try");
                            return;
                        }

                        Array.Copy(CapTmp, RegTmps[RegisterCount], cbCapTmp);
                        String strBase64 = zkfp2.BlobToBase64(CapTmp, cbCapTmp);
                        byte[] blob      = zkfp2.Base64ToBlob(strBase64);
                        RegisterCount++;
                        if (RegisterCount >= REGISTER_FINGER_COUNT)
                        {
                            RegisterCount = 0;
                            if (zkfp.ZKFP_ERR_OK == (ret = zkfp2.DBMerge(mDBHandle, RegTmps[0], RegTmps[1], RegTmps[2], RegTmp, ref cbRegTmp)))
                            {
                                //插入数据到本地数据库
                                int last_id = ldb.AddFingerprint(userid, fingerindex, "", strBase64, realname);
                                if (last_id != 0)
                                {
                                    if (zkfp.ZKFP_ERR_OK == (ret = zkfp2.DBAdd(mDBHandle, last_id, RegTmp)))
                                    {
                                        frm2.SetTips("指纹存储成功!");
                                        playVoice("success");
                                        MessageBox.Show("指纹存储成功!", "提示");
                                    }
                                    else
                                    {
                                        var s = ldb.DelFingerprint("template", last_id);
                                        if (!s)          //再删除一遍
                                        {
                                            ldb.DelFingerprint("template", last_id);
                                        }
                                        frm2.SetTips("指纹录入失败02");
                                        playVoice("fail");
                                        MessageBox.Show("指纹录入失败02", "提示");
                                    }
                                }
                                else
                                {
                                    frm2.SetTips("指纹存储失败!");
                                    playVoice("fail");
                                    MessageBox.Show("指纹存储失败!", "提示");
                                }
                            }
                            else
                            {
                                frm2.SetTips("指纹录入失败 code=" + ret);
                                playVoice("fail");
                            }
                            IsRegister = false;
                            return;
                        }
                        else
                        {
                            frm2.SetTips("还需按压" + (REGISTER_FINGER_COUNT - RegisterCount) + "次");
                            playVoice("try");
                        }
                    }

                    return;
                }
                else
                {
                    this.fingerprintImg.Image = bmp;
                    if (cbRegTmp <= 0)
                    {
                        textTips.Text = "指纹库指纹条数为0,请先录入指纹!";
                        playVoice("dd");
                        return;
                    }
                    if (bIdentify)
                    {        //1:1识别
                        int ret = zkfp.ZKFP_ERR_OK;
                        int fid = 0, score = 0;
                        ret = zkfp2.DBIdentify(mDBHandle, CapTmp, ref fid, ref score);
                        if (zkfp.ZKFP_ERR_OK == ret)
                        {
                            var userInfo = ldb.GetUserInfo(fid);
                            if (userInfo.Autoid == 0)
                            {
                                textTips.Text = "当前指纹已删除!";
                                return;
                            }
                            textTips.Text = "1:1指纹识别成功, 识别ID: " + fid + ",姓名:" + userInfo.Realname + ",手指:" + userInfo.Fingerindex + ",识别分数:" + score + "!";

                            //textTips.Text = f.SendGprsPrintContent("邹慧刚");c#直接发送请求给打印机
                            string resultJson = goPrint.SendPrint(userInfo.userid);        //请求golang服务器,简介发送打印请求,同时判断是否成功

                            //解析json字符串
                            var rs = JsonConvert.DeserializeObject <JsonAnooc>(resultJson);       //result为上面的Json数据
                            if (rs.status == 200)
                            {
                                textTips.Text = "发送打印请求成功!返回信息:" + resultJson;
                                playVoice("line");
                            }
                            else
                            {
                                textTips.Text = "发送打印请求失败!返回信息:" + resultJson;
                                playVoice("di");
                            }

                            return;
                        }
                        else
                        {
                            textTips.Text = "1:1指纹识别失败, 错误: " + ret;
                            return;
                        }
                    }
                    else
                    {        //1:N识别
                        int ret = zkfp2.DBMatch(mDBHandle, CapTmp, RegTmp);
                        if (0 < ret)
                        {
                            textTips.Text = "1:N指纹识别成功, score=" + ret + "!";
                            playVoice("print");
                            return;
                        }
                        else
                        {
                            textTips.Text = "1:N指纹识别失败, ret= " + ret;
                            return;
                        }
                    }
                }
            }
            break;

            default:
                base.DefWndProc(ref m);    //程序初始化,会到这里
                break;
            }
        }