Esempio n. 1
0
        private static void BGW_Enroll_DoWork(object sender, DoWorkEventArgs e)
        {
            // get arguments from list
            List <object> genericlist   = e.Argument as List <object>;
            RichTextBox   rtb_status    = (RichTextBox)genericlist[0];
            RichTextBox   rtb_log       = (RichTextBox)genericlist[1];
            PictureBox    pb            = (PictureBox)genericlist[2];
            RichTextBox   rtb_id        = (RichTextBox)genericlist[3];
            ComboBox      cb            = (ComboBox)genericlist[4];
            CheckBox      chk           = (CheckBox)genericlist[5];
            RichTextBox   rtb_privilege = (RichTextBox)genericlist[6];
            bool          save_img      = ui.ReadCheckBox(chk);

            CheckBox    chk_https = (CheckBox)genericlist[7];
            RichTextBox rtb_ip    = (RichTextBox)genericlist[8];
            RichTextBox rtb_port  = (RichTextBox)genericlist[9];

            ui.ClearLog(rtb_log);

            //ask API.dll to provide finger data
            fp_operation fp = new fp_operation();

            fp.DeviceConnect(rtb_log);
            fp.Get_EnrollEx_Encrypted(save_img, pb, rtb_status, rtb_log);
            fp.DeviceDisconnect(rtb_log);

            string id = ui.ReadText(rtb_id);
            int    fp_idx;

            int.TryParse(ui.ReadComboBox(cb), out fp_idx);

            int privilege;

            int.TryParse(ui.ReadText(rtb_privilege), out privilege);


            //feed finger data to to remote "redirect server"
            srv_operation srv         = new srv_operation();
            string        encMinutiae = BitConverter.ToString(fp.EncryptedMinutiae).Replace("-", "");
            string        eSkey       = BitConverter.ToString(fp.EncryptedSessionKey).Replace("-", "");
            string        iv          = BitConverter.ToString(fp.piv).Replace("-", "");

            string json_str = srv.BuildJson_Enroll(encMinutiae, eSkey, iv, id, fp_idx, privilege);

            bool   https_en = ui.ReadCheckBox(chk_https);
            string ip       = ui.ReadText(rtb_ip);
            string port     = ui.ReadText(rtb_port);
            string srv_rtn  = srv.Srv_Enroll(json_str, https_en, ip, port);

            ui.AddLog(rtb_log, "Send server = " + json_str);
            ui.AddLog(rtb_log, "server return = " + srv_rtn);

            ui.ShowStatus(rtb_status, "Enroll finished");
        }
        private static void BGW_File_Match_DoWork(object sender, DoWorkEventArgs e)
        {
            // get arguments from list
            List <object> genericlist   = e.Argument as List <object>;
            RichTextBox   rtb_status    = (RichTextBox)genericlist[0];
            RichTextBox   rtb_log       = (RichTextBox)genericlist[1];
            PictureBox    pb            = (PictureBox)genericlist[2];
            RichTextBox   rtb_id        = (RichTextBox)genericlist[3];
            ComboBox      cb            = (ComboBox)genericlist[4];
            CheckBox      chk           = (CheckBox)genericlist[5];
            RichTextBox   rtb_privilege = (RichTextBox)genericlist[6];
            bool          save_img      = ui.ReadCheckBox(chk);

            CheckBox    chk_https = (CheckBox)genericlist[7];
            RichTextBox rtb_ip    = (RichTextBox)genericlist[8];
            RichTextBox rtb_port  = (RichTextBox)genericlist[9];

            string filename = (string)genericlist[10];

            ui.ClearLog(rtb_log);

            ui.AddLog(rtb_log, "select file path=" + filename);
            Bitmap img = new Bitmap(filename);


            ui.ShowImage(pb, img);

            if (save_img == true)
            {
                Bitmap clone = img.Clone(new Rectangle(0, 0, img.Width, img.Height), img.PixelFormat);
                clone.Save("temp.bmp");
                clone.Dispose();
            }


            fp_operation fp      = new fp_operation();
            int          connect = fp.DeviceConnect(rtb_log);

            if (connect != 0)
            {
                fp.Image_Match_to_LST(save_img, pb, rtb_status, rtb_log, img);
                fp.DeviceDisconnect(rtb_log);
            }

            //ui.ShowStatus(rtb_status, "Match finished");
        }