Пример #1
0
        private IEnumerable <Fmd> CaptureAndExtractFmd()
        {
            while (!objVariables.reset)
            {
                DataResult <Fmd> resultConversion;

                try
                {
                    if (objVariables.count >= 8)
                    {
                        MessageBox.Show("El registro no se completó, vuelve a intentarlo.",
                                        "Aviso",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation,
                                        MessageBoxDefaultButton.Button1);

                        objVariables.count = 0;
                        break;
                    }

                    Fid fid = null;

                    if (objVariables.currentReader == null)
                    {
                        objVariables.currentReader = objDevice.IndexDevice();
                        objDevice.InitializeDevice(ref objVariables.currentReader);
                    }

                    if (!CaptureFinger(ref fid))
                    {
                        //break;
                    }

                    if (fid == null)
                    {
                        continue;
                    }

                    objVariables.count++;

                    resultConversion = FeatureExtraction.CreateFmdFromFid(fid, Constants.Formats.Fmd.ANSI);

                    objPrincipal.txtSalida.Dispatcher.BeginInvoke(new Action(delegate()
                    {
                        objPrincipal.txtSalida.AppendText("\nLa huella se ha capturado. Captura Numero: " + objVariables.count);
                    }));

                    if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        break;
                    }
                }
                catch (Exception)
                {
                    break;
                }

                yield return(resultConversion.Data);
            }
        }
Пример #2
0
 //method that runs for every capturing
 public void OnCaptured(CaptureResult captureResult)
 {
     try
     {
         // Check capture quality and throw an error if bad.
         if (!fp.CheckCaptureResult(captureResult))
         {
             return;
         }
         else
         {
             //convert to a valid finger print first
             DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
             if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS)
             {
                 throw new Exception(resultConversion.ResultCode.ToString());
             }
             else
             {
                 //if it succesfully convert then display for user to see
                 // Create bitmap - this part display the captured on screen
                 foreach (Fid.Fiv fiv in captureResult.Data.Views)
                 {
                     SendMessage(Action.SendBitmap, fp.CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height));
                 }
                 firstFinger = resultConversion.Data;
             }
         }
     }
     catch (Exception ex)
     {
         // Send error message, then close form
         SendMessage(Action.SendMessage, "Error:  " + ex.Message);
     }
 }
Пример #3
0
        /// <summary>
        /// Handler for when a fingerprint is captured.
        /// </summary>
        /// <param name="captureResult">contains info and data on the fingerprint capture</param>
        private void OnCaptured(CaptureResult captureResult)
        {
            try
            {
                // Check capture quality and throw an error if bad.
                if (!_sender.CheckCaptureResult(captureResult))
                {
                    return;
                }

                SendMessage(Action.SendMessage, "A finger was captured.");

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    _sender.Reset = true;
                    throw new Exception(captureResult.ResultCode.ToString());
                }

                if (count == 0)
                {
                    rightIndex = resultConversion.Data;
                    count     += 1;
                    SendMessage(Action.SendMessage, "Now place your right thumb on the reader.");
                }
                else if (count == 1)
                {
                    rightThumb = resultConversion.Data;
                    count     += 1;
                    SendMessage(Action.SendMessage, "Now place any finger on the reader.");
                }
                else if (count == 2)
                {
                    anyFinger = resultConversion.Data;
                    Fmd[] fmds = new Fmd[2];
                    fmds[0] = rightIndex;
                    fmds[1] = rightThumb;

                    // See the SDK documentation for an explanation on threshold scores.
                    int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;

                    IdentifyResult identifyResult = Comparison.Identify(anyFinger, 0, fmds, thresholdScore, 2);
                    if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        _sender.Reset = true;
                        throw new Exception(identifyResult.ResultCode.ToString());
                    }

                    SendMessage(Action.SendMessage, "Identification resulted in the following number of matches: " + identifyResult.Indexes.Length.ToString());
                    SendMessage(Action.SendMessage, "Place your right index finger on the reader.");
                    count = 0;
                }
            }
            catch (Exception ex)
            {
                // Send error message, then close form
                SendMessage(Action.SendMessage, "Error:  " + ex.Message);
            }
        }
Пример #4
0
        private void OnCaptured(CaptureResult captureResult)
        {
            bool existio = false;

            try
            {
                if (!Clases.HuellaDigital.CheckCaptureResult(captureResult))
                {
                    return;
                }

                ////Creamos el bitmap para el PictureBox
                //foreach (Fid.Fiv fiv in captureResult.Data.Views)
                //{
                //    SendMessage(Action.SendBitmap, Clases.HuellaDigital.CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height));
                //}

                //Guardamos la variable de la huella
                res = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    Clases.HuellaDigital.Reset = true;
                    throw new Exception(captureResult.ResultCode.ToString());
                }

                Fmd[] fmds = new Fmd[2];

                foreach (int k in Clases.HuellaDigital.Fmds.Keys)
                {
                    fmds[0] = Clases.HuellaDigital.Fmds[k];
                    int probabilidad = DPFJ_PROBABILITY_ONE * 1 / 100000;

                    IdentifyResult ideRes = Comparison.Identify(res.Data, 0, fmds, probabilidad, Clases.HuellaDigital.Fmds.Count + 1);

                    if (ideRes.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        Clases.HuellaDigital.Reset = true;
                        throw new Exception(ideRes.ResultCode.ToString());
                    }
                    if (ideRes.Indexes.Length > 0)
                    {
                        SendMessage(Action.SendOK, k.ToString());
                        existio = true;
                        break;
                    }
                }
                if (!existio)
                {
                    SendMessage(Action.SendMessage, "La huella no coincide con alguna del registro\n");
                }
            }
            catch (Exception ex)
            {
                //Mostramos un MessageBox con el mensaje de error
                SendMessage(Action.SendMessage, ex.Message);
            }
        }
Пример #5
0
        /// <summary>
        /// Handler for when a fingerprint is captured.
        /// </summary>
        /// <param name="captureResult">contains info and data on the fingerprint capture</param>
        private void OnCaptured(CaptureResult captureResult)
        {
            try
            {
                // Check capture quality and throw an error if bad.
                if (!_sender.CheckCaptureResult(captureResult))
                {
                    return;
                }

                SendMessage(Action.SendMessage, oHelper.Mensaje2);

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    _sender.Reset = true;
                    throw new Exception(resultConversion.ResultCode.ToString());
                }

                if (count == 0)
                {
                    firstFinger = resultConversion.Data;

                    OperadorEncontrado = funciones.CompararHuella(firstFinger, secondFinger);

                    if (OperadorEncontrado.IdOperador != 0)
                    {
                        SendMessage(Action.SendMessage, "Huella coincide con operador " + OperadorEncontrado.Nombre + " y su status es " + OperadorEncontrado.Status);
                        SendMessage(Action.SendMessage, oHelper.Mensaje1);
                    }

                    else
                    {
                        SendMessage(Action.SendMessage, oHelper.Mensaje5);
                        SendMessage(Action.SendMessage, oHelper.Mensaje1);
                    }

                    count = 0;
                }
            }
            catch (Exception ex)
            {
                // Send error message, then close form
                SendMessage(Action.SendMessage, oHelper.Error + ex.Message);
            }

            ///si el lector es desconectado con la ventana de verification abierta, mandamos a cerrarla automaticamente
            ///para llamar al evento Verification_Closed y que se cargue el load del main para que salga el mensajeBox de lector
            ///desconectado (Reintentar/Salir)
            if (captureResult.ResultCode == Constants.ResultCode.DP_DEVICE_FAILURE)
            {
                Thread t = new Thread(cerrar);
                t.Start();
            }
        }
Пример #6
0
        public void OnCaptured(CaptureResult captureResult)
        {
            this.picBoxToCap     = picBoxFingerPrint;
            this.fingerToCapture = 0;
            count++;
            lblCount.Invoke(new Action(() => { lblCount.Text = count.ToString(); }));
            DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);

            if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
            {
                if (CurrentReader != null)
                {
                    CurrentReader.Dispose();
                    CurrentReader = null;
                }

                MessageBox.Show("Error:  " + captureResult.ResultCode);
            }
            if (captureResult.Data != null)
            {
                foreach (Fid.Fiv fiv in captureResult.Data.Views)
                {
                    picBoxFingerPrint.Image    = CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height);
                    picBoxFingerPrint.SizeMode = PictureBoxSizeMode.Zoom;
                }
            }
            preenrollmentFmds.Add(resultConversion.Data);
            if (count >= 4)
            {
                resultEnrollment = Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.ANSI, preenrollmentFmds);

                TempFingerPrint = Fmd.SerializeXml(resultConversion.Data);

                resultEnrollment = DPUruNet.Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.ANSI, preenrollmentFmds);

                if (resultEnrollment.ResultCode == Constants.ResultCode.DP_SUCCESS)
                {
                    FileStream fs = new System.IO.FileStream(@"..\..\Pictures\right.bmp", FileMode.Open, FileAccess.Read);
                    picRigithWrong.Invoke(new Action(() => { picRigithWrong.Image = Image.FromStream(fs); }));
                    picRigithWrong.SizeMode = PictureBoxSizeMode.Zoom;
                    //preenrollmentFmds.Clear();
                    //count = 0;
                    MessageBox.Show("An enrollment was successfully created.");
                    return;
                }
                else if (resultEnrollment.ResultCode == Constants.ResultCode.DP_ENROLLMENT_INVALID_SET)
                {
                    MessageBox.Show("Enrollment was unsuccessful.  Please try again.");
                    preenrollmentFmds.Clear();
                    count = 0;
                    return;
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Handler for when a fingerprint is captured.
        /// </summary>
        /// <param name="captureResult">contains info and data on the fingerprint capture</param>
        private void OnCaptured(CaptureResult captureResult)
        {
            try
            {
                // Check capture quality and throw an error if bad.
                if (!_sender.CheckCaptureResult(captureResult))
                {
                    return;
                }

                count++;

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);

                SendMessage(Action.SendMessage, "A finger was captured.  \r\nCount:  " + (count));

                if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    _sender.Reset = true;
                    throw new Exception(resultConversion.ResultCode.ToString());
                }

                preenrollmentFmds.Add(resultConversion.Data);

                if (count >= 4)
                {
                    DataResult <Fmd> resultEnrollment = DPUruNet.Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.ANSI, preenrollmentFmds);

                    if (resultEnrollment.ResultCode == Constants.ResultCode.DP_SUCCESS)
                    {
                        SendMessage(Action.SendMessage, "An enrollment FMD was successfully created.");
                        SendMessage(Action.SendMessage, "Place a finger on the reader.");
                        preenrollmentFmds.Clear();
                        count = 0;
                        return;
                    }
                    else if (resultEnrollment.ResultCode == Constants.ResultCode.DP_ENROLLMENT_INVALID_SET)
                    {
                        SendMessage(Action.SendMessage, "Enrollment was unsuccessful.  Please try again.");
                        SendMessage(Action.SendMessage, "Place a finger on the reader.");
                        preenrollmentFmds.Clear();
                        count = 0;
                        return;
                    }
                }

                SendMessage(Action.SendMessage, "Now place the same finger on the reader.");
            }
            catch (Exception ex)
            {
                // Send error message, then close form
                SendMessage(Action.SendMessage, "Error:  " + ex.Message);
            }
        }
