Esempio n. 1
0
        private bool Conexion_BaseDatos()
        {
            bool          bandera          = true;
            var           connectionString = ConfigurationManager.ConnectionStrings["DBInformix"].ConnectionString;
            PerInformixDB per = new PerInformixDB();

            try
            {
                per.AbrirConexion();
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry("Error:" + ex.Message);
                using (StreamWriter writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine(Environment.NewLine + "--Error de Conexión de Base de Datos-----------------------------------------" + Environment.NewLine);
                    writer.WriteLine("Fecha de Error: " + DateTime.Now + "");
                    writer.WriteLine("Error: " + ex.Message.ToString() + "");
                    writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine);
                }

                bandera = false;
            }

            return(bandera);
        }
Esempio n. 2
0
        public void Insertar_Enrrolamiento_BD(List <checkinout> ListaEmpleadoEnrrolamiento)
        {
            var           connectionString = ConfigurationManager.ConnectionStrings["DBInformix"].ConnectionString;
            PerInformixDB per = new PerInformixDB();

            try
            {
                per.AbrirConexion();
                EventLog.WriteEntry("Insercion de Datos a la Base de Datos");

                foreach (checkinout entidad in ListaEmpleadoEnrrolamiento)
                {
                    var sql = "insert into checkinout (enrollnumber,date,hour,checkinout,device,id_dispositivo,id_empleado) values (?,?,?,?,?,?,?);";

                    using (var cmd = new IfxCommand(sql, per.Conexion))
                    {
                        cmd.Parameters.Add(new IfxParameter()).Value = entidad.numeroCredencial;
                        cmd.Parameters.Add(new IfxParameter()).Value = entidad.pFecha;
                        cmd.Parameters.Add(new IfxParameter()).Value = entidad.pHora;
                        cmd.Parameters.Add(new IfxParameter()).Value = entidad.Ckecked;
                        cmd.Parameters.Add(new IfxParameter()).Value = entidad.Device;
                        cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_dispositivo;
                        cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_empleado;
                        cmd.ExecuteNonQuery();
                    }

                    string filePath = ConfigurationManager.AppSettings["file_log"];
                    using (StreamWriter writer = new StreamWriter(filePath, true))
                    {
                        writer.WriteLine(Environment.NewLine + "---Inserción de Asistencia a la Base de Datos Exitosamente!!-------------------------------" + Environment.NewLine);
                        writer.WriteLine("ID Empleado: " + entidad.id_empleado.ToString() + Environment.NewLine);
                        writer.WriteLine("Número de Enrolamiento: " + entidad.numeroCredencial.ToString());
                        writer.WriteLine(Environment.NewLine + "-------------------------------------------------------------------------------------------" + Environment.NewLine);
                    }
                }
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry("Error:" + ex.Message);
                using (StreamWriter writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine(Environment.NewLine + "--Error de Conexión de Base de Datos-----------------------------------------" + Environment.NewLine);
                    writer.WriteLine("Hora de Error: " + DateTime.Now + "");
                    writer.WriteLine("Error: " + ex.Message.ToString() + "");
                    writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine);
                }
            }
            finally
            {
                per.CerrarConexion();
            }
        }
Esempio n. 3
0
        private void zkemClient_OnAttTransactionEx(string EnrollNumber, int IsInValid, int AttState, int VerifyMethod, int Year, int Month, int Day, int Hour, int Minute, int Second, int WorkCode)
        {
            var connectionString = ConfigurationManager.ConnectionStrings["DBInformix"].ConnectionString;

            ip = ConfigurationManager.AppSettings["device_ip"];

            using (StreamWriter writer = new StreamWriter(filePath, true))
            {
                writer.WriteLine(" OnAttTrasactionEx Has been Triggered,Verified OK on" + "Date :" + "Enrollnumber: " + EnrollNumber + "|" + DateTime.Now.ToString());
                writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine);
            }
            PerInformixDB per = new PerInformixDB();

            try
            {
                checkinout entidad = new checkinout();
                entidad.anio             = Year;
                entidad.mes              = Month;
                entidad.dia              = Day;
                entidad.hora             = Hour;
                entidad.minuto           = Minute;
                entidad.segundo          = Second;
                entidad.numeroCredencial = int.Parse(EnrollNumber);
                entidad.Device           = ip;

                per.AbrirConexion();
                EventLog.WriteEntry("Connection Open");

                var sql = "insert into checkinout (enrollnumber,date,hour,checkinout,device) values (?,?,?,?,?);";

                using (var cmd = new IfxCommand(sql, per.Conexion))
                {
                    cmd.Parameters.Add(new IfxParameter()).Value = entidad.numeroCredencial;
                    cmd.Parameters.Add(new IfxParameter()).Value = entidad.pFecha;
                    cmd.Parameters.Add(new IfxParameter()).Value = entidad.pHora;
                    cmd.Parameters.Add(new IfxParameter()).Value = entidad.Ckecked;
                    cmd.Parameters.Add(new IfxParameter()).Value = entidad.Device;
                    cmd.ExecuteNonQuery();
                }

                EventLog.WriteEntry("Insert EnrollNumber: " + EnrollNumber);
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry("Error:" + ex.Message);
            }
            finally
            {
                per.CerrarConexion();
            }
        }