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;
            }
        }
Пример #2
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";
            }
        }
Пример #3
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;
            }
        }
        //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));
            }
        }
Пример #5
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));
        }
Пример #6
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;
        }
Пример #7
0
        private Task <bool> ComparePersona(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.CompararHuellaPersona(new ComparationRequest
            {
                BIOMETRICO         = bytesHuella,
                ID_TIPO_BIOMETRICO = verifyFinger,
                ID_TIPO_FORMATO    = enumTipoFormato.FMTO_DP,
                ID_TIPO_PERSONA    = BuscarPor == enumTipoPersona.PERSONA_TODOS ? new Nullable <enumTipoPersona>() : BuscarPor
            });

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

                foreach (var item in CompareResult.Result)
                {
                    var persona = new cPersonaBiometrico().GetData().Where(w => w.ID_PERSONA == item.ID_PERSONA && (w.ID_TIPO_BIOMETRICO == (DD_Dedo.HasValue ? (short)DD_Dedo.Value : (short)enumTipoBiometrico.INDICE_DERECHO)) && w.ID_FORMATO == (short)enumTipoFormato.FMTO_DP).FirstOrDefault();

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

                    Application.Current.Dispatcher.Invoke((System.Action)(delegate
                    {
                        var perosonabiometrico = new cPersonaBiometrico().GetData().Where(w => w.ID_PERSONA == persona.ID_PERSONA).ToList();
                        var FotoBusquedaHuella = new Imagenes().ConvertByteToBitmap(new Imagenes().getImagenPerson());

                        if (perosonabiometrico != null)
                        {
                            if (perosonabiometrico.Any())
                            {
                                if (perosonabiometrico.Where(w => w.ID_TIPO_BIOMETRICO == (short)enumTipoBiometrico.FOTO_FRENTE_SEGUIMIENTO && w.ID_FORMATO == (short)enumTipoFormato.FMTO_JPG).Any())
                                {
                                    FotoBusquedaHuella = new Imagenes().ConvertByteToBitmap(perosonabiometrico.Where(w => w.ID_TIPO_BIOMETRICO == (short)enumTipoBiometrico.FOTO_FRENTE_SEGUIMIENTO && w.ID_FORMATO == (short)enumTipoFormato.FMTO_JPG).SingleOrDefault().BIOMETRICO);
                                }
                                else
                                if (perosonabiometrico.Where(w => w.ID_TIPO_BIOMETRICO == (short)enumTipoBiometrico.FOTO_FRENTE_REGISTRO && w.ID_FORMATO == (short)enumTipoFormato.FMTO_JPG).Any())
                                {
                                    FotoBusquedaHuella = new Imagenes().ConvertByteToBitmap(perosonabiometrico.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     = persona.PERSONA.NOMBRE,
                            APaterno   = persona.PERSONA.PATERNO,
                            AMaterno   = persona.PERSONA.MATERNO,
                            Expediente = persona.PERSONA.ID_PERSONA.ToString(),
                            NIP        = persona.PERSONA.PERSONA_NIP.Where(w => w.ID_CENTRO == GlobalVar.gCentro).Any() ?
                                         persona.PERSONA.PERSONA_NIP.Where(w => w.ID_CENTRO == GlobalVar.gCentro).FirstOrDefault().NIP.HasValue
                                    ? persona.PERSONA.PERSONA_NIP.Where(w => w.ID_CENTRO == GlobalVar.gCentro).FirstOrDefault().NIP.Value.ToString()
                                        : string.Empty : string.Empty,
                            Foto    = FotoBusquedaHuella,
                            Persona = persona.PERSONA
                        });
                    }));
                }

                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));
        }