Пример #8
0
 public FingerTemplate Extract(FingerImage image)
 {
     if (image is FingerImageDP)
     {
         var fingerImage = image as FingerImageDP;
         DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(fingerImage.fid, Constants.Formats.Fmd.ANSI);
         if (resultConversion.ResultCode == Constants.ResultCode.DP_SUCCESS)
         {
             return(new TemplateDP(resultConversion.Data));
         }
     }
     return(null);
 }
Пример #9
0
        /// <summary>
        /// Handler for when a fingerprint is captured.
        /// </summary>
        /// <param name="captureResult">contains info and data on the fingerprint capture</param>
        private void OnCaptured(CaptureResult captureResult)
        {
            try
            {
                // Check capture quality and throw an error if bad.
                if (!_sender.CheckCaptureResult(captureResult))
                {
                    return;
                }

                SendMessage(Action.SendMessage, "A finger was captured.");

                IDs.Clear();

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    _sender.Reset = true;
                    throw new Exception(captureResult.ResultCode.ToString());
                }

                SendMessage(Action.SendMessage, "Please wait while searching is done in background.");

                anyFinger = resultConversion.Data;
                Fmd[] fmdsArray = fmds.ToArray();

                foreach (Fmd fmd in fmdsArray)
                {
                    CompareResult compareResult = Comparison.Compare(anyFinger, 0, fmd, 0);
                    if (compareResult.Score < (PROBABILITY_ONE / 100000))
                    {
                        IDs.Add(fmdsDic[fmd]);
                    }
                }
                SendMessage(Action.SendMessage, IDs.Count.ToString() + " Finger Print(s) Matched.");
                SendMessage(Action.SendMessage, "Click the button below to show results or place thumb to search again.");

                if (IDs.Count > 0)
                {
                    SendMessage(Action.ShowMatchedEntry, "");
                }
                else
                {
                    SendMessage(Action.HideMatchedEntry, "");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in Identification: " + ex.Message);
            }
        }
        private async void Identify(object Huella = null)
        {
            try
            {
                if (FingerPrintData == null)
                {
                    return;
                }

                Error           = "Verificando huella...";
                IniciaAnimacion = true;
                Thread.Sleep(5000);
                var Service = new BiometricoServiceClient();

                var CompareResult = Service.CompararHuellaImputado(new ComparationRequest {
                    BIOMETRICO = FeatureExtraction.CreateFmdFromFid(FingerPrintData, Constants.Formats.Fmd.ANSI).Data.Bytes, ID_TIPO_BIOMETRICO = DD_Dedo.HasValue ? DD_Dedo.Value : enumTipoBiometrico.INDICE_DERECHO, ID_TIPO_FORMATO = enumTipoFormato.FMTO_DP
                });

                if (CompareResult.Identify)
                {
                    var result      = CompareResult.Result[0];
                    var NombreLogin = await StaticSourcesViewModel.CargarDatosAsync(() => new cImputado().GetData().Where(w => w.ID_ANIO == result.ID_ANIO && w.ID_CENTRO == result.ID_CENTRO && w.ID_IMPUTADO == result.ID_IMPUTADO).FirstOrDefault());

                    var nombreComparar = NombreLogin.NOMBRE.Trim() + " " + NombreLogin.PATERNO.Trim() + " " + NombreLogin.MATERNO.Trim();
                    //cambiar el proceso para que traiga el username y de ahi sacar el resto de los datos.
                    if (_usuario.NombreCompleto != nombreComparar)
                    {
                        Error = "El capturista no pertenece a esta sesion";
                    }
                    else
                    {
                        Error = "Su huella ha sido autenticada con exito";

                        OnProgress.Start();
                        Autenticado = true;
                    }
                }
                else
                {
                    Error = "Esta huella no esta registrada en el sistema";
                }
                IniciaAnimacion = false;
                FingerPrintData = null;
            }
            catch (Exception ex)
            {
                Error           = "Ocurrió un error al verficar la huella";
                IniciaAnimacion = false;
            }
        }
Пример #11
0
        /// <summary>
        /// Handler for when a fingerprint is captured.
        /// </summary>
        /// <param name="captureResult">contains info and data on the fingerprint capture</param>
        private void OnCaptured(CaptureResult captureResult)
        {
            try
            {
                // Check capture quality and throw an error if bad.
                if (!_sender.CheckCaptureResult(captureResult))
                {
                    return;
                }

                SendMessage(Action.SendMessage, "A finger was captured.");

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    _sender.Reset = true;
                    throw new Exception(resultConversion.ResultCode.ToString());
                }

                if (count == 0)
                {
                    firstFinger = resultConversion.Data;
                    count      += 1;
                    SendMessage(Action.SendMessage, "Now place the same or a different finger on the reader.");
                }
                else if (count == 1)
                {
                    secondFinger = resultConversion.Data;
                    CompareResult compareResult = Comparison.Compare(firstFinger, 0, secondFinger, 0);
                    if (compareResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        _sender.Reset = true;
                        throw new Exception(compareResult.ResultCode.ToString());
                    }

                    SendMessage(Action.SendMessage, "Comparison resulted in a dissimilarity score of " + compareResult.Score.ToString() + (compareResult.Score < (PROBABILITY_ONE / 100000) ? " (fingerprints matched)" : " (fingerprints did not match)"));
                    SendMessage(Action.SendMessage, "Place a finger on the reader.");
                    count = 0;
                }
            }
            catch (Exception ex)
            {
                // Send error message, then close form
                SendMessage(Action.SendMessage, "Error:  " + ex.Message);
            }
        }
Пример #12
0
        void reader_On_Captured(CaptureResult capResult)
        {
            if (capResult.Quality == Constants.CaptureQuality.DP_QUALITY_GOOD)
            {
                count++;
                DataResult <Fmd> fmd = FeatureExtraction.CreateFmdFromFid(capResult.Data, Constants.Formats.Fmd.DP_PRE_REGISTRATION);

                // Get view bytes to create bitmap.
                foreach (Fid.Fiv fiv in capResult.Data.Views)
                {
                    //Ask user to press finger to get fingerprint
                    UpdateEnrollMessage("Click save button to save fingerprint", HelperFunctions.CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height));
                    break;
                }

                //preEnrollmentFmd.Add(fmd.Data);
                //enrollmentFmd = DPUruNet.Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.DP_REGISTRATION, preEnrollmentFmd);

                ////if (enrollmentFmd.ResultCode == Constants.ResultCode.DP_SUCCESS)
                //{
                //    if (fingerindex == 0)
                //    {
                //        fmd1 = enrollmentFmd;
                //        fingerindex++;
                //        count = 0;
                //        preEnrollmentFmd.Clear();
                //        UpdateEnrollMessage("Please swipe 2nd finger", null);
                //    }
                //    else if (fingerindex == 1)
                //    {
                //        fmd2 = enrollmentFmd;
                //        preEnrollmentFmd.Clear();
                //        UpdateEnrollMessage("User " + userIDTb.Text.ToString() + " Successfully Enrolled!", null);
                //        string userid = userIDTb.Text.ToString();
                //        HelperFunctions.updateFMDUserIDList(fmd1.Data, fmd2.Data, userid);

                //        if (!CheckIfUserExists())
                //        {
                //            SaveEnrolledFmd(userIDTb.Text.ToString(), Fmd.SerializeXml(fmd1.Data), Fmd.SerializeXml(fmd2.Data));
                //        }

                //    }

                // }
            }
        }
Пример #13
0
        void reader_On_Captured(CaptureResult capResult)
        {
            if (capResult.Quality == Constants.CaptureQuality.DP_QUALITY_GOOD)
            {
                DataResult <Fmd> fmdResult = FeatureExtraction.CreateFmdFromFid(capResult.Data, Constants.Formats.Fmd.DP_VERIFICATION);
                //If successfully extracted fmd then assign fmd
                if (fmdResult.ResultCode == Constants.ResultCode.DP_SUCCESS)
                {
                    fmd = fmdResult.Data;
                    // Get view bytes to create bitmap.
                    foreach (Fid.Fiv fiv in capResult.Data.Views)
                    {
                        UpdateVerifyMessage("Fingerprint Captured", CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height));
                        break;
                    }
                }
                else
                {
                    UpdateVerifyMessage("Could not successfully create a verification FMD", null);
                }

                //Perform indentification of fmd of captured sample against enrolledFmdList
                IdentifyResult vResult = Comparison.Identify(fmd, 0, enrolledFmdList, 21474, 5);

                //If number of matches returned by IdentificationResult are greater than 0 then user is authorized
                if (vResult.ResultCode == Constants.ResultCode.DP_SUCCESS)
                {
                    if (vResult.Indexes.Length > 0)
                    {
                        UpdateVerifyMessage("User Authorized", null);
                    }
                    else
                    {
                        UpdateVerifyMessage("User Unauthorized", null);
                    }
                }
                else
                {
                    UpdateVerifyMessage("Error occured on verfication.", null);
                }
            }
            else
            {
                UpdateVerifyMessage("Please swipe finger again", null);
            }
        }
