Ejemplo n.º 1
0
        // obtiene checadas BlackWhite
        private List <Modelos.AttLogs> obtieneChecadas()
        {
            List <Modelos.AttLogs> result = new List <Modelos.AttLogs>();

            Modelos.AttLogs ent;

            int    idwEnrollNumber = 0;
            int    idwVerifyMode   = 0;
            int    idwInOutMode    = 0;
            string dwTimestr       = string.Empty;

            int idwErrorCode = 0;

            Cursor = Cursors.WaitCursor;

            axCZKEM1.EnableDevice(iMachineNumber, false);                                                                                      // disable the device

            if (axCZKEM1.ReadGeneralLogData(iMachineNumber))                                                                                   // read all the attendance records to the memory
            {
                while (axCZKEM1.GetGeneralLogDataStr(iMachineNumber, ref idwEnrollNumber, ref idwVerifyMode, ref idwInOutMode, ref dwTimestr)) // get records from the memory
                {
                    ent = new Modelos.AttLogs();

                    ent.enrolIdNumber = idwEnrollNumber;
                    ent.fecha         = Convert.ToDateTime(dwTimestr);

                    result.Add(ent);
                }
            }
            else
            {
                Cursor = Cursors.Default;
                axCZKEM1.GetLastError(ref idwErrorCode);

                if (idwErrorCode != 0)
                {
                    this.agregarDetalle("Lectura de información del checador falló. ErrorCode: " + idwErrorCode.ToString());
                    throw new Exception("Lectura de información del checador falló. ErrorCode: " + idwErrorCode.ToString());
                }
                else
                {
                    this.agregarDetalle("No hay informacion en el Checador");
                    throw new Exception("No hay informacion en el Checador");
                }
            }

            axCZKEM1.EnableDevice(iMachineNumber, true);//enable the device
            Cursor = Cursors.Default;

            return(result);
        }
Ejemplo n.º 2
0
        // conexion y checadas TFT
        private Modelos.Response checadasTFT(string ip, int puerto, DateTime ultFecha)
        {
            Modelos.Response result = new Modelos.Response();

            try
            {
                // estableciendo conexion con el checador
                this.agregarDetalle("Estableciendo conexión con el checador");
                var respuesta = TFT.TFT.conectar(ip, puerto);

                if (respuesta.status == TFT.Estatus.ERROR)
                {
                    throw new Exception(respuesta.error);
                }

                this.agregarDetalle("Conexión Exitosa!!!");

                // inicializa clase de conexion a la base de datos
                this._consultasNegocio = new ConsultasNegocio();

                // obtiene checadas
                this.agregarDetalle("Obteniendo los registros del checador");
                List <TFT.AttLogs> resultado = TFT.TFT.obtieneChecadas();
                List <TFT.AttLogs> traspaso  = resultado.FindAll(fl => fl.fecha >= ultFecha);

                Modelos.AttLogs ent;

                foreach (TFT.AttLogs res in traspaso)
                {
                    try
                    {
                        ent = new Modelos.AttLogs();
                        ent.enrolIdNumber = res.enrolIdNumber;
                        ent.fecha         = res.fecha;
                        ent.noChecador    = Modelos.ConectionString.numCh;

                        // ingresa un usuario como pendiente en caso de no tenerlo registrado
                        this._consultasNegocio.insertaNuevo(res.enrolIdNumber);

                        // inserta los registros a la base de datos
                        this._consultasNegocio.insertaRegistro(ent);

                        // imprime mensajes en pantalla
                        this.agregarDetalle("Registro Agregado: IdInterno: " + res.enrolIdNumber + "\tFecha: " + res.fecha.ToString("yyyy-MM-dd HH:mm"));
                    }
                    catch (Exception EX)
                    {
                        if (EX.Message.ToLower().Contains("duplicate entry"))
                        {
                            this.agregarDetalle(string.Format("El registro con IdInteno: {0} y FechaHora: {1} ya existe.", res.enrolIdNumber, res.fecha.ToString("yyyy-MM-dd HH:mm")));
                            Application.DoEvents();
                            continue;
                        }

                        throw new Exception(EX.Message);
                    }
                }

                // desconectar checador
                this.agregarDetalle("Cerrando conexión con el checador");
                TFT.TFT.desConectar();

                result.status = Modelos.Estatus.OK;
            }
            catch (Exception Ex)
            {
                TFT.TFT.desConectar();
                Cursor        = Cursors.Default;
                result.error  = Ex.Message;
                result.status = Modelos.Estatus.ERROR;
            }

            return(result);
        }