Gestione cmp footer
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
// See https://aka.ms/new-console-template for more information
|
||||
using System.Diagnostics;
|
||||
using System.Net.Security;
|
||||
using System.Text;
|
||||
|
||||
int lineCount = 0;
|
||||
//StringBuilder output = new StringBuilder();
|
||||
|
||||
|
||||
void OutputHandler(object sender, DataReceivedEventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(e.Data))
|
||||
{
|
||||
Console.WriteLine($"RIPOSTA PROCESSO [{lineCount}] - {e.Data}");
|
||||
if (e.Data == "SUCCESS")
|
||||
{
|
||||
lineCount += 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var domanda = "Sai chi ti saluta tantissimo?";
|
||||
|
||||
Console.WriteLine(domanda);
|
||||
|
||||
// Create a new process object
|
||||
Process p = new Process();
|
||||
|
||||
// Specify the file name of the external exe
|
||||
p.StartInfo.FileName = @"C:\Temp\TestEcho.bat";
|
||||
p.StartInfo.UseShellExecute = false;
|
||||
p.StartInfo.RedirectStandardOutput = true;
|
||||
p.StartInfo.RedirectStandardInput = true;
|
||||
//var stdIn = p.StandardInput;
|
||||
p.OutputDataReceived += (s, e) => OutputHandler(s, e);
|
||||
|
||||
// Optionally, specify any arguments for the exe
|
||||
//p.StartInfo.Arguments = domanda;
|
||||
|
||||
// Start the process
|
||||
p.Start();
|
||||
|
||||
p.StandardInput.WriteLine(domanda);
|
||||
|
||||
p.BeginOutputReadLine();
|
||||
|
||||
while (!p.HasExited)
|
||||
{
|
||||
//Console.WriteLine(output.ToString());
|
||||
Thread.Sleep(500);
|
||||
//var inVar = Console.ReadLine();
|
||||
//// mando nuovo input...
|
||||
//p.StandardInput.WriteLine(domanda);
|
||||
Thread.Sleep(500);
|
||||
// mando nuovo input...
|
||||
p.StandardInput.WriteLine(domanda);
|
||||
Thread.Sleep(500);
|
||||
// mando nuovo input...
|
||||
p.StandardInput.WriteLine(domanda);
|
||||
Thread.Sleep(500);
|
||||
// mando nuovo input...
|
||||
p.StandardInput.WriteLine(domanda);
|
||||
Thread.Sleep(500);
|
||||
// mando nuovo input...
|
||||
p.StandardInput.WriteLine("escape");
|
||||
}
|
||||
|
||||
|
||||
// Optionally, wait for the process to exit
|
||||
p.WaitForExit();
|
||||
|
||||
|
||||
p.Close();
|
||||
|
||||
Console.WriteLine("Ho finito...");
|
||||
Console.WriteLine("...press return to close");
|
||||
|
||||
Console.ReadLine();
|
||||
Reference in New Issue
Block a user