Пример #14
0
        private async void Identify(object Huella = null)
        {
            try
            {
                if (FingerPrintData == null)
                {
                    return;
                }

                Error = "Iniciando sesión...";
                var Service = new BiometricoServiceClient();

                var CompareResult = Service.CompararHuellaImputado(new ComparationRequest {
                    BIOMETRICO = FeatureExtraction.CreateFmdFromFid(FingerPrintData, Constants.Formats.Fmd.ANSI).Data.Bytes, ID_TIPO_BIOMETRICO = DD_Dedo.HasValue ? DD_Dedo.Value : BiometricoServiceReference.enumTipoBiometrico.INDICE_DERECHO, ID_TIPO_FORMATO = enumTipoFormato.FMTO_DP
                });

                if (CompareResult.Identify)
                {
                    var result      = CompareResult.Result[0];
                    var NombreLogin = await StaticSourcesViewModel.CargarDatosAsync(() => new cImputado().GetData().Where(w => w.ID_ANIO == result.ID_ANIO && w.ID_CENTRO == result.ID_CENTRO && w.ID_IMPUTADO == result.ID_IMPUTADO).FirstOrDefault());

                    User.NombreCompleto = NombreLogin.NOMBRE.Trim() + " " + NombreLogin.PATERNO.Trim() + " " + NombreLogin.MATERNO.Trim();
                    //cambiar el proceso para que traiga el username y de ahi sacar el resto de los datos.
                    if (User.NombreCompleto == "ANGEL EMILIO AREVALO MARQUEZ")
                    {
                        User.Username = "******";
                    }
                    else
                    {
                        User.Username = "******";
                    }
                    OnProgress.Start();
                }
                else
                {
                    Error = "El usuario o la contraseña son incorrectos";
                }

                FingerPrintData = null;
            }
            catch
            {
                Error = "Ocurrió un error al iniciar sesión";
            }
        }
Пример #15
0
        private IEnumerable <Fmd> CaptureAndExtractFmd()
        {
            while (!reset)
            {
                DataResult <Fmd> resultConversion;

                try
                {
                    if (count >= 8)
                    {
                        SendMessage("Enrollment was unsuccessful.  Please try again.");
                        count = 0;
                        break;
                    }

                    Fid fid = null;
                    if (!_sender.CaptureFinger(ref fid))
                    {
                        break;
                    }

                    if (fid == null)
                    {
                        continue;
                    }

                    count++;

                    resultConversion = FeatureExtraction.CreateFmdFromFid(fid, Constants.Formats.Fmd.ANSI);

                    SendMessage("A finger was captured.  \r\nCount:  " + (count));

                    if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        break;
                    }
                }
                catch (Exception)
                {
                    break;
                }

                yield return(resultConversion.Data);
            }
        }
Пример #16
0
 /// <summary>
 /// Handler for when a fingerprint is captured.
 /// </summary>
 /// <param name="captureResult">contains info and data on the fingerprint capture</param>
 public void OnCaptured(CaptureResult captureResult)
 {
     try
     {
         // Check capture quality and throw an error if bad.
         if (!Clases.HuellaDigital.CheckCaptureResult(captureResult))
         {
             return;
         }
         // Create bitmap
         foreach (Fid.Fiv fiv in captureResult.Data.Views)
         {
             SendMessage(Action.SendBitmap, Clases.HuellaDigital.CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height));
         }
         //Guardamos el FMD de la huella
         res = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
     }
     catch (Exception ex)
     {
         // Send error message, then close form
         SendMessage(Action.SendMessage, "Error:  " + ex.Message);
     }
 }
Пример #17
0
        private void IdentifyThread()
        {
            while (!reset)
            {
                Fid fid = null;

                if (!CaptureFinger(ref fid))
                {
                    //break;
                }

                if (objReader == null)
                {
                    objReader = objDeviceReader.IndexDevice();
                    objDeviceReader.InitializeDevice(ref objReader);
                }

                if (fid == null)
                {
                    continue;
                }

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(fid, Constants.Formats.Fmd.ANSI);


                if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    //break;

                    if (objReader != null)
                    {
                        objReader.Dispose();
                        objReader = null;
                    }
                    return;
                }

                int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;

                Fmd aux = resultConversion.Data;
                Fmd temp;
                foreach (Clases.Persona item in listPersons)
                {
                    try
                    {
                        temp = Fmd.DeserializeXml(item.huella);

                        CompareResult identifyResult = Comparison.Compare(aux, 0, temp, 0);

                        if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                        {
                            break;
                        }

                        if (identifyResult.Score < thresholdScore)
                        {
                            List <Datos.membresia> mem = new Negocios.Nmembresia().ListarMembresia(item.id);
                            //guardar la asistencia en la base de datos
                            try
                            {
                                //insertamos en la base de datos
                                string cs = ConfigurationManager.ConnectionStrings["saffron.GYM.GYM2"].ConnectionString;

                                SqlConnection conexion = new SqlConnection(cs);
                                conexion.Open();
                                SqlCommand query = new SqlCommand("INSERT INTO GYM.asistencias VALUES (" + item.id + ", GETDATE())", conexion);
                                query.ExecuteNonQuery();
                                conexion.Close();
                            }
                            catch (Exception err)
                            {
                                MessageBox.Show(err.Message);
                            }

                            if (mem.Count > 0)
                            {
                                string   membresia = "";
                                DateTime fecha_i   = DateTime.Now;
                                DateTime fecha_f   = DateTime.Now;
                                foreach (var m in mem)
                                {
                                    //sacamos el tipo de membresia
                                    switch (m.tipo_membresia)
                                    {
                                    case "G": membresia = "Gimnasio"; break;

                                    case "Z": membresia = "Zumba"; break;

                                    case "C": membresia = "Crossfit"; break;
                                    }
                                    //sacamos la fecha inicial
                                }

                                // Difference in days, hours, and minutes.
                                TimeSpan ts = fecha_f - DateTime.Now;

                                // Difference in days.
                                int differenceInDays = ts.Days;
                                SendMessage("Cliente identificado: ", item.Nombre, membresia, fecha_i.ToShortDateString(), fecha_f.ToShortDateString(), differenceInDays.ToString());
                            }
                            else
                            {
                                SendMessage("Cliente identificado: ", item.Nombre, "Sin Membresia Activa", "", "", "");
                            }
                            Thread.Sleep(10000);
                            SendMessage("Coloque el dedo en el checador...", "", "", "", "", "");
                            menuPrincipal.Dispatcher.BeginInvoke(new Action(delegate()
                            {
                                menuPrincipal.lblMembresia.Content = "";
                                menuPrincipal.lbl_inicio.Content   = "";
                                menuPrincipal.lbl_fin.Content      = "";
                                menuPrincipal.lbl_resto.Content    = "";
                            }));
                            break;
                        }

                        /*else
                         * {
                         *  SendMessage("No se encuentra registrada la huella capturada", "", "", "","","");
                         *  Thread.Sleep(2000);
                         *  SendMessage("Coloque el dedo en el checador...", "", "", "", "","");
                         *  break;
                         * }*/
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show(error.Message);
                    }
                }
            }

            if (objReader != null)
            {
                objReader.Dispose();
            }
        }
Пример #18
0
        private void OnCaptured(CaptureResult captureResult)
        {
            try
            {
                if (!fingerprint.CheckCaptureResult(captureResult))
                {
                    return;
                }

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    fingerprint.CurrentReader.Reset();
                    Application.Current.Dispatcher.Invoke((Action) delegate
                    {
                        TxtBlock_FingerprintMessage.Text = "Error. Please try again. Place your finger on the device.";
                    });
                    throw new Exception(captureResult.ResultCode.ToString());
                }

                if (studentInfo.Firstfinger == null)
                {
                    studentInfo.Firstfinger = resultConversion.Data;
                    Application.Current.Dispatcher.Invoke((Action) delegate
                    {
                        TxtBlock_FingerprintMessage.Text = "Finger was captured. Now Place the same finger on the device.";
                    });
                }
                else
                {
                    if (studentInfo.Lastfinger == null)
                    {
                        studentInfo.Lastfinger = resultConversion.Data;
                        Fmd[] fmds = new Fmd[1];
                        fmds[0] = studentInfo.Firstfinger;

                        // See the SDK documentation for an explanation on threshold scores.
                        int            thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;
                        IdentifyResult identifyResult = Comparison.Identify(studentInfo.Lastfinger, 0, fmds, thresholdScore, 1);
                        if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                        {
                            throw new Exception(identifyResult.ResultCode.ToString());
                        }

                        if (identifyResult.Indexes.Length <= 0)
                        {
                            Application.Current.Dispatcher.Invoke((Action) delegate
                            {
                                TxtBlock_FingerprintMessage.Text = "Failed, first finger and second finger not matched. Please try again, place any finger on the device.";
                                studentInfo.Firstfinger          = null;
                                studentInfo.Lastfinger           = null;
                            });
                        }
                        else
                        {
                            Application.Current.Dispatcher.Invoke((Action) delegate
                            {
                                SaveStudentToDatabase();
                                TxtBlock_FingerprintMessage.Text = "Success, your fingerprint data was saved. Please click the next button to finish.";
                                Btn_ProceedLast.IsEnabled        = true;
                                fingerprint.CancelCaptureAndCloseReader(this.OnCaptured);
                            });
                        }
                    }
                }
            } catch (Exception ex)
            {
                MessageBox.Show("Error while capturing the fingerprint.\nPlease try again later." + ex, "Error Fingerprint", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Dispatcher.Invoke((Action) delegate
                {
                    fingerprint.CurrentReader.Dispose();
                    fingerprint.CurrentReader = null;
                    this.Close();
                });
            }
        }
Пример #19
0
        /// <summary>
        /// The on capture.
        /// </summary>
        /// <param name="captureResult">
        /// The capture result.
        /// </param>
        private void OnCapture(CaptureResult captureResult)
        {
            var resultFingerprint = new ResultFingerprint {
                Result = this.CheckCaptureResult(captureResult)
            };

            resultFingerprint.Message                 = !resultFingerprint.Result ? es_CO.BadCapture : es_CO.Captured;
            resultFingerprint.ImageFingerprints       = !resultFingerprint.Result ? null : FingerprintSerializer.GetFingerprintBitmap(captureResult.Data.Views);
            resultFingerprint.StringImageFingerprints = !resultFingerprint.Result ? null : FingerprintSerializer.GetFingerprintStringBitmap(captureResult.Data.Views);
            resultFingerprint.XmlFmd = !resultFingerprint.Result ? string.Empty : Fmd.SerializeXml(FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI).Data);
            resultFingerprint.FileFingerprintImage = !resultFingerprint.Result ? string.Empty : FingerprintSerializer.GetFingerprintFile(captureResult.Data.Views);

            this.CaptureProcessed?.Invoke(resultFingerprint);
        }
        private void OnCaptured(CaptureResult captureResult)
        {
            try
            {
                if (!fingerprintReader.CheckCaptureResult(captureResult))
                {
                    return;
                }
                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    fingerprintReader.CurrentReader.Reset();
                    throw new Exception(captureResult.ResultCode.ToString());
                }

                // See the SDK documentation for an explanation on threshold scores.
                int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;

                if (isAdminLogin)
                {
                    IdentifyResult identifyResult = Comparison.Identify(resultConversion.Data, 0, AdminFingerPrints.ToArray(), thresholdScore, AdminFingerPrints.Count);
                    if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        throw new Exception(identifyResult.ResultCode.ToString());
                    }

                    if (identifyResult.Indexes.Length > 0)
                    {
                        fingerprintReader.CancelCaptureAndCloseReader(this.OnCaptured);
                        Application.Current.Dispatcher.Invoke((Action) delegate
                        {
                            AdminDashboard adminDashboard = new AdminDashboard();
                            adminDashboard.CurrentAdminId = AdminId.ElementAt(identifyResult.Indexes[0][0]);
                            adminDashboard.Show();
                            fingerprintReader.CurrentReader.Dispose();
                            fingerprintReader.CurrentReader = null;
                            this.Close();
                        });
                    }
                }
                else
                {
                    IdentifyResult identifyResult = Comparison.Identify(resultConversion.Data, 0, StudenFingerPrints.ToArray(), thresholdScore, StudenFingerPrints.Count);
                    if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        throw new Exception(identifyResult.ResultCode.ToString());
                    }

                    if (identifyResult.Indexes.Length > 0)
                    {
                        fingerprintReader.CancelCaptureAndCloseReader(this.OnCaptured);
                        Application.Current.Dispatcher.Invoke((Action) delegate
                        {
                            StudentDashboard studentDash = new StudentDashboard(StudentId.ElementAt(identifyResult.Indexes[0][0]).ToString(), database);
                            studentDash.Show();
                            fingerprintReader.CurrentReader.Dispose();
                            fingerprintReader.CurrentReader = null;
                            this.Close();
                        });
                    }
                }
            }
            catch (Exception)
            {
                Application.Current.Dispatcher.Invoke((Action) delegate
                {
                    ErrorHeader1.Text     = "Fingerprint device error";
                    ErrorContent1.Text    = "Error while capturing the fingerprint.";
                    DialogMessage1.IsOpen = true;
                });
            }
        }
Пример #21
0
        private void IdentifyThread()
        {
            while (!reset)
            {
                Fid fid = null;

                if (!CaptureFinger(ref fid))
                {
                    //break;
                }

                if (objReader == null)
                {
                    objReader = objDeviceReader.IndexDevice();
                    objDeviceReader.InitializeDevice(ref objReader);
                }

                if (fid == null)
                {
                    continue;
                }

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(fid, Constants.Formats.Fmd.ANSI);

                if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    //break;

                    if (objReader != null)
                    {
                        objReader.Dispose();
                        objReader = null;
                    }
                    return;
                }

                int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;

                Fmd aux = resultConversion.Data;
                Fmd temp;

                foreach (Clases.Persona item in listPersons)
                {
                    temp = Fmd.DeserializeXml(item.huella);

                    CompareResult identifyResult = Comparison.Compare(aux, 0, temp, 0);

                    if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        break;
                    }

                    if (identifyResult.Score < thresholdScore)
                    {
                        SendMessage("Identificado");
                        MessageBox.Show("Identificado");
                        Thread.Sleep(3000);
                        SendMessage("Buscando...");
                        break;
                    }
                }
            }

            if (objReader != null)
            {
                objReader.Dispose();
            }
        }
