From 7c35e1ede612524345115da3677db030b6de91a2 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 23 Jun 2021 18:08:01 +0200 Subject: [PATCH 1/4] Aggiunta step x creazione DB + stringhe init MySql --- GWMS.Data/AdminContext.cs | 75 +++++++++++++++++++++++ GWMS.Data/Controllers/GWMSController.cs | 10 +++ GWMS.Data/DatabaseModels/UserPrivModel.cs | 27 ++++++++ GWMS.Data/DbAdmin.cs | 75 +++++++++++++++++++++++ GWMS.Data/DbConfig.cs | 60 ++++++++++++++++++ GWMS.Data/GWMSContext.cs | 40 +++++------- 6 files changed, 264 insertions(+), 23 deletions(-) create mode 100644 GWMS.Data/AdminContext.cs create mode 100644 GWMS.Data/DatabaseModels/UserPrivModel.cs create mode 100644 GWMS.Data/DbAdmin.cs create mode 100644 GWMS.Data/DbConfig.cs diff --git a/GWMS.Data/AdminContext.cs b/GWMS.Data/AdminContext.cs new file mode 100644 index 0000000..9c5b224 --- /dev/null +++ b/GWMS.Data/AdminContext.cs @@ -0,0 +1,75 @@ +using GWMS.Data.DatabaseModels; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GWMS.Data +{ + public partial class AdminContext : DbContext + { + #region Private Fields + + private IConfiguration _configuration; + + #endregion Private Fields + + #region Public Constructors + + public AdminContext() + { + } + + public AdminContext(IConfiguration configuration) + { + _configuration = configuration; + } + + public AdminContext(DbContextOptions options) : base(options) + { + } + + #endregion Public Constructors + + #region Public Properties + + /// + /// User management + /// + public DbSet UserList { get; set; } + + #endregion Public Properties + + #region Private Methods + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); + + #endregion Private Methods + + #region Protected Methods + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + string connString = DbConfig.ADMIN_CONNECTION_STRING; + if (!optionsBuilder.IsConfigured) + { + //connString = _configuration.GetConnectionString("GWMS.Data"); + //connString = "Server=localhost;port=3306;database=GWMS;user=GWMS;pwd=GWMS_secret_pwd;sslmode=None;"; + var serverVersion = ServerVersion.AutoDetect(connString); + optionsBuilder.UseMySql(connString, serverVersion); + } + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasKey(c => new { c.Host, c.User }); + + OnModelCreatingPartial(modelBuilder); + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/GWMS.Data/Controllers/GWMSController.cs b/GWMS.Data/Controllers/GWMSController.cs index 8c42f0b..ab2dcc1 100644 --- a/GWMS.Data/Controllers/GWMSController.cs +++ b/GWMS.Data/Controllers/GWMSController.cs @@ -235,6 +235,16 @@ namespace GWMS.Data.Controllers return dbResult; } + public bool HasPlantLog() + { + var answ = + dbCtx + .DbSetPlantLog + .Count(); + + return (answ > 0); + } + /// /// Aggiorna un Ordine /// diff --git a/GWMS.Data/DatabaseModels/UserPrivModel.cs b/GWMS.Data/DatabaseModels/UserPrivModel.cs new file mode 100644 index 0000000..37d8d20 --- /dev/null +++ b/GWMS.Data/DatabaseModels/UserPrivModel.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GWMS.Data.DatabaseModels +{ + /// + /// Tabella dei USER di MySql + /// + [Table("user")] + public class UserPriv + { + #region Public Properties + + [Column("Host", Order = 1)] + public string Host { get; set; } = ""; + + [Column("User", Order = 2)] + public string User { get; set; } = ""; + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/GWMS.Data/DbAdmin.cs b/GWMS.Data/DbAdmin.cs new file mode 100644 index 0000000..4871887 --- /dev/null +++ b/GWMS.Data/DbAdmin.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; + +namespace GWMS.Data +{ + public class DbAdmin : IDisposable + { + #region Private Fields + + private AdminContext adbCtx; + + #endregion Private Fields + + #region Public Fields + + /// + /// Singleton gestione + /// + public static DbAdmin man = new DbAdmin(); + + #endregion Public Fields + + #region Public Constructors + + public DbAdmin() + { + // Initialize database context for ADMIN + adbCtx = new AdminContext(); + } + + #endregion Public Constructors + + #region Public Methods + + public bool checkCreateUser(string username, string pwd) + { + bool answ = false; + // ricerca utente... + var numUser = adbCtx + .UserList + .Where(x => x.User == username) + .ToList() + .Count; + if (numUser > 0) + { + answ = true; + } + if (!answ) + { + // creo utente + string sqlCommand = "FLUSH PRIVILEGES;"; + adbCtx.Database.ExecuteSqlRaw(sqlCommand); + sqlCommand = $"CREATE USER '{username}'@'localhost' IDENTIFIED BY '{pwd}';"; + adbCtx.Database.ExecuteSqlRaw(sqlCommand); + sqlCommand = $"GRANT ALL ON *.* TO '{username}'@'localhost';"; + adbCtx.Database.ExecuteSqlRaw(sqlCommand); + sqlCommand = "FLUSH PRIVILEGES;"; + adbCtx.Database.ExecuteSqlRaw(sqlCommand); + } + return answ; + } + + public void Dispose() + { + // Clear database context + adbCtx.Dispose(); + } + + #endregion Public Methods + } +} \ No newline at end of file diff --git a/GWMS.Data/DbConfig.cs b/GWMS.Data/DbConfig.cs new file mode 100644 index 0000000..b7a8a61 --- /dev/null +++ b/GWMS.Data/DbConfig.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GWMS.Data +{ + public static class DbConfig + { + #region Public Fields + + public static string DATABASE_NAME = "GWMS"; + + public static int DATABASE_PROCESS_TIMEOUT = 5; + public static string DATABASE_PWD = "viadante16"; + + // Database config + public static string DATABASE_SERV = "127.0.0.1"; + + public static string DATABASE_USER = "GWMS_User"; + + #endregion Public Fields + + #region Public Properties + + /// + /// DB Connection string per azioni amministrative + /// + public static string ADMIN_CONNECTION_STRING { get; set; } = ""; + + /// + /// DB Connection string + /// + public static string CONNECTION_STRING { get; set; } = ""; + + #endregion Public Properties + + #region Public Methods + + public static bool CheckUser(string nKey, string sKey) + { + // esecuzione script di install locale + return DbAdmin.man.checkCreateUser(DATABASE_USER, DATABASE_PWD); + } + + public static void InitDb(string server, string nKey, string sKey) + { + DATABASE_SERV = server; + DATABASE_NAME = $"GWMS_{nKey}"; + DATABASE_USER = $"user_{nKey}"; + DATABASE_PWD = $"pwd_{sKey}"; + CONNECTION_STRING = $"server={DATABASE_SERV};port=3306;database={DATABASE_NAME};uid={DATABASE_USER};pwd={DATABASE_PWD};sslmode=None"; + // stringa admin con utente root egalware... + ADMIN_CONNECTION_STRING = $"server={DATABASE_SERV};port=3306;database=mysql;uid=root;pwd=Egalware_24068!;sslmode=None"; + } + + #endregion Public Methods + } +} \ No newline at end of file diff --git a/GWMS.Data/GWMSContext.cs b/GWMS.Data/GWMSContext.cs index 8136bdb..aa3ade7 100644 --- a/GWMS.Data/GWMSContext.cs +++ b/GWMS.Data/GWMSContext.cs @@ -5,6 +5,7 @@ using Microsoft.Extensions.Configuration; using GWMS.Data.DatabaseModels; using NLog; using System.Linq; +using GWMS.Data.Controllers; namespace GWMS.Data { @@ -16,8 +17,6 @@ namespace GWMS.Data private IConfiguration _configuration; - private bool useMysql = true; - #endregion Private Fields #region Public Constructors @@ -29,10 +28,14 @@ namespace GWMS.Data public GWMSContext(IConfiguration configuration) { _configuration = configuration; + // se non ci fosse... crea! + Database.EnsureCreated(); } public GWMSContext(DbContextOptions options) : base(options) { + // se non ci fosse... crea! + Database.EnsureCreated(); } #endregion Public Constructors @@ -66,24 +69,20 @@ namespace GWMS.Data protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - string connString = ""; + //var test01 = _configuration.GetConnectionString("GWMS.Data"); + string server = _configuration["DbConfig:Server"]; + string nKey = _configuration["DbConfig:nKey"]; + string sKey = _configuration["DbConfig:sKey"]; + + DbConfig.InitDb("localhost", nKey, sKey); + DbConfig.CheckUser(nKey, sKey); + + string connString = DbConfig.CONNECTION_STRING; if (!optionsBuilder.IsConfigured) { - // caso MySql - if (useMysql) - { - //connString = _configuration.GetConnectionString("GWMS.Data"); - connString = "Server=localhost;port=3306;database=GWMS;user=GWMS;pwd=GWMS_secret_pwd;sslmode=None;"; - var serverVersion = ServerVersion.AutoDetect(connString); - optionsBuilder.UseMySql(connString, serverVersion); - } - // caso MsSql - else - { - //connString = _configuration.GetConnectionString("GWMS.Data"); - //optionsBuilder.UseSqlServer(connString); - optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=GWMS;Trusted_Connection=True;"); - } + //connString = "Server=localhost;port=3306;database=GWMS;user=GWMS;pwd=GWMS_secret_pwd;sslmode=None;"; + var serverVersion = ServerVersion.AutoDetect(connString); + optionsBuilder.UseMySql(connString, serverVersion); } } @@ -94,11 +93,6 @@ namespace GWMS.Data relationship.DeleteBehavior = DeleteBehavior.Restrict; } - if (!useMysql) - { - modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS"); - } - modelBuilder.Entity(entity => { entity.Property(e => e.ValStd) From 28956a84812fdfe84243c926ed2f8bf7bcb752a9 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 23 Jun 2021 18:08:18 +0200 Subject: [PATCH 2/4] refresh init: se DB non configurato --> warning x SIM --- GWMS.UI/Data/GWMSDataService.cs | 5 +++++ GWMS.UI/Pages/Index.razor | 33 ++++++++++++++++++++++++++++++++- GWMS.UI/appsettings.json | 9 +++++++-- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/GWMS.UI/Data/GWMSDataService.cs b/GWMS.UI/Data/GWMSDataService.cs index 7d3deba..0d381b4 100644 --- a/GWMS.UI/Data/GWMSDataService.cs +++ b/GWMS.UI/Data/GWMSDataService.cs @@ -129,6 +129,11 @@ namespace GWMS.UI.Data return await Task.FromResult(dbResult); } + public async Task HasPlantLog() + { + return await Task.FromResult(dbController.HasPlantLog()); + } + public async Task> ItemsGetAll() { //return Task.FromResult(dbController.ActionsGetAll()); diff --git a/GWMS.UI/Pages/Index.razor b/GWMS.UI/Pages/Index.razor index 7a1b5ae..f79886b 100644 --- a/GWMS.UI/Pages/Index.razor +++ b/GWMS.UI/Pages/Index.razor @@ -1,5 +1,9 @@ @page "/" +@using GWMS.UI.Data + +@inject GWMSDataService DataService +
@@ -14,4 +18,31 @@
- \ No newline at end of file + +@if (!DataOk) +{ +
+
+
+
+ No data Found +
+
+ + Setup Parametri + +
+
+
+
+} + +@code +{ + protected bool DataOk { get; set; } = false; + + protected override async Task OnInitializedAsync() + { + DataOk = await DataService.HasPlantLog(); + } +} \ No newline at end of file diff --git a/GWMS.UI/appsettings.json b/GWMS.UI/appsettings.json index d65a4be..325c75c 100644 --- a/GWMS.UI/appsettings.json +++ b/GWMS.UI/appsettings.json @@ -8,8 +8,13 @@ }, "AllowedHosts": "*", "ConnectionStrings": { - "DefaultConnection": "Server=SQL2016DEV;Database=GWMS;Trusted_Connection=True;MultipleActiveResultSets=true", - "GWMS.Data": "Server=SQL2016DEV;Database=GWMS;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=GWMS.UI;" + "DefaultConnection": "Server=localhost;port=3306;database=GWMS;user=GWMS;pwd=GWMS_secret_pwd;sslmode=None;", + "GWMS.Data": "Server=localhost;port=3306;database=GWMS;user=GWMS;pwd=GWMS_secret_pwd;sslmode=None;" + }, + "DbConfig": { + "Server": "localhost", + "nKey": "PZZFRR", + "sKey": "M3T@n0" }, "matrixUrl": "http://qrcode.steamware.net/" } \ No newline at end of file From 8e0c31b29a95fd499bdb7051f9d29eb5383c7e46 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 23 Jun 2021 18:17:27 +0200 Subject: [PATCH 3/4] modifica DB x gestione planner consegne avanzato --- .../DatabaseModels/PlantSupplWeekPlanModel.cs | 5 + GWMS.Data/GWMSContext.cs | 23 +- .../20210623161219_UpdatePlanner.Designer.cs | 787 ++++++++++++++++++ .../20210623161219_UpdatePlanner.cs | 130 +++ .../Migrations/GWMSContextModelSnapshot.cs | 25 +- 5 files changed, 957 insertions(+), 13 deletions(-) create mode 100644 GWMS.Data/Migrations/20210623161219_UpdatePlanner.Designer.cs create mode 100644 GWMS.Data/Migrations/20210623161219_UpdatePlanner.cs diff --git a/GWMS.Data/DatabaseModels/PlantSupplWeekPlanModel.cs b/GWMS.Data/DatabaseModels/PlantSupplWeekPlanModel.cs index 655d566..168cd9e 100644 --- a/GWMS.Data/DatabaseModels/PlantSupplWeekPlanModel.cs +++ b/GWMS.Data/DatabaseModels/PlantSupplWeekPlanModel.cs @@ -21,6 +21,8 @@ namespace GWMS.Data.DatabaseModels public int SupplierId { get; set; } + public int TransporterId { get; set; } + public DayOfWeek DayNum { get; set; } = DayOfWeek.Monday; [MaxLength(250)] @@ -32,6 +34,9 @@ namespace GWMS.Data.DatabaseModels [ForeignKey("SupplierId")] public virtual SupplierModel Supplier { get; set; } + [ForeignKey("TransporterId")] + public virtual TransporterModel Transporter { get; set; } + #endregion Public Properties } } \ No newline at end of file diff --git a/GWMS.Data/GWMSContext.cs b/GWMS.Data/GWMSContext.cs index aa3ade7..8a621d3 100644 --- a/GWMS.Data/GWMSContext.cs +++ b/GWMS.Data/GWMSContext.cs @@ -69,15 +69,24 @@ namespace GWMS.Data protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - //var test01 = _configuration.GetConnectionString("GWMS.Data"); - string server = _configuration["DbConfig:Server"]; - string nKey = _configuration["DbConfig:nKey"]; - string sKey = _configuration["DbConfig:sKey"]; + // default + string connString = "Server=localhost;port=3306;database=GWMS;user=GWMS;pwd=GWMS_secret_pwd;sslmode=None;"; - DbConfig.InitDb("localhost", nKey, sKey); - DbConfig.CheckUser(nKey, sKey); + // tento setup da config + try + { + string server = _configuration["DbConfig:Server"]; + string nKey = _configuration["DbConfig:nKey"]; + string sKey = _configuration["DbConfig:sKey"]; - string connString = DbConfig.CONNECTION_STRING; + DbConfig.InitDb("localhost", nKey, sKey); + DbConfig.CheckUser(nKey, sKey); + + // uso conn string calcolata + connString = DbConfig.CONNECTION_STRING; + } + catch + { } if (!optionsBuilder.IsConfigured) { //connString = "Server=localhost;port=3306;database=GWMS;user=GWMS;pwd=GWMS_secret_pwd;sslmode=None;"; diff --git a/GWMS.Data/Migrations/20210623161219_UpdatePlanner.Designer.cs b/GWMS.Data/Migrations/20210623161219_UpdatePlanner.Designer.cs new file mode 100644 index 0000000..d2ea7c6 --- /dev/null +++ b/GWMS.Data/Migrations/20210623161219_UpdatePlanner.Designer.cs @@ -0,0 +1,787 @@ +// +using System; +using GWMS.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace GWMS.Data.Migrations +{ + [DbContext(typeof(GWMSContext))] + [Migration("20210623161219_UpdatePlanner")] + partial class UpdatePlanner + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 64) + .HasAnnotation("ProductVersion", "5.0.6"); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.AnKeyValModel", b => + { + b.Property("KeyName") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Descript") + .HasMaxLength(250) + .HasColumnType("varchar(250)") + .HasComment("Descrizione dell'item"); + + b.Property("ValFloat") + .HasColumnType("int"); + + b.Property("ValInt") + .HasColumnType("int"); + + b.Property("ValString") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("KeyName"); + + b.ToTable("AnKeyVal"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.ConfigModel", b => + { + b.Property("KeyName") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Note") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Val") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ValStd") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasComment("Valore di default/riferimento per la variabile"); + + b.HasKey("KeyName"); + + b.ToTable("Config"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.ItemModel", b => + { + b.Property("ItemId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("ItemCode") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("ItemDesc") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("ItemType") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("UM") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("ItemId"); + + b.ToTable("Items"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.ListValModel", b => + { + b.Property("TabName") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("TabName"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("FieldName"); + + b.Property("Val") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("Val"); + + b.Property("Descript") + .HasMaxLength(250) + .HasColumnType("varchar(250)") + .HasColumnName("Descript"); + + b.Property("Ordinal") + .HasColumnType("int") + .HasColumnName("Ordinal"); + + b.HasKey("TabName", "FieldName", "Val"); + + b.ToTable("ListVal"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DtETA") + .HasColumnType("datetime(6)"); + + b.Property("DtExecEnd") + .HasColumnType("datetime(6)"); + + b.Property("DtExecStart") + .HasColumnType("datetime(6)"); + + b.Property("DtOrder") + .HasColumnType("datetime(6)"); + + b.Property("ExecutionQty") + .HasColumnType("double"); + + b.Property("OrderCode") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("OrderDesc") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("OrderQty") + .HasColumnType("double"); + + b.Property("PlantId") + .HasColumnType("int"); + + b.Property("SupplierId") + .HasColumnType("int"); + + b.Property("TransporterId") + .HasColumnType("int"); + + b.HasKey("OrderId"); + + b.HasIndex("PlantId"); + + b.HasIndex("SupplierId"); + + b.HasIndex("TransporterId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantDetailModel", b => + { + b.Property("PlantId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("LevelAct") + .HasColumnType("double"); + + b.Property("LevelMax") + .HasColumnType("double"); + + b.Property("PlantCode") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("PlantDesc") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("PressAct") + .HasColumnType("double"); + + b.Property("PressBHAct") + .HasColumnType("double"); + + b.Property("PressBHMax") + .HasColumnType("double"); + + b.Property("PressBLAct") + .HasColumnType("double"); + + b.Property("PressBLMax") + .HasColumnType("double"); + + b.Property("PressMax") + .HasColumnType("double"); + + b.HasKey("PlantId"); + + b.ToTable("PlantDetail"); + + b.HasData( + new + { + PlantId = 1, + LevelAct = 0.0, + LevelMax = 28000.0, + PlantCode = "PIZ03", + PlantDesc = "Collecchio", + PressAct = 0.0, + PressBHAct = 0.0, + PressBHMax = 270.0, + PressBLAct = 0.0, + PressBLMax = 270.0, + PressMax = 19.0 + }, + new + { + PlantId = 2, + LevelAct = 0.0, + LevelMax = 28000.0, + PlantCode = "PIZ04", + PlantDesc = "Noceto", + PressAct = 0.0, + PressBHAct = 0.0, + PressBHMax = 270.0, + PressBLAct = 0.0, + PressBLMax = 270.0, + PressMax = 19.0 + }, + new + { + PlantId = 3, + LevelAct = 0.0, + LevelMax = 24000.0, + PlantCode = "PIZ05", + PlantDesc = "Baganzola", + PressAct = 0.0, + PressBHAct = 0.0, + PressBHMax = 270.0, + PressBLAct = 0.0, + PressBLMax = 270.0, + PressMax = 19.0 + }, + new + { + PlantId = 4, + LevelAct = 0.0, + LevelMax = 24000.0, + PlantCode = "PIZ08", + PlantDesc = "Pilastrello", + PressAct = 0.0, + PressBHAct = 0.0, + PressBHMax = 270.0, + PressBLAct = 0.0, + PressBLMax = 270.0, + PressMax = 19.0 + }); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantLogModel", b => + { + b.Property("PlantDataId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DtEvent") + .HasColumnType("datetime(6)"); + + b.Property("FluxType") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("PlantId") + .HasColumnType("int"); + + b.Property("ValNumber") + .HasColumnType("double"); + + b.Property("ValString") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("PlantDataId"); + + b.HasIndex("PlantId"); + + b.ToTable("PlantLog"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantStatusModel", b => + { + b.Property("PlantId") + .HasColumnType("int"); + + b.Property("FluxType") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("DtEvent") + .HasColumnType("datetime(6)"); + + b.Property("ValNumber") + .HasColumnType("double"); + + b.Property("ValString") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("PlantId", "FluxType"); + + b.ToTable("PlantStatus"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantSupplWeekPlanModel", b => + { + b.Property("PlantId") + .HasColumnType("int"); + + b.Property("SupplierId") + .HasColumnType("int"); + + b.Property("DayNum") + .HasColumnType("int"); + + b.Property("Note") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("TransporterId") + .HasColumnType("int"); + + b.HasKey("PlantId", "SupplierId", "DayNum"); + + b.HasIndex("SupplierId"); + + b.HasIndex("TransporterId"); + + b.ToTable("PlantSupplWeekPlan"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.SupplierModel", b => + { + b.Property("SupplierId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("SupplierCode") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("SupplierDesc") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("SupplierId"); + + b.ToTable("Supplier"); + + b.HasData( + new + { + SupplierId = 1, + SupplierCode = "LIQUIGAS", + SupplierDesc = "Fornitore Liquigas" + }, + new + { + SupplierId = 2, + SupplierCode = "VULKANGAS", + SupplierDesc = "Fornitore Vulkangas" + }); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.TransporterModel", b => + { + b.Property("TransporterId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("PositionLatitude") + .HasColumnType("double"); + + b.Property("PositionLongitude") + .HasColumnType("double"); + + b.Property("PositionUpdated") + .HasColumnType("datetime(6)"); + + b.Property("TransporterCode") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("TransporterDesc") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("TransporterId"); + + b.ToTable("Transporter"); + + b.HasData( + new + { + TransporterId = 1, + PositionLatitude = 0.0, + PositionLongitude = 0.0, + PositionUpdated = new DateTime(2021, 6, 23, 18, 12, 19, 514, DateTimeKind.Local).AddTicks(5589), + TransporterCode = "LEVO", + TransporterDesc = "Trasportatore Levorato" + }, + new + { + TransporterId = 2, + PositionLatitude = 0.0, + PositionLongitude = 0.0, + PositionUpdated = new DateTime(2021, 6, 23, 18, 12, 19, 514, DateTimeKind.Local).AddTicks(6159), + TransporterCode = "TRAF", + TransporterDesc = "Trasportatore Traffik" + }); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.UserModel", b => + { + b.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AuthKey") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("Firstname") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Lang") + .HasMaxLength(10) + .HasColumnType("varchar(10)"); + + b.Property("Lastname") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Livello") + .HasColumnType("int"); + + b.Property("MaskPlantId") + .HasColumnType("int"); + + b.Property("MaskSupplierId") + .HasColumnType("int"); + + b.Property("MaskTranspId") + .HasColumnType("int"); + + b.Property("SaltPasswd") + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("UserName") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("UserId"); + + b.ToTable("Users"); + + b.HasData( + new + { + UserId = 1, + AuthKey = "th1sIsTh3R1vrOfThNgt98", + Email = "samuele@steamware.net", + Firstname = "Samuele", + IsActive = true, + Lang = "IT", + Lastname = "Locatelli", + Livello = 1, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "samuele.locatelli" + }, + new + { + UserId = 2, + AuthKey = "th1sIsTh3R1vrOfThNgt91", + Email = "giancarlo@steamware.net", + Firstname = "Giancarlo", + IsActive = true, + Lang = "IT", + Lastname = "Rottoli", + Livello = 1, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "giancarlo.rottoli" + }, + new + { + UserId = 3, + AuthKey = "th1sIsTh3R1vrOfThNgt93", + Email = "info@steamware.net", + Firstname = "Steamware", + IsActive = true, + Lang = "IT", + Lastname = "Admin", + Livello = 1, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "steamw.admin" + }, + new + { + UserId = 4, + AuthKey = "th1sIsTh3R1vrOfThNgt97", + Email = "a.pizzaferri@pizzaferripetroli.it", + Firstname = "Angelo", + IsActive = true, + Lang = "IT", + Lastname = "Pizzaferri", + Livello = 2, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "angelo.pizzaferri" + }, + new + { + UserId = 5, + AuthKey = "th1sIsTh3R1vrOfThNgt99", + Email = "andrei.valeanu@winnlab.it", + Firstname = "Andrei", + IsActive = true, + Lang = "IT", + Lastname = "Valeanu", + Livello = 2, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "andrei.valeanu" + }, + new + { + UserId = 6, + AuthKey = "th1sIsTh3R1vrOfThNgt92", + Email = "info@steamware.net", + Firstname = "User", + IsActive = true, + Lang = "IT", + Lastname = "LIQUIGAS", + Livello = 4, + MaskPlantId = 0, + MaskSupplierId = 1, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "liquigas.user01" + }, + new + { + UserId = 7, + AuthKey = "th1sIsTh3R1vrOfThNgt94", + Email = "info@steamware.net", + Firstname = "User", + IsActive = true, + Lang = "IT", + Lastname = "VULKANGAS", + Livello = 4, + MaskPlantId = 0, + MaskSupplierId = 2, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "vulkangas.user01" + }, + new + { + UserId = 8, + AuthKey = "th1sIsTh3R1vrOfThNgt95", + Email = "info@steamware.net", + Firstname = "User", + IsActive = true, + Lang = "IT", + Lastname = "LEVORATO", + Livello = 4, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 1, + SaltPasswd = "", + UserName = "levorato.user01" + }, + new + { + UserId = 9, + AuthKey = "th1sIsTh3R1vrOfThNgt96", + Email = "info@steamware.net", + Firstname = "User", + IsActive = true, + Lang = "IT", + Lastname = "TRAFFIK", + Livello = 4, + MaskPlantId = 0, + MaskSupplierId = 0, + MaskTranspId = 2, + SaltPasswd = "", + UserName = "traffik.user01" + }, + new + { + UserId = 10, + AuthKey = "th1sIsTh3R1vrOfThNgt96", + Email = "info@steamware.net", + Firstname = "Stazione", + IsActive = true, + Lang = "IT", + Lastname = "Collecchio", + Livello = 3, + MaskPlantId = 1, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "piz03.user01" + }, + new + { + UserId = 11, + AuthKey = "th1sIsTh3R1vrOfThNgt96", + Email = "info@steamware.net", + Firstname = "Stazione", + IsActive = true, + Lang = "IT", + Lastname = "Noceto", + Livello = 3, + MaskPlantId = 2, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "piz04.user01" + }, + new + { + UserId = 12, + AuthKey = "th1sIsTh3R1vrOfThNgt96", + Email = "info@steamware.net", + Firstname = "Stazione", + IsActive = true, + Lang = "IT", + Lastname = "Baganzola", + Livello = 3, + MaskPlantId = 3, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "piz05.user01" + }, + new + { + UserId = 13, + AuthKey = "th1sIsTh3R1vrOfThNgt96", + Email = "info@steamware.net", + Firstname = "Stazione", + IsActive = true, + Lang = "IT", + Lastname = "Pilastrello", + Livello = 3, + MaskPlantId = 4, + MaskSupplierId = 0, + MaskTranspId = 0, + SaltPasswd = "", + UserName = "piz08.user01" + }); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.OrderModel", b => + { + b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant") + .WithMany() + .HasForeignKey("PlantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GWMS.Data.DatabaseModels.SupplierModel", "Supplier") + .WithMany() + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GWMS.Data.DatabaseModels.TransporterModel", "Transporter") + .WithMany() + .HasForeignKey("TransporterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Plant"); + + b.Navigation("Supplier"); + + b.Navigation("Transporter"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantLogModel", b => + { + b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant") + .WithMany() + .HasForeignKey("PlantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Plant"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantStatusModel", b => + { + b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant") + .WithMany() + .HasForeignKey("PlantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Plant"); + }); + + modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantSupplWeekPlanModel", b => + { + b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant") + .WithMany() + .HasForeignKey("PlantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GWMS.Data.DatabaseModels.SupplierModel", "Supplier") + .WithMany() + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("GWMS.Data.DatabaseModels.TransporterModel", "Transporter") + .WithMany() + .HasForeignKey("TransporterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Plant"); + + b.Navigation("Supplier"); + + b.Navigation("Transporter"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/GWMS.Data/Migrations/20210623161219_UpdatePlanner.cs b/GWMS.Data/Migrations/20210623161219_UpdatePlanner.cs new file mode 100644 index 0000000..073582e --- /dev/null +++ b/GWMS.Data/Migrations/20210623161219_UpdatePlanner.cs @@ -0,0 +1,130 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace GWMS.Data.Migrations +{ + public partial class UpdatePlanner : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "TransporterId", + table: "PlantSupplWeekPlan", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.UpdateData( + table: "Transporter", + keyColumn: "TransporterId", + keyValue: 1, + column: "PositionUpdated", + value: new DateTime(2021, 6, 23, 18, 12, 19, 514, DateTimeKind.Local).AddTicks(5589)); + + migrationBuilder.UpdateData( + table: "Transporter", + keyColumn: "TransporterId", + keyValue: 2, + column: "PositionUpdated", + value: new DateTime(2021, 6, 23, 18, 12, 19, 514, DateTimeKind.Local).AddTicks(6159)); + + migrationBuilder.UpdateData( + table: "Users", + keyColumn: "UserId", + keyValue: 6, + column: "Livello", + value: 4); + + migrationBuilder.UpdateData( + table: "Users", + keyColumn: "UserId", + keyValue: 7, + column: "Livello", + value: 4); + + migrationBuilder.UpdateData( + table: "Users", + keyColumn: "UserId", + keyValue: 8, + column: "Livello", + value: 4); + + migrationBuilder.UpdateData( + table: "Users", + keyColumn: "UserId", + keyValue: 9, + column: "Livello", + value: 4); + + migrationBuilder.CreateIndex( + name: "IX_PlantSupplWeekPlan_TransporterId", + table: "PlantSupplWeekPlan", + column: "TransporterId"); + + migrationBuilder.AddForeignKey( + name: "FK_PlantSupplWeekPlan_Transporter_TransporterId", + table: "PlantSupplWeekPlan", + column: "TransporterId", + principalTable: "Transporter", + principalColumn: "TransporterId", + onDelete: ReferentialAction.Restrict); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_PlantSupplWeekPlan_Transporter_TransporterId", + table: "PlantSupplWeekPlan"); + + migrationBuilder.DropIndex( + name: "IX_PlantSupplWeekPlan_TransporterId", + table: "PlantSupplWeekPlan"); + + migrationBuilder.DropColumn( + name: "TransporterId", + table: "PlantSupplWeekPlan"); + + migrationBuilder.UpdateData( + table: "Transporter", + keyColumn: "TransporterId", + keyValue: 1, + column: "PositionUpdated", + value: new DateTime(2021, 6, 22, 17, 52, 9, 697, DateTimeKind.Local).AddTicks(5955)); + + migrationBuilder.UpdateData( + table: "Transporter", + keyColumn: "TransporterId", + keyValue: 2, + column: "PositionUpdated", + value: new DateTime(2021, 6, 22, 17, 52, 9, 697, DateTimeKind.Local).AddTicks(6523)); + + migrationBuilder.UpdateData( + table: "Users", + keyColumn: "UserId", + keyValue: 6, + column: "Livello", + value: 3); + + migrationBuilder.UpdateData( + table: "Users", + keyColumn: "UserId", + keyValue: 7, + column: "Livello", + value: 3); + + migrationBuilder.UpdateData( + table: "Users", + keyColumn: "UserId", + keyValue: 8, + column: "Livello", + value: 3); + + migrationBuilder.UpdateData( + table: "Users", + keyColumn: "UserId", + keyValue: 9, + column: "Livello", + value: 3); + } + } +} diff --git a/GWMS.Data/Migrations/GWMSContextModelSnapshot.cs b/GWMS.Data/Migrations/GWMSContextModelSnapshot.cs index bd2163d..52ed754 100644 --- a/GWMS.Data/Migrations/GWMSContextModelSnapshot.cs +++ b/GWMS.Data/Migrations/GWMSContextModelSnapshot.cs @@ -347,10 +347,15 @@ namespace GWMS.Data.Migrations .HasMaxLength(250) .HasColumnType("varchar(250)"); + b.Property("TransporterId") + .HasColumnType("int"); + b.HasKey("PlantId", "SupplierId", "DayNum"); b.HasIndex("SupplierId"); + b.HasIndex("TransporterId"); + b.ToTable("PlantSupplWeekPlan"); }); @@ -420,7 +425,7 @@ namespace GWMS.Data.Migrations TransporterId = 1, PositionLatitude = 0.0, PositionLongitude = 0.0, - PositionUpdated = new DateTime(2021, 6, 22, 17, 52, 9, 697, DateTimeKind.Local).AddTicks(5955), + PositionUpdated = new DateTime(2021, 6, 23, 18, 12, 19, 514, DateTimeKind.Local).AddTicks(5589), TransporterCode = "LEVO", TransporterDesc = "Trasportatore Levorato" }, @@ -429,7 +434,7 @@ namespace GWMS.Data.Migrations TransporterId = 2, PositionLatitude = 0.0, PositionLongitude = 0.0, - PositionUpdated = new DateTime(2021, 6, 22, 17, 52, 9, 697, DateTimeKind.Local).AddTicks(6523), + PositionUpdated = new DateTime(2021, 6, 23, 18, 12, 19, 514, DateTimeKind.Local).AddTicks(6159), TransporterCode = "TRAF", TransporterDesc = "Trasportatore Traffik" }); @@ -578,7 +583,7 @@ namespace GWMS.Data.Migrations IsActive = true, Lang = "IT", Lastname = "LIQUIGAS", - Livello = 3, + Livello = 4, MaskPlantId = 0, MaskSupplierId = 1, MaskTranspId = 0, @@ -594,7 +599,7 @@ namespace GWMS.Data.Migrations IsActive = true, Lang = "IT", Lastname = "VULKANGAS", - Livello = 3, + Livello = 4, MaskPlantId = 0, MaskSupplierId = 2, MaskTranspId = 0, @@ -610,7 +615,7 @@ namespace GWMS.Data.Migrations IsActive = true, Lang = "IT", Lastname = "LEVORATO", - Livello = 3, + Livello = 4, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 1, @@ -626,7 +631,7 @@ namespace GWMS.Data.Migrations IsActive = true, Lang = "IT", Lastname = "TRAFFIK", - Livello = 3, + Livello = 4, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 2, @@ -762,9 +767,17 @@ namespace GWMS.Data.Migrations .OnDelete(DeleteBehavior.Restrict) .IsRequired(); + b.HasOne("GWMS.Data.DatabaseModels.TransporterModel", "Transporter") + .WithMany() + .HasForeignKey("TransporterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + b.Navigation("Plant"); b.Navigation("Supplier"); + + b.Navigation("Transporter"); }); #pragma warning restore 612, 618 } From af2d16547fafc9d456ab3a59a17fd09dc6a82862 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 23 Jun 2021 18:17:52 +0200 Subject: [PATCH 4/4] Abbozzo pagina WeekPlan --- GWMS.UI/Pages/WeekPlan.razor | 7 +++++++ GWMS.UI/Shared/NavMenu.razor | 5 +++++ Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 5 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 GWMS.UI/Pages/WeekPlan.razor diff --git a/GWMS.UI/Pages/WeekPlan.razor b/GWMS.UI/Pages/WeekPlan.razor new file mode 100644 index 0000000..eb8e4bf --- /dev/null +++ b/GWMS.UI/Pages/WeekPlan.razor @@ -0,0 +1,7 @@ +@page "/WeekPlan" + +

WeekPlan

+ +@code { + +} \ No newline at end of file diff --git a/GWMS.UI/Shared/NavMenu.razor b/GWMS.UI/Shared/NavMenu.razor index ebbed63..5b4e932 100644 --- a/GWMS.UI/Shared/NavMenu.razor +++ b/GWMS.UI/Shared/NavMenu.razor @@ -47,6 +47,11 @@ Scheda Stazione +