예제 #1
0
        public IClientToPuppet ConnectToClient(int clientNumber)
        {
            String hostname;
            int    port;

            if (!_core.AppManager.GetProcessIPandPort(ProcessType.Client, clientNumber, false, out hostname, out port))
            {
                throw new CommandException("Can not get client IP and port. Client: " + clientNumber);
            }

            IClientToPuppet server = null;

            try
            {
                server = (IClientToPuppet)Activator.GetObject(
                    typeof(IClientToPuppet), "tcp://" + hostname + ":" + port + "/PADIConnection");

                //_core.DisplayMessage("Connected to Client: " + clientNumber);
                return(server);
            }
            catch (SocketException e)
            {
                throw new CommandException("Error connecting to Client" + e.Message);
            }
            catch (RemotingException e)
            {
                throw new CommandException("Error connecting to Client" + e.Message);
            }
        }
예제 #2
0
 private String ExeScript(IClientToPuppet server, String[] words, String fullCommand)
 {
     if (words.Length < 3)
     {
         throw new CommandException("ClientProxy: ExeScript: Invalid number of arguments " + fullCommand);
     }
     try
     {
         String filename = words[2];
         //Read file
         Queue <String> commands           = _core.ReadFileName(words[2]);
         DelExeScript   remoteDelExeScript = new DelExeScript(server.ExeScript);
         AsyncCallback  remoteCallBack     = new AsyncCallback(CBExeScript);
         remoteDelExeScript.BeginInvoke(commands, remoteCallBack, null);
     }
     catch (InvalidCastException ex)
     {
         throw new CommandException("ClientProxy: ExeScript: Invalid arguments " + fullCommand + "Error: " + ex.Message);
     }
     return("Running execScript on Client");
 }