Пример #22
0
        private void Compare(object Huella = null)
        {
            if (FingerPrintData == null)
            {
                Application.Current.Dispatcher.Invoke((System.Action)(delegate
                {
                    ScannerMessage = "Vuelve a capturar la huella";
                    TextoBoton     = "Crear Nuevo Expediente";
                    ColorMessage   = new SolidColorBrush(Colors.DarkOrange);
                }));
                return;
            }
            Application.Current.Dispatcher.Invoke((System.Action)(delegate
            {
                ScannerMessage             = "Procesando... ";
                ColorMessage               = new SolidColorBrush(Color.FromRgb(51, 115, 242));
                AceptarBusquedaHuellaFocus = false;
            }));

            var Service       = new BiometricoServiceClient();
            var CompareResult = Service.CompararHuellaImputado(new ComparationRequest {
                BIOMETRICO = FeatureExtraction.CreateFmdFromFid(FingerPrintData, Constants.Formats.Fmd.ANSI).Data.Bytes, ID_TIPO_BIOMETRICO = (DD_Dedo.HasValue ? DD_Dedo.Value : enumTipoBiometrico.INDICE_DERECHO), ID_TIPO_FORMATO = enumTipoFormato.FMTO_DP
            });

            if (CompareResult.Identify)
            {
                Application.Current.Dispatcher.Invoke((System.Action)(delegate
                {
                    var item     = CompareResult.Result.FirstOrDefault();
                    var imputado = new cImputadoBiometrico().GetData().Where(w => w.ID_ANIO == item.ID_ANIO && w.ID_CENTRO == item.ID_CENTRO && w.ID_IMPUTADO == item.ID_IMPUTADO && w.ID_TIPO_BIOMETRICO == (DD_Dedo.HasValue ? (short)DD_Dedo.Value : (short)enumTipoBiometrico.INDICE_DERECHO) && w.ID_FORMATO == (short)enumTipoFormato.FMTO_DP).FirstOrDefault();

                    if (imputado == null)
                    {
                        ScannerMessage = "Registro no encontrado";
                        TextoBoton     = "Crear Nuevo Expediente";
                        ColorMessage   = new SolidColorBrush(Colors.Red);
                        return;
                    }

                    Imputado = imputado.IMPUTADO;

                    var ingresobiometrico = imputado.IMPUTADO.INGRESO.OrderByDescending(o => o.ID_INGRESO).FirstOrDefault();

                    if (ingresobiometrico != null)
                    {
                        if (ingresobiometrico.INGRESO_BIOMETRICO.Any())
                        {
                            if (ingresobiometrico.INGRESO_BIOMETRICO.Where(w => w.ID_TIPO_BIOMETRICO == (short)enumTipoBiometrico.FOTO_FRENTE_SEGUIMIENTO && w.ID_FORMATO == (short)enumTipoFormato.FMTO_JPG).Any())
                            {
                                ImputadoFoto = new Imagenes().ConvertByteToBitmap(ingresobiometrico.INGRESO_BIOMETRICO.Where(w => w.ID_TIPO_BIOMETRICO == (short)enumTipoBiometrico.FOTO_FRENTE_SEGUIMIENTO && w.ID_FORMATO == (short)enumTipoFormato.FMTO_JPG).SingleOrDefault().BIOMETRICO);
                            }
                            else
                            if (ingresobiometrico.INGRESO_BIOMETRICO.Where(w => w.ID_TIPO_BIOMETRICO == (short)enumTipoBiometrico.FOTO_FRENTE_REGISTRO && w.ID_FORMATO == (short)enumTipoFormato.FMTO_JPG).Any())
                            {
                                ImputadoFoto = new Imagenes().ConvertByteToBitmap(ingresobiometrico.INGRESO_BIOMETRICO.Where(w => w.ID_TIPO_BIOMETRICO == (short)enumTipoBiometrico.FOTO_FRENTE_REGISTRO && w.ID_FORMATO == (short)enumTipoFormato.FMTO_JPG).SingleOrDefault().BIOMETRICO);
                            }
                            else
                            {
                                ImputadoFoto = new Imagenes().ConvertByteToBitmap(new Imagenes().getImagenPerson());
                            }
                        }
                    }
                    TextoBoton                 = "Nuevo Ingreso";
                    ScannerMessage             = "Registro encontrado";
                    AceptarBusquedaHuellaFocus = true;
                    ColorMessage               = new SolidColorBrush(Colors.Green);
                }));
            }
            else
            {
                Application.Current.Dispatcher.Invoke((System.Action)(delegate
                {
                    TextoBoton                 = "Crear Nuevo Expediente";
                    ScannerMessage             = "Huella no encontrada";
                    ColorMessage               = new SolidColorBrush(Colors.Red);
                    AceptarBusquedaHuellaFocus = true;
                }));
                _IsSucceed    = false;
                _Imputado     = null;
                Nombre        = string.Empty;
                APaterno      = string.Empty;
                AMaterno      = string.Empty;
                Expediente    = string.Empty;
                NIP           = string.Empty;
                PropertyImage = null;
                ImputadoFoto  = null;
            }

            Service.Close();
            FingerPrintData = null;
        }
        public void CompararHuellaImputado()
        {
            ImagenImputado   = new Imagenes().getImagenPerson();
            ImputadoEntrante = new List <InternoVisitaLegal>();
            var bytesHuella = FingerPrintData != null?FeatureExtraction.CreateFmdFromFid(FingerPrintData, Constants.Formats.Fmd.ANSI).Data.Bytes : null;

            var MensajeResultado = enumMensajeResultadoComparacion.HUELLA_VACIA;

            if (bytesHuella == null)
            {
                Application.Current.Dispatcher.Invoke((Action)(delegate()
                {
                    CambiarMensaje(MensajeResultado);
                }));
            }
            else
            {
                MensajeResultado = enumMensajeResultadoComparacion.PROCESANDO;
                Application.Current.Dispatcher.Invoke((Action)(delegate
                {
                    CambiarMensaje(MensajeResultado);
                }));

                var doIdentify = Comparison.Identify(Importer.ImportFmd(bytesHuella, Constants.Formats.Fmd.ANSI, Constants.Formats.Fmd.ANSI).Data, 0, HuellasImputadosVisitas.Where(w => w.FMD != null && w.tipo_biometrico == SelectedFinger).Select(s => s.FMD), (0x7fffffff / 100000), 10);
                var result     = new List <object>();

                if (doIdentify.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    if (HuellasImputadosVisitas.Count == 0)
                    {
                        MensajeResultado = enumMensajeResultadoComparacion.NO_ENCONTRADO;
                    }
                    else
                    {
                        switch (doIdentify.ResultCode)
                        {
                        case Constants.ResultCode.DP_DEVICE_BUSY:
                            break;

                        case Constants.ResultCode.DP_DEVICE_FAILURE:
                            break;

                        case Constants.ResultCode.DP_ENROLLMENT_INVALID_SET:
                            break;

                        case Constants.ResultCode.DP_ENROLLMENT_IN_PROGRESS:
                            break;

                        case Constants.ResultCode.DP_ENROLLMENT_NOT_READY:
                            break;

                        case Constants.ResultCode.DP_ENROLLMENT_NOT_STARTED:
                            break;

                        case Constants.ResultCode.DP_FAILURE:
                            break;

                        case Constants.ResultCode.DP_INVALID_DEVICE:
                            break;

                        case Constants.ResultCode.DP_INVALID_FID:
                            break;

                        case Constants.ResultCode.DP_INVALID_FMD:
                            break;

                        case Constants.ResultCode.DP_INVALID_PARAMETER:
                            break;

                        case Constants.ResultCode.DP_MORE_DATA:
                            break;

                        case Constants.ResultCode.DP_NOT_IMPLEMENTED:
                            break;

                        case Constants.ResultCode.DP_NO_DATA:
                            break;

                        case Constants.ResultCode.DP_TOO_SMALL_AREA:
                            break;

                        case Constants.ResultCode.DP_VERSION_INCOMPATIBILITY:
                            break;

                        default:
                            break;
                        }
                    }
                }
                else
                {
                    if (doIdentify.Indexes.Count() > 0)
                    {
                        foreach (var resultado in doIdentify.Indexes.ToList())
                        {
                            result.Add(HuellasImputadosVisitas[resultado.FirstOrDefault()].IMPUTADO);
                        }
                    }
                    if (result.Count > 0)
                    {
                        if (result.Count == 1)
                        {
                            try
                            {
                                var   imputado         = ((cHuellasImputado)result.FirstOrDefault());
                                var   ultimo_ingreso   = new cIngreso().ObtenerUltimoIngreso(imputado.ID_CENTRO, imputado.ID_ANIO, imputado.ID_IMPUTADO);
                                var   ultima_ubicacion = new cIngresoUbicacion().ObtenerUltimaUbicacion(imputado.ID_ANIO, imputado.ID_CENTRO, (int)imputado.ID_IMPUTADO, ultimo_ingreso.ID_INGRESO);
                                var   LOCUTORIOS       = Parametro.UBICACION_VISITA_ACTUARIO;
                                var   SALA_ABOGADOS    = Parametro.UBICACION_VISITA_ABOGADO;
                                short SIN_AREA         = 0;
                                if (ultima_ubicacion != null)
                                {
                                    //if (ultima_ubicacion.ESTATUS == (short)enumUbicacion.EN_TRANSITO && (ultima_ubicacion.ID_AREA == LOCUTORIOS || ultima_ubicacion.ID_AREA == SALA_ABOGADOS))
                                    //{
                                    var aduana_ingreso          = new cAduanaIngreso();
                                    var consulta_aduana_ingreso = aduana_ingreso.ObtenerAduanaIngresoSinNotificacion(imputado.ID_CENTRO, imputado.ID_ANIO, imputado.ID_IMPUTADO, ultimo_ingreso.ID_INGRESO, Fechas.GetFechaDateServer).FirstOrDefault();
                                    if (consulta_aduana_ingreso != null)
                                    {
                                        new cAduanaIngreso().CambiarEstadoVisitaInterno(new INGRESO_UBICACION()
                                        {
                                            ID_CENTRO      = consulta_aduana_ingreso.ID_CENTRO,
                                            ID_ANIO        = consulta_aduana_ingreso.ID_ANIO,
                                            ID_IMPUTADO    = consulta_aduana_ingreso.ID_IMPUTADO,
                                            ID_INGRESO     = consulta_aduana_ingreso.ID_INGRESO,
                                            ID_CONSEC      = new cIngresoUbicacion().ObtenerConsecutivo <int>(imputado.ID_CENTRO, imputado.ID_ANIO, imputado.ID_IMPUTADO, ultimo_ingreso.ID_INGRESO),
                                            ID_AREA        = consulta_aduana_ingreso.ADUANA.ID_AREA != null ? (consulta_aduana_ingreso.ADUANA.ID_AREA == SALA_ABOGADOS ? SALA_ABOGADOS : LOCUTORIOS) : SIN_AREA,//ultima_ubicacion.ID_AREA == LOCUTORIOS ? LOCUTORIOS : SALA_ABOGADOS,
                                            MOVIMIENTO_FEC = Fechas.GetFechaDateServer,
                                            ACTIVIDAD      = VISITA_LEGAL,
                                            ESTATUS        = (short)enumUbicacion.ACTIVIDAD
                                        }, new ADUANA_INGRESO()
                                        {
                                            ID_ADUANA          = consulta_aduana_ingreso.ID_ADUANA,
                                            ID_CENTRO          = consulta_aduana_ingreso.ID_CENTRO,
                                            ID_ANIO            = consulta_aduana_ingreso.ID_ANIO,
                                            ID_IMPUTADO        = consulta_aduana_ingreso.ID_IMPUTADO,
                                            ID_INGRESO         = consulta_aduana_ingreso.ID_INGRESO,
                                            INTERNO_NOTIFICADO = INTERNO_NOTIFICADO
                                        });
                                        var imputado_entrante = new List <InternoVisitaLegal>();
                                        imputado_entrante.Add(new InternoVisitaLegal()
                                        {
                                            ID_CENTRO   = imputado.ID_CENTRO,
                                            ID_ANIO     = imputado.ID_ANIO,
                                            ID_IMPUTADO = (short)imputado.ID_IMPUTADO,
                                            PATERNO     = ultimo_ingreso.IMPUTADO.PATERNO.TrimEnd(),
                                            MATERNO     = ultimo_ingreso.IMPUTADO.MATERNO.TrimEnd(),
                                            NOMBRE      = ultimo_ingreso.IMPUTADO.NOMBRE.TrimEnd(),
                                            PERMITIR    = true,
                                            HABILITAR   = true
                                        });
                                        ImputadoEntrante = imputado_entrante;
                                        SelectedImputado = ImputadoEntrante.FirstOrDefault();
                                        var huella = HuellasImputadosVisitas.Where(w =>
                                                                                   w.IMPUTADO.ID_CENTRO == SelectedImputado.ID_CENTRO &&
                                                                                   w.IMPUTADO.ID_ANIO == SelectedImputado.ID_ANIO &&
                                                                                   w.IMPUTADO.ID_IMPUTADO == SelectedImputado.ID_IMPUTADO).FirstOrDefault();
                                        HuellasImputadosVisitas.Remove(huella);
                                        var placeholder      = new Imagenes().getImagenPerson();
                                        var foto_seguimiento = consulta_aduana_ingreso.INGRESO.INGRESO_BIOMETRICO != null?consulta_aduana_ingreso.INGRESO.INGRESO_BIOMETRICO.Where(w =>
                                                                                                                                                                                   w.BIOMETRICO_TIPO.ID_TIPO_BIOMETRICO == (short)enumTipoBiometrico.FOTO_FRENTE_SEGUIMIENTO).FirstOrDefault() : null;

                                        var foto_registro = consulta_aduana_ingreso.INGRESO.INGRESO_BIOMETRICO != null?consulta_aduana_ingreso.INGRESO.INGRESO_BIOMETRICO.Where(w =>
                                                                                                                                                                                w.BIOMETRICO_TIPO.ID_TIPO_BIOMETRICO == (short)enumTipoBiometrico.FOTO_FRENTE_REGISTRO).FirstOrDefault() : null;

                                        ImagenImputado   = foto_seguimiento != null ? foto_seguimiento.BIOMETRICO : (foto_registro != null ? foto_registro.BIOMETRICO : placeholder);
                                        MensajeResultado = enumMensajeResultadoComparacion.ENCONTRADO;
                                    }
                                    else
                                    {
                                        MensajeResultado = enumMensajeResultadoComparacion.NO_ENCONTRADO;
                                    }
                                    //}
                                    //else
                                    //{
                                    //    MensajeResultado = enumMensajeResultadoComparacion.NO_ENCONTRADO;
                                    //}
                                }
                                else
                                {
                                    MensajeResultado = enumMensajeResultadoComparacion.NO_ENCONTRADO;
                                }
                            }
                            catch (Exception ex)
                            {
                                throw new ApplicationException(ex.Message);
                            }
                        }
                        else
                        {
                            MensajeResultado = enumMensajeResultadoComparacion.COINCIDENCIAS;
                        }
                    }
                    else
                    {
                        MensajeResultado = enumMensajeResultadoComparacion.NO_ENCONTRADO;
                    }
                }
            }
            Application.Current.Dispatcher.Invoke((Action)(delegate()
            {
                CambiarMensaje(MensajeResultado);
            }));
        }
