Exemplo n.º 1
0
        public static ApiResponse.DatosChip GetDataChip(string ROM)
        {
            PropiedadesExtendidas LogPropiedades = new PropiedadesExtendidas();
            CategoriasLog         LogCategorias  = new CategoriasLog();

            try
            {
                ApiResponse.DatosChip response = null;
                LogCategorias.Clear();
                LogCategorias.Agregar("SICOM");
                LogPropiedades.Clear();
                LogPropiedades.Agregar("Mensaje", "Antes de enviar la consulta");
                LogPropiedades.Agregar("ROM ENVIADO", ROM);
                LogPropiedades.Agregar("Fecha", DateTime.Now.ToString());
                POSstation.Fabrica.LogIt.Loguear("Envio de consulta de chip sicom", LogPropiedades, LogCategorias);

                string json = ApiSICOM.ExecuteApiCommand("ConsultarChip", "", ROM);


                LogCategorias.Clear();
                LogCategorias.Agregar("SICOM");
                LogPropiedades.Clear();
                LogPropiedades.Agregar("Mensaje", "Despues de enviar la consulta");
                LogPropiedades.Agregar("JSON RECIBIDO", json);
                LogPropiedades.Agregar("Fecha", DateTime.Now.ToString());
                POSstation.Fabrica.LogIt.Loguear("Respuesta de consulta de chip sicom", LogPropiedades, LogCategorias);

                response = JSON.Deserialize <ApiResponse.DatosChip>(json);

                ApiSICOM.ThrowExceptionApi(response);

                return(response);
            }
            catch { throw; }
        }
Exemplo n.º 2
0
 //Se verifica el formato del chip
 private string LimpiarCadena(string cadena)
 {
     System.Text.StringBuilder resultado = new StringBuilder();
     try
     {
         for (int I = 0; I < cadena.Length; I++)
         {
             if ("ABCDEFGHIJKLMNÑOPQRSTUVWXYZabcdefghijklmnñopqrstuvwxyz;0123456789".IndexOf(cadena.Substring(I, 1)) >= 0)
             {
                 resultado.Append(cadena.Substring(I, 1));
             }
             else
             {
                 break;
             }
         }
     }
     catch (Exception ex)
     {
         LogCategorias.Clear();
         LogCategorias.Agregar("SeguimientoCodigoDTI");
         LogPropiedades.Clear();
         LogPropiedades.Agregar("Mensaje", ex.Message);
         POSstation.Fabrica.LogIt.Loguear("Error en LimpiarCadena DTI", LogPropiedades, LogCategorias);
     }
     return(resultado.ToString());
 }
