Move Repo/Serv x TagModel...
This commit is contained in:
@@ -7,7 +7,6 @@ using EgwCoreLib.Lux.Data.DbModel.Job;
|
||||
using EgwCoreLib.Lux.Data.DbModel.Production;
|
||||
using EgwCoreLib.Lux.Data.DbModel.Sales;
|
||||
using EgwCoreLib.Lux.Data.DbModel.Stats;
|
||||
using EgwCoreLib.Lux.Data.DbModel.Utils;
|
||||
using EgwCoreLib.Lux.Data.Domains;
|
||||
using EgwMultiEngineManager.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -1179,30 +1178,6 @@ namespace EgwCoreLib.Lux.Data.Controllers
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco completo Tags
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal async Task<List<TagsModel>> TagsGetAllAsync()
|
||||
{
|
||||
List<TagsModel> dbResult = new List<TagsModel>();
|
||||
//using (DataLayerContext dbCtx = new DataLayerContext(_config))
|
||||
using (DataLayerContext dbCtx = new DataLayerContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
dbResult = await dbCtx
|
||||
.DbSetTags
|
||||
.ToListAsync();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante TagsGetAllAsync{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#if true
|
||||
internal bool UpdateCodGroup(List<BomItemDTO> bomList)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using EgwCoreLib.Lux.Data.DbModel.Utils;
|
||||
|
||||
namespace EgwCoreLib.Lux.Data.Repository.Utils
|
||||
{
|
||||
public interface ITagRepository
|
||||
{
|
||||
Task<List<TagsModel>> GetAllAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using EgwCoreLib.Lux.Data.DbModel.Utils;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EgwCoreLib.Lux.Data.Repository.Utils
|
||||
{
|
||||
public class TagRepository : BaseRepository, ITagRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public TagRepository(IDbContextFactory<DataLayerContext> ctxFactory) : base(ctxFactory)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public async Task<List<TagsModel>> GetAllAsync()
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
return await dbCtx.DbSetTags
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ using EgwCoreLib.Lux.Data.DbModel.Cost;
|
||||
using EgwCoreLib.Lux.Data.DbModel.Job;
|
||||
using EgwCoreLib.Lux.Data.DbModel.Production;
|
||||
using EgwCoreLib.Lux.Data.DbModel.Sales;
|
||||
using EgwCoreLib.Lux.Data.DbModel.Utils;
|
||||
using EgwMultiEngineManager.Data;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
@@ -642,40 +641,6 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco completo Tags disponibili
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<TagsModel>> TagsGetAllAsync()
|
||||
{
|
||||
using var activity = StartActivity();
|
||||
string source = "DB";
|
||||
List<TagsModel>? result = new List<TagsModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Tags:ALL";
|
||||
RedisValue rawData = _redisDb.StringGet(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<TagsModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await dbController.TagsGetAllAsync();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
_redisDb.StringSet(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<TagsModel>();
|
||||
}
|
||||
// aggiunta tags + log
|
||||
activity?.SetTag("data.source", source);
|
||||
LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
using EgwCoreLib.Lux.Data.DbModel.Utils;
|
||||
|
||||
namespace EgwCoreLib.Lux.Data.Services.Utils
|
||||
{
|
||||
|
||||
public interface ITagService
|
||||
{
|
||||
Task<List<TagsModel>> GetAllAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using EgwCoreLib.Lux.Data.DbModel.Utils;
|
||||
using EgwCoreLib.Lux.Data.Repository.Utils;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace EgwCoreLib.Lux.Data.Services.Utils
|
||||
{
|
||||
public class TagService : BaseServ, ITagService
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public TagService(
|
||||
IConfiguration config,
|
||||
IConnectionMultiplexer redis,
|
||||
ITagRepository repo) : base(config, redis)
|
||||
{
|
||||
_className = "Tag";
|
||||
_repo = repo;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public async Task<List<TagsModel>> GetAllAsync()
|
||||
{
|
||||
return await TraceAsync($"{_className}.GetAll", async (activity) =>
|
||||
{
|
||||
return await GetOrSetCacheAsync(
|
||||
$"{_redisBaseKey}:{_className}:ALL",
|
||||
async () => await _repo.GetAllAsync(),
|
||||
UltraLongCache
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly string _className;
|
||||
private readonly ITagRepository _repo;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -196,6 +196,7 @@ builder.Services.AddScoped<IProductionOdlRepository, ProductionOdlRepository>();
|
||||
builder.Services.AddScoped<IProductionPlantRepository, ProductionPlantRepository>();
|
||||
builder.Services.AddScoped<IResourceRepository, ResourceRepository>();
|
||||
builder.Services.AddScoped<ISellingItemRepository, SellingItemRepository>();
|
||||
builder.Services.AddScoped<ITagRepository, TagRepository>();
|
||||
builder.Services.AddScoped<ITemplateRepository, TemplateRepository>();
|
||||
builder.Services.AddScoped<ITemplateRowRepository, TemplateRowRepository>();
|
||||
|
||||
@@ -221,6 +222,7 @@ builder.Services.AddScoped<IProductionOdlService, ProductionOdlService>();
|
||||
builder.Services.AddScoped<IProductionPlantService, ProductionPlantService>();
|
||||
builder.Services.AddScoped<IResourceService, ResourceService>();
|
||||
builder.Services.AddScoped<ISellingItemService, SellingItemService>();
|
||||
builder.Services.AddScoped<ITagService, TagService>();
|
||||
builder.Services.AddScoped<ITemplateService, TemplateService>();
|
||||
builder.Services.AddScoped<ITemplateRowService, TemplateRowService>();
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using EgwCoreLib.Lux.Data.DbModel.Job;
|
||||
using EgwCoreLib.Lux.Data.Services;
|
||||
using EgwCoreLib.Lux.Data.Services.Cost;
|
||||
using EgwCoreLib.Lux.Data.Services.Job;
|
||||
using EgwCoreLib.Lux.Data.Services.Utils;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Lux.UI.Components.Pages
|
||||
@@ -23,6 +24,9 @@ namespace Lux.UI.Components.Pages
|
||||
[Inject]
|
||||
protected IResourceService ResService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected ITagService TagService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
@@ -74,7 +78,7 @@ namespace Lux.UI.Components.Pages
|
||||
private async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
var rawTags = await DLService.TagsGetAllAsync();
|
||||
var rawTags = await TagService.GetAllAsync();
|
||||
ListTagsAvailable = rawTags.Select(x => x.CodTag).ToList();
|
||||
ListCostDrivers = await DLService.CostDriverGetAllAsync();
|
||||
ListPhases = await DLService.PhasesGetAllAsync();
|
||||
|
||||
@@ -234,6 +234,7 @@ builder.Services.AddScoped<IProductionOdlRepository, ProductionOdlRepository>();
|
||||
builder.Services.AddScoped<IProductionPlantRepository, ProductionPlantRepository>();
|
||||
builder.Services.AddScoped<IResourceRepository, ResourceRepository>();
|
||||
builder.Services.AddScoped<ISellingItemRepository, SellingItemRepository>();
|
||||
builder.Services.AddScoped<ITagRepository, TagRepository>();
|
||||
builder.Services.AddScoped<ITemplateRepository, TemplateRepository>();
|
||||
builder.Services.AddScoped<ITemplateRowRepository, TemplateRowRepository>();
|
||||
|
||||
@@ -259,6 +260,7 @@ builder.Services.AddScoped<IProductionOdlService, ProductionOdlService>();
|
||||
builder.Services.AddScoped<IProductionPlantService, ProductionPlantService>();
|
||||
builder.Services.AddScoped<IResourceService, ResourceService>();
|
||||
builder.Services.AddScoped<ISellingItemService, SellingItemService>();
|
||||
builder.Services.AddScoped<ITagService, TagService>();
|
||||
builder.Services.AddScoped<ITemplateService, TemplateService>();
|
||||
builder.Services.AddScoped<ITemplateRowService, TemplateRowService>();
|
||||
|
||||
|
||||
@@ -25,30 +25,3 @@
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<body>
|
||||
<i>LUX - Web Windows MES</i>
|
||||
<h4>Versione: 1.1.2603.1819</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
<b>Ultime modifiche:</b>
|
||||
<ul>{{LAST-CHANGES}}</ul>
|
||||
</li>
|
||||
<li>
|
||||
<b>v.0.9.* →</b>
|
||||
<ul>
|
||||
<li>Versione preliminare</li>
|
||||
<li>Release dotNet8</li>
|
||||
<li>Integrazione EFCore</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<div>
|
||||
<div style="float: left;">
|
||||
<img src="logoEgalware.png" />
|
||||
</div>
|
||||
<div style="float: right;">
|
||||
<a href="https://www.egalware.net/LUX" target="_blank">© Egalware 2025+</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
1.1.2603.1819
|
||||
1.1.2603.1819
|
||||
|
||||
@@ -5,10 +5,3 @@
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
</item>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.1.2603.1819</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user