diff --git a/ConfMan.IOB.CApp/Program.cs b/ConfMan.IOB.CApp/Program.cs index 627b41c..5778ee8 100644 --- a/ConfMan.IOB.CApp/Program.cs +++ b/ConfMan.IOB.CApp/Program.cs @@ -1,6 +1,7 @@ // See https://aka.ms/new-console-template for more information using ConfMan.IOB.CApp; using Spectre.Console; +using System.Diagnostics; using System.Net; AnsiConsole.Write( @@ -96,10 +97,16 @@ newTags.Add("HostAddr", HostAddr); AnsiConsole.WriteLine(); // ora processa tutti i file, andando ad aggiungere in coda i TAGS selezionati... +Stopwatch sw = new Stopwatch(); +sw.Start(); foreach (var confFile in fileList) { TagManager tMan = new TagManager(confFile); tMan.addTagList(newTags); } - -return 1; \ No newline at end of file +sw.Stop(); +var elTime = sw.Elapsed; +rule = new Rule("File update [green]Completed[/]!"); +rule.Alignment = Justify.Left; +AnsiConsole.Write(rule); +AnsiConsole.MarkupLineInterpolated($"Processati [yellow]{fileList.Count()}[/] file in {elTime.TotalMilliseconds}ms"); \ No newline at end of file diff --git a/ConfMan.IOB.CApp/TagManager.cs b/ConfMan.IOB.CApp/TagManager.cs index 23ca4d0..dcffc5a 100644 --- a/ConfMan.IOB.CApp/TagManager.cs +++ b/ConfMan.IOB.CApp/TagManager.cs @@ -29,7 +29,7 @@ namespace ConfMan.IOB.CApp if (File.Exists(_filePath)) { // leggo file - var fileRows = File.ReadAllLines(_filePath); + var fileRows = File.ReadAllLines(_filePath).ToList(); //string fileContent = File.ReadAllText(_filePath); bool tagFound = false; string tagHead = "[TAGS]"; @@ -47,12 +47,11 @@ namespace ConfMan.IOB.CApp } if (!tagFound) { - fileRows.Append(""); - fileRows.Append("; Tags manuali"); - fileRows.Append(tagHead); + fileRows.Add(""); + fileRows.Add("; Tags manuali"); + fileRows.Add(tagHead); rowTagIndex = fileRows.Count() - 1; } - fileRows.Append(""); int numRows = fileRows.Count(); // ora aggiungo le varie chiavi dal dizionario foreach (var tag in tags) @@ -71,7 +70,7 @@ namespace ConfMan.IOB.CApp // aggiungo tag in coda se no sostituito if (!rowChanged) { - fileRows.Append($"{tag.Key}={tag.Value}"); + fileRows.Add($"{tag.Key}={tag.Value}"); } } // salvo! @@ -81,5 +80,7 @@ namespace ConfMan.IOB.CApp } return fatto; } + + } } diff --git a/ConfMan.IOB.Core/HostInfo.cs b/ConfMan.IOB.Core/HostInfo.cs index 94789c0..a955a4b 100644 --- a/ConfMan.IOB.Core/HostInfo.cs +++ b/ConfMan.IOB.Core/HostInfo.cs @@ -1,12 +1,34 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConfMan.IOB.Core +namespace ConfMan.IOB.Core { - internal class HostData + public class HostInfo { + #region Public Constructors + + /// + /// Init classe default + /// + public HostInfo() + { } + + #endregion Public Constructors + + #region Public Properties + + /// + /// Indirizzo Ip dell'HOST + /// + public string HostAddr { get; set; } = "127.0.0.1"; + + /// + /// Nome Host + /// + public string HostName { get; set; } = "localhost"; + + /// + /// Sistema Operativo + /// + public string OS { get; set; } = "WIN"; + + #endregion Public Properties } -} +} \ No newline at end of file diff --git a/ConfMan.IOB.Core/IobConfTree.cs b/ConfMan.IOB.Core/IobConfTree.cs index aefb994..dfa694b 100644 --- a/ConfMan.IOB.Core/IobConfTree.cs +++ b/ConfMan.IOB.Core/IobConfTree.cs @@ -59,7 +59,7 @@ namespace ConfMan.IOB.Core // recupero NUOVI dati TAGS newConfObj.GeneralCom = (ComType)Enum.Parse(typeof(ComType), fIni.ReadString("TAGS", "ComType", "ND")); newConfObj.Customer = fIni.ReadString("TAGS", "Customer", "ND"); - newConfObj.HostData.OS = fIni.ReadString("TAGS", "OS", "WIN"); + newConfObj.HostData.OS = fIni.ReadString("TAGS", "HostOS", "WIN"); newConfObj.HostData.HostName = fIni.ReadString("TAGS", "HostName", "localhost"); newConfObj.HostData.HostAddr = fIni.ReadString("TAGS", "HostAddr", "127.0.0.1");