public static XQt2830OutBlock FromQuery(XQt2830 query) { XQt2830OutBlock block = new XQt2830OutBlock(); block.IsValidData = true; block.InvalidReason = ""; if (query.QueryResult != null && query.QueryResult.IsSystemError == true) { block.IsValidData = false; block.InvalidReason = query.ReceiveMessage; return(block); } try { block.hname = query.GetFieldData(block.GetBlockName(), "hname", 0).TrimEnd('?'); // char 20 block.price = query.GetFieldData(block.GetBlockName(), "price", 0).ParseFloat("price"); // float 6.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.jnilclose = query.GetFieldData(block.GetBlockName(), "jnilclose", 0).ParseFloat("jnilclose"); // float 6.2 block.diff = query.GetFieldData(block.GetBlockName(), "diff", 0).ParseFloat("diff"); // float 6.2 block.volume = query.GetFieldData(block.GetBlockName(), "volume", 0).ParseLong("volume"); // long 12 block.value = query.GetFieldData(block.GetBlockName(), "value", 0).ParseLong("value"); // long 12 block.open = query.GetFieldData(block.GetBlockName(), "open", 0).ParseFloat("open"); // float 6.2 block.high = query.GetFieldData(block.GetBlockName(), "high", 0).ParseFloat("high"); // float 6.2 block.low = query.GetFieldData(block.GetBlockName(), "low", 0).ParseFloat("low"); // float 6.2 block.recprice = query.GetFieldData(block.GetBlockName(), "recprice", 0).ParseFloat("recprice"); // float 6.2 block.theoryprice = query.GetFieldData(block.GetBlockName(), "theoryprice", 0).ParseFloat("theoryprice"); // float 6.2 block.actprice = query.GetFieldData(block.GetBlockName(), "actprice", 0).ParseFloat("actprice"); // float 6.2 block.impv = query.GetFieldData(block.GetBlockName(), "impv", 0).ParseFloat("impv"); // float 6.2 block.timevl = query.GetFieldData(block.GetBlockName(), "timevl", 0).ParseFloat("timevl"); // float 6.2 block.kospijisu = query.GetFieldData(block.GetBlockName(), "kospijisu", 0).ParseFloat("kospijisu"); // float 6.2 block.kospisign = query.GetFieldData(block.GetBlockName(), "kospisign", 0).FirstOrDefault(); // char 1 block.kospichange = query.GetFieldData(block.GetBlockName(), "kospichange", 0).ParseFloat("kospichange"); // float 6.2 block.kospidiff = query.GetFieldData(block.GetBlockName(), "kospidiff", 0).ParseFloat("kospidiff"); // float 6.2 block.cmeprice = query.GetFieldData(block.GetBlockName(), "cmeprice", 0).ParseFloat("cmeprice"); // float 6.2 block.cmesign = query.GetFieldData(block.GetBlockName(), "cmesign", 0).FirstOrDefault(); // char 1 block.cmechange = query.GetFieldData(block.GetBlockName(), "cmechange", 0).ParseFloat("cmechange"); // float 6.2 block.cmediff = query.GetFieldData(block.GetBlockName(), "cmediff", 0).ParseFloat("cmediff"); // float 6.2 block.cmefocode = query.GetFieldData(block.GetBlockName(), "cmefocode", 0).TrimEnd('?'); // char 8 block.uplmtprice = query.GetFieldData(block.GetBlockName(), "uplmtprice", 0).ParseFloat("uplmtprice"); // float 6.2 block.dnlmtprice = query.GetFieldData(block.GetBlockName(), "dnlmtprice", 0).ParseFloat("dnlmtprice"); // float 6.2 block.focode = query.GetFieldData(block.GetBlockName(), "focode", 0).TrimEnd('?'); // char 8 block.yeprice = query.GetFieldData(block.GetBlockName(), "yeprice", 0).ParseFloat("yeprice"); // float 6.2 block.ysign = query.GetFieldData(block.GetBlockName(), "ysign", 0).FirstOrDefault(); // char 1 block.ychange = query.GetFieldData(block.GetBlockName(), "ychange", 0).ParseFloat("ychange"); // float 6.2 block.ydiff = query.GetFieldData(block.GetBlockName(), "ydiff", 0).ParseFloat("ydiff"); // float 6.2 block.danhochk = query.GetFieldData(block.GetBlockName(), "danhochk", 0).FirstOrDefault(); // char 1 block.jnilvolume = query.GetFieldData(block.GetBlockName(), "jnilvolume", 0).ParseLong("jnilvolume"); // long 12 block.jnilvalue = query.GetFieldData(block.GetBlockName(), "jnilvalue", 0).ParseLong("jnilvalue"); // long 12 } catch (InvalidDataFormatException e) { block.IsValidData = false; block.InvalidReason = $"FieldName == {e.DataFieldName}, FieldData == \"{e.DataValue}\""; } return(block); }
public static XQt2830OutBlock ReadFromDB(string tableNamePostfix = null /*, string focode = default */) { using (XQt2830 instance = new XQt2830()) { string tableName = (tableNamePostfix == null) ? "XQt2830OutBlock" : $"XQt2830OutBlock_{tableNamePostfix}"; QueryOption qo = new QueryOption(tableName); // if (focode != default) qo.Add("focode", focode); var outBlock = instance.Select <XQt2830OutBlock>(qo); return(outBlock); } }
public static XQt2830OutBlock Get(string focode = default) { using (XQt2830 instance = new XQt2830()) { instance.SetFieldData(XQt2830InBlock.BlockName, XQt2830InBlock.F.focode, 0, focode); // char 8 if (instance.Request() < 0) { return(null); } var outBlock = instance.GetBlock(); if (outBlock.IsValidData == false) { return(null); } return(outBlock); } }