SPEC:
- aggiunta pagina operatori - completato fix
This commit is contained in:
@@ -162,6 +162,40 @@ namespace MP.Data.Repository.Anag
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<RepartiDTO>> GruppiRepartoDtoByOperAsync(int matrOpr)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
var listReparti = await AnagGruppiGetTipoAsync("REPARTO");
|
||||
|
||||
var listMacc = await dbCtx
|
||||
.DbSetGrp2Macc
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
var listOpr = await dbCtx
|
||||
.DbSetGrp2Oper
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
|
||||
var gruppiOpr = await dbCtx.DbSetGrp2Oper
|
||||
.Where(x => x.MatrOpr == matrOpr)
|
||||
.Select(x => x.CodGruppo)
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
return listReparti
|
||||
.Where(r => gruppiOpr.Contains(r.CodGruppo))
|
||||
.Select(x => new RepartiDTO()
|
||||
{
|
||||
CodGruppo = x.CodGruppo,
|
||||
TipoGruppo = x.TipoGruppo,
|
||||
DescrGruppo = x.DescrGruppo,
|
||||
SelEnabled = x.SelEnabled,
|
||||
CountMacc = listMacc.Where(y => y.CodGruppo == x.CodGruppo).Select(y => y.IdxMacchina).Distinct().Count(),
|
||||
CountOpr = listOpr.Where(y => y.CodGruppo == x.CodGruppo).Select(y => y.MatrOpr).Distinct().Count()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> AnagGruppiUpsertAsync(AnagGruppiModel updRec)
|
||||
{
|
||||
|
||||
@@ -75,14 +75,6 @@ namespace MP.Data.Repository.Anag
|
||||
/// <returns>Lista di valori ammessi</returns>
|
||||
Task<List<ListValuesModel>> AnagTipoArtLvAsync();
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Elenco codice articoli che abbiano dati Dossier
|
||||
/// </summary>
|
||||
/// <returns>Lista di codici articolo</returns>
|
||||
Task<List<string>> ArticleWithDossierAsync();
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Conteggio num articoli Async
|
||||
/// </summary>
|
||||
@@ -154,6 +146,20 @@ namespace MP.Data.Repository.Anag
|
||||
/// <returns>True se aggiornato</returns>
|
||||
Task<bool> ArticoliUpdateRecord(AnagArticoliModel editRec);
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Gruppi tipo REPARTOin formato DTO con conteggi del numero record trovati filtrati per operatore
|
||||
/// </summary>
|
||||
/// <returns>Lista di DTO reparti con conteggio macchine e operatori</returns>
|
||||
Task<List<RepartiDTO>> GruppiRepartoDtoByOperAsync(int matrOpr);
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Elenco codice articoli che abbiano dati Dossier
|
||||
/// </summary>
|
||||
/// <returns>Lista di codici articolo</returns>
|
||||
Task<List<string>> ArticleWithDossierAsync();
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Elenco valori ammessi x tabella/colonna Async
|
||||
/// </summary>
|
||||
|
||||
@@ -11,27 +11,36 @@ namespace MP.Data.Repository.Dossier
|
||||
{
|
||||
public class DossierRepository : IDossierRepository
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public DossierRepository(IConfiguration configuration)
|
||||
public DossierRepository(
|
||||
IConfiguration configuration,
|
||||
IDbContextFactory<MoonPro_FluxContext> ctxFactoryFL)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_ctxFactoryFL = ctxFactoryFL;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<string>> ArticleWithDossierAsync()
|
||||
{
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetDossiers
|
||||
.AsNoTracking()
|
||||
.Select(i => i.CodArticolo)
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> DossiersDeleteRecordAsync(DossierModel currRec)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
var currVal = await dbCtx
|
||||
.DbSetDossiers
|
||||
.Where(x => x.IdxDossier == currRec.IdxDossier)
|
||||
@@ -46,7 +55,7 @@ namespace MP.Data.Repository.Dossier
|
||||
/// <inheritdoc />
|
||||
public async Task<List<DossierModel>> DossiersGetLastFiltAsync(string IdxMacchina, string CodArticolo, DateTime DtStart, DateTime DtEnd, int MaxRec)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetDossiers
|
||||
.AsNoTracking()
|
||||
@@ -61,7 +70,7 @@ namespace MP.Data.Repository.Dossier
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> DossiersInsertAsync(DossierModel newRec)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
await dbCtx
|
||||
.DbSetDossiers
|
||||
.AddAsync(newRec);
|
||||
@@ -71,7 +80,7 @@ namespace MP.Data.Repository.Dossier
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> DossiersTakeParamsSnapshotLastAsync(string idxMacchina, DateTime dtMin, DateTime dtMax)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var pDtMin = new SqlParameter("@DtMin", dtMin);
|
||||
var pDtMax = new SqlParameter("@DtMax", dtMax);
|
||||
@@ -85,7 +94,7 @@ namespace MP.Data.Repository.Dossier
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> DossiersUpdateValoreAsync(DossierModel editRec)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
var currRec = await dbCtx
|
||||
.DbSetDossiers
|
||||
.Where(x => x.IdxDossier == editRec.IdxDossier)
|
||||
@@ -104,18 +113,18 @@ namespace MP.Data.Repository.Dossier
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<string>> ArticleWithDossierAsync()
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
return await dbCtx
|
||||
.DbSetDossiers
|
||||
.AsNoTracking()
|
||||
.Select(i => i.CodArticolo)
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
}
|
||||
#endregion Public Methods
|
||||
|
||||
#endregion
|
||||
#region Protected Fields
|
||||
|
||||
protected readonly IDbContextFactory<MoonPro_FluxContext> _ctxFactoryFL;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,21 +15,15 @@ namespace MP.Data.Repository.FluxLog
|
||||
{
|
||||
public class FluxLogRepository : IFluxLogRepository
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private readonly IConfiguration _configuration;
|
||||
private static NLog.Logger Log = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public FluxLogRepository(IConfiguration configuration)
|
||||
public FluxLogRepository(IConfiguration configuration, IDbContextFactory<MoonPro_FluxContext> ctxFactoryFL)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_ctxFactoryFL = ctxFactoryFL;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
@@ -60,7 +54,7 @@ namespace MP.Data.Repository.FluxLog
|
||||
var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMaccSel);
|
||||
var pOnlyTest = new SqlParameter("@OnlyTest", false);
|
||||
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
foreach (var item in fluxList)
|
||||
{
|
||||
Log.Info($"FluxLogDataReduxAsync | Flux: {item}");
|
||||
@@ -149,7 +143,7 @@ namespace MP.Data.Repository.FluxLog
|
||||
/// <inheritdoc />
|
||||
public async Task<List<FluxLogModel>> FluxLogGetLastFiltAsync(DateTime DtMax, DateTime DtMin, string IdxMacchina, string CodFlux, int MaxRec)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
@@ -162,7 +156,7 @@ namespace MP.Data.Repository.FluxLog
|
||||
/// <inheritdoc />
|
||||
public async Task<List<ParetoFluxLogDTO>> FluxLogParetoAsync(string idxMacchina, DateTime dtFrom, DateTime dtTo)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.Where(x => (string.IsNullOrEmpty(idxMacchina) || x.IdxMacchina == idxMacchina) && (dtFrom <= x.dtEvento && x.dtEvento <= dtTo))
|
||||
@@ -173,6 +167,19 @@ namespace MP.Data.Repository.FluxLog
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected readonly IDbContextFactory<MoonPro_FluxContext> _ctxFactoryFL;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static NLog.Logger Log = NLog.LogManager.GetCurrentClassLogger();
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ namespace MP.Data.Repository.MpLand
|
||||
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly IDbContextFactory<MoonProContext> _ctxFactory;
|
||||
private readonly IDbContextFactory<MoonPro_FluxContext> _ctxFactoryFluxLog;
|
||||
private readonly IDbContextFactory<MoonPro_STATSContext> _ctxFactoryStats;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -61,11 +63,12 @@ namespace MP.Data.Repository.MpLand
|
||||
if (!string.IsNullOrEmpty(_configuration.GetConnectionString("MP.All")))
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var singleRes = await dbCtx
|
||||
var singleRes = dbCtx
|
||||
.DbSetDbSize
|
||||
.FromSqlRaw(stp_DbInfo)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync();
|
||||
.AsEnumerable()
|
||||
.FirstOrDefault();
|
||||
if (singleRes != null)
|
||||
{
|
||||
dbResult.Add(singleRes);
|
||||
@@ -73,12 +76,13 @@ namespace MP.Data.Repository.MpLand
|
||||
}
|
||||
if (!string.IsNullOrEmpty(_configuration.GetConnectionString("MP.Flux")))
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
var singleRes = await dbCtx
|
||||
await using var dbCtx = await _ctxFactoryFluxLog.CreateDbContextAsync();
|
||||
var singleRes = dbCtx
|
||||
.DbSetDbSize
|
||||
.FromSqlRaw(stp_DbInfo)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync();
|
||||
.AsEnumerable()
|
||||
.FirstOrDefault();
|
||||
if (singleRes != null)
|
||||
{
|
||||
dbResult.Add(singleRes);
|
||||
@@ -86,12 +90,13 @@ namespace MP.Data.Repository.MpLand
|
||||
}
|
||||
if (!string.IsNullOrEmpty(_configuration.GetConnectionString("MP.Stats")))
|
||||
{
|
||||
await using var dbCtx = new MoonPro_STATSContext(_configuration);
|
||||
var singleRes = await dbCtx
|
||||
await using var dbCtx = await _ctxFactoryStats.CreateDbContextAsync();
|
||||
var singleRes = dbCtx
|
||||
.DbSetDbSize
|
||||
.FromSqlRaw(stp_DbInfo)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync();
|
||||
.AsEnumerable()
|
||||
.FirstOrDefault();
|
||||
if (singleRes != null)
|
||||
{
|
||||
dbResult.Add(singleRes);
|
||||
|
||||
@@ -6,10 +6,35 @@ namespace MP.Data.Repository.MpVoc
|
||||
{
|
||||
public interface IMpVocRepository
|
||||
{
|
||||
Task<List<ConfigModel>> ConfigGetAllAsync();
|
||||
#region Public Methods
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Recupero elenco config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<ConfigModel>> ConfigGetAllAsync();
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// recupero elenco lingue
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<LingueModel>> LingueGetAllAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Recupero tutte le voci dizionario, async
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<VocabolarioModel>> VocabolarioGetAllAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Recupero dizionario traduzioni x singola lingua
|
||||
/// </summary>
|
||||
/// <param name="lingua">Codice lingua</param>
|
||||
/// <returns>Dizionario di traduzioni</returns>
|
||||
Dictionary<string, string> VocabolarioGetLang(string lingua);
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -8,12 +9,6 @@ namespace MP.Data.Repository.MpVoc
|
||||
{
|
||||
public class MpVocRepository : IMpVocRepository
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private readonly IDbContextFactory<MoonPro_VocContext> _ctxFactory;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public MpVocRepository(IDbContextFactory<MoonPro_VocContext> ctxFactory)
|
||||
@@ -21,10 +16,11 @@ namespace MP.Data.Repository.MpVoc
|
||||
_ctxFactory = ctxFactory;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
#if false
|
||||
/// <inheritdoc />
|
||||
public async Task<List<ConfigModel>> ConfigGetAllAsync()
|
||||
{
|
||||
@@ -34,7 +30,8 @@ namespace MP.Data.Repository.MpVoc
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Chiave)
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<LingueModel>> LingueGetAllAsync()
|
||||
@@ -58,6 +55,28 @@ namespace MP.Data.Repository.MpVoc
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
#endregion
|
||||
/// <inheritdoc />
|
||||
public Dictionary<string, string> VocabolarioGetLang(string lingua)
|
||||
{
|
||||
using var dbCtx = _ctxFactory.CreateDbContextAsync().GetAwaiter().GetResult();
|
||||
var rawList = dbCtx
|
||||
.DbSetVocabolario
|
||||
.AsNoTracking()
|
||||
.Where(x => x.Lingua.ToLower() == lingua.ToLower())
|
||||
.OrderBy(x => x.Lemma)
|
||||
.ToList();
|
||||
// Proietto in dizionario
|
||||
return rawList
|
||||
.DistinctBy(t => t.Lemma, StringComparer.OrdinalIgnoreCase)
|
||||
.ToDictionary(t => t.Lemma, t => t.Traduzione, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly IDbContextFactory<MoonPro_VocContext> _ctxFactory;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,6 +106,7 @@ namespace MP.Data.Repository.Production
|
||||
Task<List<AnagGiacenzeModel>> ListGiacenzeAsync(int IdxOdl);
|
||||
|
||||
Task<List<AnagOperatoriModel>> OperatoriGetFiltAsync(string codGruppo);
|
||||
Task<bool> OperatoriUpsertAsync(AnagOperatoriModel updRec);
|
||||
|
||||
Task<List<string>> ParametriGetFiltAsync(string IdxMacchina);
|
||||
|
||||
|
||||
@@ -19,10 +19,15 @@ namespace MP.Data.Repository.Production
|
||||
#endregion
|
||||
|
||||
#region Public Constructors
|
||||
protected readonly IDbContextFactory<MoonPro_FluxContext> _ctxFactoryFL;
|
||||
|
||||
public ProductionRepository(IDbContextFactory<MoonProContext> ctxFactory, IConfiguration configuration)
|
||||
public ProductionRepository(
|
||||
IConfiguration configuration,
|
||||
IDbContextFactory<MoonProContext> ctxFactory,
|
||||
IDbContextFactory<MoonPro_FluxContext> ctxFactoryFL)
|
||||
{
|
||||
_ctxFactory = ctxFactory;
|
||||
_ctxFactoryFL = ctxFactoryFL;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
@@ -686,7 +691,7 @@ namespace MP.Data.Repository.Production
|
||||
/// <inheritdoc />
|
||||
public async Task<List<string>> MacchineWithFluxAsync(DateTime dtStart, DateTime dtEnd)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
@@ -841,10 +846,23 @@ namespace MP.Data.Repository.Production
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public async Task<bool> OperatoriUpsertAsync(AnagOperatoriModel updRec)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbOperatori
|
||||
.FindAsync(updRec.MatrOpr);
|
||||
if (dbRec != null)
|
||||
{
|
||||
dbCtx.Entry(dbRec).CurrentValues.SetValues(updRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<string>> ParametriGetFiltAsync(string IdxMacchina)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
await using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
|
||||
Reference in New Issue
Block a user