From 8643e573690a410ad1cb603bf2d21f9af9e268b8 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 4 May 2023 12:55:47 +0200 Subject: [PATCH] Bozza progetto dataFiller x interclays --- MapoDataFiller/MConf.cs | 48 ++++++++++++++++++++++++++++ MapoDataFiller/MapoDataFiller.csproj | 15 +++++++++ MapoDataFiller/Program.cs | 28 ++++++++++++++++ MapoDataFiller/conf.yaml | 3 ++ 4 files changed, 94 insertions(+) create mode 100644 MapoDataFiller/MConf.cs create mode 100644 MapoDataFiller/MapoDataFiller.csproj create mode 100644 MapoDataFiller/Program.cs create mode 100644 MapoDataFiller/conf.yaml diff --git a/MapoDataFiller/MConf.cs b/MapoDataFiller/MConf.cs new file mode 100644 index 0000000..428c5c4 --- /dev/null +++ b/MapoDataFiller/MConf.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; +using YamlDotNet.Serialization.NamingConventions; +using YamlDotNet.Serialization; +using System.Reflection.Metadata; + +namespace MapoDataFiller +{ + public class MConf + { + public string DaySetupFile { get; set; } = ""; + public string FillMode { get; set; } = ""; + public bool HasHeader { get; set; } = false; + + public MConf() + { + this.DaySetupFile = @"C:\temp\Interclays\Interclays02.csv"; + this.FillMode = "NONE"; + this.HasHeader = false; + } + } + public class CMan + { + /// + /// Deserializza dato filePath + /// + /// + public static MConf readConf(string filePath) + { + MConf retObj = new MConf(); + if (File.Exists(filePath)) + { + var deserializer = new DeserializerBuilder() + .WithNamingConvention(new PascalCaseNamingConvention()) + .Build(); + string rawData = File.ReadAllText(filePath); + + var input = new StringReader(rawData); + retObj = deserializer.Deserialize(input); + } + return retObj; + } + } +} diff --git a/MapoDataFiller/MapoDataFiller.csproj b/MapoDataFiller/MapoDataFiller.csproj new file mode 100644 index 0000000..2f008bb --- /dev/null +++ b/MapoDataFiller/MapoDataFiller.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + + diff --git a/MapoDataFiller/Program.cs b/MapoDataFiller/Program.cs new file mode 100644 index 0000000..51d5a0b --- /dev/null +++ b/MapoDataFiller/Program.cs @@ -0,0 +1,28 @@ +// See https://aka.ms/new-console-template for more information +using MapoDataFiller; +using Spectre.Console; + + +AnsiConsole.Write( + new FigletText("MapoDataFiller") + .LeftAligned() + .Color(Color.Blue1)); +var rule = new Rule("[green]Setup data[/]"); +rule.Alignment = Justify.Left; +AnsiConsole.Write(rule); + +// recupero configurazione... +MConf currConf = new MConf(); +if (File.Exists("conf.yaml")) +{ + currConf = CMan.readConf("conf.yaml"); +} +AnsiConsole.WriteLine(); +AnsiConsole.MarkupLineInterpolated($"Conf FillMode: [yellow]{currConf.FillMode}[/]"); +var typeOk = AnsiConsole.Confirm("Confermi FillMode?"); +while (!typeOk) +{ + currConf.FillMode = AnsiConsole.Ask("Inserisci il modo desiderato:"); + AnsiConsole.WriteLine(currConf.FillMode); + typeOk = AnsiConsole.Confirm("Confermi FillMode?"); +} \ No newline at end of file diff --git a/MapoDataFiller/conf.yaml b/MapoDataFiller/conf.yaml new file mode 100644 index 0000000..d2f1011 --- /dev/null +++ b/MapoDataFiller/conf.yaml @@ -0,0 +1,3 @@ +DaySetupFile: C:\temp\Interclays +FillMode: Interclays-02 +HasHeader: true \ No newline at end of file