Exemple #1
0
        public static XQt3521OutBlock FromQuery(XQt3521 query)
        {
            XQt3521OutBlock block = new XQt3521OutBlock();

            block.IsValidData   = true;
            block.InvalidReason = "";
            if (query.QueryResult != null && query.QueryResult.IsSystemError == true)
            {
                block.IsValidData   = false;
                block.InvalidReason = query.ReceiveMessage;
                return(block);
            }
            try
            {
                block.symbol = query.GetFieldData(block.GetBlockName(), "symbol", 0).TrimEnd('?');             // char 16
                block.hname  = query.GetFieldData(block.GetBlockName(), "hname", 0).TrimEnd('?');              // char 20
                block.close  = query.GetFieldData(block.GetBlockName(), "close", 0).ParseFloat("close");       // float 12.2
                block.sign   = query.GetFieldData(block.GetBlockName(), "sign", 0).FirstOrDefault();           // char 1
                block.change = query.GetFieldData(block.GetBlockName(), "change", 0).ParseFloat("change");     // float 6.2
                block.diff   = query.GetFieldData(block.GetBlockName(), "diff", 0).ParseFloat("diff");         // float 6.2
                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);
        }
Exemple #2
0
        public static XQt3521OutBlock ReadFromDB(string tableNamePostfix = null /*, char kind = default,string symbol = default */)
        {
            using (XQt3521 instance = new XQt3521())
            {
                string      tableName = (tableNamePostfix == null) ? "XQt3521OutBlock" : $"XQt3521OutBlock_{tableNamePostfix}";
                QueryOption qo        = new QueryOption(tableName);
                // if (kind != default) qo.Add("kind", kind);
                // if (symbol != default) qo.Add("symbol", symbol);


                var outBlock = instance.Select <XQt3521OutBlock>(qo);
                return(outBlock);
            }
        }
Exemple #3
0
        public static XQt3521OutBlock Get(char kind = default, string symbol = default)
        {
            using (XQt3521 instance = new XQt3521())
            {
                instance.SetFieldData(XQt3521InBlock.BlockName, XQt3521InBlock.F.kind, 0, kind.ToString());          // char 1
                instance.SetFieldData(XQt3521InBlock.BlockName, XQt3521InBlock.F.symbol, 0, symbol);                 // char 16

                if (instance.Request() < 0)
                {
                    return(null);
                }

                var outBlock = instance.GetBlock();
                if (outBlock.IsValidData == false)
                {
                    return(null);
                }
                return(outBlock);
            }
        }