public async Task <int> HuellaRegister(HuellaForRegister huellaRegister)
        {
            Huella huella = new Huella();

            huella.Caslvl        = huellaRegister.Caslvl;
            huella.CodigoHuella  = huellaRegister.CodigoHuella;
            huella.ProductoId    = huellaRegister.ProductoId;
            huella.FechaRegistro = DateTime.Now;

            using (var transaction = _context.Database.BeginTransaction())
            {
                try
                {
                    await _context.Huella.AddAsync(huella);

                    await _context.SaveChangesAsync();

                    transaction.Commit();
                }
                catch (System.Exception)
                {
                    transaction.Rollback();
                    throw;
                }
                return(huella.Id);
            }
        }
Example #2
0
        public Task <bool> Guardarcalculo(HuellaDTO oHuella)
        {
            var huella = new Huella
            {
                IdProyecto            = oHuella.IdProyecto,
                Toneledas             = oHuella.Toneledas,
                Fecha                 = oHuella.Fecha,
                Precisar              = oHuella.Precisar,
                TipoArbol             = oHuella.TipoArbol,
                Zona                  = oHuella.Zona,
                EstadoCompensacion    = false,
                Area                  = oHuella.Area,
                Cant_arboles          = oHuella.Cant_arboles,
                DensidadArbolHectarea = oHuella.DensidadArbolHectarea
            };

            entity.Huella.Add(huella);
            entity.SaveChanges();

            var detalle = new DetalleHuella
            {
                IdHuella   = huella.IdHuella,
                Porcentaje = oHuella.Porcentaje,
                //Estado = oHuella.Estado
            };

            entity.DetalleHuella.Add(detalle);
            entity.SaveChanges();

            return(Task.FromResult <bool>(true));
        }
