예제 #1
0
        public static XQt1902OutBlock FromQuery(XQt1902 query)
        {
            XQt1902OutBlock block = new XQt1902OutBlock();

            block.IsValidData   = true;
            block.InvalidReason = "";
            if (query.QueryResult != null && query.QueryResult.IsSystemError == true)
            {
                block.IsValidData   = false;
                block.InvalidReason = query.ReceiveMessage;
                return(block);
            }
            try
            {
                block.time   = query.GetFieldData(block.GetBlockName(), "time", 0).TrimEnd('?');               // char 6
                block.hname  = query.GetFieldData(block.GetBlockName(), "hname", 0).TrimEnd('?');              // char 20
                block.upname = query.GetFieldData(block.GetBlockName(), "upname", 0).TrimEnd('?');             // char 20
            } catch (InvalidDataFormatException e) {
                block.IsValidData   = false;
                block.InvalidReason = $"FieldName == {e.DataFieldName}, FieldData == \"{e.DataValue}\"";
            }
            return(block);
        }
예제 #2
0
        public static XQt1902OutBlock1[] ListFromQuery(XQt1902 query)
        {
            int count = query.GetBlockCount(XQt1902OutBlock1.BlockName);
            List <XQt1902OutBlock1> list = new List <XQt1902OutBlock1>();

            if (query.QueryResult != null && query.QueryResult.IsSystemError == true)
            {
                return(list.ToArray());
            }
            for (int i = 0; i < count; i++)
            {
                XQt1902OutBlock1 block = new XQt1902OutBlock1();
                block.IsValidData   = true;
                block.InvalidReason = "";
                try
                {
                    block.time      = query.GetFieldData(block.GetBlockName(), "time", i).TrimEnd('?');                 // char 8
                    block.price     = query.GetFieldData(block.GetBlockName(), "price", i).ParseLong("price");          // long 8
                    block.sign      = query.GetFieldData(block.GetBlockName(), "sign", i).FirstOrDefault();             // char 1
                    block.change    = query.GetFieldData(block.GetBlockName(), "change", i).ParseLong("change");        // long 8
                    block.volume    = query.GetFieldData(block.GetBlockName(), "volume", i).ParseFloat("volume");       // float 12
                    block.navdiff   = query.GetFieldData(block.GetBlockName(), "navdiff", i).ParseFloat("navdiff");     // float 9.2
                    block.nav       = query.GetFieldData(block.GetBlockName(), "nav", i).ParseFloat("nav");             // float 9.2
                    block.navchange = query.GetFieldData(block.GetBlockName(), "navchange", i).ParseFloat("navchange"); // float 9.2
                    block.crate     = query.GetFieldData(block.GetBlockName(), "crate", i).ParseFloat("crate");         // float 9.2
                    block.grate     = query.GetFieldData(block.GetBlockName(), "grate", i).ParseFloat("grate");         // float 9.2
                    block.jisu      = query.GetFieldData(block.GetBlockName(), "jisu", i).ParseFloat("jisu");           // float 8.2
                    block.jichange  = query.GetFieldData(block.GetBlockName(), "jichange", i).ParseFloat("jichange");   // float 8.2
                    block.jirate    = query.GetFieldData(block.GetBlockName(), "jirate", i).ParseFloat("jirate");       // float 8.2
                } catch (InvalidDataFormatException e) {
                    block.IsValidData   = false;
                    block.InvalidReason = $"FieldName == {e.DataFieldName}, FieldData == \"{e.DataValue}\"";
                }
                list.Add(block);
            }
            return(list.ToArray());
        }