private bool addServerData(ServerClass.serverUser server) { try { MessageClass mess = new MessageClass(); List <ServerClass.serverUser> allServerList = ServerClass.allServerList; for (int i = 0; i < allServerList.Count; i++) { string user = allServerList[i].user; if (server.user.Equals(user)) { List <ServerClass.serverComputer> nowUserList = allServerList[i].server; for (int ii = 0; ii < nowUserList.Count; ii++) { string name = server.server[0].name; //当前要控制的设备名称 if (name.Equals(nowUserList[ii].name)) { ServerClass.serverComputer temp = server.server[0]; //ServerClass.allServerList[i].server[ii].data = temp.data; //修改列表 if (nowUserList[ii].socket != null) { if (new BasicSocketClass().sendSocket(nowUserList[ii].socket, temp.data)) //客户端在线 //mess.writeLine(String.Format("Client user:{0} name:{1} shell:{2}", server.user, temp.name, temp.data)); { return(true); } else //客户端不在线 { mess.writeLine(String.Format("Server user:{0} name:{1} Leave", server.user, temp.name)); ServerClass.allServerList.Remove(allServerList[i]); //删除这条记录 mess.writeLine(String.Format("Client user:{0} name:{1} shell:{2},客户端已下线,指令取消", server.user, temp.name, temp.data)); return(false); } } return(false); } } mess.writeLog(String.Format("Client:该用户电脑未在线,Code:1,用户:{0},电脑:{1}", server.user, server.server[0].name)); return(false); //没有该设备 } } mess.writeLog(String.Format("Client:该用户电脑未在线,Code:2,用户:{0},电脑:{1}", server.user, server.server[0].name)); return(false); //没有该用户 } catch (Exception error) { new MessageClass().writeLog("Client::addServerData Error:" + error.Message); return(true); } }