From 4e50f4332e5e3733fa44dd47ad8b9d337fefb0f7 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 17 Jan 2024 15:17:32 +0100 Subject: [PATCH] Completato fix gestione inventario magazzino --- MagMan.Core/MagMan.Core.csproj | 3 + MagMan.Core/Services/MessageService.cs | 610 ++++++++++++++++++ MagMan.Data.Admin/Services/MTAdminService.cs | 152 +++-- .../Controllers/TenantController.cs | 69 +- MagMan.Data.Tenant/MagMan.Data.Tenant.csproj | 4 + ...222165912_CreateIdentitySchema.Designer.cs | 311 --------- .../20231222165912_CreateIdentitySchema.cs | 286 -------- .../UserIdentityDbContextModelSnapshot.cs | 309 --------- MagMan.Data.Tenant/Services/MessageService.cs | 1 - MagMan.Data.Tenant/Services/TenantService.cs | 165 +++-- MagMan.UI/Components/CmpTop.razor | 8 +- MagMan.UI/Components/CmpTop.razor.cs | 35 +- MagMan.UI/Components/CustomerEdit.razor | 12 +- ...msController.cs => InventoryController.cs} | 48 +- MagMan.UI/Controllers/MaterialsController.cs | 29 +- MagMan.UI/MagMan.UI.csproj | 2 +- MagMan.UI/Pages/AdminArea.razor.cs | 5 +- MagMan.UI/Pages/Index.razor.cs | 3 +- MagMan.UI/Pages/ResetCache.razor.cs | 7 +- MagMan.UI/Pages/WareHouse.razor.cs | 5 +- MagMan.UI/Shared/MainLayout.razor | 48 -- MagMan.UI/Shared/MainLayout.razor.cs | 68 ++ MagMan.UI/_Imports.razor | 1 + Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 26 files changed, 1018 insertions(+), 1169 deletions(-) create mode 100644 MagMan.Core/Services/MessageService.cs delete mode 100644 MagMan.Data.Tenant/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.Designer.cs delete mode 100644 MagMan.Data.Tenant/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.cs delete mode 100644 MagMan.Data.Tenant/Migrations/UserIdentityDb/UserIdentityDbContextModelSnapshot.cs rename MagMan.UI/Controllers/{ItemsController.cs => InventoryController.cs} (69%) create mode 100644 MagMan.UI/Shared/MainLayout.razor.cs diff --git a/MagMan.Core/MagMan.Core.csproj b/MagMan.Core/MagMan.Core.csproj index df2e60e..3636131 100644 --- a/MagMan.Core/MagMan.Core.csproj +++ b/MagMan.Core/MagMan.Core.csproj @@ -7,9 +7,12 @@ + + + diff --git a/MagMan.Core/Services/MessageService.cs b/MagMan.Core/Services/MessageService.cs new file mode 100644 index 0000000..f7278a0 --- /dev/null +++ b/MagMan.Core/Services/MessageService.cs @@ -0,0 +1,610 @@ +using Blazored.LocalStorage; +using Blazored.SessionStorage; +using NLog; +using StackExchange.Redis; +using System.Diagnostics; + +namespace MagMan.Core.Services +{ + public class MessageService + { + #region Public Constructors + + public MessageService(ILocalStorageService genLocalStorage, ISessionStorageService sessStore, IConnectionMultiplexer RedConn) + { + // gestione sessioni in browser + localStore = genLocalStorage; + sessionStore = sessStore; + // setup componenti REDIS + redisConn = RedConn; + redisDb = redisConn.GetDatabase(); + } + + #endregion Public Constructors + + #region Public Events + + public event Action EA_FilterUpdated = null!; + + public event Action EA_HideSearch = null!; + + public event Action EA_PageUpdated = null!; + + public event Action EA_SearchUpdated = null!; + + public event Action EA_ShowSearch = null!; + + #endregion Public Events + +#if false + public SelectData DetailFilter + { + get => _detailFilter; + set + { + if (_detailFilter != value) + { + _detailFilter = value; + + if (EA_FilterUpdated != null) + { + EA_FilterUpdated?.Invoke(); + } + } + } + } + + public SelectOrderData Order_Filter { get; set; } = SelectOrderData.Init(5, 30); +#endif + + #region Public Properties + + public string PageIcon + { + get => _pageIcon; + set + { + if (_pageIcon != value) + { + _pageIcon = value; + ReportPageUpd(); + } + } + } + + public string PageName + { + get => _pageName; + set + { + if (_pageName != value) + { + _pageName = value; + ReportPageUpd(); + } + } + } + + public string SearchVal + { + get => _searchVal; + set + { + if (_searchVal != value) + { + _searchVal = value; + + if (EA_SearchUpdated != null) + { + EA_SearchUpdated?.Invoke(); + } + } + } + } + + public string SelOrderCode { get; set; } = ""; + public string SelPlantId { get; set; } = "0"; + + public bool ShowSearch + { + get => _showSearch; + set + { + if (_showSearch != value) + { + _showSearch = value; + if (_showSearch) + { + if (EA_ShowSearch != null) + { + EA_ShowSearch?.Invoke(); + } + } + else + { + if (EA_HideSearch != null) + { + EA_HideSearch?.Invoke(); + } + } + } + } + } + + #endregion Public Properties + + #region Public Methods + + /// + /// Recupera CustomerID dal dizionario dei token noti o cercando sul DB + /// + /// + /// + public async Task CustomerIdByToken(string RestToken) + { + string currKey = $"{Const.rKeyConfig}:Dict:Token2CustID"; + int answ = await RedisHashGetInt(currKey, RestToken); + return answ; + } + + /// + /// salvataggio in dizionario Redis associativo Token / Customer + /// + /// + /// + /// + public bool CustomerIdByTokenSet(string RestToken, int CustId) + { + string currKey = $"{Const.rKeyConfig}:Dict:Token2CustID"; + bool fatto = RedisHashSet(currKey, RestToken, $"{CustId}"); + return fatto; + } + + /// + /// Recupera CustomerID dal dizionario dei token noti o cercando sul DB + /// + /// + /// + public async Task MainKeyByCustomer(int CustID) + { + string currKey = $"{Const.rKeyConfig}:Dict:Cust2MKey"; + int answ = await RedisHashGetInt(currKey, $"{CustID}"); + return answ; + } + + /// + /// salvataggio in dizionario Redis associativo Token / Customer + /// + /// + /// + /// + public bool MainKeyByCustomerSet(int CustId, int MainKey) + { + string currKey = $"{Const.rKeyConfig}:Dict:Cust2MKey"; + bool fatto = RedisHashSet(currKey, $"{CustId}", $"{MainKey}"); + return fatto; + } + + /// + /// Recupera MainKey dal dizionario dei token noti o cercando sul DB + /// + /// + /// + public async Task MainKeyByToken(string RestToken) + { + string currKey = $"{Const.rKeyConfig}:Dict:Token2MKey"; + int answ = await RedisHashGetInt(currKey, RestToken); + return answ; + } + + /// + /// salvataggio in dizionario Redis associativo Token / Customer + /// + /// + /// + /// + public bool MainKeyByTokenSet(string RestToken, int CustId) + { + string currKey = $"{Const.rKeyConfig}:Dict:Token2MKey"; + bool fatto = RedisHashSet(currKey, RestToken, $"{CustId}"); + return fatto; + } + + /// + /// Get single hash record + /// + /// Redis Key for Hashlist + /// Requested key on list + /// Value as Int + public async Task RedisHashGetInt(RedisKey currKey, string chiave) + { + int result = 0; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + var hasVal = await redisDb.HashExistsAsync(currKey, chiave); + if (hasVal) + { + var rawRes = await redisDb.HashGetAsync(currKey, chiave); + if (rawRes.HasValue) + { + int.TryParse($"{rawRes}", out result); + } + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"RedisHashGetInt | {currKey} | in: {ts.TotalMilliseconds} ms"); + return result; + } + + /// + /// Get single hash record + /// + /// Redis Key for Hashlist + /// Requested key on list + /// Value as string + public async Task RedisHashGetString(RedisKey currKey, string chiave) + { + string result = ""; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + var hasVal = await redisDb.HashExistsAsync(currKey, chiave); + if (hasVal) + { + var rawRes = await redisDb.HashGetAsync(currKey, chiave); + if (rawRes.HasValue) + { + result = $"{rawRes}"; + } + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"RedisHashGetString | {currKey} | in: {ts.TotalMilliseconds} ms"); + return result; + } + + /// + /// Remove for single hash record + /// + /// Chiave redis della Hashlist + /// Chiave nella HashList + /// Esito rimozione + public async Task RedisHashRemove(RedisKey currKey, string chiave) + { + bool fatto = false; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + fatto = await redisDb.HashDeleteAsync(currKey, chiave); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"RedisHashRemove | {currKey} | in: {ts.TotalMilliseconds} ms"); + return fatto; + } + + /// + /// Resetta 1:1 i dizionari Hash in Redis + /// + /// + public bool ResetHashDict() + { + bool fatto = false; + string baseKey = $"{Const.rKeyConfig}:Dict"; + try + { + // salvo! + RedisHashDictSet($"{baseKey}:Token2CustID", new Dictionary()); + RedisHashDictSet($"{baseKey}:Token2MKey", new Dictionary()); + RedisHashDictSet($"{baseKey}:Cust2MKey", new Dictionary()); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in ResetHashDict{Environment.NewLine}{exc}"); + } + return fatto; + } + + /// + /// Svuota localstorage (clear) + /// + /// + public async Task StoreLocalClear() + { + bool answ = false; + try + { + await localStore.ClearAsync(); + answ = true; + } + catch (Exception ex) + { + Log.Error($"Eccezione in StoreLocalClear{Environment.NewLine}{ex}"); + } + return answ; + } + + /// + /// Restituisce il valore richiesto da localstorage + /// + /// Chiave + /// + public async Task StoreLocalGet(string sKey) + { + string answ = ""; + var result = await localStore.GetItemAsync(sKey); + if (result != null) + { + answ = result; + } + return answ; + } + + /// + /// Scrive il valore nel localstorage + /// + /// Chiave + /// Valore associato + /// + public async Task StoreLocalSet(string sKey, string sVal) + { + bool answ = false; + try + { + await localStore.SetItemAsStringAsync(sKey, sVal); + answ = true; + } + catch (Exception ex) + { + Log.Error($"Eccezione in StoreLocalSet{Environment.NewLine}{ex}"); + } + return answ; + } + + /// + /// Svuota sessionstorage (clear) + /// + /// + public async Task StoreSessClear() + { + bool answ = false; + try + { + await sessionStore.ClearAsync(); + answ = true; + } + catch (Exception ex) + { + Log.Error($"Eccezione in StoreLocalClear{Environment.NewLine}{ex}"); + } + return answ; + } + + /// + /// Restituisce il valore richiesto da sessionstorage + /// + /// Chiave + /// + public async Task StoreSessGet(string sKey) + { + string answ = ""; + var result = await sessionStore.GetItemAsync(sKey); + if (result != null) + { + answ = result; + } + return answ; + } + + /// + /// Scrive il valore nel sessionstorage (tab) + /// + /// Chiave + /// Valore associato + /// + public async Task StoreSessSet(string sKey, string sVal) + { + bool answ = false; + try + { + await sessionStore.SetItemAsStringAsync(sKey, sVal); + answ = true; + } + catch (Exception ex) + { + Log.Error($"Eccezione in StoreSessSet{Environment.NewLine}{ex}"); + } + return answ; + } + + #endregion Public Methods + + #region Protected Fields + + /// + /// Oggetto per connessione a REDIS + /// + protected IConnectionMultiplexer redisConn = null!; + + /// + /// Oggetto DB redis da impiegare x chiamate R/W + /// + protected IDatabase redisDb = null!; + + #endregion Protected Fields + + #region Protected Properties + + protected ILocalStorageService localStore { get; set; } = null!; + protected ISessionStorageService sessionStore { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + /// + /// Effettua upsert in HasList redis + /// + /// Chiave redis della Hashlist + /// Chiave nella HashList + /// Valore da salvare + /// Num record nella HashList + protected async Task RedisHashUpsert(RedisKey currKey, string chiave, string valore) + { + long numReq = 0; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + await redisDb.HashSetAsync(currKey, chiave, valore); + numReq = await redisDb.HashLengthAsync(currKey); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"RedisHashUpsert | {currKey} | in: {ts.TotalMilliseconds} ms"); + return numReq; + } + + #endregion Protected Methods + +#if false + private SelectData _detailFilter = SelectData.Init(5, 15); +#endif + + #region Private Fields + + private string _pageIcon = ""; + private string _pageName = ""; + private string _searchVal = ""; + private bool _showSearch = false; + private Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields + + #region Private Methods + + /// + /// Recupero HashSet redis come Dictionary + /// + /// + /// + private Dictionary RedisHashDictGet(RedisKey currKey) + { + Dictionary answ = new Dictionary(); + try + { + answ = redisDb + .HashGetAll(currKey) + .ToDictionary(x => $"{x.Name}", x => $"{x.Value}"); + } + catch (Exception exc) + { + Log.Info($"Errore RedisHashDictGet | currKey: {currKey}{Environment.NewLine}{exc}"); + } + return answ; + } + + /// + /// Salvataggio Dictionary come HashSet Redis + /// + /// + /// + private bool RedisHashDictSet(RedisKey currKey, Dictionary dict) + { + bool fatto = false; + try + { + HashEntry[] data2ins = new HashEntry[dict.Count]; + int i = 0; + foreach (KeyValuePair kvp in dict) + { + data2ins[i] = new HashEntry(kvp.Key, kvp.Value); + i++; + } + // salvo! + redisDb.HashSet(currKey, data2ins); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in RedisHashDictSet | currKey: {currKey}{Environment.NewLine}{exc}"); + } + return fatto; + } + + /// + /// Salvataggio Dictionary come HashSet Redis + /// + /// + /// + /// + private bool RedisHashDictSet(RedisKey currKey, Dictionary dict, TimeSpan ttl) + { + bool fatto = false; + try + { + HashEntry[] data2ins = new HashEntry[dict.Count]; + int i = 0; + foreach (KeyValuePair kvp in dict) + { + data2ins[i] = new HashEntry(kvp.Key, kvp.Value); + i++; + } + // salvo! + redisDb.HashSet(currKey, data2ins); + redisDb.KeyExpire(currKey, ttl); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in RedisHashDictSet(+TTL) | currKey: {currKey} | ttl: {ttl}{Environment.NewLine}{exc}"); + } + return fatto; + } + + /// + /// Aggiunta KVP in HashSet Redis + /// + /// + /// + private bool RedisHashSet(RedisKey currKey, string hashField, string value) + { + bool fatto = false; + try + { + // salvo! + redisDb.HashSet(currKey, hashField, value); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in RedisHashSet | currKey: {currKey}{Environment.NewLine}{exc}"); + } + return fatto; + } + + private void ReportPageUpd() + { + if (EA_PageUpdated != null) + { + EA_PageUpdated?.Invoke(); + } + } + + private void ReportSearch() + { + if (EA_SearchUpdated != null) + { + EA_SearchUpdated?.Invoke(); + } + } + + #endregion Private Methods + +#if false + /// + /// Dizionario totale preferenze utente + /// + public Dictionary UsersPrefDict + { + get => RedisHashDictGet((RedisKey)$"{redisBaseKey}:{MatrOpr}"); + set => RedisHashDictSet((RedisKey)$"{redisBaseKey}:{MatrOpr}", value); + } +#endif + } +} \ No newline at end of file diff --git a/MagMan.Data.Admin/Services/MTAdminService.cs b/MagMan.Data.Admin/Services/MTAdminService.cs index dc73740..70eac3e 100644 --- a/MagMan.Data.Admin/Services/MTAdminService.cs +++ b/MagMan.Data.Admin/Services/MTAdminService.cs @@ -1,4 +1,5 @@ using MagMan.Core; +using MagMan.Core.Services; using MagMan.Data.Admin.Controllers; using MagMan.Data.Admin.DbModels; using Microsoft.AspNetCore.Identity.UI.Services; @@ -14,12 +15,6 @@ namespace MagMan.Data.Admin.Services { public class MTAdminService : BaseServ { - #region Public Fields - - public static MTAdminController dbController = null!; - - #endregion Public Fields - #region Public Constructors public MTAdminService(IConfiguration configuration, IConnectionMultiplexer redisConnMult, IEmailSender emailSender) @@ -238,6 +233,34 @@ namespace MagMan.Data.Admin.Services return dbResult; } + /// + /// Recupera CustomerID dal dizionario dei token noti o cercando sul DB + /// + /// + /// + public async Task CustomerIdByToken(string RestToken) + { + int answ = -1; + if (TokenCustList.ContainsKey(RestToken)) + { + answ = TokenCustList[RestToken]; + } + else + { + // cerco nel DB + var custList = await CustomerGetAll(); + var custRow = custList.FirstOrDefault(x => x.RestToken == RestToken); + // se trovato salvo + if (custRow != null) + { + answ = custRow.CustomerID; + TokenCustList.Add(RestToken, answ); + Log.Info($"TokenCustList: added {RestToken} --> {answ}"); + } + } + return answ; + } + /// /// Update record customer + refresh cache /// @@ -395,64 +418,6 @@ namespace MagMan.Data.Admin.Services return fatto; } - #endregion Public Methods - - #region Protected Methods - - /// - /// Recupera CustomerID dal dizionario dei token noti o cercando sul DB - /// - /// - /// - public async Task CustomerIdByToken(string RestToken) - { - int answ = -1; - if (TokenCustList.ContainsKey(RestToken)) - { - answ = TokenCustList[RestToken]; - } - else - { - // cerco nel DB - var custList = await CustomerGetAll(); - var custRow = custList.FirstOrDefault(x => x.RestToken == RestToken); - // se trovato salvo - if (custRow != null) - { - answ = custRow.CustomerID; - TokenCustList.Add(RestToken, answ); - Log.Info($"TokenCustList: added {RestToken} --> {answ}"); - } - } - return answ; - } - /// - /// Recupera MainKey dal dizionario dei token noti o cercando sul DB - /// - /// - /// - public async Task MainKeyByToken(string RestToken) - { - int answ = -1; - if (TokenMKeyList.ContainsKey(RestToken)) - { - answ = TokenMKeyList[RestToken]; - } - else - { - // cerco nel DB - var custList = await CustomerGetAll(); - var custRow = custList.FirstOrDefault(x => x.RestToken == RestToken); - // se trovato salvo - if (custRow != null) - { - answ = custRow.MainKey; - TokenMKeyList.Add(RestToken, answ); - Log.Info($"TokenMKeyList: added {RestToken} --> {answ}"); - } - } - return answ; - } /// /// Recupera CustomerID dal dizionario dei token noti o cercando sul DB /// @@ -481,11 +446,44 @@ namespace MagMan.Data.Admin.Services return answ; } - #endregion Protected Methods + /// + /// Recupera MainKey dal dizionario dei token noti o cercando sul DB + /// + /// + /// + public async Task MainKeyByToken(string RestToken) + { + int answ = -1; + if (TokenMKeyList.ContainsKey(RestToken)) + { + answ = TokenMKeyList[RestToken]; + } + else + { + // cerco nel DB + var custList = await CustomerGetAll(); + var custRow = custList.FirstOrDefault(x => x.RestToken == RestToken); + // se trovato salvo + if (custRow != null) + { + answ = custRow.MainKey; + TokenMKeyList.Add(RestToken, answ); + Log.Info($"TokenMKeyList: added {RestToken} --> {answ}"); + } + } + return answ; + } + + #endregion Public Methods + + #region Protected Fields + + protected static MTAdminController dbController = null!; + + #endregion Protected Fields #region Private Fields - private static JsonSerializerSettings? JSSettings; private static Logger Log = LogManager.GetCurrentClassLogger(); @@ -522,22 +520,22 @@ namespace MagMan.Data.Admin.Services #region Private Properties /// - /// Dizionario dei token 2 customer - /// - private Dictionary TokenCustList { get; set; } = new Dictionary(); - /// - /// Dizionario dei token 2 MainKey (x calcolo DB) - /// - private Dictionary TokenMKeyList { get; set; } = new Dictionary(); - /// - /// Dizionario customer 2 MainKey (x calcolo DB) + /// Dizionario customer 2 MainKey (x calcolo DB) /// private Dictionary CustMKeyList { get; set; } = new Dictionary(); + /// + /// Dizionario dei token 2 customer + /// + private Dictionary TokenCustList { get; set; } = new Dictionary(); + + /// + /// Dizionario dei token 2 MainKey (x calcolo DB) + /// + private Dictionary TokenMKeyList { get; set; } = new Dictionary(); + #endregion Private Properties - - #region Private Methods /// diff --git a/MagMan.Data.Tenant/Controllers/TenantController.cs b/MagMan.Data.Tenant/Controllers/TenantController.cs index 436a8b4..7d14a91 100644 --- a/MagMan.Data.Tenant/Controllers/TenantController.cs +++ b/MagMan.Data.Tenant/Controllers/TenantController.cs @@ -203,18 +203,69 @@ namespace MagMan.Data.Tenant.Controllers /// /// Stringa connessione (variabile x cliente) /// - public List MaterialGetAll(string connString) + public List MaterialGetAll(string connString, bool withChild) { List dbResult = new List(); using (MagManContext dbCtx = new MagManContext(connString)) { - dbResult = dbCtx - .DbSetMaterials - .OrderBy(x => x.MatDesc) - .ThenBy(x => x.WMm) - .ThenBy(x => x.TMm) - .ThenBy(x => x.LMm) - .ToList(); + if (withChild) + { + dbResult = dbCtx + .DbSetMaterials + .Include(x => x.ItemNav) + .OrderBy(x => x.MatDesc) + .ThenBy(x => x.WMm) + .ThenBy(x => x.TMm) + .ThenBy(x => x.LMm) + .ToList(); + } + else + { + dbResult = dbCtx + .DbSetMaterials + .OrderBy(x => x.MatDesc) + .ThenBy(x => x.WMm) + .ThenBy(x => x.TMm) + .ThenBy(x => x.LMm) + .ToList(); + } + } + return dbResult; + } /// + /// Elenco Materiali gestiti a magazzino + /// + /// Stringa connessione (variabile x cliente) + /// Materiale richiesto + /// Se true allora include record child (Items) + /// + public List MaterialGetFilt(string connString, int matID, bool withChild) + { + List dbResult = new List(); + using (MagManContext dbCtx = new MagManContext(connString)) + { + if (withChild) + { + dbResult = dbCtx + .DbSetMaterials + .Where(x=> x.MatID == matID) + .Include(x => x.ItemNav) + .OrderBy(x => x.MatDesc) + .ThenBy(x => x.WMm) + .ThenBy(x => x.TMm) + .ThenBy(x => x.LMm) + .ToList(); + } + else + { + dbResult = dbCtx + .DbSetMaterials + .Where(x => x.MatID == matID) + .OrderBy(x => x.MatDesc) + .ThenBy(x => x.WMm) + .ThenBy(x => x.TMm) + .ThenBy(x => x.LMm) + .ToList(); + } } return dbResult; } @@ -234,7 +285,7 @@ namespace MagMan.Data.Tenant.Controllers { var currData = dbCtx .DbSetMaterials - .Where(x => x.MatID == rec2upd.MatID || x.MatExtCode==rec2upd.MatExtCode) + .Where(x => x.MatID == rec2upd.MatID || x.MatExtCode == rec2upd.MatExtCode) .FirstOrDefault(); if (currData != null) { diff --git a/MagMan.Data.Tenant/MagMan.Data.Tenant.csproj b/MagMan.Data.Tenant/MagMan.Data.Tenant.csproj index 4be0bad..cd5d5f6 100644 --- a/MagMan.Data.Tenant/MagMan.Data.Tenant.csproj +++ b/MagMan.Data.Tenant/MagMan.Data.Tenant.csproj @@ -12,6 +12,10 @@ + + + + diff --git a/MagMan.Data.Tenant/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.Designer.cs b/MagMan.Data.Tenant/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.Designer.cs deleted file mode 100644 index 46864d8..0000000 --- a/MagMan.Data.Tenant/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.Designer.cs +++ /dev/null @@ -1,311 +0,0 @@ -// -using System; -using MagMan.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MagMan.Data.Migrations.UserIdentityDb -{ - [DbContext(typeof(UserIdentityDbContext))] - [Migration("20231222165912_CreateIdentitySchema")] - partial class CreateIdentitySchema - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.25") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("MagMan.Data.DbModels.TableCount", b => - { - b.Property("Count") - .HasColumnType("int"); - - b.Property("TableName") - .IsRequired() - .HasColumnType("longtext"); - - b.ToTable("DbSetCounts"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("varchar(255)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - - b.HasData( - new - { - Id = "eebed9c1-7433-4716-a62f-df9829dc0f09", - ConcurrencyStamp = "4a1affe9-543f-4165-816a-2ed6d3f06c77", - Name = "Undef", - NormalizedName = "UNDEF" - }, - new - { - Id = "ca44b425-5c7e-4812-a28a-047ec6aa2e68", - ConcurrencyStamp = "a1357889-6a23-49cb-9d33-6bc5ef6eb4e6", - Name = "User", - NormalizedName = "USER" - }, - new - { - Id = "86a8f484-ca14-4e4d-a786-3eba35da6e06", - ConcurrencyStamp = "9dd579c3-bdfa-4c44-b6ca-6dd10d34debb", - Name = "Admin", - NormalizedName = "ADMIN" - }, - new - { - Id = "f5bd74e5-df26-4c52-963e-2d87e858c4d6", - ConcurrencyStamp = "1d620875-05b0-490d-91d5-6f21a83844f1", - Name = "SuperAdmin", - NormalizedName = "SUPERADMIN" - }); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => - { - b.Property("Id") - .HasColumnType("varchar(255)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("LockoutEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("LockoutEnd") - .HasColumnType("datetime(6)"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("PasswordHash") - .HasColumnType("longtext"); - - b.Property("PhoneNumber") - .HasColumnType("longtext"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("SecurityStamp") - .HasColumnType("longtext"); - - b.Property("TwoFactorEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("varchar(255)"); - - b.Property("ProviderKey") - .HasColumnType("varchar(255)"); - - b.Property("ProviderDisplayName") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("varchar(255)"); - - b.Property("RoleId") - .HasColumnType("varchar(255)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("varchar(255)"); - - b.Property("LoginProvider") - .HasColumnType("varchar(255)"); - - b.Property("Name") - .HasColumnType("varchar(255)"); - - b.Property("Value") - .HasColumnType("longtext"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MagMan.Data.Tenant/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.cs b/MagMan.Data.Tenant/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.cs deleted file mode 100644 index 1eb4f0a..0000000 --- a/MagMan.Data.Tenant/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.cs +++ /dev/null @@ -1,286 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MagMan.Data.Migrations.UserIdentityDb -{ - public partial class CreateIdentitySchema : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterDatabase() - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "AspNetRoles", - columns: table => new - { - Id = table.Column(type: "varchar(255)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Name = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - NormalizedName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ConcurrencyStamp = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetRoles", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "AspNetUsers", - columns: table => new - { - Id = table.Column(type: "varchar(255)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - UserName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - NormalizedUserName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Email = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - NormalizedEmail = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - EmailConfirmed = table.Column(type: "tinyint(1)", nullable: false), - PasswordHash = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - SecurityStamp = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ConcurrencyStamp = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - PhoneNumber = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - PhoneNumberConfirmed = table.Column(type: "tinyint(1)", nullable: false), - TwoFactorEnabled = table.Column(type: "tinyint(1)", nullable: false), - LockoutEnd = table.Column(type: "datetime(6)", nullable: true), - LockoutEnabled = table.Column(type: "tinyint(1)", nullable: false), - AccessFailedCount = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUsers", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "DbSetCounts", - columns: table => new - { - Count = table.Column(type: "int", nullable: false), - TableName = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "AspNetRoleClaims", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - RoleId = table.Column(type: "varchar(255)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ClaimType = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ClaimValue = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); - table.ForeignKey( - name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "AspNetUserClaims", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - UserId = table.Column(type: "varchar(255)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ClaimType = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ClaimValue = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); - table.ForeignKey( - name: "FK_AspNetUserClaims_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "AspNetUserLogins", - columns: table => new - { - LoginProvider = table.Column(type: "varchar(255)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ProviderKey = table.Column(type: "varchar(255)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ProviderDisplayName = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - UserId = table.Column(type: "varchar(255)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); - table.ForeignKey( - name: "FK_AspNetUserLogins_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "AspNetUserRoles", - columns: table => new - { - UserId = table.Column(type: "varchar(255)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - RoleId = table.Column(type: "varchar(255)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "AspNetUserTokens", - columns: table => new - { - UserId = table.Column(type: "varchar(255)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - LoginProvider = table.Column(type: "varchar(255)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Name = table.Column(type: "varchar(255)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Value = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); - table.ForeignKey( - name: "FK_AspNetUserTokens_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.InsertData( - table: "AspNetRoles", - columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" }, - values: new object[,] - { - { "86a8f484-ca14-4e4d-a786-3eba35da6e06", "9dd579c3-bdfa-4c44-b6ca-6dd10d34debb", "Admin", "ADMIN" }, - { "ca44b425-5c7e-4812-a28a-047ec6aa2e68", "a1357889-6a23-49cb-9d33-6bc5ef6eb4e6", "User", "USER" }, - { "eebed9c1-7433-4716-a62f-df9829dc0f09", "4a1affe9-543f-4165-816a-2ed6d3f06c77", "Undef", "UNDEF" }, - { "f5bd74e5-df26-4c52-963e-2d87e858c4d6", "1d620875-05b0-490d-91d5-6f21a83844f1", "SuperAdmin", "SUPERADMIN" } - }); - - migrationBuilder.CreateIndex( - name: "IX_AspNetRoleClaims_RoleId", - table: "AspNetRoleClaims", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "RoleNameIndex", - table: "AspNetRoles", - column: "NormalizedName", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserClaims_UserId", - table: "AspNetUserClaims", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserLogins_UserId", - table: "AspNetUserLogins", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserRoles_RoleId", - table: "AspNetUserRoles", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "EmailIndex", - table: "AspNetUsers", - column: "NormalizedEmail"); - - migrationBuilder.CreateIndex( - name: "UserNameIndex", - table: "AspNetUsers", - column: "NormalizedUserName", - unique: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AspNetRoleClaims"); - - migrationBuilder.DropTable( - name: "AspNetUserClaims"); - - migrationBuilder.DropTable( - name: "AspNetUserLogins"); - - migrationBuilder.DropTable( - name: "AspNetUserRoles"); - - migrationBuilder.DropTable( - name: "AspNetUserTokens"); - - migrationBuilder.DropTable( - name: "DbSetCounts"); - - migrationBuilder.DropTable( - name: "AspNetRoles"); - - migrationBuilder.DropTable( - name: "AspNetUsers"); - } - } -} diff --git a/MagMan.Data.Tenant/Migrations/UserIdentityDb/UserIdentityDbContextModelSnapshot.cs b/MagMan.Data.Tenant/Migrations/UserIdentityDb/UserIdentityDbContextModelSnapshot.cs deleted file mode 100644 index cc6e811..0000000 --- a/MagMan.Data.Tenant/Migrations/UserIdentityDb/UserIdentityDbContextModelSnapshot.cs +++ /dev/null @@ -1,309 +0,0 @@ -// -using System; -using MagMan.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MagMan.Data.Migrations.UserIdentityDb -{ - [DbContext(typeof(UserIdentityDbContext))] - partial class UserIdentityDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.25") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("MagMan.Data.DbModels.TableCount", b => - { - b.Property("Count") - .HasColumnType("int"); - - b.Property("TableName") - .IsRequired() - .HasColumnType("longtext"); - - b.ToTable("DbSetCounts"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("varchar(255)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - - b.HasData( - new - { - Id = "eebed9c1-7433-4716-a62f-df9829dc0f09", - ConcurrencyStamp = "4a1affe9-543f-4165-816a-2ed6d3f06c77", - Name = "Undef", - NormalizedName = "UNDEF" - }, - new - { - Id = "ca44b425-5c7e-4812-a28a-047ec6aa2e68", - ConcurrencyStamp = "a1357889-6a23-49cb-9d33-6bc5ef6eb4e6", - Name = "User", - NormalizedName = "USER" - }, - new - { - Id = "86a8f484-ca14-4e4d-a786-3eba35da6e06", - ConcurrencyStamp = "9dd579c3-bdfa-4c44-b6ca-6dd10d34debb", - Name = "Admin", - NormalizedName = "ADMIN" - }, - new - { - Id = "f5bd74e5-df26-4c52-963e-2d87e858c4d6", - ConcurrencyStamp = "1d620875-05b0-490d-91d5-6f21a83844f1", - Name = "SuperAdmin", - NormalizedName = "SUPERADMIN" - }); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => - { - b.Property("Id") - .HasColumnType("varchar(255)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("LockoutEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("LockoutEnd") - .HasColumnType("datetime(6)"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("PasswordHash") - .HasColumnType("longtext"); - - b.Property("PhoneNumber") - .HasColumnType("longtext"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("SecurityStamp") - .HasColumnType("longtext"); - - b.Property("TwoFactorEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("varchar(255)"); - - b.Property("ProviderKey") - .HasColumnType("varchar(255)"); - - b.Property("ProviderDisplayName") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("varchar(255)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("varchar(255)"); - - b.Property("RoleId") - .HasColumnType("varchar(255)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("varchar(255)"); - - b.Property("LoginProvider") - .HasColumnType("varchar(255)"); - - b.Property("Name") - .HasColumnType("varchar(255)"); - - b.Property("Value") - .HasColumnType("longtext"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MagMan.Data.Tenant/Services/MessageService.cs b/MagMan.Data.Tenant/Services/MessageService.cs index 649d893..0ad9e5c 100644 --- a/MagMan.Data.Tenant/Services/MessageService.cs +++ b/MagMan.Data.Tenant/Services/MessageService.cs @@ -311,7 +311,6 @@ namespace MagMan.Data.Tenant.Services } return answ; } - private string redisBaseKey = "MagMan"; /// /// Oggetto per connessione a REDIS /// diff --git a/MagMan.Data.Tenant/Services/TenantService.cs b/MagMan.Data.Tenant/Services/TenantService.cs index 1344b13..cc0d40e 100644 --- a/MagMan.Data.Tenant/Services/TenantService.cs +++ b/MagMan.Data.Tenant/Services/TenantService.cs @@ -79,6 +79,28 @@ namespace MagMan.Data.Tenant.Services return fatto; } + /// + /// Converte il DTO in ItemModel + /// + /// + /// + public ItemModel ItemFromDto(ItemDTO origItem) + { + ItemModel answ = new ItemModel() + { + MatID = origItem.MatID, + Note = origItem.Note, + LMm = origItem.LMm, + WMm = origItem.WMm, + TMm = origItem.TMm, + IsRemn = origItem.IsRemn, + Location = origItem.Location, + QtyAvail = origItem.QtyAvail + }; + + return answ; + } + /// /// Lista Items gestiti a magazzino /// @@ -91,7 +113,7 @@ namespace MagMan.Data.Tenant.Services List? dbResult = new List(); try { - string currKey = $"{Const.rKeyConfig}:{nKey}:ItemList"; + string currKey = $"{Const.rKeyConfig}:ItemList:{nKey}"; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); string? rawData = await redisDb.StringGetAsync(currKey); @@ -230,19 +252,40 @@ namespace MagMan.Data.Tenant.Services return fatto; } + /// + /// Converte il DTO in MaterialModel + /// + /// + /// + public MaterialModel MaterialFromDto(MaterialDTO origItem) + { + MaterialModel answ = new MaterialModel() + { + MatExtCode = origItem.MatExtCode, + MatDesc = origItem.MatDesc, + LMm = origItem.LMm, + WMm = origItem.WMm, + TMm = origItem.TMm + }; + + return answ; + } + /// /// Lista Materiali gestiti a magazzino /// /// Key di riferimento + /// Se true allora include record child (Items) /// - public async Task> MaterialGetAll(int nKey) + public async Task> MaterialGetAll(int nKey, bool withChild) { string source = "DB"; string cString = ConnString(nKey); List? dbResult = new List(); try { - string currKey = $"{Const.rKeyConfig}:{nKey}:Materials"; + string dType = withChild ? "MaterialsFull" : "Materials"; + string currKey = $"{Const.rKeyConfig}:{dType}:{nKey}"; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); string? rawData = await redisDb.StringGetAsync(currKey); @@ -261,9 +304,15 @@ namespace MagMan.Data.Tenant.Services } else { - dbResult = dbController.MaterialGetAll(cString); + dbResult = dbController.MaterialGetAll(cString, withChild); rawData = JsonConvert.SerializeObject(dbResult, JSSettings); await redisDb.StringSetAsync(currKey, rawData, LongCache); + // per evitare loopback uso deserialize... + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult != null) + { + dbResult = tempResult; + } } if (dbResult == null) { @@ -279,6 +328,64 @@ namespace MagMan.Data.Tenant.Services } return dbResult; } + /// + /// Lista Materiali gestiti a magazzino + /// + /// Key di riferimento + /// Materiale richiesto + /// Se true allora include record child (Items) + /// + public async Task> MaterialGetFilt(int nKey, int matID, bool withChild) + { + string source = "DB"; + string cString = ConnString(nKey); + List? dbResult = new List(); + try + { + string dType = withChild ? "MatInvFull" : "MatInv"; + string currKey = $"{Const.rKeyConfig}:{dType}:{nKey}:{matID}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData) && rawData.Length > 2) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.MaterialGetFilt(cString, matID, withChild); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, LongCache); + // per evitare loopback uso deserialize... + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult != null) + { + dbResult = tempResult; + } + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"MaterialGetFilt | {source} in: {ts.TotalMilliseconds} ms"); + } + catch (Exception exc) + { + Log.Error($"Error during MaterialGetFilt:{Environment.NewLine}{exc}"); + } + return dbResult; + } /// /// Update record Materiale + refresh cache @@ -305,47 +412,6 @@ namespace MagMan.Data.Tenant.Services return fatto; } - /// - /// Converte il DTO in MaterialModel - /// - /// - /// - public MaterialModel MaterialFromDto(MaterialDTO origItem) - { - MaterialModel answ = new MaterialModel() - { - MatExtCode = origItem.MatExtCode, - MatDesc = origItem.MatDesc, - LMm = origItem.LMm, - WMm = origItem.WMm, - TMm = origItem.TMm - }; - - return answ; - } - - /// - /// Converte il DTO in ItemModel - /// - /// - /// - public ItemModel ItemFromDto(ItemDTO origItem) - { - ItemModel answ = new ItemModel() - { - MatID = origItem.MatID, - Note = origItem.Note, - LMm = origItem.LMm, - WMm = origItem.WMm, - TMm = origItem.TMm, - IsRemn= origItem.IsRemn, - Location = origItem.Location, - QtyAvail = origItem.QtyAvail - }; - - return answ; - } - #endregion Public Methods #region Private Fields @@ -391,13 +457,14 @@ namespace MagMan.Data.Tenant.Services return answ; } + #endregion Private Methods + #if false /// - /// Dizionario dei token 2 connectionStrings + /// Dizionario dei token 2 connectionStrings /// private Dictionary TokenList { get; set; } = new Dictionary(); - /// /// Recupera ConnectionString dal dizionario dei token noti o cercando sul DB /// @@ -424,9 +491,7 @@ namespace MagMan.Data.Tenant.Services } } return answ; - } + } #endif - - #endregion Private Methods } } \ No newline at end of file diff --git a/MagMan.UI/Components/CmpTop.razor b/MagMan.UI/Components/CmpTop.razor index 5714a62..850c2d8 100644 --- a/MagMan.UI/Components/CmpTop.razor +++ b/MagMan.UI/Components/CmpTop.razor @@ -1,10 +1,4 @@ -@using MagMan.UI.Components -@using System.Security.Claims -@using Microsoft.AspNetCore.Components.Authorization - -@inject MessageService AppMessages - -
+
diff --git a/MagMan.UI/Components/CmpTop.razor.cs b/MagMan.UI/Components/CmpTop.razor.cs index 7e309de..12f1112 100644 --- a/MagMan.UI/Components/CmpTop.razor.cs +++ b/MagMan.UI/Components/CmpTop.razor.cs @@ -1,22 +1,13 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. using Microsoft.AspNetCore.Components; +using MagMan.UI.Components; +using System.Security.Claims; +using Microsoft.AspNetCore.Components.Authorization; +using MagMan.Core.Services; namespace MagMan.UI.Components { public partial class CmpTop { - #region Private Properties - - private string PageIcon { get; set; } = ""; - - private string PageName { get; set; } = ""; - - [CascadingParameter(Name = "ShowSearch")] - private bool ShowSearch { get; set; } = false; - - #endregion Private Properties - #region Public Methods public void Dispose() @@ -36,6 +27,13 @@ namespace MagMan.UI.Components #endregion Public Methods + #region Protected Properties + + [Inject] + protected MessageService AppMessages { get; set; } = null!; + + #endregion Protected Properties + #region Protected Methods protected override void OnInitialized() @@ -49,5 +47,16 @@ namespace MagMan.UI.Components } #endregion Protected Methods + + #region Private Properties + + private string PageIcon { get; set; } = ""; + + private string PageName { get; set; } = ""; + + [CascadingParameter(Name = "ShowSearch")] + private bool ShowSearch { get; set; } = false; + + #endregion Private Properties } } \ No newline at end of file diff --git a/MagMan.UI/Components/CustomerEdit.razor b/MagMan.UI/Components/CustomerEdit.razor index 3f140c9..853870a 100644 --- a/MagMan.UI/Components/CustomerEdit.razor +++ b/MagMan.UI/Components/CustomerEdit.razor @@ -1,13 +1,19 @@ @if (CurrRecord != null) {
-
+
-
+
+
+ + +
+
+
@@ -29,7 +35,7 @@
-
+
diff --git a/MagMan.UI/Controllers/ItemsController.cs b/MagMan.UI/Controllers/InventoryController.cs similarity index 69% rename from MagMan.UI/Controllers/ItemsController.cs rename to MagMan.UI/Controllers/InventoryController.cs index 0543984..a2f1b9b 100644 --- a/MagMan.UI/Controllers/ItemsController.cs +++ b/MagMan.UI/Controllers/InventoryController.cs @@ -1,4 +1,5 @@ using MagMan.Core; +using MagMan.Core.Services; using MagMan.Data.Admin.DbModels; using MagMan.Data.Admin.Services; using MagMan.Data.Tenant.DbModels; @@ -13,7 +14,7 @@ namespace MagMan.UI.Controllers { [Route("api/[controller]")] [ApiController] - public class ItemsController : ControllerBase + public class InventoryController : ControllerBase { /// /// Classe per logging @@ -22,7 +23,7 @@ namespace MagMan.UI.Controllers private MTAdminService MTAdminService { get; set; } = null!; private static JsonSerializerSettings? JSSettings; private TenantService TService { get; set; } = null!; - public ItemsController(MTAdminService MTDataService, TenantService TDataService) + public InventoryController(MTAdminService MTDataService, TenantService TDataService) { MTAdminService = MTDataService; TService = TDataService; @@ -31,12 +32,12 @@ namespace MagMan.UI.Controllers { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }; - Log.Info("Avviata classe ItemsController"); + Log.Info("Avviata classe InventoryController"); } /// /// Controllo status Alive - /// GET: api/Items/alive + /// GET: api/Inventory/alive /// /// [HttpGet("alive")] @@ -46,11 +47,11 @@ namespace MagMan.UI.Controllers return $"OK"; } - // GET api/Items + // GET api/Inventory [HttpGet] public async Task> Get() { - // se non ho chaive --> vuoto! + // se non ho chiave --> vuoto! List ListRecords = new List(); await Task.Delay(100); return ListRecords; @@ -62,20 +63,20 @@ namespace MagMan.UI.Controllers /// Rest Token cliente /// ID del materiale cercato /// - // GET api/Items/00000000-0000-0000-0000-000000000000 + // GET api/Inventory/00000000-0000-0000-0000-000000000000 [HttpGet("{id}")] - public async Task> Get(string id, int MatId) + public async Task> Get(string id, int MatId) { // in primis recupero codice chiave da token... int nKey = await MTAdminService.MainKeyByToken(id); // ora recupero direttametne i materiali - var ListRecords = await TService.ItemGetByMat(nKey, MatId); + var ListRecords = await TService.MaterialGetFilt(nKey, MatId, true); return ListRecords; } /// /// Processa una chiamata POST per l'invio di un array Json di oggetti MaterialModel da salvare - /// PUT: api/Items/upsert/00000000-0000-0000-0000-000000000000 + /// PUT: api/Inventory/upsert/00000000-0000-0000-0000-000000000000 /// /// token comunicazione /// @@ -89,20 +90,23 @@ namespace MagMan.UI.Controllers { // in primis recupero codice chiave da token... int nKey = await MTAdminService.MainKeyByToken(id); - // creo oggetti materiale da lista ricevuta - List matList = rawList.ItemList.Select(jpl => TService.ItemFromDto(jpl)).ToList(); - - foreach (var item in matList) + if (nKey > 0) { - try + // creo oggetti materiale da lista ricevuta + List matList = rawList.ItemList.Select(jpl => TService.ItemFromDto(jpl)).ToList(); + + foreach (var item in matList) { - await TService.ItemUpdate(nKey, item); - fatto = true; - } - catch (Exception exc) - { - Log.Error($"ItemsController.upsert | Errore in fase salvataggio ItemDto{Environment.NewLine}{exc}"); - fatto = false; + try + { + await TService.ItemUpdate(nKey, item); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"InventoryController.upsert | Errore in fase salvataggio ItemDto{Environment.NewLine}{exc}"); + fatto = false; + } } } } diff --git a/MagMan.UI/Controllers/MaterialsController.cs b/MagMan.UI/Controllers/MaterialsController.cs index 754dafc..3534796 100644 --- a/MagMan.UI/Controllers/MaterialsController.cs +++ b/MagMan.UI/Controllers/MaterialsController.cs @@ -68,7 +68,7 @@ namespace MagMan.UI.Controllers // in primis recupero codice chiave da token... int nKey = await MTAdminService.MainKeyByToken(id); // ora recupero direttametne i materiali - var ListRecords = await TService.MaterialGetAll(nKey); + var ListRecords = await TService.MaterialGetAll(nKey, false); return ListRecords; } @@ -88,20 +88,23 @@ namespace MagMan.UI.Controllers { // in primis recupero codice chiave da token... int nKey = await MTAdminService.MainKeyByToken(id); - // creo oggetti materiale da lista ricevuta - List matList = rawList.MatList.Select(jpl => TService.MaterialFromDto(jpl)).ToList(); - - foreach (var item in matList) + if (nKey > 0) { - try + // creo oggetti materiale da lista ricevuta + List matList = rawList.MatList.Select(jpl => TService.MaterialFromDto(jpl)).ToList(); + + foreach (var item in matList) { - await TService.MaterialUpdate(nKey, item); - fatto = true; - } - catch (Exception exc) - { - Log.Error($"MaterialsController.upsert | Errore in fase salvataggio MaterialDto{Environment.NewLine}{exc}"); - fatto = false; + try + { + await TService.MaterialUpdate(nKey, item); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"MaterialsController.upsert | Errore in fase salvataggio MaterialDto{Environment.NewLine}{exc}"); + fatto = false; + } } } } diff --git a/MagMan.UI/MagMan.UI.csproj b/MagMan.UI/MagMan.UI.csproj index da783b1..d3d412c 100644 --- a/MagMan.UI/MagMan.UI.csproj +++ b/MagMan.UI/MagMan.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 1.0.2401.1614 + 1.0.2401.1715 enable enable true diff --git a/MagMan.UI/Pages/AdminArea.razor.cs b/MagMan.UI/Pages/AdminArea.razor.cs index cd24a4b..1e2e4e1 100644 --- a/MagMan.UI/Pages/AdminArea.razor.cs +++ b/MagMan.UI/Pages/AdminArea.razor.cs @@ -1,9 +1,6 @@ -// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this -// file to you under the MIT license. -using k8s.Models; +using MagMan.Core.Services; using MagMan.Data.Admin.DbModels; using MagMan.Data.Admin.Services; -using MagMan.Data.Tenant.Services; using Microsoft.AspNetCore.Components; namespace MagMan.UI.Pages diff --git a/MagMan.UI/Pages/Index.razor.cs b/MagMan.UI/Pages/Index.razor.cs index 98bd9f5..5c29f2f 100644 --- a/MagMan.UI/Pages/Index.razor.cs +++ b/MagMan.UI/Pages/Index.razor.cs @@ -1,6 +1,5 @@ -using MagMan.Data.Tenant.Services; +using MagMan.Core.Services; using Microsoft.AspNetCore.Components; -using System; namespace MagMan.UI.Pages { diff --git a/MagMan.UI/Pages/ResetCache.razor.cs b/MagMan.UI/Pages/ResetCache.razor.cs index 5b1fec6..4f66efc 100644 --- a/MagMan.UI/Pages/ResetCache.razor.cs +++ b/MagMan.UI/Pages/ResetCache.razor.cs @@ -1,11 +1,6 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -using k8s.KubeConfigModels; +using MagMan.Core.Services; using MagMan.Data.Admin.Services; -using MagMan.Data.Tenant.Services; -using MagMan.UI.Shared; using Microsoft.AspNetCore.Components; -using System; namespace MagMan.UI.Pages { diff --git a/MagMan.UI/Pages/WareHouse.razor.cs b/MagMan.UI/Pages/WareHouse.razor.cs index e48c733..864137c 100644 --- a/MagMan.UI/Pages/WareHouse.razor.cs +++ b/MagMan.UI/Pages/WareHouse.razor.cs @@ -1,9 +1,6 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -using k8s.Models; +using MagMan.Core.Services; using MagMan.Data.Admin.DbModels; using MagMan.Data.Admin.Services; -using MagMan.Data.Tenant.Services; using Microsoft.AspNetCore.Components; namespace MagMan.UI.Pages diff --git a/MagMan.UI/Shared/MainLayout.razor b/MagMan.UI/Shared/MainLayout.razor index 0e5211b..2131c01 100644 --- a/MagMan.UI/Shared/MainLayout.razor +++ b/MagMan.UI/Shared/MainLayout.razor @@ -1,10 +1,5 @@ @inherits LayoutComponentBase -@using MagMan.UI.Components -@inject MessageService MessageService -@implements IDisposable - - MagMan UI
@@ -27,46 +22,3 @@
- -@code { - bool ShowSearch { get; set; } = false; - - protected override void OnInitialized() - { - MessageService.EA_ShowSearch += OnShowSearch; - MessageService.EA_HideSearch += OnHideSearch; - } - public void OnShowSearch() - { - ShowSearch = true; - InvokeAsync(() => - { - StateHasChanged(); - }); - } - public void OnHideSearch() - { - ShowSearch = false; - InvokeAsync(() => - { - StateHasChanged(); - }); - } - - public void Dispose() - { - MessageService.EA_ShowSearch -= OnShowSearch; - MessageService.EA_ShowSearch -= OnHideSearch; - } - - protected bool navLarge { get; set; } = true; - - protected string sideClass { get; set; } = "sidebar"; - - protected void UpdateNavDisplay() - { - navLarge = !navLarge; - sideClass = navLarge ? "sidebar" : "sidebarSmall"; - } - -} diff --git a/MagMan.UI/Shared/MainLayout.razor.cs b/MagMan.UI/Shared/MainLayout.razor.cs new file mode 100644 index 0000000..a719d54 --- /dev/null +++ b/MagMan.UI/Shared/MainLayout.razor.cs @@ -0,0 +1,68 @@ +using MagMan.Core.Services; +using Microsoft.AspNetCore.Components; + +namespace MagMan.UI.Shared +{ + public partial class MainLayout : IDisposable + { + #region Public Methods + + public void Dispose() + { + MessageService.EA_ShowSearch -= OnShowSearch; + MessageService.EA_ShowSearch -= OnHideSearch; + } + + public void OnHideSearch() + { + ShowSearch = false; + InvokeAsync(() => + { + StateHasChanged(); + }); + } + + public void OnShowSearch() + { + ShowSearch = true; + InvokeAsync(() => + { + StateHasChanged(); + }); + } + + #endregion Public Methods + + #region Protected Properties + + [Inject] + protected MessageService MessageService { get; set; } = null!; + + protected bool navLarge { get; set; } = true; + protected string sideClass { get; set; } = "sidebar"; + + #endregion Protected Properties + + #region Protected Methods + + protected override void OnInitialized() + { + MessageService.EA_ShowSearch += OnShowSearch; + MessageService.EA_HideSearch += OnHideSearch; + } + + protected void UpdateNavDisplay() + { + navLarge = !navLarge; + sideClass = navLarge ? "sidebar" : "sidebarSmall"; + } + + #endregion Protected Methods + + #region Private Properties + + private bool ShowSearch { get; set; } = false; + + #endregion Private Properties + } +} \ No newline at end of file diff --git a/MagMan.UI/_Imports.razor b/MagMan.UI/_Imports.razor index 848ba8c..1e0d96a 100644 --- a/MagMan.UI/_Imports.razor +++ b/MagMan.UI/_Imports.razor @@ -1,6 +1,7 @@ @using EgwCoreLib.Razor @using MagMan.Core @using MagMan.Core.DTO +@using MagMan.Core.Services @using MagMan.Data @using MagMan.Data.Admin @using MagMan.Data.Admin.DbModels diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index bbca584..18377ce 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ MagMan - Wood Warehouse Management System -

Versione: 1.0.2401.1614

+

Versione: 1.0.2401.1715


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index e6729af..4180614 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2401.1614 +1.0.2401.1715 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index fbd45fb..fbe1319 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2401.1614 + 1.0.2401.1715 http://nexus.steamware.net/repository/SWS/MagMan/stable/0/MagMan.UI.zip http://nexus.steamware.net/repository/SWS/MagMan/stable/0/ChangeLog.html false