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); }
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; }
public void addProcessListener(ProcessListener pl) { if (!listeners.Contains(pl)) { listeners.Add(pl); } }
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); } } }
public void OnSwitch(IPlayerWeaponProcessor controller, int weaponId, EInOrOff op) { ProcessListener.OnSwitch(controller, weaponId, op); }
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); }
public void Listener_OnExpend(EWeaponSlotType slot) { ProcessListener.OnExpend(entity, slot); }
public void Listener_Drop(EWeaponSlotType slot) { ProcessListener.OnDrop(entity, slot); }
public void Listener_Pickup(EWeaponSlotType slot) { ProcessListener.OnPickup(entity, slot); }
public void OnDrop(IPlayerWeaponProcessor controller, EWeaponSlotType slot, EntityKey dropedWeapon) { ProcessListener.OnDrop(controller, slot, dropedWeapon); }
public void OnExpend(IPlayerWeaponProcessor controller, EWeaponSlotType slot) { ProcessListener.OnExpend(controller, slot); }
public void removeProcessListener(ProcessListener pl) { listeners.Remove(pl); }