Exemplo n.º 3
0
 public TcpServer(string Puerto, int IdDispositivo)
 {
     try
     {
         this.Puerto        = Puerto;
         IdDispositivoLSIB4 = IdDispositivo;
         IPAddress[] ipv4Addresses = Array.FindAll(Dns.GetHostEntry(string.Empty).AddressList, a => a.AddressFamily == AddressFamily.InterNetwork);
         _Ip = ipv4Addresses[0].ToString();
     }
     catch (Exception ex)
     {
         LogCategorias.Clear();
         LogCategorias.Agregar("Anomalia");
         LogPropiedades.Clear();
         LogPropiedades.Agregar("Mensaje", ex.Message);
         POSstation.Fabrica.LogIt.Loguear("Excepcion Iniciando Servidor Tcp", LogPropiedades, LogCategorias);
     }
 }
        private string[] ExtraerInformacionRecibidaDelDispositivoDTI(byte[] ArregloBytes)
        {
            byte[] Temporal;
            string TempPuerto = string.Empty;

            string[] Valores = new string[1];
            int      j       = 0;

            try
            {
                LogCategorias.Clear();
                LogCategorias.Agregar("SeguimientoCodigoDTI");
                LogPropiedades.Clear();
                LogPropiedades.Agregar("Numero Bytes Recibidos de Lectura", ArregloBytes.Length.ToString());
                LogPropiedades.Agregar("FechaHora:", DateTime.Now.ToString());
                POSstation.Fabrica.LogIt.Loguear("Logueando el numero de bytes recibidos de la dti", LogPropiedades, LogCategorias);


                if (ArregloBytes.Length > 150)//Se realizo una mala conexcion del chip en el lector
                {
                    LogCategorias.Clear();
                    LogCategorias.Agregar("SeguimientoCodigoDTI");
                    LogPropiedades.Clear();
                    LogPropiedades.Agregar("FechaHora:", DateTime.Now.ToString());
                    POSstation.Fabrica.LogIt.Loguear("Logueando la lectura del chip no se hizo correctamente debido que se coloco y se retiro inmediatamente", LogPropiedades, LogCategorias);
                }
                else
                {
                    if (ArregloBytes.Length > 128) //Me indica que lo que llega es una lectura con pagina y no la trama I#.NC que es la trama cuando se desconecta
                    {                              //El chip del lector
                        ////Saco la informacion correspondiente a la cabecera de la trama dado que me llegara de la siguiente forma
                        //// I#.ROM PAGINAS
                        Temporal = new byte[19]; //Aqui saco la informacion del Puerto y el ROM que vienen en los primeros 19 Bytes
                        for (int i = 0; i <= 18; i++)
                        {
                            Temporal[i] = ArregloBytes[i];
                        }


                        System.Array oPaginas;
                        oPaginas = System.Array.CreateInstance(typeof(byte), ArregloBytes.Length);

                        for (int i = 0; i < ArregloBytes.Length; i++)
                        {
                            oPaginas.SetValue(ArregloBytes[i], i);
                        }

                        ///OJOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO////
                        //Aqui le informo a sauce que se conecto el chip
                        if (EnviarBytesLecturaChipPorDti != null)
                        {
                            EnviarBytesLecturaChipPorDti(oPaginas, Puerto, IdDispositivoDti);
                        }
                    }
                    else//Cuando entra aqui es porque se desconecto el chip y recibi la trama I#.NC ()
                    {
                        Temporal = new byte[5]; //Aqui saco la informacion del Puerto y el donde se deconecto el chip
                        for (int i = 0; i <= 4; i++)
                        {
                            Temporal[i] = ArregloBytes[i];
                        }


                        System.Array oPaginas;
                        oPaginas = System.Array.CreateInstance(typeof(byte), Temporal.Length);

                        for (int i = 0; i < Temporal.Length; i++)
                        {
                            oPaginas.SetValue(Temporal[i], i);
                        }

                        //Aqui le informo a sauce que se desconecto el chip
                        if (EnviarBytesLecturaChipPorDti != null)
                        {
                            EnviarBytesLecturaChipPorDti(oPaginas, Puerto, IdDispositivoDti);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogCategorias.Clear();
                LogCategorias.Agregar("SeguimientoCodigoDTI");
                LogPropiedades.Clear();
                LogPropiedades.Agregar("Mensaje", ex.Message);
                POSstation.Fabrica.LogIt.Loguear("Error en ExtraerPuerto", LogPropiedades, LogCategorias);
                throw ex;
            }
            return(Valores);
        }
Exemplo n.º 5
0
        private void OEventos_EnviarBytesLecturaChipPorDti(System.Array Lectura, string Puerto, int IdDispositivoDti)
        {
            try
            {
                byte[] paginas       = new byte[147];
                int    i             = 0;
                byte[] cabeceratrama = new byte[19];
                string trama         = null;
                System.Text.UTF8Encoding convercion = new System.Text.UTF8Encoding();
                string[] Temporal      = null;
                string   puertodti     = "";
                string   identificador = null;

                Helper oHelper        = new Helper();
                string CadenaAuxiliar = "";
                int    j = 0;


                //'Datos de la lectura del chip
                if (Lectura.Length >= 147)
                {
                    for (i = 0; i <= 18; i++)
                    {
                        cabeceratrama[i] = (byte)Lectura.GetValue(i);
                    }


                    for (i = 0; i <= Lectura.Length - 1; i++)
                    {
                        paginas[j] = (byte)Lectura.GetValue(i);
                        j          = j + 1;
                    }

                    //Saco la cabecera de la trama que corresponde al puerto de la dti y el rom
                    trama = convercion.GetString(cabeceratrama);

                    if (!string.IsNullOrEmpty(trama))
                    {
                        Temporal      = trama.Split(('.'));
                        puertodti     = Temporal[0];
                        identificador = Temporal[1];
                    }

                    if (paginas.Length >= 128)
                    {
                        try
                        {
                            Cara = oHelper.RecuperarCaraPorDispositivo(IdDispositivoDti, puertodti);
                            BytesLectura Bytes = new BytesLectura();
                            Bytes.ArregloBytes = paginas;


                            if (LecturasLSIB4.ContainsKey(Cara.ToString()))
                            {
                                LecturasLSIB4.Remove(Cara.ToString());
                            }
                            else
                            {
                                LecturasLSIB4.Add(Cara.ToString(), Bytes);
                            }
                        }
                        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;
                        }
                    }
                }
                else
                {
                    //Aqui saco la informacion del Puerto y el donde se deconecto el chip
                    for (i = 0; i <= 4; i++)
                    {
                        cabeceratrama[i] = (byte)Lectura.GetValue(i);
                    }

                    System.Text.UTF8Encoding datos = new System.Text.UTF8Encoding();
                    //convierto a string los primeros 19 byets para sacar el rom y el puerto
                    CadenaAuxiliar = datos.GetString(cabeceratrama);


                    LogCategorias.Clear();
                    LogCategorias.Agregar("SeguimientoCodigoDTI");
                    LogPropiedades.Clear();
                    LogPropiedades.Agregar("Puerto Recibido", puertodti);
                    POSstation.Fabrica.LogIt.Loguear("Logueando la separacion de la trama cuando se desconecta el chip", LogPropiedades, LogCategorias);

                    if (!string.IsNullOrEmpty(CadenaAuxiliar))
                    {
                        string[] cadenaTemporal = null;

                        //Hago un split para separa la trama, por ejemplo me llega I2.NC, hago el slit para sacar el puerto y la trama
                        cadenaTemporal = CadenaAuxiliar.Split('.');

                        //Almaceno el puerto

                        puertodti = cadenaTemporal[0];
                        //Aqui le informo al autorizador que se desconecto el chip de la DTI

                        Cara = oHelper.RecuperarCaraPorDispositivo(IdDispositivoDti, puertodti);
                        // OEventosInformarCaraSinChipDti(Cara, puertodti, Puerto);
                    }
                    else
                    {
                        throw new System.Exception("Falla en extraer Puerto en la trama de desconexion de chip LSIB4");
                    }
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }