161c57ffde
-aggiunta progetto originale (WEB) x conversione CONF
80 lines
2.0 KiB
C#
80 lines
2.0 KiB
C#
using ConfMan.IOB.Core;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace ConfMan.IOB.UI.Components
|
|
{
|
|
public partial class TestConfig
|
|
{
|
|
#region Public Methods
|
|
|
|
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:00}";
|
|
CurrentConf = new IobConfTree()
|
|
{
|
|
CodIOB = CodIOB
|
|
};
|
|
// aggiorno conf JSON/YAML
|
|
confJson = (MarkupString)CurrentConf.GetJson().Replace("\n", "<br/>").Replace(" ", " ");
|
|
confYaml = (MarkupString)CurrentConf.GetYaml().Replace("\n", "<br/>").Replace(" ", " ");
|
|
}
|
|
|
|
#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 Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await UpdateConf();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Methods
|
|
|
|
private void checkOutDir()
|
|
{
|
|
if (!Directory.Exists(baseDir))
|
|
{
|
|
Directory.CreateDirectory(baseDir);
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |