Exemplo n.º 1
0
        public static void mensaje(String sMensaje, String sNombreArchivo, String sExtencion)
        {
            char cLF, cCR;

            cLF = Convert.ToChar(0X0A);
            cCR = Convert.ToChar(0X0D);

            String sFecha = DateTime.Now.ToString("yyyyMMddHH:mm:ss");
            String sRuta  = AppPath(true) + "Log\\";

            Directory.CreateDirectory(sRuta);
            UTILIDADES.almacenarArchivo(sRuta, sNombreArchivo, true, sMensaje);
            //new GrabaArchivo(sRuta + sNombreArchivo + sFecha.Substring(0, 8) + "." + sExtencion, sFecha.Substring(8) + "\t" + sMensaje, true);
        }
Exemplo n.º 2
0
        public String EnvioRequerimiento()
        {
            String         _respuesta = "";
            String         sError     = "";
            String         sPosteo;
            String         sFileName;
            String         sFecha;
            ParserContext  parserContext;
            Hashtable      ISO;
            Iso8583Message isoMsgResp;
            Socket         socket;

            byte[] bBody;
            byte[] bBufferRecive;
            byte[] bBufferEnvio;
            int    iLargoBody;

            if (this._trama.Length != _lengthTrama)
            {
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("POS   : " + "Longitud de trama Plana de requerimiento no es valida", "LogEvent", "log");
                }
                return("");
            }
            if (this._iGrabaLog == 1)
            {
                UTILIDADES.mensaje("INPUT METODO : " + UTILIDADES.ProtegeTramaPlana(_trama), "LogTracer", "log");
            }
            try
            {
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("DEBUG : " + "Previo Socket", "LogEvent", "log");
                }
                socket = InicializaSocket();
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("DEBUG : " + "Despues Socket", "LogEvent", "log");
                }
            }
            catch (System.Net.Sockets.SocketException e)
            {
                sError += e.Message;
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("POS   : " + e.Message, "LogEvent", "log");
                }
                throw new Exception(sError);
            }
            try
            {
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("DEBUG : " + "Antes de ISO to BYTE", "LogEvent", "log");
                }
                bBufferEnvio = TransformaISOByte(_ISOMsg, "6000081000");
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("DEBUG : " + "Despues de ISO to BYTE", "LogEvent", "log");
                }
            }
            catch (Exception e)
            {
                sError += e.Message;
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("POS   : " + e.Message, "LogEvent", "log");
                }
                throw new Exception(sError);
            }
            try
            {
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("DEBUG : " + "Antes de Envio", "LogEvent", "log");
                }
                socket.Send(bBufferEnvio);
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("DEBUG : " + "Despues de Envio", "LogEvent", "log");
                }
                if (this._iGrabaLog == 1)
                {
                    UTILIDADES.mensaje("OUTPUT DLL   : " + _ISOMsg.ToString(), "LogTracer", "log");
                }
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("DEBUG : " + "TimeOut Definido", "LogEvent", "log");
                }
                socket.ReceiveTimeout = Convert.ToInt32(_timeoutPos);
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("DEBUG : " + "TimeOut Definido", "LogEvent", "log");
                }
                bBufferRecive = new byte[socket.ReceiveBufferSize];
                socket.Receive(bBufferRecive);
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("DEBUG : " + "Buffer recibido", "LogEvent", "log");
                }
                ISO = TransaformaIso(bBufferRecive);
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("DEBUG : " + "Transforma buffer ISO", "LogEvent", "log");
                }
                bBody         = (byte[])ISO["Body"];
                iLargoBody    = bBody.Length;
                parserContext = new ParserContext(iLargoBody);
                parserContext.Initialize();
                parserContext.ResizeBuffer(iLargoBody);
                parserContext.Write(bBody);
                isoMsgResp = (Iso8583Message)_ISOMsg.Formatter.Parse(ref parserContext);
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("DEBUG : " + "Finaliza buffer ISO", "LogEvent", "log");
                }
                if (this._iGrabaLog == 1)
                {
                    UTILIDADES.mensaje("INPUT DLL    : " + isoMsgResp.ToString(), "LogTracer", "log");
                }
            }
            catch (Exception e)
            {
                sError += e.Message;
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("DEBUG : " + "Excepcion :" + sError, "LogEvent", "log");
                }
                if (((Field)_ISOMsg.Fields[3]).Value.ToString().CompareTo("003000") == 0)
                {
                    try
                    {
                        if (this._iGrabaMsg == 1)
                        {
                            UTILIDADES.mensaje("DEBUG : " + "Inicia Posteo", "LogEvent", "log");
                        }
                        sPosteo = UTILIDADES.F3DESEncriptarBloque(UTILIDADES.padMultiplo(UTILIDADES.Byte2Hex(_ISOMsg.GetBytes()), 16, "1C"), _sLlaveKEKIzquierda, _sLlaveKEKDerecha);
                        if (this._iGrabaMsg == 1)
                        {
                            UTILIDADES.mensaje("DEBUG : " + "Finaliza cifrado", "LogEvent", "log");
                        }
                        sFecha = DateTime.Now.ToString("HHmmss");
                        String sRuta = UTILIDADES.AppPath(true) + "Saf\\";
                        if (this._iGrabaMsg == 1)
                        {
                            UTILIDADES.mensaje("DEBUG : " + "Valida Ruta de Posteo", "LogEvent", "log");
                        }
                        Directory.CreateDirectory(sRuta);
                        sFileName = Convert.ToString(_ISOMsg.MessageTypeIdentifier) + ((Field)_ISOMsg.Fields[11]).Value.ToString() + ((Field)_ISOMsg.Fields[41]).Value.ToString() + ((Field)_ISOMsg.Fields[112]).Value.ToString() + sFecha + ".saf";
                        //new GrabaArchivo(sFileName, sPosteo, false);
                        if (this._iGrabaMsg == 1)
                        {
                            UTILIDADES.mensaje("DEBUG : " + "Guarda Archivo de Posteo", "LogEvent", "log");
                        }
                        UTILIDADES.almacenarArchivo(sRuta, sFileName, false, sPosteo);
                        if (this._iGrabaMsg == 1)
                        {
                            UTILIDADES.mensaje("DEBUG : " + "Ejecuta Posteo", "LogEvent", "log");
                        }
                        new Posteo(_ip, _puerto, _timeoutPos, _iGrabaLog, _iGrabaMsg, _sLlaveKEKIzquierda, _sLlaveKEKDerecha, _formato);
                        if (this._iGrabaMsg == 1)
                        {
                            UTILIDADES.mensaje("DEBUG : " + "Finaliza Posteo", "LogEvent", "log");
                        }
                        if (socket != null)
                        {
                            socket.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        sError += "\t" + ex.Message;
                        if (this._iGrabaMsg == 1)
                        {
                            UTILIDADES.mensaje("POS   : " + ex.Message, "LogEvent", "log");
                        }
                    }
                }
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("POS   : " + e.Message, "LogEvent", "log");
                }
                throw new Exception(sError);
            }
            try
            {
                socket.Close();
            }
            catch (Exception e)
            {
                sError += e.Message;
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("POS   : " + e.Message, "LogEvent", "log");
                }
            }
            try
            {
                new Posteo(_ip, _puerto, _timeoutPos, _iGrabaLog, _iGrabaMsg, _sLlaveKEKIzquierda, _sLlaveKEKDerecha, _formato);
            }
            catch (Exception e)
            {
                sError += e.Message;
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("POS   : " + e.Message, "LogEvent", "log");
                }
            }
            try
            {
                _respuesta = camposTramaPlano(isoMsgResp);
            }
            catch (Exception e)
            {
                sError += e.Message;
                if (this._iGrabaMsg == 1)
                {
                    UTILIDADES.mensaje("POS   : " + e.Message, "LogEvent", "log");
                }
            }
            if (this._iGrabaLog == 1)
            {
                UTILIDADES.mensaje("OUTPUT METODO: " + _respuesta, "LogTracer", "log");
            }
            if (_respuesta.Length > 0)
            {
                return(_respuesta);
            }
            return("");
        }
Exemplo n.º 3
0
        public void grabacion()
        {
            String sRuta = "";

            UTILIDADES.almacenarArchivo(sRuta, _NombreArchivo, _boAcumulativo, _sMensaje);
        }