Completato fixApp x gestione ConfIOB:

- aggiunta tags su richiesta
This commit is contained in:
Samuele Locatelli
2022-12-28 12:49:30 +01:00
parent f33a91efc6
commit 56cb0966fe
4 changed files with 48 additions and 18 deletions
+9 -2
View File
@@ -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;
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");
+7 -6
View File
@@ -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;
}
}
}
+31 -9
View File
@@ -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
/// <summary>
/// Init classe default
/// </summary>
public HostInfo()
{ }
#endregion Public Constructors
#region Public Properties
/// <summary>
/// Indirizzo Ip dell'HOST
/// </summary>
public string HostAddr { get; set; } = "127.0.0.1";
/// <summary>
/// Nome Host
/// </summary>
public string HostName { get; set; } = "localhost";
/// <summary>
/// Sistema Operativo
/// </summary>
public string OS { get; set; } = "WIN";
#endregion Public Properties
}
}
}
+1 -1
View File
@@ -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");