/// <summary> /// 获取历史数据 /// </summary> /// <param name="dataInfo"></param> /// <param name="datas"></param> /// <param name="body"></param> /// <param name="bodyLength"></param> /// <returns></returns> public static int GetHistoryDatas(ref HistoryDataInfo dataInfo, List <SecurityData> datas, byte[] body, int bodyLength) { Binary binary = new Binary(); binary.Write(body, bodyLength); dataInfo.m_securityCode = binary.ReadString(); dataInfo.m_type = binary.ReadChar(); dataInfo.m_size = binary.ReadInt(); dataInfo.m_cycle = binary.ReadInt(); dataInfo.m_subscription = binary.ReadInt(); dataInfo.m_startDate = binary.ReadDouble(); dataInfo.m_endDate = binary.ReadDouble(); dataInfo.m_pushData = binary.ReadBool(); int size = dataInfo.m_size; for (int i = 0; i < size; i++) { SecurityData item = new SecurityData(); item.m_date = binary.ReadDouble(); item.m_close = binary.ReadFloat(); item.m_high = binary.ReadFloat(); item.m_low = binary.ReadFloat(); item.m_open = binary.ReadFloat(); item.m_volume = binary.ReadDouble(); item.m_amount = binary.ReadDouble(); if (dataInfo.m_cycle == 0) { item.m_avgPrice = binary.ReadFloat(); } datas.Add(item); } binary.Close(); return(1); }
/// <summary> /// 获取表格 /// </summary> /// <param name="bytes">流</param> /// <param name="native">方法库</param> /// <returns>表格</returns> public GridA GetGrid(byte[] bytes, INativeBase native) { Binary br = new Binary(); br.Write(bytes, bytes.Length); GridA grid = new GridA(); grid.Native = native; grid.Name = br.ReadString(); int columnsSize = br.ReadInt(); for (int i = 0; i < columnsSize; i++) { GridColumn column = new GridColumn(); column.Name = br.ReadString(); column.ColumnType = br.ReadString(); grid.AddColumn(column); } grid.Update(); List <GridColumn> columns = grid.GetColumns(); int rowsCount = br.ReadInt(); for (int i = 0; i < rowsCount; i++) { GridRow row = new GridRow(); grid.AddRow(row); for (int j = 0; j < columnsSize; j++) { GridColumn column = columns[j]; string columnType = column.ColumnType.ToLower(); GridCell cell = null; if (columnType == "bool") { cell = new GridBoolCell(); row.AddCell(j, cell); cell.SetBool(br.ReadBool()); } else if (columnType == "double") { cell = new GridDoubleCell(); row.AddCell(j, cell); cell.SetDouble(br.ReadDouble()); } else if (columnType == "float") { cell = new GridFloatCell(); row.AddCell(j, cell); cell.SetFloat(br.ReadFloat()); } else if (columnType == "int") { cell = new GridIntCell(); row.AddCell(j, cell); cell.SetInt(br.ReadInt()); } else if (columnType == "long") { cell = new GridLongCell(); row.AddCell(j, cell); cell.SetLong((long)br.ReadDouble()); } else if (columnType == "string") { cell = new GridStringCell(); row.AddCell(j, cell); cell.SetString(br.ReadString()); } else { cell = new GridStringCell(); row.AddCell(j, cell); cell.SetString(br.ReadString()); } } } br.Close(); return(grid); }