Example #3
0
        //Este método lo utilizo para setearle las huellas al list de empleados
        public List <Empleado> SetHuellas(List <Empleado> empleados)
        {
            query = "SELECT FingerIndex, Template, Lengh, Flag FROM Huellas WHERE IdEmpleado = @Id";
            IDataReader dr  = null;
            IDbCommand  cmd = null;

            try
            {
                cmd = FactoryConnection.Instancia.GetCommand(query, FactoryConnection.Instancia.GetConnection());
                var parameter = cmd.CreateParameter();
                parameter.ParameterName = "@Id";
                foreach (Empleado e in empleados)
                {
                    cmd.Parameters.Clear(); //--> Borro el parametro que inserté en la pasada anterior.
                    parameter.Value = e.Id;
                    cmd.Parameters.Add(parameter);

                    dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        Huella h = new Huella();
                        h.FingerIndex = Convert.ToInt32(dr["FingerIndex"]);
                        h.Lengh       = Convert.ToInt32(dr["Lengh"]);
                        h.Template    = dr["Template"].ToString();
                        h.Flag        = Convert.ToInt32(dr["Flag"]);
                        e.Huellas.Add(h);
                    }
                    dr.Close(); //--> Lo cierro para poder iniciarlizarlo cuando vuelvo a pasar por el bucle.
                }
            }
            catch (AppException appex)
            {
                throw appex;
            }
            catch (DbException dbEx)
            {
                throw new AppException("Error al consultar la tabla huellas", "Error", dbEx);
            }
            catch (Exception ex)
            {
                throw new AppException("Error desconocido al intentar consultar la tabla huellas", "Fatal", ex);
            }
            finally
            {
                try
                {
                    if (dr != null)
                    {
                        dr.Close();
                    }
                    FactoryConnection.Instancia.ReleaseConn();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(empleados);
        }
Example #4
0
 private void BiometricoSuprema()
 {
     try
     {
         if (Resultado != null && Resultado.huella == null)
         {
             Empleado resul = Huella.IniciarEscaneo();
             Resultado.huellaByte = resul.huellaByte;
             Resultado.pesoHuella = resul.pesoHuella;
             if (resul.pesoHuella > 0)
             {
                 btnRegistrar.Enabled = true;
             }
         }
     }
     catch { }
 }
Example #5
0
 private void btnEliminarHuella_Click(object sender, EventArgs e)
 {
     try
     {
         ActualizarHuellaApi(txtCodEmpleado.Text, "");
         EliminarHuellaLocal(txtCodEmpleado.Text);
         Resultado.huella          = null;
         btnEliminarHuella.Visible = false;
         pbImageFrame.Image        = Image.FromFile(pathMalImg);
         Huella.LlenarGridEmpleado();
         MessageBox.Show(Mensajes.EliminadoHuella, Mensajes.Exito, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (Resultado != null)
                {
                    if (Resultado.huella != null || Huella.HuellaTomada == 1)
                    {
                        try
                        {
                            if (Huella.HuellaTomada == 1)
                            {
                                var resultado = RegistrarHuellaApi();

                                Resultado.guiHuella = resultado.guiHuella;
                                Resultado.huella    = resultado.huella;
                            }
                        }
                        catch (Exception x)
                        {
                            throw new Exception(x.Message + " " + Mensajes.RegistrosSinSeleccionar);
                        }

                        Huella.RegistrarEmpleado(Resultado);
                    }
                    else
                    {
                        throw new Exception(Mensajes.ColocarIndiceScan);
                    }
                }
                else
                {
                    throw new Exception(Mensajes.RegistrosSinSeleccionar);
                }
            }
            catch (Exception ec)
            {
                MessageBox.Show(ec.Message + Mensajes.PermisoAdmin, Mensajes.Error, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally {
                Resultado                 = null;
                btnRegistrar.Enabled      = false;
                btnEliminarHuella.Visible = false;
                Limpiar();
            }
        }
Example #7
0
        public bool Existe(Huella h)
        {
            IDataReader dr = null;

            try
            {
                query = "SELECT TOP 1 HuellaId FROM HUELLAS WHERE IdEmpleado='" + h.Empleado.Id.ToString() + "' AND FingerIndex='" + h.FingerIndex.ToString() + "'";
                dr    = FactoryConnection.Instancia.GetReader(query, FactoryConnection.Instancia.GetConnection());
                if (dr.Read())
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (AppException appex)
            {
                throw appex;
            }
            catch (DbException dbex)
            {
                throw new AppException("Error al consultar la tabla de huellas", "Error", dbex);
            }
            catch (Exception ex)
            {
                throw new AppException("Error desconocido al consultar la tabla huellas", "Fatal", ex);
            }
            finally
            {
                try
                {
                    if (dr != null)
                    {
                        dr.Close();
                    }
                    FactoryConnection.Instancia.ReleaseConn();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Example #8
0
        private void SendMessage(Action action, object payload)
        {
            try
            {
                Huella.huellaBase64 = null;
                if (this.pbFingerprint.InvokeRequired)
                {
                    SendMessageCallback d = new SendMessageCallback(SendMessage);
                    this.Invoke(d, new object[] { action, payload });
                }
                else
                {
                    switch (action)
                    {
                    case Action.SendMessage:
                        MessageBox.Show((string)payload);
                        break;

                    case Action.SendBitmap:
                        pbFingerprint.Image = (Bitmap)payload;
                        pbFingerprint.Refresh();

                        if (Form_Main.OptFormulario == 1)
                        {
                            Huella.pbImageFrame.Image    = (Bitmap)payload;
                            Huella.pbImageFrame.SizeMode = PictureBoxSizeMode.StretchImage;
                            Huella.pbImageFrame.Refresh();
                            Huella.MarcarHuellaDos();
                        }
                        else
                        {
                            RegistroEmpleado.pbImageFrame.Image    = (Bitmap)payload;
                            RegistroEmpleado.pbImageFrame.SizeMode = PictureBoxSizeMode.StretchImage;
                            RegistroEmpleado.pbImageFrame.Refresh();
                        }

                        break;
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Example #9
0
        public async Task <IActionResult> putRegistro([FromBody] Huella huella)
        {
            var user_uuid = User.Claims.Where(x => x.Type == ClaimTypes.Sid).First().Value;

            //el correo es el user en el registro aqui se usa para localizar al paciente
            Paciente paciente = _context.Pacientes
                                .Where(p => p.correoElectronico == huella.user)
                                .FirstOrDefault();

            Registro registro = _context.registros
                                .Where(r => r.pacienteId.UUID == paciente.UUID)
                                .FirstOrDefault();

            registro.passwordHuella = huella.huellaId;

            await _context.SaveChangesAsync();

            return(Ok("Huella registrada"));
        }
Example #10
0
        public void ActualizarHuella(Huella h)
        {
            IDbCommand cmd = null;

            try
            {
                query = "UPDATE Huellas SET Template='" + h.Template + "', Lengh='" + h.Lengh + "', Flag='" + h.Flag.ToString() +
                        "' WHERE IdEmpleado='" + h.Empleado.Id.ToString() + "' AND FingerIndex='" + h.FingerIndex.ToString() + "'";

                cmd = FactoryConnection.Instancia.GetCommand(query, FactoryConnection.Instancia.GetConnection());
                cmd.ExecuteNonQuery();
            }
            catch (AppException appex)
            {
                throw appex;
            }
            catch (DbException dbex)
            {
                throw new AppException("Error al actualizar la tabla de huellas", "Error", dbex);
            }
            catch (Exception ex)
            {
                throw new AppException("Error desconocido al actualizar la tabla huellas", "Fatal", ex);
            }
            finally
            {
                try
                {
                    if (cmd != null)
                    {
                        cmd.Dispose();
                    }
                    FactoryConnection.Instancia.ReleaseConn();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Example #11
0
        public void InsertarHuella(Huella h)
        {
            IDbCommand cmd = null;

            try
            {
                query = "INSERT INTO Huellas (IdEmpleado, Template, FingerIndex, Lengh, Flag) VALUES(" + h.Empleado.Id + ", '" + h.Template + "', '" + h.FingerIndex.ToString() + "', '" + h.Lengh.ToString() + "', '" + h.Flag.ToString() + "')";
                cmd   = FactoryConnection.Instancia.GetCommand(query, FactoryConnection.Instancia.GetConnection());
                cmd.ExecuteNonQuery();
            }
            catch (AppException appex)
            {
                throw appex;
            }
            catch (DbException dbex)
            {
                throw new AppException("Error al insertar registros en la tabla huellas", "Error", dbex);
            }
            catch (Exception ex)
            {
                throw new AppException("Error desconocido al intentar actualizar en la tabla huellas", "Fatal", ex);
            }
            finally
            {
                try
                {
                    if (cmd != null)
                    {
                        cmd.Dispose();
                    }
                    FactoryConnection.Instancia.ReleaseConn();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }