Esempio n. 1
0
        private void ReadDefinition(ref ISOMessageFieldsPackager msgFieldPackager, XmlReader reader)
        {
            ISOMessageTypesPackager isoMessageTypesPackager = null;
            string headerPackager = null;

            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    switch (reader.Name)
                    {
                    case "isopackager":
                        string attribute = reader["totalfields"];
                        m_totalFields  = Int32.Parse(attribute);
                        m_totalFields += 1;
                        headerPackager = reader["headerpackager"];
                        break;

                    case "messages":
                        isoMessageTypesPackager = LoadMessageTypes(reader);
                        break;

                    case "isofields":
                        msgFieldPackager = LoadISOMessageFieldsPackager(reader, 0);
                        msgFieldPackager.HeaderPackager = headerPackager;
                        msgFieldPackager.SetMessageTypesPackager(isoMessageTypesPackager);
                        msgFieldPackager.SetStorageClass(Type.GetType("ISO8583Net.Field.ISOMessageFields"));
                        break;
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="fileName"></param>
        /// <param name="msgFieldPackager"></param>
        public ISOPackagerLoader(ILogger logger, string fileName, ref ISOMessageFieldsPackager msgFieldPackager)
        {
            _logger = logger;

            XmlReader reader = null;

            ISOMessageTypesPackager isoMessageTypesPackager = null;

            if (File.Exists(fileName))
            {
                if (Logger.IsEnabled(LogLevel.Trace))
                {
                    Logger.LogTrace("Loading packager definition from [" + fileName + "]");
                }

                reader = XmlReader.Create(fileName);
            }
            else
            {
                Logger.LogError(string.Format("Filename [{0}] does not exist", fileName));

                throw new Exception(string.Format("Filename[{0}] does not exist", fileName));
            }

            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    switch (reader.Name)
                    {
                    case "isopackager":
                        string attribute = reader["totalfields"];
                        m_totalFields  = Int32.Parse(attribute);
                        m_totalFields += 1;
                        break;

                    case "messages":
                        isoMessageTypesPackager = new ISOMessageTypesPackager(Logger, m_totalFields);
                        isoMessageTypesPackager = LoadMessageTypes(reader);
                        break;

                    case "isofields":
                        msgFieldPackager = LoadISOMessageFieldsPackager(reader, 0);
                        msgFieldPackager.SetMessageTypesPackager(isoMessageTypesPackager);
                        msgFieldPackager.SetStorageClass(Type.GetType("ISO8583Net.ISOMessageFields"));
                        break;
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="msgFieldPackager"></param>
        public ISOPackagerLoader(ILogger logger, ref ISOMessageFieldsPackager msgFieldPackager)
        {
            _logger = logger;
            if (_logger.IsEnabled(LogLevel.Trace))
            {
                _logger.LogTrace("Loading packager definition from build-in resource");
            }

            // load from embeded resource visa.xml

            Stream stream = typeof(ISOPackagerLoader).GetTypeInfo().Assembly.GetManifestResourceStream("ISO8583Net.ISODialects.visa.xml");

            var reader = XmlReader.Create(stream);

            ReadDefinition(ref msgFieldPackager, reader);
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="msgFieldPackager"></param>
        public ISOPackagerLoader(ILogger logger, ref ISOMessageFieldsPackager msgFieldPackager)
        {
            _logger = logger;

            XmlReader reader = null;

            ISOMessageTypesPackager isoMessageTypesPackager = null;

            if (Logger.IsEnabled(LogLevel.Trace))
            {
                Logger.LogTrace("Loading packager definition from build-in resource");
            }

            // load from embeded resource visa.xml

            Stream stream = typeof(ISOPackagerLoader).GetTypeInfo().Assembly.GetManifestResourceStream("ISO8583Net.ISODialects.visa.xml");

            reader = XmlReader.Create(stream);

            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    switch (reader.Name)
                    {
                    case "isopackager":
                        string attribute = reader["totalfields"];
                        m_totalFields  = Int32.Parse(attribute);
                        m_totalFields += 1;
                        break;

                    case "messages":
                        isoMessageTypesPackager = new ISOMessageTypesPackager(Logger, m_totalFields);
                        isoMessageTypesPackager = LoadMessageTypes(reader);
                        break;

                    case "isofields":
                        msgFieldPackager = LoadISOMessageFieldsPackager(reader, 0);
                        msgFieldPackager.SetMessageTypesPackager(isoMessageTypesPackager);
                        msgFieldPackager.SetStorageClass(Type.GetType("ISO8583Net.Field.ISOMessageFields"));
                        break;
                    }
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Create a new packager based on an embedded file or an actual file on disk
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="fileName">File name on disk, or embedded resource file name</param>
        /// <param name="msgFieldPackager"></param>
        public ISOPackagerLoader(ILogger logger, string fileName, ref ISOMessageFieldsPackager msgFieldPackager)
        {
            _logger = logger;

            XmlReader reader = null;

            try
            {
                var embeddedResource = typeof(ISOPackagerLoader).GetTypeInfo().Assembly.GetManifestResourceStream("ISO8583Net.ISODialects." + fileName);
                reader = XmlReader.Create(embeddedResource);
            }
            catch (Exception)
            {
                //Resource Not found try with a file
            }

            if (reader != null)
            {
                ReadDefinition(ref msgFieldPackager, reader);
            }
            else
            {
                if (File.Exists(fileName))
                {
                    if (_logger.IsEnabled(LogLevel.Trace))
                    {
                        _logger.LogTrace("Loading packager definition from [" + fileName + "]");
                    }

                    reader = XmlReader.Create(fileName);
                    ReadDefinition(ref msgFieldPackager, reader);
                }
                else
                {
                    _logger.LogError(string.Format("Filename [{0}] does not exist", fileName));

                    throw new Exception(string.Format("Filename[{0}] does not exist", fileName));
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="fieldNumber"></param>
        /// <returns></returns>
        private ISOMessageFieldsPackager LoadISOMessageFieldsPackager(XmlReader reader, int fieldNumber)
        {
            ISOMessageFieldsPackager msgFieldPackager = new ISOMessageFieldsPackager(_logger, fieldNumber, m_totalFields);

            if (reader.ReadToDescendant("isofield"))
            {
                do
                {
                    int fldNumber = int.Parse(reader["number"]);

                    string packager       = reader["packager"];
                    string storageclass   = reader["storageclass"];
                    string iscomposite    = reader["composite"];
                    string isointerpreter = reader["interpreter"];

                    if (_logger.IsEnabled(LogLevel.Trace))
                    {
                        _logger.LogTrace("Field Number: " + fldNumber.ToString().PadLeft(3, '0') + " Name: " + reader["name"] + " Description: " + reader["desc"]);
                    }

                    switch (packager)
                    {
                    case "ISOFieldBitmapSubFieldsPackager":

                        int totalFields = Int32.Parse(reader["totalfields"]);

                        totalFields += 1;

                        if (_logger.IsEnabled(LogLevel.Trace))
                        {
                            _logger.LogTrace("Field Number: " + fldNumber.ToString().PadLeft(3, '0') + " is of [[[<--ISOMessageFieldsPackager-->]]], SubFields follow:");
                        }

                        ISOFieldPackager fPackager = LoadISOFieldPackager(reader);

                        ISOFieldBitmapSubFieldsPackager newMsgFieldPackager = LoadISOMessageSubFieldsPackager(reader, fldNumber);

                        newMsgFieldPackager.SetISOFieldDefinition(fPackager.GetISOFieldDefinition());

                        newMsgFieldPackager.SetStorageClass(Type.GetType("ISO8583Net.Field.ISOFieldBitmapSubFields"));

                        msgFieldPackager.Add(newMsgFieldPackager, newMsgFieldPackager.GetFieldNumber());

                        newMsgFieldPackager.totalFields = totalFields;

                        break;

                    default:

                        ISOFieldPackager fieldPackager = LoadISOFieldPackager(reader);

                        if (storageclass == null)
                        {
                            fieldPackager.SetStorageClass(Type.GetType("ISO8583Net.Field.ISOField"));
                        }
                        else
                        {
                            fieldPackager.SetStorageClass(Type.GetType("ISO8583Net." + storageclass));
                        }

                        if (iscomposite == null || iscomposite == "N" || iscomposite == "n" || iscomposite == "No" || iscomposite == "no")
                        {
                            fieldPackager.SetComposite(false);
                        }
                        else
                        {
                            fieldPackager.SetComposite(true);
                        }

                        switch (isointerpreter)
                        {
                        //case "ISOEMVTagInterpreter":
                        //    fieldPackager.SetISOInterpreter(new ISOEMVTagInterpreter(Logger));
                        //    break;

                        case "ISOIndexedValueInterpreter":
                            ISOIndexedValueInterpreter isoIndexedValueInterpreter = LoadISOIndexedValueInterpreter(reader);
                            fieldPackager.SetISOInterpreter(isoIndexedValueInterpreter);
                            break;
                        }

                        msgFieldPackager.Add(fieldPackager, fieldPackager.GetFieldNumber());

                        break;
                    }
                } while (reader.ReadToNextSibling("isofield"));
            }
            return(msgFieldPackager);
        }