Files
mapo-core/IobConf.UI/Pages/Index.razor.cs
T
Samuele Locatelli 310f304b7e Aggiunta preliminare oggetto IobConf
- testing gestione file conf YAML/JSON
- bozza acquisizione e salvataggio dati conf da IOB sul campo
2022-12-22 18:31:24 +01:00

74 lines
1.9 KiB
C#

using IobConf.Core;
using Microsoft.AspNetCore.Components;
namespace IobConf.UI.Pages
{
public partial class Index
{
#region Public Methods
protected override void OnInitialized()
{
UpdateConf();
}
public async Task SaveJson()
{
checkOutDir();
await Task.Delay(1);
string fileName = Path.Combine(baseDir, $"Conf.json");
CurrentConf.SaveJson(fileName);
}
public async Task SaveYaml()
{
checkOutDir();
await Task.Delay(1);
string fileName = Path.Combine(baseDir, $"Conf.yml");
CurrentConf.SaveYaml(fileName);
}
public async Task UpdateConf()
{
await Task.Delay(1);
CodIOB = $"NewIOB_{DateTime.Now.Second}";
CurrentConf = new IobConfTree()
{
codIOB = CodIOB
};
// aggiorno conf JSON/YAML
confJson = (MarkupString)CurrentConf.getJson().Replace("\n", "<br/>").Replace(" ", "&nbsp;&nbsp;");
confYaml = (MarkupString)CurrentConf.getYaml().Replace("\n", "<br/>").Replace(" ", "&nbsp;&nbsp;");
}
#endregion Public Methods
#region Protected Fields
protected string baseDir = @"c:\temp\IobConf";
protected string CodIOB = "NewIOB_00";
#endregion Protected Fields
#region Protected Properties
protected MarkupString confJson { get; set; }
protected MarkupString confYaml { get; set; }
protected IobConfTree CurrentConf { get; set; } = new IobConfTree();
#endregion Protected Properties
#region Private Methods
private void checkOutDir()
{
if (!Directory.Exists(baseDir))
{
Directory.CreateDirectory(baseDir);
}
}
#endregion Private Methods
}
}