b86a6021bf
- Adapter - Decoder - UI
119 lines
3.7 KiB
C#
119 lines
3.7 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using MP.MONO.Core;
|
|
using MP.MONO.UI.Data;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace MP.MONO.UI.Pages
|
|
{
|
|
public partial class Info
|
|
{
|
|
#region Public Methods
|
|
|
|
public async Task flushCache()
|
|
{
|
|
await Task.Delay(1);
|
|
await MDService.FlushRedisCache();
|
|
// rimando a home
|
|
NavManager.NavigateTo("", true);
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected CurrentDataService MDService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
// validatore
|
|
var mDV = new MachineDataValidator();
|
|
// dati macchina
|
|
biosInfo = MachineDataValidator.biosInfo;
|
|
cpuInfo = MachineDataValidator.cpuInfo;
|
|
netInfo = MachineDataValidator.netInfo;
|
|
osInfo = MachineDataValidator.osInfo;
|
|
ramInfo = MachineDataValidator.ramInfo;
|
|
// check licenze
|
|
licOk = await MachineDataValidator.testCurrInfo();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private string baseDir = $"{Directory.GetCurrentDirectory()}";
|
|
private Dictionary<string, string> biosInfo = new Dictionary<string, string>();
|
|
private Dictionary<string, string> cpuInfo = new Dictionary<string, string>();
|
|
private bool licOk = false;
|
|
private Dictionary<string, string> netInfo = new Dictionary<string, string>();
|
|
private Dictionary<string, string> osInfo = new Dictionary<string, string>();
|
|
private Dictionary<string, string> ramInfo = new Dictionary<string, string>();
|
|
private bool showBios = false;
|
|
private bool showCpu = false;
|
|
private bool showKeyMan = false;
|
|
private bool showNet = false;
|
|
private bool showOs = false;
|
|
private bool showRam = false;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private string fileName { get; set; } = "InfoData.json";
|
|
private string licVal { get; set; } = "";
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private void saveInfoData()
|
|
{
|
|
var fullData = biosInfo.Concat(cpuInfo).Concat(netInfo).Concat(osInfo).Concat(ramInfo).GroupBy(ele => ele.Key).OrderBy(x => x.Key).ToDictionary(ele => ele.Key, ele => ele.First().Value);
|
|
string filePath = Path.Combine(baseDir, "temp", "InfoData.json");
|
|
File.WriteAllText(filePath, JsonConvert.SerializeObject(fullData, Formatting.Indented));
|
|
}
|
|
|
|
private async Task SaveLic()
|
|
{
|
|
//se ho un valore x la licenza...
|
|
if (!string.IsNullOrEmpty(licVal))
|
|
{
|
|
string filePath = Path.Combine(baseDir, "Conf", "lic.file");
|
|
File.WriteAllText(filePath, licVal);
|
|
}
|
|
|
|
// check licenze
|
|
licOk = await MachineDataValidator.testCurrInfo();
|
|
// se ok --> rivado ad home!
|
|
if (licOk)
|
|
{
|
|
await Task.Delay(1);
|
|
// rimando alla home
|
|
NavManager.NavigateTo("/", true);
|
|
}
|
|
}
|
|
|
|
private void ShowAll()
|
|
{
|
|
showBios = true;
|
|
showCpu = true;
|
|
showNet = true;
|
|
showOs = true;
|
|
showRam = true;
|
|
}
|
|
|
|
private void ToggleKeyMan()
|
|
{
|
|
showKeyMan = !showKeyMan;
|
|
// salvo su disco...
|
|
saveInfoData();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |