111 lines
3.1 KiB
C#
111 lines
3.1 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Newtonsoft.Json;
|
|
using WebDoorCreator.Data.DbModels;
|
|
using WebDoorCreator.UI.Data;
|
|
|
|
namespace WebDoorCreator.UI.Components.Hardware
|
|
{
|
|
public partial class SingleInstance
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public DoorOpModel DoorOpInst { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public string HwCode { get; set; } = "";
|
|
|
|
[Parameter]
|
|
public string Lingua { get; set; } = "EN";
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public Dictionary<string, Dictionary<string, List<string>>> getGraphicParams()
|
|
{
|
|
var deserialized = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, List<string>>>>(DoorOpInst.JsoncConfigVal!);
|
|
if (deserialized != null)
|
|
{
|
|
graphicParams = deserialized;
|
|
}
|
|
return graphicParams;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
protected string _folderName { get; set; } = "";
|
|
|
|
protected string folderName
|
|
{
|
|
get => _folderName;
|
|
set
|
|
{
|
|
if (_folderName != value)
|
|
{
|
|
_folderName = value;
|
|
var pUpd = Task.Run(async () => await ReloadData(false));
|
|
}
|
|
}
|
|
}
|
|
|
|
protected Dictionary<string, Dictionary<string, List<string>>> graphicParams { get; set; } = null!;
|
|
protected List<ListValuesModel>? listValuesFiles { get; set; } = null!;
|
|
|
|
protected List<ListValuesModel>? listValuesFname { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected WebDoorCreatorService WDCService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected WDCVocabularyService WDVService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
await ReloadData(true);
|
|
}
|
|
|
|
protected string translate(string lemma)
|
|
{
|
|
string answ = "";
|
|
|
|
answ = WDVService.Traduci(Lingua, lemma);
|
|
|
|
return answ;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Methods
|
|
|
|
private async Task ReloadData(bool isFirst)
|
|
{
|
|
var tempListVal = await WDCService.ListValuesGetAll(HwCode, "Folder");
|
|
if (tempListVal != null)
|
|
{
|
|
listValuesFname = tempListVal;
|
|
if (listValuesFname != null)
|
|
{
|
|
if (isFirst)
|
|
{
|
|
folderName = listValuesFname.FirstOrDefault()?.Label!;
|
|
}
|
|
var tempListFiles = await WDCService.ListValuesGetAll(HwCode, "Template");
|
|
|
|
if (tempListFiles != null)
|
|
{
|
|
listValuesFiles = tempListFiles.Where(x => x.Value.Contains(folderName)).ToList();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |