From f13e1cfc85833faee9330b23c2b8c9049347014f Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 22 Mar 2023 08:43:43 +0100 Subject: [PATCH 01/43] bozza home con layer --- WebDoorCreator.UI/Pages/Index.razor | 5 ++++- WebDoorCreator.UI/Pages/Index.razor.css | 4 ++++ WebDoorCreator.UI/Pages/Index.razor.less | 6 +++++- WebDoorCreator.UI/Pages/Index.razor.min.css | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/WebDoorCreator.UI/Pages/Index.razor b/WebDoorCreator.UI/Pages/Index.razor index e80f637..7293567 100644 --- a/WebDoorCreator.UI/Pages/Index.razor +++ b/WebDoorCreator.UI/Pages/Index.razor @@ -3,5 +3,8 @@ Index
-

Web Door Creator

+ +
+

Web Door Creator

+
\ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/Index.razor.css b/WebDoorCreator.UI/Pages/Index.razor.css index 9f0b44a..48f1870 100644 --- a/WebDoorCreator.UI/Pages/Index.razor.css +++ b/WebDoorCreator.UI/Pages/Index.razor.css @@ -7,4 +7,8 @@ background-size: cover; /* Resize the background image to cover the entire container */ height: 35rem; +} +.transpLayer { + color: #DEDEDE; + background-image: linear-gradient(to-right, rgba(15, 15, 15, 0.9), rgba(255, 255, 255, 0.1)); } \ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/Index.razor.less b/WebDoorCreator.UI/Pages/Index.razor.less index 3ba62d8..2659ac0 100644 --- a/WebDoorCreator.UI/Pages/Index.razor.less +++ b/WebDoorCreator.UI/Pages/Index.razor.less @@ -4,5 +4,9 @@ background-repeat: no-repeat; /* Do not repeat the image */ background-size: cover; /* Resize the background image to cover the entire container */ height: 35rem; - +} + +.transpLayer { + color: #DEDEDE; + background-image: linear-gradient(to-right, rgba(15,15,15,0.9), rgba(255,255,255,0.1)); } diff --git a/WebDoorCreator.UI/Pages/Index.razor.min.css b/WebDoorCreator.UI/Pages/Index.razor.min.css index 77ad80d..7ef5037 100644 --- a/WebDoorCreator.UI/Pages/Index.razor.min.css +++ b/WebDoorCreator.UI/Pages/Index.razor.min.css @@ -1 +1 @@ -.bgbg{background-image:url("images/DOORBG.png");background-position:center;background-repeat:no-repeat;background-size:cover;height:35rem;} \ No newline at end of file +.bgbg{background-image:url("images/DOORBG.png");background-position:center;background-repeat:no-repeat;background-size:cover;height:35rem;}.transpLayer{color:#dedede;background-image:linear-gradient(to-right,rgba(15,15,15,.9),rgba(255,255,255,.1));} \ No newline at end of file From 8e3b05fa1d6f7c54783983303c00611c1e49d5df Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Wed, 22 Mar 2023 08:59:16 +0100 Subject: [PATCH 02/43] fix landing page --- WebDoorCreator.UI/Pages/Index.razor.css | 9 +++++++-- WebDoorCreator.UI/Pages/Index.razor.less | 9 +++++++-- WebDoorCreator.UI/Pages/Index.razor.min.css | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/WebDoorCreator.UI/Pages/Index.razor.css b/WebDoorCreator.UI/Pages/Index.razor.css index 48f1870..f7d91b5 100644 --- a/WebDoorCreator.UI/Pages/Index.razor.css +++ b/WebDoorCreator.UI/Pages/Index.razor.css @@ -6,9 +6,14 @@ /* Do not repeat the image */ background-size: cover; /* Resize the background image to cover the entire container */ - height: 35rem; + height: 45rem; } .transpLayer { color: #DEDEDE; - background-image: linear-gradient(to-right, rgba(15, 15, 15, 0.9), rgba(255, 255, 255, 0.1)); + background-image: linear-gradient(to right, rgba(30, 30, 30, 0.9), rgba(255, 255, 255, 0.1)); + width: 100%; + height: 100%; + display: flex; + flex-wrap: wrap; + align-items: end; } \ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/Index.razor.less b/WebDoorCreator.UI/Pages/Index.razor.less index 2659ac0..af15245 100644 --- a/WebDoorCreator.UI/Pages/Index.razor.less +++ b/WebDoorCreator.UI/Pages/Index.razor.less @@ -3,10 +3,15 @@ background-position: center; /* Center the image */ background-repeat: no-repeat; /* Do not repeat the image */ background-size: cover; /* Resize the background image to cover the entire container */ - height: 35rem; + height: 45rem; } .transpLayer { color: #DEDEDE; - background-image: linear-gradient(to-right, rgba(15,15,15,0.9), rgba(255,255,255,0.1)); + background-image: linear-gradient(to right, rgba(30,30,30,0.9), rgba(255,255,255,0.1)); + width: 100%; + height: 100%; + display: flex; + flex-wrap: wrap; + align-items: end; } diff --git a/WebDoorCreator.UI/Pages/Index.razor.min.css b/WebDoorCreator.UI/Pages/Index.razor.min.css index 7ef5037..b8eb15e 100644 --- a/WebDoorCreator.UI/Pages/Index.razor.min.css +++ b/WebDoorCreator.UI/Pages/Index.razor.min.css @@ -1 +1 @@ -.bgbg{background-image:url("images/DOORBG.png");background-position:center;background-repeat:no-repeat;background-size:cover;height:35rem;}.transpLayer{color:#dedede;background-image:linear-gradient(to-right,rgba(15,15,15,.9),rgba(255,255,255,.1));} \ No newline at end of file +.bgbg{background-image:url("images/DOORBG.png");background-position:center;background-repeat:no-repeat;background-size:cover;height:45rem;}.transpLayer{color:#dedede;background-image:linear-gradient(to right,rgba(30,30,30,.9),rgba(255,255,255,.1));width:100%;height:100%;display:flex;flex-wrap:wrap;align-items:end;} \ No newline at end of file From 4d348afa47c357b72075f2a51adf6178ce8a3001 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Wed, 22 Mar 2023 09:05:54 +0100 Subject: [PATCH 03/43] fix grafica landing page --- WebDoorCreator.UI/Pages/Index.razor.css | 5 ++++- WebDoorCreator.UI/Pages/Index.razor.less | 5 ++++- WebDoorCreator.UI/Pages/Index.razor.min.css | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/WebDoorCreator.UI/Pages/Index.razor.css b/WebDoorCreator.UI/Pages/Index.razor.css index f7d91b5..e58d54c 100644 --- a/WebDoorCreator.UI/Pages/Index.razor.css +++ b/WebDoorCreator.UI/Pages/Index.razor.css @@ -7,12 +7,15 @@ background-size: cover; /* Resize the background image to cover the entire container */ height: 45rem; + display: flex; + flex-wrap: wrap; + align-items: end; } .transpLayer { color: #DEDEDE; background-image: linear-gradient(to right, rgba(30, 30, 30, 0.9), rgba(255, 255, 255, 0.1)); width: 100%; - height: 100%; + height: 7rem; display: flex; flex-wrap: wrap; align-items: end; diff --git a/WebDoorCreator.UI/Pages/Index.razor.less b/WebDoorCreator.UI/Pages/Index.razor.less index af15245..d425ba3 100644 --- a/WebDoorCreator.UI/Pages/Index.razor.less +++ b/WebDoorCreator.UI/Pages/Index.razor.less @@ -4,13 +4,16 @@ background-repeat: no-repeat; /* Do not repeat the image */ background-size: cover; /* Resize the background image to cover the entire container */ height: 45rem; + display: flex; + flex-wrap: wrap; + align-items: end; } .transpLayer { color: #DEDEDE; background-image: linear-gradient(to right, rgba(30,30,30,0.9), rgba(255,255,255,0.1)); width: 100%; - height: 100%; + height: 7rem; display: flex; flex-wrap: wrap; align-items: end; diff --git a/WebDoorCreator.UI/Pages/Index.razor.min.css b/WebDoorCreator.UI/Pages/Index.razor.min.css index b8eb15e..1cac8d3 100644 --- a/WebDoorCreator.UI/Pages/Index.razor.min.css +++ b/WebDoorCreator.UI/Pages/Index.razor.min.css @@ -1 +1 @@ -.bgbg{background-image:url("images/DOORBG.png");background-position:center;background-repeat:no-repeat;background-size:cover;height:45rem;}.transpLayer{color:#dedede;background-image:linear-gradient(to right,rgba(30,30,30,.9),rgba(255,255,255,.1));width:100%;height:100%;display:flex;flex-wrap:wrap;align-items:end;} \ No newline at end of file +.bgbg{background-image:url("images/DOORBG.png");background-position:center;background-repeat:no-repeat;background-size:cover;height:45rem;display:flex;flex-wrap:wrap;align-items:end;}.transpLayer{color:#dedede;background-image:linear-gradient(to right,rgba(30,30,30,.9),rgba(255,255,255,.1));width:100%;height:7rem;display:flex;flex-wrap:wrap;align-items:end;} \ No newline at end of file From cc83fc775e22dba85d5db08788e41263ea89a50b Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 22 Mar 2023 17:37:37 +0100 Subject: [PATCH 04/43] Update preliminare DB + migration relativa --- WebDoorCreator.Core/ConfigItem.cs | 46 ++ WebDoorCreator.Core/Enum.cs | 1 + WebDoorCreator.Data/DbModels/DoorModel.cs | 2 +- WebDoorCreator.Data/DbModels/DoorOpModel.cs | 69 ++ .../DbModels/DoorOpTypeModel.cs | 112 +++ WebDoorCreator.Data/DbModels/DoorTypeModel.cs | 2 +- ...0322163704_DoorOpModelCreation.Designer.cs | 635 ++++++++++++++++++ .../20230322163704_DoorOpModelCreation.cs | 91 +++ .../WDCData/WDCDataContextModelSnapshot.cs | 132 ++++ WebDoorCreator.Data/WDCDataContext.cs | 20 +- WebDoorCreator.UI/Pages/Index.razor | 5 +- WebDoorCreator.UI/Pages/Index.razor.css | 2 +- WebDoorCreator.UI/Pages/Index.razor.less | 2 +- WebDoorCreator.UI/Pages/Index.razor.min.css | 2 +- 14 files changed, 1112 insertions(+), 9 deletions(-) create mode 100644 WebDoorCreator.Core/ConfigItem.cs create mode 100644 WebDoorCreator.Data/DbModels/DoorOpModel.cs create mode 100644 WebDoorCreator.Data/DbModels/DoorOpTypeModel.cs create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230322163704_DoorOpModelCreation.Designer.cs create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230322163704_DoorOpModelCreation.cs diff --git a/WebDoorCreator.Core/ConfigItem.cs b/WebDoorCreator.Core/ConfigItem.cs new file mode 100644 index 0000000..e85b846 --- /dev/null +++ b/WebDoorCreator.Core/ConfigItem.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebDoorCreator.Core +{ + public class ConfigItem + { + /// + /// Nome dell'item + /// + public string Name { get; set; } = ""; + + /// + /// Tipo dell'item (es: string, int, double, list...) + /// + public string Type { get; set; } = ""; + + /// + /// Valore dell'item + /// + public string ValString { get; set; } = ""; + + public int ValInt + { + get + { + int answ = 0; + int.TryParse(ValString, out answ); + return answ; + } + } + public double ValDouble + { + get + { + double answ = 0; + double.TryParse(ValString, out answ); + return answ; + } + } + + } +} diff --git a/WebDoorCreator.Core/Enum.cs b/WebDoorCreator.Core/Enum.cs index f374775..b2aa24b 100644 --- a/WebDoorCreator.Core/Enum.cs +++ b/WebDoorCreator.Core/Enum.cs @@ -21,5 +21,6 @@ ApprovedByCustomer, InProduction } + } } \ No newline at end of file diff --git a/WebDoorCreator.Data/DbModels/DoorModel.cs b/WebDoorCreator.Data/DbModels/DoorModel.cs index c5853c1..ecf80c8 100644 --- a/WebDoorCreator.Data/DbModels/DoorModel.cs +++ b/WebDoorCreator.Data/DbModels/DoorModel.cs @@ -12,7 +12,7 @@ using System.Threading.Tasks; namespace WebDoorCreator.Data.DbModels { /// - /// Tabella dati Orders + /// Tabella dati Door /// [Table("Door")] public class DoorModel diff --git a/WebDoorCreator.Data/DbModels/DoorOpModel.cs b/WebDoorCreator.Data/DbModels/DoorOpModel.cs new file mode 100644 index 0000000..ac10a90 --- /dev/null +++ b/WebDoorCreator.Data/DbModels/DoorOpModel.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace WebDoorCreator.Data.DbModels +{ + /// + /// Tabella dati operation CONCRETE collegate alla porta + /// + [Table("DoorOp")] + public class DoorOpModel + { + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int DoorOpId { get; set; } + + /// + /// porta di riferimento + /// + public int DoorId { get; set; } = 0; + /// + /// Tipo astratto di riferimento + /// + public int DoorOpTypId { get; set; } = 0; + + /// + /// Descrizione + /// + public string Description { get; set; } = ""; + + /// + /// Data inserimento ordine + /// + public DateTime DateIns { get; set; } = DateTime.Now; + + /// + /// Codice utente che ha creato + /// + public string UserIdIns { get; set; } = ""; + + /// + /// Data (ultima) modifica ordine + /// + public DateTime DateMod { get; set; } = DateTime.Now; + + /// + /// Codice utente che ha creato + /// + public string UserIdMod { get; set; } = ""; + + /// + /// Oggetto Json per specifica configurazione VALORIZZATO + /// + public string JsoncConfigVal { get; set; } = ""; + + + [ForeignKey("DoorId")] + public virtual DoorModel? DoorNav { get; set; } + + [ForeignKey("DoorOpTypId")] + public virtual DoorOpTypeModel? DoorOpTypeNav { get; set; } + } +} diff --git a/WebDoorCreator.Data/DbModels/DoorOpTypeModel.cs b/WebDoorCreator.Data/DbModels/DoorOpTypeModel.cs new file mode 100644 index 0000000..a53f244 --- /dev/null +++ b/WebDoorCreator.Data/DbModels/DoorOpTypeModel.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace WebDoorCreator.Data.DbModels +{ + /// + /// Tabella dati Door Operation Type (astratte) + /// + [Table("DoorOpType")] + public class DoorOpTypeModel + { + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int DoorOpTypId { get; set; } + + /// + /// Codice univoco dell'operazione da svolgere (calcolato, idealmente 4 char da 36 val 0..Z) + /// + public string OpCode { get; set; } = ""; + + /// + /// Descrizione + /// + public string Description { get; set; } = ""; + + /// + /// Indica se ci sia un hardware correlato all'operazione + /// + public bool HasHw { get; set; } = true; + + /// + /// Indica se sia un oggetto concreto (= con un file, che si può produrre) o abstract (ha figli, è un gruppo logico) + /// + public bool IsConcrete { get; set; } = true; + + /// + /// Codice dell'HW collegato + /// + public string HwCode { get; set; } = ""; + + /// + /// Descrizione dell'HW collegato + /// + public string HwDescription { get; set; } = ""; + + /// + /// Path folder/file di riferimento + /// + public string FPath { get; set; } = ""; + + /// + /// Idx univoco dell'elemento parent (se 0 = root) + /// + public int ParentDoorOpId { get; set; } = 0; + + /// + /// Codice tipo treeView + /// + public string TreeCode { get; set; } = ""; + + /// + /// Oggetto Json per specifica configurazione (template) + /// + public string JsoncConfig { get; set; } = ""; + + /// + /// Codice esterno (opzionale) + /// + public string ExtOpCode { get; set; } = ""; + + /// + /// Descrizione esterna (opzionale) + /// + public string ExtDescript { get; set; } = ""; + + /// + /// Revisione dell'item + /// + public string Rev { get; set; } = ""; + + /// + /// Inizio validità item + /// + public DateTime ValidFrom { get; set; } = new DateTime(2000, 1, 1); + + /// + /// Fine validità item + /// + public DateTime ValidUntil { get; set; } = new DateTime(3000, 1, 1); + + /// + /// Check validità item + /// + [NotMapped] + public bool IsActive + { + get => DateTime.Today >= ValidFrom && DateTime.Today <= ValidUntil; + } + +#if false + [ForeignKey("ParentDoorOpId")] + public virtual DoorOpTypeModel? ParentNav { get; set; } +#endif + } +} diff --git a/WebDoorCreator.Data/DbModels/DoorTypeModel.cs b/WebDoorCreator.Data/DbModels/DoorTypeModel.cs index 624cae5..c219731 100644 --- a/WebDoorCreator.Data/DbModels/DoorTypeModel.cs +++ b/WebDoorCreator.Data/DbModels/DoorTypeModel.cs @@ -12,7 +12,7 @@ using System.Threading.Tasks; namespace WebDoorCreator.Data.DbModels { /// - /// Tabella dati Orders + /// Tabella dati Door Type /// [Table("DoorType")] public class DoorTypeModel diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230322163704_DoorOpModelCreation.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230322163704_DoorOpModelCreation.Designer.cs new file mode 100644 index 0000000..c8b72ff --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230322163704_DoorOpModelCreation.Designer.cs @@ -0,0 +1,635 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230322163704_DoorOpModelCreation")] + partial class DoorOpModelCreation + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentDoorOpId") + .HasColumnType("int"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TreeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230322163704_DoorOpModelCreation.cs b/WebDoorCreator.Data/Migrations/WDCData/20230322163704_DoorOpModelCreation.cs new file mode 100644 index 0000000..6c7e23d --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230322163704_DoorOpModelCreation.cs @@ -0,0 +1,91 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class DoorOpModelCreation : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "DoorOpType", + columns: table => new + { + DoorOpTypId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + OpCode = table.Column(type: "nvarchar(max)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + HasHw = table.Column(type: "bit", nullable: false), + IsConcrete = table.Column(type: "bit", nullable: false), + HwCode = table.Column(type: "nvarchar(max)", nullable: false), + HwDescription = table.Column(type: "nvarchar(max)", nullable: false), + FPath = table.Column(type: "nvarchar(max)", nullable: false), + ParentDoorOpId = table.Column(type: "int", nullable: false), + TreeCode = table.Column(type: "nvarchar(max)", nullable: false), + JsoncConfig = table.Column(type: "nvarchar(max)", nullable: false), + ExtOpCode = table.Column(type: "nvarchar(max)", nullable: false), + ExtDescript = table.Column(type: "nvarchar(max)", nullable: false), + Rev = table.Column(type: "nvarchar(max)", nullable: false), + ValidFrom = table.Column(type: "datetime2", nullable: false), + ValidUntil = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DoorOpType", x => x.DoorOpTypId); + }); + + migrationBuilder.CreateTable( + name: "DoorOp", + columns: table => new + { + DoorOpId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + DoorId = table.Column(type: "int", nullable: false), + DoorOpTypId = table.Column(type: "int", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + DateIns = table.Column(type: "datetime2", nullable: false), + UserIdIns = table.Column(type: "nvarchar(max)", nullable: false), + DateMod = table.Column(type: "datetime2", nullable: false), + UserIdMod = table.Column(type: "nvarchar(max)", nullable: false), + JsoncConfigVal = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DoorOp", x => x.DoorOpId); + table.ForeignKey( + name: "FK_DoorOp_Door_DoorId", + column: x => x.DoorId, + principalTable: "Door", + principalColumn: "DoorId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_DoorOp_DoorOpType_DoorOpTypId", + column: x => x.DoorOpTypId, + principalTable: "DoorOpType", + principalColumn: "DoorOpTypId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_DoorOp_DoorId", + table: "DoorOp", + column: "DoorId"); + + migrationBuilder.CreateIndex( + name: "IX_DoorOp_DoorOpTypId", + table: "DoorOp", + column: "DoorOpTypId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "DoorOp"); + + migrationBuilder.DropTable( + name: "DoorOpType"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs index f58247e..3b8d19c 100644 --- a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs +++ b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs @@ -228,6 +228,119 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.ToTable("Door"); }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentDoorOpId") + .HasColumnType("int"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TreeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => { b.Property("TypeId") @@ -485,6 +598,25 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.Navigation("TypeNav"); }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => { b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") diff --git a/WebDoorCreator.Data/WDCDataContext.cs b/WebDoorCreator.Data/WDCDataContext.cs index e663ae1..1ca735a 100644 --- a/WebDoorCreator.Data/WDCDataContext.cs +++ b/WebDoorCreator.Data/WDCDataContext.cs @@ -67,6 +67,9 @@ namespace WebDoorCreator.Data public virtual DbSet DbSetUsersView { get; set; } = null!; public virtual DbSet DbSetValues { get; set; } = null!; + public virtual DbSet DbSetDoorOpType { get; set; } = null!; + public virtual DbSet DbSetDoorOp { get; set; } = null!; + #endregion Public Properties #region Public Methods @@ -128,8 +131,23 @@ namespace WebDoorCreator.Data modelBuilder.Entity().HasKey(c => new { c.UserId, c.RoleId }); modelBuilder.Entity().HasKey(c => new { c.UserId, c.RoleId }); modelBuilder.Entity().HasKey(c => new { c.TableName, c.FieldName, c.value }); + +#if false + // gestione onCascade DoorOp <--> parent + modelBuilder.Entity().HasOne(e => e.ParentNav).WithOne(e => e.ParentNav).OnDelete(DeleteBehavior.NoAction); +#endif + // verifico SE devo eseguire la migration del DB IDENT... - bool disableMigrate = _configuration.GetValue("SetupOpt:DisableWDCMigrate"); + bool disableMigrate = false; + if (_configuration != null && _configuration.GetValue("SetupOpt:DisableWDCMigrate") != null) + { + try + { + _configuration.GetValue("SetupOpt:DisableWDCMigrate"); + } + catch + { } + } if (!disableMigrate) { modelBuilder.ApplyConfiguration(new ListValuesConfiguration()); diff --git a/WebDoorCreator.UI/Pages/Index.razor b/WebDoorCreator.UI/Pages/Index.razor index 7293567..baa924b 100644 --- a/WebDoorCreator.UI/Pages/Index.razor +++ b/WebDoorCreator.UI/Pages/Index.razor @@ -2,9 +2,8 @@ Index -
- +
-

Web Door Creator

+
Web Door Creator
\ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/Index.razor.css b/WebDoorCreator.UI/Pages/Index.razor.css index e58d54c..04befb6 100644 --- a/WebDoorCreator.UI/Pages/Index.razor.css +++ b/WebDoorCreator.UI/Pages/Index.razor.css @@ -15,7 +15,7 @@ color: #DEDEDE; background-image: linear-gradient(to right, rgba(30, 30, 30, 0.9), rgba(255, 255, 255, 0.1)); width: 100%; - height: 7rem; + height: 5rem; display: flex; flex-wrap: wrap; align-items: end; diff --git a/WebDoorCreator.UI/Pages/Index.razor.less b/WebDoorCreator.UI/Pages/Index.razor.less index d425ba3..111d2cf 100644 --- a/WebDoorCreator.UI/Pages/Index.razor.less +++ b/WebDoorCreator.UI/Pages/Index.razor.less @@ -13,7 +13,7 @@ color: #DEDEDE; background-image: linear-gradient(to right, rgba(30,30,30,0.9), rgba(255,255,255,0.1)); width: 100%; - height: 7rem; + height: 5rem; display: flex; flex-wrap: wrap; align-items: end; diff --git a/WebDoorCreator.UI/Pages/Index.razor.min.css b/WebDoorCreator.UI/Pages/Index.razor.min.css index 1cac8d3..9e5b8bb 100644 --- a/WebDoorCreator.UI/Pages/Index.razor.min.css +++ b/WebDoorCreator.UI/Pages/Index.razor.min.css @@ -1 +1 @@ -.bgbg{background-image:url("images/DOORBG.png");background-position:center;background-repeat:no-repeat;background-size:cover;height:45rem;display:flex;flex-wrap:wrap;align-items:end;}.transpLayer{color:#dedede;background-image:linear-gradient(to right,rgba(30,30,30,.9),rgba(255,255,255,.1));width:100%;height:7rem;display:flex;flex-wrap:wrap;align-items:end;} \ No newline at end of file +.bgbg{background-image:url("images/DOORBG.png");background-position:center;background-repeat:no-repeat;background-size:cover;height:45rem;display:flex;flex-wrap:wrap;align-items:end;}.transpLayer{color:#dedede;background-image:linear-gradient(to right,rgba(30,30,30,.9),rgba(255,255,255,.1));width:100%;height:5rem;display:flex;flex-wrap:wrap;align-items:end;} \ No newline at end of file From 4d0994b0d524d3b49976abbf921c03dda5a348ff Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Thu, 23 Mar 2023 17:19:56 +0100 Subject: [PATCH 05/43] predisposizione hierarchyID --- .../DbModels/DoorOpTypeModel.cs | 13 +- WebDoorCreator.Data/DbModels/HardwareModel.cs | 29 + WebDoorCreator.Data/DoorOpConfiguration.cs | 46 ++ .../20230323075059_DoorOpMigr.Designer.cs | 649 ++++++++++++++++++ .../WDCData/20230323075059_DoorOpMigr.cs | 36 + .../WDCData/WDCDataContextModelSnapshot.cs | 14 + WebDoorCreator.Data/WDCDataContext.cs | 6 +- WebDoorCreator.UI/WebDoorCreator.UI.csproj | 1 + 8 files changed, 789 insertions(+), 5 deletions(-) create mode 100644 WebDoorCreator.Data/DbModels/HardwareModel.cs create mode 100644 WebDoorCreator.Data/DoorOpConfiguration.cs create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230323075059_DoorOpMigr.Designer.cs create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230323075059_DoorOpMigr.cs diff --git a/WebDoorCreator.Data/DbModels/DoorOpTypeModel.cs b/WebDoorCreator.Data/DbModels/DoorOpTypeModel.cs index a53f244..619a224 100644 --- a/WebDoorCreator.Data/DbModels/DoorOpTypeModel.cs +++ b/WebDoorCreator.Data/DbModels/DoorOpTypeModel.cs @@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; // // This is here so CodeMaid doesn't reorganize this document @@ -54,16 +55,24 @@ namespace WebDoorCreator.Data.DbModels /// Path folder/file di riferimento /// public string FPath { get; set; } = ""; +#if false /// /// Idx univoco dell'elemento parent (se 0 = root) /// - public int ParentDoorOpId { get; set; } = 0; + public int ParentDoorOpId { get; set; } = 0; /// /// Codice tipo treeView /// public string TreeCode { get; set; } = ""; +#endif + + /// + /// Idx univoco dell'elemento parent (se 0 = root) + /// + public HierarchyId? DoorOpIdPathFromPatriarch { get; set; } + /// /// Oggetto Json per specifica configurazione (template) @@ -106,7 +115,7 @@ namespace WebDoorCreator.Data.DbModels #if false [ForeignKey("ParentDoorOpId")] - public virtual DoorOpTypeModel? ParentNav { get; set; } + public virtual DoorOpModel? ParentNav { get; set; } #endif } } diff --git a/WebDoorCreator.Data/DbModels/HardwareModel.cs b/WebDoorCreator.Data/DbModels/HardwareModel.cs new file mode 100644 index 0000000..6e4554b --- /dev/null +++ b/WebDoorCreator.Data/DbModels/HardwareModel.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace WebDoorCreator.Data.DbModels +{ + /// + /// Tabella dati Hardware + /// + [Table("Hardware")] + public class HardwareModel + { + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int DoorOpTypId { get; set; } + + /// + /// Codice univoco dell'operazione da svolgere (calcolato, idealmente 4 char da 36 val 0..Z) + /// + public string OpCode { get; set; } = ""; + } +} diff --git a/WebDoorCreator.Data/DoorOpConfiguration.cs b/WebDoorCreator.Data/DoorOpConfiguration.cs new file mode 100644 index 0000000..cacf123 --- /dev/null +++ b/WebDoorCreator.Data/DoorOpConfiguration.cs @@ -0,0 +1,46 @@ +using Microsoft.AspNetCore.Identity; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using WebDoorCreator.Data.DbModels; + +namespace WebDoorCreator.Data +{ + public class DoorOpConfiguration : IEntityTypeConfiguration + { + + + #region Public Methods + + public void Configure(EntityTypeBuilder builder) + { + + // Default seeded users + builder.HasData( + ); + } + + #endregion Public Methods + + #region Protected Fields + + #endregion Protected Fields + + #region Protected Methods + + protected IdentityUser getNewUser(string email, string passwd) + { + var newRec = new IdentityUser + { + UserName = email, + NormalizedUserName = email.ToUpper(), + Email = email, + NormalizedEmail = email.ToUpper(), + EmailConfirmed = true, + PasswordHash = hasher.HashPassword(null!, passwd), + }; + return newRec; + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230323075059_DoorOpMigr.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230323075059_DoorOpMigr.Designer.cs new file mode 100644 index 0000000..07df1ad --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230323075059_DoorOpMigr.Designer.cs @@ -0,0 +1,649 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230323075059_DoorOpMigr")] + partial class DoorOpMigr + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentDoorOpId") + .HasColumnType("int"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TreeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.HasIndex("ParentDoorOpId") + .IsUnique(); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpModel", "ParentNav") + .WithOne() + .HasForeignKey("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "ParentDoorOpId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("ParentNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230323075059_DoorOpMigr.cs b/WebDoorCreator.Data/Migrations/WDCData/20230323075059_DoorOpMigr.cs new file mode 100644 index 0000000..312cd75 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230323075059_DoorOpMigr.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class DoorOpMigr : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_DoorOpType_ParentDoorOpId", + table: "DoorOpType", + column: "ParentDoorOpId", + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_DoorOpType_DoorOp_ParentDoorOpId", + table: "DoorOpType", + column: "ParentDoorOpId", + principalTable: "DoorOp", + principalColumn: "DoorOpId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_DoorOpType_DoorOp_ParentDoorOpId", + table: "DoorOpType"); + + migrationBuilder.DropIndex( + name: "IX_DoorOpType_ParentDoorOpId", + table: "DoorOpType"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs index 3b8d19c..339a0b2 100644 --- a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs +++ b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs @@ -338,6 +338,9 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasKey("DoorOpTypId"); + b.HasIndex("ParentDoorOpId") + .IsUnique(); + b.ToTable("DoorOpType"); }); @@ -617,6 +620,17 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.Navigation("DoorOpTypeNav"); }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpModel", "ParentNav") + .WithOne() + .HasForeignKey("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "ParentDoorOpId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("ParentNav"); + }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => { b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") diff --git a/WebDoorCreator.Data/WDCDataContext.cs b/WebDoorCreator.Data/WDCDataContext.cs index 1ca735a..45b1601 100644 --- a/WebDoorCreator.Data/WDCDataContext.cs +++ b/WebDoorCreator.Data/WDCDataContext.cs @@ -108,7 +108,7 @@ namespace WebDoorCreator.Data } else { - optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=WebDoorCreator;Trusted_Connection=True;"); + optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=WebDoorCreator;Trusted_Connection=True;", e=>e.UseHierarchyId()); } } } @@ -132,9 +132,9 @@ namespace WebDoorCreator.Data modelBuilder.Entity().HasKey(c => new { c.UserId, c.RoleId }); modelBuilder.Entity().HasKey(c => new { c.TableName, c.FieldName, c.value }); -#if false // gestione onCascade DoorOp <--> parent - modelBuilder.Entity().HasOne(e => e.ParentNav).WithOne(e => e.ParentNav).OnDelete(DeleteBehavior.NoAction); + //modelBuilder.Entity().HasOne(e => e.ParentNav).WithOne().OnDelete(DeleteBehavior.NoAction); +#if false #endif // verifico SE devo eseguire la migration del DB IDENT... diff --git a/WebDoorCreator.UI/WebDoorCreator.UI.csproj b/WebDoorCreator.UI/WebDoorCreator.UI.csproj index 660abd9..c23d9ee 100644 --- a/WebDoorCreator.UI/WebDoorCreator.UI.csproj +++ b/WebDoorCreator.UI/WebDoorCreator.UI.csproj @@ -16,6 +16,7 @@ + From 168a1589699c7c2ae014488a283f9c72e7202cc4 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Tue, 28 Mar 2023 17:02:05 +0200 Subject: [PATCH 06/43] inizio lettura file ini --- WebDoorCreator.Core/IniFile.cs | 112 +++ .../WebDoorCreator.Core.csproj | 1 + .../DbModels/GraphicParamsModel.cs | 59 ++ WebDoorCreator.Data/DbModels/HardwareModel.cs | 20 +- WebDoorCreator.Data/DoorOpConfiguration.cs | 29 +- .../20230328135646_HWHandle.Designer.cs | 699 ++++++++++++++++++ .../WDCData/20230328135646_HWHandle.cs | 110 +++ .../WDCData/WDCDataContextModelSnapshot.cs | 92 ++- WebDoorCreator.Data/WDCDataContext.cs | 2 + .../WebDoorCreator.Data.csproj | 1 + .../Components/Gen/NavMenuHorizontal.razor.cs | 1 + .../Data/WebDoorCreatorService.cs | 126 +++- 12 files changed, 1211 insertions(+), 41 deletions(-) create mode 100644 WebDoorCreator.Core/IniFile.cs create mode 100644 WebDoorCreator.Data/DbModels/GraphicParamsModel.cs create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230328135646_HWHandle.Designer.cs create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230328135646_HWHandle.cs diff --git a/WebDoorCreator.Core/IniFile.cs b/WebDoorCreator.Core/IniFile.cs new file mode 100644 index 0000000..5bf73a2 --- /dev/null +++ b/WebDoorCreator.Core/IniFile.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace WebDoorCreator.Core +{ + public class IniFile + { + public string FileName; + + /// + /// Constructor + /// + /// + public IniFile(string INIPath) + { + FileName = INIPath; + } + + /// + /// Read data from the Ini file + /// + /// + /// + /// + public string ReadString(string Section, string Key) + { + StringBuilder temp = new StringBuilder(255); + int i = GetPrivateProfileString(Section, Key, "", temp, 255, FileName); + return temp.ToString(); + } + + /// + /// Read a string. If not found use default value + /// + /// + /// + /// + /// + public string ReadString(string Section, string Key, string DefaultVal) + { + string temp = ReadString(Section, Key); + if (temp == "") temp = DefaultVal; + return temp; + } + + /// + /// GetPrivateProfileString: import windows dll functions + /// + /// + /// + /// + /// + /// + /// + /// + [DllImport("kernel32")] + private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); + + /// + /// GetPrivateProfileSection: import windows dll functions + /// + /// + /// + /// + /// + /// + [DllImport("kernel32")] + private static extern int GetPrivateProfileSection(string section, IntPtr retVal, uint size, string filePath); + + /// + /// Read a complete section (keys=values) + /// + /// + /// Section name + /// + /// restituisce delle stringhe keys=values da suddividere appunto come key/val successivamente + /// + public string[] ReadSection(string Section) + { + const int bufferSize = 2048; // max is 32767 + + StringBuilder returnedString = new StringBuilder(); + + IntPtr pReturnedString = Marshal.AllocCoTaskMem(bufferSize); + try + { + int bytesReturned = GetPrivateProfileSection(Section, pReturnedString, bufferSize, FileName); + if (bytesReturned > 0) + { + //bytesReturned -1 to remove trailing \0 + for (int i = 0; i < bytesReturned - 1; i++) + { + var currPointer = IntPtr.Add(pReturnedString, i); + var currChar = (char)Marshal.ReadByte(currPointer); + returnedString.Append(currChar); + } + } + } + finally + { + Marshal.FreeCoTaskMem(pReturnedString); + } + + string sectionData = returnedString.ToString(); + return sectionData.Split('\0'); + } + } +} diff --git a/WebDoorCreator.Core/WebDoorCreator.Core.csproj b/WebDoorCreator.Core/WebDoorCreator.Core.csproj index 1f04627..969c0c7 100644 --- a/WebDoorCreator.Core/WebDoorCreator.Core.csproj +++ b/WebDoorCreator.Core/WebDoorCreator.Core.csproj @@ -7,6 +7,7 @@ + diff --git a/WebDoorCreator.Data/DbModels/GraphicParamsModel.cs b/WebDoorCreator.Data/DbModels/GraphicParamsModel.cs new file mode 100644 index 0000000..8c4dde8 --- /dev/null +++ b/WebDoorCreator.Data/DbModels/GraphicParamsModel.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace WebDoorCreator.Data.DbModels +{ + /// + /// Tabella dati Hardware + /// + [Table("GraphicParams")] + public class GraphicParamsModel + { + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int GraphicParamId { get; set; } + + /// + /// Id del componente di riferimento + /// + public int compoId { get; set; } = 0; + + /// + /// Testata del gruppo di parametri + /// + public string graphicParamsN { get; set; } = ""; + + /// + /// Titolo del parametro + /// + public string graphicParamKey { get; set; } = ""; + + /// + /// Nome del parametro scritto nel file DDF + /// + public string graphicParamName { get; set; } = ""; + + /// + /// Nome del parametro visualizzato dall'utente + /// + public string graphicParamAlias { get; set; } = ""; + + /// + /// Tipo del parametro + /// + public string graphicParamType { get; set; } = ""; + + /// + /// Tipo del parametro + /// + public string graphicParamDefaultVal { get; set; } = ""; + } +} diff --git a/WebDoorCreator.Data/DbModels/HardwareModel.cs b/WebDoorCreator.Data/DbModels/HardwareModel.cs index 6e4554b..53da97e 100644 --- a/WebDoorCreator.Data/DbModels/HardwareModel.cs +++ b/WebDoorCreator.Data/DbModels/HardwareModel.cs @@ -18,12 +18,24 @@ namespace WebDoorCreator.Data.DbModels [Table("Hardware")] public class HardwareModel { - [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int DoorOpTypId { get; set; } + [Key] + public int HardwareId { get; set; } /// - /// Codice univoco dell'operazione da svolgere (calcolato, idealmente 4 char da 36 val 0..Z) + /// Nome del componente che verrà scritto nel file DDF /// - public string OpCode { get; set; } = ""; + public string compoName { get; set; } = ""; + /// + /// Nome del componente che verrà visualizzato a schermo (pescato dal file di sinonimi) + /// + public string compoAlias { get; set; } = ""; + /// + /// Nome del layer legato al componente + /// + public string compoLayerName { get; set; } = ""; + /// + /// Indica se il il componente deve risultare utilizzabile dal cliente + /// + public bool compoTemplateIsActive { get; set; } = true; } } diff --git a/WebDoorCreator.Data/DoorOpConfiguration.cs b/WebDoorCreator.Data/DoorOpConfiguration.cs index cacf123..590fbbe 100644 --- a/WebDoorCreator.Data/DoorOpConfiguration.cs +++ b/WebDoorCreator.Data/DoorOpConfiguration.cs @@ -15,8 +15,7 @@ namespace WebDoorCreator.Data { // Default seeded users - builder.HasData( - ); + } #endregion Public Methods @@ -27,19 +26,19 @@ namespace WebDoorCreator.Data #region Protected Methods - protected IdentityUser getNewUser(string email, string passwd) - { - var newRec = new IdentityUser - { - UserName = email, - NormalizedUserName = email.ToUpper(), - Email = email, - NormalizedEmail = email.ToUpper(), - EmailConfirmed = true, - PasswordHash = hasher.HashPassword(null!, passwd), - }; - return newRec; - } + //protected DoorOpModel getNewDoorOP(int DoorOpId, int DoorId, int DoorOpTypId, string Description, DateTime DateIns, string UserIdIns, DateTime DateMod, string UserIdMod, string JsoncConfigVal) + //{ + // var newRec = new IdentityUser + // { + // UserName = email, + // NormalizedUserName = email.ToUpper(), + // Email = email, + // NormalizedEmail = email.ToUpper(), + // EmailConfirmed = true, + // PasswordHash = hasher.HashPassword(null!, passwd), + // }; + // return newRec; + //} #endregion Protected Methods } diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230328135646_HWHandle.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230328135646_HWHandle.Designer.cs new file mode 100644 index 0000000..dcab92a --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230328135646_HWHandle.Designer.cs @@ -0,0 +1,699 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230328135646_HWHandle")] + partial class HWHandle + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorOpIdPathFromPatriarch") + .HasColumnType("hierarchyid"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => + { + b.Property("GraphicParamId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GraphicParamId"), 1L, 1); + + b.Property("compoId") + .HasColumnType("int"); + + b.Property("graphicParamAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamDefaultVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamsN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("GraphicParamId"); + + b.ToTable("GraphicParams"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => + { + b.Property("HardwareId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("HardwareId"), 1L, 1); + + b.Property("compoAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoLayerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoTemplateIsActive") + .HasColumnType("bit"); + + b.HasKey("HardwareId"); + + b.ToTable("Hardware"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230328135646_HWHandle.cs b/WebDoorCreator.Data/Migrations/WDCData/20230328135646_HWHandle.cs new file mode 100644 index 0000000..28cd089 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230328135646_HWHandle.cs @@ -0,0 +1,110 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class HWHandle : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_DoorOpType_DoorOp_ParentDoorOpId", + table: "DoorOpType"); + + migrationBuilder.DropIndex( + name: "IX_DoorOpType_ParentDoorOpId", + table: "DoorOpType"); + + migrationBuilder.DropColumn( + name: "ParentDoorOpId", + table: "DoorOpType"); + + migrationBuilder.DropColumn( + name: "TreeCode", + table: "DoorOpType"); + + migrationBuilder.AddColumn( + name: "DoorOpIdPathFromPatriarch", + table: "DoorOpType", + type: "hierarchyid", + nullable: true); + + migrationBuilder.CreateTable( + name: "GraphicParams", + columns: table => new + { + GraphicParamId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + compoId = table.Column(type: "int", nullable: false), + graphicParamsN = table.Column(type: "nvarchar(max)", nullable: false), + graphicParamKey = table.Column(type: "nvarchar(max)", nullable: false), + graphicParamName = table.Column(type: "nvarchar(max)", nullable: false), + graphicParamAlias = table.Column(type: "nvarchar(max)", nullable: false), + graphicParamType = table.Column(type: "nvarchar(max)", nullable: false), + graphicParamDefaultVal = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GraphicParams", x => x.GraphicParamId); + }); + + migrationBuilder.CreateTable( + name: "Hardware", + columns: table => new + { + HardwareId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + compoName = table.Column(type: "nvarchar(max)", nullable: false), + compoAlias = table.Column(type: "nvarchar(max)", nullable: false), + compoLayerName = table.Column(type: "nvarchar(max)", nullable: false), + compoTemplateIsActive = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Hardware", x => x.HardwareId); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "GraphicParams"); + + migrationBuilder.DropTable( + name: "Hardware"); + + migrationBuilder.DropColumn( + name: "DoorOpIdPathFromPatriarch", + table: "DoorOpType"); + + migrationBuilder.AddColumn( + name: "ParentDoorOpId", + table: "DoorOpType", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TreeCode", + table: "DoorOpType", + type: "nvarchar(max)", + nullable: false, + defaultValue: ""); + + migrationBuilder.CreateIndex( + name: "IX_DoorOpType_ParentDoorOpId", + table: "DoorOpType", + column: "ParentDoorOpId", + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_DoorOpType_DoorOp_ParentDoorOpId", + table: "DoorOpType", + column: "ParentDoorOpId", + principalTable: "DoorOp", + principalColumn: "DoorOpId"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs index 339a0b2..99f06d9 100644 --- a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs +++ b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs @@ -285,6 +285,9 @@ namespace WebDoorCreator.Data.Migrations.WDCData .IsRequired() .HasColumnType("nvarchar(max)"); + b.Property("DoorOpIdPathFromPatriarch") + .HasColumnType("hierarchyid"); + b.Property("ExtDescript") .IsRequired() .HasColumnType("nvarchar(max)"); @@ -319,17 +322,10 @@ namespace WebDoorCreator.Data.Migrations.WDCData .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("ParentDoorOpId") - .HasColumnType("int"); - b.Property("Rev") .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("TreeCode") - .IsRequired() - .HasColumnType("nvarchar(max)"); - b.Property("ValidFrom") .HasColumnType("datetime2"); @@ -338,9 +334,6 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasKey("DoorOpTypId"); - b.HasIndex("ParentDoorOpId") - .IsUnique(); - b.ToTable("DoorOpType"); }); @@ -365,6 +358,74 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.ToTable("DoorType"); }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => + { + b.Property("GraphicParamId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GraphicParamId"), 1L, 1); + + b.Property("compoId") + .HasColumnType("int"); + + b.Property("graphicParamAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamDefaultVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamsN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("GraphicParamId"); + + b.ToTable("GraphicParams"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => + { + b.Property("HardwareId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("HardwareId"), 1L, 1); + + b.Property("compoAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoLayerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoTemplateIsActive") + .HasColumnType("bit"); + + b.HasKey("HardwareId"); + + b.ToTable("Hardware"); + }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => { b.Property("TableName") @@ -620,17 +681,6 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.Navigation("DoorOpTypeNav"); }); - modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => - { - b.HasOne("WebDoorCreator.Data.DbModels.DoorOpModel", "ParentNav") - .WithOne() - .HasForeignKey("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "ParentDoorOpId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.Navigation("ParentNav"); - }); - modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => { b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") diff --git a/WebDoorCreator.Data/WDCDataContext.cs b/WebDoorCreator.Data/WDCDataContext.cs index 45b1601..4b2bc3b 100644 --- a/WebDoorCreator.Data/WDCDataContext.cs +++ b/WebDoorCreator.Data/WDCDataContext.cs @@ -69,6 +69,8 @@ namespace WebDoorCreator.Data public virtual DbSet DbSetDoorOpType { get; set; } = null!; public virtual DbSet DbSetDoorOp { get; set; } = null!; + public virtual DbSet DbSetHardware { get; set; } = null!; + public virtual DbSet DbSetGraphicParams { get; set; } = null!; #endregion Public Properties diff --git a/WebDoorCreator.Data/WebDoorCreator.Data.csproj b/WebDoorCreator.Data/WebDoorCreator.Data.csproj index 12c8b7f..3b29502 100644 --- a/WebDoorCreator.Data/WebDoorCreator.Data.csproj +++ b/WebDoorCreator.Data/WebDoorCreator.Data.csproj @@ -13,6 +13,7 @@ + diff --git a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs index 1e643c9..11f2992 100644 --- a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs +++ b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs @@ -148,6 +148,7 @@ namespace WebDoorCreator.UI.Components.Gen protected override async Task OnInitializedAsync() { await Task.Delay(1); + await WDCService.SetAllCompoList(@"C:\EgtData\Doors\EgtCompoBase\Compo"); WDCUService.EA_UserClaims += OnNewUserClaims; WDCUService.EA_UserCurrCompany += OnNewUserCurrComp; } diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index cbaf4d6..fd4e252 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -6,6 +6,8 @@ using StackExchange.Redis; using System.Diagnostics; using WebDoorCreator.Data.Controllers; using WebDoorCreator.Data.DbModels; +using WebDoorCreator.Core; +using System.Security.AccessControl; namespace WebDoorCreator.UI.Data { @@ -60,7 +62,7 @@ namespace WebDoorCreator.UI.Data #region Company methods - + /// /// Company list filtered by company id /// @@ -558,6 +560,128 @@ namespace WebDoorCreator.UI.Data #endregion ListValues Methods + /*----------------------------------------------------------------------------------------------------------------------*/ + + #region IniFiles Methods + + + /// + /// Getting a list of all the active components + /// + /// Path to start + /// + public async Task> GetAllActiveCompo(string rootPath) + { + await Task.Delay(1); + List listActiveCompo = new List(); + + //estraggo la lista di componenti che sono attive per il cliente + IniFile fIni = new IniFile(rootPath); + string compoDDF = fIni.ReadString("CompoOrder", "CompoDDFOrder", "CONFIG"); + var compoDDFList = compoDDF.Split(","); + foreach (string compo in compoDDFList) + { + listActiveCompo.Add(compo.Trim()); + } + + return listActiveCompo; + } + /// + /// Getting a list of all the active components + /// + /// Path to start + /// + public async Task> SetGraphicParams(string file, string match, int n, int i) + { + await Task.Delay(1); + List listGraphicParams = new List(); + + IniFile fIni = new IniFile(file); + //estraggo la lista di componenti che sono attive per il cliente + var graphicParamsName = fIni.ReadSection(match.Substring(1, match.Length - 2)); //cerco il contenuto delle sezioni + if (int.Parse(match.Substring(match.Length - 2, 1)) == n) //controllo se tra i numeri di graphic params vi è un buco ES: Graphic parameters1 Graphic parameters3 se il buco c'è salto tutti i parametri che stanno dopo il buco ==> tengo conto solo di Graphic parameters1 + { + 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(";"); + if (param.Split("=")[0].StartsWith("Param")) + { + + 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] }; + listGraphicParams.Add(graphicParams); //creo nuovo oggetto parametro che conterrà anche il nome del componente per creare relazione + } + else + { + GraphicParamsModel graphicParams = new GraphicParamsModel() { compoId = i, graphicParamsN = match.Substring(1, match.Length - 2), graphicParamKey = param.Split("=")[0], graphicParamName = compoParams }; + listGraphicParams.Add(graphicParams); //creo nuovo oggetto parametro che conterrà anche il nome del componente per creare relazione + } + } + } + + return listGraphicParams; + } + + + /// + /// Getting a list of all the active components + /// + /// Path to start + /// + public async Task SetAllCompoList(string rootPath) + { + bool fatto = false; + string compoName = ""; + int n = 1; + int i = 1; + List listActiveCompo = await GetAllActiveCompo(Path.Combine(rootPath, @"Default.ini")); + List listCompoS = new List(); + //estraggo tutte le sotto directory della cartella \EgtData\Doors\EgtCompoBase\Compo + string[] dirs = Directory.GetDirectories(rootPath, "*", SearchOption.TopDirectoryOnly); + + foreach (string dir in dirs) + { + string[] files = Directory.GetFiles(dir, "Config.ini"); //iterazione per cercare tutti i file "Config.ini" nelle sotto directory + + compoName = ""; + foreach (string file in files) //iterazione per cercare tutti i file "Config.ini" nelle sotto directory + { + List lines = File.ReadAllLines(file).ToList(); //leggo tutte le linee del file + List listGraphicParams = new List(); + IniFile fIni = new IniFile(file); + 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; + string layerName = fIni.ReadString("Layer", "LayerName", "LAYER"); + if (isActive == "0") + { + compoTemplateIsActive = false; + } + 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) + 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 + n = 1; + foreach (var match in lineToSearch) + { + listGraphicParams = await SetGraphicParams(file, match, n, i); + n++; + } + + } + i++; + } + + } + + return fatto; + } + + #endregion IniFiles Methods + #endregion Public Methods #region Protected Fields From 38b5412230af621bc10b8f7a14b89198e706a349 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Tue, 28 Mar 2023 17:27:57 +0200 Subject: [PATCH 07/43] fix funzioni per gestione file ini --- WebDoorCreator.UI/Data/WebDoorCreatorService.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index fd4e252..a8b560d 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -625,7 +625,7 @@ namespace WebDoorCreator.UI.Data /// - /// Getting a list of all the active components + /// Setting all the component list /// /// Path to start /// @@ -635,6 +635,7 @@ namespace WebDoorCreator.UI.Data string compoName = ""; int n = 1; int i = 1; + List listGraphicParams = new List(); List listActiveCompo = await GetAllActiveCompo(Path.Combine(rootPath, @"Default.ini")); List listCompoS = new List(); //estraggo tutte le sotto directory della cartella \EgtData\Doors\EgtCompoBase\Compo @@ -648,7 +649,6 @@ namespace WebDoorCreator.UI.Data foreach (string file in files) //iterazione per cercare tutti i file "Config.ini" nelle sotto directory { List lines = File.ReadAllLines(file).ToList(); //leggo tutte le linee del file - List listGraphicParams = new List(); IniFile fIni = new IniFile(file); 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 @@ -670,7 +670,6 @@ namespace WebDoorCreator.UI.Data listGraphicParams = await SetGraphicParams(file, match, n, i); n++; } - } i++; } From 3c2a59215ae43cd8f0478ff0b991eeefe6edf1fe Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Wed, 29 Mar 2023 10:40:24 +0200 Subject: [PATCH 08/43] fix gestione refresh componenti --- .../Controllers/WebDoorCreatorController.cs | 30 +++++++++++++++++++ WebDoorCreator.Data/WDCDataContext.cs | 2 +- .../Components/Gen/NavMenuHorizontal.razor.cs | 2 +- .../Data/WebDoorCreatorService.cs | 2 ++ WebDoorCreator.UI/Pages/SuperAdmin.razor | 18 +++++++---- WebDoorCreator.UI/Pages/SuperAdmin.razor.cs | 9 ++++++ 6 files changed, 56 insertions(+), 7 deletions(-) diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index e227521..f9aaf12 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -479,5 +479,35 @@ namespace WebDoorCreator.Data.Controllers } #endregion ListValues Methods + + #region Components Methods + + /// + /// Adding a new Compo + /// + /// Record to add + /// + public async Task CompoAdd(HardwareModel addRec) + { + bool fatto = false; + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + localDbCtx + .DbSetHardware + .Add(addRec); + await localDbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante CompoAdd: {Environment.NewLine}{exc}"); + } + } + return fatto; + } + + #endregion Components Methods } } \ No newline at end of file diff --git a/WebDoorCreator.Data/WDCDataContext.cs b/WebDoorCreator.Data/WDCDataContext.cs index 4b2bc3b..0bfda7c 100644 --- a/WebDoorCreator.Data/WDCDataContext.cs +++ b/WebDoorCreator.Data/WDCDataContext.cs @@ -106,7 +106,7 @@ namespace WebDoorCreator.Data string connString = _configuration.GetConnectionString("WDC.DB"); if (!string.IsNullOrEmpty(connString)) { - optionsBuilder.UseSqlServer(connString); + optionsBuilder.UseSqlServer(connString, e => e.UseHierarchyId()); } else { diff --git a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs index 11f2992..67b55b2 100644 --- a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs +++ b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs @@ -145,10 +145,10 @@ namespace WebDoorCreator.UI.Components.Gen userCurrCompany = compToShow.CompanyId; } + protected override async Task OnInitializedAsync() { await Task.Delay(1); - await WDCService.SetAllCompoList(@"C:\EgtData\Doors\EgtCompoBase\Compo"); WDCUService.EA_UserClaims += OnNewUserClaims; WDCUService.EA_UserCurrCompany += OnNewUserCurrComp; } diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index a8b560d..ba70266 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -8,6 +8,7 @@ using WebDoorCreator.Data.Controllers; using WebDoorCreator.Data.DbModels; using WebDoorCreator.Core; using System.Security.AccessControl; +using WebDoorCreator.Data; namespace WebDoorCreator.UI.Data { @@ -662,6 +663,7 @@ namespace WebDoorCreator.UI.Data if (listActiveCompo.Contains(compoNameSplit[0].ToString())) { HardwareModel compoConfig = new HardwareModel() { compoName = compoNameSplit[0].ToString(), compoAlias = compoNameSplit[1].ToString(), 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 n = 1; diff --git a/WebDoorCreator.UI/Pages/SuperAdmin.razor b/WebDoorCreator.UI/Pages/SuperAdmin.razor index 91f9863..29dd330 100644 --- a/WebDoorCreator.UI/Pages/SuperAdmin.razor +++ b/WebDoorCreator.UI/Pages/SuperAdmin.razor @@ -4,13 +4,21 @@
-
-
- Company management +
+
+
+ Company management +
+
+ Users Management +
-
- Users Management +
+
+ + +
diff --git a/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs b/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs index d6c91b3..a164025 100644 --- a/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs +++ b/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs @@ -132,6 +132,10 @@ namespace WebDoorCreator.UI.Pages set { _passwordConfirm = value; } } + protected string _defaultPath = ""; + + protected string defaultPath { get; set; } = ""; + protected bool isCompShow { get; set; } = true; protected async Task addModNewCompany() @@ -285,5 +289,10 @@ namespace WebDoorCreator.UI.Pages await Task.Delay(1); isCompShow = false; } + protected async Task refreshHw() + { + await Task.Delay(1); + await WDService.SetAllCompoList(@$"{defaultPath}"); + } } } \ No newline at end of file From 0ed4fc5595dc2a7dadf3d33d7b0bf009683b100d Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Wed, 29 Mar 2023 10:51:22 +0200 Subject: [PATCH 09/43] aggiunta gestione compo params --- .../Controllers/WebDoorCreatorController.cs | 25 +++++++++++++++++++ .../Data/WebDoorCreatorService.cs | 10 ++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index f9aaf12..7e9fdfe 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -507,6 +507,31 @@ namespace WebDoorCreator.Data.Controllers } return fatto; } + /// + /// Adding a new graphic param + /// + /// Record to add + /// + public async Task ParamAdd(GraphicParamsModel addRec) + { + bool fatto = false; + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + localDbCtx + .DbSetGraphicParams + .Add(addRec); + await localDbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante ParamAdd: {Environment.NewLine}{exc}"); + } + } + return fatto; + } #endregion Components Methods } diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index ba70266..385bdd3 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -587,10 +587,14 @@ namespace WebDoorCreator.UI.Data return listActiveCompo; } + /// - /// Getting a list of all the active components + /// Setting the graphic parameters for components /// - /// Path to start + /// + /// + /// + /// /// public async Task> SetGraphicParams(string file, string match, int n, int i) { @@ -612,11 +616,13 @@ namespace WebDoorCreator.UI.Data 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] }; listGraphicParams.Add(graphicParams); //creo nuovo oggetto parametro che conterrà anche il nome del componente per creare relazione + await dbController.ParamAdd(graphicParams); } else { GraphicParamsModel graphicParams = new GraphicParamsModel() { compoId = i, graphicParamsN = match.Substring(1, match.Length - 2), graphicParamKey = param.Split("=")[0], graphicParamName = compoParams }; listGraphicParams.Add(graphicParams); //creo nuovo oggetto parametro che conterrà anche il nome del componente per creare relazione + await dbController.ParamAdd(graphicParams); } } } From fcff424770f65ab44a5af22f000a97e1effb465e Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Wed, 29 Mar 2023 13:04:47 +0200 Subject: [PATCH 10/43] inizio definizione automatica door types --- .../Controllers/WebDoorCreatorController.cs | 32 +++++++++++++++++++ .../DoorDef/DoorSizingStep.razor.cs | 2 ++ .../Data/WebDoorCreatorService.cs | 13 ++++++++ 3 files changed, 47 insertions(+) diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index 7e9fdfe..06637a4 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -507,6 +507,7 @@ namespace WebDoorCreator.Data.Controllers } return fatto; } + /// /// Adding a new graphic param /// @@ -534,5 +535,36 @@ namespace WebDoorCreator.Data.Controllers } #endregion Components Methods + + #region Door Operationm Methods + + + /// + /// Adding a new DoorOpType + /// + /// Record to add + /// + public async Task DoorOpTypeAdd(DoorOpTypeModel addRec) + { + bool fatto = false; + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + localDbCtx + .DbSetDoorOpType + .Add(addRec); + await localDbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante DoorOpTypeAdd: {Environment.NewLine}{exc}"); + } + } + return fatto; + } + + #endregion Door Operationm Methods } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs b/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs index dcdf55a..99c311a 100644 --- a/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs +++ b/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs @@ -57,6 +57,8 @@ namespace WebDoorCreator.UI.Components.DoorDef { ListSwings = await WDService.ListValuesGetAll("Opening", "Swing"); ListEdges = await WDService.ListValuesGetAll("Edges", "EdgeType"); + + } protected override async Task OnInitializedAsync() diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index 385bdd3..a05275c 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -9,6 +9,7 @@ using WebDoorCreator.Data.DbModels; using WebDoorCreator.Core; using System.Security.AccessControl; using WebDoorCreator.Data; +using Microsoft.EntityFrameworkCore; namespace WebDoorCreator.UI.Data { @@ -678,6 +679,18 @@ namespace WebDoorCreator.UI.Data listGraphicParams = await SetGraphicParams(file, match, n, i); n++; } + + DoorOpTypeModel doorOpType = new DoorOpTypeModel() + { + Description = $"DOOR OPERATION TYPE FOR {compoNameSplit[1].ToString()}", + HasHw = true, + IsConcrete = true, + HwCode = compoNameSplit[0].ToString(), + DoorOpIdPathFromPatriarch = HierarchyId.Parse("/1/"), + JsoncConfig = JsonConvert.SerializeObject(listGraphicParams) + }; + + await dbController.DoorOpTypeAdd(doorOpType); } i++; } From b84eab15422fa8a8c1d3f1cb1b9df1b22868fca9 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Thu, 30 Mar 2023 09:55:44 +0200 Subject: [PATCH 11/43] 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; } From e9fdda348d6e46d6df009542dd6c7fecb2d950f0 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 30 Mar 2023 11:13:46 +0200 Subject: [PATCH 12/43] Add flux cache page - ForceReload --- .../Data/WebDoorCreatorService.cs | 680 +++++++++--------- WebDoorCreator.UI/Pages/ForceReload.razor | 3 + WebDoorCreator.UI/Pages/ForceReload.razor.cs | 40 ++ 3 files changed, 365 insertions(+), 358 deletions(-) create mode 100644 WebDoorCreator.UI/Pages/ForceReload.razor create mode 100644 WebDoorCreator.UI/Pages/ForceReload.razor.cs diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index 99a36af..e08462b 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -1,15 +1,13 @@ using EgwCoreLib.Razor.Data; using Microsoft.AspNetCore.Identity.UI.Services; +using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; using NLog; using StackExchange.Redis; using System.Diagnostics; +using WebDoorCreator.Core; using WebDoorCreator.Data.Controllers; using WebDoorCreator.Data.DbModels; -using WebDoorCreator.Core; -using System.Security.AccessControl; -using WebDoorCreator.Data; -using Microsoft.EntityFrameworkCore; namespace WebDoorCreator.UI.Data { @@ -62,8 +60,20 @@ namespace WebDoorCreator.UI.Data #region Public Methods - #region Company methods - + /// + /// Update company + /// + /// + /// + public async Task CompanyAddMod(CompanyModel currRec) + { + var dbResult = await dbController.CompanyAddMod(currRec); + // elimino cache redis... + RedisValue pattern = new RedisValue($"{rKeyCompany}"); + bool answ = await ExecFlushRedisPattern(pattern); + await Task.Delay(1); + return dbResult; + } /// /// Company list filtered by company id @@ -109,104 +119,51 @@ namespace WebDoorCreator.UI.Data return dbResult; } - /// - /// Update company - /// - /// - /// - public async Task CompanyAddMod(CompanyModel currRec) - { - var dbResult = await dbController.CompanyAddMod(currRec); - // elimino cache redis... - RedisValue pattern = new RedisValue($"{rKeyCompany}"); - bool answ = await ExecFlushRedisPattern(pattern); - await Task.Delay(1); - return dbResult; - } - - #endregion Company methods - /*----------------------------------------------------------------------------------------------------------------------*/ - #region Cache methods - - /// - /// Esegue flush memoria redis dato pattern - /// - /// - /// - private async Task ExecFlushRedisPattern(RedisValue pattern) - { - bool answ = false; - var listEndpoints = redisConn.GetEndPoints(); - foreach (var endPoint in listEndpoints) - { - //var server = redisConnAdmin.GetServer(listEndpoints[0]); - var server = redisConn.GetServer(endPoint); - if (server != null) - { - var keyList = server.Keys(redisDb.Database, pattern); - foreach (var item in keyList) - { - await redisDb.KeyDeleteAsync(item); - } - answ = true; - } - } - - return answ; - } - - public async Task FlushRedisCache() - { - await Task.Delay(1); - RedisValue pattern = new RedisValue($"{redisBaseAddr}"); - bool answ = await ExecFlushRedisPattern(pattern); - return answ; - } - - #endregion Cache methods - - /*----------------------------------------------------------------------------------------------------------------------*/ - - #region Security Methods - public string DecriptData(string encData) { return SteamCrypto.DecryptString(encData, passPhrase); } - public string EncriptData(string rawData) + /// + /// Adding or removing a single door + /// + /// Record id to edit or add + /// States if it has to be added or removing a door + /// + public async Task DoorModQty(int doorId, bool isAdd) { - return SteamCrypto.EncryptString(rawData, passPhrase); + var dbResult = await dbController.DoorModQty(doorId, isAdd); + // elimino cache redis dati porta... + RedisValue pattern = new RedisValue($"{rKeyDoor}:*"); + bool answ = await ExecFlushRedisPattern(pattern); + // elimino cache redis dati ordine... + pattern = new RedisValue($"{rKeyOrderStatus}:*"); + answ = await ExecFlushRedisPattern(pattern); + return dbResult; } - #endregion Security Methods - - /*----------------------------------------------------------------------------------------------------------------------*/ - - #region User Methods - /// - /// Users roles list + /// Doors list by orderId /// - public async Task?> GetUserView() + public async Task?> DoorsGetByOrderId(int orderId) { string source = "DB"; - List? dbResult = new List(); + List? dbResult = new List(); // cerco da cache - string currKey = rKeyUsersView; + string currKey = $"{rKeyDoor}:{orderId}"; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); string? rawData = await redisDb.StringGetAsync(currKey); if (!string.IsNullOrEmpty(rawData)) { source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject>(rawData); + var tempResult = JsonConvert.DeserializeObject>(rawData); if (tempResult == null) { - dbResult = new List(); + dbResult = new List(); } else { @@ -215,17 +172,149 @@ namespace WebDoorCreator.UI.Data } else { - dbResult = dbController.GetUserView(); + dbResult = dbController.DoorsGetByOrderId(orderId); rawData = JsonConvert.SerializeObject(dbResult, JSSettings); await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); } if (dbResult == null) { - dbResult = new List(); + dbResult = new List(); } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"GetUserView | {source} in: {ts.TotalMilliseconds} ms"); + Log.Debug($"DoorsGetByOrderId | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + + /// + /// Update or add door + /// + /// + /// + public async Task DoorUpsert(DoorModel currRec) + { + var dbResult = await dbController.DoorUpsert(currRec); + // elimino cache redis dati porta... + RedisValue pattern = new RedisValue($"{rKeyDoor}:{currRec.DoorId}:*"); + bool answ = await ExecFlushRedisPattern(pattern); + // elimino cache redis dati ordine... + answ = answ && await OrdersFlushCache(); + return dbResult; + } + + public string EncriptData(string rawData) + { + return SteamCrypto.EncryptString(rawData, passPhrase); + } + + public async Task FlushRedisCache() + { + await Task.Delay(1); + RedisValue pattern = new RedisValue($"{redisBaseAddr}*"); + bool answ = await ExecFlushRedisPattern(pattern); + return answ; + } + + /// + /// Getting a list of all the active components + /// + /// Path to start + /// + public async Task> GetAllActiveCompo(string rootPath) + { + await Task.Delay(1); + List listActiveCompo = new List(); + + //estraggo la lista di componenti che sono attive per il cliente + IniFile fIni = new IniFile(rootPath); + string compoDDF = fIni.ReadString("CompoOrder", "CompoDDFOrder", "CONFIG"); + var compoDDFList = compoDDF.Split(","); + foreach (string compo in compoDDFList) + { + listActiveCompo.Add(compo.Trim()); + } + + return listActiveCompo; + } + + public async Task?> GetOrderStatus(int companyId, int orderStatus, DateTime dataFrom, DateTime dataTo) + { + string source = "DB"; + + List? dbResult = new List(); + // cerco da cache + string currKey = $"{rKeyOrderStatus}:{companyId}:{orderStatus}:{dataFrom:yyyyMMdd}:{dataTo:yyyyMMdd}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.GetOrderStatus(companyId, orderStatus, dataFrom, dataTo); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"GetOrderStatus | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + + /// + /// roles list + /// + public async Task?> GetRolesAll() + { + string source = "DB"; + + List? dbResult = new List(); + // cerco da cache + string currKey = rKeyRoles; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.GetRolesAll(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"GetRolesAll | {source} in: {ts.TotalMilliseconds} ms"); return dbResult; } @@ -313,32 +402,26 @@ namespace WebDoorCreator.UI.Data return dbResult; } - #endregion User Methods - - /*----------------------------------------------------------------------------------------------------------------------*/ - - #region Roles Methods - /// - /// roles list + /// Users roles list /// - public async Task?> GetRolesAll() + public async Task?> GetUserView() { string source = "DB"; - List? dbResult = new List(); + List? dbResult = new List(); // cerco da cache - string currKey = rKeyRoles; + string currKey = rKeyUsersView; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); string? rawData = await redisDb.StringGetAsync(currKey); if (!string.IsNullOrEmpty(rawData)) { source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject>(rawData); + var tempResult = JsonConvert.DeserializeObject>(rawData); if (tempResult == null) { - dbResult = new List(); + dbResult = new List(); } else { @@ -347,177 +430,20 @@ namespace WebDoorCreator.UI.Data } else { - dbResult = dbController.GetRolesAll(); + dbResult = dbController.GetUserView(); rawData = JsonConvert.SerializeObject(dbResult, JSSettings); await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); } if (dbResult == null) { - dbResult = new List(); + dbResult = new List(); } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"GetRolesAll | {source} in: {ts.TotalMilliseconds} ms"); + Log.Debug($"GetUserView | {source} in: {ts.TotalMilliseconds} ms"); return dbResult; } - #endregion Roles Methods - - /*----------------------------------------------------------------------------------------------------------------------*/ - - #region Order status Methods - - public async Task?> GetOrderStatus(int companyId, int orderStatus, DateTime dataFrom, DateTime dataTo) - { - string source = "DB"; - - List? dbResult = new List(); - // cerco da cache - string currKey = $"{rKeyOrderStatus}:{companyId}:{orderStatus}:{dataFrom:yyyyMMdd}:{dataTo:yyyyMMdd}"; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - string? rawData = await redisDb.StringGetAsync(currKey); - if (!string.IsNullOrEmpty(rawData)) - { - source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject>(rawData); - if (tempResult == null) - { - dbResult = new List(); - } - else - { - dbResult = tempResult; - } - } - else - { - dbResult = dbController.GetOrderStatus(companyId, orderStatus, dataFrom, dataTo); - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); - } - if (dbResult == null) - { - dbResult = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"GetOrderStatus | {source} in: {ts.TotalMilliseconds} ms"); - return dbResult; - } - - #endregion Order status Methods - - /*----------------------------------------------------------------------------------------------------------------------*/ - - #region Order Methods - - /// - /// Add new order - /// - /// - /// - public async Task OrderAdd(OrderModel currRec) - { - var dbResult = await dbController.OrderAdd(currRec); - // elimino cache redis... - RedisValue pattern = new RedisValue($"{rKeyOrderStatus}:*"); - bool answ = await ExecFlushRedisPattern(pattern); - await Task.Delay(1); - return dbResult; - } - - #endregion Order Methods - - /*----------------------------------------------------------------------------------------------------------------------*/ - - #region Door Methods - - /// - /// Doors list by orderId - /// - public async Task?> DoorsGetByOrderId(int orderId) - { - string source = "DB"; - - List? dbResult = new List(); - // cerco da cache - string currKey = $"{rKeyDoor}:{orderId}"; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - string? rawData = await redisDb.StringGetAsync(currKey); - if (!string.IsNullOrEmpty(rawData)) - { - source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject>(rawData); - if (tempResult == null) - { - dbResult = new List(); - } - else - { - dbResult = tempResult; - } - } - else - { - dbResult = dbController.DoorsGetByOrderId(orderId); - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); - } - if (dbResult == null) - { - dbResult = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"DoorsGetByOrderId | {source} in: {ts.TotalMilliseconds} ms"); - return dbResult; - } - - /// - /// Update or add door - /// - /// - /// - public async Task DoorUpsert(DoorModel currRec) - { - var dbResult = await dbController.DoorUpsert(currRec); - // elimino cache redis dati porta... - RedisValue pattern = new RedisValue($"{rKeyDoor}:{currRec.DoorId}:*"); - bool answ = await ExecFlushRedisPattern(pattern); - // elimino cache redis dati ordine... - pattern = new RedisValue($"{rKeyOrderStatus}:*"); - answ = await ExecFlushRedisPattern(pattern); - await Task.Delay(1); - return dbResult; - } - - /// - /// Adding or removing a single door - /// - /// Record id to edit or add - /// States if it has to be added or removing a door - /// - public async Task DoorModQty(int doorId, bool isAdd) - { - var dbResult = await dbController.DoorModQty(doorId, isAdd); - // elimino cache redis dati porta... - RedisValue pattern = new RedisValue($"{rKeyDoor}:*"); - bool answ = await ExecFlushRedisPattern(pattern); - // elimino cache redis dati ordine... - pattern = new RedisValue($"{rKeyOrderStatus}:*"); - answ = await ExecFlushRedisPattern(pattern); - await Task.Delay(1); - return dbResult; - } - - #endregion Door Methods - - /*----------------------------------------------------------------------------------------------------------------------*/ - - #region ListValues Methods - /// /// Company list /// @@ -560,88 +486,35 @@ namespace WebDoorCreator.UI.Data return dbResult; } - #endregion ListValues Methods - - /*----------------------------------------------------------------------------------------------------------------------*/ - - #region IniFiles Methods - - /// - /// Getting a list of all the active components + /// Add new order /// - /// Path to start + /// /// - public async Task> GetAllActiveCompo(string rootPath) + public async Task OrderAdd(OrderModel currRec) { + var dbResult = await dbController.OrderAdd(currRec); + // elimino cache redis... + RedisValue pattern = new RedisValue($"{rKeyOrderStatus}:*"); + bool answ = await ExecFlushRedisPattern(pattern); await Task.Delay(1); - List listActiveCompo = new List(); - - //estraggo la lista di componenti che sono attive per il cliente - IniFile fIni = new IniFile(rootPath); - string compoDDF = fIni.ReadString("CompoOrder", "CompoDDFOrder", "CONFIG"); - var compoDDFList = compoDDF.Split(","); - foreach (string compo in compoDDFList) - { - listActiveCompo.Add(compo.Trim()); - } - - return listActiveCompo; + return dbResult; } /// - /// Setting the graphic parameters for components + /// Clean redis ORDERS cache /// - /// - /// - /// - /// + /// /// - public async Task> SetGraphicParams(string file, string match, int n, int i) + public async Task OrdersFlushCache() { - await Task.Delay(1); - List listGraphicParams = new List(); - - IniFile fIni = new IniFile(file); - //estraggo la lista di componenti che sono attive per il cliente - var graphicParamsName = fIni.ReadSection(match.Substring(1, match.Length - 2)); //cerco il contenuto delle sezioni - if (int.Parse(match.Substring(match.Length - 2, 1)) == n) //controllo se tra i numeri di graphic params vi è un buco ES: Graphic parameters1 Graphic parameters3 se il buco c'è salto tutti i parametri che stanno dopo il buco ==> tengo conto solo di Graphic parameters1 - { - 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 = 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); - } - else - { - GraphicParamsModel graphicParams = new GraphicParamsModel() { compoId = i, graphicParamsN = match.Substring(1, match.Length - 2), graphicParamKey = param.Split("=")[0], graphicParamName = compoParams }; - listGraphicParams.Add(graphicParams); //creo nuovo oggetto parametro che conterrà anche il nome del componente per creare relazione - await dbController.ParamAdd(graphicParams); - } - } - } - - return listGraphicParams; + RedisValue pattern = new RedisValue($"{rKeyOrderStatus}:*"); + bool answ = await ExecFlushRedisPattern(pattern); + return answ; } - /// - /// Setting all the component list + /// Setting all the component list /// /// Path to start /// @@ -678,7 +551,7 @@ namespace WebDoorCreator.UI.Data { compoTemplateIsActive = false; } - var compoNameSplit = compoName.Split("/"); // lo slash indica l'alias + 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(), compoLayerName = layerName, compoTemplateIsActive = compoTemplateIsActive }; //creo il componente (padre) @@ -707,7 +580,6 @@ namespace WebDoorCreator.UI.Data } i++; } - } List edges = new List(); @@ -753,40 +625,59 @@ namespace WebDoorCreator.UI.Data return fatto; } - #endregion IniFiles Methods + /// + /// Setting the graphic parameters for components + /// + /// + /// + /// + /// + /// + public async Task> SetGraphicParams(string file, string match, int n, int i) + { + await Task.Delay(1); + List listGraphicParams = new List(); + + IniFile fIni = new IniFile(file); + //estraggo la lista di componenti che sono attive per il cliente + var graphicParamsName = fIni.ReadSection(match.Substring(1, match.Length - 2)); //cerco il contenuto delle sezioni + if (int.Parse(match.Substring(match.Length - 2, 1)) == n) //controllo se tra i numeri di graphic params vi è un buco ES: Graphic parameters1 Graphic parameters3 se il buco c'è salto tutti i parametri che stanno dopo il buco ==> tengo conto solo di Graphic parameters1 + { + 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 = 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); + } + else + { + GraphicParamsModel graphicParams = new GraphicParamsModel() { compoId = i, graphicParamsN = match.Substring(1, match.Length - 2), graphicParamKey = param.Split("=")[0], graphicParamName = compoParams }; + listGraphicParams.Add(graphicParams); //creo nuovo oggetto parametro che conterrà anche il nome del componente per creare relazione + await dbController.ParamAdd(graphicParams); + } + } + } + + return listGraphicParams; + } #endregion Public Methods #region Protected Fields - #region Private Properties - - /// - /// Durata cache lunga (+ perturbazione percentuale +/-10%) - /// - private TimeSpan FastCache - { - get => TimeSpan.FromSeconds(cacheTtlShort * rnd.Next(900, 1100) / 1000); - } - - /// - /// Durata cache lunga (+ perturbazione percentuale +/-10%) - /// - private TimeSpan LongCache - { - get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 1100) / 1000); - } - - /// - /// Durata cache lunga (+ perturbazione percentuale +/-10%) - /// - private TimeSpan UltraLongCache - { - get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000); - } - - #endregion Private Properties - protected const string passPhrase = "9eb4660f-8753-46bc-b23b-08759ba03fe9"; //#region Protected Fields @@ -795,13 +686,18 @@ namespace WebDoorCreator.UI.Data //#endregion Public Methods protected const string rKeyCompany = $"{redisBaseAddr}:Cache:Company"; - protected const string rKeyOrderStatus = $"{redisBaseAddr}:Cache:OrderStatus"; - protected const string rKeyUsers = $"{redisBaseAddr}:Cache:Users"; - protected const string rKeyUsersView = $"{redisBaseAddr}:Cache:UsersView"; - protected const string rKeyRoles = $"{redisBaseAddr}:Cache:Roles"; protected const string rKeyDoor = $"{redisBaseAddr}:Cache:Doors"; + protected const string rKeyListValues = $"{redisBaseAddr}:Cache:ListValues"; + protected const string rKeyOrderStatus = $"{redisBaseAddr}:Cache:OrderStatus"; + + protected const string rKeyRoles = $"{redisBaseAddr}:Cache:Roles"; + + protected const string rKeyUsers = $"{redisBaseAddr}:Cache:Users"; + + protected const string rKeyUsersView = $"{redisBaseAddr}:Cache:UsersView"; + protected Random rnd = new Random(); #endregion Protected Fields @@ -838,5 +734,73 @@ namespace WebDoorCreator.UI.Data private IDatabase redisDb = null!; #endregion Private Fields + + #region Private Properties + + /// + /// Durata cache lunga (+ perturbazione percentuale +/-10%) + /// + private TimeSpan FastCache + { + get => TimeSpan.FromSeconds(cacheTtlShort * rnd.Next(900, 1100) / 1000); + } + + /// + /// Durata cache lunga (+ perturbazione percentuale +/-10%) + /// + private TimeSpan LongCache + { + get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 1100) / 1000); + } + + /// + /// Durata cache lunga (+ perturbazione percentuale +/-10%) + /// + private TimeSpan UltraLongCache + { + get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000); + } + + #endregion Private Properties + + #region Private Methods + + /// + /// Esegue flush memoria redis dato pattern + /// + /// + /// + private async Task ExecFlushRedisPattern(RedisValue pattern) + { + bool answ = false; + var listEndpoints = redisConn.GetEndPoints(); + foreach (var endPoint in listEndpoints) + { + //var server = redisConnAdmin.GetServer(listEndpoints[0]); + var server = redisConn.GetServer(endPoint); + if (server != null) + { + var keyList = server.Keys(redisDb.Database, pattern); + foreach (var item in keyList) + { + await redisDb.KeyDeleteAsync(item); + } + answ = true; + } + } + + return answ; + } + + #endregion Private Methods + + /*----------------------------------------------------------------------------------------------------------------------*/ + /*----------------------------------------------------------------------------------------------------------------------*/ + /*----------------------------------------------------------------------------------------------------------------------*/ + /*----------------------------------------------------------------------------------------------------------------------*/ + /*----------------------------------------------------------------------------------------------------------------------*/ + /*----------------------------------------------------------------------------------------------------------------------*/ + /*----------------------------------------------------------------------------------------------------------------------*/ + /*----------------------------------------------------------------------------------------------------------------------*/ } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/ForceReload.razor b/WebDoorCreator.UI/Pages/ForceReload.razor new file mode 100644 index 0000000..e45c89e --- /dev/null +++ b/WebDoorCreator.UI/Pages/ForceReload.razor @@ -0,0 +1,3 @@ +@page "/ForceReload" + + diff --git a/WebDoorCreator.UI/Pages/ForceReload.razor.cs b/WebDoorCreator.UI/Pages/ForceReload.razor.cs new file mode 100644 index 0000000..79045d5 --- /dev/null +++ b/WebDoorCreator.UI/Pages/ForceReload.razor.cs @@ -0,0 +1,40 @@ +using Microsoft.AspNetCore.Components; +using WebDoorCreator.UI.Data; + +namespace WebDoorCreator.UI.Pages +{ + public partial class ForceReload + { + #region Public Methods + + public async Task flushCache() + { + await Task.Delay(1); + await WDService.FlushRedisCache(); + await Task.Delay(1); + // rimando a pagina corrente + NavManager.NavigateTo("/", true); + } + + #endregion Public Methods + + #region Protected Properties + + [Inject] + protected NavigationManager NavManager { get; set; } = null!; + + [Inject] + protected WebDoorCreatorService WDService { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnInitializedAsync() + { + await flushCache(); + } + + #endregion Protected Methods + } +} \ No newline at end of file From b04f09bb1c2631e3bd9aaac6148ac134d29faa1e Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 30 Mar 2023 11:14:01 +0200 Subject: [PATCH 13/43] Fix data periodo display ordini --- .../Controllers/WebDoorCreatorController.cs | 5 ++--- WebDoorCreator.UI/Components/Order/OrderList.razor.cs | 4 ++-- WebDoorCreator.UI/Pages/DoorDefinition.razor.cs | 8 ++++---- WebDoorCreator.UI/Pages/OrdersHomePage.razor | 2 +- WebDoorCreator.UI/Pages/OrdersHomePage.razor.cs | 10 ++++++++-- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index ac3d161..71a2ffe 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -286,10 +286,9 @@ namespace WebDoorCreator.Data.Controllers { var CompanyId = new SqlParameter("@CompanyId", companyId); var OrderStatus = new SqlParameter("@OrderStatus", orderStatus); - var DataFrom = new SqlParameter("@DataFrom", dataFrom.Date); - var DataTo = new SqlParameter("@DataTo", dataTo.Date); + var DataFrom = new SqlParameter("@DataFrom", dataFrom); + var DataTo = new SqlParameter("@DataTo", dataTo); - var k = $"exec dbo.stp_OrderList_getFilt {companyId}, {orderStatus}, '{dataFrom.Date.ToString("yyyy/MM/dd")}', '{dataTo.Date.ToString("yyyy/MM/dd")}'"; dbResult = dbCtx .DbSetOrderStatus diff --git a/WebDoorCreator.UI/Components/Order/OrderList.razor.cs b/WebDoorCreator.UI/Components/Order/OrderList.razor.cs index 8a310f2..987afec 100644 --- a/WebDoorCreator.UI/Components/Order/OrderList.razor.cs +++ b/WebDoorCreator.UI/Components/Order/OrderList.razor.cs @@ -100,12 +100,12 @@ namespace WebDoorCreator.UI.Components.Order } private async Task ReloadData() { - var adesso = DateTime.Now.Date; + var domani = DateTime.Today.AddDays(1); ListOrdersStatus = null; await Task.Delay(1); if (userClaims != null) { - ListOrdersStatus = await WDService.GetOrderStatus(userCurrCompany, 0, adesso.AddYears(-2), adesso); + ListOrdersStatus = await WDService.GetOrderStatus(userCurrCompany, 0, domani.AddYears(-2), domani); } await Task.Delay(1); await InvokeAsync(StateHasChanged); diff --git a/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs b/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs index 618b5c0..338a0ab 100644 --- a/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs +++ b/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs @@ -8,7 +8,7 @@ namespace WebDoorCreator.UI.Pages public partial class DoorDefinition { [Inject] - protected NavigationManager navManager { get; set; } = null!; + protected NavigationManager NavManager { get; set; } = null!; [Inject] protected WebDoorCreatorService WDService { get; set; } = null!; @@ -20,7 +20,7 @@ namespace WebDoorCreator.UI.Pages protected override async Task OnInitializedAsync() { await Task.Delay(1); - var uri = navManager.ToAbsoluteUri(navManager.Uri); + var uri = NavManager.ToAbsoluteUri(NavManager.Uri); if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("idOrd", out var _idOrd)) { idOrd = int.Parse(_idOrd); @@ -30,10 +30,10 @@ namespace WebDoorCreator.UI.Pages protected async Task reloadData() { - var adesso = DateTime.Now.Date; + var domani = DateTime.Today.AddDays(1); ListOrdersStatus = null; await Task.Delay(1); - ListOrdersStatus = await WDService.GetOrderStatus(0, 0, adesso.AddYears(-2), adesso); + ListOrdersStatus = await WDService.GetOrderStatus(0, 0, domani.AddYears(-2), domani); if (ListOrdersStatus != null) { orderStatus = ListOrdersStatus.Where(x => x.OrderId == idOrd).FirstOrDefault(); diff --git a/WebDoorCreator.UI/Pages/OrdersHomePage.razor b/WebDoorCreator.UI/Pages/OrdersHomePage.razor index cc5bbaf..7e0370b 100644 --- a/WebDoorCreator.UI/Pages/OrdersHomePage.razor +++ b/WebDoorCreator.UI/Pages/OrdersHomePage.razor @@ -42,7 +42,7 @@ @if (orderCodExt != "") { - + }
diff --git a/WebDoorCreator.UI/Pages/OrdersHomePage.razor.cs b/WebDoorCreator.UI/Pages/OrdersHomePage.razor.cs index e136921..c6e09be 100644 --- a/WebDoorCreator.UI/Pages/OrdersHomePage.razor.cs +++ b/WebDoorCreator.UI/Pages/OrdersHomePage.razor.cs @@ -6,7 +6,7 @@ using WebDoorCreator.UI.Data; namespace WebDoorCreator.UI.Pages { - public partial class OrdersHomePage:IDisposable + public partial class OrdersHomePage : IDisposable { #region Protected Properties @@ -116,7 +116,13 @@ namespace WebDoorCreator.UI.Pages if (done) { - NavManager.NavigateTo(NavManager.Uri, true); + // flush dati ordine + reload + await WDService.OrdersFlushCache(); + orderCodExt = ""; + orderDescr = ""; + doorChange = true; + //// da eliminare... + //NavManager.NavigateTo(NavManager.Uri, true); } } From 67dc2c5acd39f04ea38dabd2df24114b8797f3a8 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 30 Mar 2023 11:33:13 +0200 Subject: [PATCH 14/43] ORDERS - metodo remove --- .../Controllers/WebDoorCreatorController.cs | 31 +++++++++++++++++++ .../Components/Order/OrderList.razor | 17 +++++++--- .../Components/Order/OrderList.razor.cs | 14 +++++++++ .../Data/WebDoorCreatorService.cs | 14 ++++++++- 4 files changed, 70 insertions(+), 6 deletions(-) diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index 71a2ffe..38beef7 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -334,6 +334,37 @@ namespace WebDoorCreator.Data.Controllers return fatto; } + /// + /// Remove order + /// + /// Record to add + /// + public async Task OrderRem(int OrdId) + { + bool fatto = false; + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + var selRec = localDbCtx + .DbSetOrders + .Where(x => x.OrderId == OrdId) + .FirstOrDefault(); + if (selRec != null) + { + localDbCtx.DbSetOrders.Remove(selRec); + await localDbCtx.SaveChangesAsync(); + fatto = true; + } + } + catch (Exception exc) + { + Log.Error($"Eccezione durante OrderRem: {Environment.NewLine}{exc}"); + } + } + return fatto; + } + #endregion Order methods #region Door methods diff --git a/WebDoorCreator.UI/Components/Order/OrderList.razor b/WebDoorCreator.UI/Components/Order/OrderList.razor index a91963d..8a3df44 100644 --- a/WebDoorCreator.UI/Components/Order/OrderList.razor +++ b/WebDoorCreator.UI/Components/Order/OrderList.razor @@ -14,7 +14,8 @@ else Doors Number Model Number TOTAL COST - @* PROGRESS*@ + @*PROGRESS*@ + @@ -29,10 +30,16 @@ else @item.NumType @($"{item.TotCost:C2}") @* -
-
-
- *@ +
+
+
+ *@ + + @if (item.OrderStatus < (int)Core.Enum.OrderStatus.Sent) + { + + } + } diff --git a/WebDoorCreator.UI/Components/Order/OrderList.razor.cs b/WebDoorCreator.UI/Components/Order/OrderList.razor.cs index 987afec..b96c87a 100644 --- a/WebDoorCreator.UI/Components/Order/OrderList.razor.cs +++ b/WebDoorCreator.UI/Components/Order/OrderList.razor.cs @@ -1,7 +1,9 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Identity; using Microsoft.JSInterop; +using NLog.LayoutRenderers; using WebDoorCreator.Data.DbModels; using WebDoorCreator.UI.Data; @@ -117,6 +119,18 @@ namespace WebDoorCreator.UI.Components.Order await E_currOrderStatus.InvokeAsync(currOrd); } + protected async Task deleteRecord(OrderStatusViewModel currRec) + { + + if (!await JSRuntime.InvokeAsync("confirm", $"Order Deletion requested: are you sure to remove {currRec.OrderExtCode}?")) + return; + + await Task.Delay(1); + var done = await WDService.OrderRem(currRec.OrderId); + await WDService.OrdersFlushCache(); + await ReloadData(); + } + #endregion Private Methods } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index e08462b..6287655 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -497,7 +497,19 @@ namespace WebDoorCreator.UI.Data // elimino cache redis... RedisValue pattern = new RedisValue($"{rKeyOrderStatus}:*"); bool answ = await ExecFlushRedisPattern(pattern); - await Task.Delay(1); + return dbResult; + } + /// + /// Remove order + /// + /// + /// + public async Task OrderRem(int OrdId) + { + var dbResult = await dbController.OrderRem(OrdId); + // elimino cache redis... + RedisValue pattern = new RedisValue($"{rKeyOrderStatus}:*"); + bool answ = await ExecFlushRedisPattern(pattern); return dbResult; } From 1ccc73fee996e8aec0e546eca22eca3120d54780 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 30 Mar 2023 12:23:07 +0200 Subject: [PATCH 15/43] Data migration x lock / UM --- WebDoorCreator.Core/Enum.cs | 23 +- .../Controllers/WebDoorCreatorController.cs | 36 +- WebDoorCreator.Data/DbModels/DoorModel.cs | 15 + ...30330102212_DoorLockAndMeasure.Designer.cs | 710 ++++++++++++++++++ .../20230330102212_DoorLockAndMeasure.cs | 49 ++ .../WDCData/WDCDataContextModelSnapshot.cs | 11 + 6 files changed, 833 insertions(+), 11 deletions(-) create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230330102212_DoorLockAndMeasure.Designer.cs create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230330102212_DoorLockAndMeasure.cs diff --git a/WebDoorCreator.Core/Enum.cs b/WebDoorCreator.Core/Enum.cs index b2aa24b..61b2166 100644 --- a/WebDoorCreator.Core/Enum.cs +++ b/WebDoorCreator.Core/Enum.cs @@ -2,6 +2,18 @@ { public class Enum { + #region Public Enums + + public enum OrderStatus + { + NA = 0, + DoorDef, + Sent, + ApprovedByMaker, + ApprovedByCustomer, + InProduction + } + public enum UserLevel { ND = 0, @@ -12,15 +24,6 @@ User = 5 } - public enum OrderStatus - { - NA=0, - DoorDef, - Sent, - ApprovedByMaker, - ApprovedByCustomer, - InProduction - } - + #endregion Public Enums } } \ No newline at end of file diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index 38beef7..120e590 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -396,6 +396,40 @@ namespace WebDoorCreator.Data.Controllers return dbResult; } + /// + /// Adding a new door + /// + /// Record to edit or add + /// + public async Task DoorInsert(DoorModel newRec) + { + int ordId = 0; + //List dbResult = new List(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + var currRec = localDbCtx + .DbSetDoor + .Where(x => x.DoorId == newRec.DoorId) + .FirstOrDefault(); + // procedo solo se non c'è già + if (currRec == null) + { + var newDbRec = localDbCtx + .DbSetDoor + .Add(newRec); + ordId= await localDbCtx.SaveChangesAsync(); + } + } + catch (Exception exc) + { + Log.Error($"Eccezione durante DoorInsert: {Environment.NewLine}{exc}"); + } + } + return ordId; + } + /// /// Modifying or adding a new door /// @@ -429,7 +463,7 @@ namespace WebDoorCreator.Data.Controllers } catch (Exception exc) { - Log.Error($"Eccezione durante DoorsAddMod: {Environment.NewLine}{exc}"); + Log.Error($"Eccezione durante DoorUpsert: {Environment.NewLine}{exc}"); } } return fatto; diff --git a/WebDoorCreator.Data/DbModels/DoorModel.cs b/WebDoorCreator.Data/DbModels/DoorModel.cs index ecf80c8..6a65e06 100644 --- a/WebDoorCreator.Data/DbModels/DoorModel.cs +++ b/WebDoorCreator.Data/DbModels/DoorModel.cs @@ -25,6 +25,11 @@ namespace WebDoorCreator.Data.DbModels ///
public int OrderId { get; set; } + /// + /// Unità di misura + /// + public string MeasureUnit { get; set; } = ""; + /// /// Door's Type /// @@ -71,6 +76,16 @@ namespace WebDoorCreator.Data.DbModels public decimal UnitCost { get; set; } = 0; + /// + /// Data scadenza Lock + /// + public DateTime DateLockExpiry { get; set; } = DateTime.Now; + + /// + /// Codice utente che ha bloccato record + /// + public string UserIdLock { get; set; } = ""; + [ForeignKey("OrderId")] public virtual OrderModel? OrderNav { get; set; } diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230330102212_DoorLockAndMeasure.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230330102212_DoorLockAndMeasure.Designer.cs new file mode 100644 index 0000000..4d76d75 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230330102212_DoorLockAndMeasure.Designer.cs @@ -0,0 +1,710 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230330102212_DoorLockAndMeasure")] + partial class DoorLockAndMeasure + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateLockExpiry") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MeasureUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdLock") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorOpIdPathFromPatriarch") + .HasColumnType("hierarchyid"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => + { + b.Property("GraphicParamId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GraphicParamId"), 1L, 1); + + b.Property("compoId") + .HasColumnType("int"); + + b.Property("graphicParamAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamDefaultVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamsN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("GraphicParamId"); + + b.ToTable("GraphicParams"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => + { + b.Property("HardwareId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("HardwareId"), 1L, 1); + + b.Property("compoAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoLayerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoTemplateIsActive") + .HasColumnType("bit"); + + b.HasKey("HardwareId"); + + b.ToTable("Hardware"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230330102212_DoorLockAndMeasure.cs b/WebDoorCreator.Data/Migrations/WDCData/20230330102212_DoorLockAndMeasure.cs new file mode 100644 index 0000000..0b08579 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230330102212_DoorLockAndMeasure.cs @@ -0,0 +1,49 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class DoorLockAndMeasure : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "DateLockExpiry", + table: "Door", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "MeasureUnit", + table: "Door", + type: "nvarchar(max)", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "UserIdLock", + table: "Door", + type: "nvarchar(max)", + nullable: false, + defaultValue: ""); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "DateLockExpiry", + table: "Door"); + + migrationBuilder.DropColumn( + name: "MeasureUnit", + table: "Door"); + + migrationBuilder.DropColumn( + name: "UserIdLock", + table: "Door"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs index 99f06d9..d01bacf 100644 --- a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs +++ b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs @@ -188,6 +188,9 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.Property("DateIns") .HasColumnType("datetime2"); + b.Property("DateLockExpiry") + .HasColumnType("datetime2"); + b.Property("DateMod") .HasColumnType("datetime2"); @@ -199,6 +202,10 @@ namespace WebDoorCreator.Data.Migrations.WDCData .IsRequired() .HasColumnType("nvarchar(max)"); + b.Property("MeasureUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + b.Property("OrderId") .HasColumnType("int"); @@ -215,6 +222,10 @@ namespace WebDoorCreator.Data.Migrations.WDCData .IsRequired() .HasColumnType("nvarchar(max)"); + b.Property("UserIdLock") + .IsRequired() + .HasColumnType("nvarchar(max)"); + b.Property("UserIdMod") .IsRequired() .HasColumnType("nvarchar(max)"); From a9619bcf1ac624ad4ceea004cc196ed2ae9545d6 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 30 Mar 2023 12:23:15 +0200 Subject: [PATCH 16/43] Aggiunta metodo creazione porta (2 test) --- .../Data/WebDoorCreatorService.cs | 34 +++++- WebDoorCreator.UI/Pages/DoorDefinition.razor | 10 +- .../Pages/DoorDefinition.razor.cs | 33 +++++- WebDoorCreator.UI/Pages/OrderDetails.razor | 15 ++- WebDoorCreator.UI/Pages/OrderDetails.razor.cs | 101 ++++++++++++------ 5 files changed, 148 insertions(+), 45 deletions(-) diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index 6287655..49d58e0 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -186,6 +186,37 @@ namespace WebDoorCreator.UI.Data return dbResult; } + /// + /// Add door + /// + /// + /// + public async Task DoorInsert(DoorModel newRec) + { + var dbResult = await dbController.DoorInsert(newRec); + // elimino cache redis dati porta... + bool answ = await DoorFlushCache(newRec.DoorId); + // elimino cache redis dati ordine... + answ = answ && await OrdersFlushCache(); + return dbResult; + } + + /// + /// Clean redis DOORS cache + /// + /// 0 = all + /// + public async Task DoorFlushCache(int DoorId) + { + RedisValue pattern = new RedisValue($"{rKeyDoor}:*"); + if (DoorId > 0) + { + pattern = new RedisValue($"{rKeyDoor}:{DoorId}:*"); + } + bool answ = await ExecFlushRedisPattern(pattern); + return answ; + } + /// /// Update or add door /// @@ -195,8 +226,7 @@ namespace WebDoorCreator.UI.Data { var dbResult = await dbController.DoorUpsert(currRec); // elimino cache redis dati porta... - RedisValue pattern = new RedisValue($"{rKeyDoor}:{currRec.DoorId}:*"); - bool answ = await ExecFlushRedisPattern(pattern); + bool answ = await DoorFlushCache(currRec.DoorId); // elimino cache redis dati ordine... answ = answ && await OrdersFlushCache(); return dbResult; diff --git a/WebDoorCreator.UI/Pages/DoorDefinition.razor b/WebDoorCreator.UI/Pages/DoorDefinition.razor index 77305cd..2b13e1f 100644 --- a/WebDoorCreator.UI/Pages/DoorDefinition.razor +++ b/WebDoorCreator.UI/Pages/DoorDefinition.razor @@ -1,7 +1,13 @@ @page "/DoorDefinition" -

Door Definition

- +
+
+

Door Definition

+
+
+ +
+
diff --git a/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs b/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs index 338a0ab..19161a4 100644 --- a/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs +++ b/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.WebUtilities; +using Microsoft.JSInterop; using WebDoorCreator.Data.DbModels; using WebDoorCreator.UI.Data; @@ -7,15 +8,24 @@ namespace WebDoorCreator.UI.Pages { public partial class DoorDefinition { + #region Protected Properties + + protected int idOrd { get; set; } = 0; + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + [Inject] protected NavigationManager NavManager { get; set; } = null!; + protected OrderStatusViewModel? orderStatus { get; set; } = null; + [Inject] protected WebDoorCreatorService WDService { get; set; } = null!; - protected int idOrd { get; set; } = 0; - protected OrderStatusViewModel? orderStatus { get; set; } = null; - private List? ListOrdersStatus = null; + #endregion Protected Properties + + #region Protected Methods protected override async Task OnInitializedAsync() { @@ -40,5 +50,22 @@ namespace WebDoorCreator.UI.Pages } await Task.Delay(1); } + + protected async Task toOrderPage() + { + if (!await JSRuntime.InvokeAsync("confirm", $"Do you really want to return to the order page without saving current work?")) + return; + + await Task.Delay(1); + NavManager.NavigateTo($"OrderDetails?idOrd={idOrd}"); + } + + #endregion Protected Methods + + #region Private Fields + + private List? ListOrdersStatus = null; + + #endregion Private Fields } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/OrderDetails.razor b/WebDoorCreator.UI/Pages/OrderDetails.razor index 9cdca43..a1aeac3 100644 --- a/WebDoorCreator.UI/Pages/OrderDetails.razor +++ b/WebDoorCreator.UI/Pages/OrderDetails.razor @@ -2,11 +2,20 @@
- LIST DOORS IN ORDER @idOrd - + Add new door +
+ LIST DOORS IN ORDER @idOrd +
+
+
+ + +
+
-
diff --git a/WebDoorCreator.UI/Pages/OrderDetails.razor.cs b/WebDoorCreator.UI/Pages/OrderDetails.razor.cs index e4415e8..c095bff 100644 --- a/WebDoorCreator.UI/Pages/OrderDetails.razor.cs +++ b/WebDoorCreator.UI/Pages/OrderDetails.razor.cs @@ -1,59 +1,90 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Components; -using System.Net.Http; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Components.Authorization; -using Microsoft.AspNetCore.Components.Forms; -using Microsoft.AspNetCore.Components.Routing; -using Microsoft.AspNetCore.Components.Web; -using Microsoft.AspNetCore.Components.Web.Virtualization; -using Microsoft.JSInterop; -using WebDoorCreator.UI; -using WebDoorCreator.UI.Components; -using WebDoorCreator.UI.Components.Buttons; -using WebDoorCreator.UI.Components.CompMan; -using WebDoorCreator.UI.Components.DoorMan; -using WebDoorCreator.UI.Components.DoorDef; -using WebDoorCreator.UI.Components.Gen; -using WebDoorCreator.UI.Components.Order; -using WebDoorCreator.UI.Components.Users; -using WebDoorCreator.UI.Shared; -using WebDoorCreator.Data.DbModels; -using Microsoft.AspNetCore.WebUtilities; -using WebDoorCreator.UI.Data; using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.WebUtilities; +using System.Collections.Specialized; +using WebDoorCreator.Data.DbModels; +using WebDoorCreator.UI.Data; namespace WebDoorCreator.UI.Pages { public partial class OrderDetails { + #region Protected Properties + [Inject] - protected NavigationManager navManager { get; set; } = null!; + protected UserManager _userManager { get; set; } = null!; + + protected DoorModel? currDoor { get; set; } = null; + + protected int currDoorType { get; set; } = 0; + + /// + /// Unità di misura selezionata + /// + protected string currMeaUnit { get; set; } = "mm"; + + protected List? DoorsList { get; set; } = null; + + protected int idOrd { get; set; } = 0; + + [Inject] + protected NavigationManager NavManager { get; set; } = null!; + + protected OrderStatusViewModel? OrderStatus { get; set; } = null; [Inject] protected WebDoorCreatorService WDService { get; set; } = null!; - protected int idOrd { get; set; } = 0; - protected OrderStatusViewModel? orderStatus { get; set; } = null; - private List? ListOrdersStatus = null; + [Inject] + protected WDCUserService WDCUService { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods protected override async Task OnInitializedAsync() { await Task.Delay(1); - var uri = navManager.ToAbsoluteUri(navManager.Uri); + var uri = NavManager.ToAbsoluteUri(NavManager.Uri); if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("idOrd", out var _idOrd)) { idOrd = int.Parse(_idOrd); } } - protected int currDoorType { get; set; } = 0; - protected DoorModel? currDoor { get; set; } = null; - protected List? DoorsList { get; set; } = null; - [Inject] - protected UserManager _userManager { get; set; } = null!; + #endregion Protected Methods + + #region Private Fields + + private List? ListOrdersStatus = null; + + protected async Task createDoor() + { + // conto le porte x questo ordine e uso x chiamata successiva... + var door4ord = await WDService.DoorsGetByOrderId(idOrd); + int numDoors = door4ord?.Count ?? 0; + // creo una nuova porta... + DoorModel newDoor = new DoorModel() + { + OrderId = idOrd, + MeasureUnit = currMeaUnit, + DateIns = DateTime.Now, + UserIdIns = WDCUService.newUserName, + UserIdMod = WDCUService.newUserName, + DateMod = DateTime.Now, + DoorDescript = $"ORD {idOrd} | Door {numDoors + 1:00}", + DoorExtCode = $"ORD {idOrd} | Ext Code --", + Quantity = 1, + UnitCost = 0, + TypeId = 0 + }; + // chiamo metodo x insert... + var doorId = await WDService.DoorInsert(newDoor); + + // rimando alla pagina... dettaglio... + NavManager.NavigateTo($"/DoorDefinition?idOrd={idOrd}&idDoor={doorId}"); + } + + #endregion Private Fields } } \ No newline at end of file From 961f4c29432acac8c54fb5ea6339298962f46f0c Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 30 Mar 2023 12:33:23 +0200 Subject: [PATCH 17/43] Fix creazione porta --- WebDoorCreator.UI/Pages/OrderDetails.razor | 2 +- WebDoorCreator.UI/Pages/OrderDetails.razor.cs | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/WebDoorCreator.UI/Pages/OrderDetails.razor b/WebDoorCreator.UI/Pages/OrderDetails.razor index a1aeac3..25c32ab 100644 --- a/WebDoorCreator.UI/Pages/OrderDetails.razor +++ b/WebDoorCreator.UI/Pages/OrderDetails.razor @@ -6,7 +6,7 @@ LIST DOORS IN ORDER @idOrd
-
+
+
Height
- +
Thickness
- +
} else if(isOpening) {
Swing
- @if (ListSwings != null) { @foreach (var item in ListSwings) @@ -40,7 +40,7 @@ {
Lock edge
- @if (ListEdges != null) { @foreach (var item in ListEdges) @@ -52,7 +52,7 @@
Hinge edge
- @if (ListEdges != null) { @foreach (var item in ListEdges) @@ -64,7 +64,7 @@
Top edge
- @if (ListEdges != null) { @foreach (var item in ListEdges) @@ -76,7 +76,7 @@
Bottom edge
- @if (ListEdges != null) { @foreach (var item in ListEdges) diff --git a/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs b/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs index 99c311a..a894815 100644 --- a/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs +++ b/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Components; +using Newtonsoft.Json; using WebDoorCreator.Data.DbModels; using WebDoorCreator.UI.Data; @@ -9,9 +10,16 @@ namespace WebDoorCreator.UI.Components.DoorDef [Inject] protected WebDoorCreatorService WDService { get; set; } = null!; + [Parameter] + public int DoorId { get; set; } = 0; + protected bool isSizing { get; set; } = true; protected List? ListSwings { get; set; } = null; protected List? ListEdges { get; set; } = null; + protected List? ListDoorOp { get; set; } = null; + protected Edges? DefaultEdges { get; set; } = null; + protected Opening? DefaultOpening { get; set; } = null; + protected Sizing? DefaultSizing { get; set; } = null; protected string isSizingActive { @@ -53,15 +61,103 @@ namespace WebDoorCreator.UI.Components.DoorDef isEdges = true; } + protected string _lockEdge { get; set; } = ""; + + protected string lockEdge + { + get => _lockEdge; + set=> _lockEdge = value; + } + protected string _hingeEdge { get; set; } = ""; + + protected string hingeEdge + { + get => _hingeEdge; + set => _hingeEdge = value; + } + + protected string _topEdge { get; set; } = ""; + + protected string topEdge + { + get => _topEdge; + set => _topEdge = value; + } + + protected string _bottomEdge { get; set; } = ""; + + protected string bottomEdge + { + get => _bottomEdge; + set => _bottomEdge = value; + } + + protected double _width { get; set; } = 0.0; + + protected double width + { + get => _width; + set => _width = value; + } + + protected double _height { get; set; } = 0.0; + + protected double height + { + get => _height; + set => _height = value; + } + protected double _thickness{ get; set; } = 0.0; + + protected double thickness + { + get => _thickness; + set => _thickness = value; + } + + protected string _swing { get; set; } = ""; + + protected string swing + { + get => _swing; + set => _swing = value; + } + protected async Task ReloadData() { ListSwings = await WDService.ListValuesGetAll("Opening", "Swing"); ListEdges = await WDService.ListValuesGetAll("Edges", "EdgeType"); - + ListDoorOp = await WDService.DoorOpGetByDoorId(DoorId); + if (ListDoorOp != null) + { + foreach (var doorOp in ListDoorOp) + { + if (doorOp.DoorOpTypId == 19) + { + DefaultEdges = JsonConvert.DeserializeObject(doorOp.JsoncConfigVal); + lockEdge = DefaultEdges.lockEdge; + hingeEdge = DefaultEdges.hingeEdge; + topEdge = DefaultEdges.topEdge; + bottomEdge = DefaultEdges.bottomEdge; + } + if (doorOp.DoorOpTypId == 20) + { + DefaultSizing = JsonConvert.DeserializeObject(doorOp.JsoncConfigVal); + width = double.Parse(DefaultSizing.width); + height = double.Parse(DefaultSizing.height); + thickness = double.Parse(DefaultSizing.thickness); + } + if (doorOp.DoorOpTypId == 21) + { + DefaultOpening = JsonConvert.DeserializeObject(doorOp.JsoncConfigVal); + swing = DefaultOpening.swing; + } + } + } } - protected override async Task OnInitializedAsync() + protected override async Task OnParametersSetAsync() { await ReloadData(); } diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index a844239..cd78690 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -340,6 +340,46 @@ namespace WebDoorCreator.UI.Data Log.Debug($"DoorGetByOrderId | {source} in: {ts.TotalMilliseconds} ms"); return dbResult; } + /// + /// Doors list by orderId + /// + public async Task?> DoorOpGetByDoorId(int doorId) + { + string source = "DB"; + List? dbResult = new List(); + // cerco da cache + string currKey = $"{rKeyDoorOp}:{doorId}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.DoorOpGetByDoorId(doorId); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"DoorOpGetByDoorId | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } /// /// Add door @@ -418,7 +458,7 @@ namespace WebDoorCreator.UI.Data else { #endif - dbResult = await dbController.DoorOpGetDefault(); + dbResult = await dbController.DoorOpTypeGetDefault(); #if false rawData = JsonConvert.SerializeObject(dbResult, JSSettings); await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); diff --git a/WebDoorCreator.UI/Pages/DoorDefinition.razor b/WebDoorCreator.UI/Pages/DoorDefinition.razor index 2b13e1f..b3f3bab 100644 --- a/WebDoorCreator.UI/Pages/DoorDefinition.razor +++ b/WebDoorCreator.UI/Pages/DoorDefinition.razor @@ -16,7 +16,7 @@
- +
diff --git a/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs b/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs index 861479e..c290328 100644 --- a/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs +++ b/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.WebUtilities; using Microsoft.JSInterop; +using Newtonsoft.Json; using WebDoorCreator.Data.DbModels; using WebDoorCreator.UI.Data; @@ -11,6 +12,8 @@ namespace WebDoorCreator.UI.Pages #region Protected Properties protected int idOrd { get; set; } = 0; + protected int idDoor { get; set; } = 0; + [Inject] protected IJSRuntime JSRuntime { get; set; } = null!; @@ -31,11 +34,13 @@ namespace WebDoorCreator.UI.Pages { await Task.Delay(1); var uri = NavManager.ToAbsoluteUri(NavManager.Uri); - if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("idOrd", out var _idOrd)) + if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("idOrd", out var _idOrd) && QueryHelpers.ParseQuery(uri.Query).TryGetValue("idDoor", out var _idDoor)) { idOrd = int.Parse(_idOrd); + idDoor = int.Parse(_idDoor); await reloadData(); } + } protected async Task reloadData() From 30638a351461ef1db22ee001fa1f67830e362323 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Fri, 31 Mar 2023 15:06:31 +0200 Subject: [PATCH 28/43] gestione creazione porza --- WebDoorCreator.Core/Enum.cs | 7 ++ .../Controllers/WebDoorCreatorController.cs | 24 +++++++ .../Components/Buttons/ButtonsDoorDef.razor | 13 ++++ .../Buttons/ButtonsDoorDef.razor.cs | 37 ++++++++++ .../Components/DoorDef/DoorDefHwStep.razor | 3 + .../Components/DoorDef/DoorDefHwStep.razor.cs | 21 ++++++ .../DoorDef/DoorDefOrderTopRow.razor.cs | 1 + .../Components/DoorDef/DoorSizingStep.razor | 6 +- .../DoorDef/DoorSizingStep.razor.cs | 69 +++++++++++++++---- .../Components/DoorDef/StepsList.razor | 6 +- .../Components/DoorDef/StepsList.razor.cs | 30 ++++++++ .../Components/Gen/NavMenuHorizontal.razor | 2 +- .../Data/WebDoorCreatorService.cs | 43 ++++++++++++ WebDoorCreator.UI/Pages/DoorDefinition.razor | 7 +- .../Pages/DoorDefinition.razor.cs | 12 ++-- WebDoorCreator.UI/Pages/OrderDetails.razor.cs | 2 +- 16 files changed, 252 insertions(+), 31 deletions(-) create mode 100644 WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor create mode 100644 WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor.cs create mode 100644 WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor create mode 100644 WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor.cs diff --git a/WebDoorCreator.Core/Enum.cs b/WebDoorCreator.Core/Enum.cs index 61b2166..e869fc4 100644 --- a/WebDoorCreator.Core/Enum.cs +++ b/WebDoorCreator.Core/Enum.cs @@ -24,6 +24,13 @@ User = 5 } + public enum DoorDefStep + { + Door = 0, + Hardware, + report + } + #endregion Public Enums } } \ No newline at end of file diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index 811fde7..745effb 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -536,6 +536,30 @@ namespace WebDoorCreator.Data.Controllers } return fatto; } + /// + /// Getting all the graphic parameters by hw id + /// + /// Hardware's id to search for + /// + public List ParamGetByHwId(int hwId) + { + List dbResult = new List(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + dbResult = localDbCtx + .DbSetGraphicParams + .Where(x=>x.compoId == hwId) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Eccezione durante ParamGetByHwId: {Environment.NewLine}{exc}"); + } + } + return dbResult; + } /// /// Retrieving data from roles table diff --git a/WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor b/WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor new file mode 100644 index 0000000..39428c4 --- /dev/null +++ b/WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor @@ -0,0 +1,13 @@ +
+ @if (change) + { + + } + else + { + + } + +
+ + diff --git a/WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor.cs b/WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor.cs new file mode 100644 index 0000000..fe1af83 --- /dev/null +++ b/WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor.cs @@ -0,0 +1,37 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; + +namespace WebDoorCreator.UI.Components.Buttons +{ + public partial class ButtonsDoorDef + { + [Parameter] + public bool paramsChanged { get; set; } + + [Parameter] + public int idOrd { get; set; } = 0; + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + [Inject] + protected NavigationManager NavManager { get; set; } = null!; + + protected bool change { get;set; } + + protected async Task toOrderPage() + { + if (!await JSRuntime.InvokeAsync("confirm", $"Do you really want to return to the order page without saving current work?")) + return; + + await Task.Delay(1); + NavManager.NavigateTo($"OrderDetails?idOrd={idOrd}"); + } + + protected override async Task OnParametersSetAsync() + { + await Task.Delay(1); + change = paramsChanged; + } + } +} \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor b/WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor new file mode 100644 index 0000000..b5b4861 --- /dev/null +++ b/WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor @@ -0,0 +1,3 @@ +@if(ListGraphicParams != null){ + +} \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor.cs b/WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor.cs new file mode 100644 index 0000000..ae3c766 --- /dev/null +++ b/WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor.cs @@ -0,0 +1,21 @@ +using Microsoft.AspNetCore.Components; +using WebDoorCreator.Data.DbModels; +using WebDoorCreator.UI.Data; + +namespace WebDoorCreator.UI.Components.DoorDef +{ + public partial class DoorDefHwStep + { + + [Inject] + protected WebDoorCreatorService WDService { get; set; } = null!; + + List? ListGraphicParams { get; set; } = null; + + + protected async override Task OnInitializedAsync() + { + ListGraphicParams = await WDService.ParamGetByHwId(6); + } + } +} \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/DoorDef/DoorDefOrderTopRow.razor.cs b/WebDoorCreator.UI/Components/DoorDef/DoorDefOrderTopRow.razor.cs index d26782b..c6b3ef4 100644 --- a/WebDoorCreator.UI/Components/DoorDef/DoorDefOrderTopRow.razor.cs +++ b/WebDoorCreator.UI/Components/DoorDef/DoorDefOrderTopRow.razor.cs @@ -7,5 +7,6 @@ namespace WebDoorCreator.UI.Components.DoorDef { [Parameter] public OrderStatusViewModel? currOrderStatus { get; set; } = null; + } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor b/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor index 1f1fe57..c7debcc 100644 --- a/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor +++ b/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor @@ -21,11 +21,11 @@
} - else if(isOpening) + else if (isOpening) {
Swing
- @if (ListSwings != null) { @foreach (var item in ListSwings) @@ -40,7 +40,7 @@ {
Lock edge
- @if (ListEdges != null) { @foreach (var item in ListEdges) diff --git a/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs b/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs index a894815..7b04e9c 100644 --- a/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs +++ b/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs @@ -13,6 +13,9 @@ namespace WebDoorCreator.UI.Components.DoorDef [Parameter] public int DoorId { get; set; } = 0; + [Parameter] + public EventCallback E_paramChanged { get; set; } + protected bool isSizing { get; set; } = true; protected List? ListSwings { get; set; } = null; protected List? ListEdges { get; set; } = null; @@ -34,6 +37,7 @@ namespace WebDoorCreator.UI.Components.DoorDef } protected bool isEdges { get; set; } = false; + protected bool paramIsChanged { get; set; } = false; protected string isEdgesActive { @@ -66,7 +70,18 @@ namespace WebDoorCreator.UI.Components.DoorDef protected string lockEdge { get => _lockEdge; - set=> _lockEdge = value; + set + { + _lockEdge = value; + if (DefaultEdges != null) + { + if (_lockEdge != DefaultEdges.lockEdge) + { + paramIsChanged = true; + var pUpd = Task.Run(async () => await E_paramChanged.InvokeAsync(paramIsChanged)); + } + } + } } protected string _hingeEdge { get; set; } = ""; @@ -107,7 +122,7 @@ namespace WebDoorCreator.UI.Components.DoorDef get => _height; set => _height = value; } - protected double _thickness{ get; set; } = 0.0; + protected double _thickness { get; set; } = 0.0; protected double thickness { @@ -135,23 +150,45 @@ namespace WebDoorCreator.UI.Components.DoorDef { if (doorOp.DoorOpTypId == 19) { - DefaultEdges = JsonConvert.DeserializeObject(doorOp.JsoncConfigVal); - lockEdge = DefaultEdges.lockEdge; - hingeEdge = DefaultEdges.hingeEdge; - topEdge = DefaultEdges.topEdge; - bottomEdge = DefaultEdges.bottomEdge; + var edges = JsonConvert.DeserializeObject>(doorOp.JsoncConfigVal); + if (edges != null) + { + DefaultEdges = edges.FirstOrDefault(); + if (DefaultEdges != null) + { + lockEdge = DefaultEdges.lockEdge; + hingeEdge = DefaultEdges.hingeEdge; + topEdge = DefaultEdges.topEdge; + bottomEdge = DefaultEdges.bottomEdge; + + } + } } if (doorOp.DoorOpTypId == 20) { - DefaultSizing = JsonConvert.DeserializeObject(doorOp.JsoncConfigVal); - width = double.Parse(DefaultSizing.width); - height = double.Parse(DefaultSizing.height); - thickness = double.Parse(DefaultSizing.thickness); + var sizing = JsonConvert.DeserializeObject>(doorOp.JsoncConfigVal); + if (sizing != null) + { + DefaultSizing = sizing.FirstOrDefault(); + if (DefaultSizing != null) + { + width = double.Parse(DefaultSizing.width); + height = double.Parse(DefaultSizing.height); + thickness = double.Parse(DefaultSizing.thickness); + } + } } if (doorOp.DoorOpTypId == 21) { - DefaultOpening = JsonConvert.DeserializeObject(doorOp.JsoncConfigVal); - swing = DefaultOpening.swing; + var opening = JsonConvert.DeserializeObject>(doorOp.JsoncConfigVal); + if (opening != null) + { + DefaultOpening = opening.FirstOrDefault(); + if (DefaultOpening != null) + { + swing = DefaultOpening.swing; + } + } } } } @@ -159,7 +196,11 @@ namespace WebDoorCreator.UI.Components.DoorDef protected override async Task OnParametersSetAsync() { - await ReloadData(); + if (!paramIsChanged) + { + await ReloadData(); + } } + } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/DoorDef/StepsList.razor b/WebDoorCreator.UI/Components/DoorDef/StepsList.razor index 88e5581..65c5325 100644 --- a/WebDoorCreator.UI/Components/DoorDef/StepsList.razor +++ b/WebDoorCreator.UI/Components/DoorDef/StepsList.razor @@ -1,5 +1,5 @@ 
-
Door
-
Hardware
-
Report
+
Door
+
Hardware
+
Report
\ No newline at end of file diff --git a/WebDoorCreator.UI/Components/DoorDef/StepsList.razor.cs b/WebDoorCreator.UI/Components/DoorDef/StepsList.razor.cs index 68e83de..88d0b83 100644 --- a/WebDoorCreator.UI/Components/DoorDef/StepsList.razor.cs +++ b/WebDoorCreator.UI/Components/DoorDef/StepsList.razor.cs @@ -1,6 +1,36 @@ +using Microsoft.AspNetCore.Components; + namespace WebDoorCreator.UI.Components.DoorDef { public partial class StepsList { + [Parameter] + public Core.Enum.DoorDefStep DoorDefStep { get; set; } = Core.Enum.DoorDefStep.Door; + + protected string doorCSS { get; set; } = "btn-secondary"; + protected string hwCSS { get; set; } = "btn-secondary"; + protected string reportCSS { get; set; } = "btn-secondary"; + + + protected override async Task OnParametersSetAsync() + { + await Task.Delay(1); + + if(DoorDefStep == Core.Enum.DoorDefStep.Door) + { + doorCSS = "btn-success"; + } + else if (DoorDefStep == Core.Enum.DoorDefStep.Hardware) + { + doorCSS = "btn-success"; + hwCSS = "btn-success"; + } + else if(DoorDefStep == Core.Enum.DoorDefStep.report) + { + doorCSS = "btn-success"; + hwCSS = "btn-success"; + reportCSS = "btn-success"; + } + } } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor index 2ba0dca..661bc92 100644 --- a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor +++ b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor @@ -76,7 +76,7 @@ diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index cd78690..e8a3d56 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -568,6 +568,48 @@ namespace WebDoorCreator.UI.Data return listGraphicParams; } + /// + /// Graphic parameters list by hw id + /// + public async Task?> ParamGetByHwId(int hwId) + { + string source = "DB"; + + List? dbResult = new List(); + // cerco da cache + string currKey = $"{rKeyGraphicParameters}:{hwId}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.ParamGetByHwId(hwId); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"ParamGetByHwId | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + /// /// Company list /// @@ -900,6 +942,7 @@ namespace WebDoorCreator.UI.Data protected const string rKeyUsers = $"{redisBaseAddr}:Cache:Users"; protected const string rKeyUsersView = $"{redisBaseAddr}:Cache:UsersView"; + protected const string rKeyGraphicParameters = $"{redisBaseAddr}:Cache:GraphicParameters"; protected Random rnd = new Random(); diff --git a/WebDoorCreator.UI/Pages/DoorDefinition.razor b/WebDoorCreator.UI/Pages/DoorDefinition.razor index b3f3bab..5708362 100644 --- a/WebDoorCreator.UI/Pages/DoorDefinition.razor +++ b/WebDoorCreator.UI/Pages/DoorDefinition.razor @@ -4,9 +4,7 @@

Door Definition

-
- -
+
@@ -16,7 +14,8 @@
- + @**@ +
diff --git a/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs b/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs index c290328..353b437 100644 --- a/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs +++ b/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs @@ -13,6 +13,7 @@ namespace WebDoorCreator.UI.Pages protected int idOrd { get; set; } = 0; protected int idDoor { get; set; } = 0; + protected bool paramChanged { get; set; } = false; [Inject] @@ -56,13 +57,14 @@ namespace WebDoorCreator.UI.Pages await Task.Delay(1); } - protected async Task toOrderPage() + protected async Task catchParamChange(bool ParamChanged) { - if (!await JSRuntime.InvokeAsync("confirm", $"Do you really want to return to the order page without saving current work?")) - return; - await Task.Delay(1); - NavManager.NavigateTo($"OrderDetails?idOrd={idOrd}"); + paramChanged = ParamChanged; + await InvokeAsync(() => + { + StateHasChanged(); + }); } #endregion Protected Methods diff --git a/WebDoorCreator.UI/Pages/OrderDetails.razor.cs b/WebDoorCreator.UI/Pages/OrderDetails.razor.cs index b8c2b33..8583cdc 100644 --- a/WebDoorCreator.UI/Pages/OrderDetails.razor.cs +++ b/WebDoorCreator.UI/Pages/OrderDetails.razor.cs @@ -55,7 +55,7 @@ namespace WebDoorCreator.UI.Pages #region Private Fields - private List? ListOrdersStatus = null; + private List?ListOrdersStatus = null; protected async Task createDoor() { From 8d990e0dab9e76513ad1c497eabb72d51e7e446d Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 31 Mar 2023 15:29:08 +0200 Subject: [PATCH 29/43] DB Model aggiornato x DoorOpType - Add migration - update caricamento --- .../DbModels/DoorOpTypeModel.cs | 16 +- .../WDCData/20230330111904_DoorOpTypeinit.cs | 4 +- ...30331131556_DoorOpTypeExtend01.Designer.cs | 723 ++++++++++++++++++ .../20230331131556_DoorOpTypeExtend01.cs | 58 ++ .../WDCData/WDCDataContextModelSnapshot.cs | 12 +- .../Data/WebDoorCreatorService.cs | 309 ++++---- WebDoorCreator.UI/Pages/DoorDefinition.razor | 4 +- WebDoorCreator.UI/WebDoorCreator.UI.csproj | 1 + 8 files changed, 973 insertions(+), 154 deletions(-) create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230331131556_DoorOpTypeExtend01.Designer.cs create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230331131556_DoorOpTypeExtend01.cs diff --git a/WebDoorCreator.Data/DbModels/DoorOpTypeModel.cs b/WebDoorCreator.Data/DbModels/DoorOpTypeModel.cs index 561a726..2bf2aca 100644 --- a/WebDoorCreator.Data/DbModels/DoorOpTypeModel.cs +++ b/WebDoorCreator.Data/DbModels/DoorOpTypeModel.cs @@ -56,17 +56,24 @@ namespace WebDoorCreator.Data.DbModels /// public string HwDescription { get; set; } = ""; + + /// + /// URL dell'immagine/link di riferimento + /// + public string DisplayUrl { get; set; } = ""; + /// /// Path folder/file di riferimento /// public string FPath { get; set; } = ""; -#if false - + /// /// Idx univoco dell'elemento parent (se 0 = root) /// public int ParentDoorOpId { get; set; } = 0; +#if false + /// /// Codice tipo treeView /// @@ -118,6 +125,11 @@ namespace WebDoorCreator.Data.DbModels get => DateTime.Today >= ValidFrom && DateTime.Today <= ValidUntil; } + /// + /// Numero massimo associabile a singola Door + /// + public int MaxAllowed { get; set; } = 1; + #if false [ForeignKey("ParentDoorOpId")] public virtual DoorOpModel? ParentNav { get; set; } diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230330111904_DoorOpTypeinit.cs b/WebDoorCreator.Data/Migrations/WDCData/20230330111904_DoorOpTypeinit.cs index 90aa679..b2c2e09 100644 --- a/WebDoorCreator.Data/Migrations/WDCData/20230330111904_DoorOpTypeinit.cs +++ b/WebDoorCreator.Data/Migrations/WDCData/20230330111904_DoorOpTypeinit.cs @@ -9,7 +9,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( - name: "IsDefault", + name: "Isdefault", table: "DoorOpType", type: "bit", nullable: false, @@ -19,7 +19,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropColumn( - name: "IsDefault", + name: "Isdefault", table: "DoorOpType"); } } diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230331131556_DoorOpTypeExtend01.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230331131556_DoorOpTypeExtend01.Designer.cs new file mode 100644 index 0000000..37a15bf --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230331131556_DoorOpTypeExtend01.Designer.cs @@ -0,0 +1,723 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230331131556_DoorOpTypeExtend01")] + partial class DoorOpTypeExtend01 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateLockExpiry") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MeasureUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdLock") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorOpIdPathFromPatriarch") + .HasColumnType("hierarchyid"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MaxAllowed") + .HasColumnType("int"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentDoorOpId") + .HasColumnType("int"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => + { + b.Property("GraphicParamId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GraphicParamId"), 1L, 1); + + b.Property("compoId") + .HasColumnType("int"); + + b.Property("graphicParamAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamDefaultVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamsN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("GraphicParamId"); + + b.ToTable("GraphicParams"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => + { + b.Property("HardwareId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("HardwareId"), 1L, 1); + + b.Property("compoAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoLayerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoTemplateIsActive") + .HasColumnType("bit"); + + b.HasKey("HardwareId"); + + b.ToTable("Hardware"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230331131556_DoorOpTypeExtend01.cs b/WebDoorCreator.Data/Migrations/WDCData/20230331131556_DoorOpTypeExtend01.cs new file mode 100644 index 0000000..ed3c2d3 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230331131556_DoorOpTypeExtend01.cs @@ -0,0 +1,58 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class DoorOpTypeExtend01 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Isdefault", + table: "DoorOpType", + newName: "IsDefault"); + + migrationBuilder.AddColumn( + name: "DisplayUrl", + table: "DoorOpType", + type: "nvarchar(max)", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "MaxAllowed", + table: "DoorOpType", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ParentDoorOpId", + table: "DoorOpType", + type: "int", + nullable: false, + defaultValue: 0); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "DisplayUrl", + table: "DoorOpType"); + + migrationBuilder.DropColumn( + name: "MaxAllowed", + table: "DoorOpType"); + + migrationBuilder.DropColumn( + name: "ParentDoorOpId", + table: "DoorOpType"); + + migrationBuilder.RenameColumn( + name: "IsDefault", + table: "DoorOpType", + newName: "Isdefault"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs index 9f2b13d..cc2af84 100644 --- a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs +++ b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs @@ -296,6 +296,10 @@ namespace WebDoorCreator.Data.Migrations.WDCData .IsRequired() .HasColumnType("nvarchar(max)"); + b.Property("DisplayUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + b.Property("DoorOpIdPathFromPatriarch") .HasColumnType("hierarchyid"); @@ -325,17 +329,23 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.Property("IsConcrete") .HasColumnType("bit"); - b.Property("Isdefault") + b.Property("IsDefault") .HasColumnType("bit"); b.Property("JsoncConfig") .IsRequired() .HasColumnType("nvarchar(max)"); + b.Property("MaxAllowed") + .HasColumnType("int"); + b.Property("OpCode") .IsRequired() .HasColumnType("nvarchar(max)"); + b.Property("ParentDoorOpId") + .HasColumnType("int"); + b.Property("Rev") .IsRequired() .HasColumnType("nvarchar(max)"); diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index e8a3d56..f5466f6 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -152,8 +152,7 @@ namespace WebDoorCreator.UI.Data { bool fatto = false; string compoName = ""; - int n = 1; - int i = 1; + int numHier = 0; List listGraphicParams = new List(); dbController.TestTablesTruncate(); @@ -163,57 +162,7 @@ namespace WebDoorCreator.UI.Data //estraggo tutte le sotto directory della cartella \EgtData\Doors\EgtCompoBase\Compo string[] dirs = Directory.GetDirectories(rootPath, "*", SearchOption.TopDirectoryOnly); - foreach (string dir in dirs) - { - //iterazione per cercare tutti i file "Config.ini" nelle sotto directory - string[] files = Directory.GetFiles(dir, "Config.ini"); - - compoName = ""; - //iterazione per cercare tutti i file "Config.ini" nelle sotto directory - foreach (string file in files) - { - 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; - string layerName = fIni.ReadString("Layer", "LayerName", "LAYER"); - if (isActive == "0") - { - compoTemplateIsActive = false; - } - var compoNameSplit = compoName.Split("/"); // lo slash indica l'alias - if (listActiveCompo.Contains(compoNameSplit[0].ToString())) - { - HardwareModel compoConfig = new HardwareModel() { compoName = $"{compoNameSplit[0]}", 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 - n = 1; - foreach (var match in lineToSearch) - { - listGraphicParams = await GraphicParamsGetAll(file, match, n, i); - n++; - } - - DoorOpTypeModel doorOpType = new DoorOpTypeModel() - { - Description = $"DOOR OPERATION TYPE FOR {compoNameSplit[0]}", - OpCode = opCode.ToString(), - HasHw = true, - IsConcrete = true, - HwCode = compoNameSplit[0].ToString(), - DoorOpIdPathFromPatriarch = HierarchyId.Parse("/1/"), - JsoncConfig = JsonConvert.SerializeObject(listGraphicParams) - }; - - await dbController.DoorOpTypeAdd(doorOpType); - } - i++; - } - } - + // parto con obj base List edges = new List(); edges.Add(new Edges()); List sizing = new List(); @@ -229,9 +178,11 @@ namespace WebDoorCreator.UI.Data OpCode = opCodeEdges.ToString(), HasHw = false, IsConcrete = true, - DoorOpIdPathFromPatriarch = HierarchyId.Parse("/1/"), + DoorOpIdPathFromPatriarch = HierarchyId.Parse($"/{numHier++}/"), IsDefault = true, - JsoncConfig = JsonConvert.SerializeObject(edges) + JsoncConfig = JsonConvert.SerializeObject(edges), + DisplayUrl = $"DoorOpTypeImg/{numHier}.svg", + MaxAllowed = 1 }; DoorOpTypeModel doorOpTypeSizing = new DoorOpTypeModel() { @@ -239,9 +190,11 @@ namespace WebDoorCreator.UI.Data OpCode = opCodeSizing.ToString(), HasHw = false, IsConcrete = true, - DoorOpIdPathFromPatriarch = HierarchyId.Parse("/1/"), + DoorOpIdPathFromPatriarch = HierarchyId.Parse($"/{numHier++}/"), IsDefault = true, - JsoncConfig = JsonConvert.SerializeObject(sizing) + JsoncConfig = JsonConvert.SerializeObject(sizing), + DisplayUrl = $"DoorOpTypeImg/{numHier}.svg", + MaxAllowed = 1 }; DoorOpTypeModel doorOpTypeOpening = new DoorOpTypeModel() { @@ -249,11 +202,74 @@ namespace WebDoorCreator.UI.Data OpCode = opCodeOpening.ToString(), HasHw = false, IsConcrete = true, - DoorOpIdPathFromPatriarch = HierarchyId.Parse("/1/"), + DoorOpIdPathFromPatriarch = HierarchyId.Parse($"/{numHier++}/"), IsDefault = true, - JsoncConfig = JsonConvert.SerializeObject(opening) + JsoncConfig = JsonConvert.SerializeObject(opening), + DisplayUrl = $"DoorOpTypeImg/{numHier}.svg", + MaxAllowed = 1 }; + foreach (string dir in dirs) + { + int numPar = 1; + int numHead = 1; + // scansione della directory... + string[] files = Directory.GetFiles(dir, "Config.ini"); + + compoName = ""; + //iterazione per cercare tutti numPar file "Config.ini" nelle sotto directory + foreach (string file in files) + { + //leggo tutte le linee del file + List lines = File.ReadAllLines(file).ToList(); + IniFile fIni = new IniFile(file); + Guid opCode = Guid.NewGuid(); + //cerco la sezione del file ed estraggo il nome del componente + compoName = fIni.ReadString("Compo", "Name", "COMPONAME"); + //cerco la sezione del file ed estraggo se numPar template sono attivi per il seguente componente + var isActive = fIni.ReadString("Template", "IsActive", "1"); + bool compoTemplateIsActive = true; + string layerName = fIni.ReadString("Layer", "LayerName", "LAYER"); + if (isActive == "0") + { + compoTemplateIsActive = false; + } + // lo slash indica l'alias + var compoNameSplit = compoName.Split("/"); + if (listActiveCompo.Contains(compoNameSplit[0].ToString())) + { + //creo il componente (padre) + HardwareModel compoConfig = new HardwareModel() { compoName = $"{compoNameSplit[0]}", compoAlias = compoNameSplit[1].ToString(), compoLayerName = layerName, compoTemplateIsActive = compoTemplateIsActive }; + await dbController.CompoAdd(compoConfig); + listCompoS.Add(compoConfig); + //cerco all'interno del file tutte le sezioni che contengono "[Graphic" così da poter prendere il nome della sezione ES: [Graphic parameters1] = Graphic parameters1 + var lineToSearch = lines.Where(x => x.Contains("[Graphic")).ToList(); + numHead = 1; + foreach (var match in lineToSearch) + { + listGraphicParams = await GraphicParamsGetAll(file, match, numHead, numPar); + numHead++; + } + + DoorOpTypeModel doorOpType = new DoorOpTypeModel() + { + Description = $"DOOR OPERATION TYPE FOR {compoNameSplit[0]}", + OpCode = opCode.ToString(), + HasHw = true, + IsConcrete = true, + HwCode = compoNameSplit[0].ToString(), + DoorOpIdPathFromPatriarch = HierarchyId.Parse($"/{numHier++}/"), + JsoncConfig = JsonConvert.SerializeObject(listGraphicParams), + DisplayUrl = $"DoorOpTypeImg/{numHier}.svg", + MaxAllowed = 2 + }; + + await dbController.DoorOpTypeAdd(doorOpType); + } + numPar++; + } + } + await dbController.DoorOpTypeAdd(doorOpTypeEdges); await dbController.DoorOpTypeAdd(doorOpTypeSizing); await dbController.DoorOpTypeAdd(doorOpTypeOpening); @@ -340,46 +356,6 @@ namespace WebDoorCreator.UI.Data Log.Debug($"DoorGetByOrderId | {source} in: {ts.TotalMilliseconds} ms"); return dbResult; } - /// - /// Doors list by orderId - /// - public async Task?> DoorOpGetByDoorId(int doorId) - { - string source = "DB"; - List? dbResult = new List(); - // cerco da cache - string currKey = $"{rKeyDoorOp}:{doorId}"; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - string? rawData = await redisDb.StringGetAsync(currKey); - if (!string.IsNullOrEmpty(rawData)) - { - source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject>(rawData); - if (tempResult == null) - { - dbResult = new List(); - } - else - { - dbResult = tempResult; - } - } - else - { - dbResult = dbController.DoorOpGetByDoorId(doorId); - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); - } - if (dbResult == null) - { - dbResult = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"DoorOpGetByDoorId | {source} in: {ts.TotalMilliseconds} ms"); - return dbResult; - } /// /// Add door @@ -428,6 +404,47 @@ namespace WebDoorCreator.UI.Data return answ; } + /// + /// Doors list by orderId + /// + public async Task?> DoorOpGetByDoorId(int doorId) + { + string source = "DB"; + List? dbResult = new List(); + // cerco da cache + string currKey = $"{rKeyDoorOp}:{doorId}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.DoorOpGetByDoorId(doorId); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"DoorOpGetByDoorId | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + /// /// lista DoorOp necessarie all'init /// @@ -456,13 +473,13 @@ namespace WebDoorCreator.UI.Data } } else - { + { #endif dbResult = await dbController.DoorOpTypeGetDefault(); #if false rawData = JsonConvert.SerializeObject(dbResult, JSSettings); await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); - } + } #endif if (dbResult == null) { @@ -535,7 +552,7 @@ namespace WebDoorCreator.UI.Data IniFile fIni = new IniFile(file); //estraggo la lista di componenti che sono attive per il cliente var graphicParamsName = fIni.ReadSection(match.Substring(1, match.Length - 2)); //cerco il contenuto delle sezioni - if (int.Parse(match.Substring(match.Length - 2, 1)) == n) //controllo se tra i numeri di graphic params vi è un buco ES: Graphic parameters1 Graphic parameters3 se il buco c'è salto tutti i parametri che stanno dopo il buco ==> tengo conto solo di Graphic parameters1 + if (int.Parse(match.Substring(match.Length - 2, 1)) == n) //controllo se tra numPar numeri di graphic params vi è un buco ES: Graphic parameters1 Graphic parameters3 se il buco c'è salto tutti numPar parametri che stanno dopo il buco ==> tengo conto solo di Graphic parameters1 { foreach (string param in graphicParamsName) { @@ -568,48 +585,6 @@ namespace WebDoorCreator.UI.Data return listGraphicParams; } - /// - /// Graphic parameters list by hw id - /// - public async Task?> ParamGetByHwId(int hwId) - { - string source = "DB"; - - List? dbResult = new List(); - // cerco da cache - string currKey = $"{rKeyGraphicParameters}:{hwId}"; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - string? rawData = await redisDb.StringGetAsync(currKey); - if (!string.IsNullOrEmpty(rawData)) - { - source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject>(rawData); - if (tempResult == null) - { - dbResult = new List(); - } - else - { - dbResult = tempResult; - } - } - else - { - dbResult = dbController.ParamGetByHwId(hwId); - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); - } - if (dbResult == null) - { - dbResult = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"ParamGetByHwId | {source} in: {ts.TotalMilliseconds} ms"); - return dbResult; - } - /// /// Company list /// @@ -747,6 +722,48 @@ namespace WebDoorCreator.UI.Data return dbResult; } + /// + /// Graphic parameters list by hw id + /// + public async Task?> ParamGetByHwId(int hwId) + { + string source = "DB"; + + List? dbResult = new List(); + // cerco da cache + string currKey = $"{rKeyGraphicParameters}:{hwId}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.ParamGetByHwId(hwId); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"ParamGetByHwId | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + /// /// roles list /// @@ -931,6 +948,7 @@ namespace WebDoorCreator.UI.Data protected const string rKeyDoorOpType = $"{redisBaseAddr}:Cache:DoorOpType"; + protected const string rKeyGraphicParameters = $"{redisBaseAddr}:Cache:GraphicParameters"; protected const string rKeyListValues = $"{redisBaseAddr}:Cache:ListValues"; protected const string rKeyOrderDetail = $"{redisBaseAddr}:Cache:OrderDetail"; @@ -942,8 +960,6 @@ namespace WebDoorCreator.UI.Data protected const string rKeyUsers = $"{redisBaseAddr}:Cache:Users"; protected const string rKeyUsersView = $"{redisBaseAddr}:Cache:UsersView"; - protected const string rKeyGraphicParameters = $"{redisBaseAddr}:Cache:GraphicParameters"; - protected Random rnd = new Random(); #endregion Protected Fields @@ -1038,6 +1054,5 @@ namespace WebDoorCreator.UI.Data } #endregion Private Methods - } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/DoorDefinition.razor b/WebDoorCreator.UI/Pages/DoorDefinition.razor index 5708362..41d514d 100644 --- a/WebDoorCreator.UI/Pages/DoorDefinition.razor +++ b/WebDoorCreator.UI/Pages/DoorDefinition.razor @@ -14,8 +14,8 @@
- @**@ - + + @**@
diff --git a/WebDoorCreator.UI/WebDoorCreator.UI.csproj b/WebDoorCreator.UI/WebDoorCreator.UI.csproj index c23d9ee..4406b62 100644 --- a/WebDoorCreator.UI/WebDoorCreator.UI.csproj +++ b/WebDoorCreator.UI/WebDoorCreator.UI.csproj @@ -39,6 +39,7 @@ + From 9ed8f175c0a8c428e3c6f6d20eda197176810f0f Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 31 Mar 2023 15:40:50 +0200 Subject: [PATCH 30/43] update metodo inserimento x numerazione HierarchId --- .../Controllers/WebDoorCreatorController.cs | 28 +++++++++++++++- .../Data/WebDoorCreatorService.cs | 32 +++++++++++++------ 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index 745effb..165d925 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -318,7 +318,33 @@ namespace WebDoorCreator.Data.Controllers } catch (Exception exc) { - Log.Error($"Eccezione durante DoorOpTypeAdd: {Environment.NewLine}{exc}"); + Log.Error($"Eccezione durante DoorOpTypeAdd:{Environment.NewLine}{exc}"); + } + } + + return fatto; + } + /// + /// Adding a new DoorOpType + /// + /// Record to add + /// + public async Task DoorOpTypeAddRange(List listRec) + { + bool fatto = false; + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + localDbCtx + .DbSetDoorOpType + .AddRange(listRec); + await localDbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante DoorOpTypeAddRange:{Environment.NewLine}{exc}"); } } return fatto; diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index f5466f6..43fec77 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -152,7 +152,7 @@ namespace WebDoorCreator.UI.Data { bool fatto = false; string compoName = ""; - int numHier = 0; + int numHier = 1; List listGraphicParams = new List(); dbController.TestTablesTruncate(); @@ -162,6 +162,9 @@ namespace WebDoorCreator.UI.Data //estraggo tutte le sotto directory della cartella \EgtData\Doors\EgtCompoBase\Compo string[] dirs = Directory.GetDirectories(rootPath, "*", SearchOption.TopDirectoryOnly); + // elenco obj da inserire + List ListObjDOT = new List(); + // parto con obj base List edges = new List(); edges.Add(new Edges()); @@ -178,36 +181,46 @@ namespace WebDoorCreator.UI.Data OpCode = opCodeEdges.ToString(), HasHw = false, IsConcrete = true, - DoorOpIdPathFromPatriarch = HierarchyId.Parse($"/{numHier++}/"), + DoorOpIdPathFromPatriarch = HierarchyId.Parse($"/{numHier}/"), IsDefault = true, JsoncConfig = JsonConvert.SerializeObject(edges), DisplayUrl = $"DoorOpTypeImg/{numHier}.svg", MaxAllowed = 1 }; + numHier++; DoorOpTypeModel doorOpTypeSizing = new DoorOpTypeModel() { Description = "DOOR OPERATION TYPE FOR Sizing", OpCode = opCodeSizing.ToString(), HasHw = false, IsConcrete = true, - DoorOpIdPathFromPatriarch = HierarchyId.Parse($"/{numHier++}/"), + DoorOpIdPathFromPatriarch = HierarchyId.Parse($"/{numHier}/"), IsDefault = true, JsoncConfig = JsonConvert.SerializeObject(sizing), DisplayUrl = $"DoorOpTypeImg/{numHier}.svg", MaxAllowed = 1 }; + numHier++; DoorOpTypeModel doorOpTypeOpening = new DoorOpTypeModel() { Description = "DOOR OPERATION TYPE FOR Opening", OpCode = opCodeOpening.ToString(), HasHw = false, IsConcrete = true, - DoorOpIdPathFromPatriarch = HierarchyId.Parse($"/{numHier++}/"), + DoorOpIdPathFromPatriarch = HierarchyId.Parse($"/{numHier}/"), IsDefault = true, JsoncConfig = JsonConvert.SerializeObject(opening), DisplayUrl = $"DoorOpTypeImg/{numHier}.svg", MaxAllowed = 1 }; + numHier++; + + //await dbController.DoorOpTypeAdd(doorOpTypeEdges); + //await dbController.DoorOpTypeAdd(doorOpTypeSizing); + //await dbController.DoorOpTypeAdd(doorOpTypeOpening); + ListObjDOT.Add(doorOpTypeEdges); + ListObjDOT.Add(doorOpTypeSizing); + ListObjDOT.Add(doorOpTypeOpening); foreach (string dir in dirs) { @@ -258,21 +271,22 @@ namespace WebDoorCreator.UI.Data HasHw = true, IsConcrete = true, HwCode = compoNameSplit[0].ToString(), - DoorOpIdPathFromPatriarch = HierarchyId.Parse($"/{numHier++}/"), + DoorOpIdPathFromPatriarch = HierarchyId.Parse($"/{numHier}/"), JsoncConfig = JsonConvert.SerializeObject(listGraphicParams), DisplayUrl = $"DoorOpTypeImg/{numHier}.svg", MaxAllowed = 2 }; + numHier++; - await dbController.DoorOpTypeAdd(doorOpType); + ListObjDOT.Add(doorOpType); + //await dbController.DoorOpTypeAdd(doorOpType); } numPar++; } } - await dbController.DoorOpTypeAdd(doorOpTypeEdges); - await dbController.DoorOpTypeAdd(doorOpTypeSizing); - await dbController.DoorOpTypeAdd(doorOpTypeOpening); + fatto = await dbController.DoorOpTypeAddRange(ListObjDOT); + return fatto; } From 809766dd50cb10d0946886b133ab814421661f2b Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Fri, 31 Mar 2023 17:48:43 +0200 Subject: [PATCH 31/43] prima versione grafica hw list --- .../Controllers/WebDoorCreatorController.cs | 38 ++++++-- .../Components/DoorDef/DoorDefHwStep.razor | 3 +- .../Components/Hardware/HardwareList.razor | 17 ++++ .../Components/Hardware/HardwareList.razor.cs | 25 ++++++ .../Hardware/HardwareList.razor.css | 15 ++++ .../Hardware/HardwareList.razor.less | 20 +++++ .../Hardware/HardwareList.razor.min.css | 1 + .../Data/WebDoorCreatorService.cs | 88 ++++++++++++++++++- WebDoorCreator.UI/Pages/DoorDefinition.razor | 3 +- WebDoorCreator.UI/_Imports.razor | 1 + WebDoorCreator.UI/compilerconfig.json | 4 + 11 files changed, 203 insertions(+), 12 deletions(-) create mode 100644 WebDoorCreator.UI/Components/Hardware/HardwareList.razor create mode 100644 WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs create mode 100644 WebDoorCreator.UI/Components/Hardware/HardwareList.razor.css create mode 100644 WebDoorCreator.UI/Components/Hardware/HardwareList.razor.less create mode 100644 WebDoorCreator.UI/Components/Hardware/HardwareList.razor.min.css diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index 165d925..c7074d8 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -321,9 +321,10 @@ namespace WebDoorCreator.Data.Controllers Log.Error($"Eccezione durante DoorOpTypeAdd:{Environment.NewLine}{exc}"); } } - + return fatto; } + /// /// Adding a new DoorOpType /// @@ -562,6 +563,7 @@ namespace WebDoorCreator.Data.Controllers } return fatto; } + /// /// Getting all the graphic parameters by hw id /// @@ -576,7 +578,7 @@ namespace WebDoorCreator.Data.Controllers { dbResult = localDbCtx .DbSetGraphicParams - .Where(x=>x.compoId == hwId) + .Where(x => x.compoId == hwId) .ToList(); } catch (Exception exc) @@ -656,13 +658,6 @@ namespace WebDoorCreator.Data.Controllers .Include(u => u.UsersNav) .Include(u => u.RolesNav) .ToList(); - - //UserRoleClaimDTO userDTO = new UserRoleClaimDTO() - //{ - // userName = item.UserName, - // rolesName = userRoles - //}; - //dbResult.Add(userDTO); } } return dbResult; @@ -754,6 +749,31 @@ namespace WebDoorCreator.Data.Controllers return dbResult; } + /// + /// Retrieving data from door operation type table + /// + /// + public List DoorOpTypeGetAll() + { + List dbResult = new List(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + // extracting entire set + dbResult = localDbCtx + .DbSetDoorOpType + .OrderBy(x => x.DoorOpTypId) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Error in DoorOpTypeGetAll:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + /// /// Retrieving current data from door /// diff --git a/WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor b/WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor index b5b4861..4460ef1 100644 --- a/WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor +++ b/WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor @@ -1,3 +1,4 @@ @if(ListGraphicParams != null){ -} \ No newline at end of file +} + diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor new file mode 100644 index 0000000..bca10d7 --- /dev/null +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor @@ -0,0 +1,17 @@ +@if (doorOp != null) +{ +
+ + @foreach (var item in doorOp) + { +
+
+ @item.HwCode +
+
+ Immagine +
+
+ } +
+} \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs new file mode 100644 index 0000000..3c8ec27 --- /dev/null +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs @@ -0,0 +1,25 @@ +using Microsoft.AspNetCore.Components; +using WebDoorCreator.Data.DbModels; +using WebDoorCreator.UI.Data; + +namespace WebDoorCreator.UI.Components.Hardware +{ + public partial class HardwareList + { + [Inject] + protected WebDoorCreatorService WDService { get; set; } = null!; + + protected List? doorOp { get; set; } = null; + + protected override async Task OnInitializedAsync() + { + var listRecord = await WDService.DoorOpTypeGetAll(); + if (listRecord != null) + { + + doorOp = listRecord.Where(x => !(x.IsDefault)).ToList(); + } + } + + } +} \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.css b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.css new file mode 100644 index 0000000..826eb86 --- /dev/null +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.css @@ -0,0 +1,15 @@ +.hwName { + background-color: #455A64; + margin: 1rem; + padding: 0.5rem; + border-radius: 0.6rem; + text-align: center; + color: #fff; + font-weight: bold; +} +.hwCircle { + background-color: yellow; + border-radius: 50%; + height: 60px; + width: 60px; +} \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.less b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.less new file mode 100644 index 0000000..114ed16 --- /dev/null +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.less @@ -0,0 +1,20 @@ +body { + +} + +.hwName { + background-color: #455A64; + margin: 1rem; + padding: 0.5rem; + border-radius: 0.6rem; + text-align: center; + color: #fff; + font-weight: bold; +} + +.hwCircle{ + background-color: yellow; + border-radius: 50%; + height: 60px; + width: 60px; +} diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.min.css b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.min.css new file mode 100644 index 0000000..291ec5e --- /dev/null +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.min.css @@ -0,0 +1 @@ +.hwName{background-color:#455a64;margin:1rem;padding:.5rem;border-radius:.6rem;text-align:center;color:#fff;font-weight:bold;}.hwCircle{background-color:#ff0;border-radius:50%;height:60px;width:60px;} \ No newline at end of file diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index 43fec77..4717db1 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -270,7 +270,7 @@ namespace WebDoorCreator.UI.Data OpCode = opCode.ToString(), HasHw = true, IsConcrete = true, - HwCode = compoNameSplit[0].ToString(), + HwCode = $"{compoNameSplit[1]}", DoorOpIdPathFromPatriarch = HierarchyId.Parse($"/{numHier}/"), JsoncConfig = JsonConvert.SerializeObject(listGraphicParams), DisplayUrl = $"DoorOpTypeImg/{numHier}.svg", @@ -459,6 +459,49 @@ namespace WebDoorCreator.UI.Data return dbResult; } + /// + /// Doors list by orderId + /// + public async Task?> DoorOpTypeGetAll() + { + string source = "DB"; + List? dbResult = new List(); + // cerco da cache + string currKey = $"{rKeyDoorOpType}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); +#if false + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } +#endif + dbResult = dbController.DoorOpTypeGetAll(); + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"DoorOpTypeGetAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + /// /// lista DoorOp necessarie all'init /// @@ -778,6 +821,48 @@ namespace WebDoorCreator.UI.Data return dbResult; } + /// + /// Graphic parameters list by hw id + /// + //public async Task?> HardwareGetAll() + //{ + // string source = "DB"; + + // List? dbResult = new List(); + // // cerco da cache + // string currKey = $"{rKeyGraphicParameters}"; + // Stopwatch stopWatch = new Stopwatch(); + // stopWatch.Start(); + // string? rawData = await redisDb.StringGetAsync(currKey); + // if (!string.IsNullOrEmpty(rawData)) + // { + // source = "REDIS"; + // var tempResult = JsonConvert.DeserializeObject>(rawData); + // if (tempResult == null) + // { + // dbResult = new List(); + // } + // else + // { + // dbResult = tempResult; + // } + // } + // else + // { + // dbResult = dbController.HardwareGetAll(); + // rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + // await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + // } + // if (dbResult == null) + // { + // dbResult = new List(); + // } + // stopWatch.Stop(); + // TimeSpan ts = stopWatch.Elapsed; + // Log.Debug($"HardwareGetAll | {source} in: {ts.TotalMilliseconds} ms"); + // return dbResult; + //} + /// /// roles list /// @@ -963,6 +1048,7 @@ namespace WebDoorCreator.UI.Data protected const string rKeyDoorOpType = $"{redisBaseAddr}:Cache:DoorOpType"; protected const string rKeyGraphicParameters = $"{redisBaseAddr}:Cache:GraphicParameters"; + protected const string rKeyListValues = $"{redisBaseAddr}:Cache:ListValues"; protected const string rKeyOrderDetail = $"{redisBaseAddr}:Cache:OrderDetail"; diff --git a/WebDoorCreator.UI/Pages/DoorDefinition.razor b/WebDoorCreator.UI/Pages/DoorDefinition.razor index 41d514d..b4b7328 100644 --- a/WebDoorCreator.UI/Pages/DoorDefinition.razor +++ b/WebDoorCreator.UI/Pages/DoorDefinition.razor @@ -14,8 +14,9 @@
- + @**@ @**@ +
diff --git a/WebDoorCreator.UI/_Imports.razor b/WebDoorCreator.UI/_Imports.razor index d72ff7c..8faa1ad 100644 --- a/WebDoorCreator.UI/_Imports.razor +++ b/WebDoorCreator.UI/_Imports.razor @@ -15,6 +15,7 @@ @using WebDoorCreator.UI.Components.Gen @using WebDoorCreator.UI.Components.Order @using WebDoorCreator.UI.Components.Users +@using WebDoorCreator.UI.Components.Hardware @using WebDoorCreator.UI.Shared @using WebDoorCreator.Data.DbModels diff --git a/WebDoorCreator.UI/compilerconfig.json b/WebDoorCreator.UI/compilerconfig.json index f41598d..5ac6e93 100644 --- a/WebDoorCreator.UI/compilerconfig.json +++ b/WebDoorCreator.UI/compilerconfig.json @@ -22,5 +22,9 @@ { "outputFile": "Pages/Index.razor.css", "inputFile": "Pages/Index.razor.less" + }, + { + "outputFile": "Components/Hardware/HardwareList.razor.css", + "inputFile": "Components/Hardware/HardwareList.razor.less" } ] \ No newline at end of file From a59d43b7643580551b805f1ce1ce1936c2b42cd1 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Mon, 3 Apr 2023 16:02:36 +0200 Subject: [PATCH 32/43] gestoione vocabolario --- .../Controllers/WebDoorCreatorController.cs | 151 +++- .../DbModels/VocabularyModel.cs | 39 + .../DbModels/VocabularyTempModel.cs | 39 + ...403140002_VocabularyAndTempAdd.Designer.cs | 763 ++++++++++++++++++ .../20230403140002_VocabularyAndTempAdd.cs | 47 ++ .../WDCData/WDCDataContextModelSnapshot.cs | 40 + WebDoorCreator.Data/WDCDataContext.cs | 4 + .../Components/Gen/NavMenuHorizontal.razor.cs | 41 +- .../Components/Hardware/HardwareList.razor | 10 +- .../Hardware/HardwareList.razor.css | 35 +- .../Hardware/HardwareList.razor.less | 40 +- .../Hardware/HardwareList.razor.min.css | 2 +- .../Data/WDCVocabularyService.cs | 30 + .../Data/WebDoorCreatorService.cs | 90 +++ WebDoorCreator.UI/Pages/SuperAdmin.razor | 3 +- WebDoorCreator.UI/Pages/SuperAdmin.razor.cs | 5 + WebDoorCreator.UI/Program.cs | 1 + 17 files changed, 1276 insertions(+), 64 deletions(-) create mode 100644 WebDoorCreator.Data/DbModels/VocabularyModel.cs create mode 100644 WebDoorCreator.Data/DbModels/VocabularyTempModel.cs create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230403140002_VocabularyAndTempAdd.Designer.cs create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230403140002_VocabularyAndTempAdd.cs create mode 100644 WebDoorCreator.UI/Data/WDCVocabularyService.cs diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index c7074d8..673efe9 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using NLog; +using System.Collections.Generic; using WebDoorCreator.Data.DbModels; using WebDoorCreator.Data.DTO; @@ -251,24 +252,28 @@ namespace WebDoorCreator.Data.Controllers return fatto; } - public async Task> DoorOpTypeGetDefault() + /// + /// Retrieving current data from door + /// + /// + public List DoorOpGetByDoorId(int doorId) { - List dbResult = new List(); + List dbResult = new List(); using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) { try { + // extracting entire set dbResult = localDbCtx - .DbSetDoorOpType - .Where(x => x.IsDefault) - .ToList(); + .DbSetDoorOp + .Where(x => x.DoorId == doorId) + .ToList(); } catch (Exception exc) { - Log.Error($"Eccezione durante DoorOpTypeGetDefault: {Environment.NewLine}{exc}"); + Log.Error($"Error in DoorOpGetByDoorId:{Environment.NewLine}{exc}"); } } - await Task.Delay(1); return dbResult; } @@ -351,6 +356,51 @@ namespace WebDoorCreator.Data.Controllers return fatto; } + /// + /// Retrieving data from door operation type table + /// + /// + public List DoorOpTypeGetAll() + { + List dbResult = new List(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + // extracting entire set + dbResult = localDbCtx + .DbSetDoorOpType + .OrderBy(x => x.DoorOpTypId) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Error in DoorOpTypeGetAll:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + + public async Task> DoorOpTypeGetDefault() + { + List dbResult = new List(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + dbResult = localDbCtx + .DbSetDoorOpType + .Where(x => x.IsDefault) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Eccezione durante DoorOpTypeGetDefault: {Environment.NewLine}{exc}"); + } + } + await Task.Delay(1); + return dbResult; + } /// /// Getting door data by orderId /// @@ -749,56 +799,101 @@ namespace WebDoorCreator.Data.Controllers return dbResult; } - /// - /// Retrieving data from door operation type table - /// - /// - public List DoorOpTypeGetAll() + public List>> VocLemmaGetAll() { - List dbResult = new List(); + List>> dbResult = new List>>(); using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) { try { // extracting entire set - dbResult = localDbCtx - .DbSetDoorOpType - .OrderBy(x => x.DoorOpTypId) + var allVoc = localDbCtx + .DbSetVocabulary .ToList(); + + foreach (var lemma in allVoc) + { + Dictionary dict = new Dictionary + { + { lemma.Lemma, lemma.Traduzione } + }; + + Dictionary> dicts = new Dictionary> { + {lemma.Lingua, dict} + }; + + dbResult.Add(dicts); + } } catch (Exception exc) { - Log.Error($"Error in DoorOpTypeGetAll:{Environment.NewLine}{exc}"); + Log.Error($"Error in VocLemmaGetAll:{Environment.NewLine}{exc}"); } } return dbResult; } /// - /// Retrieving current data from door + /// Aggiunta di un nuovo set di lemmi /// + /// /// - public List DoorOpGetByDoorId(int doorId) + public async Task VocLemmaInsert(List newVocLemma) { - List dbResult = new List(); + bool fatto = false; + List list2Ins = new List(); + List list2Upd = new List(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) { try { - // extracting entire set - dbResult = localDbCtx - .DbSetDoorOp - .Where(x => x.DoorId == doorId) - .ToList(); + var lisKey = localDbCtx + .DbSetVocabulary + .ToList(); + + foreach (var item in newVocLemma) + { + var trovato = lisKey.Where(x => x.Lingua == item.Lingua && x.Lemma == item.Lemma).FirstOrDefault(); + + if (trovato == null) + { + list2Ins.Add(item); + } + else + { + if (trovato.Traduzione != item.Traduzione) + { + list2Upd.Add(item); + } + } + } + + //aggiungo i mancanti + + localDbCtx + .DbSetVocabulary + .AddRange(list2Ins); + + foreach (var item in list2Upd) + { + var trovato = newVocLemma.Where(x => x.Lingua == item.Lingua && x.Lemma == item.Lemma).FirstOrDefault(); + if (trovato != null) + { + trovato.Traduzione = item.Traduzione; + localDbCtx.Entry(trovato).State = EntityState.Modified; + } + } + await localDbCtx.SaveChangesAsync(); + fatto = true; } catch (Exception exc) { - Log.Error($"Error in DoorOpGetByDoorId:{Environment.NewLine}{exc}"); + Log.Error($"Eccezione durante VocLemmaInsert: {Environment.NewLine}{exc}"); } } - return dbResult; + return fatto; } - #endregion Public Methods #region Private Fields diff --git a/WebDoorCreator.Data/DbModels/VocabularyModel.cs b/WebDoorCreator.Data/DbModels/VocabularyModel.cs new file mode 100644 index 0000000..5af563c --- /dev/null +++ b/WebDoorCreator.Data/DbModels/VocabularyModel.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static WebDoorCreator.Core.Enum; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace WebDoorCreator.Data.DbModels +{ + /// + /// Vocabolario termini + /// + [Table("Vocabulary")] + public class VocabularyModel + { + /// + /// Lingua del lemma + /// + [MaxLength(5)] + public string Lingua { get; set; } = ""; + + /// + /// Lemma del termine + /// + [MaxLength(50)] + public string Lemma { get; set; } = ""; + + /// + /// Traduzione del lemma + /// + [MaxLength(250)] + public string Traduzione { get; set; } = ""; + } +} diff --git a/WebDoorCreator.Data/DbModels/VocabularyTempModel.cs b/WebDoorCreator.Data/DbModels/VocabularyTempModel.cs new file mode 100644 index 0000000..ac2b8f2 --- /dev/null +++ b/WebDoorCreator.Data/DbModels/VocabularyTempModel.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static WebDoorCreator.Core.Enum; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace WebDoorCreator.Data.DbModels +{ + /// + /// Vocabolario termini + /// + [Table("VocabularyTemp")] + public class VocabularyTempModel + { + /// + /// Lingua del lemma + /// + [MaxLength(5)] + public string Lingua { get; set; } = ""; + + /// + /// Lemma del termine + /// + [MaxLength(50)] + public string Lemma { get; set; } = ""; + + /// + /// Traduzione del lemma + /// + [MaxLength(250)] + public string Traduzione { get; set; } = ""; + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230403140002_VocabularyAndTempAdd.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230403140002_VocabularyAndTempAdd.Designer.cs new file mode 100644 index 0000000..7376d7b --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230403140002_VocabularyAndTempAdd.Designer.cs @@ -0,0 +1,763 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230403140002_VocabularyAndTempAdd")] + partial class VocabularyAndTempAdd + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateLockExpiry") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MeasureUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdLock") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorOpIdPathFromPatriarch") + .HasColumnType("hierarchyid"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MaxAllowed") + .HasColumnType("int"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentDoorOpId") + .HasColumnType("int"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => + { + b.Property("GraphicParamId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GraphicParamId"), 1L, 1); + + b.Property("compoId") + .HasColumnType("int"); + + b.Property("graphicParamAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamDefaultVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamsN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("GraphicParamId"); + + b.ToTable("GraphicParams"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => + { + b.Property("HardwareId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("HardwareId"), 1L, 1); + + b.Property("compoAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoLayerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoTemplateIsActive") + .HasColumnType("bit"); + + b.HasKey("HardwareId"); + + b.ToTable("Hardware"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("Vocabulary"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyTempModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("VocabularyTemp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230403140002_VocabularyAndTempAdd.cs b/WebDoorCreator.Data/Migrations/WDCData/20230403140002_VocabularyAndTempAdd.cs new file mode 100644 index 0000000..b57c2aa --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230403140002_VocabularyAndTempAdd.cs @@ -0,0 +1,47 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class VocabularyAndTempAdd : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Vocabulary", + columns: table => new + { + Lingua = table.Column(type: "nvarchar(5)", maxLength: 5, nullable: false), + Lemma = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Traduzione = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Vocabulary", x => new { x.Lingua, x.Lemma }); + }); + + migrationBuilder.CreateTable( + name: "VocabularyTemp", + columns: table => new + { + Lingua = table.Column(type: "nvarchar(5)", maxLength: 5, nullable: false), + Lemma = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Traduzione = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_VocabularyTemp", x => new { x.Lingua, x.Lemma }); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Vocabulary"); + + migrationBuilder.DropTable( + name: "VocabularyTemp"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs index cc2af84..65a23f8 100644 --- a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs +++ b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs @@ -648,6 +648,46 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.ToView("UsersViewModel"); }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("Vocabulary"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyTempModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("VocabularyTemp"); + }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => { b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") diff --git a/WebDoorCreator.Data/WDCDataContext.cs b/WebDoorCreator.Data/WDCDataContext.cs index 0bfda7c..d28efd3 100644 --- a/WebDoorCreator.Data/WDCDataContext.cs +++ b/WebDoorCreator.Data/WDCDataContext.cs @@ -71,6 +71,8 @@ namespace WebDoorCreator.Data public virtual DbSet DbSetDoorOp { get; set; } = null!; public virtual DbSet DbSetHardware { get; set; } = null!; public virtual DbSet DbSetGraphicParams { get; set; } = null!; + public virtual DbSet DbSetVocabulary { get; set; } = null!; + public virtual DbSet DbSetVocabularyTemp { get; set; } = null!; #endregion Public Properties @@ -133,6 +135,8 @@ namespace WebDoorCreator.Data modelBuilder.Entity().HasKey(c => new { c.UserId, c.RoleId }); modelBuilder.Entity().HasKey(c => new { c.UserId, c.RoleId }); modelBuilder.Entity().HasKey(c => new { c.TableName, c.FieldName, c.value }); + modelBuilder.Entity().HasKey(c => new { c.Lingua, c.Lemma }); + modelBuilder.Entity().HasKey(c => new { c.Lingua, c.Lemma }); // gestione onCascade DoorOp <--> parent //modelBuilder.Entity().HasOne(e => e.ParentNav).WithOne().OnDelete(DeleteBehavior.NoAction); diff --git a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs index 681ff57..cc6fd54 100644 --- a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs +++ b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs @@ -19,6 +19,8 @@ namespace WebDoorCreator.UI.Components.Gen public EventCallback E_UserRole { get; set; } public EventCallback E_UserId { get; set; } + public EventCallback>>> E_VocLemmas { get; set; } + public List listCompanies { get; set; } = new List(); public List listRecord { get; set; } = new List(); @@ -64,6 +66,7 @@ namespace WebDoorCreator.UI.Components.Gen reportChangeRole(); } } + public string userId { get @@ -76,6 +79,18 @@ namespace WebDoorCreator.UI.Components.Gen reportUserId(); } } + public List>>? listVocLemmas + { + get + { + return WDCVService.VocabularyLemmas; + } + set + { + WDCVService.VocabularyLemmas = value; + reportVocLemmas(); + } + } #endregion Public Properties @@ -86,6 +101,7 @@ namespace WebDoorCreator.UI.Components.Gen WDCUService.EA_UserClaims -= OnNewUserClaims; WDCUService.EA_UserCurrCompany -= OnNewUserCurrComp; WDCUService.EA_UserId -= OnNewUserId; + WDCVService.EA_VocabularyLemmas -= OnNewVocLemma; } public async void OnNewUserClaims() @@ -119,6 +135,15 @@ namespace WebDoorCreator.UI.Components.Gen StateHasChanged(); }); } + + public async void OnNewVocLemma() + { + await InvokeAsync(() => + { + StateHasChanged(); + }); + } + #endregion Public Methods #region Protected Properties @@ -136,6 +161,8 @@ namespace WebDoorCreator.UI.Components.Gen [Inject] protected WDCUserService WDCUService { get; set; } = null!; + [Inject] + protected WDCVocabularyService WDCVService { get; set; } = null!; #endregion Protected Properties @@ -163,13 +190,13 @@ namespace WebDoorCreator.UI.Components.Gen userCurrCompany = compToShow.CompanyId; } - protected override async Task OnInitializedAsync() { await Task.Delay(1); WDCUService.EA_UserClaims += OnNewUserClaims; WDCUService.EA_UserCurrCompany += OnNewUserCurrComp; WDCUService.EA_UserId += OnNewUserId; + WDCVService.EA_VocabularyLemmas += OnNewVocLemma; } protected override async Task OnParametersSetAsync() @@ -194,13 +221,17 @@ namespace WebDoorCreator.UI.Components.Gen // reset preliminare listRecord = new List(); listCompanies = new List(); + listVocLemmas = new List>>(); //await WDCService.FlushRedisCache(); + + listVocLemmas = await WDCService.VocLemmaGetAll(); + var user = await _userManager.FindByNameAsync(currUser); if (user != null) { userId = user.Id; } - var roleList = await _userManager.GetRolesAsync(user); + var roleList = await _userManager.GetRolesAsync(user); if (roleList != null) { var role = roleList.FirstOrDefault(); @@ -263,11 +294,17 @@ namespace WebDoorCreator.UI.Components.Gen { E_UserRole.InvokeAsync(userRole); } + private void reportUserId() { E_UserId.InvokeAsync(userId); } + private void reportVocLemmas() + { + E_VocLemmas.InvokeAsync(); + } + #endregion Private Methods } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor index bca10d7..550b280 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor @@ -1,15 +1,13 @@ @if (doorOp != null) { -
+
@foreach (var item in doorOp) { -
-
+
+
@item.HwCode -
-
- Immagine +
} diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.css b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.css index 826eb86..a856fe0 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.css +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.css @@ -1,15 +1,28 @@ -.hwName { - background-color: #455A64; - margin: 1rem; - padding: 0.5rem; - border-radius: 0.6rem; - text-align: center; - color: #fff; +.rectangle { + height: 2.75rem; + width: 75%; + background: #CFD8DC; + position: relative; + margin-bottom: 4rem; + margin-top: 1.25rem; + border-radius: 0.8rem; + display: flex; + flex-wrap: wrap; + align-items: center; + color: #000; font-weight: bold; } -.hwCircle { - background-color: yellow; +.circle { + position: absolute; + height: 6.25rem; + width: 6.25rem; border-radius: 50%; - height: 60px; - width: 60px; + border: 4px solid #CFD8DC; + left: 100%; + margin-left: -1.563rem; + top: -1.5rem; + background: black; +} +.all { + width: 72rem; } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.less b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.less index 114ed16..9afc56e 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.less +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.less @@ -1,20 +1,30 @@ -body { - -} - -.hwName { - background-color: #455A64; - margin: 1rem; - padding: 0.5rem; - border-radius: 0.6rem; - text-align: center; - color: #fff; +.rectangle { + height: 2.75rem; + width: 75%; + background: #CFD8DC; + position: relative; + margin-bottom: 4rem; + margin-top: 1.25rem; + border-radius: 0.8rem; + display: flex; + flex-wrap: wrap; + align-items: center; + color: #000; font-weight: bold; } -.hwCircle{ - background-color: yellow; +.circle { + position: absolute; + height: 6.25rem; + width: 6.25rem; border-radius: 50%; - height: 60px; - width: 60px; + border: 4px solid #CFD8DC; + left: 100%; + margin-left: -1.563rem; + top: -1.5rem; + background: black; +} + +.all { + width: 72rem; } diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.min.css b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.min.css index 291ec5e..c6e65f8 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.min.css +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.min.css @@ -1 +1 @@ -.hwName{background-color:#455a64;margin:1rem;padding:.5rem;border-radius:.6rem;text-align:center;color:#fff;font-weight:bold;}.hwCircle{background-color:#ff0;border-radius:50%;height:60px;width:60px;} \ No newline at end of file +.rectangle{height:2.75rem;width:75%;background:#cfd8dc;position:relative;margin-bottom:4rem;margin-top:1.25rem;border-radius:.8rem;display:flex;flex-wrap:wrap;align-items:center;color:#000;font-weight:bold;}.circle{position:absolute;height:6.25rem;width:6.25rem;border-radius:50%;border:4px solid #cfd8dc;left:100%;margin-left:-1.563rem;top:-1.5rem;background:#000;}.all{width:72rem;} \ No newline at end of file diff --git a/WebDoorCreator.UI/Data/WDCVocabularyService.cs b/WebDoorCreator.UI/Data/WDCVocabularyService.cs new file mode 100644 index 0000000..388e6eb --- /dev/null +++ b/WebDoorCreator.UI/Data/WDCVocabularyService.cs @@ -0,0 +1,30 @@ +namespace WebDoorCreator.UI.Data +{ + public class WDCVocabularyService + { + public event Action EA_VocabularyLemmas = null!; + + public List>>? VocabularyLemmas + { + get => _vocabularyLemmas; + set + { + if (_vocabularyLemmas != value) + { + _vocabularyLemmas = value; + reportVocabularyLemmas(); + } + } + } + + protected void reportVocabularyLemmas() + { + if (EA_VocabularyLemmas != null) + { + EA_VocabularyLemmas?.Invoke(); + } + } + + private List>>? _vocabularyLemmas { get; set; } = null; + } +} diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index 4717db1..535380d 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -290,6 +290,57 @@ namespace WebDoorCreator.UI.Data return fatto; } + public async Task VocLemmaInsert(string rootPath) + { + + bool fatto = false; + + List VocLemmas = new List(); + + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + + string[] files = Directory.GetFiles(rootPath, "*"); + foreach (string file in files) + { + + //leggo tutte le linee del file + List lines = File.ReadAllLines(file).ToList(); + string lang = ""; + + foreach (var line in lines) + { + if (!line.StartsWith("//") && line != "") + { + string[] lineSplit = line.Split("="); + if (lineSplit[0] == "0") + { + lang = lineSplit[1]; + } + else + { + //string trad = ""; + if (lineSplit.Length != 1) + { + VocabularyModel newVocLemma = new VocabularyModel() + { + Lingua = lang, + Lemma = lineSplit[0], + Traduzione = lineSplit[1] + }; + VocLemmas.Add(newVocLemma); + } + } + } + } + } + fatto = await dbController.VocLemmaInsert(VocLemmas); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"VocLemmaInsert in: {ts.TotalMilliseconds} ms"); + return fatto; + } + public string DecriptData(string encData) { return SteamCrypto.DecryptString(encData, passPhrase); @@ -458,6 +509,43 @@ namespace WebDoorCreator.UI.Data Log.Debug($"DoorOpGetByDoorId | {source} in: {ts.TotalMilliseconds} ms"); return dbResult; } + public async Task>>?> VocLemmaGetAll() + { + string source = "DB"; + List>>? dbResult = new List>>(); + // cerco da cache + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string currKey = $"{rKeyVocLemma}"; + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>>>(rawData); + if (tempResult == null) + { + dbResult = new List>>(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.VocLemmaGetAll(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List>>(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"VocLemmaGetAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } /// /// Doors list by orderId @@ -565,6 +653,7 @@ namespace WebDoorCreator.UI.Data return dbResult; } + /// /// Update or add door /// @@ -1060,6 +1149,7 @@ namespace WebDoorCreator.UI.Data protected const string rKeyUsers = $"{redisBaseAddr}:Cache:Users"; protected const string rKeyUsersView = $"{redisBaseAddr}:Cache:UsersView"; + protected const string rKeyVocLemma = $"{redisBaseAddr}:Cache:VocLemma"; protected Random rnd = new Random(); #endregion Protected Fields diff --git a/WebDoorCreator.UI/Pages/SuperAdmin.razor b/WebDoorCreator.UI/Pages/SuperAdmin.razor index 29dd330..430fa34 100644 --- a/WebDoorCreator.UI/Pages/SuperAdmin.razor +++ b/WebDoorCreator.UI/Pages/SuperAdmin.razor @@ -15,9 +15,10 @@
+
- +
diff --git a/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs b/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs index 6993313..1c2aad3 100644 --- a/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs +++ b/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs @@ -294,5 +294,10 @@ namespace WebDoorCreator.UI.Pages await Task.Delay(1); await WDService.CompoListSetAll(@$"{defaultPath}"); } + protected async Task refreshVoc() + { + await Task.Delay(1); + await WDService.VocLemmaInsert(@$"{defaultPath}"); + } } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Program.cs b/WebDoorCreator.UI/Program.cs index 395ead3..dbe1c77 100644 --- a/WebDoorCreator.UI/Program.cs +++ b/WebDoorCreator.UI/Program.cs @@ -51,6 +51,7 @@ builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped>(); builder.Services.AddHttpContextAccessor(); builder.Services.AddSingleton(redisMultiplexer); From 0dfc561125a29a1d4a89146360fcda54a88836d9 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Mon, 3 Apr 2023 16:07:57 +0200 Subject: [PATCH 33/43] cancellata migrazione --- ...403140002_VocabularyAndTempAdd.Designer.cs | 763 ------------------ .../20230403140002_VocabularyAndTempAdd.cs | 47 -- .../WDCData/WDCDataContextModelSnapshot.cs | 58 +- 3 files changed, 9 insertions(+), 859 deletions(-) delete mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230403140002_VocabularyAndTempAdd.Designer.cs delete mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230403140002_VocabularyAndTempAdd.cs diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230403140002_VocabularyAndTempAdd.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230403140002_VocabularyAndTempAdd.Designer.cs deleted file mode 100644 index 7376d7b..0000000 --- a/WebDoorCreator.Data/Migrations/WDCData/20230403140002_VocabularyAndTempAdd.Designer.cs +++ /dev/null @@ -1,763 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using WebDoorCreator.Data; - -#nullable disable - -namespace WebDoorCreator.Data.Migrations.WDCData -{ - [DbContext(typeof(WDCDataContext))] - [Migration("20230403140002_VocabularyAndTempAdd")] - partial class VocabularyAndTempAdd - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .UseCollation("Latin1_General_CI_AS") - .HasAnnotation("ProductVersion", "6.0.14") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("nvarchar(450)"); - - b.Property("ConcurrencyStamp") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("NormalizedName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("RoleId") - .HasColumnType("nvarchar(450)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("nvarchar(450)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("NormalizedEmail") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("NormalizedUserName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PasswordHash") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("SecurityStamp") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => - { - b.Property("CompanyId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); - - b.Property("Address") - .IsRequired() - .HasMaxLength(250) - .HasColumnType("nvarchar(250)"); - - b.Property("City") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CompanyExtCode") - .IsRequired() - .HasMaxLength(250) - .HasColumnType("nvarchar(250)"); - - b.Property("CompanyName") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("CompanyToken") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.Property("PrivateNote") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("State") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("VAT") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ZipCode") - .HasColumnType("int"); - - b.HasKey("CompanyId"); - - b.ToTable("Company"); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => - { - b.Property("DoorId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); - - b.Property("DateIns") - .HasColumnType("datetime2"); - - b.Property("DateLockExpiry") - .HasColumnType("datetime2"); - - b.Property("DateMod") - .HasColumnType("datetime2"); - - b.Property("DoorDescript") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("DoorExtCode") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("MeasureUnit") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.Property("TypeId") - .HasColumnType("int"); - - b.Property("UnitCost") - .HasColumnType("decimal(18,2)"); - - b.Property("UserIdIns") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserIdLock") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserIdMod") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("DoorId"); - - b.HasIndex("OrderId"); - - b.HasIndex("TypeId"); - - b.ToTable("Door"); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => - { - b.Property("DoorOpId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); - - b.Property("DateIns") - .HasColumnType("datetime2"); - - b.Property("DateMod") - .HasColumnType("datetime2"); - - b.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("DoorId") - .HasColumnType("int"); - - b.Property("DoorOpTypId") - .HasColumnType("int"); - - b.Property("JsoncConfigVal") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserIdIns") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserIdMod") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("DoorOpId"); - - b.HasIndex("DoorId"); - - b.HasIndex("DoorOpTypId"); - - b.ToTable("DoorOp"); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => - { - b.Property("DoorOpTypId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); - - b.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("DisplayUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("DoorOpIdPathFromPatriarch") - .HasColumnType("hierarchyid"); - - b.Property("ExtDescript") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ExtOpCode") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FPath") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("HasHw") - .HasColumnType("bit"); - - b.Property("HwCode") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("HwDescription") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IsConcrete") - .HasColumnType("bit"); - - b.Property("IsDefault") - .HasColumnType("bit"); - - b.Property("JsoncConfig") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("MaxAllowed") - .HasColumnType("int"); - - b.Property("OpCode") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ParentDoorOpId") - .HasColumnType("int"); - - b.Property("Rev") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ValidFrom") - .HasColumnType("datetime2"); - - b.Property("ValidUntil") - .HasColumnType("datetime2"); - - b.HasKey("DoorOpTypId"); - - b.ToTable("DoorOpType"); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => - { - b.Property("TypeId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); - - b.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("TypeCode") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("TypeId"); - - b.ToTable("DoorType"); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => - { - b.Property("GraphicParamId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GraphicParamId"), 1L, 1); - - b.Property("compoId") - .HasColumnType("int"); - - b.Property("graphicParamAlias") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("graphicParamDefaultVal") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("graphicParamKey") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("graphicParamName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("graphicParamType") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("graphicParamsN") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("GraphicParamId"); - - b.ToTable("GraphicParams"); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => - { - b.Property("HardwareId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("HardwareId"), 1L, 1); - - b.Property("compoAlias") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("compoLayerName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("compoName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("compoTemplateIsActive") - .HasColumnType("bit"); - - b.HasKey("HardwareId"); - - b.ToTable("Hardware"); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => - { - b.Property("TableName") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("FieldName") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("value") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("label") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ordinal") - .HasColumnType("int"); - - b.HasKey("TableName", "FieldName", "value"); - - b.ToTable("ListValues"); - - b.HasData( - new - { - TableName = "Opening", - FieldName = "Swing", - value = "LH", - label = "Left Handed", - ordinal = 1 - }, - new - { - TableName = "Opening", - FieldName = "Swing", - value = "RH", - label = "Right Handed", - ordinal = 2 - }, - new - { - TableName = "Opening", - FieldName = "Swing", - value = "LHR", - label = "Left Handed Reverse", - ordinal = 3 - }, - new - { - TableName = "Opening", - FieldName = "Swing", - value = "RHR", - label = "Right Handed Reverse", - ordinal = 4 - }, - new - { - TableName = "Edges", - FieldName = "EdgeType", - value = "BV", - label = "Bevel", - ordinal = 1 - }, - new - { - TableName = "Edges", - FieldName = "EdgeType", - value = "SQ", - label = "Squared", - ordinal = 2 - }, - new - { - TableName = "Edges", - FieldName = "EdgeType", - value = "1B", - label = "Bull Nose 1", - ordinal = 3 - }); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => - { - b.Property("OrderId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); - - b.Property("CompanyId") - .HasColumnType("int"); - - b.Property("DateIns") - .HasColumnType("datetime2"); - - b.Property("DateMod") - .HasColumnType("datetime2"); - - b.Property("OrderDescript") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OrderExtCode") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("UserIdIns") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserIdMod") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("OrderId"); - - b.HasIndex("CompanyId"); - - b.ToTable("Order"); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => - { - b.Property("OrderId") - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); - - b.Property("CompanyId") - .HasColumnType("int"); - - b.Property("DateIns") - .HasColumnType("datetime2"); - - b.Property("NumDoors") - .HasColumnType("int"); - - b.Property("NumType") - .HasColumnType("int"); - - b.Property("OrderDescript") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OrderExtCode") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OrderStatus") - .HasColumnType("int"); - - b.Property("TotCost") - .HasColumnType("decimal(18,2)"); - - b.Property("UserIdIns") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserIdMod") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("OrderId"); - - b.ToView("OrderStatusViewModel"); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("RoleId") - .HasColumnType("nvarchar(450)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("RoleName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "RoleId"); - - b.ToView("UsersViewModel"); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyModel", b => - { - b.Property("Lingua") - .HasMaxLength(5) - .HasColumnType("nvarchar(5)"); - - b.Property("Lemma") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Traduzione") - .IsRequired() - .HasMaxLength(250) - .HasColumnType("nvarchar(250)"); - - b.HasKey("Lingua", "Lemma"); - - b.ToTable("Vocabulary"); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyTempModel", b => - { - b.Property("Lingua") - .HasMaxLength(5) - .HasColumnType("nvarchar(5)"); - - b.Property("Lemma") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Traduzione") - .IsRequired() - .HasMaxLength(250) - .HasColumnType("nvarchar(250)"); - - b.HasKey("Lingua", "Lemma"); - - b.ToTable("VocabularyTemp"); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => - { - b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("RolesNav"); - - b.Navigation("UsersNav"); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => - { - b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") - .WithMany() - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") - .WithMany() - .HasForeignKey("TypeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("OrderNav"); - - b.Navigation("TypeNav"); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => - { - b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") - .WithMany() - .HasForeignKey("DoorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") - .WithMany() - .HasForeignKey("DoorOpTypId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("DoorNav"); - - b.Navigation("DoorOpTypeNav"); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => - { - b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") - .WithMany() - .HasForeignKey("CompanyId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CompanyNav"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230403140002_VocabularyAndTempAdd.cs b/WebDoorCreator.Data/Migrations/WDCData/20230403140002_VocabularyAndTempAdd.cs deleted file mode 100644 index b57c2aa..0000000 --- a/WebDoorCreator.Data/Migrations/WDCData/20230403140002_VocabularyAndTempAdd.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace WebDoorCreator.Data.Migrations.WDCData -{ - public partial class VocabularyAndTempAdd : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Vocabulary", - columns: table => new - { - Lingua = table.Column(type: "nvarchar(5)", maxLength: 5, nullable: false), - Lemma = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), - Traduzione = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Vocabulary", x => new { x.Lingua, x.Lemma }); - }); - - migrationBuilder.CreateTable( - name: "VocabularyTemp", - columns: table => new - { - Lingua = table.Column(type: "nvarchar(5)", maxLength: 5, nullable: false), - Lemma = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), - Traduzione = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_VocabularyTemp", x => new { x.Lingua, x.Lemma }); - }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Vocabulary"); - - migrationBuilder.DropTable( - name: "VocabularyTemp"); - } - } -} diff --git a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs index 65a23f8..432fc82 100644 --- a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs +++ b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs @@ -174,7 +174,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasKey("CompanyId"); - b.ToTable("Company"); + b.ToTable("Company", (string)null); }); modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => @@ -236,7 +236,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasIndex("TypeId"); - b.ToTable("Door"); + b.ToTable("Door", (string)null); }); modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => @@ -281,7 +281,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasIndex("DoorOpTypId"); - b.ToTable("DoorOp"); + b.ToTable("DoorOp", (string)null); }); modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => @@ -358,7 +358,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasKey("DoorOpTypId"); - b.ToTable("DoorOpType"); + b.ToTable("DoorOpType", (string)null); }); modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => @@ -379,7 +379,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasKey("TypeId"); - b.ToTable("DoorType"); + b.ToTable("DoorType", (string)null); }); modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => @@ -419,7 +419,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasKey("GraphicParamId"); - b.ToTable("GraphicParams"); + b.ToTable("GraphicParams", (string)null); }); modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => @@ -447,7 +447,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasKey("HardwareId"); - b.ToTable("Hardware"); + b.ToTable("Hardware", (string)null); }); modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => @@ -473,7 +473,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasKey("TableName", "FieldName", "value"); - b.ToTable("ListValues"); + b.ToTable("ListValues", (string)null); b.HasData( new @@ -574,7 +574,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasIndex("CompanyId"); - b.ToTable("Order"); + b.ToTable("Order", (string)null); }); modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => @@ -648,46 +648,6 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.ToView("UsersViewModel"); }); - modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyModel", b => - { - b.Property("Lingua") - .HasMaxLength(5) - .HasColumnType("nvarchar(5)"); - - b.Property("Lemma") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Traduzione") - .IsRequired() - .HasMaxLength(250) - .HasColumnType("nvarchar(250)"); - - b.HasKey("Lingua", "Lemma"); - - b.ToTable("Vocabulary"); - }); - - modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyTempModel", b => - { - b.Property("Lingua") - .HasMaxLength(5) - .HasColumnType("nvarchar(5)"); - - b.Property("Lemma") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Traduzione") - .IsRequired() - .HasMaxLength(250) - .HasColumnType("nvarchar(250)"); - - b.HasKey("Lingua", "Lemma"); - - b.ToTable("VocabularyTemp"); - }); - modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => { b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") From f31b3187e8fc6deb73dcaa07960c2a0e5ee86bb6 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 3 Apr 2023 16:20:03 +0200 Subject: [PATCH 34/43] Vocabolario: - Fix creazione tab + stored - modifica metodo upsert --- .../Controllers/WebDoorCreatorController.cs | 62 +- ...20230403140917_VocabularySetup.Designer.cs | 763 ++++++++++++++++++ .../WDCData/20230403140917_VocabularySetup.cs | 66 ++ .../WDCData/WDCDataContextModelSnapshot.cs | 58 +- .../SqlScripts/Stored/stp_Voc_Import.sql | 22 + .../SqlScripts/Stored/stp_Voc_Prepare.sql | 29 + 6 files changed, 951 insertions(+), 49 deletions(-) create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230403140917_VocabularySetup.Designer.cs create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230403140917_VocabularySetup.cs create mode 100644 WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Import.sql create mode 100644 WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Prepare.sql diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index 673efe9..5172253 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -3,8 +3,11 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using NLog; using System.Collections.Generic; +using System.ComponentModel.Design; +using System.Data; using WebDoorCreator.Data.DbModels; using WebDoorCreator.Data.DTO; +using static WebDoorCreator.Core.Enum; namespace WebDoorCreator.Data.Controllers { @@ -676,8 +679,8 @@ namespace WebDoorCreator.Data.Controllers try { dbCtx - .Database - .ExecuteSqlRaw("EXEC man.[stp_TruncTables]"); + .Database + .ExecuteSqlRaw("EXEC man.[stp_TruncTables]"); dbResult = true; } @@ -836,55 +839,34 @@ namespace WebDoorCreator.Data.Controllers /// /// Aggiunta di un nuovo set di lemmi /// - /// + /// /// - public async Task VocLemmaInsert(List newVocLemma) + public async Task VocLemmaInsert(List listNewTerms) { bool fatto = false; - List list2Ins = new List(); - List list2Upd = new List(); using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) { try { - var lisKey = localDbCtx - .DbSetVocabulary - .ToList(); - - foreach (var item in newVocLemma) - { - var trovato = lisKey.Where(x => x.Lingua == item.Lingua && x.Lemma == item.Lemma).FirstOrDefault(); - - if (trovato == null) - { - list2Ins.Add(item); - } - else - { - if (trovato.Traduzione != item.Traduzione) - { - list2Upd.Add(item); - } - } - } - - //aggiungo i mancanti + // stored di reset vocabolario + var storedRes = localDbCtx + .Database + .ExecuteSqlRaw("exec dbo.stp_Voc_Prepare"); + // import massivo dati in tab temp localDbCtx - .DbSetVocabulary - .AddRange(list2Ins); + .DbSetVocabularyTemp + .AddRange(listNewTerms); + + localDbCtx.SaveChanges(); + + + // stored di merge dati in vocabolario + storedRes = localDbCtx + .Database + .ExecuteSqlRaw("exec dbo.stp_Voc_Import"); - foreach (var item in list2Upd) - { - var trovato = newVocLemma.Where(x => x.Lingua == item.Lingua && x.Lemma == item.Lemma).FirstOrDefault(); - if (trovato != null) - { - trovato.Traduzione = item.Traduzione; - localDbCtx.Entry(trovato).State = EntityState.Modified; - } - } - await localDbCtx.SaveChangesAsync(); fatto = true; } catch (Exception exc) diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230403140917_VocabularySetup.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230403140917_VocabularySetup.Designer.cs new file mode 100644 index 0000000..b430324 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230403140917_VocabularySetup.Designer.cs @@ -0,0 +1,763 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230403140917_VocabularySetup")] + partial class VocabularySetup + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateLockExpiry") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MeasureUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdLock") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorOpIdPathFromPatriarch") + .HasColumnType("hierarchyid"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MaxAllowed") + .HasColumnType("int"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentDoorOpId") + .HasColumnType("int"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => + { + b.Property("GraphicParamId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GraphicParamId"), 1L, 1); + + b.Property("compoId") + .HasColumnType("int"); + + b.Property("graphicParamAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamDefaultVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamsN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("GraphicParamId"); + + b.ToTable("GraphicParams"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => + { + b.Property("HardwareId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("HardwareId"), 1L, 1); + + b.Property("compoAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoLayerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoTemplateIsActive") + .HasColumnType("bit"); + + b.HasKey("HardwareId"); + + b.ToTable("Hardware"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("Vocabulary"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyTempModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("VocabularyTemp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230403140917_VocabularySetup.cs b/WebDoorCreator.Data/Migrations/WDCData/20230403140917_VocabularySetup.cs new file mode 100644 index 0000000..763bafa --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230403140917_VocabularySetup.cs @@ -0,0 +1,66 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class VocabularySetup : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Vocabulary", + columns: table => new + { + Lingua = table.Column(type: "nvarchar(5)", maxLength: 5, nullable: false), + Lemma = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Traduzione = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Vocabulary", x => new { x.Lingua, x.Lemma }); + }); + + migrationBuilder.CreateTable( + name: "VocabularyTemp", + columns: table => new + { + Lingua = table.Column(type: "nvarchar(5)", maxLength: 5, nullable: false), + Lemma = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Traduzione = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_VocabularyTemp", x => new { x.Lingua, x.Lemma }); + }); + + + addStored(migrationBuilder, "stp_Voc_Prepare"); + addStored(migrationBuilder, "stp_Voc_Import"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Vocabulary"); + + migrationBuilder.DropTable( + name: "VocabularyTemp"); + + remStored(migrationBuilder, "stp_Voc_Prepare"); + remStored(migrationBuilder, "stp_Voc_Import"); + } + + private void addStored(MigrationBuilder migrationBuilder, string viewName) + { + string path = Path.Combine("SqlScripts", "Stored", $"{viewName}.sql"); + string viewBody = File.ReadAllText(path); + migrationBuilder.Sql(viewBody); + } + + private void remStored(MigrationBuilder migrationBuilder, string viewName) + { + migrationBuilder.Sql($"exec('DROP PROCEDURE dbo.{viewName}');"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs index 432fc82..65a23f8 100644 --- a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs +++ b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs @@ -174,7 +174,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasKey("CompanyId"); - b.ToTable("Company", (string)null); + b.ToTable("Company"); }); modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => @@ -236,7 +236,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasIndex("TypeId"); - b.ToTable("Door", (string)null); + b.ToTable("Door"); }); modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => @@ -281,7 +281,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasIndex("DoorOpTypId"); - b.ToTable("DoorOp", (string)null); + b.ToTable("DoorOp"); }); modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => @@ -358,7 +358,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasKey("DoorOpTypId"); - b.ToTable("DoorOpType", (string)null); + b.ToTable("DoorOpType"); }); modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => @@ -379,7 +379,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasKey("TypeId"); - b.ToTable("DoorType", (string)null); + b.ToTable("DoorType"); }); modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => @@ -419,7 +419,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasKey("GraphicParamId"); - b.ToTable("GraphicParams", (string)null); + b.ToTable("GraphicParams"); }); modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => @@ -447,7 +447,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasKey("HardwareId"); - b.ToTable("Hardware", (string)null); + b.ToTable("Hardware"); }); modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => @@ -473,7 +473,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasKey("TableName", "FieldName", "value"); - b.ToTable("ListValues", (string)null); + b.ToTable("ListValues"); b.HasData( new @@ -574,7 +574,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.HasIndex("CompanyId"); - b.ToTable("Order", (string)null); + b.ToTable("Order"); }); modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => @@ -648,6 +648,46 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.ToView("UsersViewModel"); }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("Vocabulary"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyTempModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("VocabularyTemp"); + }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => { b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") diff --git a/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Import.sql b/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Import.sql new file mode 100644 index 0000000..4dce251 --- /dev/null +++ b/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Import.sql @@ -0,0 +1,22 @@ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +-- ============================================= +-- Author: S.E.L. +-- Create date: 2023.04.03 +-- Description: Esecuzione preparazione tab temp x import vocabolario +-- ============================================= +ALTER PROCEDURE [dbo].[stp_Voc_Prepare] +AS +BEGIN + SET NOCOUNT ON; + + BEGIN tran + + -- effettua preparazione tab appoggio + TRUNCATE TABLE VocabularyTemp + + COMMIT tran + +END \ No newline at end of file diff --git a/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Prepare.sql b/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Prepare.sql new file mode 100644 index 0000000..af69d73 --- /dev/null +++ b/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Prepare.sql @@ -0,0 +1,29 @@ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +-- ============================================= +-- Author: S.E.L. +-- Create date: 2023.04.03 +-- Description: Esecuzione upsert vocabolario +-- ============================================= +ALTER PROCEDURE [dbo].[stp_Voc_Import] +AS +BEGIN + SET NOCOUNT ON; + + BEGIN tran + + -- effettua merge dati vocabolario + MERGE Vocabulary as tgt + USING (SELECT Lingua, Lemma, Traduzione FROM VocabularyTemp) as src + ON tgt.Lemma = src.Lemma AND tgt.Lingua = src.Lingua + WHEN MATCHED THEN + UPDATE SET Traduzione = Traduzione + WHEN NOT MATCHED THEN + INSERT (Lingua, Lemma, Traduzione) + VALUES (Lingua, Lemma, Traduzione); + + COMMIT tran + +END \ No newline at end of file From 8ef3a6978c30f9bc137d3f3065e1820888cbeee5 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Mon, 3 Apr 2023 18:13:20 +0200 Subject: [PATCH 35/43] fix vocabolario + inizializzazione oggetto traduzione --- .../Controllers/WebDoorCreatorController.cs | 36 ++++++++-------- .../DbModels/VocabularyModel.cs | 2 +- .../DbModels/VocabularyTempModel.cs | 2 +- ...03143539_VocabularyAndTempAdd.Designer.cs} | 12 +++--- ...=> 20230403143539_VocabularyAndTempAdd.cs} | 25 ++--------- .../WDCData/WDCDataContextModelSnapshot.cs | 8 ++-- .../SqlScripts/Stored/stp_Voc_Import.sql | 15 +++++-- .../SqlScripts/Stored/stp_Voc_Prepare.sql | 15 ++----- .../Components/Gen/NavMenuHorizontal.razor.cs | 4 +- .../Components/Hardware/HardwareList.razor | 2 +- .../Components/Hardware/HardwareList.razor.cs | 12 ++++++ .../Data/WDCVocabularyService.cs | 23 +++++++++-- .../Data/WebDoorCreatorService.cs | 41 +++++++++---------- WebDoorCreator.UI/Program.cs | 2 +- 14 files changed, 105 insertions(+), 94 deletions(-) rename WebDoorCreator.Data/Migrations/WDCData/{20230403140917_VocabularySetup.Designer.cs => 20230403143539_VocabularyAndTempAdd.Designer.cs} (98%) rename WebDoorCreator.Data/Migrations/WDCData/{20230403140917_VocabularySetup.cs => 20230403143539_VocabularyAndTempAdd.cs} (66%) diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index 5172253..7bd00ac 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -802,30 +802,33 @@ namespace WebDoorCreator.Data.Controllers return dbResult; } - public List>> VocLemmaGetAll() + public Dictionary> VocLemmaGetAll() { - List>> dbResult = new List>>(); + Dictionary> DTOResult = new Dictionary>(); using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) { try { + List lingue = new List() + { + "IT", + "EN" + }; + // extracting entire set var allVoc = localDbCtx .DbSetVocabulary + .AsNoTracking() .ToList(); - foreach (var lemma in allVoc) + foreach (var lingua in lingue) { - Dictionary dict = new Dictionary + Dictionary dict = new Dictionary(); + foreach (var lemma in allVoc.Where(x=>x.Lingua == lingua)) { - { lemma.Lemma, lemma.Traduzione } - }; - - Dictionary> dicts = new Dictionary> { - {lemma.Lingua, dict} - }; - - dbResult.Add(dicts); + dict.Add(lemma.Lemma, lemma.Traduzione); + } + DTOResult.Add(lingua, dict); } } catch (Exception exc) @@ -833,7 +836,7 @@ namespace WebDoorCreator.Data.Controllers Log.Error($"Error in VocLemmaGetAll:{Environment.NewLine}{exc}"); } } - return dbResult; + return DTOResult; } /// @@ -845,6 +848,8 @@ namespace WebDoorCreator.Data.Controllers { bool fatto = false; + //var o = listNewTerms.Where(x => x.Traduzione.Length > 200).ToList(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) { try @@ -853,14 +858,13 @@ namespace WebDoorCreator.Data.Controllers var storedRes = localDbCtx .Database .ExecuteSqlRaw("exec dbo.stp_Voc_Prepare"); + await localDbCtx.SaveChangesAsync(); // import massivo dati in tab temp localDbCtx .DbSetVocabularyTemp .AddRange(listNewTerms); - - localDbCtx.SaveChanges(); - + await localDbCtx.SaveChangesAsync(); // stored di merge dati in vocabolario storedRes = localDbCtx diff --git a/WebDoorCreator.Data/DbModels/VocabularyModel.cs b/WebDoorCreator.Data/DbModels/VocabularyModel.cs index 5af563c..140bf92 100644 --- a/WebDoorCreator.Data/DbModels/VocabularyModel.cs +++ b/WebDoorCreator.Data/DbModels/VocabularyModel.cs @@ -33,7 +33,7 @@ namespace WebDoorCreator.Data.DbModels /// /// Traduzione del lemma /// - [MaxLength(250)] + [MaxLength(500)] public string Traduzione { get; set; } = ""; } } diff --git a/WebDoorCreator.Data/DbModels/VocabularyTempModel.cs b/WebDoorCreator.Data/DbModels/VocabularyTempModel.cs index ac2b8f2..1ba7024 100644 --- a/WebDoorCreator.Data/DbModels/VocabularyTempModel.cs +++ b/WebDoorCreator.Data/DbModels/VocabularyTempModel.cs @@ -33,7 +33,7 @@ namespace WebDoorCreator.Data.DbModels /// /// Traduzione del lemma /// - [MaxLength(250)] + [MaxLength(500)] public string Traduzione { get; set; } = ""; } } diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230403140917_VocabularySetup.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230403143539_VocabularyAndTempAdd.Designer.cs similarity index 98% rename from WebDoorCreator.Data/Migrations/WDCData/20230403140917_VocabularySetup.Designer.cs rename to WebDoorCreator.Data/Migrations/WDCData/20230403143539_VocabularyAndTempAdd.Designer.cs index b430324..c998595 100644 --- a/WebDoorCreator.Data/Migrations/WDCData/20230403140917_VocabularySetup.Designer.cs +++ b/WebDoorCreator.Data/Migrations/WDCData/20230403143539_VocabularyAndTempAdd.Designer.cs @@ -12,8 +12,8 @@ using WebDoorCreator.Data; namespace WebDoorCreator.Data.Migrations.WDCData { [DbContext(typeof(WDCDataContext))] - [Migration("20230403140917_VocabularySetup")] - partial class VocabularySetup + [Migration("20230403143539_VocabularyAndTempAdd")] + partial class VocabularyAndTempAdd { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -662,8 +662,8 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.Property("Traduzione") .IsRequired() - .HasMaxLength(250) - .HasColumnType("nvarchar(250)"); + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); b.HasKey("Lingua", "Lemma"); @@ -682,8 +682,8 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.Property("Traduzione") .IsRequired() - .HasMaxLength(250) - .HasColumnType("nvarchar(250)"); + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); b.HasKey("Lingua", "Lemma"); diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230403140917_VocabularySetup.cs b/WebDoorCreator.Data/Migrations/WDCData/20230403143539_VocabularyAndTempAdd.cs similarity index 66% rename from WebDoorCreator.Data/Migrations/WDCData/20230403140917_VocabularySetup.cs rename to WebDoorCreator.Data/Migrations/WDCData/20230403143539_VocabularyAndTempAdd.cs index 763bafa..f0afdc9 100644 --- a/WebDoorCreator.Data/Migrations/WDCData/20230403140917_VocabularySetup.cs +++ b/WebDoorCreator.Data/Migrations/WDCData/20230403143539_VocabularyAndTempAdd.cs @@ -4,7 +4,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData { - public partial class VocabularySetup : Migration + public partial class VocabularyAndTempAdd : Migration { protected override void Up(MigrationBuilder migrationBuilder) { @@ -14,7 +14,7 @@ namespace WebDoorCreator.Data.Migrations.WDCData { Lingua = table.Column(type: "nvarchar(5)", maxLength: 5, nullable: false), Lemma = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), - Traduzione = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) + Traduzione = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false) }, constraints: table => { @@ -27,16 +27,12 @@ namespace WebDoorCreator.Data.Migrations.WDCData { Lingua = table.Column(type: "nvarchar(5)", maxLength: 5, nullable: false), Lemma = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), - Traduzione = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) + Traduzione = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false) }, constraints: table => { table.PrimaryKey("PK_VocabularyTemp", x => new { x.Lingua, x.Lemma }); }); - - - addStored(migrationBuilder, "stp_Voc_Prepare"); - addStored(migrationBuilder, "stp_Voc_Import"); } protected override void Down(MigrationBuilder migrationBuilder) @@ -46,21 +42,6 @@ namespace WebDoorCreator.Data.Migrations.WDCData migrationBuilder.DropTable( name: "VocabularyTemp"); - - remStored(migrationBuilder, "stp_Voc_Prepare"); - remStored(migrationBuilder, "stp_Voc_Import"); - } - - private void addStored(MigrationBuilder migrationBuilder, string viewName) - { - string path = Path.Combine("SqlScripts", "Stored", $"{viewName}.sql"); - string viewBody = File.ReadAllText(path); - migrationBuilder.Sql(viewBody); - } - - private void remStored(MigrationBuilder migrationBuilder, string viewName) - { - migrationBuilder.Sql($"exec('DROP PROCEDURE dbo.{viewName}');"); } } } diff --git a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs index 65a23f8..7ecdb15 100644 --- a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs +++ b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs @@ -660,8 +660,8 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.Property("Traduzione") .IsRequired() - .HasMaxLength(250) - .HasColumnType("nvarchar(250)"); + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); b.HasKey("Lingua", "Lemma"); @@ -680,8 +680,8 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.Property("Traduzione") .IsRequired() - .HasMaxLength(250) - .HasColumnType("nvarchar(250)"); + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); b.HasKey("Lingua", "Lemma"); diff --git a/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Import.sql b/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Import.sql index 4dce251..9cfa50c 100644 --- a/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Import.sql +++ b/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Import.sql @@ -5,17 +5,24 @@ GO -- ============================================= -- Author: S.E.L. -- Create date: 2023.04.03 --- Description: Esecuzione preparazione tab temp x import vocabolario +-- Description: Esecuzione upsert vocabolario -- ============================================= -ALTER PROCEDURE [dbo].[stp_Voc_Prepare] +ALTER PROCEDURE [dbo].[stp_Voc_Import] AS BEGIN SET NOCOUNT ON; BEGIN tran - -- effettua preparazione tab appoggio - TRUNCATE TABLE VocabularyTemp + -- effettua merge dati vocabolario + MERGE Vocabulary as tgt + USING (SELECT Lingua, Lemma, Traduzione FROM VocabularyTemp) as src + ON tgt.Lemma = src.Lemma AND tgt.Lingua = src.Lingua + WHEN MATCHED THEN + UPDATE SET Traduzione = src.Traduzione + WHEN NOT MATCHED THEN + INSERT (Lingua, Lemma, Traduzione) + VALUES (Lingua, Lemma, Traduzione); COMMIT tran diff --git a/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Prepare.sql b/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Prepare.sql index af69d73..4dce251 100644 --- a/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Prepare.sql +++ b/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Prepare.sql @@ -5,24 +5,17 @@ GO -- ============================================= -- Author: S.E.L. -- Create date: 2023.04.03 --- Description: Esecuzione upsert vocabolario +-- Description: Esecuzione preparazione tab temp x import vocabolario -- ============================================= -ALTER PROCEDURE [dbo].[stp_Voc_Import] +ALTER PROCEDURE [dbo].[stp_Voc_Prepare] AS BEGIN SET NOCOUNT ON; BEGIN tran - -- effettua merge dati vocabolario - MERGE Vocabulary as tgt - USING (SELECT Lingua, Lemma, Traduzione FROM VocabularyTemp) as src - ON tgt.Lemma = src.Lemma AND tgt.Lingua = src.Lingua - WHEN MATCHED THEN - UPDATE SET Traduzione = Traduzione - WHEN NOT MATCHED THEN - INSERT (Lingua, Lemma, Traduzione) - VALUES (Lingua, Lemma, Traduzione); + -- effettua preparazione tab appoggio + TRUNCATE TABLE VocabularyTemp COMMIT tran diff --git a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs index cc6fd54..646db5b 100644 --- a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs +++ b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs @@ -79,7 +79,7 @@ namespace WebDoorCreator.UI.Components.Gen reportUserId(); } } - public List>>? listVocLemmas + public Dictionary>? listVocLemmas { get { @@ -221,7 +221,7 @@ namespace WebDoorCreator.UI.Components.Gen // reset preliminare listRecord = new List(); listCompanies = new List(); - listVocLemmas = new List>>(); + listVocLemmas = new Dictionary>(); //await WDCService.FlushRedisCache(); listVocLemmas = await WDCService.VocLemmaGetAll(); diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor index 550b280..b598d4e 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor @@ -6,7 +6,7 @@ {
- @item.HwCode + @(translate(item.HwCode))
diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs index 3c8ec27..f860b7d 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs @@ -9,6 +9,9 @@ namespace WebDoorCreator.UI.Components.Hardware [Inject] protected WebDoorCreatorService WDService { get; set; } = null!; + [Inject] + protected WDCVocabularyService WDVService { get; set; } = null!; + protected List? doorOp { get; set; } = null; protected override async Task OnInitializedAsync() @@ -21,5 +24,14 @@ namespace WebDoorCreator.UI.Components.Hardware } } + protected string translate(string lemma) + { + string answ = ""; + + answ = WDVService.traduci("IT",lemma); + + return answ; + } + } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Data/WDCVocabularyService.cs b/WebDoorCreator.UI/Data/WDCVocabularyService.cs index 388e6eb..88e36e2 100644 --- a/WebDoorCreator.UI/Data/WDCVocabularyService.cs +++ b/WebDoorCreator.UI/Data/WDCVocabularyService.cs @@ -1,10 +1,12 @@ -namespace WebDoorCreator.UI.Data +using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal; + +namespace WebDoorCreator.UI.Data { public class WDCVocabularyService { public event Action EA_VocabularyLemmas = null!; - public List>>? VocabularyLemmas + public Dictionary>? VocabularyLemmas { get => _vocabularyLemmas; set @@ -17,6 +19,21 @@ } } + public string traduci(string lingua, string lemma) + { + string answ = $"[{lemma}]"; + + if (VocabularyLemmas != null && VocabularyLemmas.ContainsKey(lingua)) + { + if (VocabularyLemmas[lingua].ContainsKey(lemma)) + { + answ = VocabularyLemmas[lingua][lemma]; + } + } + + return answ; + } + protected void reportVocabularyLemmas() { if (EA_VocabularyLemmas != null) @@ -25,6 +42,6 @@ } } - private List>>? _vocabularyLemmas { get; set; } = null; + private Dictionary>? _vocabularyLemmas { get; set; } = null; } } diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index 535380d..3dbecf0 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -1,5 +1,6 @@ using EgwCoreLib.Razor.Data; using Microsoft.AspNetCore.Identity.UI.Services; +using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.ValueContentAnalysis; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; using NLog; @@ -295,41 +296,37 @@ namespace WebDoorCreator.UI.Data bool fatto = false; - List VocLemmas = new List(); + List VocLemmas = new List(); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); string[] files = Directory.GetFiles(rootPath, "*"); + string lang = ""; foreach (string file in files) { + var fileName = file.Split("."); + + lang = fileName[0].Substring(fileName[0].Length - 2, 2); //leggo tutte le linee del file List lines = File.ReadAllLines(file).ToList(); - string lang = ""; foreach (var line in lines) { if (!line.StartsWith("//") && line != "") { string[] lineSplit = line.Split("="); - if (lineSplit[0] == "0") + //string trad = ""; + if (lineSplit.Length != 1) { - lang = lineSplit[1]; - } - else - { - //string trad = ""; - if (lineSplit.Length != 1) + VocabularyTempModel newVocLemma = new VocabularyTempModel() { - VocabularyModel newVocLemma = new VocabularyModel() - { - Lingua = lang, - Lemma = lineSplit[0], - Traduzione = lineSplit[1] - }; - VocLemmas.Add(newVocLemma); - } + Lingua = lang, + Lemma = lineSplit[0], + Traduzione = lineSplit[1] + }; + VocLemmas.Add(newVocLemma); } } } @@ -509,10 +506,10 @@ namespace WebDoorCreator.UI.Data Log.Debug($"DoorOpGetByDoorId | {source} in: {ts.TotalMilliseconds} ms"); return dbResult; } - public async Task>>?> VocLemmaGetAll() + public async Task>?> VocLemmaGetAll() { string source = "DB"; - List>>? dbResult = new List>>(); + Dictionary>? dbResult = new Dictionary>(); // cerco da cache Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); @@ -521,10 +518,10 @@ namespace WebDoorCreator.UI.Data if (!string.IsNullOrEmpty(rawData)) { source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject>>>(rawData); + var tempResult = JsonConvert.DeserializeObject>>(rawData); if (tempResult == null) { - dbResult = new List>>(); + dbResult = new Dictionary>(); } else { @@ -539,7 +536,7 @@ namespace WebDoorCreator.UI.Data } if (dbResult == null) { - dbResult = new List>>(); + dbResult = new Dictionary>(); } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; diff --git a/WebDoorCreator.UI/Program.cs b/WebDoorCreator.UI/Program.cs index dbe1c77..6f93052 100644 --- a/WebDoorCreator.UI/Program.cs +++ b/WebDoorCreator.UI/Program.cs @@ -51,7 +51,7 @@ builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); builder.Services.AddScoped(); -builder.Services.AddScoped(); +builder.Services.AddSingleton(); builder.Services.AddScoped>(); builder.Services.AddHttpContextAccessor(); builder.Services.AddSingleton(redisMultiplexer); From b410d4dd0cdb48dbe554bfe5d4de981746f9174f Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Tue, 4 Apr 2023 11:07:16 +0200 Subject: [PATCH 36/43] aggiunto modello lingue --- WebDoorCreator.Data/DbModels/LanguageModel.cs | 33 + WebDoorCreator.Data/LanguageConfiguration.cs | 38 + ...20230404072710_AddLanguagePack.Designer.cs | 791 ++++++++++++++++++ .../WDCData/20230404072710_AddLanguagePack.cs | 40 + .../WDCData/WDCDataContextModelSnapshot.cs | 28 + WebDoorCreator.Data/WDCDataContext.cs | 7 +- 6 files changed, 934 insertions(+), 3 deletions(-) create mode 100644 WebDoorCreator.Data/DbModels/LanguageModel.cs create mode 100644 WebDoorCreator.Data/LanguageConfiguration.cs create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230404072710_AddLanguagePack.Designer.cs create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230404072710_AddLanguagePack.cs diff --git a/WebDoorCreator.Data/DbModels/LanguageModel.cs b/WebDoorCreator.Data/DbModels/LanguageModel.cs new file mode 100644 index 0000000..d6d3f9d --- /dev/null +++ b/WebDoorCreator.Data/DbModels/LanguageModel.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static WebDoorCreator.Core.Enum; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace WebDoorCreator.Data.DbModels +{ + /// + /// Lingue conosciute per il programma + /// + [Table("Languages")] + public class LanguageModel + { + /// + /// codice lingua + /// + [Key, MaxLength(5)] + public string CodLingua { get; set; } = ""; + + /// + /// Descrizione della lingua (Lingua per esteso) + /// + [MaxLength(50)] + public string DescrizioneLingua { get; set; } = ""; + } +} diff --git a/WebDoorCreator.Data/LanguageConfiguration.cs b/WebDoorCreator.Data/LanguageConfiguration.cs new file mode 100644 index 0000000..6cb29af --- /dev/null +++ b/WebDoorCreator.Data/LanguageConfiguration.cs @@ -0,0 +1,38 @@ +using Microsoft.AspNetCore.Identity; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WebDoorCreator.Data.DbModels; +using Org.BouncyCastle.Utilities.Collections; + +namespace WebDoorCreator.Data +{ + public class LanguageConfiguration : IEntityTypeConfiguration + { + #region Public Methods + + public void Configure(EntityTypeBuilder builder) + { + builder.HasData( + getNewLang("EN", "English"), + getNewLang("IT", "Italiano") + ); + } + + #endregion Public Methods + + protected LanguageModel getNewLang(string codeLang, string descLang) + { + var newRec = new LanguageModel + { + CodLingua = codeLang, + DescrizioneLingua = descLang + }; + return newRec; + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230404072710_AddLanguagePack.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230404072710_AddLanguagePack.Designer.cs new file mode 100644 index 0000000..231133a --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230404072710_AddLanguagePack.Designer.cs @@ -0,0 +1,791 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230404072710_AddLanguagePack")] + partial class AddLanguagePack + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateLockExpiry") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MeasureUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdLock") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorOpIdPathFromPatriarch") + .HasColumnType("hierarchyid"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MaxAllowed") + .HasColumnType("int"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentDoorOpId") + .HasColumnType("int"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => + { + b.Property("GraphicParamId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GraphicParamId"), 1L, 1); + + b.Property("compoId") + .HasColumnType("int"); + + b.Property("graphicParamAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamDefaultVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamsN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("GraphicParamId"); + + b.ToTable("GraphicParams"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => + { + b.Property("HardwareId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("HardwareId"), 1L, 1); + + b.Property("compoAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoLayerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoTemplateIsActive") + .HasColumnType("bit"); + + b.HasKey("HardwareId"); + + b.ToTable("Hardware"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.LanguageModel", b => + { + b.Property("CodLingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("DescrizioneLingua") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("CodLingua"); + + b.ToTable("Languages"); + + b.HasData( + new + { + CodLingua = "EN", + DescrizioneLingua = "English" + }, + new + { + CodLingua = "IT", + DescrizioneLingua = "Italiano" + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("Vocabulary"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyTempModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("VocabularyTemp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230404072710_AddLanguagePack.cs b/WebDoorCreator.Data/Migrations/WDCData/20230404072710_AddLanguagePack.cs new file mode 100644 index 0000000..8844c45 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230404072710_AddLanguagePack.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class AddLanguagePack : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Languages", + columns: table => new + { + CodLingua = table.Column(type: "nvarchar(5)", maxLength: 5, nullable: false), + DescrizioneLingua = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Languages", x => x.CodLingua); + }); + + migrationBuilder.InsertData( + table: "Languages", + columns: new[] { "CodLingua", "DescrizioneLingua" }, + values: new object[] { "EN", "English" }); + + migrationBuilder.InsertData( + table: "Languages", + columns: new[] { "CodLingua", "DescrizioneLingua" }, + values: new object[] { "IT", "Italiano" }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Languages"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs index 7ecdb15..9e72436 100644 --- a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs +++ b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs @@ -450,6 +450,34 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.ToTable("Hardware"); }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.LanguageModel", b => + { + b.Property("CodLingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("DescrizioneLingua") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("CodLingua"); + + b.ToTable("Languages"); + + b.HasData( + new + { + CodLingua = "EN", + DescrizioneLingua = "English" + }, + new + { + CodLingua = "IT", + DescrizioneLingua = "Italiano" + }); + }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => { b.Property("TableName") diff --git a/WebDoorCreator.Data/WDCDataContext.cs b/WebDoorCreator.Data/WDCDataContext.cs index d28efd3..c448ca8 100644 --- a/WebDoorCreator.Data/WDCDataContext.cs +++ b/WebDoorCreator.Data/WDCDataContext.cs @@ -73,6 +73,7 @@ namespace WebDoorCreator.Data public virtual DbSet DbSetGraphicParams { get; set; } = null!; public virtual DbSet DbSetVocabulary { get; set; } = null!; public virtual DbSet DbSetVocabularyTemp { get; set; } = null!; + public virtual DbSet DbSetLanguages { get; set; } = null!; #endregion Public Properties @@ -112,7 +113,7 @@ namespace WebDoorCreator.Data } else { - optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=WebDoorCreator;Trusted_Connection=True;", e=>e.UseHierarchyId()); + optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=WebDoorCreator;Trusted_Connection=True;", e => e.UseHierarchyId()); } } } @@ -157,10 +158,10 @@ namespace WebDoorCreator.Data if (!disableMigrate) { modelBuilder.ApplyConfiguration(new ListValuesConfiguration()); + modelBuilder.ApplyConfiguration(new LanguageConfiguration()); - //modelBuilder.ApplyConfiguration(new RoleConfiguration()); - //modelBuilder.Seed(); } + //modelBuilder.Seed(); OnModelCreatingPartial(modelBuilder); } From 6fa2b6eae2bfbfd19084f4ac436f23a13843bae7 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Tue, 4 Apr 2023 11:07:50 +0200 Subject: [PATCH 37/43] fix init vocabolario --- .../Controllers/WebDoorCreatorController.cs | 32 ++++- .../Components/Gen/NavMenuHorizontal.razor.cs | 19 ++- .../Components/Hardware/HardwareList.razor.cs | 5 +- WebDoorCreator.UI/Data/WDCUserService.cs | 25 +++- .../Data/WDCVocabularyService.cs | 126 ++++++++++++++++-- .../Data/WebDoorCreatorService.cs | 53 +++++++- 6 files changed, 233 insertions(+), 27 deletions(-) diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index 7bd00ac..157cbf4 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -2,12 +2,9 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using NLog; -using System.Collections.Generic; -using System.ComponentModel.Design; using System.Data; using WebDoorCreator.Data.DbModels; using WebDoorCreator.Data.DTO; -using static WebDoorCreator.Core.Enum; namespace WebDoorCreator.Data.Controllers { @@ -404,6 +401,7 @@ namespace WebDoorCreator.Data.Controllers await Task.Delay(1); return dbResult; } + /// /// Getting door data by orderId /// @@ -473,6 +471,30 @@ namespace WebDoorCreator.Data.Controllers return fatto; } + /// + /// Estraggo tutte le lingue disponibili per questa applicazione + /// + /// + public List LanguageGetAll() + { + List dbResult = new List(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + // extracting entire set + dbResult = localDbCtx + .DbSetLanguages + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Error in LanguageGetAll:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + /// /// ListValues list (All) /// @@ -801,7 +823,6 @@ namespace WebDoorCreator.Data.Controllers } return dbResult; } - public Dictionary> VocLemmaGetAll() { Dictionary> DTOResult = new Dictionary>(); @@ -824,7 +845,7 @@ namespace WebDoorCreator.Data.Controllers foreach (var lingua in lingue) { Dictionary dict = new Dictionary(); - foreach (var lemma in allVoc.Where(x=>x.Lingua == lingua)) + foreach (var lemma in allVoc.Where(x => x.Lingua == lingua)) { dict.Add(lemma.Lemma, lemma.Traduzione); } @@ -880,6 +901,7 @@ namespace WebDoorCreator.Data.Controllers } return fatto; } + #endregion Public Methods #region Private Fields diff --git a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs index 646db5b..be64d9f 100644 --- a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs +++ b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs @@ -19,7 +19,7 @@ namespace WebDoorCreator.UI.Components.Gen public EventCallback E_UserRole { get; set; } public EventCallback E_UserId { get; set; } - public EventCallback>>> E_VocLemmas { get; set; } + public EventCallback>> E_VocLemmas { get; set; } public List listCompanies { get; set; } = new List(); @@ -101,7 +101,6 @@ namespace WebDoorCreator.UI.Components.Gen WDCUService.EA_UserClaims -= OnNewUserClaims; WDCUService.EA_UserCurrCompany -= OnNewUserCurrComp; WDCUService.EA_UserId -= OnNewUserId; - WDCVService.EA_VocabularyLemmas -= OnNewVocLemma; } public async void OnNewUserClaims() @@ -196,9 +195,19 @@ namespace WebDoorCreator.UI.Components.Gen WDCUService.EA_UserClaims += OnNewUserClaims; WDCUService.EA_UserCurrCompany += OnNewUserCurrComp; WDCUService.EA_UserId += OnNewUserId; - WDCVService.EA_VocabularyLemmas += OnNewVocLemma; + //WDCVService.EA_VocabularyLemmas += OnNewVocLemma; } + //protected override async Task OnAfterRenderAsync(bool firstRender) + //{ + // if (firstRender) + // { + // listVocLemmas = new Dictionary>(); + + // listVocLemmas = await WDCService.VocLemmaGetAll(); + // } + //} + protected override async Task OnParametersSetAsync() { await Task.Delay(1); @@ -221,10 +230,6 @@ namespace WebDoorCreator.UI.Components.Gen // reset preliminare listRecord = new List(); listCompanies = new List(); - listVocLemmas = new Dictionary>(); - //await WDCService.FlushRedisCache(); - - listVocLemmas = await WDCService.VocLemmaGetAll(); var user = await _userManager.FindByNameAsync(currUser); if (user != null) diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs index f860b7d..0074d0e 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs @@ -1,7 +1,9 @@ using Microsoft.AspNetCore.Components; +using System.Globalization; using WebDoorCreator.Data.DbModels; using WebDoorCreator.UI.Data; + namespace WebDoorCreator.UI.Components.Hardware { public partial class HardwareList @@ -24,11 +26,12 @@ namespace WebDoorCreator.UI.Components.Hardware } } + //CultureInfo ci = CultureInfo.InstalledUICulture; protected string translate(string lemma) { string answ = ""; - answ = WDVService.traduci("IT",lemma); + answ = WDVService.traduci("EN", lemma); return answ; } diff --git a/WebDoorCreator.UI/Data/WDCUserService.cs b/WebDoorCreator.UI/Data/WDCUserService.cs index 7431177..1af9414 100644 --- a/WebDoorCreator.UI/Data/WDCUserService.cs +++ b/WebDoorCreator.UI/Data/WDCUserService.cs @@ -12,6 +12,9 @@ public event Action EA_UserCurrCompany = null!; + public event Action EA_CurrLanguage = null!; + + #endregion Public Events #region Public Properties @@ -67,7 +70,18 @@ } } } - + public string? currLanguage + { + get => _currLanguage; + set + { + if (_currLanguage != value) + { + _currLanguage = value; + reportCurrentLanguage(); + } + } + } #endregion Public Properties #region Protected Methods @@ -103,7 +117,13 @@ EA_UserCurrCompany?.Invoke(); } } - + protected void reportCurrentLanguage() + { + if (EA_CurrLanguage != null) + { + EA_CurrLanguage?.Invoke(); + } + } #endregion Protected Methods #region Private Properties @@ -112,6 +132,7 @@ private List? _userClaims { get; set; } = null; private string _userRole { get; set; } = ""; private int _userCurrComp { get; set; } //= -1; + private string? _currLanguage { get; set; } = null; #endregion Private Properties } diff --git a/WebDoorCreator.UI/Data/WDCVocabularyService.cs b/WebDoorCreator.UI/Data/WDCVocabularyService.cs index 88e36e2..5c3c33c 100644 --- a/WebDoorCreator.UI/Data/WDCVocabularyService.cs +++ b/WebDoorCreator.UI/Data/WDCVocabularyService.cs @@ -1,10 +1,53 @@ -using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal; +using Microsoft.AspNetCore.Identity.UI.Services; +using Newtonsoft.Json; +using NLog; +using Org.BouncyCastle.Asn1.X500; +using StackExchange.Redis; +using System.Diagnostics; +using WebDoorCreator.Data.Controllers; namespace WebDoorCreator.UI.Data { public class WDCVocabularyService { - public event Action EA_VocabularyLemmas = null!; + public static WebDoorCreatorController dbController = null!; + + public WDCVocabularyService(IConfiguration configuration, IConnectionMultiplexer redisConnMult, IEmailSender emailSender) + { + _configuration = configuration; + _emailSender = emailSender; + // Conf cache + redisConn = redisConnMult; + redisDb = this.redisConn.GetDatabase(); + + // json serializer... FIX errore loop circolare https://www.ryadel.com/en/jsonserializationexception-self-referencing-loop-detected-error-fix-entity-framework-asp-net-core/ + JSSettings = new JsonSerializerSettings() + { + ReferenceLoopHandling = ReferenceLoopHandling.Ignore + }; + + // cod app + CodApp = _configuration["CodApp"]; + // Conf DB + string connStr = _configuration.GetConnectionString("WDC.DB"); + if (string.IsNullOrEmpty(connStr)) + { + Log.Info("ConnString empty!"); + } + else + { + dbController = new WebDoorCreatorController(configuration); + } + + if(VocabularyLemmas == null) + { + VocabularyLemmas = Task.Run(async () => await VocLemmaGetAll()).Result; + } + + Log.Info("Avviata classe WDCVocabularyService"); + } + + public Dictionary>? VocabularyLemmas { @@ -14,11 +57,18 @@ namespace WebDoorCreator.UI.Data if (_vocabularyLemmas != value) { _vocabularyLemmas = value; - reportVocabularyLemmas(); } } } + + private Dictionary>? _vocabularyLemmas { get; set; } = null; + + private TimeSpan UltraLongCache + { + get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000); + } + public string traduci(string lingua, string lemma) { string answ = $"[{lemma}]"; @@ -34,14 +84,74 @@ namespace WebDoorCreator.UI.Data return answ; } - protected void reportVocabularyLemmas() + public async Task>?> VocLemmaGetAll() { - if (EA_VocabularyLemmas != null) + string source = "DB"; + Dictionary>? dbResult = new Dictionary>(); + // cerco da cache + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string currKey = $"{rKeyVocLemma}"; + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) { - EA_VocabularyLemmas?.Invoke(); + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>>(rawData); + if (tempResult == null) + { + dbResult = new Dictionary>(); + } + else + { + dbResult = tempResult; + } } + else + { + dbResult = dbController.VocLemmaGetAll(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new Dictionary>(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"VocLemmaGetAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; } - private Dictionary>? _vocabularyLemmas { get; set; } = null; + + /// + /// Durata cache lunga IN SECONDI + /// + private int cacheTtlLong = 60 * 5; + + /// + /// Oggetto per connessione a REDIS + /// + private IConnectionMultiplexer redisConn; + + /// + /// Oggetto DB redis da impiegare x chiamate R/W + /// + private IDatabase redisDb = null!; + + protected const string redisBaseAddr = "WDC"; + + protected const string rKeyVocLemma = $"{redisBaseAddr}:Cache:VocLemma"; + + protected Random rnd = new Random(); + + private static IConfiguration _configuration = null!; + + private static JsonSerializerSettings? JSSettings; + + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + private readonly IEmailSender _emailSender; + + public string CodApp { get; set; } = ""; } -} +} \ No newline at end of file diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index 3dbecf0..97245e5 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -1,6 +1,5 @@ using EgwCoreLib.Razor.Data; using Microsoft.AspNetCore.Identity.UI.Services; -using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.ValueContentAnalysis; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; using NLog; @@ -293,7 +292,6 @@ namespace WebDoorCreator.UI.Data public async Task VocLemmaInsert(string rootPath) { - bool fatto = false; List VocLemmas = new List(); @@ -506,6 +504,7 @@ namespace WebDoorCreator.UI.Data Log.Debug($"DoorOpGetByDoorId | {source} in: {ts.TotalMilliseconds} ms"); return dbResult; } + public async Task>?> VocLemmaGetAll() { string source = "DB"; @@ -571,7 +570,7 @@ namespace WebDoorCreator.UI.Data } } else - { + { rawData = JsonConvert.SerializeObject(dbResult, JSSettings); await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); } @@ -650,7 +649,6 @@ namespace WebDoorCreator.UI.Data return dbResult; } - /// /// Update or add door /// @@ -770,6 +768,49 @@ namespace WebDoorCreator.UI.Data return dbResult; } + /// + /// Estraggo tutte le lingue disponibili per questa applicazione + /// + /// + public async Task?> LanguageGetAll() + { + string source = "DB"; + + List? dbResult = new List(); + // cerco da cache + string currKey = $"{rKeyLanguage}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.LanguageGetAll(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"LanguageGetAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + /// /// Add new order /// @@ -1146,7 +1187,11 @@ namespace WebDoorCreator.UI.Data protected const string rKeyUsers = $"{redisBaseAddr}:Cache:Users"; protected const string rKeyUsersView = $"{redisBaseAddr}:Cache:UsersView"; + protected const string rKeyVocLemma = $"{redisBaseAddr}:Cache:VocLemma"; + + protected const string rKeyLanguage = $"{redisBaseAddr}:Cache:Languages"; + protected Random rnd = new Random(); #endregion Protected Fields From 5e97a37541e518d743b7ab04146e1a01df127c9e Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 4 Apr 2023 11:43:20 +0200 Subject: [PATCH 38/43] Prototipo cambio lingua --- .../WebDoorCreator.Data.csproj | 6 ++++ .../Components/Gen/NavMenuHorizontal.razor | 6 ++++ .../Components/Gen/NavMenuHorizontal.razor.cs | 6 ++++ .../Components/Hardware/HardwareList.razor.cs | 28 +++++++++++++++---- .../Data/WDCVocabularyService.cs | 18 ++++++------ WebDoorCreator.UI/Pages/DoorDefinition.razor | 2 +- .../Pages/DoorDefinition.razor.cs | 27 ++++++++++++++---- 7 files changed, 73 insertions(+), 20 deletions(-) diff --git a/WebDoorCreator.Data/WebDoorCreator.Data.csproj b/WebDoorCreator.Data/WebDoorCreator.Data.csproj index 3b29502..92c6d6d 100644 --- a/WebDoorCreator.Data/WebDoorCreator.Data.csproj +++ b/WebDoorCreator.Data/WebDoorCreator.Data.csproj @@ -31,6 +31,12 @@ + + Always + + + Always + Always diff --git a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor index 661bc92..d729dd3 100644 --- a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor +++ b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor @@ -64,6 +64,12 @@ }
+
+ +
diff --git a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs index be64d9f..49c5373 100644 --- a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs +++ b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs @@ -145,6 +145,12 @@ namespace WebDoorCreator.UI.Components.Gen #endregion Public Methods + protected string userLang + { + get => WDCUService.currLanguage ?? "NA"; + set => WDCUService.currLanguage = value; + } + #region Protected Properties [Inject] diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs index 0074d0e..c27f527 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs @@ -1,27 +1,42 @@ using Microsoft.AspNetCore.Components; -using System.Globalization; using WebDoorCreator.Data.DbModels; using WebDoorCreator.UI.Data; - namespace WebDoorCreator.UI.Components.Hardware { public partial class HardwareList { + #region Public Properties + + [Parameter] + public string Lingua { get; set; } = "NA"; + + #endregion Public Properties + + #region Protected Properties + + protected List? doorOp { get; set; } = null; + [Inject] protected WebDoorCreatorService WDService { get; set; } = null!; [Inject] protected WDCVocabularyService WDVService { get; set; } = null!; - protected List? doorOp { get; set; } = null; + #endregion Protected Properties - protected override async Task OnInitializedAsync() + #region Protected Methods + + protected override async Task OnParametersSetAsync() + { + await ReloadData(); + } + + private async Task ReloadData() { var listRecord = await WDService.DoorOpTypeGetAll(); if (listRecord != null) { - doorOp = listRecord.Where(x => !(x.IsDefault)).ToList(); } } @@ -31,10 +46,11 @@ namespace WebDoorCreator.UI.Components.Hardware { string answ = ""; - answ = WDVService.traduci("EN", lemma); + answ = WDVService.Traduci(Lingua, lemma); return answ; } + #endregion Protected Methods } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Data/WDCVocabularyService.cs b/WebDoorCreator.UI/Data/WDCVocabularyService.cs index 5c3c33c..fca3140 100644 --- a/WebDoorCreator.UI/Data/WDCVocabularyService.cs +++ b/WebDoorCreator.UI/Data/WDCVocabularyService.cs @@ -10,7 +10,7 @@ namespace WebDoorCreator.UI.Data { public class WDCVocabularyService { - public static WebDoorCreatorController dbController = null!; + public static WebDoorCreatorController dbController = null!; public WDCVocabularyService(IConfiguration configuration, IConnectionMultiplexer redisConnMult, IEmailSender emailSender) { @@ -38,16 +38,18 @@ namespace WebDoorCreator.UI.Data { dbController = new WebDoorCreatorController(configuration); } - - if(VocabularyLemmas == null) + if (dbController != null) { - VocabularyLemmas = Task.Run(async () => await VocLemmaGetAll()).Result; + if (VocabularyLemmas == null) + { + VocabularyLemmas = Task.Run(async () => await VocLemmaGetAll()).Result; + } } Log.Info("Avviata classe WDCVocabularyService"); - } - - + } + + public Dictionary>? VocabularyLemmas { @@ -69,7 +71,7 @@ namespace WebDoorCreator.UI.Data get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000); } - public string traduci(string lingua, string lemma) + public string Traduci(string lingua, string lemma) { string answ = $"[{lemma}]"; diff --git a/WebDoorCreator.UI/Pages/DoorDefinition.razor b/WebDoorCreator.UI/Pages/DoorDefinition.razor index b4b7328..b1ec27c 100644 --- a/WebDoorCreator.UI/Pages/DoorDefinition.razor +++ b/WebDoorCreator.UI/Pages/DoorDefinition.razor @@ -16,7 +16,7 @@
@**@ @**@ - +
diff --git a/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs b/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs index 353b437..c3258e6 100644 --- a/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs +++ b/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs @@ -7,14 +7,14 @@ using WebDoorCreator.UI.Data; namespace WebDoorCreator.UI.Pages { - public partial class DoorDefinition + public partial class DoorDefinition : IDisposable { #region Protected Properties protected int idOrd { get; set; } = 0; protected int idDoor { get; set; } = 0; protected bool paramChanged { get; set; } = false; - + [Inject] protected IJSRuntime JSRuntime { get; set; } = null!; @@ -26,9 +26,13 @@ namespace WebDoorCreator.UI.Pages [Inject] protected WebDoorCreatorService WDService { get; set; } = null!; + [Inject] + protected WDCUserService WDCUService { get; set; } = null!; #endregion Protected Properties + protected string userLang { get; set; } = "NA"; + #region Protected Methods protected override async Task OnInitializedAsync() @@ -39,12 +43,25 @@ namespace WebDoorCreator.UI.Pages { idOrd = int.Parse(_idOrd); idDoor = int.Parse(_idDoor); - await reloadData(); + await ReloadData(); } - + userLang = WDCUService.currLanguage ?? "NA"; + WDCUService.EA_CurrLanguage += WDUService_EA_CurrLanguage; } - protected async Task reloadData() + public void Dispose() + { + WDCUService.EA_CurrLanguage -= WDUService_EA_CurrLanguage; + } + + private void WDUService_EA_CurrLanguage() + { + userLang = WDCUService.currLanguage ?? "NA"; + StateHasChanged(); + //Task.Run(async () => await ReloadData()); + } + + protected async Task ReloadData() { var domani = DateTime.Today.AddDays(1); ListOrdersStatus = null; From d35e2f07271806b44fcaad927e97540e929de539 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Tue, 4 Apr 2023 15:49:50 +0200 Subject: [PATCH 39/43] aggiunta hardware --- .../Components/Gen/NavMenuHorizontal.razor | 14 +++--- .../Components/Hardware/HardwareList.razor | 40 +++++++++++---- .../Components/Hardware/HardwareList.razor.cs | 46 ++++++++++++++++- .../Hardware/HardwareList.razor.css | 25 ++++++++++ .../Hardware/HardwareList.razor.less | 28 +++++++++++ .../Hardware/HardwareList.razor.min.css | 2 +- .../Hardware/HardwareNewPanel.razor | 16 ++++++ .../Hardware/HardwareNewPanel.razor.cs | 50 +++++++++++++++++++ WebDoorCreator.UI/Pages/DoorDefinition.razor | 2 +- .../Pages/DoorDefinition.razor.cs | 6 +-- 10 files changed, 205 insertions(+), 24 deletions(-) create mode 100644 WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor create mode 100644 WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor.cs diff --git a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor index d729dd3..893b3f9 100644 --- a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor +++ b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor @@ -40,7 +40,7 @@
-
+
Hello, @context.User.Identity?.Name!
@if (listCompanies != null) @@ -63,12 +63,12 @@ } }
-
-
- +
+ +
diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor index b598d4e..c6136c0 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor @@ -1,15 +1,35 @@ -@if (doorOp != null) +@if (doorOpType != null) { -
- @foreach (var item in doorOp) - { -
-
- @(translate(item.HwCode)) -
+ @if (doorOpToShow != null) + { +
+
+
+
+ @(translate(doorOpToShow.HwCode)) +
+
- } -
+ +
+ +
+
+ } + else + { +
+ @foreach (var item in doorOpType) + { +
+
+ @(translate(item.HwCode)) +
+
+
+ } +
+ } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs index c27f527..27308eb 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Components; using WebDoorCreator.Data.DbModels; +using WebDoorCreator.UI.Components.DoorMan; using WebDoorCreator.UI.Data; namespace WebDoorCreator.UI.Components.Hardware @@ -10,12 +11,18 @@ namespace WebDoorCreator.UI.Components.Hardware [Parameter] public string Lingua { get; set; } = "NA"; + [Parameter] + public int DoorId { get; set; } = 0; + [Parameter] + public string UserId { get; set; } = ""; #endregion Public Properties #region Protected Properties - protected List? doorOp { get; set; } = null; + protected List? doorOpType { get; set; } = null; + protected DoorOpTypeModel? doorOpToShow { get; set; } = null; + protected List? doorOp { get; set; } = null; [Inject] protected WebDoorCreatorService WDService { get; set; } = null!; @@ -27,6 +34,7 @@ namespace WebDoorCreator.UI.Components.Hardware #region Protected Methods + protected int hwCodeToShow { get; set; } = 0; protected override async Task OnParametersSetAsync() { await ReloadData(); @@ -37,7 +45,7 @@ namespace WebDoorCreator.UI.Components.Hardware var listRecord = await WDService.DoorOpTypeGetAll(); if (listRecord != null) { - doorOp = listRecord.Where(x => !(x.IsDefault)).ToList(); + doorOpType = listRecord.Where(x => !(x.IsDefault)).ToList(); } } @@ -51,6 +59,40 @@ namespace WebDoorCreator.UI.Components.Hardware return answ; } + protected async Task hwToChoose(string hwCode) + { + await Task.Delay(1); + if (hwCode != "" && doorOpType != null) + { + doorOpToShow = doorOpType.Where(x => x.HwCode == hwCode).FirstOrDefault(); + } + } + + protected async Task hwToAdd() + { + await Task.Delay(1); + DateTime adesso = DateTime.Now; + List listOp = new List(); + + if (doorOpToShow != null) + { + DoorOpModel doorOpToAdd = new DoorOpModel() + { + DateIns = adesso, + DateMod = adesso, + UserIdIns = UserId, + UserIdMod = UserId, + DoorOpTypId = doorOpToShow.DoorOpTypId, + DoorId = DoorId, + JsoncConfigVal = doorOpToShow.JsoncConfig + }; + listOp.Add(doorOpToAdd); + // salvo Door OP associate + await WDService.DoorOpInsert(DoorId, listOp); + } + + } + #endregion Protected Methods } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.css b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.css index a856fe0..a092c98 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.css +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.css @@ -23,6 +23,31 @@ top: -1.5rem; background: black; } +.rectangleDetail { + height: 2.75rem; + width: 75%; + background: #CFD8DC; + position: relative; + margin-bottom: 4rem; + margin-top: 1.25rem; + border-radius: 0.8rem; + display: flex; + flex-wrap: wrap; + align-items: center; + color: #000; + font-weight: bold; +} +.circleDetail { + position: absolute; + height: 6.25rem; + width: 6.25rem; + border-radius: 50%; + border: 4px solid #CFD8DC; + left: 100%; + margin-left: -1.563rem; + top: -1.5rem; + background: black; +} .all { width: 72rem; } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.less b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.less index 9afc56e..7713e3f 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.less +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.less @@ -25,6 +25,34 @@ background: black; } + +.rectangleDetail { + height: 2.75rem; + width: 75%; + background: #CFD8DC; + position: relative; + margin-bottom: 4rem; + margin-top: 1.25rem; + border-radius: 0.8rem; + display: flex; + flex-wrap: wrap; + align-items: center; + color: #000; + font-weight: bold; +} + +.circleDetail { + position: absolute; + height: 6.25rem; + width: 6.25rem; + border-radius: 50%; + border: 4px solid #CFD8DC; + left: 100%; + margin-left: -1.563rem; + top: -1.5rem; + background: black; +} + .all { width: 72rem; } diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.min.css b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.min.css index c6e65f8..eb050cf 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.min.css +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.min.css @@ -1 +1 @@ -.rectangle{height:2.75rem;width:75%;background:#cfd8dc;position:relative;margin-bottom:4rem;margin-top:1.25rem;border-radius:.8rem;display:flex;flex-wrap:wrap;align-items:center;color:#000;font-weight:bold;}.circle{position:absolute;height:6.25rem;width:6.25rem;border-radius:50%;border:4px solid #cfd8dc;left:100%;margin-left:-1.563rem;top:-1.5rem;background:#000;}.all{width:72rem;} \ No newline at end of file +.rectangle{height:2.75rem;width:75%;background:#cfd8dc;position:relative;margin-bottom:4rem;margin-top:1.25rem;border-radius:.8rem;display:flex;flex-wrap:wrap;align-items:center;color:#000;font-weight:bold;}.circle{position:absolute;height:6.25rem;width:6.25rem;border-radius:50%;border:4px solid #cfd8dc;left:100%;margin-left:-1.563rem;top:-1.5rem;background:#000;}.rectangleDetail{height:2.75rem;width:75%;background:#cfd8dc;position:relative;margin-bottom:4rem;margin-top:1.25rem;border-radius:.8rem;display:flex;flex-wrap:wrap;align-items:center;color:#000;font-weight:bold;}.circleDetail{position:absolute;height:6.25rem;width:6.25rem;border-radius:50%;border:4px solid #cfd8dc;left:100%;margin-left:-1.563rem;top:-1.5rem;background:#000;}.all{width:72rem;} \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor b/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor new file mode 100644 index 0000000..a3cc0a5 --- /dev/null +++ b/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor @@ -0,0 +1,16 @@ +@if (DoorOp != null) +{ + + @foreach (var item in DoorOp) + { + @foreach (var graph in getGraphicParams(item)) + { + @if (graph.graphicParamType == "TextBox") + { + + } + } + + } +} + diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor.cs b/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor.cs new file mode 100644 index 0000000..8af99bd --- /dev/null +++ b/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor.cs @@ -0,0 +1,50 @@ +using Microsoft.AspNetCore.Components; +using Newtonsoft.Json; +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 int DoorId { get; set; } = 0; + + [Inject] + protected WebDoorCreatorService WDCService { 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 override async Task OnParametersSetAsync() + { + ListRecord = await WDCService.DoorOpGetByDoorId(DoorId); + if (ListRecord != null) + { + DoorOp = ListRecord.Where(x => (x.DoorId == DoorId) && (x.DoorOpTypId == DoorTypeTypeId)).ToList(); + } + } + + public List getGraphicParams(DoorOpModel currDoorOp) + { + if (DoorOp != null) + { + var param = currDoorOp.JsoncConfigVal; + var deserialized = JsonConvert.DeserializeObject>(param); + + if (deserialized != null) + { + graphicParams = deserialized; + } + } + + return graphicParams; + } + } +} \ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/DoorDefinition.razor b/WebDoorCreator.UI/Pages/DoorDefinition.razor index b1ec27c..2983889 100644 --- a/WebDoorCreator.UI/Pages/DoorDefinition.razor +++ b/WebDoorCreator.UI/Pages/DoorDefinition.razor @@ -16,7 +16,7 @@
@**@ @**@ - +
diff --git a/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs b/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs index c3258e6..d81115f 100644 --- a/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs +++ b/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs @@ -31,7 +31,7 @@ namespace WebDoorCreator.UI.Pages #endregion Protected Properties - protected string userLang { get; set; } = "NA"; + protected string userLang { get; set; } = "EN"; #region Protected Methods @@ -45,7 +45,7 @@ namespace WebDoorCreator.UI.Pages idDoor = int.Parse(_idDoor); await ReloadData(); } - userLang = WDCUService.currLanguage ?? "NA"; + userLang = WDCUService.currLanguage ?? "EN"; WDCUService.EA_CurrLanguage += WDUService_EA_CurrLanguage; } @@ -56,7 +56,7 @@ namespace WebDoorCreator.UI.Pages private void WDUService_EA_CurrLanguage() { - userLang = WDCUService.currLanguage ?? "NA"; + userLang = WDCUService.currLanguage ?? "EN"; StateHasChanged(); //Task.Run(async () => await ReloadData()); } From 2bfbc205353066b8390fb1f5f74afdc693461900 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Tue, 4 Apr 2023 17:20:08 +0200 Subject: [PATCH 40/43] fix gestione aggiunta nuovo hardware --- .../Components/Hardware/HardwareList.razor | 12 +++++---- .../Components/Hardware/HardwareList.razor.cs | 15 ++++++++++- .../Hardware/HardwareNewPanel.razor | 25 ++++++++++++------- .../Hardware/HardwareNewPanel.razor.cs | 18 +++++++++++++ .../Data/WebDoorCreatorService.cs | 6 ++--- 5 files changed, 58 insertions(+), 18 deletions(-) diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor index c6136c0..a176926 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor @@ -5,17 +5,19 @@ {
-
+
@(translate(doorOpToShow.HwCode)) -
+
-
- -
+ +
+ +
+
} else diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs index 27308eb..1ccc032 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs @@ -23,6 +23,7 @@ namespace WebDoorCreator.UI.Components.Hardware protected List? doorOpType { get; set; } = null; protected DoorOpTypeModel? doorOpToShow { get; set; } = null; protected List? doorOp { get; set; } = null; + protected bool hwAdd { get; set; } = false; [Inject] protected WebDoorCreatorService WDService { get; set; } = null!; @@ -88,11 +89,23 @@ namespace WebDoorCreator.UI.Components.Hardware }; listOp.Add(doorOpToAdd); // salvo Door OP associate - await WDService.DoorOpInsert(DoorId, listOp); + bool fatto = await WDService.DoorOpInsert(DoorId, listOp); + + if (fatto) + { + hwAdd = fatto; + await InvokeAsync(StateHasChanged); + } } } + protected async Task backToList() + { + await Task.Delay(1); + doorOpToShow = null; + } + #endregion Protected Methods } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor b/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor index a3cc0a5..ac94497 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor +++ b/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor @@ -1,16 +1,23 @@ @if (DoorOp != null) { - @foreach (var item in DoorOp) - { - @foreach (var graph in getGraphicParams(item)) +
+ @foreach (var item in DoorOp) { - @if (graph.graphicParamType == "TextBox") - { - - } - } +
+ @foreach (var graph in getGraphicParams(item)) + { + @if (graph.graphicParamType == "TextBox") + { +
+ @(translate(graph.graphicParamAlias)) + +
+ } + } +
- } + } +
} diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor.cs b/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor.cs index 8af99bd..065ab86 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor.cs +++ b/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor.cs @@ -14,9 +14,18 @@ namespace WebDoorCreator.UI.Components.Hardware [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!; @@ -46,5 +55,14 @@ namespace WebDoorCreator.UI.Components.Hardware return graphicParams; } + + protected string translate(string lemma) + { + string answ = ""; + + answ = WDVService.Traduci(Lingua, lemma); + + return answ; + } } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index 97245e5..1ba1cc6 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -455,10 +455,10 @@ namespace WebDoorCreator.UI.Data /// public async Task DoorOpFlushCache(int DoorId) { - RedisValue pattern = new RedisValue($"{rKeyDoorOp}:*"); + RedisValue pattern = new RedisValue($"{rKeyDoorOp}*"); if (DoorId > 0) { - pattern = new RedisValue($"{rKeyDoorOp}:{DoorId}:*"); + pattern = new RedisValue($"{rKeyDoorOp}:{DoorId}*"); } bool answ = await ExecFlushRedisPattern(pattern); return answ; @@ -727,7 +727,7 @@ namespace WebDoorCreator.UI.Data } /// - /// Company list + /// List values /// public async Task?> ListValuesGetAll(string tableName, string fieldName) { From 66bb31deff802c6d35f404d12646c9aec052a111 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Tue, 4 Apr 2023 18:35:45 +0200 Subject: [PATCH 41/43] aggiunta files lua in listvalues --- .../Controllers/WebDoorCreatorController.cs | 43 + .../DbModels/ListValuesTempModel.cs | 36 + ...230404153616_AddListValuesTemp.Designer.cs | 817 ++++++++++++++++++ .../20230404153616_AddListValuesTemp.cs | 33 + .../WDCData/WDCDataContextModelSnapshot.cs | 26 + WebDoorCreator.Data/WDCDataContext.cs | 2 + .../Data/WebDoorCreatorService.cs | 37 + WebDoorCreator.UI/Pages/SuperAdmin.razor | 1 + WebDoorCreator.UI/Pages/SuperAdmin.razor.cs | 5 + 9 files changed, 1000 insertions(+) create mode 100644 WebDoorCreator.Data/DbModels/ListValuesTempModel.cs create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230404153616_AddListValuesTemp.Designer.cs create mode 100644 WebDoorCreator.Data/Migrations/WDCData/20230404153616_AddListValuesTemp.cs diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index 157cbf4..94ce7c1 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -522,6 +522,49 @@ namespace WebDoorCreator.Data.Controllers return dbResult; } + /// + /// Adding a new list value + /// + /// Record to add + /// + public async Task ListValuesAdd(List addList) + { + bool fatto = false; + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + + // stored di reset ListValues + var storedRes = localDbCtx + .Database + .ExecuteSqlRaw("exec dbo.stp_ListVal_Prepare"); + await localDbCtx.SaveChangesAsync(); + + // import massivo dati in tab temp + localDbCtx + .DbSetValuesTemp + .AddRange(addList); + await localDbCtx.SaveChangesAsync(); + + // stored di merge dati in vocabolario + storedRes = localDbCtx + .Database + .ExecuteSqlRaw("exec dbo.stp_ListVal_Import"); + + fatto = true; + + + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante ListValuesAdd: {Environment.NewLine}{exc}"); + } + } + return fatto; + } + /// /// Adding a new order /// diff --git a/WebDoorCreator.Data/DbModels/ListValuesTempModel.cs b/WebDoorCreator.Data/DbModels/ListValuesTempModel.cs new file mode 100644 index 0000000..80b9714 --- /dev/null +++ b/WebDoorCreator.Data/DbModels/ListValuesTempModel.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebDoorCreator.Data.DbModels +{ +#nullable disable + // + // This is here so CodeMaid doesn't reorganize this document + // + [Table("ListValuesTemp")] + public partial class ListValuesTempModel + { + #region Public Properties + + [MaxLength(50)] + public string TableName { get; set; } + + [MaxLength(50)] + public string FieldName { get; set; } + + [MaxLength(50)] + public string value { get; set; } + + [MaxLength(50)] + public string label { get; set; } + + public int ordinal { get; set; } + + #endregion Public Properties + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230404153616_AddListValuesTemp.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230404153616_AddListValuesTemp.Designer.cs new file mode 100644 index 0000000..b008afd --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230404153616_AddListValuesTemp.Designer.cs @@ -0,0 +1,817 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230404153616_AddListValuesTemp")] + partial class AddListValuesTemp + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateLockExpiry") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MeasureUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdLock") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorOpIdPathFromPatriarch") + .HasColumnType("hierarchyid"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MaxAllowed") + .HasColumnType("int"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentDoorOpId") + .HasColumnType("int"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => + { + b.Property("GraphicParamId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GraphicParamId"), 1L, 1); + + b.Property("compoId") + .HasColumnType("int"); + + b.Property("graphicParamAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamDefaultVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamsN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("GraphicParamId"); + + b.ToTable("GraphicParams"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => + { + b.Property("HardwareId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("HardwareId"), 1L, 1); + + b.Property("compoAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoLayerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoTemplateIsActive") + .HasColumnType("bit"); + + b.HasKey("HardwareId"); + + b.ToTable("Hardware"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.LanguageModel", b => + { + b.Property("CodLingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("DescrizioneLingua") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("CodLingua"); + + b.ToTable("Languages"); + + b.HasData( + new + { + CodLingua = "EN", + DescrizioneLingua = "English" + }, + new + { + CodLingua = "IT", + DescrizioneLingua = "Italiano" + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesTempModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValuesTemp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("Vocabulary"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyTempModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("VocabularyTemp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230404153616_AddListValuesTemp.cs b/WebDoorCreator.Data/Migrations/WDCData/20230404153616_AddListValuesTemp.cs new file mode 100644 index 0000000..0e06ed8 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230404153616_AddListValuesTemp.cs @@ -0,0 +1,33 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class AddListValuesTemp : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "ListValuesTemp", + columns: table => new + { + TableName = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + FieldName = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + value = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + label = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + ordinal = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ListValuesTemp", x => new { x.TableName, x.FieldName, x.value }); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ListValuesTemp"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs index 9e72436..c613b03 100644 --- a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs +++ b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs @@ -562,6 +562,32 @@ namespace WebDoorCreator.Data.Migrations.WDCData }); }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesTempModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValuesTemp"); + }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => { b.Property("OrderId") diff --git a/WebDoorCreator.Data/WDCDataContext.cs b/WebDoorCreator.Data/WDCDataContext.cs index c448ca8..cb57ac1 100644 --- a/WebDoorCreator.Data/WDCDataContext.cs +++ b/WebDoorCreator.Data/WDCDataContext.cs @@ -66,6 +66,7 @@ namespace WebDoorCreator.Data public virtual DbSet DbSetUsers { get; set; } = null!; public virtual DbSet DbSetUsersView { get; set; } = null!; public virtual DbSet DbSetValues { get; set; } = null!; + public virtual DbSet DbSetValuesTemp { get; set; } = null!; public virtual DbSet DbSetDoorOpType { get; set; } = null!; public virtual DbSet DbSetDoorOp { get; set; } = null!; @@ -136,6 +137,7 @@ namespace WebDoorCreator.Data modelBuilder.Entity().HasKey(c => new { c.UserId, c.RoleId }); modelBuilder.Entity().HasKey(c => new { c.UserId, c.RoleId }); modelBuilder.Entity().HasKey(c => new { c.TableName, c.FieldName, c.value }); + modelBuilder.Entity().HasKey(c => new { c.TableName, c.FieldName, c.value }); modelBuilder.Entity().HasKey(c => new { c.Lingua, c.Lemma }); modelBuilder.Entity().HasKey(c => new { c.Lingua, c.Lemma }); diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index 1ba1cc6..3f08b74 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -543,6 +543,43 @@ namespace WebDoorCreator.UI.Data return dbResult; } + public async Task ListValuesInsert(string rootPath) + { + List values = new List(); + string[] dirs = Directory.GetDirectories(rootPath); + foreach (string dir in dirs) + { + int ordin = 1; + string[] templateDirectories = Directory.GetDirectories(dir); + foreach (string templateDirectory in templateDirectories) + { + string[] templateFiles = Directory.GetFiles(templateDirectory); + foreach (string templateFile in templateFiles) + { + var tName = templateDirectory.Split("\\"); + var fName = templateDirectory.Split("\\"); + + ListValuesTempModel temp = new ListValuesTempModel() + { + TableName = $"{tName[tName.Length - 1]} {tName[tName.Length - 2]}", + FieldName = "Compo", + value = Path.GetFileName(templateFile), + label = Path.GetFileName(templateFile).Split(".")[0], + ordinal = ordin + }; + + values.Add(temp); + } + } + } + + bool fatto = await dbController.ListValuesAdd(values); + + return fatto; + } + + + /// /// Doors list by orderId /// diff --git a/WebDoorCreator.UI/Pages/SuperAdmin.razor b/WebDoorCreator.UI/Pages/SuperAdmin.razor index 430fa34..a2661f0 100644 --- a/WebDoorCreator.UI/Pages/SuperAdmin.razor +++ b/WebDoorCreator.UI/Pages/SuperAdmin.razor @@ -16,6 +16,7 @@
+
diff --git a/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs b/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs index 1c2aad3..9ccb2c3 100644 --- a/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs +++ b/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs @@ -299,5 +299,10 @@ namespace WebDoorCreator.UI.Pages await Task.Delay(1); await WDService.VocLemmaInsert(@$"{defaultPath}"); } + protected async Task refreshFiles() + { + await Task.Delay(1); + await WDService.ListValuesInsert(@$"{defaultPath}"); + } } } \ No newline at end of file From 61aafd4975d6b520054ae9d7aaae40a8db8790e8 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Tue, 4 Apr 2023 18:38:09 +0200 Subject: [PATCH 42/43] fix ordinal increment --- WebDoorCreator.UI/Data/WebDoorCreatorService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index 3f08b74..0bfbba9 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -569,6 +569,7 @@ namespace WebDoorCreator.UI.Data }; values.Add(temp); + ordin++; } } } From a146fbd7985aca3bbc054be47bccb147f0ea4452 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Wed, 5 Apr 2023 08:43:05 +0200 Subject: [PATCH 43/43] fix nome file per insert list value --- WebDoorCreator.UI/Data/WebDoorCreatorService.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index 0bfbba9..fa0dbe7 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -5,6 +5,7 @@ using Newtonsoft.Json; using NLog; using StackExchange.Redis; using System.Diagnostics; +using System.Security.AccessControl; using WebDoorCreator.Core; using WebDoorCreator.Data.Controllers; using WebDoorCreator.Data.DbModels; @@ -550,9 +551,22 @@ namespace WebDoorCreator.UI.Data foreach (string dir in dirs) { int ordin = 1; + string compoCode = ""; string[] templateDirectories = Directory.GetDirectories(dir); + + string[] iniFiles = Directory.GetFiles(dir, "Config.ini"); + + foreach (string templateDirectory in templateDirectories) { + foreach (var file in iniFiles) + { + List lines = File.ReadAllLines(file).ToList(); + IniFile fIni = new IniFile(file); + + var compoName = fIni.ReadString("Compo", "Name", "COMPONAME"); + compoCode = compoName.Split("/")[1]; + } string[] templateFiles = Directory.GetFiles(templateDirectory); foreach (string templateFile in templateFiles) { @@ -561,7 +575,7 @@ namespace WebDoorCreator.UI.Data ListValuesTempModel temp = new ListValuesTempModel() { - TableName = $"{tName[tName.Length - 1]} {tName[tName.Length - 2]}", + TableName = $"{tName[tName.Length - 1]}_{compoCode}".Replace(" ", "_"), FieldName = "Compo", value = Path.GetFileName(templateFile), label = Path.GetFileName(templateFile).Split(".")[0],