From b84eab15422fa8a8c1d3f1cb1b9df1b22868fca9 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Thu, 30 Mar 2023 09:55:44 +0200 Subject: [PATCH] fix gestione hw params e dooroptype --- .../Controllers/WebDoorCreatorController.cs | 29 ++++++++- WebDoorCreator.Data/DbModels/Edges.cs | 16 +++++ WebDoorCreator.Data/DbModels/Opening.cs | 13 ++++ WebDoorCreator.Data/DbModels/Sizing.cs | 15 +++++ .../Data/WebDoorCreatorService.cs | 61 +++++++++++++++++-- 5 files changed, 128 insertions(+), 6 deletions(-) create mode 100644 WebDoorCreator.Data/DbModels/Edges.cs create mode 100644 WebDoorCreator.Data/DbModels/Opening.cs create mode 100644 WebDoorCreator.Data/DbModels/Sizing.cs diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index 06637a4..ac3d161 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -534,9 +534,34 @@ namespace WebDoorCreator.Data.Controllers return fatto; } + /// + /// truncate tables + /// + /// + public bool TablesTruncate() + { + bool dbResult = false; + using (var dbCtx = new WDCDataContext(_configuration)) + { + try + { + dbCtx + .Database + .ExecuteSqlRaw("EXEC man.[stp_TruncTables]"); + + dbResult = true; + } + catch (Exception exc) + { + Log.Error($"Error in TablesTruncate:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + #endregion Components Methods - #region Door Operationm Methods + #region Door Operation Methods /// @@ -565,6 +590,6 @@ namespace WebDoorCreator.Data.Controllers return fatto; } - #endregion Door Operationm Methods + #endregion Door Operation Methods } } \ No newline at end of file diff --git a/WebDoorCreator.Data/DbModels/Edges.cs b/WebDoorCreator.Data/DbModels/Edges.cs new file mode 100644 index 0000000..48b2b84 --- /dev/null +++ b/WebDoorCreator.Data/DbModels/Edges.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebDoorCreator.Data.DbModels +{ + public class Edges + { + public string lockEdge { get; set; } = "BV"; + public string hingeEdge { get; set; } = "BV"; + public string topEdge { get; set; } = "SQ"; + public string bottomEdge { get; set; } = "SQ"; + } +} diff --git a/WebDoorCreator.Data/DbModels/Opening.cs b/WebDoorCreator.Data/DbModels/Opening.cs new file mode 100644 index 0000000..fddd4f9 --- /dev/null +++ b/WebDoorCreator.Data/DbModels/Opening.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebDoorCreator.Data.DbModels +{ + public class Opening + { + public string swing { get; set; } = "RH"; + } +} diff --git a/WebDoorCreator.Data/DbModels/Sizing.cs b/WebDoorCreator.Data/DbModels/Sizing.cs new file mode 100644 index 0000000..0068b75 --- /dev/null +++ b/WebDoorCreator.Data/DbModels/Sizing.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebDoorCreator.Data.DbModels +{ + public class Sizing + { + public string width { get; set; } = "33.8125"; + public string height { get; set; } = "81.25"; + public string thickness { get; set; } = "1.75"; + } +} diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index a05275c..99a36af 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -610,12 +610,20 @@ namespace WebDoorCreator.UI.Data foreach (string param in graphicParamsName) { string compoParams = fIni.ReadString(match.Substring(1, match.Length - 2), $"{param.Split("=")[0]}", "CONFIG"); //cerco il parametro nella sezione - var compoParamsSplit = compoParams.Split(";"); + + string CompoParamName = ""; + string CompoParamAlias = ""; if (param.Split("=")[0].StartsWith("Param")) { + if (compoParamsSplit[1].Contains("/")) + { + CompoParamName = compoParamsSplit[1].Split("/")[0]; + CompoParamAlias = compoParamsSplit[1].Split("/")[1]; - GraphicParamsModel graphicParams = new GraphicParamsModel() { compoId = i, graphicParamsN = match.Substring(1, match.Length - 2), graphicParamKey = param.Split("=")[0], graphicParamName = compoParamsSplit[1], graphicParamAlias = compoParamsSplit[1], graphicParamType = compoParamsSplit[0], graphicParamDefaultVal = compoParamsSplit[2] }; + } + + GraphicParamsModel graphicParams = new GraphicParamsModel() { compoId = i, graphicParamsN = match.Substring(1, match.Length - 2), graphicParamKey = param.Split("=")[0], graphicParamName = CompoParamName, graphicParamAlias = CompoParamAlias, graphicParamType = compoParamsSplit[0], graphicParamDefaultVal = compoParamsSplit[2] }; listGraphicParams.Add(graphicParams); //creo nuovo oggetto parametro che conterrà anche il nome del componente per creare relazione await dbController.ParamAdd(graphicParams); } @@ -644,6 +652,9 @@ namespace WebDoorCreator.UI.Data int n = 1; int i = 1; List listGraphicParams = new List(); + + dbController.TablesTruncate(); + List listActiveCompo = await GetAllActiveCompo(Path.Combine(rootPath, @"Default.ini")); List listCompoS = new List(); //estraggo tutte le sotto directory della cartella \EgtData\Doors\EgtCompoBase\Compo @@ -658,6 +669,7 @@ namespace WebDoorCreator.UI.Data { List lines = File.ReadAllLines(file).ToList(); //leggo tutte le linee del file IniFile fIni = new IniFile(file); + Guid opCode = Guid.NewGuid(); compoName = fIni.ReadString("Compo", "Name", "COMPONAME"); //cerco la sezione del file ed estraggo il nome del componente var isActive = fIni.ReadString("Template", "IsActive", "1");//cerco la sezione del file ed estraggo se i template sono attivi per il seguente componente bool compoTemplateIsActive = true; @@ -669,7 +681,7 @@ namespace WebDoorCreator.UI.Data var compoNameSplit = compoName.Split("/"); // lo slash indica l'alias if (listActiveCompo.Contains(compoNameSplit[0].ToString())) { - HardwareModel compoConfig = new HardwareModel() { compoName = compoNameSplit[0].ToString(), compoAlias = compoNameSplit[1].ToString(), compoTemplateIsActive = compoTemplateIsActive }; //creo il componente (padre) + HardwareModel compoConfig = new HardwareModel() { compoName = compoNameSplit[0].ToString(), compoAlias = compoNameSplit[1].ToString(), compoLayerName = layerName, compoTemplateIsActive = compoTemplateIsActive }; //creo il componente (padre) await dbController.CompoAdd(compoConfig); listCompoS.Add(compoConfig); var lineToSearch = lines.Where(x => x.Contains("[Graphic")).ToList(); //cerco all'interno del file tutte le sezioni che contengono "[Graphic" così da poter prendere il nome della sezione ES: [Graphic parameters1] = Graphic parameters1 @@ -682,7 +694,8 @@ namespace WebDoorCreator.UI.Data DoorOpTypeModel doorOpType = new DoorOpTypeModel() { - Description = $"DOOR OPERATION TYPE FOR {compoNameSplit[1].ToString()}", + Description = $"DOOR OPERATION TYPE FOR {compoNameSplit[0].ToString()}", + OpCode = opCode.ToString(), HasHw = true, IsConcrete = true, HwCode = compoNameSplit[0].ToString(), @@ -697,6 +710,46 @@ namespace WebDoorCreator.UI.Data } + List edges = new List(); + edges.Add(new Edges()); + List sizing = new List(); + sizing.Add(new Sizing()); + List opening = new List(); + opening.Add(new Opening()); + Guid opCodeEdges = Guid.NewGuid(); + Guid opCodeSizing = Guid.NewGuid(); + Guid opCodeOpening = Guid.NewGuid(); + DoorOpTypeModel doorOpTypeEdges = new DoorOpTypeModel() + { + Description = "DOOR OPERATION TYPE FOR Edges", + OpCode = opCodeEdges.ToString(), + HasHw = false, + IsConcrete = true, + DoorOpIdPathFromPatriarch = HierarchyId.Parse("/1/"), + JsoncConfig = JsonConvert.SerializeObject(edges) + }; + DoorOpTypeModel doorOpTypeSizing = new DoorOpTypeModel() + { + Description = "DOOR OPERATION TYPE FOR Sizing", + OpCode = opCodeSizing.ToString(), + HasHw = false, + IsConcrete = true, + DoorOpIdPathFromPatriarch = HierarchyId.Parse("/1/"), + JsoncConfig = JsonConvert.SerializeObject(sizing) + }; + DoorOpTypeModel doorOpTypeOpening = new DoorOpTypeModel() + { + Description = "DOOR OPERATION TYPE FOR Opening", + OpCode = opCodeOpening.ToString(), + HasHw = false, + IsConcrete = true, + DoorOpIdPathFromPatriarch = HierarchyId.Parse("/1/"), + JsoncConfig = JsonConvert.SerializeObject(opening) + }; + + await dbController.DoorOpTypeAdd(doorOpTypeEdges); + await dbController.DoorOpTypeAdd(doorOpTypeSizing); + await dbController.DoorOpTypeAdd(doorOpTypeOpening); return fatto; }