diff --git a/EgwCoreLib.Lux.Data/Repository/BaseRepository.cs b/EgwCoreLib.Lux.Data/Repository/BaseRepository.cs index 37ca20e..4ce8331 100644 --- a/EgwCoreLib.Lux.Data/Repository/BaseRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/BaseRepository.cs @@ -1,14 +1,46 @@ -namespace EgwCoreLib.Lux.Data.Repository +using Microsoft.EntityFrameworkCore; + +namespace EgwCoreLib.Lux.Data.Repository { public abstract class BaseRepository : IBaseRepository { - protected readonly DataLayerContext _dbCtx; - protected BaseRepository(DataLayerContext db) => _dbCtx = db; + #region Protected Fields + protected readonly IDbContextFactory _ctxFactory; + + #endregion Protected Fields + + #region Protected Constructors + + protected BaseRepository(IDbContextFactory ctxFactory) + => _ctxFactory = ctxFactory; + + #endregion Protected Constructors + + #region Protected Methods + + /// + /// Creazione dbcontext per singola transazione + /// + /// + protected async Task CreateContextAsync() + => await _ctxFactory.CreateDbContextAsync(); + +#if false /// /// Salvataggio dati asincrono /// /// + protected async Task SaveChangesAsync(DataLayerContext ctx) + => await ctx.SaveChangesAsync() > 0; +#endif + + #endregion Protected Methods + +#if false + protected readonly DataLayerContext _dbCtx; + protected BaseRepository(DataLayerContext db) => _dbCtx = db; public async Task SaveChangesAsync() => await _dbCtx.SaveChangesAsync() > 0; +#endif } -} +} \ No newline at end of file diff --git a/EgwCoreLib.Lux.Data/Repository/Catalog/ITemplateRepository.cs b/EgwCoreLib.Lux.Data/Repository/Catalog/ITemplateRepository.cs index 5c4bf11..107ef2c 100644 --- a/EgwCoreLib.Lux.Data/Repository/Catalog/ITemplateRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Catalog/ITemplateRepository.cs @@ -7,13 +7,13 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils { #region Public Methods - void Add(TemplateModel entity); + Task AddAsync(TemplateModel entity); Task CloneAsync(TemplateModel rec2clone); Task CountChildrenAsync(int TemplateID); - void Delete(TemplateModel entity); + Task DeleteAsync(TemplateModel entity); Task> GetAllWithNavAsync(); @@ -27,7 +27,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils Task SaveRowsAsync(List rows); - void Update(TemplateModel entity); + Task UpdateAsync(TemplateModel entity); #endregion Public Methods diff --git a/EgwCoreLib.Lux.Data/Repository/Catalog/ITemplateRowRepository.cs b/EgwCoreLib.Lux.Data/Repository/Catalog/ITemplateRowRepository.cs index 7a78126..c3159a3 100644 --- a/EgwCoreLib.Lux.Data/Repository/Catalog/ITemplateRowRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Catalog/ITemplateRowRepository.cs @@ -6,11 +6,11 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils { #region Public Methods - void Add(TemplateRowModel entity); + Task AddAsync(TemplateRowModel entity); Task CloneAsync(TemplateRowModel rec2clone); - void Delete(TemplateRowModel entity); + Task DeleteAsync(TemplateRowModel entity); Task> GetAllWithNavAsync(); @@ -20,7 +20,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils Task SaveRowsAsync(List rows); - void Update(TemplateRowModel entity); + Task UpdateAsync(TemplateRowModel entity); #endregion Public Methods diff --git a/EgwCoreLib.Lux.Data/Repository/Catalog/TemplateRepository.cs b/EgwCoreLib.Lux.Data/Repository/Catalog/TemplateRepository.cs index 9979051..008a3f1 100644 --- a/EgwCoreLib.Lux.Data/Repository/Catalog/TemplateRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Catalog/TemplateRepository.cs @@ -9,7 +9,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils { #region Public Constructors - public TemplateRepository(DataLayerContext db) : base(db) + public TemplateRepository(IDbContextFactory ctxFactory) : base(ctxFactory) { } @@ -17,7 +17,12 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils #region Public Methods - public void Add(TemplateModel entity) => _dbCtx.DbSetTemplate.Add(entity); + public async Task AddAsync(TemplateModel entity) + { + await using var dbCtx = await CreateContextAsync(); + await dbCtx.DbSetTemplate.AddAsync(entity); + return await dbCtx.SaveChangesAsync() > 0; + } /// /// Esegue il cloning completo di un Template e di TUTTE le relative righe... @@ -26,10 +31,11 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils /// public async Task CloneAsync(TemplateModel rec2clone) { + await using var dbCtx = await CreateContextAsync(); DateTime now = DateTime.Now; // 1. Recupero il record originale con i child - var currRec = await _dbCtx.DbSetTemplate + var currRec = await dbCtx.DbSetTemplate .Include(x => x.TemplateRowNav) .FirstOrDefaultAsync(x => x.TemplateID == rec2clone.TemplateID); @@ -81,22 +87,28 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils .ToList(); // 4. Aggiungo il nuovo parent (EF aggiunge anche i child) - _dbCtx.DbSetTemplate.Add(newRec); + dbCtx.DbSetTemplate.Add(newRec); // 5. Salvo tutto - return await _dbCtx.SaveChangesAsync() > 0; + return await dbCtx.SaveChangesAsync() > 0; } public async Task CountChildrenAsync(int TemplateID) { - return await _dbCtx.DbSetTemplateRow.CountAsync(x => x.TemplateID == TemplateID); + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetTemplateRow.CountAsync(x => x.TemplateID == TemplateID); + } + public async Task DeleteAsync(TemplateModel entity) + { + await using var dbCtx = await CreateContextAsync(); + dbCtx.DbSetTemplate.Remove(entity); + return await dbCtx.SaveChangesAsync() > 0; } - - public void Delete(TemplateModel entity) => _dbCtx.DbSetTemplate.Remove(entity); public async Task> GetAllWithNavAsync() { - return await _dbCtx.DbSetTemplate + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetTemplate .Include(o => o.TemplateRowNav) .AsNoTracking() .ToListAsync(); @@ -104,48 +116,57 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils public async Task> GetBomItemsAsync() { - return await _dbCtx.DbSetItem + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetItem .Where(x => x.ItemType == ItemClassType.Bom || x.ItemType == ItemClassType.BomAlt) .ToListAsync(); } - public async Task GetByIdAsync(int TemplateID) => - await _dbCtx.DbSetTemplate.FirstOrDefaultAsync(x => x.TemplateID == TemplateID); + public async Task GetByIdAsync(int TemplateID) + { + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetTemplate.FirstOrDefaultAsync(x => x.TemplateID == TemplateID); + } public async Task> GetItemGroupsAsync() { - return await _dbCtx.DbSetItemGroup.ToListAsync(); + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetItemGroup.ToListAsync(); } public async Task> GetRowsAsync(int TemplateID) { - return await _dbCtx.DbSetTemplateRow - .Where(x => x.TemplateID == TemplateID) - .ToListAsync(); + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetTemplateRow + .Where(x => x.TemplateID == TemplateID) + .ToListAsync(); } public async Task SaveRowsAsync(List rows) { + await using var dbCtx = await CreateContextAsync(); foreach (var row in rows) - _dbCtx.Entry(row).State = EntityState.Modified; + dbCtx.Entry(row).State = EntityState.Modified; - return await _dbCtx.SaveChangesAsync() > 0; + return await dbCtx.SaveChangesAsync() > 0; } - public void Update(TemplateModel entity) + public async Task UpdateAsync(TemplateModel entity) { + await using var dbCtx = await CreateContextAsync(); // Recuperiamo l'entità tracciata dal context - var trackedEntity = _dbCtx.DbSetTemplate.Local.FirstOrDefault(x => x.TemplateID == entity.TemplateID); + var trackedEntity = dbCtx.DbSetTemplate.Local.FirstOrDefault(x => x.TemplateID == entity.TemplateID); if (trackedEntity != null) { // Aggiorna i valori dell'entità tracciata con quelli della nuova - _dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity); + dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity); } else { - _dbCtx.DbSetTemplate.Update(entity); + dbCtx.DbSetTemplate.Update(entity); } + return await dbCtx.SaveChangesAsync() > 0; } #endregion Public Methods diff --git a/EgwCoreLib.Lux.Data/Repository/Catalog/TemplateRowRepository.cs b/EgwCoreLib.Lux.Data/Repository/Catalog/TemplateRowRepository.cs index f79a6cb..94b7ad8 100644 --- a/EgwCoreLib.Lux.Data/Repository/Catalog/TemplateRowRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Catalog/TemplateRowRepository.cs @@ -7,7 +7,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils { #region Public Constructors - public TemplateRowRepository(DataLayerContext db) : base(db) + public TemplateRowRepository(IDbContextFactory ctxFactory) : base(ctxFactory) { } @@ -15,7 +15,12 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils #region Public Methods - public void Add(TemplateRowModel entity) => _dbCtx.DbSetTemplateRow.Add(entity); + public async Task AddAsync(TemplateRowModel entity) + { + await using var dbCtx = await CreateContextAsync(); + await dbCtx.DbSetTemplateRow.AddAsync(entity); + return await dbCtx.SaveChangesAsync() > 0; + } /// /// Esegue il cloning completo di un Template e di TUTTE le relative righe... @@ -24,14 +29,15 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils /// public async Task CloneAsync(TemplateRowModel rec2clone) { - var currRec = await _dbCtx.DbSetTemplateRow + await using var dbCtx = await CreateContextAsync(); + var currRec = await dbCtx.DbSetTemplateRow .FirstOrDefaultAsync(x => x.TemplateRowID == rec2clone.TemplateRowID); if (currRec == null) return false; // cerco ultimo rec... - var lastRec = await _dbCtx + var lastRec = await dbCtx .DbSetTemplateRow .Where(x => x.TemplateID == rec2clone.TemplateID) .OrderByDescending(x => x.RowNum) @@ -72,16 +78,22 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils TemplateRowUID = rec2clone.TemplateRowDtx }; - _dbCtx.DbSetTemplateRow.Add(newRec); + dbCtx.DbSetTemplateRow.Add(newRec); - return await _dbCtx.SaveChangesAsync() > 0; + return await dbCtx.SaveChangesAsync() > 0; } - public void Delete(TemplateRowModel entity) => _dbCtx.DbSetTemplateRow.Remove(entity); + public async Task DeleteAsync(TemplateRowModel entity) + { + await using var dbCtx = await CreateContextAsync(); + dbCtx.DbSetTemplateRow.Remove(entity); + return await dbCtx.SaveChangesAsync() > 0; + } public async Task> GetAllWithNavAsync() { - return await _dbCtx.DbSetTemplateRow + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetTemplateRow .Include(o => o.SellingItemNav) .AsNoTracking() .ToListAsync(); @@ -89,13 +101,15 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils public async Task GetRowAsync(int templateRowId) { - return await _dbCtx.DbSetTemplateRow + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetTemplateRow .FirstOrDefaultAsync(x => x.TemplateRowID == templateRowId); } public async Task> GetRowsAsync(int templateId) { - return await _dbCtx.DbSetTemplateRow + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetTemplateRow .Where(x => x.TemplateID == templateId) .Include(r => r.SellingItemNav) .ToListAsync(); @@ -103,26 +117,29 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils public async Task SaveRowsAsync(List rows) { + await using var dbCtx = await CreateContextAsync(); foreach (var row in rows) - _dbCtx.Entry(row).State = EntityState.Modified; + dbCtx.Entry(row).State = EntityState.Modified; - return await _dbCtx.SaveChangesAsync() > 0; + return await dbCtx.SaveChangesAsync() > 0; } - public void Update(TemplateRowModel entity) + public async Task UpdateAsync(TemplateRowModel entity) { + await using var dbCtx = await CreateContextAsync(); // Recuperiamo l'entità tracciata dal context - var trackedEntity = _dbCtx.DbSetTemplateRow.Local.FirstOrDefault(x => x.TemplateID == entity.TemplateID); + var trackedEntity = dbCtx.DbSetTemplateRow.Local.FirstOrDefault(x => x.TemplateID == entity.TemplateID); if (trackedEntity != null) { // Aggiorna i valori dell'entità tracciata con quelli della nuova - _dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity); + dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity); } else { - _dbCtx.DbSetTemplateRow.Update(entity); + dbCtx.DbSetTemplateRow.Update(entity); } + return await dbCtx.SaveChangesAsync() > 0; } #endregion Public Methods diff --git a/EgwCoreLib.Lux.Data/Repository/Config/ConfGlassRepository.cs b/EgwCoreLib.Lux.Data/Repository/Config/ConfGlassRepository.cs index f2b1585..6a4489a 100644 --- a/EgwCoreLib.Lux.Data/Repository/Config/ConfGlassRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Config/ConfGlassRepository.cs @@ -7,7 +7,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Config { #region Public Constructors - public ConfGlassRepository(DataLayerContext db) : base(db) + public ConfGlassRepository(IDbContextFactory ctxFactory) : base(ctxFactory) { } @@ -15,38 +15,48 @@ namespace EgwCoreLib.Lux.Data.Repository.Config #region Public Methods - public void Add(GlassModel entity) => _dbCtx.DbSetConfGlass.Add(entity); + public async Task AddAsync(GlassModel entity) + { + await using var dbCtx = await CreateContextAsync(); + await dbCtx.DbSetConfGlass.AddAsync(entity); + return await dbCtx.SaveChangesAsync() > 0; + } - public void Delete(GlassModel entity) => _dbCtx.DbSetConfGlass.Remove(entity); + public async Task DeleteAsync(GlassModel entity) + { + await using var dbCtx = await CreateContextAsync(); + dbCtx.DbSetConfGlass.Remove(entity); + return await dbCtx.SaveChangesAsync() > 0; + } public async Task> GetAllAsync() { - return await _dbCtx.DbSetConfGlass - .AsNoTracking() - .ToListAsync(); + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetConfGlass.AsNoTracking().ToListAsync(); } public async Task GetByIdAsync(int recId) { - return await _dbCtx.DbSetConfGlass + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetConfGlass .Where(x => x.GlassID == recId) .FirstOrDefaultAsync(); } - public void Update(GlassModel entity) + public async Task UpdateAsync(GlassModel entity) { - // Recuperiamo l'entità tracciata dal context - var trackedEntity = _dbCtx.DbSetConfGlass.Local.FirstOrDefault(x => x.GlassID == entity.GlassID); + await using var dbCtx = await CreateContextAsync(); + var trackedEntity = dbCtx.DbSetConfGlass.Local.FirstOrDefault(x => x.GlassID == entity.GlassID); if (trackedEntity != null) { - // Aggiorna i valori dell'entità tracciata con quelli della nuova - _dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity); + dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity); } else { - _dbCtx.DbSetConfGlass.Update(entity); + dbCtx.DbSetConfGlass.Update(entity); } + return await dbCtx.SaveChangesAsync() > 0; } #endregion Public Methods diff --git a/EgwCoreLib.Lux.Data/Repository/Config/ConfProfileRepository.cs b/EgwCoreLib.Lux.Data/Repository/Config/ConfProfileRepository.cs index ab2381a..3952903 100644 --- a/EgwCoreLib.Lux.Data/Repository/Config/ConfProfileRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Config/ConfProfileRepository.cs @@ -7,7 +7,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Config { #region Public Constructors - public ConfProfileRepository(DataLayerContext db) : base(db) + public ConfProfileRepository(IDbContextFactory ctxFactory) : base(ctxFactory) { } @@ -15,38 +15,49 @@ namespace EgwCoreLib.Lux.Data.Repository.Config #region Public Methods - public void Add(ProfileModel entity) => _dbCtx.DbSetConfProfile.Add(entity); - - public void Delete(ProfileModel entity) => _dbCtx.DbSetConfProfile.Remove(entity); + public async Task AddAsync(ProfileModel entity) + { + await using var dbCtx = await CreateContextAsync(); + await dbCtx.DbSetConfProfile.AddAsync(entity); + return await dbCtx.SaveChangesAsync() > 0; + } + public async Task DeleteAsync(ProfileModel entity) + { + await using var dbCtx = await CreateContextAsync(); + dbCtx.DbSetConfProfile.Remove(entity); + return await dbCtx.SaveChangesAsync() > 0; + } public async Task> GetAllAsync() { - return await _dbCtx.DbSetConfProfile - .AsNoTracking() - .ToListAsync(); + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetConfProfile.AsNoTracking().ToListAsync(); } public async Task GetByIdAsync(int recId) { - return await _dbCtx.DbSetConfProfile + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetConfProfile .Where(x => x.ProfileID == recId) .FirstOrDefaultAsync(); } - public void Update(ProfileModel entity) + + public async Task UpdateAsync(ProfileModel entity) { - // Recuperiamo l'entità tracciata dal context - var trackedEntity = _dbCtx.DbSetConfProfile.Local.FirstOrDefault(x => x.ProfileID == entity.ProfileID); + await using var dbCtx = await CreateContextAsync(); + var trackedEntity = dbCtx.DbSetConfProfile.Local.FirstOrDefault(x => x.ProfileID == entity.ProfileID); if (trackedEntity != null) { // Aggiorna i valori dell'entità tracciata con quelli della nuova - _dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity); + dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity); } else { - _dbCtx.DbSetConfProfile.Update(entity); + dbCtx.DbSetConfProfile.Update(entity); } + return await dbCtx.SaveChangesAsync() > 0; } #endregion Public Methods diff --git a/EgwCoreLib.Lux.Data/Repository/Config/ConfWoodRepository.cs b/EgwCoreLib.Lux.Data/Repository/Config/ConfWoodRepository.cs index 76e6bf9..a4c6e14 100644 --- a/EgwCoreLib.Lux.Data/Repository/Config/ConfWoodRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Config/ConfWoodRepository.cs @@ -7,7 +7,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Config { #region Public Constructors - public ConfWoodRepository(DataLayerContext db) : base(db) + public ConfWoodRepository(IDbContextFactory ctxFactory) : base(ctxFactory) { } @@ -15,38 +15,51 @@ namespace EgwCoreLib.Lux.Data.Repository.Config #region Public Methods - public void Add(WoodModel entity) => _dbCtx.DbSetConfWood.Add(entity); + public async Task AddAsync(WoodModel entity) + { + await using var dbCtx = await CreateContextAsync(); + await dbCtx.DbSetConfWood.AddAsync(entity); + return await dbCtx.SaveChangesAsync() > 0; + } - public void Delete(WoodModel entity) => _dbCtx.DbSetConfWood.Remove(entity); + public async Task DeleteAsync(WoodModel entity) + { + await using var dbCtx = await CreateContextAsync(); + dbCtx.DbSetConfWood.Remove(entity); + return await dbCtx.SaveChangesAsync() > 0; + } public async Task> GetAllAsync() { - return await _dbCtx.DbSetConfWood + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetConfWood .AsNoTracking() .ToListAsync(); } public async Task GetByIdAsync(int recId) { - return await _dbCtx.DbSetConfWood + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetConfWood .Where(x => x.WoodID == recId) .FirstOrDefaultAsync(); } - public void Update(WoodModel entity) + public async Task UpdateAsync(WoodModel entity) { - // Recuperiamo l'entità tracciata dal context - var trackedEntity = _dbCtx.DbSetConfWood.Local.FirstOrDefault(x => x.WoodID == entity.WoodID); + await using var dbCtx = await CreateContextAsync(); + var trackedEntity = dbCtx.DbSetConfWood.Local.FirstOrDefault(x => x.WoodID == entity.WoodID); if (trackedEntity != null) { // Aggiorna i valori dell'entità tracciata con quelli della nuova - _dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity); + dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity); } else { - _dbCtx.DbSetConfWood.Update(entity); + dbCtx.DbSetConfWood.Update(entity); } + return await dbCtx.SaveChangesAsync() > 0; } #endregion Public Methods diff --git a/EgwCoreLib.Lux.Data/Repository/Config/EnvirParamRepository.cs b/EgwCoreLib.Lux.Data/Repository/Config/EnvirParamRepository.cs index adeb457..4a54f92 100644 --- a/EgwCoreLib.Lux.Data/Repository/Config/EnvirParamRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Config/EnvirParamRepository.cs @@ -7,7 +7,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Config { #region Public Constructors - public EnvirParamRepository(DataLayerContext db) : base(db) + public EnvirParamRepository(IDbContextFactory ctxFactory) : base(ctxFactory) { } @@ -17,7 +17,8 @@ namespace EgwCoreLib.Lux.Data.Repository.Config public async Task> GetAllAsync() { - return await _dbCtx.DbSetEnvirPar + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetEnvirPar .AsNoTracking() .ToListAsync(); } diff --git a/EgwCoreLib.Lux.Data/Repository/Config/IConfGlassRepository.cs b/EgwCoreLib.Lux.Data/Repository/Config/IConfGlassRepository.cs index 488e5e1..0959ea8 100644 --- a/EgwCoreLib.Lux.Data/Repository/Config/IConfGlassRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Config/IConfGlassRepository.cs @@ -6,15 +6,15 @@ namespace EgwCoreLib.Lux.Data.Repository.Config { #region Public Methods - void Add(GlassModel entity); + Task AddAsync(GlassModel entity); - void Delete(GlassModel entity); + Task DeleteAsync(GlassModel entity); Task> GetAllAsync(); Task GetByIdAsync(int recId); - void Update(GlassModel entity); + Task UpdateAsync(GlassModel entity); #endregion Public Methods } diff --git a/EgwCoreLib.Lux.Data/Repository/Config/IConfProfileRepository.cs b/EgwCoreLib.Lux.Data/Repository/Config/IConfProfileRepository.cs index 9f13267..5419d02 100644 --- a/EgwCoreLib.Lux.Data/Repository/Config/IConfProfileRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Config/IConfProfileRepository.cs @@ -4,15 +4,15 @@ namespace EgwCoreLib.Lux.Data.Repository.Config { public interface IConfProfileRepository : IBaseRepository { - void Add(ProfileModel entity); + Task AddAsync(ProfileModel entity); - void Delete(ProfileModel entity); + Task DeleteAsync(ProfileModel entity); Task> GetAllAsync(); Task GetByIdAsync(int recId); - void Update(ProfileModel entity); + Task UpdateAsync(ProfileModel entity); } } diff --git a/EgwCoreLib.Lux.Data/Repository/Config/IConfWoodRepository.cs b/EgwCoreLib.Lux.Data/Repository/Config/IConfWoodRepository.cs index 9856e0e..95a5797 100644 --- a/EgwCoreLib.Lux.Data/Repository/Config/IConfWoodRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Config/IConfWoodRepository.cs @@ -4,15 +4,15 @@ namespace EgwCoreLib.Lux.Data.Repository.Config { public interface IConfWoodRepository : IBaseRepository { - void Add(WoodModel entity); + Task AddAsync(WoodModel entity); - void Delete(WoodModel entity); + Task DeleteAsync(WoodModel entity); Task> GetAllAsync(); Task GetByIdAsync(int recId); - void Update(WoodModel entity); + Task UpdateAsync(WoodModel entity); } } diff --git a/EgwCoreLib.Lux.Data/Repository/IBaseRepository.cs b/EgwCoreLib.Lux.Data/Repository/IBaseRepository.cs index 4094a92..5c3bdde 100644 --- a/EgwCoreLib.Lux.Data/Repository/IBaseRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/IBaseRepository.cs @@ -2,6 +2,7 @@ { public interface IBaseRepository { - Task SaveChangesAsync(); + //Task CreateContextAsync(); + //Task SaveChangesAsync(DataLayerContext ctx); } } diff --git a/EgwCoreLib.Lux.Data/Repository/Items/ISellingItemRepository.cs b/EgwCoreLib.Lux.Data/Repository/Items/ISellingItemRepository.cs index a63f533..5dd51fa 100644 --- a/EgwCoreLib.Lux.Data/Repository/Items/ISellingItemRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Items/ISellingItemRepository.cs @@ -7,9 +7,9 @@ namespace EgwCoreLib.Lux.Data.Repository.Items { #region Public Methods - void Add(SellingItemModel entity); + Task AddAsync(SellingItemModel entity); - void Delete(SellingItemModel entity); + Task DeleteAsync(SellingItemModel entity); Task GetByIdAsync(int recId); @@ -17,7 +17,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Items Task> GetFiltAsync(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS envir, ItemSourceType sourceType); - void Update(SellingItemModel entity); + Task UpdateAsync(SellingItemModel entity); #endregion Public Methods } diff --git a/EgwCoreLib.Lux.Data/Repository/Items/SellingItemRepository.cs b/EgwCoreLib.Lux.Data/Repository/Items/SellingItemRepository.cs index 89eb3bb..f1ada4a 100644 --- a/EgwCoreLib.Lux.Data/Repository/Items/SellingItemRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Items/SellingItemRepository.cs @@ -9,7 +9,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Items { #region Public Constructors - public SellingItemRepository(DataLayerContext db) : base(db) + public SellingItemRepository(IDbContextFactory ctxFactory) : base(ctxFactory) { } @@ -17,51 +17,64 @@ namespace EgwCoreLib.Lux.Data.Repository.Items #region Public Methods - public void Add(SellingItemModel entity) => _dbCtx.DbSetSellItem.Add(entity); - - - public void Delete(SellingItemModel entity) => _dbCtx.DbSetSellItem.Remove(entity); - - - public async Task GetByIdAsync(int recId) + public async Task AddAsync(SellingItemModel entity) { - return await _dbCtx.DbSetSellItem - .Where(x => x.SellingItemID == recId) - .FirstOrDefaultAsync(); + await using var dbCtx = await CreateContextAsync(); + await dbCtx.DbSetSellItem.AddAsync(entity); + return await dbCtx.SaveChangesAsync() > 0; + } + + public async Task DeleteAsync(SellingItemModel entity) + { + await using var dbCtx = await CreateContextAsync(); + dbCtx.DbSetSellItem.Remove(entity); + return await dbCtx.SaveChangesAsync() > 0; } public async Task> GetByEnvirAsync(Constants.EXECENVIRONMENTS envir) { - return await _dbCtx.DbSetSellItem + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetSellItem .Where(x => x.Envir == envir) .AsNoTracking() .ToListAsync(); } + public async Task GetByIdAsync(int recId) + { + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetSellItem + .Where(x => x.SellingItemID == recId) + .FirstOrDefaultAsync(); + } + public async Task> GetFiltAsync(Constants.EXECENVIRONMENTS envir, ItemSourceType sourceType) { - return await _dbCtx.DbSetSellItem + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetSellItem .Where(x => (x.Envir == envir || envir == Constants.EXECENVIRONMENTS.NULL) && (sourceType == ItemSourceType.ND || x.SourceType == sourceType)) .AsNoTracking() .ToListAsync(); } - public void Update(SellingItemModel entity) + public async Task UpdateAsync(SellingItemModel entity) { + await using var dbCtx = await CreateContextAsync(); // Recuperiamo l'entità tracciata dal context - var trackedEntity = _dbCtx.DbSetSellItem.Local.FirstOrDefault(x => x.SellingItemID == entity.SellingItemID); + var trackedEntity = dbCtx.DbSetSellItem.Local.FirstOrDefault(x => x.SellingItemID == entity.SellingItemID); if (trackedEntity != null) { // Aggiorna i valori dell'entità tracciata con quelli della nuova - _dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity); + dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity); } else { - _dbCtx.DbSetSellItem.Update(entity); + dbCtx.DbSetSellItem.Update(entity); } + return await dbCtx.SaveChangesAsync() > 0; } #endregion Public Methods } -} +} \ No newline at end of file diff --git a/EgwCoreLib.Lux.Data/Repository/Utils/GenClassRepository.cs b/EgwCoreLib.Lux.Data/Repository/Utils/GenClassRepository.cs index ef145e7..6c1c0e2 100644 --- a/EgwCoreLib.Lux.Data/Repository/Utils/GenClassRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Utils/GenClassRepository.cs @@ -7,48 +7,66 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils { #region Public Constructors - public GenClassRepository(DataLayerContext db) : base(db) + public GenClassRepository(IDbContextFactory ctxFactory) : base(ctxFactory) { } #endregion Public Constructors #region Public Methods + public async Task AddAsync(GenClassModel entity) + { + await using var dbCtx = await CreateContextAsync(); + await dbCtx.DbSetGenClass.AddAsync(entity); + return await dbCtx.SaveChangesAsync() > 0; + } + + public async Task DeleteAsync(GenClassModel entity) + { + await using var dbCtx = await CreateContextAsync(); + dbCtx.DbSetGenClass.Remove(entity); + return await dbCtx.SaveChangesAsync() > 0; + } + - public void Add(GenClassModel entity) => _dbCtx.DbSetGenClass.Add(entity); public async Task CountChildrenAsync(string classCod) { - return await _dbCtx.DbSetGenVal.CountAsync(x => x.ClassCod == classCod); + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetGenVal.CountAsync(x => x.ClassCod == classCod); } - public void Delete(GenClassModel entity) => _dbCtx.DbSetGenClass.Remove(entity); public async Task> GetAllAsync() { - // EF Core 8 è già molto veloce, lasciamo che l'eccezione salga - return await _dbCtx.DbSetGenClass + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetGenClass .Include(o => o.GenValNav) .AsNoTracking() .ToListAsync(); } - public async Task GetByCodeAsync(string code) => - await _dbCtx.DbSetGenClass.FirstOrDefaultAsync(x => x.ClassCod == code); - - public void Update(GenClassModel entity) + public async Task GetByCodeAsync(string code) { + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetGenClass.FirstOrDefaultAsync(x => x.ClassCod == code); + } + + public async Task UpdateAsync(GenClassModel entity) + { + await using var dbCtx = await CreateContextAsync(); // Recuperiamo l'entità tracciata dal context - var trackedEntity = _dbCtx.DbSetGenClass.Local.FirstOrDefault(x => x.ClassCod == entity.ClassCod); + var trackedEntity = dbCtx.DbSetGenClass.Local.FirstOrDefault(x => x.ClassCod == entity.ClassCod); if (trackedEntity != null) { // Aggiorna i valori dell'entità tracciata con quelli della nuova - _dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity); + dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity); } else { - _dbCtx.DbSetGenClass.Update(entity); + dbCtx.DbSetGenClass.Update(entity); } + return await dbCtx.SaveChangesAsync() > 0; } #endregion Public Methods diff --git a/EgwCoreLib.Lux.Data/Repository/Utils/GenValRepository.cs b/EgwCoreLib.Lux.Data/Repository/Utils/GenValRepository.cs index f20ff34..f4ff6fa 100644 --- a/EgwCoreLib.Lux.Data/Repository/Utils/GenValRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Utils/GenValRepository.cs @@ -7,7 +7,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils { #region Public Constructors - public GenValRepository(DataLayerContext db) : base(db) + public GenValRepository(IDbContextFactory ctxFactory) : base(ctxFactory) { } @@ -15,42 +15,52 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils #region Public Methods - public void Add(GenValueModel entity) => _dbCtx.DbSetGenVal.Add(entity); + public async Task AddAsync(GenValueModel entity) + { + await using var dbCtx = await CreateContextAsync(); + await dbCtx.DbSetGenVal.AddAsync(entity); + return await dbCtx.SaveChangesAsync() > 0; + } public async Task DeleteAsync(GenValueModel rec2del) { + await using var dbCtx = await CreateContextAsync(); + // 1. Recupero il record da eliminare - var dbResult = await _dbCtx.DbSetGenVal + var dbResult = await dbCtx.DbSetGenVal .FirstOrDefaultAsync(x => x.GenValID == rec2del.GenValID); if (dbResult == null) return false; // 2. Recupero i record successivi da shiftare - var list2Move = await _dbCtx.DbSetGenVal + var list2Move = await dbCtx.DbSetGenVal .Where(x => x.ClassCod == rec2del.ClassCod && x.Index > dbResult.Index) .ToListAsync(); foreach (var item in list2Move) { item.Index--; - _dbCtx.Entry(item).State = EntityState.Modified; + dbCtx.Entry(item).State = EntityState.Modified; } // 3. Rimuovo il record - _dbCtx.DbSetGenVal.Remove(dbResult); + dbCtx.DbSetGenVal.Remove(dbResult); // 4. Salvo tutto - return await _dbCtx.SaveChangesAsync() > 0; + return await dbCtx.SaveChangesAsync() > 0; } - - public async Task GetByIdAsync(int Id) => - await _dbCtx.DbSetGenVal.FirstOrDefaultAsync(x => x.GenValID == Id); + public async Task GetByIdAsync(int Id) + { + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetGenVal.FirstOrDefaultAsync(x => x.GenValID == Id); + } public async Task> GetFiltAsync(string codClass) { - return await _dbCtx.DbSetGenVal + await using var dbCtx = await CreateContextAsync(); + return await dbCtx.DbSetGenVal .Where(x => x.ClassCod == codClass) .AsNoTracking() .ToListAsync(); @@ -58,15 +68,16 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils public async Task MoveAsync(GenValueModel selRec, bool moveUp) { + await using var dbCtx = await CreateContextAsync(); // 1. Recupero il record corrente - var currRec = await _dbCtx.DbSetGenVal + var currRec = await dbCtx.DbSetGenVal .FirstOrDefaultAsync(x => x.GenValID == selRec.GenValID); if (currRec == null) return false; // 2. Numero totale record della classe - int numRec = await _dbCtx.DbSetGenVal + int numRec = await dbCtx.DbSetGenVal .CountAsync(x => x.ClassCod == selRec.ClassCod); // 3. Calcolo nuova posizione @@ -77,7 +88,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils return false; // 4. Recupero il record da scambiare - var otherRec = await _dbCtx.DbSetGenVal + var otherRec = await dbCtx.DbSetGenVal .FirstOrDefaultAsync(x => x.ClassCod == selRec.ClassCod && x.Index == newPos); if (otherRec == null) @@ -87,27 +98,29 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils otherRec.Index = currRec.Index; currRec.Index = newPos; - _dbCtx.Entry(otherRec).State = EntityState.Modified; - _dbCtx.Entry(currRec).State = EntityState.Modified; + dbCtx.Entry(otherRec).State = EntityState.Modified; + dbCtx.Entry(currRec).State = EntityState.Modified; // 6. Salvo - return await _dbCtx.SaveChangesAsync() > 0; + return await dbCtx.SaveChangesAsync() > 0; } - public void Update(GenValueModel entity) + public async Task UpdateAsync(GenValueModel entity) { + await using var dbCtx = await CreateContextAsync(); // Recuperiamo l'entità tracciata dal context - var trackedEntity = _dbCtx.DbSetGenVal.Local.FirstOrDefault(x => x.GenValID == entity.GenValID); + var trackedEntity = dbCtx.DbSetGenVal.Local.FirstOrDefault(x => x.GenValID == entity.GenValID); if (trackedEntity != null) { // Aggiorna i valori dell'entità tracciata con quelli della nuova - _dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity); + dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity); } else { - _dbCtx.DbSetGenVal.Update(entity); + dbCtx.DbSetGenVal.Update(entity); } + return await dbCtx.SaveChangesAsync() > 0; } #endregion Public Methods diff --git a/EgwCoreLib.Lux.Data/Repository/Utils/IGenClassRepository.cs b/EgwCoreLib.Lux.Data/Repository/Utils/IGenClassRepository.cs index 5554654..391e259 100644 --- a/EgwCoreLib.Lux.Data/Repository/Utils/IGenClassRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Utils/IGenClassRepository.cs @@ -6,17 +6,17 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils { #region Public Methods - void Add(GenClassModel entity); + Task AddAsync(GenClassModel entity); Task CountChildrenAsync(string classCod); - void Delete(GenClassModel entity); + Task DeleteAsync(GenClassModel entity); Task> GetAllAsync(); Task GetByCodeAsync(string code); - void Update(GenClassModel entity); + Task UpdateAsync(GenClassModel entity); #endregion Public Methods } diff --git a/EgwCoreLib.Lux.Data/Repository/Utils/IGenValRepository.cs b/EgwCoreLib.Lux.Data/Repository/Utils/IGenValRepository.cs index febaa00..697ddf9 100644 --- a/EgwCoreLib.Lux.Data/Repository/Utils/IGenValRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Utils/IGenValRepository.cs @@ -6,7 +6,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils { #region Public Methods - void Add(GenValueModel entity); + Task AddAsync(GenValueModel entity); Task DeleteAsync(GenValueModel entity); @@ -16,7 +16,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils Task MoveAsync(GenValueModel selRec, bool moveUp); - void Update(GenValueModel entity); + Task UpdateAsync(GenValueModel entity); #endregion Public Methods } diff --git a/EgwCoreLib.Lux.Data/Services/BaseServ.cs b/EgwCoreLib.Lux.Data/Services/BaseServ.cs index a2e6397..9aa6b59 100644 --- a/EgwCoreLib.Lux.Data/Services/BaseServ.cs +++ b/EgwCoreLib.Lux.Data/Services/BaseServ.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json; using NLog; using StackExchange.Redis; +using System.Collections.Concurrent; using System.Diagnostics; using System.Runtime.CompilerServices; @@ -308,7 +309,7 @@ namespace EgwCoreLib.Lux.Data.Services } return result!; - } + } #endif /// @@ -321,10 +322,9 @@ namespace EgwCoreLib.Lux.Data.Services /// protected async Task GetOrSetCacheAsync(string key, Func> factory, TimeSpan? expiration = null, [CallerMemberName] string? caller = null) { + using var activity = StartActivity(); string source = "DB"; - //// 🔍 Ricavo il nome del metodo chiamante dalla factory - //string caller = factory.Method.DeclaringType?.Name + "." + factory.Method.Name; // 1. Provo Redis var cached = await _redisDb.StringGetAsync(key); @@ -334,7 +334,6 @@ namespace EgwCoreLib.Lux.Data.Services var cachedResult = JsonConvert.DeserializeObject(cached!)!; activity?.SetTag("data.source", source); - //LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms", LogLevel.Trace, caller); return cachedResult; @@ -360,7 +359,6 @@ namespace EgwCoreLib.Lux.Data.Services return result!; } - /// /// Helper trace messaggio log (SE abilitato) /// @@ -414,6 +412,8 @@ namespace EgwCoreLib.Lux.Data.Services #region Private Fields + private static readonly ConcurrentDictionary _locks = new(); + /// /// Durata della cache lunga in secondi (predefinito: 5 minuti) /// Utilizzato nella proprietà LongCache per definire quanto a lungo i dati devono essere memorizzati in cache. diff --git a/EgwCoreLib.Lux.Data/Services/Catalog/TemplateRowService.cs b/EgwCoreLib.Lux.Data/Services/Catalog/TemplateRowService.cs index 1b1ea27..ae31ef5 100644 --- a/EgwCoreLib.Lux.Data/Services/Catalog/TemplateRowService.cs +++ b/EgwCoreLib.Lux.Data/Services/Catalog/TemplateRowService.cs @@ -56,8 +56,7 @@ namespace EgwCoreLib.Lux.Data.Services.Utils var dbResult = await _repo.GetRowAsync(rec2del.TemplateRowID); if (dbResult == null) return false; - _repo.Delete(dbResult); - bool success = await _repo.SaveChangesAsync(); + bool success = await _repo.DeleteAsync(dbResult); if (success) { @@ -166,7 +165,7 @@ namespace EgwCoreLib.Lux.Data.Services.Utils activity?.SetTag("db.operation", "UPDATE"); - bool success = await _repo.SaveChangesAsync(); + bool success = await _repo.UpdateAsync(currRec); if (success && flushCache) { @@ -201,7 +200,7 @@ namespace EgwCoreLib.Lux.Data.Services.Utils activity?.SetTag("db.operation", "UPDATE"); - bool success = await _repo.SaveChangesAsync(); + bool success = await _repo.UpdateAsync(currRec); if (success) { @@ -234,7 +233,7 @@ namespace EgwCoreLib.Lux.Data.Services.Utils activity?.SetTag("db.operation", "UPDATE"); - bool success = await _repo.SaveChangesAsync(); + bool success = await _repo.UpdateAsync(currRec); if (success) { @@ -258,21 +257,20 @@ namespace EgwCoreLib.Lux.Data.Services.Utils var currRec = await _repo.GetRowAsync(upsRec.TemplateRowID); string operation = "UPDATE"; + bool success = false; if (currRec != null) { - _repo.Update(upsRec); + success = await _repo.UpdateAsync(upsRec); } else { operation = "INSERT"; - _repo.Add(upsRec); + success = await _repo.AddAsync(upsRec); } activity?.SetTag("db.operation", operation); - bool success = await _repo.SaveChangesAsync(); - if (success) { await ClearCacheAsync($"{_redisBaseKey}:Template:*"); diff --git a/EgwCoreLib.Lux.Data/Services/Catalog/TemplateService.cs b/EgwCoreLib.Lux.Data/Services/Catalog/TemplateService.cs index e1294b3..4ce7609 100644 --- a/EgwCoreLib.Lux.Data/Services/Catalog/TemplateService.cs +++ b/EgwCoreLib.Lux.Data/Services/Catalog/TemplateService.cs @@ -56,25 +56,18 @@ namespace EgwCoreLib.Lux.Data.Services.Utils { return await TraceAsync("Template.Delete", async (activity) => { - // 1. Recupero il record (usando il Repository) var dbResult = await _repo.GetByIdAsync(rec2del.TemplateID); if (dbResult == null) return false; - // 2. Controllo se ci sono figli (Regola di Business) var numChild = await _repo.CountChildrenAsync(rec2del.TemplateID); if (numChild > 0) { activity?.SetTag("delete.status", "rejected_has_children"); - // Qui potresti anche lanciare un'eccezione custom tipo "HasChildrenException" return false; } - // 3. Eseguo la cancellazione - _repo.Delete(dbResult); - bool success = await _repo.SaveChangesAsync(); - - // 4. Se ha avuto successo, pulisco la cache + bool success = await _repo.DeleteAsync(dbResult); if (success) { await ClearCacheAsync($"{_redisBaseKey}:Template:*"); @@ -101,48 +94,6 @@ namespace EgwCoreLib.Lux.Data.Services.Utils }); } - /// - /// Upsert record Template - /// - /// - /// - public async Task UpsertAsync(TemplateModel upsRec) - { - return await TraceAsync("Template.Upsert", async (activity) => - { - // 1. Cerco se esiste già - var currRec = await _repo.GetByIdAsync(upsRec.TemplateID); - - string operation = "UPDATE"; - - if (currRec != null) - { - // SE TROVATO -> AGGIORNO - _repo.Update(upsRec); - } - else - { - // SE MANCA -> AGGIUNGO - operation = "INSERT"; - _repo.Add(upsRec); - } - - activity?.SetTag("db.operation", operation); - - // 2. Salvo - bool success = await _repo.SaveChangesAsync(); - - // 3. Se salvato con successo, pulisco la cache correlata - if (success) - { - await ClearCacheAsync($"{_redisBaseKey}:Template:*"); - await ClearCacheAsync($"{_redisBaseKey}:TemplateRows:*"); - } - - return success; - }); - } - /// /// Effettua update dei costi di tutte le righe del template indicato /// @@ -207,6 +158,41 @@ namespace EgwCoreLib.Lux.Data.Services.Utils }); } + /// + /// Upsert record Template + /// + /// + /// + public async Task UpsertAsync(TemplateModel upsRec) + { + return await TraceAsync("Template.Upsert", async (activity) => + { + var currRec = await _repo.GetByIdAsync(upsRec.TemplateID); + + string operation = "UPDATE"; + bool success = false; + if (currRec != null) + { + success = await _repo.UpdateAsync(upsRec); + } + else + { + operation = "INSERT"; + success = await _repo.AddAsync(upsRec); + } + + activity?.SetTag("db.operation", operation); + + if (success) + { + await ClearCacheAsync($"{_redisBaseKey}:Template:*"); + await ClearCacheAsync($"{_redisBaseKey}:TemplateRows:*"); + } + + return success; + }); + } + #endregion Public Methods #region Private Fields diff --git a/EgwCoreLib.Lux.Data/Services/Config/ConfGlassService.cs b/EgwCoreLib.Lux.Data/Services/Config/ConfGlassService.cs index 0622c66..344a572 100644 --- a/EgwCoreLib.Lux.Data/Services/Config/ConfGlassService.cs +++ b/EgwCoreLib.Lux.Data/Services/Config/ConfGlassService.cs @@ -29,10 +29,8 @@ namespace EgwCoreLib.Lux.Data.Services.Config var dbResult = await _repo.GetByIdAsync(rec2del.GlassID); if (dbResult == null) return false; - // 3. Eseguo la cancellazione - _repo.Delete(dbResult); - bool success = await _repo.SaveChangesAsync(); + bool success = await _repo.DeleteAsync(dbResult); // 4. Se ha avuto successo, pulisco la cache if (success) @@ -64,22 +62,20 @@ namespace EgwCoreLib.Lux.Data.Services.Config var currRec = await _repo.GetByIdAsync(upsRec.GlassID); string operation = "UPDATE"; - + bool success = false; if (currRec != null) { upsRec.Code = string.IsNullOrEmpty(upsRec.Code) ? $"{upsRec.GlassID:0000}" : upsRec.Code; - _repo.Update(upsRec); + success = await _repo.UpdateAsync(upsRec); } else { operation = "INSERT"; - _repo.Add(upsRec); + success = await _repo.AddAsync(upsRec); } activity?.SetTag("db.operation", operation); - bool success = await _repo.SaveChangesAsync(); - if (success) { await ClearCacheAsync($"{_redisBaseKey}:{_className}"); @@ -93,8 +89,8 @@ namespace EgwCoreLib.Lux.Data.Services.Config #region Private Fields - private readonly IConfGlassRepository _repo; private readonly string _className; + private readonly IConfGlassRepository _repo; #endregion Private Fields } diff --git a/EgwCoreLib.Lux.Data/Services/Config/ConfProfileService.cs b/EgwCoreLib.Lux.Data/Services/Config/ConfProfileService.cs index f3c22d8..dbf23e4 100644 --- a/EgwCoreLib.Lux.Data/Services/Config/ConfProfileService.cs +++ b/EgwCoreLib.Lux.Data/Services/Config/ConfProfileService.cs @@ -29,10 +29,8 @@ namespace EgwCoreLib.Lux.Data.Services.Config var dbResult = await _repo.GetByIdAsync(rec2del.ProfileID); if (dbResult == null) return false; - // 3. Eseguo la cancellazione - _repo.Delete(dbResult); - bool success = await _repo.SaveChangesAsync(); + bool success = await _repo.DeleteAsync(dbResult); // 4. Se ha avuto successo, pulisco la cache if (success) @@ -64,22 +62,20 @@ namespace EgwCoreLib.Lux.Data.Services.Config var currRec = await _repo.GetByIdAsync(upsRec.ProfileID); string operation = "UPDATE"; - + bool success = false; if (currRec != null) { upsRec.Code = string.IsNullOrEmpty(upsRec.Code) ? $"{upsRec.ProfileID:0000}" : upsRec.Code; - _repo.Update(upsRec); + success = await _repo.UpdateAsync(upsRec); } else { operation = "INSERT"; - _repo.Add(upsRec); + success = await _repo.AddAsync(upsRec); } activity?.SetTag("db.operation", operation); - bool success = await _repo.SaveChangesAsync(); - if (success) { await ClearCacheAsync($"{_redisBaseKey}:{_className}"); @@ -93,8 +89,8 @@ namespace EgwCoreLib.Lux.Data.Services.Config #region Private Fields - private readonly IConfProfileRepository _repo; private readonly string _className; + private readonly IConfProfileRepository _repo; #endregion Private Fields } diff --git a/EgwCoreLib.Lux.Data/Services/Config/ConfWoodService.cs b/EgwCoreLib.Lux.Data/Services/Config/ConfWoodService.cs index bf9b51b..4ed2fab 100644 --- a/EgwCoreLib.Lux.Data/Services/Config/ConfWoodService.cs +++ b/EgwCoreLib.Lux.Data/Services/Config/ConfWoodService.cs @@ -29,10 +29,8 @@ namespace EgwCoreLib.Lux.Data.Services.Config var dbResult = await _repo.GetByIdAsync(rec2del.WoodID); if (dbResult == null) return false; - // 3. Eseguo la cancellazione - _repo.Delete(dbResult); - bool success = await _repo.SaveChangesAsync(); + bool success = await _repo.DeleteAsync(dbResult); // 4. Se ha avuto successo, pulisco la cache if (success) @@ -64,22 +62,20 @@ namespace EgwCoreLib.Lux.Data.Services.Config var currRec = await _repo.GetByIdAsync(upsRec.WoodID); string operation = "UPDATE"; - + bool success = false; if (currRec != null) { upsRec.Code = string.IsNullOrEmpty(upsRec.Code) ? $"{upsRec.WoodID:0000}" : upsRec.Code; - _repo.Update(upsRec); + success = await _repo.UpdateAsync(upsRec); } else { operation = "INSERT"; - _repo.Add(upsRec); + success = await _repo.AddAsync(upsRec); } activity?.SetTag("db.operation", operation); - bool success = await _repo.SaveChangesAsync(); - if (success) { await ClearCacheAsync($"{_redisBaseKey}:{_className}"); @@ -93,8 +89,8 @@ namespace EgwCoreLib.Lux.Data.Services.Config #region Private Fields - private readonly IConfWoodRepository _repo; private readonly string _className; + private readonly IConfWoodRepository _repo; #endregion Private Fields } diff --git a/EgwCoreLib.Lux.Data/Services/Items/SellingItemService.cs b/EgwCoreLib.Lux.Data/Services/Items/SellingItemService.cs index 591db62..57c4ef7 100644 --- a/EgwCoreLib.Lux.Data/Services/Items/SellingItemService.cs +++ b/EgwCoreLib.Lux.Data/Services/Items/SellingItemService.cs @@ -7,7 +7,6 @@ using static EgwCoreLib.Lux.Core.Enums; namespace EgwCoreLib.Lux.Data.Services.Items { - public class SellingItemService : BaseServ, ISellingItemService { #region Public Constructors @@ -31,8 +30,7 @@ namespace EgwCoreLib.Lux.Data.Services.Items var dbResult = await _repo.GetByIdAsync(rec2del.SellingItemID); if (dbResult == null) return false; - _repo.Delete(dbResult); - bool success = await _repo.SaveChangesAsync(); + bool success = await _repo.DeleteAsync(dbResult); if (success) { @@ -43,6 +41,19 @@ namespace EgwCoreLib.Lux.Data.Services.Items }); } + public async Task> GetByEnvirAsync(Constants.EXECENVIRONMENTS envir) + { + // Uso helper TraceAsync che gestisce automaticamente StartActivity, Log e Exception tracking + return await TraceAsync("SellingItem.GetByEnvir", async (activity) => + { + return await GetOrSetCacheAsync( + $"{_redisBaseKey}:SellingItem:{envir}", + async () => await _repo.GetByEnvirAsync(envir), + UltraLongCache + ); + }); + } + public async Task> GetFiltAsync(Constants.EXECENVIRONMENTS envir, ItemSourceType sourceType) { // Uso helper TraceAsync che gestisce automaticamente StartActivity, Log e Exception tracking @@ -55,18 +66,6 @@ namespace EgwCoreLib.Lux.Data.Services.Items ); }); } - public async Task> GetByEnvirAsync(Constants.EXECENVIRONMENTS envir) - { - // Uso helper TraceAsync che gestisce automaticamente StartActivity, Log e Exception tracking - return await TraceAsync("SellingItem.GetByEnvir", async (activity) => - { - return await GetOrSetCacheAsync( - $"{_redisBaseKey}:SellingItem:{envir}", - async () => await _repo.GetByEnvirAsync(envir), - UltraLongCache - ); - }); - } public async Task UpdateFileDataAsync(SellingItemModel updRec) { @@ -76,7 +75,7 @@ namespace EgwCoreLib.Lux.Data.Services.Items var currRec = await _repo.GetByIdAsync(updRec.SellingItemID); string operation = "UPDATE"; - + bool success = false; if (currRec != null) { currRec.FileName = updRec.FileName; @@ -94,13 +93,11 @@ namespace EgwCoreLib.Lux.Data.Services.Items currRec.ImgType = ImageType.Fixed; } } - _repo.Update(currRec); + success = await _repo.UpdateAsync(currRec); } activity?.SetTag("db.operation", operation); - bool success = await _repo.SaveChangesAsync(); - if (success) { await ClearCacheAsync($"{_redisBaseKey}:SellingItem:*"); @@ -109,6 +106,7 @@ namespace EgwCoreLib.Lux.Data.Services.Items return success; }); } + public async Task UpsertAsync(SellingItemModel upsRec) { return await TraceAsync("SellingItem.Upsert", async (activity) => @@ -117,21 +115,20 @@ namespace EgwCoreLib.Lux.Data.Services.Items var currRec = await _repo.GetByIdAsync(upsRec.SellingItemID); string operation = "UPDATE"; + bool success = false; if (currRec != null) { - _repo.Update(upsRec); + success = await _repo.UpdateAsync(upsRec); } else { operation = "INSERT"; - _repo.Add(upsRec); + success = await _repo.AddAsync(upsRec); } activity?.SetTag("db.operation", operation); - bool success = await _repo.SaveChangesAsync(); - if (success) { await ClearCacheAsync($"{_redisBaseKey}:SellingItem:*"); @@ -149,4 +146,4 @@ namespace EgwCoreLib.Lux.Data.Services.Items #endregion Private Fields } -} +} \ No newline at end of file diff --git a/EgwCoreLib.Lux.Data/Services/Utils/GenClassService.cs b/EgwCoreLib.Lux.Data/Services/Utils/GenClassService.cs index 572106a..2c2fb95 100644 --- a/EgwCoreLib.Lux.Data/Services/Utils/GenClassService.cs +++ b/EgwCoreLib.Lux.Data/Services/Utils/GenClassService.cs @@ -25,25 +25,19 @@ namespace EgwCoreLib.Lux.Data.Services.Utils { return await TraceAsync("GenClass.Delete", async (activity) => { - // 1. Recupero il record (usando il Repository) var dbResult = await _repo.GetByCodeAsync(rec2del.ClassCod); if (dbResult == null) return false; - // 2. Controllo se ci sono figli (Regola di Business) var numChild = await _repo.CountChildrenAsync(rec2del.ClassCod); if (numChild > 0) { activity?.SetTag("delete.status", "rejected_has_children"); - // Qui potresti anche lanciare un'eccezione custom tipo "HasChildrenException" return false; } - // 3. Eseguo la cancellazione - _repo.Delete(dbResult); - bool success = await _repo.SaveChangesAsync(); + bool success = await _repo.DeleteAsync(dbResult); - // 4. Se ha avuto successo, pulisco la cache if (success) { await ClearCacheAsync($"{_redisBaseKey}:GenClass*"); @@ -55,7 +49,6 @@ namespace EgwCoreLib.Lux.Data.Services.Utils public async Task> GetAllAsync() { - // Uso helper TraceAsync che gestisce automaticamente StartActivity, Log e Exception tracking return await TraceAsync("GenClass.GetAll", async (activity) => { return await GetOrSetCacheAsync( @@ -70,32 +63,24 @@ namespace EgwCoreLib.Lux.Data.Services.Utils { return await TraceAsync("GenClass.Upsert", async (activity) => { - // 1. Cerco se esiste già var currRec = await _repo.GetByCodeAsync(upsRec.ClassCod); string operation = "UPDATE"; - + bool success = false; if (currRec != null) { - // SE TROVATO -> AGGIORNO - _repo.Update(upsRec); + success = await _repo.UpdateAsync(upsRec); } else { - // SE MANCA -> AGGIUNGO operation = "INSERT"; - _repo.Add(upsRec); + success = await _repo.AddAsync(upsRec); } activity?.SetTag("db.operation", operation); - // 2. Salvo - bool success = await _repo.SaveChangesAsync(); - - // 3. Se salvato con successo, pulisco la cache correlata if (success) { - // Invalido sia la lista classi che eventuali dettagli correlati await ClearCacheAsync($"{_redisBaseKey}:GenClass*"); } diff --git a/EgwCoreLib.Lux.Data/Services/Utils/GenValService.cs b/EgwCoreLib.Lux.Data/Services/Utils/GenValService.cs index 151e3f0..7ef58d0 100644 --- a/EgwCoreLib.Lux.Data/Services/Utils/GenValService.cs +++ b/EgwCoreLib.Lux.Data/Services/Utils/GenValService.cs @@ -49,27 +49,11 @@ namespace EgwCoreLib.Lux.Data.Services.Utils }); } - public async Task UpsertAsync(GenValueModel upsRec) + public async Task MoveAsync(GenValueModel selRec, bool moveUp) { - return await TraceAsync("GenVal.Upsert", async (activity) => + return await TraceAsync("GenVal.MoveAsync", async (activity) => { - var currRec = await _repo.GetByIdAsync(upsRec.GenValID); - - string operation = "UPDATE"; - - if (currRec != null) - { - _repo.Update(upsRec); - } - else - { - operation = "INSERT"; - _repo.Add(upsRec); - } - - activity?.SetTag("db.operation", operation); - - bool success = await _repo.SaveChangesAsync(); + bool success = await _repo.MoveAsync(selRec, moveUp); if (success) { @@ -81,11 +65,25 @@ namespace EgwCoreLib.Lux.Data.Services.Utils }); } - public async Task MoveAsync(GenValueModel selRec, bool moveUp) + public async Task UpsertAsync(GenValueModel upsRec) { - return await TraceAsync("GenVal.MoveAsync", async (activity) => + return await TraceAsync("GenVal.Upsert", async (activity) => { - bool success = await _repo.MoveAsync(selRec, moveUp); + var currRec = await _repo.GetByIdAsync(upsRec.GenValID); + + string operation = "UPDATE"; + bool success = false; + if (currRec != null) + { + success = await _repo.UpdateAsync(upsRec); + } + else + { + operation = "INSERT"; + success = await _repo.AddAsync(upsRec); + } + + activity?.SetTag("db.operation", operation); if (success) { diff --git a/Lux.API/Lux.API.csproj b/Lux.API/Lux.API.csproj index 6ba68f6..b83f5f2 100644 --- a/Lux.API/Lux.API.csproj +++ b/Lux.API/Lux.API.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 1.1.2603.1619 + 1.1.2603.1709 diff --git a/Lux.API/Program.cs b/Lux.API/Program.cs index 63e2b00..59840c3 100644 --- a/Lux.API/Program.cs +++ b/Lux.API/Program.cs @@ -149,7 +149,7 @@ builder.Services.AddSingleton(); var connectionString = builder.Configuration.GetConnectionString("Lux.All") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found."); // DataLayerContext (manca!) -builder.Services.AddDbContext(options => +builder.Services.AddDbContextFactory(options => { var conn = builder.Configuration.GetConnectionString("Lux.All"); options.UseMySql(conn, ServerVersion.AutoDetect(conn), mySqlOptions => diff --git a/Lux.UI/Components/Compo/Config/GlassMan.razor.cs b/Lux.UI/Components/Compo/Config/GlassMan.razor.cs index 691156a..4c36af2 100644 --- a/Lux.UI/Components/Compo/Config/GlassMan.razor.cs +++ b/Lux.UI/Components/Compo/Config/GlassMan.razor.cs @@ -27,7 +27,7 @@ namespace Lux.UI.Components.Compo.Config if (searchVal != value) { searchVal = value; - _ = FullUpdate(); + UpdateTable(); } } } @@ -108,6 +108,7 @@ namespace Lux.UI.Components.Compo.Config #region Private Fields private List AllRecords = new(); + private List SearchRecords = new(); private int currPage = 1; private GlassModel? EditRecord = null; private bool isLoading = false; @@ -142,47 +143,18 @@ namespace Lux.UI.Components.Compo.Config { // salvo await CGService.UpsertAsync(currRec); - await ResetEdit(); - UpdateTable(); + await ReloadData(); EditRecord = null; SelRecord = null; + UpdateTable(); } - private async Task FullUpdate() - { - await ReloadData(); - UpdateTable(); - await InvokeAsync(StateHasChanged); - } private async Task ReloadData() { isLoading = true; AllRecords = await CGService.GetAllAsync(); - // se ho ricerca testuale faccio filtro ulteriore... - if (string.IsNullOrEmpty(SearchVal)) - { - AllRecords = AllRecords - .OrderBy(x => x.Description) - .ToList(); - } - else - { - AllRecords = AllRecords - .Where(x => - x.Description.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase) || - x.Code.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase)) - .OrderBy(x => x.Description) - .ToList(); - } - totalCount = AllRecords.Count; - } - private Task ResetEdit() - { - // reset edit - EditRecord = null; - return ReloadData(); } /// @@ -190,8 +162,25 @@ namespace Lux.UI.Components.Compo.Config /// private void UpdateTable() { + // se ho ricerca testuale faccio filtro ulteriore... + if (string.IsNullOrEmpty(SearchVal)) + { + SearchRecords = AllRecords + .OrderBy(x => x.Description) + .ToList(); + } + else + { + SearchRecords = AllRecords + .Where(x => + x.Description.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase) || + x.Code.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase)) + .OrderBy(x => x.Description) + .ToList(); + } + totalCount = SearchRecords.Count; // fix paginazione - ListRecords = AllRecords + ListRecords = SearchRecords .Skip(numRecord * (currPage - 1)) .Take(numRecord) .ToList(); diff --git a/Lux.UI/Components/Compo/Config/WoodMan.razor.cs b/Lux.UI/Components/Compo/Config/WoodMan.razor.cs index 5b0785a..72e62df 100644 --- a/Lux.UI/Components/Compo/Config/WoodMan.razor.cs +++ b/Lux.UI/Components/Compo/Config/WoodMan.razor.cs @@ -8,99 +8,13 @@ namespace Lux.UI.Components.Compo.Config { public partial class WoodMan { - #region Protected Properties - - [Inject] - protected IConfWoodService CWService { get; set; } = null!; - - [Inject] - protected DataLayerServices DLService { get; set; } = null!; - - [Inject] - protected IJSRuntime JSRuntime { get; set; } = null!; - - protected string SearchVal - { - get => searchVal; - set - { - if (searchVal != value) - { - searchVal = value; - _ = FullUpdate(); - } - } - } - - #endregion Protected Properties - #region Protected Methods - /// - /// impossta record x eliminazione - /// - /// - protected async Task DoDelete(WoodModel selRec) - { - if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler eliminare il record? Dettagli: {selRec.WoodID} | {selRec.Description} | Tipo: {selRec.Type}")) - return; - - // esegue eliminazione del record... - await CWService.DeleteAsync(selRec); - - EditRecord = null; - SelRecord = null; - await ReloadData(); - UpdateTable(); - } - - /// - /// Edit articolo selezionato - /// - /// - protected void DoEdit(WoodModel curRec) - { - EditRecord = curRec; - } - - /// - /// Reset selezione - /// - protected void DoReset() - { - EditRecord = null; - } - - /// - /// Selezione articolo x display info - /// - /// - protected void DoSelect(WoodModel curRec) - { - SelRecord = curRec; - } - protected override async Task OnParametersSetAsync() { await ReloadData(); UpdateTable(); - } - - protected void ResetSearch() - { - SearchVal = ""; - } - - protected void SaveNumRec(int newNum) - { - numRecord = newNum; - UpdateTable(); - } - - protected void SavePage(int newNum) - { - currPage = newNum; - UpdateTable(); + await InvokeAsync(StateHasChanged); } #endregion Protected Methods @@ -113,15 +27,39 @@ namespace Lux.UI.Components.Compo.Config private bool isLoading = false; private List ListRecords = new(); private int numRecord = 5; + private List SearchRecords = new(); private WoodModel? SelRecord = null; + private int totalCount = 0; #endregion Private Fields #region Private Properties + [Inject] + private IConfWoodService CWService { get; set; } = null!; + + [Inject] + private DataLayerServices DLService { get; set; } = null!; + + [Inject] + private IJSRuntime JSRuntime { get; set; } = null!; + private string searchVal { get; set; } = string.Empty; + private string SearchVal + { + get => searchVal; + set + { + if (searchVal != value) + { + searchVal = value; + UpdateTable(); + } + } + } + #endregion Private Properties #region Private Methods @@ -138,6 +76,41 @@ namespace Lux.UI.Components.Compo.Config return DoSave(EditRecord); } + /// + /// impossta record x eliminazione + /// + /// + private async Task DoDelete(WoodModel selRec) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler eliminare il record? Dettagli: {selRec.WoodID} | {selRec.Description} | Tipo: {selRec.Type}")) + return; + + // esegue eliminazione del record... + await CWService.DeleteAsync(selRec); + + EditRecord = null; + SelRecord = null; + await ReloadData(); + UpdateTable(); + } + + /// + /// Edit articolo selezionato + /// + /// + private void DoEdit(WoodModel curRec) + { + EditRecord = curRec; + } + + /// + /// Reset selezione + /// + private void DoReset() + { + EditRecord = null; + } + private async Task DoSave(WoodModel currRec) { // salvo @@ -148,34 +121,19 @@ namespace Lux.UI.Components.Compo.Config SelRecord = null; } - private async Task FullUpdate() + /// + /// Selezione articolo x display info + /// + /// + private void DoSelect(WoodModel curRec) { - await ReloadData(); - UpdateTable(); - await InvokeAsync(StateHasChanged); + SelRecord = curRec; } private async Task ReloadData() { isLoading = true; AllRecords = await CWService.GetAllAsync(); - // se ho ricerca testuale faccio filtro ulteriore... - if (string.IsNullOrEmpty(SearchVal)) - { - AllRecords = AllRecords - .OrderBy(x => x.Description) - .ToList(); - } - else - { - AllRecords = AllRecords - .Where(x => - x.Description.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase) || - x.Code.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase)) - .OrderBy(x => x.Description) - .ToList(); - } - totalCount = AllRecords.Count; } private Task ResetEdit() @@ -185,13 +143,47 @@ namespace Lux.UI.Components.Compo.Config return ReloadData(); } + private void ResetSearch() + { + SearchVal = ""; + } + + private void SaveNumRec(int newNum) + { + numRecord = newNum; + UpdateTable(); + } + + private void SavePage(int newNum) + { + currPage = newNum; + UpdateTable(); + } + /// /// Filtro e paginazione /// private void UpdateTable() { + // se ho ricerca testuale faccio filtro ulteriore... + if (string.IsNullOrEmpty(SearchVal)) + { + SearchRecords = AllRecords + .OrderBy(x => x.Description) + .ToList(); + } + else + { + SearchRecords = AllRecords + .Where(x => + x.Description.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase) || + x.Code.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase)) + .OrderBy(x => x.Description) + .ToList(); + } + totalCount = SearchRecords.Count; // fix paginazione - ListRecords = AllRecords + ListRecords = SearchRecords .Skip(numRecord * (currPage - 1)) .Take(numRecord) .ToList(); diff --git a/Lux.UI/Lux.UI.csproj b/Lux.UI/Lux.UI.csproj index dcc7c53..d2c88b5 100644 --- a/Lux.UI/Lux.UI.csproj +++ b/Lux.UI/Lux.UI.csproj @@ -5,7 +5,7 @@ enable enable aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50 - 1.1.2603.1619 + 1.1.2603.1709 diff --git a/Lux.UI/Program.cs b/Lux.UI/Program.cs index 9298948..de1d27a 100644 --- a/Lux.UI/Program.cs +++ b/Lux.UI/Program.cs @@ -164,7 +164,7 @@ builder.Services.AddDbContext(options => }); // DataLayerContext (manca!) -builder.Services.AddDbContext(options => +builder.Services.AddDbContextFactory(options => { var conn = builder.Configuration.GetConnectionString("Lux.All"); options.UseMySql(conn, ServerVersion.AutoDetect(conn), mySqlOptions => diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 9f9ba5f..4243e09 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ LUX - Web Windows MES -

Versione: 1.1.2603.1619

+

Versione: 1.1.2603.1709


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 3932b50..69522fc 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.1.2603.1619 +1.1.2603.1709 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 82fb877..bea3530 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.1.2603.1619 + 1.1.2603.1709 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false