public static XLogPack getTranxData(File xlogDir, StyledText header, int serverId) { String xlogPath = xlogDir.getAbsolutePath() + "/" + xLogFileName; File xlogFile = new File(xlogPath); if (!xlogFile.canRead()) { return null; } byte[] xlogb = new byte[(int) xlogFile.length()]; try { FileInputStream xlogInputStream = new FileInputStream(xlogFile); xlogInputStream.read(xlogb); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } DataInputX inX = new DataInputX(xlogb); XLogPack p = null; try { p = (XLogPack) inX.readPack(); } catch (IOException e) { e.printStackTrace(); } String date = DateUtil.yyyymmdd(p.endTime); if (p != null) { ProfileTextFull.buildXLogData(date, header, p, serverId); } return p; }
@ServiceHandler(RequestCmd.REMOTE_CONTROL) public void remoteControl(DataInputX din, DataOutputX dout, boolean login) throws IOException { MapPack param = (MapPack) din.readPack(); long session = param.getLong("toSession"); RemoteControl control = new RemoteControl( // param.getText("command"), // System.currentTimeMillis(), // param, param.getLong("fromSession")); boolean result = RemoteControlManager.add(session, control); Logger.println( "[" + RequestCmd.REMOTE_CONTROL + "]" + control.commnad() + " from " + LoginManager.getUser(control.commander()).ip() + " to " + LoginManager.getUser(session).ip() + " " + result); MapPack m = new MapPack(); if (result) { m.put("success", new BooleanValue(true)); dout.writeByte(TcpFlag.HasNEXT); dout.writePack(m); } else { m.put("success", new BooleanValue(false)); dout.writeByte(TcpFlag.HasNEXT); dout.writePack(m); } }
@ServiceHandler(RequestCmd.CHECK_JOB) public void checkJob(DataInputX din, DataOutputX dout, boolean login) throws IOException { MapPack param = (MapPack) din.readPack(); long session = param.getLong("session"); RemoteControl control = RemoteControlManager.getCommand(session); if (control != null) { TextPack t = new TextPack(); t.text = control.commnad(); dout.writeByte(TcpFlag.HasNEXT); dout.writePack(t); dout.writeByte(TcpFlag.HasNEXT); dout.writePack(control.param()); } }
@ServiceHandler(RequestCmd.SERVER_DB_DELETE) public void deleteDbFiles(DataInputX din, DataOutputX dout, boolean login) throws IOException { String rootPath = DBCtr.getRootPath(); MapPack param = (MapPack) din.readPack(); ListValue fileLv = param.getList("file"); MapPack m = new MapPack(); if (fileLv != null) { for (int i = 0; i < fileLv.size(); i++) { String filename = fileLv.getString(i); File file = new File(rootPath + filename); deleteFiles(file); } m.put("size", fileLv.size()); } dout.writeByte(TcpFlag.HasNEXT); dout.writePack(m); dout.flush(); }
@ServiceHandler(RequestCmd.REMOTE_CONTROL_ALL) public void remoteControlAll(DataInputX din, DataOutputX dout, boolean login) throws IOException { MapPack param = (MapPack) din.readPack(); RemoteControl control = new RemoteControl( // param.getText("command"), // System.currentTimeMillis(), // param, param.getLong("fromSession")); LoginUser[] users = LoginManager.getLoginUserList(); for (int i = 0, len = (users != null ? users.length : 0); i < len; i++) { long session = users[i].session(); RemoteControlManager.add(session, control); } Logger.println( "[" + RequestCmd.REMOTE_CONTROL_ALL + "]" + control.commnad() + " from " + LoginManager.getUser(control.commander()).ip()); }