/// <summary> /// 获取预测的成交量 /// </summary> /// <param name="datas"></param> /// <param name="body"></param> /// <param name="bodyLength"></param> /// <returns></returns> public static int GetVolumeForecastData(List <VolumeForecastData> datas, byte[] body, int bodyLength) { Binary binary = new Binary(); binary.Write(body, bodyLength); int num = binary.ReadInt(); for (int i = 0; i < num; i++) { VolumeForecastData item = new VolumeForecastData(); item.m_securityCode = binary.ReadString(); item.m_rate = binary.ReadDouble(); datas.Add(item); } binary.Close(); return(1); }
/// <summary> /// 获取弹幕信息 /// </summary> /// <param name="datas">用于返回弹幕信息</param> /// <param name="body">包体</param> /// <param name="bodyLength">包体长度</param> /// <returns></returns> public static int GetChatDatas(List <ChatData> datas, byte[] body, int bodyLength) { Binary br = new Binary(); br.Write(body, bodyLength); int size = br.ReadInt(); for (int i = 0; i < size; i++) { ChatData chat = new ChatData(); chat.m_userID = br.ReadInt(); chat.m_type = br.ReadChar(); chat.m_text = br.ReadString(); datas.Add(chat); } br.Close(); return(1); }
/// <summary> /// 获取交易数据 /// </summary> /// <param name="securityCode"></param> /// <param name="transactionDatas"></param> /// <param name="body"></param> /// <param name="bodyLength"></param> /// <returns></returns> public static int GetTransactionDatas(ref string securityCode, List <TransactionData> transactionDatas, byte[] body, int bodyLength) { Binary binary = new Binary(); binary.Write(body, bodyLength); securityCode = binary.ReadString(); int num = binary.ReadInt(); for (int i = 0; i < num; i++) { TransactionData item = new TransactionData(); item.m_date = binary.ReadDouble(); item.m_price = binary.ReadFloat(); item.m_volume = binary.ReadDouble(); item.m_type = binary.ReadChar(); transactionDatas.Add(item); } binary.Close(); return(1); }
/// <summary> /// 通过流获取用户会话 /// </summary> /// <param name="sessions">用户会话</param> /// <param name="body">包体</param> /// <param name="bodyLength">包体长度</param> public static int GetSessions(List <UserSession> sessions, byte[] body, int bodyLength) { Binary br = new Binary(); br.Write(body, bodyLength); int size = br.ReadInt(); if (size > 0) { for (int i = 0; i < size; i++) { UserSession session = new UserSession(); session.m_userID = br.ReadInt(); session.m_key = br.ReadString(); session.m_value = br.ReadString(); sessions.Add(session); } } br.Close(); return(1); }
/// <summary> /// 获取实时数据L2 /// </summary> /// <param name="dataInfo"></param> /// <param name="datas"></param> /// <param name="body"></param> /// <param name="bodyLength"></param> /// <returns></returns> public static int GetLatestDatasLV2(ref LatestDataInfoLV2 dataInfo, List <SecurityLatestDataLV2> datas, byte[] body, int bodyLength) { Binary binary = new Binary(); binary.Write(body, bodyLength); dataInfo.m_size = binary.ReadInt(); for (int i = 0; i < dataInfo.m_size; i++) { SecurityLatestDataLV2 item = new SecurityLatestDataLV2(); item.m_securityCode = binary.ReadString(); item.m_allBuyVol = binary.ReadDouble(); item.m_avgBuyPrice = binary.ReadFloat(); item.m_allSellVol = binary.ReadDouble(); item.m_avgSellPrice = binary.ReadFloat(); item.m_buyVolume6 = binary.ReadInt(); item.m_buyPrice6 = binary.ReadFloat(); item.m_buyVolume7 = binary.ReadInt(); item.m_buyPrice7 = binary.ReadFloat(); item.m_buyVolume8 = binary.ReadInt(); item.m_buyPrice8 = binary.ReadFloat(); item.m_buyVolume9 = binary.ReadInt(); item.m_buyPrice9 = binary.ReadFloat(); item.m_buyVolume10 = binary.ReadInt(); item.m_buyPrice10 = binary.ReadFloat(); item.m_sellVolume6 = binary.ReadInt(); item.m_sellPrice6 = binary.ReadFloat(); item.m_sellVolume7 = binary.ReadInt(); item.m_sellPrice7 = binary.ReadFloat(); item.m_sellVolume8 = binary.ReadInt(); item.m_sellPrice8 = binary.ReadFloat(); item.m_sellVolume9 = binary.ReadInt(); item.m_sellPrice9 = binary.ReadFloat(); item.m_sellVolume10 = binary.ReadInt(); item.m_sellPrice10 = binary.ReadFloat(); datas.Add(item); } binary.Close(); return(1); }
public static int GetCategories(List <UserSecurityCategory> categories, byte[] body, int bodyLength) { Binary binary = new Binary(); binary.Write(body, bodyLength); int num = binary.ReadInt(); if (num > 0) { for (int i = 0; i < num; i++) { UserSecurityCategory item = new UserSecurityCategory(); item.m_categoryID = binary.ReadString(); item.m_userID = binary.ReadInt(); item.m_name = binary.ReadString(); item.m_codes = binary.ReadString(); item.m_type = binary.ReadInt(); item.m_orderNum = binary.ReadInt(); categories.Add(item); } } binary.Close(); return(1); }
public static int GetLayouts(List <IndicatorLayout> layouts, byte[] body, int bodyLength) { Binary binary = new Binary(); binary.Write(body, bodyLength); int num = binary.ReadInt(); if (num > 0) { for (int i = 0; i < num; i++) { IndicatorLayout item = new IndicatorLayout(); item.m_layoutID = binary.ReadString(); item.m_userID = binary.ReadInt(); item.m_name = binary.ReadString(); item.m_text = binary.ReadString(); item.m_type = binary.ReadInt(); item.m_orderNum = binary.ReadInt(); layouts.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); }
/// <summary> /// 接收消息方法 /// </summary> /// <param name="message">消息</param> public override void OnReceive(CMessage message) { if (message.m_functionID == FUNCTIONID_USERSECURITY_GETVISITSCOUNT) { UserSecurityVisitsCount visitsCount = new UserSecurityVisitsCount(); Binary br = new Binary(); br.Write(message.m_body, message.m_bodyLength); visitsCount.m_userID = br.ReadInt(); visitsCount.CodesFromString(br.ReadString()); m_visitsCount = visitsCount.m_codes; br.Close(); } else { List <UserSecurityCategory> categories = new List <UserSecurityCategory>(); UserSecurityService.GetCategories(categories, message.m_body, message.m_bodyLength); int categoriesSize = categories.Count; if (message.m_functionID != FUNCTIONID_USERSECURITY_GETCATEGORIES) { message.m_requestID = m_operatorRequestID; } switch (message.m_functionID) { case FUNCTIONID_USERSECURITY_GETCATEGORIES: { m_categories = categories; m_loaded = true; break; } case FUNCTIONID_USERSECURITY_ADDCATEGORIES: { bool add = false; for (int i = 0; i < categoriesSize; i++) { UserSecurityCategory category = null; if (!GetCategory(categories[i].m_categoryID, ref category)) { m_categories.Add(categories[i]); add = true; } } if (!add) { return; } break; } case FUNCTIONID_USERSECURITY_DELETECATEGORIES: { for (int i = 0; i < categoriesSize; i++) { UserSecurityCategory category = null; if (GetCategory(categories[i].m_categoryID, ref category)) { m_categories.Remove(category); } } break; } case FUNCTIONID_USERSECURITY_UPDATECATEGORIES: { for (int i = 0; i < categoriesSize; i++) { UserSecurityCategory updateCategory = categories[i]; int curCategoriesSize = m_categories.Count; for (int j = 0; j < curCategoriesSize; j++) { UserSecurityCategory category = m_categories[j]; if (category.m_categoryID == updateCategory.m_categoryID) { m_categories[j] = updateCategory; break; } } } break; } case FUNCTIONID_USERSECURITY_ADDSECURITIES: { for (int i = 0; i < categoriesSize; i++) { UserSecurityCategory updateCategory = categories[i]; int curCategoriesSize = m_categories.Count; for (int j = 0; j < curCategoriesSize; j++) { UserSecurityCategory category = m_categories[j]; if (category.m_categoryID == updateCategory.m_categoryID) { if (category.m_codes != null && category.m_codes.Length > 0) { updateCategory.m_codes = m_categories[j].m_codes + "," + updateCategory.m_codes; } m_categories[j] = updateCategory; break; } } } break; } case FUNCTIONID_USERSECURITY_DELETESECURITIES: { for (int i = 0; i < categoriesSize; i++) { UserSecurityCategory updateCategory = categories[i]; int curCategoriesSize = m_categories.Count; for (int j = 0; j < curCategoriesSize; j++) { UserSecurityCategory category = m_categories[j]; if (category.m_categoryID == updateCategory.m_categoryID) { if (updateCategory.m_codes != null && updateCategory.m_codes.Length > 0 && category.m_codes != null && category.m_codes.Length > 0) { String[] deleteCodes = updateCategory.m_codes.Split(','); int deleteCodesSize = deleteCodes.Length; Dictionary <String, String> deleteCodesMap = new Dictionary <String, String>(); for (int m = 0; m < deleteCodesSize; m++) { deleteCodesMap[deleteCodes[m]] = ""; } String[] codes = category.m_codes.Split(','); int codesSize = codes.Length; String newCodes = ""; for (int m = 0; m < codesSize; m++) { if (!deleteCodesMap.ContainsKey(codes[m])) { newCodes += codes[m] + ","; } } if (newCodes != null && newCodes.Length > 0) { if (newCodes.Substring(newCodes.Length - 1) == ",") { newCodes = newCodes.Substring(0, newCodes.Length - 1); } } updateCategory.m_codes = newCodes; } m_categories[j] = updateCategory; break; } } } break; } } } base.OnReceive(message); }