Esempio n. 1
0
        public static ProcessExecutionResult ExecuteProcess(string workingDirectory, string filepath, string arguments)
        {
            ProcessExecutionResult result = new ProcessExecutionResult();
            Process process = new Process();

            process.StartInfo.FileName         = filepath;
            process.StartInfo.Arguments        = arguments;
            process.StartInfo.WorkingDirectory = workingDirectory;

            process.StartInfo.RedirectStandardError  = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.UseShellExecute        = false;



            StringBuilder   testLogOut = new StringBuilder();
            StringBuilder   testLogErr = new StringBuilder();
            ProcessListener listen     = new ProcessListener(process);

            listen.StdOutNewLineReady += ((obj) => testLogOut.AppendLine("stdout:" + obj));             // Log StdOut
            listen.StdErrNewLineReady += ((obj) => testLogErr.AppendLine("stderror:" + obj));           // Log StdError

            process.Start();
            listen.Begin();
            process.WaitForExit();

            result.StandardError  = testLogErr.ToString();
            result.StandardOutput = testLogOut.ToString();

            listen.Dispose();
            process.Dispose();

            return(result);
        }
Esempio n. 2
0
        public static ProcessExecutionResult ExecuteProcess(string workingDirectory, string filepath, string arguments)
        {
            ProcessExecutionResult result = new ProcessExecutionResult();
            Process process = new Process();
            process.StartInfo.FileName = filepath;
            process.StartInfo.Arguments = arguments;
            process.StartInfo.WorkingDirectory = workingDirectory;

            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.UseShellExecute = false;

            StringBuilder testLogOut = new StringBuilder();
            StringBuilder testLogErr = new StringBuilder();
            ProcessListener listen = new ProcessListener(process);
            listen.StdOutNewLineReady += ((obj) => testLogOut.AppendLine("stdout:" + obj)); // Log StdOut
            listen.StdErrNewLineReady += ((obj) => testLogErr.AppendLine("stderror:" + obj)); // Log StdError

            process.Start();
            listen.Begin();
            process.WaitForExit();

            result.StandardError = testLogErr.ToString();
            result.StandardOutput = testLogOut.ToString();

            listen.Dispose();
            process.Dispose();

            return result;
        }
Esempio n. 3
0
 public void addProcessListener(ProcessListener pl)
 {
     if (!listeners.Contains(pl))
     {
         listeners.Add(pl);
     }
 }
Esempio n. 4
0
        public void ProcessAcceptConnections()
        {
            Console.WriteLine("listening on port: " + ((IPEndPoint)(ProcessListener.Server.LocalEndPoint)).Port);
            while (true)
            {
                try
                {
                    var client = ProcessListener.AcceptTcpClient();
                    var buffer = new byte[1024];
                    client.Client.Receive(buffer);
                    Console.WriteLine("Client " + ((IPEndPoint)client.Client.RemoteEndPoint).Address + ": " + Encoding.ASCII.GetString(buffer));
                    var info = Encoding.ASCII.GetString(buffer);
                    info = info.Substring(0, info.LastIndexOf("||") + "||".Length);          //info format: [process name]|[pid]|[port + foregin ip tuples inside < >]||

                    SQL.Insert_ProcessInfo(info);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
Esempio n. 5
0
 public void OnSwitch(IPlayerWeaponProcessor controller, int weaponId, EInOrOff op)
 {
     ProcessListener.OnSwitch(controller, weaponId, op);
 }
Esempio n. 6
0
 public void SendPickup(IPlayerWeaponProcessor weaponProcessor, int entityId, int itemId, int category,
                        int count)
 {
     PickupHandler.SendPickup(weaponProcessor, entityId, itemId, category, count);
     ProcessListener.OnItemPickup(weaponProcessor, itemId, category, count);
 }
Esempio n. 7
0
 public void Listener_OnExpend(EWeaponSlotType slot)
 {
     ProcessListener.OnExpend(entity, slot);
 }
Esempio n. 8
0
 public void Listener_Drop(EWeaponSlotType slot)
 {
     ProcessListener.OnDrop(entity, slot);
 }
Esempio n. 9
0
 public void Listener_Pickup(EWeaponSlotType slot)
 {
     ProcessListener.OnPickup(entity, slot);
 }
Esempio n. 10
0
 public void OnDrop(IPlayerWeaponProcessor controller, EWeaponSlotType slot, EntityKey dropedWeapon)
 {
     ProcessListener.OnDrop(controller, slot, dropedWeapon);
 }
Esempio n. 11
0
 public void OnExpend(IPlayerWeaponProcessor controller, EWeaponSlotType slot)
 {
     ProcessListener.OnExpend(controller, slot);
 }
Esempio n. 12
0
 public void removeProcessListener(ProcessListener pl)
 {
     listeners.Remove(pl);
 }