private async void DoCollect( )
        {
            fgCollectFingerprint cmd = null;

            // First collect
            this.Title = "请扫描指纹";
first:
            brdOne.Background   = new SolidColorBrush(Colors.LightBlue);
            brdTwo.Background   = new SolidColorBrush(Colors.White);
            brdThree.Background = new SolidColorBrush(Colors.White);
            while (true)
            {
                cmd          = new fgCollectFingerprint(1, _fid, 1);
                DialogResult = await FingerprintDevice.Execute(cmd);

                if (DialogResult.Code == ResultCode.GN_TASK_CANCEL)
                {
                    return;
                }
                else if (DialogResult.Code == ResultCode.GN_SUCCESS)
                {
                    break;
                }
                else
                {
                    this.Title = DialogResult.Message;
                }
            }

            // Second collect
            this.Title          = "请扫描第二遍指纹";
            brdOne.Background   = new SolidColorBrush(Colors.LightGreen);
            brdTwo.Background   = new SolidColorBrush(Colors.LightBlue);
            brdThree.Background = new SolidColorBrush(Colors.White);
            while (true)
            {
                cmd          = new fgCollectFingerprint(2, _fid, 1);
                DialogResult = await FingerprintDevice.Execute(cmd);

                if (DialogResult.Code == ResultCode.GN_TASK_CANCEL)
                {
                    return;
                }
                else if (DialogResult.Code == ResultCode.GN_SUCCESS)
                {
                    break;
                }
                else if (DialogResult.Code == ResultCode.FG_BOARD_FAIL)
                {
                    this.Title = "指纹采集失败,请重新扫描指纹";
                    goto first;
                }
                else
                {
                    this.Title = DialogResult.Message;
                }
            }

            if (DialogResult.Code == ResultCode.GN_TASK_CANCEL)
            {
                return;
            }

            // Last collect
            this.Title          = "请扫描第三遍指纹";
            brdOne.Background   = new SolidColorBrush(Colors.LightGreen);
            brdTwo.Background   = new SolidColorBrush(Colors.LightGreen);
            brdThree.Background = new SolidColorBrush(Colors.LightBlue);
            while (true)
            {
                cmd          = new fgCollectFingerprint(3, _fid, 1);
                DialogResult = await FingerprintDevice.Execute(cmd);

                if (DialogResult.Code == ResultCode.GN_TASK_CANCEL)
                {
                    return;
                }
                else if (DialogResult.Code == ResultCode.GN_SUCCESS)
                {
                    break;
                }
                else if (DialogResult.Code == ResultCode.FG_BOARD_FAIL)
                {
                    this.Title = "指纹采集失败,请重新扫描指纹";
                    goto first;
                }
                else
                {
                    this.Title = DialogResult.Message;
                }
            }

            if (DialogResult.Code == ResultCode.GN_TASK_CANCEL)
            {
                return;
            }

            this.Hide( );
        }
Esempio n. 2
0
        private async void btnDisconnect_Copy5_Click(object sender, RoutedEventArgs e)
        {
            //TimeSpan _orgTimeout = CommonRes.SerialPort.ReadTimeout;
            //try
            //{
            textBlock1.Text = "";

            // Get current count
            fgGetCount   cmd1 = new fgGetCount( );
            CommonResult ret1 = await FingerprintDevice.Execute(cmd1);

            if (ret1.Code != ResultCode.GN_SUCCESS)
            {
                textBlock1.Text = "Result: " + FingerprintDevice.LastExecuteResult.Message + "\r\nGet fingerprint count error.";
                return;
            }
            else
            {
                textBlock1.Text = "Now collect fingerprint first ....";
            }

            ushort newID = ( ushort )(cmd1.Count + 1);

            //CommonRes.SerialPort.ReadTimeout = TimeSpan.FromMilliseconds( 10000 );

            // First collect
            fgCollectFingerprint cmd2 = new fgCollectFingerprint(1, newID, 1);
            CommonResult         ret2 = await FingerprintDevice.Execute(cmd2);

            if (ret2.Code != ResultCode.GN_SUCCESS)
            {
                textBlock1.Text = "Result: " + FingerprintDevice.LastExecuteResult.Message + "\r\nCollect times 1 fail.";
                return;
            }
            else
            {
                textBlock1.Text = "Now collect fingerprint second ....";
            }

            // Second collect
            fgCollectFingerprint cmd3 = new fgCollectFingerprint(2, newID, 1);
            CommonResult         ret3 = await FingerprintDevice.Execute(cmd3);

            if (ret3.Code != ResultCode.GN_SUCCESS)
            {
                textBlock1.Text = "Result: " + FingerprintDevice.LastExecuteResult.Message + "\r\nCollect times 2 fail.";
                return;
            }
            else
            {
                textBlock1.Text = "Now collect fingerprint last ....";
            }

            // Last collect
            fgCollectFingerprint cmd4 = new fgCollectFingerprint(3, newID, 1);
            CommonResult         ret4 = await FingerprintDevice.Execute(cmd4);

            if (ret4.Code != ResultCode.GN_SUCCESS)
            {
                textBlock1.Text = "Result: " + FingerprintDevice.LastExecuteResult.Message + "\r\nCollect times 2 fail.";
                return;
            }
            else
            {
                textBlock1.Text = "Collect fingerprint finished !!!";
            }

            //}
            //finally
            //{
            //	CommonRes.SerialPort.ReadTimeout = _orgTimeout;
            //}
        }