Esempio n. 1
0
        private void BtnParseClick(object sender, EventArgs e)
        {
            // прочитать словари
            var doc = new XmlDocument();

            doc.Load(Dictionary.DicPath);
            var dicTag = FixTag.ReadTags(doc.DocumentElement.GetElementsByTagName(FixTag.PARENT_TAG)[0]);
            var dicMsg = FixTag.ReadTags(doc.DocumentElement.GetElementsByTagName(FixTag.PARENT_MSG)[0]);

            // разбить сообщение по парам тэг-значение
            var fields         = new List <FIXField>();
            var msg            = tbMsg.Text;
            var optSeparatChar = !string.IsNullOrEmpty(tbSeparator.Text) ? tbSeparator.Text[0] : (char)1;
            var pairs          = msg.Split(new[] { (char)0, optSeparatChar });

            var msgType = "";

            foreach (var pair in pairs)
            {
                var keyval = pair.Split('=');
                if (keyval.Length != 2)
                {
                    continue;
                }

                var field = new FIXField {
                    Tag = keyval[0], Value = keyval[1]
                };
                if (dicTag.ContainsKey(keyval[0]))
                {
                    var tag = dicTag[keyval[0]];
                    field.Title       = tag.Title;
                    field.Description = tag.Description;
                    field.URL         = tag.URL;
                }
                fields.Add(field);

                if (keyval[0] == "35")
                {
                    msgType = keyval[1];
                }
            }

            if (dicMsg.ContainsKey(msgType))
            {
                var msgInfo = dicMsg[msgType];
                var field   = new FIXField
                {
                    Tag         = "ТИП",
                    Title       = msgInfo.Title,
                    URL         = msgInfo.URL,
                    Description = msgInfo.Description,
                    Value       = msgType
                };
                fields.Add(field);
            }

            gridMessage.DataSource = fields;
        }
Esempio n. 2
0
        private void BtnParseClick(object sender, EventArgs e)
        {
            // прочитать словари
            var doc = new XmlDocument();
            doc.Load(Dictionary.DicPath);
            var dicTag = FixTag.ReadTags(doc.DocumentElement.GetElementsByTagName(FixTag.PARENT_TAG)[0]);
            var dicMsg = FixTag.ReadTags(doc.DocumentElement.GetElementsByTagName(FixTag.PARENT_MSG)[0]);

            // разбить сообщение по парам тэг-значение
            var fields = new List<FIXField>();
            var msg = tbMsg.Text;
            var optSeparatChar = !string.IsNullOrEmpty(tbSeparator.Text) ? tbSeparator.Text[0] : (char) 1;
            var pairs = msg.Split(new[] { (char)0, optSeparatChar });

            var msgType = "";
            foreach (var pair in pairs)
            {
                var keyval = pair.Split('=');
                if (keyval.Length != 2) continue;

                var field = new FIXField {Tag = keyval[0], Value = keyval[1]};
                if (dicTag.ContainsKey(keyval[0]))
                {
                    var tag = dicTag[keyval[0]];
                    field.Title = tag.Title;
                    field.Description = tag.Description;
                    field.URL = tag.URL;
                }
                fields.Add(field);

                if (keyval[0] == "35") msgType = keyval[1];
            }

            if (dicMsg.ContainsKey(msgType))
            {
                var msgInfo = dicMsg[msgType];
                var field = new FIXField
                                {
                                    Tag = "ТИП",
                                    Title = msgInfo.Title,
                                    URL = msgInfo.URL,
                                    Description = msgInfo.Description,
                                    Value = msgType
                                };
                fields.Add(field);
            }

            gridMessage.DataSource = fields;
        }