// See https://aka.ms/new-console-template for more information

using EgwCApp.Core;
using System.Diagnostics;
using Newtonsoft.Json;
using EgwCApp.XmlTesting;

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();
string rawData = "";

// test CSV
//newConf = new ConfigFile()
//{
//    Type = ImportType.CSV,
//    FileInPath = @"C:\Temp\test.log",
//    Return = ReturnMode.Console
//};


// svuoto eventuali conf vecchi
var listaConf = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.json");
if (listaConf != null && listaConf.Count() > 0)
{
    foreach (var file2del in listaConf)
    {
        File.Delete(file2del);
    }
}
// cerco file xlsx e ciclo...
var listaFiles = Directory.GetFiles(@"C:\temp\import\", "*.xlsx");
if (listaFiles != null && listaFiles.Count() > 0)
{
    FileProcMan fpm = new FileProcMan("Tools", "ExcImport.exe");
    foreach (var item in listaFiles)
    {
        TimeSpan timeElaps = fpm.doProcess(item);

        statsColl.Add($"Ext prog executed for {item}", timeElaps);
    }
}


Console.WriteLine(separator);
Console.WriteLine("press enter to proceed...");

Console.ReadLine();

foreach (var item in statsColl)
{
    Console.WriteLine($"{item.Key} {item.Value.TotalMilliseconds} ms");
}
//Console.WriteLine($"Display executed in {timeElaps.TotalMilliseconds} ms");

Console.ReadLine();