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? ListRecord { get; set; } = null!; protected List? DoorOp { get; set; } = null!; //protected DoorOpModel? DoorOp { get; set; } = null!; //protected List graphicParams { get; set; } = null!; protected List listValuesGP { get; set; } = null!; protected List? listValues { get; set; } = null!; protected List? listValuesFname { get; set; } = null!; protected override async Task OnParametersSetAsync() { await ReloadData(true); } private async Task ReloadData(bool isFirst) { #if false 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(); } } #endif listValues = await WDCService.ListValuesGetAll(HwCode, "*"); } 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 getGraphicParams(DoorOpModel currDoorOp) { if (DoorOp != null && listValues != null) { //var param = currDoorOp.JsoncConfigVal; //var deserialized = JsonConvert.DeserializeObject>(param); //if (deserialized != null) //{ // graphicParams = deserialized; //} listValuesGP = listValues.Where(x => x.FieldName == "Graphic Parameters1").ToList(); } return listValuesGP; } protected string translate(string lemma) { string answ = ""; answ = WDVService.Traduci(Lingua, lemma); return answ; } } }