From cc83fc775e22dba85d5db08788e41263ea89a50b Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 22 Mar 2023 17:37:37 +0100 Subject: [PATCH] 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