예제 #1
0
 public static void ActualizarRegistroLocalEnviado(int id)
 {
     try
     {
         using (var conection = Utilidad <Empleado> .ConnSqlite(BdSqlite))
         {
             SQLiteCommand comm = new SQLiteCommand("UPDATE Asistencia SET Enviado=1 WHERE Id=?", conection);
             comm.Parameters.AddWithValue("@Id", id);
             int iResultado = comm.ExecuteNonQuery();
             conection.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #2
0
 public static void EliminarHuellaLocal(string codEmpleado)
 {
     try
     {
         using (var conection = Utilidad <Empleado> .ConnSqlite(BdSqlite))
         {
             SQLiteCommand comm = new SQLiteCommand("UPDATE FingerPrints SET Template1='',Gui_Huella='' WHERE CodEmpleado=?", conection);
             comm.Parameters.AddWithValue("@CodEmpleado", codEmpleado);
             int iResultado = comm.ExecuteNonQuery();
             conection.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #3
0
        private int ObtenerEmpleado(string codigo)
        {
            using (var conection = Utilidad <Empleado> .ConnSqlite(BdSqlite))
            {
                var           query   = "Select Count(Serial) From Fingerprints where CodEmpleado=" + "'" + codigo + "'";
                SQLiteCommand command = new SQLiteCommand(query, conection);

                var reader   = command.ExecuteReader();
                var Empleado = 0;
                while (reader.Read())
                {
                    Empleado = (int.Parse(reader[0].ToString()));
                }

                reader.Close();
                conection.Close();

                return(Empleado);
            }
        }
예제 #4
0
        private string ActualizarHuellaApi(string codEmpleado, string huella)
        {
            try
            {
                var coordenada = Huella.txtCoordenada.Text;
                var terminal   = Utilidad <Empleado> .GetIp() + "::" + Utilidad <Empleado> .GetMacAddress().ToString();

                var param    = "codEmpleado=" + codEmpleado + "&huella=" + huella + "&terminal=" + terminal + "&coordenadas=" + coordenada + "&clave=" + Huella.ApiKey;
                var empleado = Utilidad <Empleado> .GetJson(new Empleado(), Huella.Api + Constante.ActualizarHuellaApi + param);

                if (empleado.error == true)
                {
                    throw new Exception(empleado.mensaje);
                }
                return(empleado.guiHuella);
            }
            catch (Exception ex) {
                throw ex;
            }
        }
예제 #5
0
        private void ConsultarApi()
        {
            try {
                Resultado = Utilidad <Empleado> .GetJson(new Empleado(), Huella.Api + Constante.ConsultarApi + txtCodEmpleado.Text + "&clave=" + Huella.ApiKey);

                if (Resultado != null)
                {
                    txtNombres.Text = Resultado.nombres;
                    txtDoc.Text     = Resultado.tipoDoc;
                    txtNroDoc.Text  = Resultado.nroDoc;
                    txtCodEmp.Text  = Resultado.codigo;

                    if (Resultado.huella != null)
                    {
                        /*string dummyData = Resultado.huella.Trim().Replace(" ", "+");
                         * if (dummyData.Length % 4 > 0)
                         *  dummyData = dummyData.PadRight(dummyData.Length + 4 - dummyData.Length % 4, '=');
                         * byte[] huellaByte = Convert.FromBase64String(dummyData);*/

                        Resultado.huellaByte      = new byte[1024];//huellaByte;
                        pbImageFrame.Image        = Image.FromFile(pathBienImg);
                        btnRegistrar.Enabled      = true;
                        btnEliminarHuella.Visible = true;
                    }
                    else
                    {
                        pbImageFrame.Image        = Image.FromFile(pathMalImg);
                        btnRegistrar.Enabled      = false;
                        btnEliminarHuella.Visible = false;
                    }
                }
                else
                {
                    Resultado = null;
                    MessageBox.Show(Mensajes.CodigoEmpleadoNoEncontrado, Mensajes.RegistroNoEncontrado, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }catch (Exception ex) {
                throw ex;
            }
        }
예제 #6
0
        public static void RegistrarAsistenciaLocal(int empleadoId, DateTime fecha, int enviado, string terminal, string coordenadas)
        {
            try
            {
                using (var conection = Utilidad <Empleado> .ConnSqlite(BdSqlite))
                {
                    SQLiteCommand comm = new SQLiteCommand("INSERT INTO Asistencia(EmpleadoId,Fecha,Estado,Enviado,Terminal,Coordenadas) VALUES (?,?,?,?,?,?)", conection);

                    comm.Parameters.AddWithValue("@EmpleadoId", empleadoId);
                    comm.Parameters.AddWithValue("@Fecha", fecha);
                    comm.Parameters.AddWithValue("@Estado", 1);
                    comm.Parameters.AddWithValue("@Enviado", enviado);
                    comm.Parameters.AddWithValue("@Terminal", terminal);
                    comm.Parameters.AddWithValue("@Coordenada", coordenadas);
                    int iResultado = comm.ExecuteNonQuery();
                    conection.Close();
                }
            }
            catch (Exception ex) {
                throw ex;
            }
        }
예제 #7
0
        public static void ProcesarDatosNoEnviados()
        {
            List <Empleado> RegSinEnviar = ObtenerResgistrosSinEnviar();

            try
            {
                if (RegSinEnviar.Count > 0)
                {
                    foreach (Empleado emp in RegSinEnviar)
                    {
                        var      param    = "empleadoId=" + emp.idEmpleado + "&terminal=" + emp.terminal + "&coordenadas=" + emp.coordenadas + "&fecha=" + emp.fecha + "&clave=" + Huella.ApiKey;
                        string   Url      = Huella.Api + Constante.RegAsistenciaApi + param;
                        Empleado empleado = Utilidad <Empleado> .GetJson(new Empleado(), Url);

                        if (empleado.resultado)
                        {
                            ActualizarRegistroLocalEnviado(int.Parse(emp.ids));
                        }
                    }
                }
            }
            catch {}
        }