Пример #24
0
        private async void Identify(object Huella = null)
        {
            try
            {
                if (FingerPrintData == null)
                {
                    return;
                }

                LoginLoading = Visibility.Visible;
                var Service = new BiometricoServiceClient();

                var CompareResult = Service.CompararHuellaPersona(new ComparationRequest
                {
                    BIOMETRICO         = FeatureExtraction.CreateFmdFromFid(FingerPrintData, Constants.Formats.Fmd.ANSI).Data.Bytes,
                    ID_TIPO_PERSONA    = enumTipoPersona.PERSONA_EMPLEADO,
                    ID_TIPO_BIOMETRICO = DD_Dedo.HasValue ? DD_Dedo.Value : enumTipoBiometrico.INDICE_DERECHO,
                    ID_TIPO_FORMATO    = enumTipoFormato.FMTO_DP
                });//.CompararHuellaImputado(new ComparationRequest { BIOMETRICO = FeatureExtraction.CreateFmdFromFid(FingerPrintData, Constants.Formats.Fmd.ANSI).Data.Bytes, ID_TIPO_BIOMETRICO = DD_Dedo.HasValue ? DD_Dedo.Value : enumTipoBiometrico.INDICE_DERECHO, ID_TIPO_FORMATO = enumTipoFormato.FMTO_DP });

                if (CompareResult.Identify)
                {
                    ///TODO: cambiar usuario login ERNESTO
                    var result = CompareResult.Result[0];
                    GlobalVariables.gUser = "******"; //"QPERSONA";
                    GlobalVariables.gPass = "******"; //"QUADRO";
                    var persona = await StaticSourcesViewModel.CargarDatosAsync(() => new cPersona().ObtenerPersona(result.ID_PERSONA));

                    GlobalVariables.gUser = string.Empty;
                    GlobalVariables.gPass = string.Empty;
                    if (persona != null)
                    {
                        if (persona.EMPLEADO.USUARIO.Count > 0)
                        {
                            var u = persona.EMPLEADO.USUARIO.FirstOrDefault();
                            //persona.USUARIO.FirstOrDefault().ID_USUARIO.Trim();
                            User.Username = u.ID_USUARIO.Trim();
                            User.Password = string.Empty;
                            huella        = true;
                            Application.Current.Dispatcher.Invoke((System.Action)(delegate
                            {
                                autentificacion();
                            }));
                        }
                    }
                    //var NombreLogin = await StaticSourcesViewModel.CargarDatosAsync(() => new SSP.Controlador.Catalogo.Justicia.cImputado().GetData().Where(w => w.ID_ANIO == result.ID_ANIO && w.ID_CENTRO == result.ID_CENTRO && w.ID_IMPUTADO == result.ID_IMPUTADO).FirstOrDefault());
                    //User.Username = "******";
                    //User.Username = NombreLogin.NOMBRE.Trim() + " " + NombreLogin.PATERNO.Trim() + " " + NombreLogin.MATERNO.Trim();
                    //OnProgress.Start();
                }
                else
                {
                    ErrorLogin = res.ControlPenales.Login.LoginViewModel.usuario_contrasena_incorrecto;
                }

                FingerPrintData = null;
            }
            catch (Exception ex)
            {
                var trace = new System.Diagnostics.StackTrace(ex, true);
                Trace.WriteLine("\n>>>[Ubicación del Problema]");
                Trace.WriteLine("Clase: " + trace.GetFrame((trace.FrameCount - 1)).GetMethod().ReflectedType.FullName);
                Trace.WriteLine("Metodo: " + trace.GetFrame((trace.FrameCount - 1)).GetMethod().Name);
                Trace.WriteLine("Linea: " + trace.GetFrame((trace.FrameCount - 1)).GetFileLineNumber());
                Trace.WriteLine("Columna: " + trace.GetFrame((trace.FrameCount - 1)).GetFileColumnNumber());
                Trace.WriteLine(ex.Message + " " + (ex.InnerException != null ? ex.InnerException.InnerException.Message : ""));
                ErrorLogin = res.ControlPenales.Login.LoginViewModel.error_sesion;
            }
        }
Пример #25
0
        private void OnCaptured(CaptureResult result)
        {
            frmEncontrarDispositivo n = new frmEncontrarDispositivo();
            //if (n.conectado==false)
            //{
            //    DialogResult dialogoerror = globales.MessageBoxError("Ocurrio un error, no se detecta dispositivo", "Verificar", globales.menuPrincipal);
            //    return;
            //    dispo.Text = "DISPOSITIVO NO CONECTADO";
            //}

            DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(result.Data, Constants.Formats.Fmd.ANSI);

            if (result.ResultCode != Constants.ResultCode.DP_SUCCESS)
            {
                //throw new Exception(result.ResultCode.ToString());
            }


            Fmd capturado = resultConversion.Data;

            try
            {
                string hexa = ByteArrayToString(capturado.Bytes);
            }
            catch
            {
                CheckForIllegalCrossThreadCalls = false;
                dispo.Text = "DISPOSITIVO NO CONECTADO";
                return;
            }

            //    string query = $"select jpp,num,huella from nominas_catalogos.maestro where huella is not null order by jpp,num";
            string query = "select jpp,num,huella from nominas_catalogos.maestro where huella is not null  and huella <>'' order by jpp,num";
            List <Dictionary <string, object> > resultado = globales.consulta(query);

            if (resultado.Count <= 0)
            {
                return;
            }


            string caaaa = Fmd.SerializeXml(capturado);
            Fmd    dese  = Fmd.DeserializeXml(caaaa);

            bool encontrado = true;

            foreach (Dictionary <string, object> item in resultado)
            {
                string      xmlStr = Convert.ToString(item["huella"]);
                XmlDocument xml    = new XmlDocument();
                xml.LoadXml(xmlStr);
                Fmd   fmd  = Fmd.DeserializeXml(xmlStr);
                Fmd[] fmds = new Fmd[1];
                fmds[0] = fmd;
                // fmds[1] = capturado;


                int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;

                CompareResult  resultadoAux   = Comparison.Compare(capturado, 0, fmd, 0);
                IdentifyResult identifyResult = Comparison.Identify(capturado, 0, fmds, thresholdScore, 2);

                if (resultadoAux.Score == 0)
                {
                    realizarMensaje(tipo_mensaje.success, $"{item["jpp"]} encontrado");


                    query     = $"select * from nominas_catalogos.maestro where huella is not null and jpp = '{item["jpp"]}' and num = {item["num"]} order by jpp,num";
                    resultado = globales.consulta(query);
                    if (resultado.Count != 0)
                    {
                        huellita = true;
                        rellenar(resultado[0]);
                    }
                    encontrado = true;
                    break;
                }
                else
                {
                    encontrado = false;
                }

                if (resultadoAux.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    realizarMensaje(tipo_mensaje.exclamation, "UPS, NO SE ENCUENTRA LA HUELLA EN LA BASE");
                    encontrado = true;
                    return;
                }
            }

            if (!encontrado)
            {
                realizarMensaje(tipo_mensaje.exclamation, "UPS, NO SE ENCUENTRA LA HUELLA EN LA BASE");
            }
        }
Пример #26
0
        private Task <bool> CompareImputado(byte[] Huella = null, enumTipoBiometrico?Finger = null)
        {
            var bytesHuella = FingerPrintData != null?FeatureExtraction.CreateFmdFromFid(FingerPrintData, Constants.Formats.Fmd.ANSI).Data.Bytes : null ?? Huella;

            var verifyFinger = Finger ?? (DD_Dedo.HasValue ? DD_Dedo.Value : enumTipoBiometrico.INDICE_DERECHO);

            if (bytesHuella == null)
            {
                Application.Current.Dispatcher.Invoke((System.Action)(delegate
                {
                    if (Finger == null)
                    {
                        ScannerMessage = "Vuelve a capturar las huellas";
                    }
                    else
                    {
                        ScannerMessage = "Siguiente Huella";
                    }
                    AceptarBusquedaHuellaFocus = true;
                    ColorMessage = new SolidColorBrush(Colors.DarkOrange);
                    ShowLine     = Visibility.Collapsed;
                }));
            }
            Application.Current.Dispatcher.Invoke((System.Action)(delegate
            {
                ScannerMessage             = "Procesando...";
                ColorMessage               = new SolidColorBrush(System.Windows.Media.Color.FromRgb(51, 115, 242));
                AceptarBusquedaHuellaFocus = false;
            }));

            var Service = new BiometricoServiceClient();

            if (Service == null)
            {
                Application.Current.Dispatcher.Invoke((System.Action)(delegate
                {
                    ScannerMessage             = "Error en el servicio de comparacion";
                    AceptarBusquedaHuellaFocus = true;
                    ColorMessage = new SolidColorBrush(Colors.Red);
                    ShowLine     = Visibility.Collapsed;
                }));
            }
            var CompareResult = Service.CompararHuellaImputado(new ComparationRequest {
                BIOMETRICO = bytesHuella, ID_TIPO_BIOMETRICO = verifyFinger, ID_TIPO_FORMATO = enumTipoFormato.FMTO_DP
            });

            if (CompareResult.Identify)
            {
                ListResultado = ListResultado ?? new List <ResultadoBusquedaBiometrico>();

                foreach (var item in CompareResult.Result)
                {
                    var imputado = new cImputadoBiometrico().GetData().Where(w => w.ID_ANIO == item.ID_ANIO && w.ID_CENTRO == item.ID_CENTRO && w.ID_IMPUTADO == item.ID_IMPUTADO && w.ID_TIPO_BIOMETRICO == (DD_Dedo.HasValue ? (short)DD_Dedo.Value : (short)enumTipoBiometrico.INDICE_DERECHO) && w.ID_FORMATO == (short)enumTipoFormato.FMTO_DP).FirstOrDefault();

                    if (imputado == null)
                    {
                        ScannerMessage = "Registro no encontrado";
                        TextoBoton     = "Crear Nuevo Expediente";
                        ColorMessage   = new SolidColorBrush(Colors.Red);
                        return(TaskEx.FromResult(false));
                    }

                    Imputado = imputado.IMPUTADO;

                    ShowContinuar = Visibility.Collapsed;
                    if (imputado == null)
                    {
                        continue;
                    }

                    Application.Current.Dispatcher.Invoke((System.Action)(delegate
                    {
                        var ingresobiometrico  = imputado.IMPUTADO.INGRESO.OrderByDescending(o => o.ID_INGRESO).FirstOrDefault();
                        var FotoBusquedaHuella = new Imagenes().ConvertByteToBitmap(new Imagenes().getImagenPerson());

                        if (ingresobiometrico != null)
                        {
                            if (ingresobiometrico.INGRESO_BIOMETRICO.Any())
                            {
                                if (ingresobiometrico.INGRESO_BIOMETRICO.Where(w => w.ID_TIPO_BIOMETRICO == (short)enumTipoBiometrico.FOTO_FRENTE_SEGUIMIENTO && w.ID_FORMATO == (short)enumTipoFormato.FMTO_JPG).Any())
                                {
                                    FotoBusquedaHuella = new Imagenes().ConvertByteToBitmap(ingresobiometrico.INGRESO_BIOMETRICO.Where(w => w.ID_TIPO_BIOMETRICO == (short)enumTipoBiometrico.FOTO_FRENTE_SEGUIMIENTO && w.ID_FORMATO == (short)enumTipoFormato.FMTO_JPG).SingleOrDefault().BIOMETRICO);
                                }
                                else
                                if (ingresobiometrico.INGRESO_BIOMETRICO.Where(w => w.ID_TIPO_BIOMETRICO == (short)enumTipoBiometrico.FOTO_FRENTE_REGISTRO && w.ID_FORMATO == (short)enumTipoFormato.FMTO_JPG).Any())
                                {
                                    FotoBusquedaHuella = new Imagenes().ConvertByteToBitmap(ingresobiometrico.INGRESO_BIOMETRICO.Where(w => w.ID_TIPO_BIOMETRICO == (short)enumTipoBiometrico.FOTO_FRENTE_REGISTRO && w.ID_FORMATO == (short)enumTipoFormato.FMTO_JPG).SingleOrDefault().BIOMETRICO);
                                }
                            }
                        }

                        ListResultado.Add(new ResultadoBusquedaBiometrico()
                        {
                            Nombre     = imputado.IMPUTADO.NOMBRE,
                            APaterno   = imputado.IMPUTADO.PATERNO,
                            AMaterno   = imputado.IMPUTADO.MATERNO,
                            Expediente = imputado.ID_ANIO + "/" + imputado.ID_IMPUTADO,
                            NIP        = imputado.IMPUTADO.NIP.ToString(),
                            Foto       = FotoBusquedaHuella,
                            Imputado   = imputado.IMPUTADO
                        });
                    }));
                }

                ListResultado = new List <ResultadoBusquedaBiometrico>(ListResultado);

                ShowContinuar = Visibility.Collapsed;

                if (ListResultado.Any())
                {
                    Application.Current.Dispatcher.Invoke((System.Action)(delegate
                    {
                        if (!CancelKeepSearching)
                        {
                            ScannerMessage             = "Registro encontrado";
                            AceptarBusquedaHuellaFocus = true;
                            ColorMessage = new SolidColorBrush(Colors.Green);
                        }
                    }));

                    if (Finger != null)
                    {
                        Service.Close();
                    }

                    return(TaskEx.FromResult(false));
                }
                else
                {
                    Application.Current.Dispatcher.Invoke((System.Action)(delegate
                    {
                        if (!CancelKeepSearching)
                        {
                            ScannerMessage             = "Registro no encontrado";
                            AceptarBusquedaHuellaFocus = true;
                            ColorMessage = new SolidColorBrush(Colors.Red);
                        }
                    }));
                }
            }
            else
            {
                Application.Current.Dispatcher.Invoke((System.Action)(delegate
                {
                    if (!CancelKeepSearching)
                    {
                        ScannerMessage             = "Huella no encontrada";
                        ColorMessage               = new SolidColorBrush(Colors.Red);
                        AceptarBusquedaHuellaFocus = true;
                    }
                }));
                _IsSucceed = false;
                if (!CancelKeepSearching)
                {
                    _SelectRegistro = null;
                }
                PropertyImage = null;
            }

            Service.Close();
            FingerPrintData = null;

            return(TaskEx.FromResult(true));
        }
        //HUELLA PARA LOS CUSTODIOS
        private Task <bool> CompararHuellaCustodio(byte[] Huella = null, enumTipoBiometrico?Finger = null)
        {
            try
            {
                var bytesHuella = FingerPrintData != null?FeatureExtraction.CreateFmdFromFid(FingerPrintData, Constants.Formats.Fmd.ANSI).Data.Bytes : null ?? Huella;

                var verifyFinger = Finger ?? (DD_DedoHuella.HasValue ? DD_DedoHuella.Value : enumTipoBiometrico.INDICE_DERECHO);
                ImagenCustodio                = null;
                ListResultadoCustodio         = null;
                TextoRegistroEdificioCustodio = null;

                if (bytesHuella == null)
                {
                    Application.Current.Dispatcher.Invoke((System.Action)(delegate
                    {
                        if (Finger == null)
                        {
                            ScannerMessage = "Vuelve a capturar las huellas";
                        }
                        else
                        {
                            ScannerMessage = "Siguiente Huella";
                        }
                        FocusAceptarBusquedaHuella = true;
                        ColorMensaje = new SolidColorBrush(Colors.DarkOrange);
                        ShowLinea    = Visibility.Collapsed;
                    }));
                }
                Application.Current.Dispatcher.Invoke((System.Action)(delegate
                {
                    ScannerMessage             = "Procesando...";
                    ColorMensaje               = new SolidColorBrush(System.Windows.Media.Color.FromRgb(51, 115, 242));
                    FocusAceptarBusquedaHuella = false;
                }));
                var Service = new BiometricoServiceClient();
                if (Service == null)
                {
                    Application.Current.Dispatcher.Invoke((System.Action)(delegate
                    {
                        ScannerMessage             = "Error en el servicio de comparación";
                        FocusAceptarBusquedaHuella = true;
                        ColorMensaje = new SolidColorBrush(Colors.Red);
                        ShowLinea    = Visibility.Collapsed;
                    }));
                }
                var CompareResult = Service.CompararHuellaPersona(new ComparationRequest {
                    BIOMETRICO = bytesHuella, ID_TIPO_BIOMETRICO = verifyFinger, ID_TIPO_FORMATO = enumTipoFormato.FMTO_DP, ID_TIPO_PERSONA = enumTipoPersona.PERSONA_EMPLEADO, ID_CENTRO = GlobalVar.gCentro
                });
                //var CompareResult = Service.CompararHuellaPersona(new ComparationRequest { BIOMETRICO = bytesHuella, ID_TIPO_BIOMETRICO = verifyFinger, ID_TIPO_FORMATO = enumTipoFormato.FMTO_DP, ID_TIPO_PERSONA = enumTipoPersona.PERSONA_EMPLEADO });

                if (CompareResult.Identify)
                {
                    ListResultadoCustodio = ListResultadoCustodio ?? new List <ResultadoBusquedaBiometricoCustodio>();

                    if (CompareResult.Result.Count() > 1)
                    {
                        TextoRegistroEdificioCustodio = "NOTA: Se encontró más de una coincidencia, por favor intente de nuevo";
                        ScannerMessage = "";
                        return(TaskEx.FromResult(false));
                    }
                    else
                    {
                        foreach (var item in CompareResult.Result)
                        {
                            var custodio = new cPersonaBiometrico().GetData().Where(w => w.ID_PERSONA == item.ID_PERSONA && (w.ID_TIPO_BIOMETRICO == (DD_DedoHuella.HasValue ? (short)DD_DedoHuella.Value : (short)enumTipoBiometrico.INDICE_DERECHO) && w.ID_FORMATO == (short)enumTipoFormato.FMTO_DP)).OrderBy(o => o.ID_PERSONA).FirstOrDefault();

                            ShowContinue = Visibility.Collapsed;
                            if (custodio == null)
                            {
                                continue;
                            }

                            Application.Current.Dispatcher.Invoke((System.Action)(delegate
                            {
                                var custodio_biometrico = custodio.PERSONA;
                                var FotoBusquedaHuella  = new Imagenes().ConvertByteToBitmap(new Imagenes().getImagenPerson());

                                if (custodio_biometrico != null)
                                {
                                    if (custodio_biometrico.PERSONA_BIOMETRICO.Where(w => w.ID_TIPO_BIOMETRICO == (short)enumTipoBiometrico.FOTO_FRENTE_SEGUIMIENTO && w.ID_FORMATO == (short)enumTipoFormato.FMTO_JPG).Any())
                                    {
                                        FotoBusquedaHuella = new Imagenes().ConvertByteToBitmap(custodio_biometrico.PERSONA_BIOMETRICO.Where(w => w.ID_TIPO_BIOMETRICO == (short)enumTipoBiometrico.FOTO_FRENTE_SEGUIMIENTO && w.ID_FORMATO == (short)enumTipoFormato.FMTO_JPG).SingleOrDefault().BIOMETRICO);
                                    }
                                    else
                                    if (custodio_biometrico.PERSONA_BIOMETRICO.Where(w => w.ID_TIPO_BIOMETRICO == (short)enumTipoBiometrico.FOTO_FRENTE_REGISTRO && w.ID_FORMATO == (short)enumTipoFormato.FMTO_JPG).Any())
                                    {
                                        FotoBusquedaHuella = new Imagenes().ConvertByteToBitmap(custodio_biometrico.PERSONA_BIOMETRICO.Where(w => w.ID_TIPO_BIOMETRICO == (short)enumTipoBiometrico.FOTO_FRENTE_REGISTRO && w.ID_FORMATO == (short)enumTipoFormato.FMTO_JPG).SingleOrDefault().BIOMETRICO);
                                    }
                                }

                                ListResultadoCustodio.Add(new ResultadoBusquedaBiometricoCustodio()
                                {
                                    IdPersona  = custodio.PERSONA.ID_PERSONA,
                                    Nombre     = string.IsNullOrEmpty(custodio.PERSONA.NOMBRE) ? string.Empty : custodio.PERSONA.NOMBRE.TrimEnd(),
                                    CPaterno   = string.IsNullOrEmpty(custodio.PERSONA.PATERNO) ? string.Empty : custodio.PERSONA.PATERNO.TrimEnd(),
                                    CMaterno   = string.IsNullOrEmpty(custodio.PERSONA.MATERNO) ? string.Empty : custodio.PERSONA.MATERNO.TrimEnd(),
                                    ENCONTRADO = true,
                                    Persona    = custodio.PERSONA
                                });
                            }));
                            ImagenCustodio = new cPersonaBiometrico().ObtenerTodos(custodio.ID_PERSONA, (short)enumTipoBiometrico.FOTO_FRENTE_REGISTRO).Any() ? new cPersonaBiometrico().ObtenerTodos(custodio.ID_PERSONA, (short)enumTipoBiometrico.FOTO_FRENTE_REGISTRO).FirstOrDefault().BIOMETRICO : new Imagenes().getImagenPerson();
                        }
                    }

                    foreach (var llenar in ListResultadoCustodio)
                    {
                        var igual = ListaCustodio.Where(w => w.IdPersona == llenar.IdPersona).Count();

                        if (igual == 0)
                        {
                            ListaCustodio.Add(llenar);
                        }
                        else
                        {
                            llenar.ENCONTRADO = false;
                        }
                        ListResultadoCustodio = new List <ResultadoBusquedaBiometricoCustodio>(ListResultadoCustodio);
                        ShowContinue          = Visibility.Collapsed;

                        if (ListResultadoCustodio.Any())
                        {
                            Application.Current.Dispatcher.Invoke((System.Action)(delegate
                            {
                                if (igual > 0)
                                {
                                    ScannerMessage             = "Registro repetido";
                                    FocusAceptarBusquedaHuella = true;
                                    ColorMensaje = new SolidColorBrush(Colors.Orange);
                                }
                                else if (!CancelKeepSearching)
                                {
                                    ScannerMessage             = "Registro encontrado";
                                    FocusAceptarBusquedaHuella = true;
                                    ColorMensaje = new SolidColorBrush(Colors.Green);
                                }
                            }));
                            if (Finger != null)
                            {
                                Service.Close();
                            }

                            return(TaskEx.FromResult(false));
                        }
                    }
                }
                else
                {
                    Application.Current.Dispatcher.Invoke((System.Action)(delegate
                    {
                        if (!CancelKeepSearching)
                        {
                            ScannerMessage             = "Huella no encontrada";
                            ColorMensaje               = new SolidColorBrush(Colors.Red);
                            FocusAceptarBusquedaHuella = true;
                            ImagenCustodio             = ImagenPlaceHolder.getImagenPerson();
                        }
                    }));
                    IsSucceded = false;
                    if (!CancelKeepSearching)
                    {
                        SelectedRegistroCustodio = null;
                    }
                    PropertyImage = null;
                }
                Service.Close();
                FingerPrintData = null;

                return(TaskEx.FromResult(true));
            }
            catch (System.ServiceModel.EndpointNotFoundException ex)
            {
                StaticSourcesViewModel.ShowMessageError("Algo pasó...", "No se pudo conectar al servidor de huellas", ex);
                return(TaskEx.FromResult(false));
            }
            catch (Exception ex)
            {
                StaticSourcesViewModel.ShowMessageError("Algo pasó...", "Ocurrió un error al cargar búsqueda", ex);
                return(TaskEx.FromResult(false));
            }
        }
Пример #28
0
        void reader_On_Captured(CaptureResult result)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new Function(delegate
                {
                    if (result.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        MessageBox.Show("Capture failed.");
                        return;
                    }

                    Fid fid = result.Data;

                    //Extract pre-registration features
                    DataResult <Fmd> fmd = FeatureExtraction.CreateFmdFromFid(result.Data, Constants.Formats.Fmd.DP_PRE_REGISTRATION);
                    if (fmd.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        MessageBox.Show("Error extracting features from image.  Please try again");
                        return;
                    }

                    listPreRegFMDs.Add(fmd.Data);  //Add good image to list of fids

                    //Attempt to create enrollment Fmd from list of fids
                    DataResult <Fmd> enrollmentFMD = Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.DP_REGISTRATION, listPreRegFMDs);

                    if (enrollmentFMD.ResultCode == Constants.ResultCode.DP_ENROLLMENT_INVALID_SET)
                    {
                        MessageBox.Show("Enrollment failed.  Please try again.");
                        pressCount = 0;
                        pb1.Image  = null;
                        pb2.Image  = null;
                        pb3.Image  = null;
                        pb4.Image  = null;
                        //reader.CaptureAsync(Constants.Formats.Fid.ISO, Constants.CaptureProcessing.DP_IMG_PROC_DEFAULT, reader.Capabilities.Resolutions[0]);
                        return;
                    }

                    if (pressCount == 0)
                    {
                        pb1.Image = new Bitmap(Fid2Bitmap.CreateBitmap(result.Data.Views[0].Bytes, fid.Views[0].Width, fid.Views[0].Height), pb1.Size);
                    }
                    else if (pressCount == 1)
                    {
                        pb2.Image = new Bitmap(Fid2Bitmap.CreateBitmap(fid.Views[0].Bytes, fid.Views[0].Width, fid.Views[0].Height), pb2.Size);
                    }
                    else if (pressCount == 2)
                    {
                        pb3.Image = new Bitmap(Fid2Bitmap.CreateBitmap(fid.Views[0].Bytes, fid.Views[0].Width, fid.Views[0].Height), pb3.Size);
                    }
                    else if (pressCount == 3) //Dont increment.  Say on last picture box until successfull registration
                    {
                        pb4.Image = new Bitmap(Fid2Bitmap.CreateBitmap(fid.Views[0].Bytes, fid.Views[0].Width, fid.Views[0].Height), pb4.Size);
                    }

                    ++pressCount;

                    if (enrollmentFMD.ResultCode == Constants.ResultCode.DP_SUCCESS) //enrollment FMD created
                    {
                        //if (rbLeftIndex.Checked)
                        //{
                        //    leftIndex = enrollmentFMD.Data;
                        //    //rbRightIndex.Checked = true;
                        //    lblInfo.Text = "Now press your right index 4 or more times.";
                        //    pb1.Image = null;  pb2.Image = null; pb3.Image = null; pb4.Image = null;
                        //    pressCount = 0;
                        //    listPreRegFMDs.Clear();
                        //}
                        //else
                        //{
                        fmd1            = enrollmentFMD.Data;
                        btnSave.Enabled = true;
                        //reader.CancelCapture();
                        //MessageBox.Show("Fingerprint enrollment complete.  Click 'Save' to complete registration.");
                        //}
                    }
                }));
            }
        }
Пример #29
0
        private void IdentifyThread()
        {
            while (!reset)
            {
                Fid fid = null;

                if (!CaptureFinger(ref fid))
                {
                    //break;
                }

                if (objReader == null)
                {
                    objReader = objDeviceReader.IndexDevice();
                    objDeviceReader.InitializeDevice(ref objReader);
                }

                if (fid == null)
                {
                    continue;
                }

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(fid, Constants.Formats.Fmd.ANSI);


                if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    //break;

                    if (objReader != null)
                    {
                        objReader.Dispose();
                        objReader = null;
                    }
                    return;
                }

                int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;

                Fmd aux = resultConversion.Data;
                Fmd temp;
                foreach (Clases.Persona item in listPersons)
                {
                    try
                    {
                        temp = Fmd.DeserializeXml(item.huella);

                        CompareResult identifyResult = Comparison.Compare(aux, 0, temp, 0);

                        if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                        {
                            break;
                        }

                        var responseString = "";

                        if (identifyResult.Score < thresholdScore)
                        {
                            //guardar la asistencia en la base de datos
                            try
                            {
                                using (var client = new WebClient())
                                {
                                    DateTime checada = DateTime.Now;
                                    var      values  = new NameValueCollection();
                                    values["cuenta"]  = item.id;
                                    values["evento"]  = _evento;
                                    values["checada"] = checada.ToString("yyyy-MM-dd H:mm:ss");
                                    var response = client.UploadValues("http://facite.uas.edu.mx/agenda/registrar_checada.php", values);
                                    responseString = Encoding.Default.GetString(response);
                                }
                            }
                            catch (Exception err)
                            {
                                MessageBox.Show(err.Message);
                            }

                            SendMessage(responseString, item.Nombre, "Se registró a las " + DateTime.Now.ToShortTimeString(), "", "", "");

                            Thread.Sleep(3000);
                            SendMessage("Coloque el dedo en el checador...", "", "", "", "", "");
                            menuPrincipal.Dispatcher.BeginInvoke(new Action(delegate()
                            {
                                menuPrincipal.lbl_fechas.Content = "";
                                menuPrincipal.lbl_resto.Content  = "";
                            }));
                            break;
                        }
                        else
                        {
                            //SendMessage("No se encuentra registrada la huella", "", "", "","","");
                            //
                            Thread.Sleep(2000);
                            SendMessage("Coloque el dedo en el checador...", "", "", "", "", "");
                            menuPrincipal.Dispatcher.BeginInvoke(new Action(delegate()
                            {
                                menuPrincipal.lbl_fechas.Content = "";
                                menuPrincipal.lbl_resto.Content  = "";
                            }));
                            //break;
                        }
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show(error.Message);
                    }
                }
            }

            if (objReader != null)
            {
                objReader.Dispose();
            }
        }
Пример #30
0
        /// <summary>
        /// Open a reader and capture three fingers to identify with.
        /// </summary>
        private void IdentifyThread()
        {
            Constants.ResultCode result = Constants.ResultCode.DP_DEVICE_FAILURE;

            result = Sender.CurrentReader.Open(Constants.CapturePriority.DP_PRIORITY_COOPERATIVE);

            if (result != Constants.ResultCode.DP_SUCCESS)
            {
                MessageBox.Show("Error:  " + result);
                if (Sender.CurrentReader != null)
                {
                    Sender.CurrentReader.Dispose();
                    Sender.CurrentReader = null;
                }
                return;
            }

            Fmd fmd1 = null;
            Fmd fmd2 = null;
            Fmd fmd3 = null;

            SendMessage("Place your right index finger on the reader.");

            var count = 0;

            while (!reset)
            {
                Fid fid = null;

                if (!Sender.CaptureFinger(ref fid))
                {
                    break;
                }

                if (fid == null)
                {
                    continue;
                }

                SendMessage("A finger was captured.");

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(fid, Constants.Formats.Fmd.ANSI);

                if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    break;
                }

                if (count == 0)
                {
                    fmd1   = resultConversion.Data;
                    count += 1;
                    SendMessage("Now place your right thumb on the reader.");
                }
                else if (count == 1)
                {
                    fmd2   = resultConversion.Data;
                    count += 1;
                    SendMessage("Now place any finger on the reader.");
                }
                else if (count == 2)
                {
                    fmd3 = resultConversion.Data;
                    Fmd[] fmds = new Fmd[2];
                    fmds[0] = fmd1;
                    fmds[1] = fmd2;

                    // See the SDK documentation for an explanation on threshold scores.
                    int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;

                    IdentifyResult identifyResult = Comparison.Identify(fmd3, 0, fmds, thresholdScore, 2);

                    if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        break;
                    }

                    SendMessage("Identification resulted in the following number of matches: " + identifyResult.Indexes.Length.ToString());
                    SendMessage("Place your right index finger on the reader.");
                    count = 0;
                }
            }

            if (Sender.CurrentReader != null)
            {
                Sender.CurrentReader.Dispose();
            }
        }