85 lines
2.1 KiB
C#
85 lines
2.1 KiB
C#
// See https://aka.ms/new-console-template for more information
|
|
|
|
using EgwCApp.Core;
|
|
using System.Diagnostics;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
Dictionary<string, TimeSpan> statsColl = new Dictionary<string, TimeSpan>();
|
|
Stopwatch sw = new Stopwatch();
|
|
|
|
string separator = "--------------------------------------";
|
|
Console.WriteLine(separator);
|
|
Console.WriteLine("Console Test Application");
|
|
Console.WriteLine(separator);
|
|
Console.WriteLine();
|
|
|
|
// creo il file di configurazione...
|
|
string fileName = "conf.json";
|
|
ConfigFile newConf = new ConfigFile()
|
|
{
|
|
Type = ImportType.CSV,
|
|
FilePath = @"C:\Temp\test.log",
|
|
Return = ReturnMode.Console
|
|
};
|
|
// serializzo e salvo!
|
|
JsonSerializerOptions jso = new JsonSerializerOptions()
|
|
{
|
|
WriteIndented = true
|
|
};
|
|
string rawData = JsonSerializer.Serialize(newConf, jso);
|
|
File.WriteAllText(fileName, rawData);
|
|
|
|
string appPath = "./Utils/ExcImport.exe";
|
|
string procArg = fileName;
|
|
Console.WriteLine("calling ext app with args:");
|
|
Console.WriteLine($"{appPath} {procArg}");
|
|
Console.WriteLine();
|
|
Console.WriteLine("press enter to proceed...");
|
|
|
|
Console.ReadLine();
|
|
|
|
ProcessStartInfo psi = new ProcessStartInfo
|
|
{
|
|
FileName = appPath,
|
|
Arguments = $"{procArg}",
|
|
WindowStyle = ProcessWindowStyle.Minimized,
|
|
//WindowStyle = ProcessWindowStyle.Hidden,
|
|
UseShellExecute = false,
|
|
//CreateNoWindow = true,
|
|
RedirectStandardOutput = true,
|
|
RedirectStandardInput = true,
|
|
};
|
|
|
|
sw.Start();
|
|
|
|
Process p = Process.Start(psi);
|
|
|
|
string q = "";
|
|
while (!p.HasExited)
|
|
{
|
|
q += p.StandardOutput.ReadToEnd();
|
|
}
|
|
|
|
sw.Stop();
|
|
var timeElaps = sw.Elapsed;
|
|
statsColl.Add("Ext prog executed", timeElaps);
|
|
Console.WriteLine(separator);
|
|
Console.WriteLine("press enter to proceed...");
|
|
|
|
Console.ReadLine();
|
|
sw.Restart();
|
|
Console.WriteLine("Data received:");
|
|
Console.WriteLine(q);
|
|
Console.WriteLine();
|
|
sw.Stop();
|
|
timeElaps = sw.Elapsed;
|
|
statsColl.Add("Data Received", timeElaps);
|
|
|
|
foreach (var item in statsColl)
|
|
{
|
|
Console.WriteLine($"{item.Key} {item.Value.TotalMilliseconds} ms");
|
|
}
|
|
//Console.WriteLine($"Display executed in {timeElaps.TotalMilliseconds} ms");
|
|
|
|
Console.ReadLine(); |