Completo riorganizzazione progetti:
- Core - Data.Admin
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Core.DTO
|
||||
{
|
||||
public class DemoObj
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -6,4 +6,10 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MailKit" Version="4.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
|
||||
<PackageReference Include="NLog" Version="5.2.7" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data
|
||||
namespace MagMan.Core
|
||||
{
|
||||
public class MailKitMailData
|
||||
{
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data
|
||||
namespace MagMan.Core
|
||||
{
|
||||
public class MailKitMailSettings
|
||||
{
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Services
|
||||
namespace MagMan.Core.Services
|
||||
{
|
||||
public interface IMailService
|
||||
{
|
||||
@@ -3,8 +3,13 @@ using MailKit.Security;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MimeKit;
|
||||
using NLog;
|
||||
using MagMan.Core;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Services
|
||||
namespace MagMan.Core.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementazione MailKit come descritto qui https://blog.christian-schou.dk/send-emails-with-asp-net-core-with-mailkit/
|
||||
@@ -1,8 +1,8 @@
|
||||
using MagMan.User.DbModels;
|
||||
using MagMan.Data.Admin.DbModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace MagMan.User
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
@@ -37,7 +37,7 @@ namespace MagMan.User
|
||||
/// <summary>
|
||||
/// User management
|
||||
/// </summary>
|
||||
public DbSet<UserPriv> UserList { get; set; }
|
||||
public virtual DbSet<UserPriv> UserList { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.User
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
public class DbAdmin : IDisposable
|
||||
{
|
||||
@@ -68,31 +68,6 @@ namespace MagMan.User
|
||||
return answ;
|
||||
}
|
||||
|
||||
#if false
|
||||
public static async Task<bool> migrateDbMain()
|
||||
{
|
||||
bool answ = false;
|
||||
using (MagManContext dbCtx = new MagManContext())
|
||||
{
|
||||
await dbCtx.Database.MigrateAsync();
|
||||
answ = true;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public static bool resetPlantLogTable()
|
||||
{
|
||||
bool answ = false;
|
||||
using (MagManContext dbCtx = new MagManContext())
|
||||
{
|
||||
string sqlCommand = "TRUNCATE TABLE PlantLog;";
|
||||
dbCtx.Database.ExecuteSqlRaw(sqlCommand);
|
||||
answ = true;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
#endif
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
@@ -5,16 +5,16 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.User
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
public static class DbConfig
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
public static string DATABASE_NAME = "MagMan";
|
||||
public static string DATABASE_NAME = "MagMan_Ident";
|
||||
|
||||
public static int DATABASE_PROCESS_TIMEOUT = 5;
|
||||
public static string DATABASE_PWD = "viadante16";
|
||||
public static string DATABASE_PWD = "viad@nte16!";
|
||||
|
||||
// Database config
|
||||
public static string DATABASE_SERV = "127.0.0.1";
|
||||
@@ -53,22 +53,15 @@ namespace MagMan.User
|
||||
return migrateTask.Result;
|
||||
}
|
||||
|
||||
#if false
|
||||
public static bool ExecMigrationMain()
|
||||
{
|
||||
// esecuzione migrazione
|
||||
var migrateTask = Task.Run(async () => await DbAdmin.migrateDbMain());
|
||||
migrateTask.Wait();
|
||||
return migrateTask.Result;
|
||||
}
|
||||
#endif
|
||||
|
||||
public static void InitDb(string server, string nKey, string sKey)
|
||||
{
|
||||
DATABASE_SERV = server;
|
||||
DATABASE_NAME = $"MagMan_{nKey}";
|
||||
// tutto fisso x gestione utenti
|
||||
#if false
|
||||
DATABASE_NAME = $"MagMan_Ident";
|
||||
DATABASE_USER = $"user_{nKey}";
|
||||
DATABASE_PWD = $"pwd_{sKey}";
|
||||
DATABASE_PWD = $"pwd_{sKey}";
|
||||
#endif
|
||||
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={DATABASE_USER};pwd={DATABASE_PWD};sslmode=None";
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.DbModels
|
||||
namespace MagMan.Data.Admin.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe fake x il conteggio tabelle e check preliminari
|
||||
@@ -15,8 +15,8 @@ namespace MagMan.Data.DbModels
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public int Count { get; set; }
|
||||
public string TableName { get; set; }
|
||||
public int Count { get; set; } = 0;
|
||||
public string TableName { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.DbModels
|
||||
namespace MagMan.Data.Admin.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Tabella dei USER di MySql
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
@@ -7,12 +7,17 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Services\" />
|
||||
<Folder Include="DTO\" />
|
||||
<ProjectReference Include="..\MagMan.Core\MagMan.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controllers\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.4.0" />
|
||||
<PackageReference Include="Blazored.SessionStorage" Version="2.4.0" />
|
||||
<PackageReference Include="MailKit" Version="4.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.25" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.25" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.25" />
|
||||
@@ -25,12 +30,10 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NLog" Version="5.2.7" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MagMan.Core\MagMan.Core.csproj" />
|
||||
<PackageReference Include="StackExchange.Redis" Version="2.7.10" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MagMan.User;
|
||||
using MagMan.Data.Admin;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
@@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.User.Migrations.UserIdentityDb
|
||||
namespace MagMan.Data.Admin.Migrations.UserIdentityDb
|
||||
{
|
||||
[DbContext(typeof(UserIdentityDbContext))]
|
||||
[Migration("20231222165912_CreateIdentitySchema")]
|
||||
@@ -21,7 +21,7 @@ namespace MagMan.User.Migrations.UserIdentityDb
|
||||
.HasAnnotation("ProductVersion", "6.0.25")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("MagMan.User.DbModels.TableCount", b =>
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.TableCount", b =>
|
||||
{
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
+1
-1
@@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.User.Migrations.UserIdentityDb
|
||||
namespace MagMan.Data.Admin.Migrations.UserIdentityDb
|
||||
{
|
||||
public partial class CreateIdentitySchema : Migration
|
||||
{
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MagMan.User;
|
||||
using MagMan.Data.Admin;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.User.Migrations.UserIdentityDb
|
||||
namespace MagMan.Data.Admin.Migrations.UserIdentityDb
|
||||
{
|
||||
[DbContext(typeof(UserIdentityDbContext))]
|
||||
partial class UserIdentityDbContextModelSnapshot : ModelSnapshot
|
||||
@@ -19,7 +19,7 @@ namespace MagMan.User.Migrations.UserIdentityDb
|
||||
.HasAnnotation("ProductVersion", "6.0.25")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("MagMan.User.DbModels.TableCount", b =>
|
||||
modelBuilder.Entity("MagMan.Data.Admin.DbModels.TableCount", b =>
|
||||
{
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Services
|
||||
namespace MagMan.Data.Admin.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe di partenza x costruzione servizi di accesso dati + cache
|
||||
@@ -7,7 +7,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.User
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
public class UserAdminConfiguration : IEntityTypeConfiguration<IdentityUser>
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace MagMan.User
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe generalizzaizone identity (user + roles + claims) x gestione semplificata in editing
|
||||
@@ -1,4 +1,4 @@
|
||||
using MagMan.User.DbModels;
|
||||
using MagMan.Data.Admin.DbModels;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
@@ -7,7 +7,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.User
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
public class UserIdentityDbContext : IdentityDbContext
|
||||
{
|
||||
@@ -24,13 +24,8 @@ namespace MagMan.User
|
||||
{ }
|
||||
}
|
||||
|
||||
public UserIdentityDbContext(DbContextOptions<UserIdentityDbContext> options)
|
||||
: base(options)
|
||||
public UserIdentityDbContext(DbContextOptions<UserIdentityDbContext> options) : base(options)
|
||||
{
|
||||
#if false
|
||||
// se non ci fosse... crea!
|
||||
Database.EnsureCreated();
|
||||
#endif
|
||||
try
|
||||
{
|
||||
// se non ci fosse... crea o migra!
|
||||
@@ -44,7 +39,7 @@ namespace MagMan.User
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public DbSet<TableCount> DbSetCounts { get; set; }
|
||||
public virtual DbSet<TableCount> DbSetCounts { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
public class UserRoleConfiguration : IEntityTypeConfiguration<IdentityRole>
|
||||
{
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data
|
||||
namespace MagMan.Data.Tenant
|
||||
{
|
||||
public class DbAdmin : IDisposable
|
||||
{
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data
|
||||
namespace MagMan.Data.Tenant
|
||||
{
|
||||
public static class DbConfig
|
||||
{
|
||||
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
namespace MagMan.Data.DbModels
|
||||
namespace MagMan.Data.Tenant.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Tabella Config
|
||||
@@ -6,7 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.DbModels
|
||||
namespace MagMan.Data.Tenant.DbModels
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
+1
-1
@@ -6,7 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.DbModels
|
||||
namespace MagMan.Data.Tenant.DbModels
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
@@ -6,7 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.DbModels
|
||||
namespace MagMan.Data.Tenant.DbModels
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
+1
-1
@@ -6,7 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.DbModels
|
||||
namespace MagMan.Data.Tenant.DbModels
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.User.DbModels
|
||||
namespace MagMan.Data.Tenant.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe fake x il conteggio tabelle e check preliminari
|
||||
+1
-1
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.User.DbModels
|
||||
namespace MagMan.Data.Tenant.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Tabella dei USER di MySql
|
||||
@@ -12,28 +12,10 @@
|
||||
<None Remove="Migrations\UserIdentityDb\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="AdminContext.cs" />
|
||||
<Compile Remove="DbModels\UserPrivModel.cs" />
|
||||
<Compile Remove="MailKitEmailSender.cs" />
|
||||
<Compile Remove="MailKitEmailSenderOptions.cs" />
|
||||
<Compile Remove="UserAdminConfiguration.cs" />
|
||||
<Compile Remove="UserData.cs" />
|
||||
<Compile Remove="UserIdentityDbContext.cs" />
|
||||
<Compile Remove="UserRoleConfiguration.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controllers\" />
|
||||
<Folder Include="DTO\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.4.0" />
|
||||
<PackageReference Include="Blazored.SessionStorage" Version="2.4.0" />
|
||||
<PackageReference Include="MailKit" Version="4.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.25" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.25" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.25" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.25">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
@@ -54,4 +36,9 @@
|
||||
<ProjectReference Include="..\MagMan.Core\MagMan.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controllers\" />
|
||||
<Folder Include="DTO\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,4 +1,4 @@
|
||||
using MagMan.Data.DbModels;
|
||||
using MagMan.Data.Tenant.DbModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NLog;
|
||||
@@ -9,7 +9,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data
|
||||
namespace MagMan.Data.Tenant
|
||||
{
|
||||
public partial class MagManContext : DbContext
|
||||
{
|
||||
+1
-1
@@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Migrations
|
||||
namespace MagMan.Data.Tenant.Migrations
|
||||
{
|
||||
[DbContext(typeof(MagManContext))]
|
||||
[Migration("20231222163946_InitDb")]
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Migrations
|
||||
namespace MagMan.Data.Tenant.Migrations
|
||||
{
|
||||
public partial class InitDb : Migration
|
||||
{
|
||||
+1
-1
@@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Migrations
|
||||
namespace MagMan.Data.Tenant.Migrations
|
||||
{
|
||||
[DbContext(typeof(MagManContext))]
|
||||
[Migration("20231222180319_AddMagBaseObj")]
|
||||
+1
-1
@@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Migrations
|
||||
namespace MagMan.Data.Tenant.Migrations
|
||||
{
|
||||
public partial class AddMagBaseObj : Migration
|
||||
{
|
||||
+1
-1
@@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Migrations
|
||||
namespace MagMan.Data.Tenant.Migrations
|
||||
{
|
||||
[DbContext(typeof(MagManContext))]
|
||||
[Migration("20231222180523_AddMagBaseObj01")]
|
||||
+1
-1
@@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Migrations
|
||||
namespace MagMan.Data.Tenant.Migrations
|
||||
{
|
||||
public partial class AddMagBaseObj01 : Migration
|
||||
{
|
||||
+1
-1
@@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Migrations
|
||||
namespace MagMan.Data.Tenant.Migrations
|
||||
{
|
||||
[DbContext(typeof(MagManContext))]
|
||||
partial class MagManContextModelSnapshot : ModelSnapshot
|
||||
+1
-1
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data
|
||||
namespace MagMan.Data.Tenant
|
||||
{
|
||||
public static class ModelBuilderExtensions
|
||||
{
|
||||
@@ -0,0 +1,70 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Tenant.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe di partenza x costruzione servizi di accesso dati + cache
|
||||
/// </summary>
|
||||
public class BaseServ
|
||||
{
|
||||
#region Protected Properties
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache breve (1 min circa + perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
protected TimeSpan FastCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlShort * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
protected TimeSpan LongCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache MOLTO breve (10 sec circa + perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
protected TimeSpan UltraFastCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlShort / 6 * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache MOLTO lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
protected TimeSpan UltraLongCache
|
||||
{
|
||||
get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000);
|
||||
}
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
|
||||
protected static IConfiguration _configuration = null!;
|
||||
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlLong = 60 * 5;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache breve IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlShort = 60 * 1;
|
||||
|
||||
private Random rnd = new Random();
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Services
|
||||
namespace MagMan.Data.Tenant.Services
|
||||
{
|
||||
public class MessageService
|
||||
{
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Services
|
||||
namespace MagMan.Data.Tenant.Services
|
||||
{
|
||||
public class SelectData
|
||||
{
|
||||
+1
-1
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Services
|
||||
namespace MagMan.Data.Tenant.Services
|
||||
{
|
||||
public class SelectOrderData : SelectData
|
||||
{
|
||||
@@ -1,75 +0,0 @@
|
||||
using MagMan.Data.DbModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
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<AdminContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// User management
|
||||
/// </summary>
|
||||
public DbSet<UserPriv> UserList { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
string connString = DbConfig.ADMIN_CONNECTION_STRING;
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
//connString = _configuration.GetConnectionString("MagMan.Data");
|
||||
connString = "Server=localhost;port=3306;database=mysql;user=root;pwd=Egalware_24068!;sslmode=None;";
|
||||
var serverVersion = ServerVersion.AutoDetect(connString);
|
||||
optionsBuilder.UseMySql(connString, serverVersion);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<UserPriv>().HasKey(c => new { c.Host, c.User });
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
|
||||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
using MimeKit.Text;
|
||||
using MimeKit;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MailKit.Net.Smtp;
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
|
||||
namespace MagMan.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementazione interfaccia email con pacchetto MailKIT
|
||||
///
|
||||
/// https://www.ryadel.com/en/asp-net-core-send-email-messages-smtp-mailkit/
|
||||
/// </summary>
|
||||
public class MailKitEmailSender : IEmailSender
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public MailKitEmailSender(IOptions<MailKitEmailSenderOptions> options)
|
||||
{
|
||||
this.Options = options.Value;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public MailKitEmailSenderOptions Options { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public Task Execute(string to, string subject, string message)
|
||||
{
|
||||
// create message
|
||||
var email = new MimeMessage();
|
||||
email.Sender = MailboxAddress.Parse(Options.Sender_EMail);
|
||||
if (!string.IsNullOrEmpty(Options.Sender_Name))
|
||||
email.Sender.Name = Options.Sender_Name;
|
||||
email.From.Add(email.Sender);
|
||||
email.To.Add(MailboxAddress.Parse(to));
|
||||
email.Subject = subject;
|
||||
email.Body = new TextPart(TextFormat.Html) { Text = message };
|
||||
|
||||
// send email
|
||||
using (var smtp = new SmtpClient())
|
||||
{
|
||||
smtp.Connect(Options.Host_Address, Options.Host_Port, Options.Host_SecureSocketOptions);
|
||||
smtp.Authenticate(Options.Host_Username, Options.Host_Password);
|
||||
smtp.Send(email);
|
||||
smtp.Disconnect(true);
|
||||
}
|
||||
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
public Task SendEmailAsync(string email, string subject, string message)
|
||||
{
|
||||
return Execute(email, subject, message);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using MailKit.Security;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data
|
||||
{
|
||||
public class MailKitEmailSenderOptions
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public MailKitEmailSenderOptions()
|
||||
{
|
||||
Host_SecureSocketOptions = SecureSocketOptions.Auto;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public string Host_Address { get; set; } = "";
|
||||
|
||||
public string Host_Password { get; set; } = "";
|
||||
public int Host_Port { get; set; } = 0;
|
||||
|
||||
public SecureSocketOptions Host_SecureSocketOptions { get; set; } = SecureSocketOptions.None;
|
||||
public string Host_Username { get; set; } = "";
|
||||
public string Sender_EMail { get; set; } = "";
|
||||
|
||||
public string Sender_Name { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
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;
|
||||
|
||||
namespace MagMan.Data
|
||||
{
|
||||
public class UserAdminConfiguration : IEntityTypeConfiguration<IdentityUser>
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
public void Configure(EntityTypeBuilder<IdentityUser> builder)
|
||||
{
|
||||
builder.HasData(
|
||||
new IdentityUser { UserName = "samuele@steamware.net", Email = "samuele@steamware.net", EmailConfirmed = true },
|
||||
new IdentityUser { UserName = "samuele.locatelli@egalware.com", Email = "samuele.locatelli@egalware.com", EmailConfirmed = true }
|
||||
);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe generalizzaizone identity (user + roles + claims) x gestione semplificata in editing
|
||||
/// </summary>
|
||||
public class UserData
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public List<System.Security.Claims.Claim> Claims { get; set; } = new List<System.Security.Claims.Claim>();
|
||||
|
||||
public IdentityUser Identity { get; set; } = new IdentityUser();
|
||||
|
||||
public List<string> Roles { get; set; } = new List<string>();
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MagMan.Data.DbModels;
|
||||
|
||||
namespace MagMan.Data
|
||||
{
|
||||
public class UserIdentityDbContext : IdentityDbContext
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public UserIdentityDbContext()
|
||||
{
|
||||
try
|
||||
{
|
||||
// se non ci fosse... crea o migra!
|
||||
Database.Migrate();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{ }
|
||||
}
|
||||
|
||||
public UserIdentityDbContext(DbContextOptions<UserIdentityDbContext> options)
|
||||
: base(options)
|
||||
{
|
||||
#if false
|
||||
// se non ci fosse... crea!
|
||||
Database.EnsureCreated();
|
||||
#endif
|
||||
try
|
||||
{
|
||||
// se non ci fosse... crea o migra!
|
||||
Database.Migrate();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{ }
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public DbSet<TableCount> DbSetCounts { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
string connString = DbConfig.CONNECTION_STRING;
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
var serverVersion = ServerVersion.AutoDetect(connString);
|
||||
optionsBuilder.UseMySql(connString, serverVersion);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
// aggiunta ruoli
|
||||
builder.ApplyConfiguration(new UserRoleConfiguration());
|
||||
// aggiunta user admin base
|
||||
builder.ApplyConfiguration(new UserAdminConfiguration());
|
||||
|
||||
// Todo: aggiungere configurazione claims oltre ai roles...
|
||||
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -7,9 +7,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagMan.UI", "MagMan.UI\MagM
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagMan.Core", "MagMan.Core\MagMan.Core.csproj", "{328950E0-CCFB-40EF-AC68-A26912135588}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagMan.Data", "MagMan.Data\MagMan.Data.csproj", "{4F26EF07-74E7-4A8F-B24B-19AACDD718B3}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagMan.Data.Tenant", "MagMan.Data.Tenant\MagMan.Data.Tenant.csproj", "{69E22B67-FFA7-4E21-81A7-B8F025A420C5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagMan.User", "MagMan.User\MagMan.User.csproj", "{E63054F2-C7EE-4996-B764-B9DA6033F754}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagMan.Data.Admin", "MagMan.Data.Admin\MagMan.Data.Admin.csproj", "{324914D5-2616-42D8-82EF-5420148DC9E1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -25,14 +25,14 @@ Global
|
||||
{328950E0-CCFB-40EF-AC68-A26912135588}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{328950E0-CCFB-40EF-AC68-A26912135588}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{328950E0-CCFB-40EF-AC68-A26912135588}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4F26EF07-74E7-4A8F-B24B-19AACDD718B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4F26EF07-74E7-4A8F-B24B-19AACDD718B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4F26EF07-74E7-4A8F-B24B-19AACDD718B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4F26EF07-74E7-4A8F-B24B-19AACDD718B3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E63054F2-C7EE-4996-B764-B9DA6033F754}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E63054F2-C7EE-4996-B764-B9DA6033F754}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E63054F2-C7EE-4996-B764-B9DA6033F754}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E63054F2-C7EE-4996-B764-B9DA6033F754}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{69E22B67-FFA7-4E21-81A7-B8F025A420C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{69E22B67-FFA7-4E21-81A7-B8F025A420C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{69E22B67-FFA7-4E21-81A7-B8F025A420C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{69E22B67-FFA7-4E21-81A7-B8F025A420C5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{324914D5-2616-42D8-82EF-5420148DC9E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{324914D5-2616-42D8-82EF-5420148DC9E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{324914D5-2616-42D8-82EF-5420148DC9E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{324914D5-2616-42D8-82EF-5420148DC9E1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
return;
|
||||
|
||||
reportProcess();
|
||||
await MagMan.Data.DbAdmin.migrateDbMain();
|
||||
await MagMan.Data.Tenant.DbAdmin.migrateDbMain();
|
||||
await ReloadData();
|
||||
reportChange();
|
||||
}
|
||||
@@ -55,7 +55,7 @@
|
||||
return;
|
||||
|
||||
reportProcess();
|
||||
await MagMan.User.DbAdmin.migrateDbIdentity();
|
||||
await MagMan.Data.Admin.DbAdmin.migrateDbIdentity();
|
||||
await ReloadData();
|
||||
reportChange();
|
||||
}
|
||||
@@ -71,7 +71,7 @@
|
||||
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
var resultIden = await Health.Checks.DbIdentity(DbConfig.DATABASE_NAME);
|
||||
var resultIden = await Health.Checks.DbIdentity(MagMan.Data.Admin.DbConfig.DATABASE_NAME);
|
||||
DbIdentity = (resultIden.Status == Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy);
|
||||
DbAllOk = (DbIdentity);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
using MagMan.Data.Services;
|
||||
|
||||
using MagMan.Data.Tenant.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace MagMan.UI.Components
|
||||
|
||||
@@ -87,10 +87,10 @@
|
||||
}
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
var resultLog = await Health.Checks.DbPlantTable(DbConfig.DATABASE_NAME);
|
||||
var resultIden = await Health.Checks.DbIdentity(DbConfig.DATABASE_NAME);
|
||||
DbLogOk = (resultLog.Status == HealthStatus.Healthy);
|
||||
var resultIden = await Health.Checks.DbIdentity(MagMan.Data.Admin.DbConfig.DATABASE_NAME);
|
||||
var resultLog = await Health.Checks.DbPlantTable(MagMan.Data.Tenant.DbConfig.DATABASE_NAME);
|
||||
DbIdentity = (resultIden.Status == HealthStatus.Healthy);
|
||||
DbLogOk = (resultLog.Status == HealthStatus.Healthy);
|
||||
DbAllOk = (DbLogOk && DbIdentity);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using MagMan.Data.DbModels;
|
||||
using MagMan.Data.Tenant.DbModels;
|
||||
using MagMan.Data;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using NLog;
|
||||
using Org.BouncyCastle.Pqc.Crypto.Lms;
|
||||
using System.Net.NetworkInformation;
|
||||
using MagMan.User;
|
||||
using MagMan.User.DbModels;
|
||||
using MagMan.Data.Admin;
|
||||
using MagMan.Data.Admin.DbModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MagMan.Data.Tenant;
|
||||
|
||||
namespace MagMan.UI.Health
|
||||
{
|
||||
@@ -25,7 +26,7 @@ namespace MagMan.UI.Health
|
||||
using (var appDb = new UserIdentityDbContext())
|
||||
{
|
||||
string description = "Try check Table IdentityUsers";
|
||||
List<User.DbModels.TableCount> recordList = new List<User.DbModels.TableCount>();
|
||||
List<MagMan.Data.Admin.DbModels.TableCount> recordList = new List<MagMan.Data.Admin.DbModels.TableCount>();
|
||||
var healthCheckData = new Dictionary<string, object>();
|
||||
try
|
||||
{
|
||||
@@ -85,7 +86,7 @@ namespace MagMan.UI.Health
|
||||
using (var adminDb = new AdminContext())
|
||||
{
|
||||
string description = "Try check MySql User table";
|
||||
List<UserPriv> userList = new List<UserPriv>();
|
||||
List<MagMan.Data.Admin.DbModels.UserPriv> userList = new List<MagMan.Data.Admin.DbModels.UserPriv>();
|
||||
var healthCheckData = new Dictionary<string, object>();
|
||||
try
|
||||
{
|
||||
|
||||
@@ -44,14 +44,15 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.16" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NLog" Version="5.2.7" />
|
||||
<PackageReference Include="StackExchange.Redis" Version="2.7.10" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MagMan.Core\MagMan.Core.csproj" />
|
||||
<ProjectReference Include="..\MagMan.Data\MagMan.Data.csproj" />
|
||||
<ProjectReference Include="..\MagMan.User\MagMan.User.csproj" />
|
||||
<ProjectReference Include="..\MagMan.Data.Admin\MagMan.Data.Admin.csproj" />
|
||||
<ProjectReference Include="..\MagMan.Data.Tenant\MagMan.Data.Tenant.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using MagMan.Data.Services;
|
||||
using MagMan.Data.Tenant.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System;
|
||||
|
||||
|
||||
+29
-24
@@ -1,22 +1,23 @@
|
||||
using MagMan.UI.Data;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MagMan.Data;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using System.Globalization;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using StackExchange.Redis;
|
||||
using MagMan.Data.Services;
|
||||
using HealthChecks.UI.Client;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
using Blazored.LocalStorage;
|
||||
using Blazored.SessionStorage;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using System.Configuration;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using HealthChecks.UI.Client;
|
||||
using MagMan.Core;
|
||||
using MagMan.Core.Services;
|
||||
using MagMan.Data;
|
||||
using MagMan.Data.Admin;
|
||||
using MagMan.Data.Tenant;
|
||||
using MagMan.Data.Tenant.Services;
|
||||
using MagMan.UI.Areas.Identity;
|
||||
using MagMan.UI.Data;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using StackExchange.Redis;
|
||||
using System.Globalization;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -37,14 +38,18 @@ builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
|
||||
string dbServerAddr = builder.Configuration["DbConfig:Server"];
|
||||
string nKey = builder.Configuration["DbConfig:nKey"];
|
||||
string sKey = builder.Configuration["DbConfig:sKey"];
|
||||
MagMan.Data.DbConfig.InitDb(dbServerAddr, nKey, sKey);
|
||||
MagMan.User.DbConfig.InitDb(dbServerAddr, nKey, sKey);
|
||||
MagMan.Data.Admin.DbConfig.InitDb(dbServerAddr, nKey, sKey);
|
||||
MagMan.Data.Tenant.DbConfig.InitDb(dbServerAddr, nKey, sKey);
|
||||
// inizializzo il DB e creo (se necessario) l'utente
|
||||
MagMan.User.DbConfig.CheckUser(nKey, sKey);
|
||||
MagMan.Data.Admin.DbConfig.CheckUser(nKey, sKey);
|
||||
|
||||
// spostare e fare in caso nelle chiamate custom
|
||||
#if true
|
||||
// verifico se serve applicazione migrazioni
|
||||
MagMan.Data.DbConfig.ExecMigrationMain();
|
||||
MagMan.Data.Tenant.DbConfig.ExecMigrationMain();
|
||||
#endif
|
||||
//DbConfig.ExecMigrationIdentity();
|
||||
string connStringDB = DbConfig.CONNECTION_STRING;
|
||||
string connStringDB = MagMan.Data.Admin.DbConfig.CONNECTION_STRING;
|
||||
|
||||
// healthchecks
|
||||
builder.Services.AddHealthChecks()
|
||||
@@ -85,11 +90,11 @@ builder.Services.Configure<DataProtectionTokenProviderOptions>(o =>
|
||||
|
||||
|
||||
|
||||
builder.Services.AddDbContext<MagMan.User.UserIdentityDbContext>(options =>
|
||||
builder.Services.AddDbContext<MagMan.Data.Admin.UserIdentityDbContext>(options =>
|
||||
options.UseSqlServer(connectionString));
|
||||
|
||||
builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
|
||||
.AddEntityFrameworkStores<MagMan.User.UserIdentityDbContext>();
|
||||
.AddEntityFrameworkStores<MagMan.Data.Admin.UserIdentityDbContext>();
|
||||
|
||||
#if false
|
||||
|
||||
@@ -123,7 +128,7 @@ builder.Services.AddBlazoredLocalStorage();
|
||||
builder.Services.AddBlazoredSessionStorage();
|
||||
|
||||
// gestione email
|
||||
builder.Services.Configure<MailKitMailSettings>(builder.Configuration.GetSection(nameof(MailKitMailSettings)));
|
||||
builder.Services.Configure<MagMan.Core.MailKitMailSettings>(builder.Configuration.GetSection(nameof(MailKitMailSettings)));
|
||||
builder.Services.AddScoped<MailService>();
|
||||
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
|
||||
@@ -7,11 +7,14 @@
|
||||
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
||||
@using Microsoft.JSInterop
|
||||
@using MagMan.Core
|
||||
@using MagMan.Core.DTO
|
||||
@using MagMan.Data
|
||||
@using MagMan.Data.DbModels
|
||||
@using MagMan.Data.Services
|
||||
@* @using MagMan.Data.DTO *@
|
||||
@using MagMan.Data.Services
|
||||
@using MagMan.Data.Admin
|
||||
@using MagMan.Data.Admin.DbModels
|
||||
@using MagMan.Data.Admin.Services
|
||||
@using MagMan.Data.Tenant
|
||||
@using MagMan.Data.Tenant.DbModels
|
||||
@using MagMan.Data.Tenant.Services
|
||||
@using MagMan.UI
|
||||
@using MagMan.UI.Shared
|
||||
@using MagMan.UI.Components
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
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;
|
||||
|
||||
namespace MagMan.User
|
||||
{
|
||||
public class UserRoleConfiguration : IEntityTypeConfiguration<IdentityRole>
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
public void Configure(EntityTypeBuilder<IdentityRole> builder)
|
||||
{
|
||||
builder.HasData(
|
||||
new IdentityRole { Name = "Undef", NormalizedName = "UNDEF" },
|
||||
//new IdentityRole { Name = "ExtUser", NormalizedName = "EXTUSER" },
|
||||
//new IdentityRole { Name = "ExtTransp", NormalizedName = "EXTTRANSP" },
|
||||
new IdentityRole { Name = "User", NormalizedName = "USER" },
|
||||
new IdentityRole { Name = "Admin", NormalizedName = "ADMIN" },
|
||||
new IdentityRole { Name = "SuperAdmin", NormalizedName = "SUPERADMIN" }
|
||||
);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,45 @@ Il sofware è previsto in modalità **multi-tenant**, dove verrà generato un DB
|
||||
|
||||
Di base il sistema deve prevedere il riconoscimento degli utenti e/o dei software EgalWare licenziati e reindirizzare l'impiego delle funzionalità avanzate verso il DB dedicato al cliente.
|
||||
|
||||
## Architettura
|
||||
|
||||
Il progetto è pensato in architettura **multi-tenant** per la versione **online**, ovvero un unico indirizzo web (tramite load balancers x reverse proxy) che fornisce l'applicazione a tutti i clienti.
|
||||
|
||||
Ogni cliente, facendo login, verrà riconosciuto e gli verrà fornita la partizione dati/DB di competenza del tenant secondo lo schema seguente:
|
||||
|
||||
### Workflow
|
||||
|
||||
Di seguito lo schema di funzionamento
|
||||
```mermaid
|
||||
flowchart TB
|
||||
user(User Login\n web browser) --> ServerApp
|
||||
egtbw(EgtB&W sw\n REST call) --> ServerApp
|
||||
|
||||
ServerApp{{magman.egalware.com}} --> multiTenant(Admin DB)
|
||||
ServerApp --> clientData(Tenant DB Data)
|
||||
|
||||
multiTenant--> tenantMgmt(Clienti)
|
||||
multiTenant--> MachMgmt(Macchine)
|
||||
multiTenant--> KeyMgmt(Chiavi)
|
||||
multiTenant--> UserMgmt(Utenti)
|
||||
|
||||
clientData --> MagData(Dati Magazzino)
|
||||
clientData --> MachineData(Stato Impianto)
|
||||
clientData --> LogData(Log Impianto)
|
||||
clientData --> CommData(Stato Commesse)
|
||||
|
||||
|
||||
style ServerApp fill:#223999
|
||||
style multiTenant fill:#921111
|
||||
style clientData fill:#226919
|
||||
|
||||
|
||||
```
|
||||
|
||||
In pratica le chiamate vengono inviate tutte al servizio web e da qui smistate per competenza e funzionalità verso i vari DB.
|
||||
|
||||
A livello architetturale il progetto è separato tra la parte **Data.Admin** e **Data.Tenant**.
|
||||
|
||||
## Oggetti di base
|
||||
|
||||
Gli oggetti di abse sono i seguenti:
|
||||
@@ -88,4 +127,6 @@ Ogni nuovo user dovrà poi essere associato al bucket del cliente tramite un cod
|
||||
|
||||
Version | Date | Editor | Note
|
||||
:--: |----------|----- | ----:
|
||||
0.3 | 2024.01.10 | S.E. Locatelli | Revisione modalità multi-tenant
|
||||
0.2 | 2024.01.05 | S.E. Locatelli | update ruoli e workflow
|
||||
0.1 | 2023.12.28 | S.E. Locatelli | Prima revisione documento
|
||||
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user