Beispiel #1
0
 protected override void InternalSaveTemplate(byte fingerCode, GriauleFingerprintLibrary.DataTypes.FingerprintTemplate fingerPrintTemplate)
 {
     base.InternalSaveTemplate(fingerCode, fingerPrintTemplate);
       using (SqlCommand cmd = new SqlCommand())
       {
     try
     {
       cmd.Connection = (SqlConnection)Connection;
       string cmdStr = String.Format("SELECT COUNT(*) n FROM [{0}] WHERE [{1}]=@individual AND [{2}]=@finger",
                                 TemplateTable, IndividualFieldName, FingerFieldName);
       cmd.CommandText = cmdStr;
       cmd.Parameters.AddWithValue("@individual", ActiveIndividual);
       cmd.Parameters.AddWithValue("@finger", fingerCode);
       int cnt = (int)cmd.ExecuteScalar();
       if (cnt > 0) //Finger template already exists, update
       {
     cmdStr = String.Format("UPDATE [{0}] SET [{1}]=@template, SET [{2}]=@quality WHERE [{3}]=@individual AND [{4}]=@finger",
                           TemplateTable, TemplateFieldName, QualityFieldName, IndividualFieldName, FingerFieldName);
       }
       else //Finger template doesn't exist, insert
       {
     cmdStr = String.Format("INSERT INTO [{0}] ([{1}],[{2}],[{3}],[{4}]) VALUES (@individual,@finger,@template,@quality)",
                           TemplateTable, IndividualFieldName, FingerFieldName, TemplateFieldName, QualityFieldName);
       }
       cmd.CommandText = cmdStr;
       //cmd.Parameters.AddWithValue("@individual", ActiveIndividual); //Already set
       //cmd.Parameters.AddWithValue("@finger", fingerCode);           //Already set
       cmd.Parameters.AddWithValue("@template", fingerPrintTemplate.Buffer);
       cmd.Parameters.AddWithValue("@quality", fingerPrintTemplate.Quality);
       int rowsAffected = cmd.ExecuteNonQuery();
       if (rowsAffected == 0)
       {
     throw new FPLibraryException(FPLibraryException.LibraryDalError, String.Format("Template not saved for individual {0} finger {1}", ActiveIndividual, fingerCode));
       }
     }
     catch (Exception ex)
     {
       MessageBox.Show(ex.Message);
     }
       }
 }
