//eh private void GetChannelsList(JObject m) { if (ServersList == null) { ServersList = new List <DiscordServer>(); } foreach (var j in m["d"]["guilds"]) { DiscordServer temp = new DiscordServer(); temp.id = j["id"].ToString(); temp.name = j["name"].ToString(); temp.owner_id = j["owner_id"].ToString(); List <DiscordChannel> tempSubs = new List <DiscordChannel>(); foreach (var u in j["channels"]) { DiscordChannel tempSub = new DiscordChannel(); tempSub.id = u["id"].ToString(); tempSub.name = u["name"].ToString(); tempSub.type = u["type"].ToString(); tempSubs.Add(tempSub); } temp.channels = tempSubs; foreach (var mm in j["members"]) { DiscordMember member = new DiscordMember(); member.user.id = mm["user"]["id"].ToString(); member.user.username = mm["user"]["username"].ToString(); temp.members.Add(member); } ServersList.Add(temp); } }
/// <summary> /// Read the server from the table of the Servers info. /// </summary> /// <param name="objServerData">Server info DataRow</param> private void LoadServerToList(DataRow objServerData) { Server objNewServer = new Server(); if (!(objServerData["ServerName"] is System.DBNull)) { objNewServer.ServerName = objServerData["ServerName"].ToString(); } if (!(objServerData["InstanceName"] is System.DBNull)) { objNewServer.InstanceName = objServerData["InstanceName"].ToString(); } if (!(objServerData["IsClustered"] is System.DBNull)) { objNewServer.IsClustered = objServerData["IsClustered"].ToString(); } if (!(objServerData["Version"] is System.DBNull)) { objNewServer.Version = objServerData["Version"].ToString(); } ServersList.Add(objNewServer); }
public void NewServer_Click(object sender, RoutedEventArgs e) { MainWindow wnd = sender as MainWindow; Views.NewServerView view = new Views.NewServerView(); view.Owner = wnd; if (view.ShowDialog() == true) { string ip = view.iptext.Text.Trim().ToString(); if (ip == "127.0.0.1") { ip = "0.0.0.0"; } int port = int.Parse(view.porttext.Text.Trim().ToString()); ServersInfo ser = new ServersInfo(); ser.IPAddr = IPAddress.Parse(ip); ser.Port = port; ser.IpEndPort = new IPEndPoint(ser.IPAddr, ser.Port); if (ServersList.Count != 0) { int temp = ServersList.ToList <ServersInfo>().FindIndex(ex => ex.IpEndPort.ToString() == ser.IpEndPort.ToString()); if (temp != -1) { MessageBox.Show("该服务器已添加"); return; } } ser.TcpServer = new AsyncTCPServer(ser.IPAddr, ser.Port); ser.TcpServer.ClientConnected += TcpServer_ClientConnected; ser.TcpServer.ClientDisconnected += TcpServer_ClientDisconnected; ser.TcpServer.DataReceived += TcpServer_DataReceived; ServersList.Add(ser); SelectServer = ServersList[ServersList.Count - 1]; } }
/// <summary> /// Adds the new server. /// </summary> /// <param name="server">The server.</param> public void AddNewServer(FrameworkServer server) { _context.FrameworkServers.Add(server); ServersList.Add(server); }