예제 #1
0
파일: t1927.cs 프로젝트: iPeterPan/XingAPI
        public static XQt1927OutBlock FromQuery(XQt1927 query)
        {
            XQt1927OutBlock block = new XQt1927OutBlock();

            block.IsValidData   = true;
            block.InvalidReason = "";
            if (query.QueryResult != null && query.QueryResult.IsSystemError == true)
            {
                block.IsValidData   = false;
                block.InvalidReason = query.ReceiveMessage;
                return(block);
            }
            try
            {
                block.date = query.GetFieldData(block.GetBlockName(), "date", 0).TrimEnd('?');                 // char 8
            } catch (InvalidDataFormatException e) {
                block.IsValidData   = false;
                block.InvalidReason = $"FieldName == {e.DataFieldName}, FieldData == \"{e.DataValue}\"";
            }
            return(block);
        }
예제 #2
0
파일: t1927.cs 프로젝트: iPeterPan/XingAPI
        public static XQt1927OutBlock1[] ListFromQuery(XQt1927 query)
        {
            int count = query.GetBlockCount(XQt1927OutBlock1.BlockName);
            List <XQt1927OutBlock1> list = new List <XQt1927OutBlock1>();

            if (query.QueryResult != null && query.QueryResult.IsSystemError == true)
            {
                return(list.ToArray());
            }
            for (int i = 0; i < count; i++)
            {
                XQt1927OutBlock1 block = new XQt1927OutBlock1();
                block.IsValidData   = true;
                block.InvalidReason = "";
                try
                {
                    block.date      = query.GetFieldData(block.GetBlockName(), "date", 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.diff      = query.GetFieldData(block.GetBlockName(), "diff", i).ParseFloat("diff");          // float 6.2
                    block.volume    = query.GetFieldData(block.GetBlockName(), "volume", i).ParseLong("volume");       // long 12
                    block.value     = query.GetFieldData(block.GetBlockName(), "value", i).ParseLong("value");         // long 12
                    block.gm_vo     = query.GetFieldData(block.GetBlockName(), "gm_vo", i).ParseLong("gm_vo");         // long 12
                    block.gm_va     = query.GetFieldData(block.GetBlockName(), "gm_va", i).ParseLong("gm_va");         // long 12
                    block.gm_per    = query.GetFieldData(block.GetBlockName(), "gm_per", i).ParseFloat("gm_per");      // float 6.2
                    block.gm_avg    = query.GetFieldData(block.GetBlockName(), "gm_avg", i).ParseLong("gm_avg");       // long 12
                    block.gm_vo_sum = query.GetFieldData(block.GetBlockName(), "gm_vo_sum", i).ParseLong("gm_vo_sum"); // long 12
                } catch (InvalidDataFormatException e) {
                    block.IsValidData   = false;
                    block.InvalidReason = $"FieldName == {e.DataFieldName}, FieldData == \"{e.DataValue}\"";
                }
                list.Add(block);
            }
            return(list.ToArray());
        }