From 1acdde89e83e3c0e41fb8dce304d4d0c4b2de561 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 9 Jan 2024 17:37:10 +0100 Subject: [PATCH] ancora setup progetto identity --- MagMan.Core/MagMan.Core.csproj | 2 +- MagMan.Data/DbAdmin.cs | 4 +++- MagMan.Data/DbConfig.cs | 4 +++- MagMan.Data/MagMan.Data.csproj | 12 ++++++++++++ MagMan.UI/Components/MigrationManager.razor | 4 ++-- MagMan.UI/Health/Checks.cs | 6 +++--- MagMan.UI/MagMan.UI.csproj | 3 ++- MagMan.UI/Program.cs | 11 ++++++----- MagMan.User/MagMan.User.csproj | 18 ++++++++++++++++-- ...1222165912_CreateIdentitySchema.Designer.cs | 6 +++--- .../20231222165912_CreateIdentitySchema.cs | 2 +- .../UserIdentityDbContextModelSnapshot.cs | 6 +++--- 12 files changed, 55 insertions(+), 23 deletions(-) diff --git a/MagMan.Core/MagMan.Core.csproj b/MagMan.Core/MagMan.Core.csproj index 132c02c..27ac386 100644 --- a/MagMan.Core/MagMan.Core.csproj +++ b/MagMan.Core/MagMan.Core.csproj @@ -1,4 +1,4 @@ - + net6.0 diff --git a/MagMan.Data/DbAdmin.cs b/MagMan.Data/DbAdmin.cs index f5d3d81..b414725 100644 --- a/MagMan.Data/DbAdmin.cs +++ b/MagMan.Data/DbAdmin.cs @@ -24,6 +24,7 @@ namespace MagMan.Data #region Public Methods +#if false public static bool checkCreateUser(string username, string pwd, string dbName) { bool answ = false; @@ -64,7 +65,8 @@ namespace MagMan.Data answ = true; } return answ; - } + } +#endif public static async Task migrateDbMain() { diff --git a/MagMan.Data/DbConfig.cs b/MagMan.Data/DbConfig.cs index a18d0d2..573f3ff 100644 --- a/MagMan.Data/DbConfig.cs +++ b/MagMan.Data/DbConfig.cs @@ -39,6 +39,7 @@ namespace MagMan.Data #region Public Methods +#if false public static bool CheckUser(string nKey, string sKey) { // esecuzione script di install locale @@ -52,6 +53,7 @@ namespace MagMan.Data migrateTask.Wait(); return migrateTask.Result; } +#endif public static bool ExecMigrationMain() { @@ -59,7 +61,7 @@ namespace MagMan.Data var migrateTask = Task.Run(async () => await DbAdmin.migrateDbMain()); migrateTask.Wait(); return migrateTask.Result; - } + } public static void InitDb(string server, string nKey, string sKey) { diff --git a/MagMan.Data/MagMan.Data.csproj b/MagMan.Data/MagMan.Data.csproj index 829a67d..01e5b7e 100644 --- a/MagMan.Data/MagMan.Data.csproj +++ b/MagMan.Data/MagMan.Data.csproj @@ -7,8 +7,20 @@ + + + + + + + + + + + + diff --git a/MagMan.UI/Components/MigrationManager.razor b/MagMan.UI/Components/MigrationManager.razor index 9820a8b..512650a 100644 --- a/MagMan.UI/Components/MigrationManager.razor +++ b/MagMan.UI/Components/MigrationManager.razor @@ -44,7 +44,7 @@ return; reportProcess(); - await DbAdmin.migrateDbMain(); + await MagMan.Data.DbAdmin.migrateDbMain(); await ReloadData(); reportChange(); } @@ -55,7 +55,7 @@ return; reportProcess(); - await DbAdmin.migrateDbIdentity(); + await MagMan.User.DbAdmin.migrateDbIdentity(); await ReloadData(); reportChange(); } diff --git a/MagMan.UI/Health/Checks.cs b/MagMan.UI/Health/Checks.cs index 0cee711..4dfe5a1 100644 --- a/MagMan.UI/Health/Checks.cs +++ b/MagMan.UI/Health/Checks.cs @@ -4,8 +4,8 @@ using Microsoft.Extensions.Diagnostics.HealthChecks; using NLog; using Org.BouncyCastle.Pqc.Crypto.Lms; using System.Net.NetworkInformation; -using MagMan.Data; -using MagMan.Data.DbModels; +using MagMan.User; +using MagMan.User.DbModels; using Microsoft.EntityFrameworkCore; namespace MagMan.UI.Health @@ -25,7 +25,7 @@ namespace MagMan.UI.Health using (var appDb = new UserIdentityDbContext()) { string description = "Try check Table IdentityUsers"; - List recordList = new List(); + List recordList = new List(); var healthCheckData = new Dictionary(); try { diff --git a/MagMan.UI/MagMan.UI.csproj b/MagMan.UI/MagMan.UI.csproj index 3ab7211..7ce14f2 100644 --- a/MagMan.UI/MagMan.UI.csproj +++ b/MagMan.UI/MagMan.UI.csproj @@ -39,7 +39,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -51,6 +51,7 @@ + diff --git a/MagMan.UI/Program.cs b/MagMan.UI/Program.cs index 0f879ea..c6f9588 100644 --- a/MagMan.UI/Program.cs +++ b/MagMan.UI/Program.cs @@ -37,11 +37,12 @@ builder.Services.AddSingleton(redisMultiplexer); string dbServerAddr = builder.Configuration["DbConfig:Server"]; string nKey = builder.Configuration["DbConfig:nKey"]; string sKey = builder.Configuration["DbConfig:sKey"]; -DbConfig.InitDb(dbServerAddr, nKey, sKey); +MagMan.Data.DbConfig.InitDb(dbServerAddr, nKey, sKey); +MagMan.User.DbConfig.InitDb(dbServerAddr, nKey, sKey); // inizializzo il DB e creo (se necessario) l'utente -DbConfig.CheckUser(nKey, sKey); +MagMan.User.DbConfig.CheckUser(nKey, sKey); // verifico se serve applicazione migrazioni -DbConfig.ExecMigrationMain(); +MagMan.Data.DbConfig.ExecMigrationMain(); //DbConfig.ExecMigrationIdentity(); string connStringDB = DbConfig.CONNECTION_STRING; @@ -84,11 +85,11 @@ builder.Services.Configure(o => -builder.Services.AddDbContext(options => +builder.Services.AddDbContext(options => options.UseSqlServer(connectionString)); builder.Services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount = true) - .AddEntityFrameworkStores(); + .AddEntityFrameworkStores(); #if false diff --git a/MagMan.User/MagMan.User.csproj b/MagMan.User/MagMan.User.csproj index d953925..75c337f 100644 --- a/MagMan.User/MagMan.User.csproj +++ b/MagMan.User/MagMan.User.csproj @@ -8,15 +8,29 @@ - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + diff --git a/MagMan.User/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.Designer.cs b/MagMan.User/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.Designer.cs index 46864d8..5680f40 100644 --- a/MagMan.User/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.Designer.cs +++ b/MagMan.User/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.Designer.cs @@ -1,6 +1,6 @@ // using System; -using MagMan.Data; +using MagMan.User; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; #nullable disable -namespace MagMan.Data.Migrations.UserIdentityDb +namespace MagMan.User.Migrations.UserIdentityDb { [DbContext(typeof(UserIdentityDbContext))] [Migration("20231222165912_CreateIdentitySchema")] @@ -21,7 +21,7 @@ namespace MagMan.Data.Migrations.UserIdentityDb .HasAnnotation("ProductVersion", "6.0.25") .HasAnnotation("Relational:MaxIdentifierLength", 64); - modelBuilder.Entity("MagMan.Data.DbModels.TableCount", b => + modelBuilder.Entity("MagMan.User.DbModels.TableCount", b => { b.Property("Count") .HasColumnType("int"); diff --git a/MagMan.User/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.cs b/MagMan.User/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.cs index 1eb4f0a..22607f3 100644 --- a/MagMan.User/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.cs +++ b/MagMan.User/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.cs @@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Migrations; #nullable disable -namespace MagMan.Data.Migrations.UserIdentityDb +namespace MagMan.User.Migrations.UserIdentityDb { public partial class CreateIdentitySchema : Migration { diff --git a/MagMan.User/Migrations/UserIdentityDb/UserIdentityDbContextModelSnapshot.cs b/MagMan.User/Migrations/UserIdentityDb/UserIdentityDbContextModelSnapshot.cs index cc6e811..f753adb 100644 --- a/MagMan.User/Migrations/UserIdentityDb/UserIdentityDbContextModelSnapshot.cs +++ b/MagMan.User/Migrations/UserIdentityDb/UserIdentityDbContextModelSnapshot.cs @@ -1,13 +1,13 @@ // using System; -using MagMan.Data; +using MagMan.User; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; #nullable disable -namespace MagMan.Data.Migrations.UserIdentityDb +namespace MagMan.User.Migrations.UserIdentityDb { [DbContext(typeof(UserIdentityDbContext))] partial class UserIdentityDbContextModelSnapshot : ModelSnapshot @@ -19,7 +19,7 @@ namespace MagMan.Data.Migrations.UserIdentityDb .HasAnnotation("ProductVersion", "6.0.25") .HasAnnotation("Relational:MaxIdentifierLength", 64); - modelBuilder.Entity("MagMan.Data.DbModels.TableCount", b => + modelBuilder.Entity("MagMan.User.DbModels.TableCount", b => { b.Property("Count") .HasColumnType("int");