From d1fca97d2538418edcb084bcbe4f05caa8761b3c Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Fri, 21 Apr 2023 13:02:46 +0200 Subject: [PATCH] fix lettura e deserializzazione parametri di base --- WebDoorCreator.Data/DTO/DDFDto.cs | 4 +- .../DoorDef/DoorDefSizingSI.razor.cs | 70 +++++++++++++++---- WebDoorCreator.UI/Pages/OrderDetails.razor.cs | 36 +++++----- WebDoorCreator.UI/temp/Conf.yaml | 19 +---- 4 files changed, 77 insertions(+), 52 deletions(-) diff --git a/WebDoorCreator.Data/DTO/DDFDto.cs b/WebDoorCreator.Data/DTO/DDFDto.cs index 5147864..6ff6007 100644 --- a/WebDoorCreator.Data/DTO/DDFDto.cs +++ b/WebDoorCreator.Data/DTO/DDFDto.cs @@ -16,6 +16,7 @@ namespace WebDoorCreator.Data.DTO #endregion Public Constructors #region Public Properties + public string version { get; set; } = "0"; public string code { get; set; } = "0015943"; public DateTime date { get; set; } = DateTime.Now; @@ -28,7 +29,6 @@ namespace WebDoorCreator.Data.DTO public string secure { get; set; } = "UP"; public Sizing size { get; set; } = new Sizing(); public string swing { get; set; } = "RH"; - public string version { get; set; } = "0"; #endregion Public Properties @@ -78,7 +78,7 @@ namespace WebDoorCreator.Data.DTO // aggiungo la parte doorOp come yaml reale/striped... if (!string.IsNullOrEmpty(serialDoorOps)) - { + { fullData += serialDoorOps; } diff --git a/WebDoorCreator.UI/Components/DoorDef/DoorDefSizingSI.razor.cs b/WebDoorCreator.UI/Components/DoorDef/DoorDefSizingSI.razor.cs index 32889b5..b81ba30 100644 --- a/WebDoorCreator.UI/Components/DoorDef/DoorDefSizingSI.razor.cs +++ b/WebDoorCreator.UI/Components/DoorDef/DoorDefSizingSI.razor.cs @@ -38,22 +38,58 @@ namespace WebDoorCreator.UI.Components.DoorDef //currVal = new Dictionary(); if (!string.IsNullOrEmpty(DoorOpInst.JsoncActVal)) { - var deserialized = JsonConvert.DeserializeObject>(DoorOpInst.JsoncActVal!); - var deserializedToComp = JsonConvert.DeserializeObject>(DoorOpInst.JsoncActVal!); + //var k = JsonConvert.DeserializeObject>>(DoorOpInst.JsoncActVal!); + var deserialized = JsonConvert.DeserializeObject>>(DoorOpInst.JsoncActVal!); + + var deserializedToComp = JsonConvert.DeserializeObject>>(DoorOpInst.JsoncActVal!); if (deserialized != null) { - currVal = deserialized; - currValToCompare = deserializedToComp; + foreach (var kvp in deserialized) + { + foreach (var val in kvp.Value) + { + if (!currVal.ContainsKey(val.Key)) + { + + currVal.Add(val.Key, val.Value); + } + } + } + + } + if (deserializedToComp != null) + { + foreach (var kvp in deserializedToComp) + { + foreach (var val in kvp.Value) + { + if (!currValToCompare.ContainsKey(val.Key)) + { + currValToCompare.Add(val.Key, val.Value); + } + } + } + } } } public void setupGraphicParams() { - var deserialized = JsonConvert.DeserializeObject>>(DoorOpInst.JsoncConfigVal!); + var deserialized = JsonConvert.DeserializeObject>>>(DoorOpInst.JsoncConfigVal!); if (deserialized != null) { - graphicParams = deserialized; + //graphicParamsTemp = deserialized; + foreach (var kvp in deserialized) + { + foreach (var val in kvp.Value) + { + if (!graphicParams.ContainsKey(val.Key)) + { + graphicParams.Add(val.Key, val.Value); + } + } + } } } @@ -64,12 +100,13 @@ namespace WebDoorCreator.UI.Components.DoorDef /// /// Array dati /// - protected Dictionary currVal { get; set; } = null!; + protected Dictionary currVal { get; set; } = new Dictionary(); - protected Dictionary? currValToCompare { get; set; } + protected Dictionary currValToCompare { get; set; } = new Dictionary(); - protected Dictionary> graphicParams { get; set; } = null!; + protected Dictionary> graphicParams { get; set; } = new Dictionary>(); + protected Dictionary>> graphicParamsTemp { get; set; } = null!; [Inject] protected IJSRuntime JSRuntime { get; set; } = null!; @@ -111,10 +148,10 @@ namespace WebDoorCreator.UI.Components.DoorDef { if (currValToCompare != null) { - if (k.Value != currValToCompare[k.Key]) - { - answ = true; - } + //if (k.Value != currValToCompare[k.Key]) + //{ + // answ = true; + //} } } } @@ -208,8 +245,11 @@ namespace WebDoorCreator.UI.Components.DoorDef private async Task FullReloadData(bool isFirst) { - setupCurrValues(); - setupGraphicParams(); + if (DoorOpInst.ObjectId != "Size") + { + setupCurrValues(); + setupGraphicParams(); + } //await ReloadData(isFirst); } diff --git a/WebDoorCreator.UI/Pages/OrderDetails.razor.cs b/WebDoorCreator.UI/Pages/OrderDetails.razor.cs index 6847eb6..3b9f587 100644 --- a/WebDoorCreator.UI/Pages/OrderDetails.razor.cs +++ b/WebDoorCreator.UI/Pages/OrderDetails.razor.cs @@ -4,7 +4,6 @@ using Newtonsoft.Json; using WebDoorCreator.Data.DbModels; using WebDoorCreator.Data.DTO; using WebDoorCreator.UI.Data; -using YamlDotNet.RepresentationModel; namespace WebDoorCreator.UI.Pages { @@ -25,17 +24,14 @@ namespace WebDoorCreator.UI.Pages #region Protected Properties protected DoorModel? currDoor { get; set; } = null; - protected WebDoorCreator.Data.DbModels.Edges edgesFirstInst { get; set; } = new WebDoorCreator.Data.DbModels.Edges(); - protected int currDoorType { get; set; } = 0; - /// /// Unità di misura selezionata /// protected string currMeaUnit { get; set; } = "mm"; protected List? DoorsList { get; set; } = null; - + protected WebDoorCreator.Data.DbModels.Edges edgesFirstInst { get; set; } = new WebDoorCreator.Data.DbModels.Edges(); protected int idOrd { get; set; } = -1; [Inject] @@ -53,6 +49,8 @@ namespace WebDoorCreator.UI.Pages #region Protected Methods + protected DDFDto CurrentConf { get; set; } = new DDFDto(); + protected async Task createDoor() { // conto le porte x questo ordine e uso x chiamata successiva... @@ -92,7 +90,8 @@ namespace WebDoorCreator.UI.Pages profCurrMach = listRecordEdge.Where(x => x.Value == "machining").FirstOrDefault(); profCurrOverMat = listRecordEdge.Where(x => x.Value == "overmaterial").FirstOrDefault(); } - Dictionary>> itemsDict = new Dictionary>>(); + Dictionary>> itemsDictDef = new Dictionary>>(); + Dictionary> itemsDictAct = new Dictionary>(); Dictionary> paramsDict = new Dictionary>(); Dictionary actDict = new Dictionary(); List listDefVal = new List(); @@ -110,7 +109,7 @@ namespace WebDoorCreator.UI.Pages paramsDict.Add(item.Value, listDefVal); } - itemsDict.Add(item.DefaultVal, paramsDict); + itemsDictDef.Add(item.DefaultVal, paramsDict); } //defaultParamsList.Add(listDefVal); } @@ -134,13 +133,12 @@ namespace WebDoorCreator.UI.Pages // salvo Door OP associate paramsDict.Clear(); actDict.Clear(); - itemsDict.Clear(); + itemsDictDef.Clear(); if (listRecordEdge != null) { listDefVal.Clear(); if (profCurrType != null) { - foreach (var param in profCurrType.DefaultVal.Split(",")) { listDefVal.Add(param.Trim()); @@ -151,7 +149,7 @@ namespace WebDoorCreator.UI.Pages //listDefVal.Clear(); } //itemsDict.Add(item.Value, paramsDict); - //paramsDict.Clear(); + //paramsDict.Clear(); } if (profCurrMach != null) { @@ -160,6 +158,7 @@ namespace WebDoorCreator.UI.Pages { listDefValCurrMach.Add(profCurrMach.DefaultVal.Trim()); paramsDict.Add(profCurrMach.Value, listDefValCurrMach); + actDict.Add(profCurrMach.Value, profCurrMach.DefaultVal.Trim()); } } if (profCurrOverMat != null) @@ -169,24 +168,28 @@ namespace WebDoorCreator.UI.Pages { listDefValOverMat.Add(profCurrOverMat.DefaultVal.Trim()); paramsDict.Add(profCurrOverMat.Value, listDefValOverMat); + actDict.Add(profCurrOverMat.Value, profCurrOverMat.DefaultVal.Trim()); } } } foreach (var item in listRecordEdge.Where(x => x.Value != "type" && x.Value != "machining" && x.Value != "overmaterial")) { - if (!itemsDict.ContainsKey(item.Value)) + if (!itemsDictDef.ContainsKey(item.Value)) { - itemsDict.Add(item.Value, paramsDict); + itemsDictDef.Add(item.Value, paramsDict); + } + if (!itemsDictAct.ContainsKey(item.Value)) + { + itemsDictAct.Add(item.Value, actDict); } - //defaultParamsList.Add(listDefVal); //defaultDict.Add(item.Label, listDefVal); } } //actDict.Add(HwToShow.TableName, actParamsList); - jsonDef = JsonConvert.SerializeObject(itemsDict); - jsonAct = JsonConvert.SerializeObject(actDict); + jsonDef = JsonConvert.SerializeObject(itemsDictDef); + jsonAct = JsonConvert.SerializeObject(itemsDictAct); doorOpToAdd = new DoorOpModel() { @@ -209,12 +212,9 @@ namespace WebDoorCreator.UI.Pages await InvokeAsync(StateHasChanged); } - // rimando alla pagina... dettaglio... NavManager.NavigateTo($"/DoorDefinition?idOrd={idOrd}&idDoor={doorId}"); } - protected DDFDto CurrentConf { get; set; } = new DDFDto(); - protected override async Task OnInitializedAsync() { await Task.Delay(1); diff --git a/WebDoorCreator.UI/temp/Conf.yaml b/WebDoorCreator.UI/temp/Conf.yaml index 0d24ccc..bab966c 100644 --- a/WebDoorCreator.UI/temp/Conf.yaml +++ b/WebDoorCreator.UI/temp/Conf.yaml @@ -2,8 +2,9 @@ #Config: EgtCompoBase #Door1 +version: 2 code: 0015943 -date: 2023-04-21T09:42:37.3671832+02:00 +date: 2023-04-21T12:51:15.4331164+02:00 material: wood measures: millimiters order: @@ -37,21 +38,5 @@ size: height: 81.25 thickness: 1.75 swing: RH -version: 2 -ept: - - template: Generic\StdEPT - ToptoCL: 15 - FacetoCL: 0.875 - - template: Generic\StdEPT - ToptoCL: 15 - FacetoCL: 0.875 - -flush_bolts: - - template: Corner\8501 - type: corner - side: top - position: 5 - offset_WS: 0.0 - ---