Beispiel #2
0
        void core_onImage(object source, GriauleFingerprintLibrary.Events.ImageEventArgs ie)
        {
            try
            {
                huella = ie.RawImage;
                core.Extract(huella, ref template);
                label4.Text = "";//"Espere, identificando...";
                bool haveHorarios = false;
                string consulta;
                byte[] dataTemp;
                GriauleFingerprintLibrary.DataTypes.FingerprintTemplate templateTemp;
                int precision, calidad;

                // selecciono
                consulta = "select id, rol, concat_ws(' ', nombre, apellidoPaterno, apellidoMaterno) as nombreCompleto, template, calidad_template, foto from usuarios where template is not null and 1 = 1";

                MySqlDataReader reader = this.EjecutarQuery(consulta);

                core.IdentifyPrepare(template);
                bool match = false;

                while (reader.Read())
                {
                    Log.WriteLog("Recorriendo usuarios.");
                    dataTemp = (byte[])reader["template"];
                    calidad = (int)reader["calidad_template"];
                    templateTemp = new GriauleFingerprintLibrary.DataTypes.FingerprintTemplate();
                    templateTemp.Buffer = dataTemp;
                    templateTemp.Size = dataTemp.Length;
                    templateTemp.Quality = calidad;

                    int result = core.Identify(templateTemp, out precision);

                    if (result == 1)
                    {

                        Usuario = reader["id"].ToString();
                        string nombreCompleto = reader["nombreCompleto"].ToString();
                        string rol = reader["rol"].ToString();
                        string foto = reader["foto"].ToString();
                        Rol = rol;

                        Log.WriteLog("Encontre al Usuario - " + reader["nombreCompleto"].ToString());
                        string inout = new Rules().isInOut(Usuario);
                        if (inout == "In")
                        {
                            Log.WriteLog(inout);
                            if (Rol == "Cliente")
                            {
                                List<Horario> horarios = this.getHorarios(Usuario);

                                if (horarios.Count > 0)
                                {
                                    haveHorarios = true;
                                }
                                else
                                {
                                    Log.WriteLog("No hay horarios disponibles.");
                                    MessageBox.Show("Lo sentimos no contamos con horarios disponibles");
                                    //clean();
                                }

                                if (haveHorarios)
                                {
                                    label4.Text = "";
                                    dataGridView1.DataSource = horarios;
                                    label2.Text = "Bienvenido " + nombreCompleto;
                                    mensualidad.Text = new Rules().ProximoPago(Usuario);
                                    Log.WriteLog("Encontre horarios para - " + nombreCompleto);
                                    if (!String.IsNullOrEmpty(foto))
                                    {
                                        fotoGrafia.ImageLocation = @"c:\wamp\www\gym\fotos\" + foto;
                                    }
                                    this.WindowState = FormWindowState.Normal;
                                }
                            }
                            else if (Rol == "Instructor")
                            {
                                label4.Text = "";
                                dataGridView1.DataSource = null;
                                label2.Text = "Bienvenido " + nombreCompleto;

                                if (!String.IsNullOrEmpty(foto))
                                {
                                    fotoGrafia.ImageLocation = @"c:\wamp\www\gym\fotos\" + foto;
                                }
                                this.WindowState = FormWindowState.Normal;
                                Log.WriteLog("Bienvenido Instructor - " + nombreCompleto);
                            }

                        }
                        else
                        {
                            if (new Rules().registrarSalida(Usuario))
                            {
                                Log.WriteLog("Se registro la salida - " + nombreCompleto);
                                label2.Text = "Hasta pronto " + nombreCompleto;

                                if (!String.IsNullOrEmpty(foto))
                                {
                                    fotoGrafia.ImageLocation = @"c:\wamp\www\gym\fotos\" + foto;
                                }
                                this.WindowState = FormWindowState.Normal;
                                this.button2.Visible = true;

                            }

                        }
                        match = true;

                        break;
                    }

                }

                if(!match)
                {
                    label4.Text = "Usuario no registrado, te invitamos a darte de alta";
                    Log.WriteLog("No se encontro ni un usuario");
                    //clean();
                    this.WindowState = FormWindowState.Normal;
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Log.WriteLog(ex.Message);
            }
        }
Beispiel #3
0
        public void StartListening(ref GriauleFingerprintLibrary.FingerprintCore fp)
        {
            fingerPrint = fp;
            oThread = new Thread(new ThreadStart(AsynchronousSocketListener.StartListening));
            oThread2 = new Thread(new ThreadStart(ReceiveTCP));
            imageSended = false;

            if (!oThread.IsAlive)
                oThread.Start();
            if (!oThread2.IsAlive)
                oThread2.Start();
        }
Beispiel #4
0
 internal void setTemplate(GriauleFingerprintLibrary.DataTypes.FingerprintTemplate _template)
 {
     this._template = _template;
 }
Beispiel #5
0
 void fingerPrint_onStatus(object source, GriauleFingerprintLibrary.Events.StatusEventArgs se)
 {
     if (se.StatusEventType == GriauleFingerprintLibrary.Events.StatusEventType.SENSOR_PLUG)
     {
         fingerPrint.StartCapture(source.ToString());
         SetLvwFPReaders(se.Source, 0);
     }
     else
     {
         fingerPrint.StopCapture(source);
         SetLvwFPReaders(se.Source, 1);
     }
 }
Beispiel #6
0
 private bool Identify(GriauleFingerprintLibrary.DataTypes.FingerprintTemplate testTemplate, out int score)
 {
     return fingerPrint.Identify(testTemplate,out score) ==  1? true : false;
 }
Beispiel #7
0
 void fingerPrint_onFinger(object source, GriauleFingerprintLibrary.Events.FingerEventArgs fe)
 {
     switch (fe.EventType)
     {
         case GriauleFingerprintLibrary.Events.FingerEventType.FINGER_DOWN:
             {
                 SetFingerStatus(fe.Source, 0);
             } break;
         case GriauleFingerprintLibrary.Events.FingerEventType.FINGER_UP:
             {
                 SetFingerStatus(fe.Source, 1);
             } break;
     }
 }
Beispiel #8
0
        void core_onImage(object source, GriauleFingerprintLibrary.Events.ImageEventArgs ie)
        {
            try
            {
                WriteLog("Obteniendo Huella.");
                huella = ie.RawImage;
                core.Extract(huella, ref template);
                string consulta;
                byte[] dataTemp;
                GriauleFingerprintLibrary.DataTypes.FingerprintTemplate templateTemp;
                int precision, calidad;

                // selecciono
                consulta = "select id, id as no_empleado, telefono, rfc, rol, concat_ws(' ', nombre, apellidoPaterno, apellidoMaterno) as nombreCompleto, template, calidad_template, foto from usuarios where template is not null and 1 = 1";

                MySqlDataReader reader = this.EjecutarQuery(consulta);
                core.IdentifyPrepare(template);

                while (reader.Read())
                {
                    dataTemp = (byte[])reader["template"];
                    calidad = (int)reader["calidad_template"];
                    templateTemp = new GriauleFingerprintLibrary.DataTypes.FingerprintTemplate();
                    templateTemp.Buffer = dataTemp;
                    templateTemp.Size = dataTemp.Length;
                    templateTemp.Quality = calidad;

                    int result = core.Identify(templateTemp, out precision);
                    WriteLog("Resultado: "+result.ToString() + " Precision: " +  precision.ToString());

                    if (result == 1)
                    {

                        //
                        Usuario = reader["id"].ToString();
                        string no_Empleado = reader["no_empleado"].ToString();
                        string nombreCompleto = reader["nombreCompleto"].ToString();
                        string rfc = reader["rfc"].ToString();
                        string telefono = reader["telefono"].ToString();
                        string rol = reader["rol"].ToString();
                        string foto = reader["foto"].ToString();
                        Rol = rol;

                        WriteLog("Huella encontrada.");
                        WriteLog("Empleado: " + no_Empleado);

                        string inout = new Rules().isInOut(Usuario);
                        if (inout == "In")
                        {
                            if (new Rules().registrarEntrada(Usuario))
                            {
                                this.no_personal.Text = no_Empleado;
                                this.nombre_completo.Text = nombreCompleto;
                                this.rfc.Text = rfc;
                                this.telefono.Text = telefono;
                                label1.Text = "Entrada";

                                if (!String.IsNullOrEmpty(foto))
                                {
                                    fotoGrafia.ImageLocation = @RutaFotos + foto;
                                }

                                this.WindowState = FormWindowState.Normal;
                                WriteLog("Entrada Registrada. " + no_Empleado);
                            }
                            else
                            {
                                MessageBox.Show("No hemos podido registrar su entrada");
                                WriteLog("No hemos podido registrar su entrada" + no_Empleado);
                            }
                        }
                        else
                        {
                            if (new Rules().registrarSalida(Usuario))
                            {
                                this.no_personal.Text = no_Empleado;
                                this.nombre_completo.Text = nombreCompleto;
                                this.rfc.Text = rfc;
                                this.telefono.Text = telefono;

                                if (!String.IsNullOrEmpty(foto))
                                {
                                    fotoGrafia.ImageLocation = @RutaFotos + foto;
                                }

                                this.no_personal.Text = no_Empleado;
                                this.nombre_completo.Text = nombreCompleto;
                                this.rfc.Text = rfc;
                                this.telefono.Text = telefono;
                                label1.Text = "Salida";

                                if (!String.IsNullOrEmpty(foto))
                                {
                                    fotoGrafia.ImageLocation = @RutaFotos + foto;
                                }

                                this.WindowState = FormWindowState.Normal;
                                WriteLog("Salida Registrada. " + no_Empleado);
                            }

                        }

                        break;
                    }
                    else
                    {
                        WriteLog("No concuerda");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #9
0
        private void DisplayImage(GriauleFingerprintLibrary.DataTypes.FingerprintTemplate template, bool identify)
        {
            IntPtr hdc = FingerprintCore.GetDC();

            IntPtr image = new IntPtr();

            if (identify)
            {
                fingerPrint.GetBiometricDisplay(template, rawImage, hdc, ref image,FingerprintConstants.GR_DEFAULT_CONTEXT);
            }
            else
            {
                fingerPrint.GetBiometricDisplay(template, rawImage, hdc, ref image, FingerprintConstants.GR_NO_CONTEXT);
            }

            SetImage(Bitmap.FromHbitmap(image));

            FingerprintCore.ReleaseDC(hdc);
        }
Beispiel #10
0
 private void DisplayNewUser(GriauleFingerprintLibrary.DataTypes.FingerprintTemplate _template)
 {
     UserView view = new UserView(true);
     view.setTemplate(_template);
     view.Show(this);
 }
 void FPCore_onImage(object source, GriauleFingerprintLibrary.Events.ImageEventArgs ie)
 {
     try
       {
     if (ie.RawImage != null)
     {
       SetImage(ie.RawImage.Image);
       template = new FingerprintTemplate();
       int ret = (int)FPCore.Enroll(ie.RawImage, ref template, (GrTemplateFormat)Controller.DefaultTemplateFormat, FingerprintConstants.GR_DEFAULT_CONTEXT);
       if (ret >= FingerprintConstants.GR_ENROLL_SUFFICIENT)
       {
     DisplayImage(template, ie.RawImage);
     EnableCaptureButton(true);
     if (ret == FingerprintConstants.GR_ENROLL_SUFFICIENT)
     {
       ShowQuality(EnrollQuality.Sufficient);
       SetFingerLabel("Place finger again to improve quality", true);
     }
     else if (ret == FingerprintConstants.GR_ENROLL_GOOD)
     {
       ShowQuality(EnrollQuality.Good);
       SetFingerLabel("Click 'Capture' to record template", true);
     }
     else if (ret == FingerprintConstants.GR_ENROLL_VERY_GOOD)
     {
       ShowQuality(EnrollQuality.VeryGood);
       SetFingerLabel("Click 'Capture' to record template", true);
     }
     else if (ret == FingerprintConstants.GR_ENROLL_MAX_LIMIT_REACHED)
     {
       SetFingerLabel("Enrollment limit reached", true);
     }
       }
       else
       {
     SetFingerLabel("Place finger again", true);
     ShowQuality(EnrollQuality.Poor);
       }
       Thread.Sleep(100);
     }
       }
       catch (FingerprintException ex)
       {
     ShowFPError(ex);
       }
       catch (Exception e)
       {
     ShowError(e);
       }
 }
 void FPCore_onFinger(object source, GriauleFingerprintLibrary.Events.FingerEventArgs fe)
 {
     switch (fe.EventType)
       {
     case GriauleFingerprintLibrary.Events.FingerEventType.FINGER_DOWN:
       SetFingerLabel("Hold finger until image appears", true);
       break;
     case GriauleFingerprintLibrary.Events.FingerEventType.FINGER_UP:
       SetFingerLabel("", false);
       break;
     default:
       break;
       }
 }
 public StatusEventArgs(string source, GriauleFingerprintLibrary.Events.StatusEventType statusEventType)
 {
     this.source = source;
     this.statusEventType = statusEventType;
 }
Beispiel #14
0
        void core_onImage(object source, GriauleFingerprintLibrary.Events.ImageEventArgs ie)
        {
            try
            {
                huella = ie.RawImage;
                core.Extract(huella, ref template);

                pictureBox1.Image = huella.Image;

                switch (template.Quality)
                {
                    case 0:
                        MessageBox.Show("Huella de mala calidad favor de volver a poner el dedo", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    case 1:
                        MessageBox.Show("La huella es de una calidad media, intente nuevamente", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    case 2:
                        MessageBox.Show("Huella con buena calidad", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        HuellaOK = true;
                        break;
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #15
0
        private void fingerPrint_onImage(object source, GriauleFingerprintLibrary.Events.ImageEventArgs ie)
        {
            SetFingerStatus(ie.Source, 2);
            rawImage = ie.RawImage;
            SetImage(ie.RawImage.Image);
            if (autoExtractToolStripMenuItem.Checked)
            {
               // buttonClick(button1);
                ExtractTemplate();

                if (autoIdentifyToolStripMenuItem.Checked)
                {
                    System.Threading.Thread.Sleep(100);
                   // buttonClick(button3);
                    Identify();
                }
            }
        }
Beispiel #16
0
 void core_onStatus(object source, GriauleFingerprintLibrary.Events.StatusEventArgs se)
 {
     if (se.StatusEventType == GriauleFingerprintLibrary.Events.StatusEventType.SENSOR_PLUG)
     {
         core.StartCapture(source);
         mensajeBarraEstado.Text = "Lector Conectado";
     }
     else
     {
         mensajeBarraEstado.Text = "Lector Desconectado";
     }
 }
Beispiel #17
0
        void core_onStatus(object source, GriauleFingerprintLibrary.Events.StatusEventArgs se)
        {
            if (se.StatusEventType == GriauleFingerprintLibrary.Events.StatusEventType.SENSOR_PLUG)
            {
                core.StartCapture(source);

            }
            else
            {

            }
        }