Esempio n. 1
0
        private InformacionVehiculo EsperarDatosChipLectorDtiImpresionTicket(string ocara, bool EsLecturaObligatoria = true)
        {
            Helper oDatos              = new Helper();
            int    intentos            = Convert.ToInt32(oDatos.RecuperarParametro("LecturaChipReintentos"));
            Int32  Delay               = Convert.ToInt32(oDatos.RecuperarParametro("LecturaChipDelay"));
            InformacionVehiculo OPlaca = new InformacionVehiculo();

            POSstation.EncriptacionDti.EncriptacionDti oNorma = new POSstation.EncriptacionDti.EncriptacionDti();
            int i = 0;

            try
            {
                while (i <= intentos)
                {
                    if (LecturasLSIB4.ContainsKey(ocara))
                    {
                        //OPlaca = oNorma.ExtraerInformacionPaginasImpresiones(LecturasLSIB4(ocara).ArregloBytes)
                        OPlaca = DesencriptarBytesDti(EsLecturaObligatoria, Convert.ToByte(ocara), LecturasLSIB4[ocara].ArregloBytes);
                        LecturasLSIB4.Remove(ocara);

                        if (OPlaca == null)
                        {
                            throw new System.Exception("Retire y coloque nuevamente el chip en el lector");
                        }

                        break; // TODO: might not be correct. Was : Exit While
                    }
                    else
                    {
                        System.Threading.Thread.Sleep(Convert.ToInt32(Delay / 3));
                    }

                    if (i >= intentos)
                    {
                        throw new System.Exception("No hay un chip conectado");
                    }
                }
                return(OPlaca);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public InformacionVehiculo DesencriptarBytesDti(bool EsLecturaChipObligatoria, byte cara, byte[] Paginas)
        {
            InformacionVehiculo oInformacion = new InformacionVehiculo();

            try
            {
                try
                {
                    System.Text.UTF8Encoding convercion = new System.Text.UTF8Encoding();
                    string strSalida     = null;
                    string identificador = "";
                    string PuertoDti     = null;

                    if (Paginas.Length > 0)
                    {
                        try
                        {
                            POSstation.EncriptacionDti.EncriptacionDti oEncripcion = new POSstation.EncriptacionDti.EncriptacionDti();

                            if (EsLecturaChipObligatoria)
                            {
                                byte[] ContenidoChip = new byte[128];
                                int    j             = 0;
                                int    i             = 0;
                                j = 0;
                                for (i = 19; i <= Paginas.Length - 1; i++)
                                {
                                    ContenidoChip[j] = Paginas[i];
                                    j = j + 1;
                                }

                                dynamic Temporal = new byte[19];

                                System.Text.UTF8Encoding datos = new System.Text.UTF8Encoding();

                                i = 0;
                                for (i = 0; i <= 18; i++)
                                {
                                    Temporal[i] = Paginas[i];
                                }

                                //convierto a string los primeros 19 byets para sacar el rom y el puerto
                                strSalida = datos.GetString(Temporal);
                                if (!string.IsNullOrEmpty(strSalida))
                                {
                                    string[] Tmp = strSalida.Split('.');
                                    PuertoDti     = Tmp[0];
                                    identificador = Tmp[1];
                                }

                                LogCategorias.Clear();
                                LogCategorias.Agregar("SeguimientoCodigoDTI");
                                LogPropiedades.Clear();
                                LogPropiedades.Agregar("Mensaje", "Se saca el Rom de la cabacera del LSIB4");
                                LogPropiedades.Agregar("Rom", identificador);
                                POSstation.Fabrica.LogIt.Loguear("DesencriptarDTI", LogPropiedades, LogCategorias);

                                oInformacion = oEncripcion.ExtraerInformacionPaginas(ContenidoChip, identificador, EsLecturaChipObligatoria);
                            }
                            else
                            {
                                dynamic Temporal = new byte[19];
                                System.Text.UTF8Encoding datos = new System.Text.UTF8Encoding();

                                for (int i = 0; i <= 18; i++)
                                {
                                    Temporal[i] = Paginas[i];
                                }

                                //convierto a string los primeros 19 byets para sacar el rom y el puerto
                                strSalida = datos.GetString(Temporal);
                                if (!string.IsNullOrEmpty(strSalida))
                                {
                                    string[] Tmp = strSalida.Split('.');
                                    PuertoDti     = Tmp[0];
                                    identificador = Tmp[1];
                                }
                                oInformacion = oEncripcion.ExtraerInformacionPaginas(Paginas, identificador, EsLecturaChipObligatoria);
                            }
                        }
                        catch (System.Exception ex)
                        {
                            LogCategorias.Clear();
                            LogCategorias.Agregar("SeguimientoCodigoDTI");
                            LogPropiedades.Clear();
                            LogPropiedades.Agregar("Mensaje", ex.Message);
                            POSstation.Fabrica.LogIt.Loguear("Error recuperando ROM chip ExtraerInformacionPaginas", LogPropiedades, LogCategorias);
                            throw ex;
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    throw ex;
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
            return(oInformacion);
        }