117 lines
3.5 KiB
C#
117 lines
3.5 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using WebDoorCreator.Data;
|
|
using WebDoorCreator.Data.DbModels;
|
|
using WebDoorCreator.UI.Data;
|
|
|
|
namespace WebDoorCreator.UI.Components.Hardware
|
|
{
|
|
public partial class HardwareNewPanel
|
|
{
|
|
[Parameter]
|
|
public int DoorTypeTypeId { get; set; } = 0;
|
|
|
|
[Parameter]
|
|
public string HwCode { get; set; } = "";
|
|
|
|
[Parameter]
|
|
public int DoorId { get; set; } = 0;
|
|
|
|
[Parameter]
|
|
public bool HwAdded { get; set; } = false;
|
|
|
|
[Parameter]
|
|
public string Lingua { get; set; } = "EN";
|
|
|
|
[Inject]
|
|
protected WebDoorCreatorService WDCService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected WDCVocabularyService WDVService { get; set; } = null!;
|
|
|
|
protected List<DoorOpModel>? ListRecord { get; set; } = null!;
|
|
protected List<DoorOpModel>? DoorOp { get; set; } = null!;
|
|
//protected DoorOpModel? DoorOp { get; set; } = null!;
|
|
protected List<GraphicParamsModel> graphicParams { get; set; } = null!;
|
|
protected List<ListValuesModel>? listValues { get; set; } = null!;
|
|
protected List<ListValuesModel>? listValuesFname { get; set; } = null!;
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
await ReloadData(true);
|
|
}
|
|
|
|
private async Task ReloadData(bool isFirst)
|
|
{
|
|
ListRecord = await WDCService.DoorOpGetByDoorId(DoorId);
|
|
var tempListVal = await WDCService.ListValuesGetAll(HwCode, "Compo");
|
|
if (ListRecord != null)
|
|
{
|
|
DoorOp = ListRecord.Where(x => (x.DoorId == DoorId) && (x.DoorOpTypId == DoorTypeTypeId)).ToList();
|
|
}
|
|
if (tempListVal != null)
|
|
{
|
|
listValuesFname = tempListVal.Where(x => (x.TableName == HwCode) && (x.Ordinal == 1)).ToList();
|
|
if (listValuesFname != null)
|
|
{
|
|
if (isFirst)
|
|
{
|
|
folderName = listValuesFname.FirstOrDefault()?.Value.Split(@"\")[0]!;
|
|
}
|
|
listValues = tempListVal.Where(x => (x.TableName == HwCode) && (x.Value.Contains(folderName))).ToList();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected string _folderName { get; set; } = "";
|
|
|
|
protected string folderName
|
|
{
|
|
get => _folderName;
|
|
set
|
|
{
|
|
if (_folderName != value)
|
|
{
|
|
_folderName = value;
|
|
var pUpd = Task.Run(async () => await ReloadData(false));
|
|
}
|
|
}
|
|
}
|
|
|
|
public List<GraphicParamsModel> getGraphicParams(DoorOpModel currDoorOp)
|
|
{
|
|
if (DoorOp != null)
|
|
{
|
|
var param = currDoorOp.JsoncConfigVal;
|
|
var deserialized = JsonConvert.DeserializeObject<List<GraphicParamsModel>>(param);
|
|
|
|
if (deserialized != null)
|
|
{
|
|
graphicParams = deserialized;
|
|
}
|
|
}
|
|
|
|
return graphicParams;
|
|
}
|
|
|
|
protected string translate(string lemma)
|
|
{
|
|
string answ = "";
|
|
|
|
answ = WDVService.Traduci(Lingua, lemma);
|
|
|
|
return answ;
|
|
}
|
|
|
|
//public List<ListValuesModel> templFileList()
|
|
//{
|
|
// if(listValues != null)
|
|
// {
|
|
|
|
// }
|
|
|
|
// return listValues;
|
|
//}
|
|
}
|
|
} |