コード例 #1
0
ファイル: frmCapturarFoto.cs プロジェクト: ABMTY/BioZ
        private void btnGuardarFoto_Click(object sender, EventArgs e)
        {
            //Image imagenrec = CambiarTamanoImagen(pcbFoto.Image, 320, 300);
            // Este metodo guarda la plantilla ya generada satisfactoriamente a la base de datos
            try
            {
                EntEmpleado entEmpleado = ctrlEmpleado.Obtener(int.Parse(Id_Empleado));
                ctrlEmpleado.Actualizar(new EntEmpleado
                {
                    id_empleado     = entEmpleado.id_empleado,
                    nombre          = entEmpleado.nombre,
                    ap_paterno      = entEmpleado.ap_paterno,
                    ap_materno      = entEmpleado.ap_materno,
                    id_departamento = entEmpleado.id_departamento,
                    id_sucursal     = entEmpleado.id_sucursal,
                    enrollnumber    = entEmpleado.enrollnumber,
                    imagen          = ImageToBase64(pcbFotoRecortada.Image, System.Drawing.Imaging.ImageFormat.Png)
                });

                frmListaEmpleados listaEmpleado = new frmListaEmpleados();
                listaEmpleado.MessageBoxShow("Se registro la foto exitosamente!", "Guardar");
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        public ActionResult Guardar(EntEmpleado entidad)
        {
            var r = false;

            try
            {
                if (entidad.id_empleado > 0)
                {
                    r = control.Actualizar(entidad);
                }
                else
                {
                    r = control.Insertar(entidad);
                    //GuardarDispositivo(new UserInfo
                    //{
                    //    EnrollNumber = entidad.enrollnumber.ToString(),
                    //    Name = entidad.nombre
                    //});
                }

                if (!r)
                {
                    return(Json("Error al realizar la operacion", JsonRequestBehavior.AllowGet));
                }

                return(Json("Realizado", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Empleados", "Create")));
            }
        }
コード例 #3
0
        public ActionResult Guardar(EntEmpleado entidad)
        {
            var r = false;

            try
            {
                if (entidad.id_empleado > 0)
                {
                    r = control.Actualizar(entidad);
                }
                else
                {
                    r = control.Insertar(entidad);
                    int id_empleado = control.ObtenerTodos().ToList().Max(p => p.id_empleado);
                    GuardarenDispositivoRH(new UserInfo
                    {
                        id_empleado    = id_empleado,
                        EnrollNumber   = entidad.enrollnumber.ToString(),
                        Name           = entidad.nombre,
                        id_dispositivo = entidad.id_dispositivo,
                    });
                }

                if (!r)
                {
                    return(Json("Error al realizar la operacion", JsonRequestBehavior.AllowGet));
                }

                return(Json("Realizado", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Empleados", "Create")));
            }
        }
コード例 #4
0
ファイル: Validar.cs プロジェクト: ABMTY/ServicioBioZ
        private bool RegistrarCheckinout(EntEmpleado entidad)
        {
            bool r = false;

            try
            {
                Checkinout checkinout = new Checkinout();
                checkinout.id_empleado = entidad.id_empleado;
                checkinout.anio        = DateTime.Now.Year;
                checkinout.mes         = DateTime.Now.Month;
                checkinout.dia         = DateTime.Now.Day;
                checkinout.hora        = DateTime.Now.Hour;
                checkinout.minuto      = DateTime.Now.Minute;
                checkinout.segundo     = DateTime.Now.Second;
                checkinout.Device      = GetLocalIPAddress();
                checkinout.id_sucursal = entidad.id_sucursal;
                r = ctrl_checkinout.Insertar(checkinout);
            }
            catch (Exception)
            {
                throw;
            }

            return(r);
        }
コード例 #5
0
ファイル: PerEmpleados.cs プロジェクト: ABMTY/BioZ
        public bool Insert(EntEmpleado entidad)
        {
            bool respuesta = false;

            try
            {
                var sql = string.Empty;
                AbrirConexion();
                if (entidad.imagen != null)
                {
                    sql = "execute procedure dml_empleados (?,NULL,?,?,?,?,?,?,?,?);";
                }
                else
                {
                    sql = "execute procedure dml_empleados (?,NULL,?,?,?,?,?,?,NULL,?);";
                }

                using (var cmd = new IfxCommand(sql, Conexion))
                {
                    cmd.Connection = Conexion;
                    cmd.Parameters.Add(new IfxParameter()).Value = "INSERT";
                    cmd.Parameters.Add(new IfxParameter()).Value = entidad.nombre;
                    cmd.Parameters.Add(new IfxParameter()).Value = entidad.ap_paterno;
                    cmd.Parameters.Add(new IfxParameter()).Value = entidad.ap_materno;
                    cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_departamento;
                    cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_sucursal;
                    cmd.Parameters.Add(new IfxParameter()).Value = entidad.enrollnumber;
                    if (entidad.imagen != null)
                    {
                        cmd.Parameters.Add(new IfxParameter()).Value = entidad.imagen;
                    }
                    cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_dispositivo;

                    cmd.ExecuteNonQuery();
                }
                respuesta = true;
            }

            catch (InvalidCastException ex)
            {
                ApplicationException excepcion = new ApplicationException("Se genero un error con el siguiente mensaje: " + ex.Message, ex);
                excepcion.Source = "Insert Empleados";
                throw excepcion;
            }
            catch (Exception ex)
            {
                ApplicationException excepcion = new ApplicationException("Se genero un error de aplicación con el siguiente mensaje: " + ex.Message, ex);
                excepcion.Source = "Insert Empleados";
                throw excepcion;
            }
            finally
            {
                CerrarConexion();
            }
            return(respuesta);
        }
コード例 #6
0
        public ActionResult Enroll(EntDispositivo entidad)
        {
            int idwFingerIndex = 0;

            try
            {
                EntDispositivo Dispositivo = ctrlDispositivo.ObtenerDispositivo(entidad.id_dispositivo);
                EntEmpleado    Empleado    = control.Obtener(entidad.id_empleado);

                if (Connect(Dispositivo.ip_dispositivo, int.Parse(Dispositivo.puerto)))
                {
                    int Enrollnumber = GetEnrollNumber_AnotherDevice(Dispositivo.numeroequipo);

                    if (Empleado.empleadohuellas.Count() > 0)
                    {
                        if (objZkeeper.SSR_SetUserInfo(Dispositivo.numeroequipo, Enrollnumber.ToString(), Empleado.nombre, Empleado.id_empleado.ToString(), 0, true))
                        {
                            foreach (EmpleadoHuella empleado_huella in Empleado.empleadohuellas)
                            {
                                for (idwFingerIndex = 0; idwFingerIndex < Empleado.empleadohuellas.Count(); idwFingerIndex++)
                                {
                                    objZkeeper.SetUserTmpExStr(Dispositivo.numeroequipo, Enrollnumber.ToString(), int.Parse(empleado_huella.fingerIndex), int.Parse(empleado_huella.flag), empleado_huella.huella);
                                }
                            }
                        }

                        EntEnrolamiento entidadEnrolamiento = new EntEnrolamiento();
                        entidadEnrolamiento.id_empleado    = Empleado.id_empleado;
                        entidadEnrolamiento.id_dispositivo = Dispositivo.id_dispositivo;
                        entidadEnrolamiento.enrollnumber   = Enrollnumber;
                        ctrlEnrolamiento.Insertar(entidadEnrolamiento);
                    }
                    else
                    {
                        return(Json("SinHuellas", JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Json("SinConexion", JsonRequestBehavior.AllowGet));
                }



                return(Json("Realizado", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Dspositivos", "Create")));
            }
        }
コード例 #7
0
ファイル: PerEmpleados.cs プロジェクト: ABMTY/BioZ
        public List <EntEmpleado> ObtenerPorEmpresa(int id_empresa)
        {
            List <EntEmpleado> Lista   = new List <EntEmpleado>();
            EntEmpleado        entidad = null;

            try
            {
                AbrirConexion();
                StringBuilder CadenaSql = new StringBuilder();
                var           sql       = "SELECT a.id_empleado,a.nombre,a.ap_paterno,a.ap_materno,a.id_departamento,a.id_sucursal,a.enrollnumber,a.imagen,b.desc_departamento,c.desc_sucursal,a.id_dispositivo ";
                sql += "FROM informix.empleados a inner join informix.departamentos b on a.id_departamento=b.id_departamento inner join informix.sucursales c on a.id_sucursal=c.id_sucursal";
                sql += " WHERE c.id_empresa =?";
                IfxCommand cmd = new IfxCommand(sql, Conexion);
                cmd.Parameters.Add(new IfxParameter()).Value = id_empresa;

                using (var dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        entidad                   = new EntEmpleado();
                        entidad.id_empleado       = int.Parse(dr["id_empleado"].ToString());
                        entidad.nombre            = dr["nombre"].ToString();
                        entidad.ap_paterno        = dr["ap_paterno"].ToString();
                        entidad.ap_materno        = dr["ap_materno"].ToString();
                        entidad.id_departamento   = int.Parse(dr["id_departamento"].ToString());
                        entidad.desc_departamento = dr["desc_departamento"].ToString();
                        entidad.id_sucursal       = int.Parse(dr["id_sucursal"].ToString());
                        entidad.desc_sucursal     = dr["desc_sucursal"].ToString();
                        entidad.enrollnumber      = int.Parse(dr["enrollnumber"].ToString());
                        entidad.imagen            = dr["imagen"].ToString();
                        entidad.id_dispositivo    = int.Parse(dr["id_dispositivo"].ToString());
                        Lista.Add(entidad);
                    }
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
            finally
            {
                CerrarConexion();
            }
            return(Lista);
        }
コード例 #8
0
ファイル: PerEmpleados.cs プロジェクト: dperezs/BioZ
        public EntEmpleado Obtener(int id)
        {
            EntEmpleado entidad = null;

            try
            {
                AbrirConexion();
                StringBuilder CadenaSql = new StringBuilder();

                IfxCommand cmd = new IfxCommand(string.Empty, Conexion);
                var        sql = "SELECT a.id_empleado,a.nombre,a.ap_paterno,a.ap_materno,a.id_departamento,a.id_sucursal,a.enrollnumber,a.imagen,b.desc_departamento,c.desc_sucursal FROM informix.empleados ";
                sql             = sql + "a left join informix.departamentos b on a.id_departamento=b.id_departamento left join informix.sucursales c on a.id_sucursal=c.id_sucursal WHERE a.id_empleado=?";
                cmd.CommandText = sql;

                cmd.Parameters.Add(new IfxParameter()).Value = id;
                using (var dr = cmd.ExecuteReader())
                {
                    if (dr.Read())
                    {
                        entidad                   = new EntEmpleado();
                        entidad.id_empleado       = int.Parse(dr["id_empleado"].ToString());
                        entidad.nombre            = dr["nombre"].ToString();
                        entidad.ap_paterno        = dr["ap_paterno"].ToString();
                        entidad.ap_materno        = dr["ap_materno"].ToString();
                        entidad.id_departamento   = int.Parse(dr["id_departamento"].ToString());
                        entidad.desc_departamento = dr["desc_departamento"].ToString();
                        entidad.id_sucursal       = int.Parse(dr["id_sucursal"].ToString());
                        entidad.desc_sucursal     = dr["desc_sucursal"].ToString();
                        entidad.enrollnumber      = int.Parse(dr["enrollnumber"].ToString());
                        entidad.imagen            = dr["imagen"].ToString();
                    }
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
            finally
            {
                CerrarConexion();
            }
            return(entidad);
        }
コード例 #9
0
        public ActionResult Eliminar(int id)
        {
            try
            {
                EntEmpleado ent = control.Obtener(id);
                var         r   = control.Eliminar(id);
                BorrarDispositivo(ent.enrollnumber);
                if (!r)
                {
                    return(Json("Error al realizar la operacion", JsonRequestBehavior.AllowGet));
                }

                return(Json("Realizado", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Empleados", "Eliminar")));
            }
        }
コード例 #10
0
        public ActionResult Savefootprint(EmpleadoHuella entidad)
        {
            List <EmpleadoHuella> Lista_Huellas = new List <EmpleadoHuella>();
            EntEmpleado           entidadEmp    = control.ObtenerEmpleado(entidad.id_empleado);
            EntDispositivo        entidadDisp   = ctrlDispositivo.Obtener(entidadEmp.id_dispositivo);

            if (Connect(entidadDisp.ip_dispositivo, int.Parse(entidadDisp.puerto)))
            {
                Lista_Huellas = Get_Footprints_Employee(entidadDisp.numeroequipo, entidadEmp.enrollnumber, entidadEmp.id_empleado);
            }

            var r = false;

            try
            {
                if (Lista_Huellas.Count() > 0)
                {
                    ctrlEmpleadoHuella.Eliminar(entidad.id_empleado);
                    foreach (EmpleadoHuella entidad_insert in Lista_Huellas)
                    {
                        r = ctrlEmpleadoHuella.Insertar(entidad_insert);
                    }

                    if (!r)
                    {
                        return(Json("Error al realizar la operacion", JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Json("SinHuellas&" + Lista_Huellas.Count().ToString(), JsonRequestBehavior.AllowGet));
                }

                return(Json("Realizado&" + Lista_Huellas.Count().ToString(), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Huellas", "Guardar")));
            }
        }
コード例 #11
0
 public bool Actualizar(EntEmpleado Entidad)
 {
     return(PerEmpleados.Update(Entidad));
 }
コード例 #12
0
 public bool Insertar(EntEmpleado Entidad)
 {
     return(PerEmpleados.Insert(Entidad));
 }
コード例 #13
0
ファイル: PerEmpleados.cs プロジェクト: ABMTY/BioZ
        public EntEmpleado Obtener(int id)
        {
            EntEmpleado entidad = null;

            try
            {
                AbrirConexion();
                StringBuilder CadenaSql = new StringBuilder();

                IfxCommand cmd = new IfxCommand(string.Empty, Conexion);
                var        sql = "SELECT a.id_empleado,a.nombre,a.ap_paterno,a.ap_materno,a.id_departamento,a.id_sucursal,a.enrollnumber,a.imagen,b.desc_departamento,c.desc_sucursal, a.id_dispositivo FROM informix.empleados ";
                sql             = sql + "a left join informix.departamentos b on a.id_departamento=b.id_departamento left join informix.sucursales c on a.id_sucursal=c.id_sucursal WHERE a.id_empleado=?";
                cmd.CommandText = sql;

                cmd.Parameters.Add(new IfxParameter()).Value = id;
                using (var dr = cmd.ExecuteReader())
                {
                    if (dr.Read())
                    {
                        entidad                   = new EntEmpleado();
                        entidad.id_empleado       = int.Parse(dr["id_empleado"].ToString());
                        entidad.nombre            = dr["nombre"].ToString();
                        entidad.ap_paterno        = dr["ap_paterno"].ToString();
                        entidad.ap_materno        = dr["ap_materno"].ToString();
                        entidad.id_departamento   = int.Parse(dr["id_departamento"].ToString());
                        entidad.desc_departamento = dr["desc_departamento"].ToString();
                        entidad.id_sucursal       = int.Parse(dr["id_sucursal"].ToString());
                        entidad.desc_sucursal     = dr["desc_sucursal"].ToString();
                        entidad.enrollnumber      = int.Parse(dr["enrollnumber"].ToString());
                        entidad.imagen            = dr["imagen"].ToString();
                        entidad.id_dispositivo    = int.Parse(dr["id_dispositivo"].ToString());
                    }
                }
                #region GetEmpleadoHuellas
                entidad.empleadohuellas = new List <EmpleadoHuella>();
                cmd.CommandText         = "SELECT id_huella, id_empleado, huella, enrollnumber, fingerindex, flag, tmplength FROM empleado_huella where id_empleado=?";
                cmd.Parameters.Clear();
                cmd.Parameters.Add(new IfxParameter()).Value = id;
                using (var dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        EmpleadoHuella huella = new EmpleadoHuella();
                        huella.id_huella   = int.Parse(dr["id_huella"].ToString());
                        huella.id_empleado = int.Parse(dr["id_empleado"].ToString());
                        if (dr["huella"].ToString() != string.Empty)
                        {
                            huella.huella = dr["huella"].ToString();
                        }
                        huella.enrollnumber = dr["enrollnumber"].ToString();
                        huella.fingerIndex  = dr["fingerIndex"].ToString();
                        huella.flag         = dr["flag"].ToString();
                        huella.tmplength    = dr["tmplength"].ToString();
                        entidad.empleadohuellas.Add(huella);
                    }
                }
                #endregion
            }
            catch (Exception exc)
            {
                throw exc;
            }
            finally
            {
                CerrarConexion();
            }
            return(entidad);
        }
コード例 #14
0
        protected void Process(DPFP.Sample Sample)
        {
            // Este método es el proceso de verificación, para revisar que la huella escaneada exista en la base de datos.
            string startupPath = Application.StartupPath;

            ProcesarMuestra(Sample);
            bool   encontrado = false;
            string Nombre     = string.Empty;

            // En cambio, si existen huellas, vamos a iterar sobre ellas
            foreach (EmpleadoHuella entEmpleadoHuella in ListaHuellas)
            {
                // Por cada huella... la almacenamos en un MemoryStream como arreglo de bytes.
                MemoryStream fingerprintData = new MemoryStream(entEmpleadoHuella.b64huella);
                // Creamos una plantilla a partir de esos bytes...
                DPFP.Template templateIterando = new DPFP.Template(fingerprintData);

                // Extraemos las caracteristicas de la plantilla
                DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification);

                // Verificamos que las caracteristicas sean buenas
                if (features != null)
                {
                    // Compare the feature set with our template
                    DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result();
                    Verificator.Verify(features, templateIterando, ref result);

                    // Y vemos si el resultado es valido o no, (verified)
                    // Si es verified, significa que el dedo escaneado ya existia en la base de datos.

                    if (result.Verified)
                    {
                        // Creamos una instancia de usuario, que va a equivaler al usuario cuya huella coincidio de la base
                        EntEmpleado u = ListaEmpleados.Where(x => x.id_empleado == entEmpleadoHuella.id_empleado).SingleOrDefault();

                        try
                        {
                            if (u.imagen != string.Empty)
                            {
                                pcbCamara.Image = null;
                                // Convert base 64 string to byte[]
                                byte[] imageBytes = Convert.FromBase64String(u.imagen);
                                // Convert byte[] to Image
                                using (var ms = new MemoryStream(imageBytes, 0, imageBytes.Length))
                                {
                                    pcbCamara.Image = Image.FromStream(ms, true);
                                }
                            }
                            else
                            {
                                pcbCamara.Image = null;
                                pcbCamara.Image = Properties.Resources.NoPicture;
                                pcbCamara.Refresh();
                                pcbCamara.Visible = true;
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        encontrado = true;
                        break;
                    }
                    else
                    {
                        encontrado = false;
                    }
                }
            }
            //Si no encontro la huella, lanzar el formulario de Registro
            if (encontrado == false)
            {
                try
                {
                    pcbCamara.Image = Properties.Resources.NoFinger;
                    pcbCamara.Refresh();
                    pcbCamara.Visible = true;
                }
                catch (Exception ex)
                {
                    //MessageBox.Show("No se encuentra RegistrosHuella!", "Falta Ejecutable", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //this.Invoke(new MethodInvoker(delegate { this.Close(); }));
                }
            }
        }
コード例 #15
0
        protected void Process(DPFP.Sample Sample)
        {
            // Este método es el proceso de verificación, para revisar que la huella escaneada exista en la base de datos.
            string startupPath       = Application.StartupPath;
            string RegistroHuellaExe = Application.StartupPath + "\\RegistroHuella.exe";
            string URLFilePath       = Application.StartupPath + "\\urlExiste.dat";

            ProcesarMuestra(Sample);

            // Si no hay huellas en la base de datos, automaticamente ejecutara el registro
            //if (ListaHuellas.Count == 0)
            //{
            //    try
            //    {
            //        System.Diagnostics.Process.Start(RegistroHuellaExe);
            //        Application.Exit();
            //    }
            //    catch (Exception ex)
            //    {
            //        MessageBox.Show("No se encuentra RegistrosHuella.exe!", "Falta Ejecutable", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    }
            //    return;
            //}
            bool encontrado = false;

            // En cambio, si existen huellas, vamos a iterar sobre ellas
            foreach (EmpleadoHuella h in ListaHuellas)
            {
                // Por cada huella... la almacenamos en un MemoryStream como arreglo de bytes.
                MemoryStream fingerprintData = new MemoryStream(h.b64huella);
                // Creamos una plantilla a partir de esos bytes...
                DPFP.Template templateIterando = new DPFP.Template(fingerprintData);

                // Extraemos las caracteristicas de la plantilla
                DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification);

                // Verificamos que las caracteristicas sean buenas
                if (features != null)
                {
                    // Compare the feature set with our template
                    DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result();
                    Verificator.Verify(features, templateIterando, ref result);

                    // Y vemos si el resultado es valido o no, (verified)
                    // Si es verified, significa que el dedo escaneado ya existia en la base de datos.

                    if (result.Verified)
                    {
                        // Creamos una instancia de usuario, que va a equivaler al usuario cuya huella coincidio de la base
                        EntEmpleado u = ListaEmpleados.Where(x => x.id_empleado == h.id_empleado).SingleOrDefault();

                        // Formulamos la URL a devolver, así como todos sus parametros
                        //string urlFile = File.ReadAllText(URLFilePath);
                        //string fechaFormatoMySQL = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        //// Enviamos todos los valores por GET
                        //string url = String.Format("{0}?idUsuario={1}&Nombre={2}&Cedula={3}&Direccion={4}&Telefono={5}&Celular={6}&ARL={7}&Serial={8}&FechaLog={9}", urlFile, u.idUsuario, u.Nombre, u.Cedula, u.Direccion, u.Telefono, u.Celular, u.ARL, u.Serial, fechaFormatoMySQL);

                        // Y ejecutamos el navegador.
                        try
                        {
                            //System.Diagnostics.Process.Start(url);
                            MessageBox.Show("Empleado Existente");
                            AgregarRegistroLog(h.id_empleado, DateTime.Now, ImageToBase64(pcbCamara.Image, System.Drawing.Imaging.ImageFormat.Bmp));
                        }
                        catch (Exception ex)
                        {
                        }
                        encontrado = true;
                        // Por ultimo se cierra el programa.
                        this.Invoke(new MethodInvoker(delegate { this.Close(); }));
                    }
                    else
                    {
                        encontrado = false;
                    }
                }
            }

            // Si no encontro la huella, lanzar el formulario de Registro
            //if (encontrado == false)
            //{
            //    try
            //    {
            //        System.Diagnostics.Process.Start(RegistroHuellaExe);
            //        Application.Exit();
            //    }
            //    catch (Exception ex)
            //    {
            //        //MessageBox.Show("No se encuentra RegistrosHuella.exe!", "Falta Ejecutable", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //        this.Invoke(new MethodInvoker(delegate { this.Close(); }));
            //    }
            //}
        }
コード例 #16
0
ファイル: Validar.cs プロジェクト: ABMTY/ServicioBioZ
        protected void Process(DPFP.Sample Sample)
        {
            // Este método es el proceso de verificación, para revisar que la huella escaneada exista en la base de datos.
            string startupPath = Application.StartupPath;

            //string RegistroHuellaExe = Application.StartupPath + "\\RegistroHuella.exe";
            //string URLFilePath = Application.StartupPath + "\\urlExiste.dat";

            ProcesarMuestra(Sample);

            bool   encontrado = false;
            string Nombre     = string.Empty;

            // En cambio, si existen huellas, vamos a iterar sobre ellas
            foreach (EmpleadoHuella h in ListaHuellas)
            {
                // Por cada huella... la almacenamos en un MemoryStream como arreglo de bytes.
                MemoryStream fingerprintData = new MemoryStream(h.b64huella);
                // Creamos una plantilla a partir de esos bytes...
                DPFP.Template templateIterando = new DPFP.Template(fingerprintData);

                // Extraemos las caracteristicas de la plantilla
                DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification);

                // Verificamos que las caracteristicas sean buenas
                if (features != null)
                {
                    // Compare the feature set with our template
                    DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result();
                    Verificator.Verify(features, templateIterando, ref result);

                    // Y vemos si el resultado es valido o no, (verified)
                    // Si es verified, significa que el dedo escaneado ya existia en la base de datos.

                    if (result.Verified)
                    {
                        // Creamos una instancia de usuario, que va a equivaler al usuario cuya huella coincidio de la base
                        EntEmpleado u = ListaEmpleados.Where(x => x.id_empleado == h.id_empleado).SingleOrDefault();
                        //Nombre = u.nombre_completo;
                        // Formulamos la URL a devolver, así como todos sus parametros
                        //string urlFile = File.ReadAllText(URLFilePath);
                        //string fechaFormatoMySQL = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        //// Enviamos todos los valores por GET
                        //string url = String.Format("{0}?idUsuario={1}&Nombre={2}&Cedula={3}&Direccion={4}&Telefono={5}&Celular={6}&ARL={7}&Serial={8}&FechaLog={9}", urlFile, u.idUsuario, u.Nombre, u.Cedula, u.Direccion, u.Telefono, u.Celular, u.ARL, u.Serial, fechaFormatoMySQL);

                        // Y ejecutamos el navegador.
                        try
                        {
                            // Convert base 64 string to byte[]
                            byte[] imageBytes = Convert.FromBase64String(u.imagen);
                            // Convert byte[] to Image
                            using (var ms = new MemoryStream(imageBytes, 0, imageBytes.Length))
                            {
                                //pcbCamara.Image = Image.FromStream(ms, true);
                                empleadoActual  = new EntEmpleado();
                                empleadoActual  = u;
                                pcbCamara.Image = StartupServiceBioZ.Properties.Resources.check_sign;
                                SoundPlayer simpleSound = new SoundPlayer(StartupServiceBioZ.Properties.Resources.Windows_Logon);
                                simpleSound.Play();
                                Thread.Sleep(TimeSpan.FromSeconds(2));
                                pcbCamara.Image = StartupServiceBioZ.Properties.Resources.computer;
                            }

                            RegistrarCheckinout(u);
                            //System.Diagnostics.Process.Start(url);
                            //MessageBox.Show("Empleado Existente");
                            //AgregarRegistroLog(h.id_empleado, DateTime.Now, ImageToBase64(pcbCamara.Image, System.Drawing.Imaging.ImageFormat.Bmp));
                            //pcbCamara.Image = pcbCamara.Image;
                        }
                        catch (Exception ex)
                        {
                        }
                        encontrado = true;
                        break;

                        // Por ultimo se cierra el programa.
                        //this.Invoke(new MethodInvoker(delegate {  }));
                    }
                    else
                    {
                        encontrado = false;
                    }
                }
            }


            //Si no encontro la huella, lanzar el formulario de Registro
            if (encontrado == false)
            {
                try
                {
                    pcbCamara.Image = StartupServiceBioZ.Properties.Resources.check_error;
                    Thread.Sleep(TimeSpan.FromMilliseconds(500));
                    pcbCamara.Image = StartupServiceBioZ.Properties.Resources.computer;
                    SoundPlayer simpleSound = new SoundPlayer(StartupServiceBioZ.Properties.Resources.Windows_Hardware_Fail);
                    simpleSound.Play();

                    //string dir = Path.GetDirectoryName(Application.ExecutablePath);
                    //string filename = Path.Combine(dir,"notfinger.jpg");
                    //label1.Text = Nombre;
                    //System.Diagnostics.Process.Start(RegistroHuellaExe);
                    //Application.Exit();
                }
                catch (Exception ex)
                {
                    //MessageBox.Show("No se encuentra RegistrosHuella!", "Falta Ejecutable", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //this.Invoke(new MethodInvoker(delegate { this.Close(); }));
                }
            }
        }