protected void btIngenieriaInversa_Click(object sender, EventArgs e)
        {
            if (this.tbTrama.Text == "")
            {
                MyMaster.AlertaMostrar("Ingrese la Trama");
                return;
            }
            byte[] vl_baTramaString = new byte[this.tbTrama.Text.Length];
            vl_baTramaString = System.Text.Encoding.ASCII.GetBytes(this.tbTrama.Text);
            var vl_cUnpackIso8583 = new ISO8583.Iso8583(vl_baTramaString, this.cbLongitud.Checked);

            this.lbMTI.Text = vl_cUnpackIso8583.MTI;
            for (int vl_iContador = 2; vl_iContador <= 128; vl_iContador++)
            {
                var vl_cCampoDato = vl_cUnpackIso8583.obtenerCampoDatos(vl_iContador);
                if (vl_cCampoDato != null)
                {
                    TableRow  vl_trRow = new TableRow();
                    TableCell vl_tcBit = new TableCell();
                    vl_tcBit.Text = "Bit " + vl_iContador.ToString();
                    TableCell vl_tcValor = new TableCell();
                    vl_tcValor.Text = vl_cCampoDato.ValorEnvio;
                    vl_trRow.Cells.Add(vl_tcBit);
                    vl_trRow.Cells.Add(vl_tcValor);
                    tlInversa.Rows.Add(vl_trRow);
                }
            }
            this.tlInversa.Visible = true;
        }
Ejemplo n.º 2
0
        protected void btEnviar_Click(object sender, EventArgs e)
        {
            if (this.ddlConexion.SelectedItem.Value == "")
            {
                MyMaster.AlertaMostrar("Seleccione la conexión");
                return;
            }
            var vl_isoTrama = new ISO8583.Iso8583(this.lbMTI.Text);

            for (int vl_iContador = 2; vl_iContador <= 128; vl_iContador++)
            {
                System.Web.UI.HtmlControls.HtmlTableRow vl_trCampo = (System.Web.UI.HtmlControls.HtmlTableRow)pnSimular.FindControl("trCampo" + vl_iContador.ToString());
                if (vl_trCampo.Visible)
                {
                    TextBox vl_tbCampo      = (TextBox)pnSimular.FindControl("tbCampo" + vl_iContador.ToString());
                    var     vl_cValidaCampo = vl_isoTrama.adicionarCampoDatos(vl_iContador, vl_tbCampo.Text);
                }
            }
            DateTime vl_dtInicio, vl_dtFin;
            int      m_iBytes = 0;

            byte[]   m_aBuffer = new byte[8000];
            byte[]   newArray;
            string[] vl_sDetalleConexion = this.ddlConexion.SelectedItem.Value.Split('|');
            byte[]   vl_baTrama          = vl_isoTrama.obtieneTramaBytes();
            this.tbTrama.Text = System.Text.Encoding.ASCII.GetString(vl_baTrama, 0, vl_baTrama.Length);
            var endPoint     = new IPEndPoint(IPAddress.Parse(vl_sDetalleConexion[0]), int.Parse(vl_sDetalleConexion[1]));
            var vl_tcpSocket = new TcpClient();

            vl_tcpSocket.SendTimeout    = int.Parse(vl_sDetalleConexion[2]) * 1000;
            vl_tcpSocket.ReceiveTimeout = int.Parse(vl_sDetalleConexion[3]) * 1000;
            vl_dtInicio = DateTime.Now;
            try
            {
                vl_tcpSocket.Connect(endPoint);
            }
            catch
            {
                MyMaster.AlertaMostrar("No se pudo establecer la conexión.");
                return;
            }
            System.IO.Stream nsEscritura = vl_tcpSocket.GetStream();
            nsEscritura.Write(vl_baTrama, 0, vl_baTrama.Length);
            try
            {
                m_iBytes = nsEscritura.Read(m_aBuffer, 0, m_aBuffer.Length);

                newArray = new byte[m_iBytes];
                Array.Copy(m_aBuffer, 0, newArray, 0, m_iBytes);
                //Buffer.BlockCopy(m_aBuffer, 16, newArray, 0, m_iBytes);
            }
            catch
            {
                MyMaster.AlertaMostrar("Se agotó el tiempo de espera para la recepción del mensaje.");
                vl_tcpSocket.Close();
                return;
            }
            vl_tcpSocket.Close();
            vl_dtFin                    = DateTime.Now;
            this.tbTrama.Text           = vl_isoTrama.generarMensaje();
            this.tlEnvio.Visible        = true;
            vl_isoTrama                 = new ISO8583.Iso8583(newArray);
            this.tbTramaRespuesta.Text  = System.Text.Encoding.ASCII.GetString(newArray);
            this.lbTiempoRespuesta.Text = (vl_dtFin - vl_dtInicio).TotalSeconds.ToString();
            this.tlRespuesta.Visible    = true;
        }