public async Task <object> AbrirPuerta([FromBody] ReaderPath_DTO pathReader)
 {
     try {
         return(await _reader_REP_LOCAL.AbrirPuerta(pathReader));
     }
     catch (Exception ex) { return(BadRequest(ex.Message)); }
 }
        public async Task <object> BloquearPuerta([FromBody] ReaderPath_DTO pathReader)
        {
            try
            {
                object result = new
                {
                    sucess = await _reader_REP_LOCAL.BloquearPuerta(pathReader),
                    status = 200,
                    data   = "Done"
                };

                return(result);
            }
            catch (Exception ex)
            {
                object result = new
                {
                    sucess = false,
                    status = 400,
                    data   = ex.Message
                };

                return(BadRequest(result));
            }
        }
 public async Task <object> CambiarEstadoPuerta([FromBody] ReaderPath_DTO pathReader, int estadoId)
 {
     try
     {
         return(await _reader_REP_LOCAL.CambioEstadoPuerta(pathReader, estadoId));
     }
     catch (Exception ex) { return(BadRequest(ex.Message)); }
 }
 public async Task <bool> AbrirPuerta(ReaderPath_DTO readerPath)
 {
     try{
         return(await _reader_REP.OpenDoor(readerPath.panelID, readerPath.readerID, _path, _user, _pass));
     }
     catch (Exception ex) {
         throw new Exception(ex.Message);
     }
 }
Beispiel #5
0
 public async Task <bool> AbrirPuerta(ReaderPath_DTO readerPath)
 {
     try{
         return(await _reader_REP.ReaderSetMode(readerPath.panelID, readerPath.readerID, IReader.readerMode.CARDONLY,
                                                _path, _user, _pass));
     }
     catch (Exception ex) {
         throw new Exception(ex.Message);
     }
 }
Beispiel #6
0
 public async Task <object> BloquearPuerta(ReaderPath_DTO readerPath)
 {
     try
     {
         return(await _reader_REP.ReaderSetMode(readerPath.panelID, readerPath.readerID, IReader.readerMode.LOCKED,
                                                _path, _user, _pass));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Beispiel #7
0
        public async Task <object> CambioEstadoPuerta(ReaderPath_DTO readerPath, int estado)
        {
            IReader.readerMode readerMode = (IReader.readerMode)Enum.Parse(typeof(IReader.readerMode), estado.ToString());

            try
            {
                return(await _reader_REP.ReaderSetMode(readerPath.panelID, readerPath.readerID, readerMode,
                                                       _path, _user, _pass));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public async Task <object> AutorizarSalida([FromBody] SendEvent_DTO evento)
        {
            try
            {
                //Obtiene la información de la persona que esta ingresando
                int               badgekey = 0;
                string            badgeID  = "";
                GetCardHolder_DTO persona  = await _cardHolder_REP_LOCAL.ObtenerPersona(evento.documento, "");

                //obtiene un badgekey de la persona
                foreach (GetBadge_DTO badge in persona.Badges)
                {
                    if (badge.estado == "1")
                    {
                        badgekey = badge.badgekey;
                        badgeID  = badge.badgeID;
                    }
                }

                if (badgekey == 0)
                {
                    throw new Exception("no se encontro un badge activo");
                }

                EvaluacionEvento_DTO eval   = new EvaluacionEvento_DTO();
                SendEvent_DTO        acceso = new SendEvent_DTO
                {
                    source    = evento.source,
                    device    = evento.device,
                    subdevice = evento.subdevice
                };
                ReaderPath_DTO lectora = new ReaderPath_DTO
                {
                    panelID  = evento.panelId,
                    readerID = evento.readerId,
                };

                if (evento.documento != null)
                {
                    eval = GetDescripcion(tipoEvento.SB, evento);
                }
                else
                {
                    eval = GetDescripcion(tipoEvento.SBNI, evento);
                }

                evento.description = eval.descripcionEvento;
                //ENVIO DE EVENTO A LA PGR
                bool enviado = await _reader_REP_LOCAL.EnviarEventoGenerico(evento);

                //EVENTO REGISTRO DE MARCACION Y ACCION
                acceso.isAccessGranted = true;
                acceso.isAccessDeny    = false;
                acceso.badgeId         = int.Parse(badgeID);
                await _reader_REP_LOCAL.EnviarEventoGenerico(acceso);

                await _reader_REP_LOCAL.AbrirPuerta(lectora);

                if (enviado)
                {
                    return(eval);
                }
                else
                {
                    throw new Exception("No se pudo enviar el evento");
                }
            }
            catch (Exception ex)
            {
                object result = new
                {
                    sucess = false,
                    status = 400,
                    data   = ex.Message
                };

                return(BadRequest(result));
            }
        }