public ChannelInfo[] GetAllChannels() { _db.Open(); List<ChannelInfo> channels = new List<ChannelInfo>(); DbDataReader reader = _db.ExcecuteReader(DbNames.GETALLCHANNELS_STOREDPROC, System.Data.CommandType.StoredProcedure, null); int ordinalId = reader.GetOrdinal(DbNames.CHANNELINFO_ID); int ordinalName = reader.GetOrdinal(DbNames.CHANNELINFO_NAME); int ordinalDesc = reader.GetOrdinal(DbNames.CHANNELINFO_DESC); int ordinalIP = reader.GetOrdinal(DbNames.CHANNELINFO_IP); int ordinalPort = reader.GetOrdinal(DbNames.CHANNELINFO_PORT); int ordinalPK = reader.GetOrdinal(DbNames.CHANNELINFO_PK); while (reader.Read()) { ChannelInfo channel = new ChannelInfo { ChannelId = reader.GetInt32(ordinalId), ChannelName = reader.GetString(ordinalName), ChannelDesc = reader.GetString(ordinalDesc), IPAddress = reader.GetString(ordinalIP), Port = reader.GetInt32(ordinalPort), PK = reader.GetBoolean(ordinalPK) }; channels.Add(channel); } reader.Close(); _db.Close(); return channels.ToArray(); }
/// <summary> /// Send channel to client /// </summary> /// <param name="CI">Channel Info, containing id, name, desc, ip address and port</param> /// <param name="TotalChannels"></param> /// <returns></returns> public static byte[] SendChannel(ChannelInfo CI, int TotalChannels) { Packet p = new Packet(500); p.WriteByte(TotalChannels); // total channels p.WriteByte(CI.ChannelId); // channel id p.WriteString(CI.ChannelName); // name p.WriteString(CI.ChannelDesc); // desc p.WriteHexString("12 F4 01"); p.WriteString(CI.IPAddress); // ip p.WriteShort(CI.Port); // port p.WriteHexString("00 00 00"); return p.GetWrittenBuffer(PacketIds.SendChannelList); }