Ejemplo n.º 1
0
        public static XQt3518OutBlock FromQuery(XQt3518 query)
        {
            XQt3518OutBlock block = new XQt3518OutBlock();

            block.IsValidData   = true;
            block.InvalidReason = "";
            if (query.QueryResult != null && query.QueryResult.IsSystemError == true)
            {
                block.IsValidData   = false;
                block.InvalidReason = query.ReceiveMessage;
                return(block);
            }
            try
            {
                block.cts_date = query.GetFieldData(block.GetBlockName(), "cts_date", 0).TrimEnd('?');                 // char 8
                block.cts_time = query.GetFieldData(block.GetBlockName(), "cts_time", 0).TrimEnd('?');                 // char 6
            } catch (InvalidDataFormatException e) {
                block.IsValidData   = false;
                block.InvalidReason = $"FieldName == {e.DataFieldName}, FieldData == \"{e.DataValue}\"";
            }
            return(block);
        }
Ejemplo n.º 2
0
        public static XQt3518OutBlock1[] ListFromQuery(XQt3518 query)
        {
            int count = query.GetBlockCount(XQt3518OutBlock1.BlockName);
            List <XQt3518OutBlock1> list = new List <XQt3518OutBlock1>();

            if (query.QueryResult != null && query.QueryResult.IsSystemError == true)
            {
                return(list.ToArray());
            }
            for (int i = 0; i < count; i++)
            {
                XQt3518OutBlock1 block = new XQt3518OutBlock1();
                block.IsValidData   = true;
                block.InvalidReason = "";
                try
                {
                    block.date     = query.GetFieldData(block.GetBlockName(), "date", i).TrimEnd('?');                 // char 8
                    block.time     = query.GetFieldData(block.GetBlockName(), "time", i).TrimEnd('?');                 // char 8
                    block.open     = query.GetFieldData(block.GetBlockName(), "open", i).ParseDouble("open");          // double 9.4
                    block.high     = query.GetFieldData(block.GetBlockName(), "high", i).ParseDouble("high");          // double 9.4
                    block.low      = query.GetFieldData(block.GetBlockName(), "low", i).ParseDouble("low");            // double 9.4
                    block.price    = query.GetFieldData(block.GetBlockName(), "price", i).ParseDouble("price");        // double 9.4
                    block.sign     = query.GetFieldData(block.GetBlockName(), "sign", i).FirstOrDefault();             // char 1
                    block.change   = query.GetFieldData(block.GetBlockName(), "change", i).ParseDouble("change");      // double 9.4
                    block.uprate   = query.GetFieldData(block.GetBlockName(), "uprate", i).ParseDouble("uprate");      // double 9.4
                    block.volume   = query.GetFieldData(block.GetBlockName(), "volume", i).ParseDouble("volume");      // double 12.0
                    block.bidho    = query.GetFieldData(block.GetBlockName(), "bidho", i).ParseDouble("bidho");        // double 9.4
                    block.offerho  = query.GetFieldData(block.GetBlockName(), "offerho", i).ParseDouble("offerho");    // double 9.4
                    block.bidrem   = query.GetFieldData(block.GetBlockName(), "bidrem", i).ParseDouble("bidrem");      // double 12.0
                    block.offerrem = query.GetFieldData(block.GetBlockName(), "offerrem", i).ParseDouble("offerrem");  // double 12.0
                    block.kind     = query.GetFieldData(block.GetBlockName(), "kind", i).FirstOrDefault();             // char 1
                    block.symbol   = query.GetFieldData(block.GetBlockName(), "symbol", i).TrimEnd('?');               // char 16
                    block.exid     = query.GetFieldData(block.GetBlockName(), "exid", i).TrimEnd('?');                 // char 4
                    block.kodate   = query.GetFieldData(block.GetBlockName(), "kodate", i).TrimEnd('?');               // char 8
                    block.kotime   = query.GetFieldData(block.GetBlockName(), "kotime", i).TrimEnd('?');               // char 8
                } catch (InvalidDataFormatException e) {
                    block.IsValidData   = false;
                    block.InvalidReason = $"FieldName == {e.DataFieldName}, FieldData == \"{e.DataValue}\"";
                }
                list.Add(block);
            }
            return(list.ToArray());
        }