Inizia code assisted review (non compila...)
This commit is contained in:
@@ -253,6 +253,8 @@ namespace MP.Data.Controllers
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Elenco codice articoli che abbiano dati Dossier
|
||||
/// </summary>
|
||||
@@ -268,6 +270,8 @@ namespace MP.Data.Controllers
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Conteggio num articoli Async
|
||||
@@ -488,6 +492,7 @@ namespace MP.Data.Controllers
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
#endif
|
||||
#if false
|
||||
|
||||
/// <summary>
|
||||
/// Elenco da tabella Config Async
|
||||
@@ -1085,6 +1090,8 @@ namespace MP.Data.Controllers
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Elenco ODL filtrati x stato, articolo, KeyRich (che contiene stato)
|
||||
/// </summary>
|
||||
|
||||
@@ -3,8 +3,12 @@ using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using MP.AppAuth.Services;
|
||||
using MP.Data.Controllers;
|
||||
using MP.Data.Repository.Anag;
|
||||
using MP.Data.Repository.Dossier;
|
||||
using MP.Data.Repository.FluxLog;
|
||||
using MP.Data.Repository.IOC;
|
||||
using MP.Data.Repository.Mtc;
|
||||
using MP.Data.Repository.Production;
|
||||
using MP.Data.Repository.System;
|
||||
using MP.Data.Repository.Utils;
|
||||
using MP.Data.Services;
|
||||
using MP.Data.Services.IOC;
|
||||
@@ -53,6 +57,10 @@ namespace MP.Data
|
||||
services.TryAddSingleton<IAnagRepository, AnagRepository>();
|
||||
|
||||
// Scoped
|
||||
services.TryAddScoped<IProductionRepository, ProductionRepository>();
|
||||
services.TryAddScoped<IDossierRepository, DossierRepository>();
|
||||
services.TryAddScoped<IFluxLogRepository, FluxLogRepository>();
|
||||
services.TryAddScoped<ISystemRepository, SystemRepository>();
|
||||
|
||||
|
||||
// ---------- End Repository ----------
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.Dossier
|
||||
{
|
||||
public class DossierRepository : IDossierRepository
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public DossierRepository(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> DossiersDeleteRecordAsync(DossierModel currRec)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
var currVal = await dbCtx
|
||||
.DbSetDossiers
|
||||
.Where(x => x.IdxDossier == currRec.IdxDossier)
|
||||
.FirstOrDefaultAsync();
|
||||
dbCtx
|
||||
.DbSetDossiers
|
||||
.Remove(currVal);
|
||||
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <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);
|
||||
return await dbCtx
|
||||
.DbSetDossiers
|
||||
.AsNoTracking()
|
||||
.Where(x => (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) && (CodArticolo == "*" || x.CodArticolo == CodArticolo) && (x.DtRif >= DtStart && x.DtRif <= DtEnd))
|
||||
.Include(m => m.MachineNav)
|
||||
.Include(a => a.ArticoloNav)
|
||||
.OrderByDescending(x => x.DtRif)
|
||||
.Take(MaxRec)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> DossiersInsertAsync(DossierModel newRec)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
await dbCtx
|
||||
.DbSetDossiers
|
||||
.AddAsync(newRec);
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> DossiersTakeParamsSnapshotLastAsync(string idxMacchina, DateTime dtMin, DateTime dtMax)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var pDtMin = new SqlParameter("@DtMin", dtMin);
|
||||
var pDtMax = new SqlParameter("@DtMax", dtMax);
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC stp_FL_TakeSnapshotLast @IdxMacchina,@DtMin,@DtMax", pIdxMacchina, pDtMin, pDtMax);
|
||||
return dbResult != 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> DossiersUpdateValoreAsync(DossierModel editRec)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
var currRec = await dbCtx
|
||||
.DbSetDossiers
|
||||
.Where(x => x.IdxDossier == editRec.IdxDossier)
|
||||
.FirstOrDefaultAsync();
|
||||
if (currRec != null)
|
||||
{
|
||||
currRec.Valore = editRec.Valore;
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
await dbCtx
|
||||
.DbSetDossiers
|
||||
.AddAsync(editRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.Dossier
|
||||
{
|
||||
public interface IDossierRepository
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
Task<bool> DossiersDeleteRecordAsync(DossierModel currRec);
|
||||
|
||||
Task<List<DossierModel>> DossiersGetLastFiltAsync(string IdxMacchina, string CodArticolo, DateTime DtStart, DateTime DtEnd, int MaxRec);
|
||||
|
||||
Task<bool> DossiersInsertAsync(DossierModel newRec);
|
||||
|
||||
Task<bool> DossiersTakeParamsSnapshotLastAsync(string idxMacchina, DateTime dtMin, DateTime dtMax);
|
||||
|
||||
Task<bool> DossiersUpdateValoreAsync(DossierModel editRec);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Core.DTO;
|
||||
using MP.Core.Objects;
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
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)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<StatDedupDTO>> FluxLogDataReduxAsync(string idxMaccSel, List<string> fluxList, Periodo currPeriodo, Enums.ValSelection valMode, Enums.DataInterval intReq, int maxItem)
|
||||
{
|
||||
List<StatDedupDTO> procStats = new List<StatDedupDTO>();
|
||||
Log.Info($"Inizio FluxLogDataReduxAsync | idxMaccSel: {idxMaccSel} | periodo: {currPeriodo.Inizio:yyyy-MM-dd} --> {currPeriodo.Fine:yyyy-MM-dd}");
|
||||
TimeSpan step = TimeSpan.FromHours(1);
|
||||
switch (intReq)
|
||||
{
|
||||
case Enums.DataInterval.minute:
|
||||
step = TimeSpan.FromMinutes(1.00 / maxItem);
|
||||
break;
|
||||
|
||||
case Enums.DataInterval.hour:
|
||||
step = TimeSpan.FromHours(1.00 / maxItem);
|
||||
break;
|
||||
|
||||
case Enums.DataInterval.day:
|
||||
step = TimeSpan.FromDays(1.00 / maxItem);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMaccSel);
|
||||
var pOnlyTest = new SqlParameter("@OnlyTest", false);
|
||||
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
foreach (var item in fluxList)
|
||||
{
|
||||
Log.Info($"FluxLogDataReduxAsync | Flux: {item}");
|
||||
int numRecProc = 0;
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
var pCodFlux = new SqlParameter("@CodFlux", item);
|
||||
DateTime dtCursStart = currPeriodo.Inizio;
|
||||
DateTime dtCursEnd = dtCursStart.Add(step);
|
||||
bool setCompleted = false;
|
||||
while (!setCompleted)
|
||||
{
|
||||
var currFlux = await dbCtx
|
||||
.DbSetFluxLog
|
||||
.Where(x => (x.CodFlux == item) && (x.dtEvento >= dtCursStart && x.dtEvento < dtCursEnd) && (x.IdxMacchina == idxMaccSel))
|
||||
.ToListAsync();
|
||||
|
||||
int numRec = currFlux.Count;
|
||||
numRecProc += numRec;
|
||||
if (numRec > maxItem)
|
||||
{
|
||||
List<Periodo> listPeriodi = new List<Periodo>();
|
||||
|
||||
switch (valMode)
|
||||
{
|
||||
case Enums.ValSelection.First:
|
||||
var recStart = currFlux.Skip(1).FirstOrDefault();
|
||||
listPeriodi.Add(new Periodo(recStart.dtEvento, dtCursEnd));
|
||||
break;
|
||||
|
||||
case Enums.ValSelection.Last:
|
||||
var recEnd = currFlux.LastOrDefault();
|
||||
listPeriodi.Add(new Periodo(dtCursStart, recEnd.dtEvento));
|
||||
break;
|
||||
|
||||
case Enums.ValSelection.Center:
|
||||
int idx = 1;
|
||||
var recCent = currFlux.Skip(idx / (maxItem + 1)).FirstOrDefault();
|
||||
listPeriodi.Add(new Periodo(dtCursStart, recCent.dtEvento));
|
||||
if (maxItem > 1)
|
||||
{
|
||||
for (int i = 2; i < maxItem; i++)
|
||||
{
|
||||
DateTime dtInizio = recCent.dtEvento;
|
||||
recCent = currFlux.Skip(i / (maxItem + 1)).FirstOrDefault();
|
||||
listPeriodi.Add(new Periodo(dtInizio, recCent.dtEvento));
|
||||
}
|
||||
}
|
||||
listPeriodi.Add(new Periodo(recCent.dtEvento.AddSeconds(1), dtCursEnd));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var slot in listPeriodi)
|
||||
{
|
||||
var pDtStart = new SqlParameter("@DtStart", slot.Inizio);
|
||||
var pDtEnd = new SqlParameter("@DtEnd", slot.Fine);
|
||||
await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC man.stp_ReduceFluxLog @IdxMacchina, @CodFlux, @DtStart, @DtEnd, @OnlyTest", pIdxMacchina, pCodFlux, pDtStart, pDtEnd, pOnlyTest);
|
||||
}
|
||||
}
|
||||
|
||||
dtCursStart = dtCursEnd;
|
||||
dtCursEnd = dtCursStart.Add(step);
|
||||
setCompleted = dtCursStart >= currPeriodo.Fine;
|
||||
}
|
||||
sw.Stop();
|
||||
StatDedupDTO currStat = new StatDedupDTO()
|
||||
{
|
||||
IdxMacchina = idxMaccSel,
|
||||
CodFlux = item,
|
||||
Interval = intReq,
|
||||
Num4Int = maxItem,
|
||||
NumRec = numRecProc,
|
||||
ProcTime = sw.Elapsed.TotalSeconds
|
||||
};
|
||||
procStats.Add(currStat);
|
||||
}
|
||||
Log.Info($"FINE FluxLogDataReduxAsync | idxMaccSel: {idxMaccSel} | periodo: {currPeriodo.Inizio:yyyy-MM-dd} --> {currPeriodo.Fine:yyyy-MM-dd}");
|
||||
return procStats;
|
||||
}
|
||||
|
||||
/// <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);
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
.Where(x => (x.dtEvento >= DtMin && x.dtEvento <= DtMax) && (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) && (CodFlux == "*" || x.CodFlux == CodFlux))
|
||||
.OrderByDescending(x => x.dtEvento)
|
||||
.Take(MaxRec)
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<ParetoFluxLogDTO>> FluxLogParetoAsync(string idxMacchina, DateTime dtFrom, DateTime dtTo)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.Where(x => (string.IsNullOrEmpty(idxMacchina) || x.IdxMacchina == idxMacchina) && (dtFrom <= x.dtEvento && x.dtEvento <= dtTo))
|
||||
.AsNoTracking()
|
||||
.GroupBy(x => x.CodFlux)
|
||||
.Select(g => new ParetoFluxLogDTO() { IdxMacchina = idxMacchina, CodFlux = g.Key, Qty = g.Count() })
|
||||
.OrderByDescending(x => x.Qty)
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using MP.Core.DTO;
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.FluxLog
|
||||
{
|
||||
public interface IFluxLogRepository
|
||||
{
|
||||
Task<List<StatDedupDTO>> FluxLogDataReduxAsync(string idxMaccSel, List<string> fluxList, Periodo currPeriodo, Enums.ValSelection valMode, Enums.DataInterval intReq, int maxItem);
|
||||
|
||||
Task<List<FluxLogModel>> FluxLogGetLastFiltAsync(DateTime DtMax, DateTime DtMin, string IdxMacchina, string CodFlux, int MaxRec);
|
||||
|
||||
Task<List<ParetoFluxLogDTO>> FluxLogParetoAsync(string idxMacchina, DateTime dtFrom, DateTime dtTo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.Production
|
||||
{
|
||||
public abstract class BaseRepository
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
protected readonly IDbContextFactory<MoonProContext> _ctxFactory;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Constructors
|
||||
|
||||
protected BaseRepository(IDbContextFactory<MoonProContext> ctxFactory) => _ctxFactory = ctxFactory;
|
||||
|
||||
#endregion Protected Constructors
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Creazione dbcontext per singola transazione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected async Task<MoonProContext> CreateContextAsync() => await _ctxFactory.CreateDbContextAsync();
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
using MP.Core.DTO;
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.Production
|
||||
{
|
||||
public interface IProductionRepository
|
||||
{
|
||||
#region ODL Methods
|
||||
|
||||
Task<List<ODLExpModel>> ListODLFiltAsync(bool inCorso, string codArt, string keyRichPart, string Reparto, string IdxMacchina, DateTime startDate, DateTime endDate);
|
||||
|
||||
Task<List<ODLExpModel>> OdlByKeyAsync(int IdxOdl);
|
||||
|
||||
Task<bool> ODLCloseAsync(int idxOdl, string idxMacchina, int matrOpr, bool confPezzi, bool confRett, int modoConfProd);
|
||||
|
||||
Task<List<ODLModel>> OdlGetCurrentAsync();
|
||||
|
||||
Task<List<StatODLModel>> OdlGetStatAsync(int IdxOdl);
|
||||
|
||||
Task<List<int>> OdlByBatchAsync(string batchSel);
|
||||
|
||||
#endregion
|
||||
|
||||
#region PODL Methods
|
||||
|
||||
Task<List<PODLExpModel>> ListPODLFiltAsync(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate);
|
||||
|
||||
Task<List<PODLExpModel>> ListPODL_ByCodArtAsync(string CodArticolo, bool OnlyAvail);
|
||||
|
||||
Task<List<PODLExpModel>> ListPODL_ByKitParentAsync(int IdxPodlParent);
|
||||
|
||||
Task<List<PODLExpModel>> ListPODL_KitFiltAsync(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate);
|
||||
|
||||
Task<PODLModel> PODL_getByKeyAsync(int idxPODL);
|
||||
|
||||
Task<PODLModel> PODL_getByOdlAsync(int idxODL);
|
||||
|
||||
Task<Dictionary<int, int>> PODL_getDictOdlPodlAsync(List<int> missingIds);
|
||||
|
||||
Task<bool> PODL_startSetup(PODLExpModel editRec, int matrOpr, double tcRich, int pzPallet, string note, DateTime dtEvent);
|
||||
|
||||
Task<bool> PODL_updateRecipe(int idxPODL, string recipeName);
|
||||
|
||||
Task<bool> PODLDeleteRecordAsync(PODLExpModel currRec);
|
||||
|
||||
Task<bool> PODLUpdateRecordAsync(PODLModel editRec);
|
||||
|
||||
Task<bool> PodlIstKitDeleteAsync(int IdxPODL);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Kit Methods
|
||||
|
||||
Task<bool> IstKitDeleteAsync(IstanzeKitModel rec2del);
|
||||
|
||||
Task<List<IstanzeKitModel>> IstKitFiltAsync(string keyKit, string keyExtOrd);
|
||||
|
||||
Task<bool> IstKitInsertByWKSAsync(string CodArtParent, string KeyFilt);
|
||||
|
||||
Task<bool> IstKitUpsertAsync(IstanzeKitModel editRec);
|
||||
|
||||
Task<bool> TemplateKitDeleteAsync(TemplateKitModel rec2del);
|
||||
|
||||
Task<List<TemplateKitModel>> TemplateKitFiltAsync(string KitCode, string codChild);
|
||||
|
||||
Task<bool> TemplateKitUpsertAsync(TemplateKitModel editRec, string codAzienda);
|
||||
|
||||
Task<bool> WipKitDeleteAsync(WipSetupKitModel rec2del);
|
||||
|
||||
Task<bool> WipKitDeleteOlderAsync(DateTime dateLimit);
|
||||
|
||||
Task<List<WipSetupKitModel>> WipKitFiltAsync(string KeyFilt);
|
||||
|
||||
Task<bool> WipKitUpsertAsync(WipSetupKitModel editRec);
|
||||
|
||||
Task<List<TksScoreModel>> TksScoreAsync(string KeyFilt, int MaxResult);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Macchine / Gruppi Methods
|
||||
|
||||
Task<List<MacchineModel>> MacchineGetFiltAsync(string codGruppo);
|
||||
|
||||
Task<List<MacchineModel>> MacchineByMatrOperAsync(int MatrOpr);
|
||||
|
||||
Task<List<string>> MacchineWithFluxAsync(DateTime dtStart, DateTime dtEnd);
|
||||
|
||||
Task<bool> Grp2MaccDeleteAsync(Gruppi2MaccModel rec2del);
|
||||
|
||||
Task<bool> Grp2MaccInsertAsync(Gruppi2MaccModel upsRec);
|
||||
|
||||
Task<bool> Grp2OperDeleteAsync(Gruppi2OperModel rec2del);
|
||||
|
||||
Task<bool> Grp2OperInsertAsync(Gruppi2OperModel upsRec);
|
||||
|
||||
Task<List<StatoMacchineModel>> StatoMacchinaAsync(string idxMacchina);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Misc Production Methods
|
||||
|
||||
Task<List<MappaStatoExplModel>> MseGetAllAsync(int maxAge = 2000);
|
||||
|
||||
Task<List<AnagGiacenzeModel>> ListGiacenzeAsync(int IdxOdl);
|
||||
|
||||
Task<List<AnagOperatoriModel>> OperatoriGetFiltAsync(string codGruppo);
|
||||
|
||||
Task<List<string>> ParametriGetFiltAsync(string IdxMacchina);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,864 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Core.DTO;
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.Production
|
||||
{
|
||||
public class ProductionRepository : IProductionRepository
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private readonly IDbContextFactory<MoonProContext> _ctxFactory;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public ProductionRepository(IDbContextFactory<MoonProContext> ctxFactory, IConfiguration configuration)
|
||||
{
|
||||
_ctxFactory = ctxFactory;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async Task<MoonProContext> GetMoonProContextAsync() => await _ctxFactory.CreateDbContextAsync();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods - ODL
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<ODLExpModel>> ListODLFiltAsync(bool inCorso, string codArt, string keyRichPart, string Reparto, string IdxMacchina, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
|
||||
var InCorso = new SqlParameter("@InCorso", inCorso);
|
||||
var CodArt = new SqlParameter("@CodArt", codArt);
|
||||
var KeyRich = new SqlParameter("@KeyRich", keyRichPart);
|
||||
var CodGruppo = new SqlParameter("@CodGruppo", Reparto);
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", IdxMacchina);
|
||||
var DataFrom = new SqlParameter("@DataFrom", startDate);
|
||||
var DataTo = new SqlParameter("@DataTo", endDate);
|
||||
|
||||
return await dbCtx
|
||||
.DbSetODLExp
|
||||
.FromSqlRaw("EXEC stp_ODL_getByFiltSpec @InCorso, @CodArt, @KeyRich, @CodGruppo, @IdxMacchina, @DataFrom, @DataTo", InCorso, CodArt, KeyRich, CodGruppo, IdxMacc, DataFrom, DataTo)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<ODLExpModel>> OdlByKeyAsync(int IdxOdl)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetODLExp
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync(x => x.IdxOdl == IdxOdl);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> ODLCloseAsync(int idxOdl, string idxMacchina, int matrOpr, bool confPezzi, bool confRett, int modoConfProd)
|
||||
{
|
||||
bool fatto = false;
|
||||
if (idxOdl > 0)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
// preparo i parametri
|
||||
var IdxODL = new SqlParameter("@IdxODL", idxOdl);
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
|
||||
try
|
||||
{
|
||||
var dbResult = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC stp_ODL_fineProd @IdxODL, @IdxMacchina", IdxODL, IdxMacchina);
|
||||
fatto = dbResult != 0;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
NLog.LogManager.GetCurrentClassLogger().Error($"Eccezione durante ODLCloseAsync{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<ODLModel>> OdlGetCurrentAsync()
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetODL
|
||||
.Where(x => x.DataInizio != null && x.DataFine == null)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<StatODLModel>> OdlGetStatAsync(int IdxOdl)
|
||||
{
|
||||
List<StatODLModel> dbResult = new List<StatODLModel>();
|
||||
if (IdxOdl > 0)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_STATSContext(_configuration);
|
||||
var IdxODL = new SqlParameter("@IdxODL", IdxOdl);
|
||||
|
||||
dbResult = await dbCtx
|
||||
.DbSetODL
|
||||
.FromSqlRaw("EXEC stp_STAT_ODL @IdxODL", IdxODL)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<int>> OdlByBatchAsync(string batchSel)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_InveContext(_configuration);
|
||||
return await dbCtx
|
||||
.DbGiacenzeData
|
||||
.AsNoTracking()
|
||||
.Where(x => x.IdxOdl > 0)
|
||||
.Select(x => x.IdxOdl)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods - PODL
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<PODLExpModel>> ListPODLFiltAsync(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var Lanc = new SqlParameter("@Lanciato", lanciato);
|
||||
var KeyRich = new SqlParameter("@KeyRich", keyRichPart);
|
||||
var CodGrp = new SqlParameter("@CodGruppo", codGruppo);
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DateFrom = new SqlParameter("@DtInizio", startDate);
|
||||
var DateTo = new SqlParameter("@DtFine", endDate);
|
||||
|
||||
return await dbCtx
|
||||
.DbSetPODLExp
|
||||
.FromSqlRaw("EXEC stp_PODL_getByFiltSpec @Lanciato, @KeyRich, @CodGruppo, @IdxMacchina, @DtInizio, @DtFine", Lanc, KeyRich, CodGrp, IdxMacc, DateFrom, DateTo)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<PODLExpModel>> ListPODL_ByCodArtAsync(string CodArticolo, bool OnlyAvail)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var pCodArticolo = new SqlParameter("@CodArticolo", CodArticolo);
|
||||
var pOnlyAvail = new SqlParameter("@onlyAvail", OnlyAvail);
|
||||
|
||||
return await dbCtx
|
||||
.DbSetPODLExp
|
||||
.FromSqlRaw("EXEC stp_PODL_getByCodArt @CodArticolo, @onlyAvail", pCodArticolo, pOnlyAvail)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<PODLExpModel>> ListPODL_ByKitParentAsync(int IdxPodlParent)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var pIdxPodlParent = new SqlParameter("@IdxPodlParent", IdxPodlParent);
|
||||
|
||||
return await dbCtx
|
||||
.DbSetPODLExp
|
||||
.FromSqlRaw("EXEC stp_PODL_getByParentKitIdx @IdxPodlParent", pIdxPodlParent)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<PODLExpModel>> ListPODL_KitFiltAsync(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var Lanc = new SqlParameter("@Lanciato", lanciato);
|
||||
var KeyRich = new SqlParameter("@KeyRich", keyRichPart);
|
||||
var CodGrp = new SqlParameter("@CodGruppo", codGruppo);
|
||||
var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
var DateFrom = new SqlParameter("@DtInizio", startDate);
|
||||
var DateTo = new SqlParameter("@DtFine", endDate);
|
||||
|
||||
return await dbCtx
|
||||
.DbSetPODLExp
|
||||
.FromSqlRaw("EXEC stp_PODL_getByFiltSpecKit @Lanciato, @KeyRich, @CodGruppo, @IdxMacchina, @DtInizio, @DtFine", Lanc, KeyRich, CodGrp, IdxMacc, DateFrom, DateTo)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<PODLModel> PODL_getByKeyAsync(int idxPODL)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
.Where(x => x.IdxPromessa == idxPODL)
|
||||
.Include(a => a.ArticoloNav)
|
||||
.FirstOrDefaultAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<PODLModel> PODL_getByOdlAsync(int idxODL)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
.Where(x => x.IdxOdl == idxODL)
|
||||
.FirstOrDefaultAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<Dictionary<int, int>> PODL_getDictOdlPodlAsync(List<int> missingIds)
|
||||
{
|
||||
if (missingIds == null || !missingIds.Any())
|
||||
return new Dictionary<int, int>();
|
||||
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
.Where(x => missingIds.Contains(x.IdxOdl))
|
||||
.ToDictionaryAsync(x => x.IdxOdl, x => x.IdxPromessa);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> PODL_startSetup(PODLExpModel editRec, int matrOpr, double tcRich, int pzPallet, string note, DateTime dtEvent)
|
||||
{
|
||||
bool answ = false;
|
||||
PODLModel recPODL = new PODLModel()
|
||||
{
|
||||
IdxPromessa = editRec.IdxPromessa,
|
||||
KeyRichiesta = editRec.KeyRichiesta,
|
||||
KeyBCode = editRec.KeyBCode,
|
||||
IdxOdl = editRec.IdxOdl,
|
||||
CodArticolo = editRec.CodArticolo,
|
||||
CodGruppo = editRec.CodGruppo,
|
||||
IdxMacchina = editRec.IdxMacchina,
|
||||
NumPezzi = editRec.NumPezzi,
|
||||
Tcassegnato = editRec.Tcassegnato,
|
||||
DueDate = editRec.DueDate,
|
||||
Priorita = editRec.Priorita,
|
||||
PzPallet = editRec.PzPallet,
|
||||
Note = editRec.Note,
|
||||
CodCli = editRec.CodCli,
|
||||
InsertDate = editRec.InsertDate
|
||||
};
|
||||
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var currRec = await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
.Where(x => x.IdxPromessa == recPODL.IdxPromessa)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (currRec != null)
|
||||
{
|
||||
var IdxPromessa = new SqlParameter("@idxPromessa", recPODL.IdxPromessa);
|
||||
var MatrOpr = new SqlParameter("@MatrOpr", matrOpr);
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", recPODL.IdxMacchina);
|
||||
var TCRichAttr = new SqlParameter("@TCRichAttr", tcRich);
|
||||
var PzPallet = new SqlParameter("@PzPallet", pzPallet);
|
||||
var Note = new SqlParameter("@Note", note);
|
||||
var DtEvento = new SqlParameter("@dtEvento", dtEvent);
|
||||
await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC stp_ODL_inizioSetupPromessa @idxPromessa, @MatrOpr, @IdxMacchina, @TCRichAttr, @PzPallet, @Note, @dtEvento", IdxPromessa, MatrOpr, IdxMacchina, TCRichAttr, PzPallet, Note, DtEvento);
|
||||
|
||||
answ = true;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> PODL_updateRecipe(int idxPODL, string recipeName)
|
||||
{
|
||||
bool answ = false;
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var currRec = await dbCtx
|
||||
.DbSetPODL
|
||||
.Where(x => x.IdxPromessa == idxPODL)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (currRec != null)
|
||||
{
|
||||
currRec.Recipe = recipeName;
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
answ = await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> PODLDeleteRecordAsync(PODLExpModel currRec)
|
||||
{
|
||||
PODLModel recPODL = new PODLModel()
|
||||
{
|
||||
IdxPromessa = currRec.IdxPromessa,
|
||||
KeyRichiesta = currRec.KeyRichiesta,
|
||||
KeyBCode = currRec.KeyBCode,
|
||||
IdxOdl = currRec.IdxOdl,
|
||||
CodArticolo = currRec.CodArticolo,
|
||||
CodGruppo = currRec.CodGruppo,
|
||||
IdxMacchina = currRec.IdxMacchina,
|
||||
NumPezzi = currRec.NumPezzi,
|
||||
Tcassegnato = currRec.Tcassegnato,
|
||||
DueDate = currRec.DueDate,
|
||||
Priorita = currRec.Priorita,
|
||||
PzPallet = currRec.PzPallet,
|
||||
Note = currRec.Note,
|
||||
CodCli = currRec.CodCli,
|
||||
InsertDate = currRec.InsertDate
|
||||
};
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var currVal = await dbCtx
|
||||
.DbSetPODL
|
||||
.Where(x => x.IdxPromessa == recPODL.IdxPromessa)
|
||||
.FirstOrDefaultAsync();
|
||||
dbCtx
|
||||
.DbSetPODL
|
||||
.Remove(currVal);
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> PODLUpdateRecordAsync(PODLModel editRec)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var currRec = await dbCtx
|
||||
.DbSetPODL
|
||||
.Where(x => x.IdxPromessa == editRec.IdxPromessa)
|
||||
.FirstOrDefaultAsync();
|
||||
if (currRec != null)
|
||||
{
|
||||
currRec.CodGruppo = editRec.CodGruppo;
|
||||
currRec.CodArticolo = editRec.CodArticolo;
|
||||
currRec.IdxMacchina = editRec.IdxMacchina;
|
||||
currRec.KeyBCode = editRec.KeyBCode;
|
||||
currRec.KeyRichiesta = editRec.KeyRichiesta;
|
||||
currRec.NumPezzi = editRec.NumPezzi;
|
||||
currRec.Tcassegnato = editRec.Tcassegnato;
|
||||
currRec.Attivabile = editRec.Attivabile;
|
||||
currRec.Note = editRec.Note;
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
await dbCtx
|
||||
.DbSetPODL
|
||||
.AddAsync(editRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> PodlIstKitDeleteAsync(int IdxPODL)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var pIdxPODL = new SqlParameter("@IdxPODL", IdxPODL);
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC dbo.stp_PodlIstKit_delete @IdxPODL", pIdxPODL);
|
||||
return dbResult != 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods - Kit
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> IstKitDeleteAsync(IstanzeKitModel rec2del)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetInstKit
|
||||
.Where(x => x.KeyKit == rec2del.KeyKit && x.KeyExtOrd == rec2del.KeyExtOrd)
|
||||
.FirstOrDefaultAsync();
|
||||
if (actRec != null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetInstKit
|
||||
.Remove(actRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<IstanzeKitModel>> IstKitFiltAsync(string keyKit, string keyExtOrd)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetInstKit
|
||||
.Where(x => (string.IsNullOrEmpty(keyKit) && string.IsNullOrEmpty(keyExtOrd)) || (x.KeyKit.Contains(keyKit) && !string.IsNullOrEmpty(keyKit)) || (x.KeyExtOrd.Contains(keyExtOrd) && !string.IsNullOrEmpty(keyExtOrd)))
|
||||
.AsNoTracking()
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> IstKitInsertByWKSAsync(string CodArtParent, string KeyFilt)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
|
||||
var pCodArtParent = new SqlParameter("@CodArtParent", CodArtParent);
|
||||
var pKeyFilt = new SqlParameter("@KeyFilt", KeyFilt);
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC dbo.stp_IstKit_insertByWKS @CodArtParent,@KeyFilt", pCodArtParent, pKeyFilt);
|
||||
return dbResult != 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> IstKitUpsertAsync(IstanzeKitModel editRec)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetInstKit
|
||||
.Where(x => x.KeyKit == editRec.KeyKit && x.KeyExtOrd == editRec.KeyExtOrd)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (actRec == null)
|
||||
{
|
||||
await dbCtx
|
||||
.DbSetInstKit
|
||||
.AddAsync(editRec);
|
||||
}
|
||||
else
|
||||
{
|
||||
actRec.CodArtParent = editRec.CodArtParent;
|
||||
actRec.CodArtChild = editRec.CodArtChild;
|
||||
actRec.QtyART = editRec.QtyART;
|
||||
actRec.QtyKIT = editRec.QtyKIT;
|
||||
dbCtx.Entry(actRec).State = EntityState.Modified;
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> TemplateKitDeleteAsync(TemplateKitModel rec2del)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetTempKit
|
||||
.Where(x => x.CodArtParent == rec2del.CodArtParent && x.CodArtChild == rec2del.CodArtChild)
|
||||
.FirstOrDefaultAsync();
|
||||
if (actRec != null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetTempKit
|
||||
.Remove(actRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<TemplateKitModel>> TemplateKitFiltAsync(string KitCode, string codChild)
|
||||
{
|
||||
List<TemplateKitModel> dbResult = new List<TemplateKitModel>();
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
dbResult = await dbCtx
|
||||
.DbSetTempKit
|
||||
.Where(x => (string.IsNullOrEmpty(KitCode) && string.IsNullOrEmpty(codChild)) || (x.CodArtParent.Contains(KitCode) && !string.IsNullOrEmpty(KitCode)) || (x.CodArtChild.Contains(codChild) && !string.IsNullOrEmpty(codChild)))
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> TemplateKitUpsertAsync(TemplateKitModel editRec, string codAzienda)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var recArt = await dbCtx
|
||||
.DbSetArticoli
|
||||
.FirstOrDefaultAsync(x => x.CodArticolo == editRec.CodArtParent);
|
||||
if (recArt == null)
|
||||
{
|
||||
AnagArticoliModel newRecArt = new AnagArticoliModel()
|
||||
{
|
||||
CodArticolo = editRec.CodArtParent,
|
||||
Tipo = "KIT",
|
||||
DescArticolo = $"Articolo KIT - {DateTime.Now:yyyy-MM-dd HH:mm:ss}",
|
||||
Disegno = "",
|
||||
Azienda = codAzienda,
|
||||
CurrRev = "",
|
||||
ProdRev = ""
|
||||
};
|
||||
dbCtx
|
||||
.DbSetArticoli
|
||||
.Add(newRecArt);
|
||||
}
|
||||
|
||||
var actRec = await dbCtx
|
||||
.DbSetTempKit
|
||||
.Where(x => x.CodArtParent == editRec.CodArtParent && x.CodArtChild == editRec.CodArtChild)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (actRec == null)
|
||||
{
|
||||
await dbCtx
|
||||
.DbSetTempKit
|
||||
.AddAsync(editRec);
|
||||
}
|
||||
else
|
||||
{
|
||||
actRec.Qty = editRec.Qty;
|
||||
dbCtx.Entry(actRec).State = EntityState.Modified;
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> WipKitDeleteAsync(WipSetupKitModel rec2del)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt == rec2del.KeyFilt && x.CodOrd == rec2del.CodOrd)
|
||||
.FirstOrDefaultAsync();
|
||||
if (actRec != null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetWipKit
|
||||
.Remove(actRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> WipKitDeleteOlderAsync(DateTime dateLimit)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.DataIns < dateLimit)
|
||||
.ToListAsync();
|
||||
if (actRec != null && actRec.Any())
|
||||
{
|
||||
dbCtx
|
||||
.DbSetWipKit
|
||||
.RemoveRange(actRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<WipSetupKitModel>> WipKitFiltAsync(string KeyFilt)
|
||||
{
|
||||
List<WipSetupKitModel> dbResult = new List<WipSetupKitModel>();
|
||||
if (!string.IsNullOrEmpty(KeyFilt))
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
dbResult = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt.Contains(KeyFilt))
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> WipKitUpsertAsync(WipSetupKitModel editRec)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt == editRec.KeyFilt && x.CodOrd == editRec.CodOrd)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (actRec == null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetWipKit
|
||||
.Add(editRec);
|
||||
}
|
||||
else
|
||||
{
|
||||
actRec.CodArt = editRec.CodArt;
|
||||
actRec.DescArt = editRec.DescArt;
|
||||
actRec.Qta = editRec.Qta;
|
||||
actRec.DataIns = editRec.DataIns;
|
||||
dbCtx.Entry(actRec).State = EntityState.Modified;
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<TksScoreModel>> TksScoreAsync(string KeyFilt, int MaxResult)
|
||||
{
|
||||
List<TksScoreModel> dbResult = new List<TksScoreModel>();
|
||||
if (!string.IsNullOrEmpty(KeyFilt))
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var pKeyFilt = new SqlParameter("@KeyFilt", KeyFilt);
|
||||
var pMaxRes = new SqlParameter("@maxResult", MaxResult);
|
||||
dbResult = await dbCtx
|
||||
.DbSetTksScore
|
||||
.FromSqlRaw("EXEC stp_TKS_Search @KeyFilt, @maxResult", pKeyFilt, pMaxRes)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods - Macchine/Gruppi
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<MacchineModel>> MacchineGetFiltAsync(string codGruppo)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
if (codGruppo == "*")
|
||||
{
|
||||
return await dbCtx
|
||||
.DbSetMacchine
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
return await dbCtx
|
||||
.DbSetGrp2Macc
|
||||
.Where(g => g.CodGruppo == codGruppo)
|
||||
.Join(dbCtx.DbSetMacchine,
|
||||
g => g.IdxMacchina,
|
||||
m => m.IdxMacchina,
|
||||
(g, m) => m
|
||||
)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<MacchineModel>> MacchineByMatrOperAsync(int MatrOpr)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
if (MatrOpr == 0)
|
||||
{
|
||||
return await dbCtx
|
||||
.DbSetMacchine
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
return await dbCtx
|
||||
.DbSetGrp2Oper
|
||||
.Where(g => g.MatrOpr == MatrOpr)
|
||||
.Join(dbCtx.DbSetGrp2Macc,
|
||||
g => g.CodGruppo,
|
||||
m => m.CodGruppo,
|
||||
(g, m) => m
|
||||
)
|
||||
.Distinct()
|
||||
.Join(dbCtx.DbSetMacchine,
|
||||
g => g.IdxMacchina,
|
||||
m => m.IdxMacchina,
|
||||
(g, m) => m
|
||||
)
|
||||
.Distinct()
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<string>> MacchineWithFluxAsync(DateTime dtStart, DateTime dtEnd)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
.Where(x => x.dtEvento >= dtStart && x.dtEvento <= dtEnd)
|
||||
.Select(i => i.IdxMacchina)
|
||||
.Distinct()
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> Grp2MaccDeleteAsync(Gruppi2MaccModel rec2del)
|
||||
{
|
||||
bool answ = false;
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetGrp2Macc
|
||||
.Where(x => x.CodGruppo == rec2del.CodGruppo && x.IdxMacchina == rec2del.IdxMacchina)
|
||||
.FirstOrDefaultAsync();
|
||||
if (dbRec != null)
|
||||
{
|
||||
dbCtx.DbSetGrp2Macc.Remove(dbRec);
|
||||
int numDone = await dbCtx.SaveChangesAsync();
|
||||
answ = numDone != 0;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> Grp2MaccInsertAsync(Gruppi2MaccModel upsRec)
|
||||
{
|
||||
bool answ = false;
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetGrp2Macc
|
||||
.Where(x => x.CodGruppo == upsRec.CodGruppo && x.IdxMacchina == upsRec.IdxMacchina)
|
||||
.FirstOrDefaultAsync();
|
||||
if (dbRec == null)
|
||||
{
|
||||
await dbCtx.DbSetGrp2Macc.AddAsync(upsRec);
|
||||
int numDone = await dbCtx.SaveChangesAsync();
|
||||
answ = numDone != 0;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> Grp2OperDeleteAsync(Gruppi2OperModel rec2del)
|
||||
{
|
||||
bool answ = false;
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetGrp2Oper
|
||||
.Where(x => x.CodGruppo == rec2del.CodGruppo && x.MatrOpr == rec2del.MatrOpr)
|
||||
.FirstOrDefaultAsync();
|
||||
if (dbRec != null)
|
||||
{
|
||||
dbCtx.DbSetGrp2Oper.Remove(dbRec);
|
||||
int numDone = await dbCtx.SaveChangesAsync();
|
||||
answ = numDone != 0;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> Grp2OperInsertAsync(Gruppi2OperModel upsRec)
|
||||
{
|
||||
bool answ = false;
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetGrp2Oper
|
||||
.Where(x => x.CodGruppo == upsRec.CodGruppo && x.MatrOpr == upsRec.MatrOpr)
|
||||
.FirstOrDefaultAsync();
|
||||
if (dbRec == null)
|
||||
{
|
||||
await dbCtx.DbSetGrp2Oper.AddAsync(upsRec);
|
||||
int numDone = await dbCtx.SaveChangesAsync();
|
||||
answ = numDone != 0;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IReadOnlyCollection<StatoMacchineModel>> StatoMacchinaAsync(string idxMacchina)
|
||||
{
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
return (await dbCtx
|
||||
.DbSetStatoMacc
|
||||
.AsNoTracking()
|
||||
.Where(x => x.IdxMacchina == idxMacchina)
|
||||
.ToListAsync())
|
||||
.AsReadOnly();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods - Misc
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<MappaStatoExplModel>> MseGetAllAsync(int maxAge = 2000)
|
||||
{
|
||||
List<MappaStatoExplModel> dbResult = new List<MappaStatoExplModel>();
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
|
||||
var maxAgeSec = new SqlParameter("@maxAgeSec", maxAge);
|
||||
|
||||
dbResult = await dbCtx
|
||||
.DbSetMSE
|
||||
.FromSqlRaw("EXEC stp_MSE_getData @maxAgeSec", maxAgeSec)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<AnagGiacenzeModel>> ListGiacenzeAsync(int IdxOdl)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_InveContext(_configuration);
|
||||
return await dbCtx
|
||||
.DbGiacenzeData
|
||||
.Where(x => x.IdxOdl == IdxOdl)
|
||||
.AsNoTracking()
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<AnagOperatoriModel>> OperatoriGetFiltAsync(string codGruppo)
|
||||
{
|
||||
List<AnagOperatoriModel> dbResult = new List<AnagOperatoriModel>();
|
||||
await using var dbCtx = await GetMoonProContextAsync();
|
||||
if (codGruppo == "*")
|
||||
{
|
||||
dbResult = await dbCtx
|
||||
.DbOperatori
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.MatrOpr)
|
||||
.ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = await dbCtx
|
||||
.DbSetGrp2Oper
|
||||
.Where(g => g.CodGruppo == codGruppo)
|
||||
.Join(dbCtx.DbOperatori,
|
||||
g => g.MatrOpr,
|
||||
m => m.MatrOpr,
|
||||
(g, m) => m
|
||||
)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.MatrOpr)
|
||||
.ToListAsync();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<string>> ParametriGetFiltAsync(string IdxMacchina)
|
||||
{
|
||||
await using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
.Where(x => (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina))
|
||||
.Take(1000)
|
||||
.Select(i => i.CodFlux)
|
||||
.Distinct()
|
||||
.OrderBy(x => x)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.System
|
||||
{
|
||||
public interface ISystemRepository
|
||||
{
|
||||
Task<List<ConfigModel>> ConfigGetAllAsync();
|
||||
|
||||
Task<bool> ConfigUpdateAsync(ConfigModel updRec);
|
||||
|
||||
Task<bool> EvListInsertAsync(EventListModel newRec);
|
||||
|
||||
Task<bool> ForceDbMaintAsync(bool doExec, bool doUpdStat, bool doSave, int minPgCnt, int minAvgFrag, int maxAvgFragReb);
|
||||
|
||||
Task<List<LinkMenuModel>> ListLinkAllAsync();
|
||||
|
||||
Task<List<LinkMenuModel>> ListLinkFiltAsync(string tipoLink);
|
||||
|
||||
Task<List<LinkMenuModel>> ElencoLinkAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.System
|
||||
{
|
||||
public class SystemRepository : ISystemRepository
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private readonly IDbContextFactory<MoonProContext> _ctxFactory;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public SystemRepository(IDbContextFactory<MoonProContext> ctxFactory, IConfiguration configuration)
|
||||
{
|
||||
_ctxFactory = ctxFactory;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<ConfigModel>> ConfigGetAllAsync()
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetConfig
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Chiave)
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> ConfigUpdateAsync(ConfigModel updRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
ConfigModel dbResult = new();
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
dbResult = await dbCtx
|
||||
.DbSetConfig
|
||||
.Where(x => x.Chiave == updRec.Chiave)
|
||||
.FirstOrDefaultAsync();
|
||||
if (dbResult != null)
|
||||
{
|
||||
dbResult.Valore = updRec.Valore;
|
||||
fatto = await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> EvListInsertAsync(EventListModel newRec)
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
_ = await dbCtx
|
||||
.DbSetEvList
|
||||
.AddAsync(newRec);
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> ForceDbMaintAsync(bool doExec, bool doUpdStat, bool doSave, int minPgCnt, int minAvgFrag, int maxAvgFragReb)
|
||||
{
|
||||
await using var dbCtx = new MoonProAdminContext(_configuration);
|
||||
|
||||
_ = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC man.stp_Utility_Maintanance");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<LinkMenuModel>> ListLinkAllAsync()
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetLinkMenu
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Ordine)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<LinkMenuModel>> ListLinkFiltAsync(string tipoLink)
|
||||
{
|
||||
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetLinkMenu
|
||||
.Where(x => x.TipoLink == tipoLink)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Ordine)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<List<LinkMenuModel>> ElencoLinkAsync()
|
||||
{
|
||||
return ListLinkFiltAsync("SpecLink");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -29,19 +29,27 @@
|
||||
## 4. Checklist Avanzamento Modifiche
|
||||
|
||||
### Fase 1: Preparazione (Infrastruttura)
|
||||
- [ ] Creazione file
|
||||
efactor_repository.md.
|
||||
- [ ] Analisi delle interfacce necessarie per ogni dominio.
|
||||
- [ ] Rinomina MpSpecController $\rightarrow$ MpSpecRepository (per allineamento naming).
|
||||
- [x] Creazione file refactor_repository.md.
|
||||
- [x] Analisi delle interfacce necessarie per ogni dominio.
|
||||
- [x] Rinomina MpSpecController $\rightarrow$ MpSpecRepository (per allineamento naming).
|
||||
|
||||
### Fase 2: Estrazione Modulare (Iterativa)
|
||||
- [ ] **Modulo Anagrafica**: Creazione AnagRepository $\rightarrow$ Spostamento metodi $\rightarrow$ Aggiornamento MpDataService.
|
||||
- [ ] **Modulo Produzione**: Creazione ProductionRepository $\rightarrow$ Spostamento metodi $\rightarrow$ Aggiornamento MpDataService.
|
||||
- [ ] **Modulo Dossier**: Creazione DossierRepository $\rightarrow$ Spostamento metodi $\rightarrow$ Aggiornamento MpDataService.
|
||||
- [ ] **Modulo FluxLog**: Creazione FluxLogRepository $\rightarrow$ Spostamento metodi $\rightarrow$ Aggiornamento MpDataService.
|
||||
- [ ] **Modulo Sistema**: Creazione SystemRepository $\rightarrow$ Spostamento metodi $\rightarrow$ Aggiornamento MpDataService.
|
||||
- [x] **Modulo Anagrafica**: Creazione AnagRepository + IAnagRepository (26 metodi migrati, codice sorgente in `#if false` in MpSpecRepository). File: `MP.Data\Repository\Anag\`
|
||||
- [x] **Modulo Produzione**: Creazione ProductionRepository + IProductionRepository (32 metodi migrati). File: `MP.Data\Repository\Production\`
|
||||
- ODL: ListODLFiltAsync, OdlByKeyAsync, ODLCloseAsync, OdlGetCurrentAsync, OdlGetStatAsync, OdlByBatchAsync
|
||||
- PODL: ListPODLFiltAsync, ListPODL_ByCodArtAsync, ListPODL_ByKitParentAsync, ListPODL_KitFiltAsync, PODL_getByKeyAsync, PODL_getByOdlAsync, PODL_getDictOdlPodlAsync, PODL_startSetup, PODL_updateRecipe, PODLDeleteRecordAsync, PODLUpdateRecordAsync, PodlIstKitDeleteAsync
|
||||
- Kit: IstKitDeleteAsync, IstKitFiltAsync, IstKitInsertByWKSAsync, IstKitUpsertAsync, TemplateKitDeleteAsync, TemplateKitFiltAsync, TemplateKitUpsertAsync, WipKitDeleteAsync, WipKitDeleteOlderAsync, WipKitFiltAsync, WipKitUpsertAsync, TksScoreAsync
|
||||
- Macchine/Gruppi: MacchineGetFiltAsync, MacchineByMatrOperAsync, MacchineWithFluxAsync, Grp2MaccDeleteAsync, Grp2MaccInsertAsync, Grp2OperDeleteAsync, Grp2OperInsertAsync
|
||||
- Misc: MseGetAllAsync, ListGiacenzeAsync, OperatoriGetFiltAsync, ParametriGetFiltAsync
|
||||
- [x] **Modulo Dossier**: Creazione DossierRepository + IDossierRepository (5 metodi migrati). File: `MP.Data\Repository\Dossier\`
|
||||
- DossiersDeleteRecordAsync, DossiersGetLastFiltAsync, DossiersInsertAsync, DossiersTakeParamsSnapshotLastAsync, DossiersUpdateValoreAsync
|
||||
- [x] **Modulo FluxLog**: Creazione FluxLogRepository + IFluxLogRepository (3 metodi migrati). File: `MP.Data\Repository\FluxLog\`
|
||||
- FluxLogDataReduxAsync, FluxLogGetLastFiltAsync, FluxLogParetoAsync
|
||||
- [x] **Modulo Sistema**: Creazione SystemRepository + ISystemRepository (7 metodi migrati). File: `MP.Data\Repository\System\`
|
||||
- ConfigGetAllAsync, ConfigUpdateAsync, EvListInsertAsync, ForceDbMaintAsync, ListLinkAllAsync, ListLinkFiltAsync, ElencoLinkAsync
|
||||
|
||||
### Fase 3: Pulizia e Verifica
|
||||
- [ ] Rimozione del codice residuo da MpSpecRepository.
|
||||
- [ ] Verifica della compilazione della soluzione (./build_all_par.ps1 --agent).
|
||||
- [ ] Verifica della coerenza dei log e della persistenza dei dati.
|
||||
- [ ] **Passo 3.1**: Spostamento a `#if false` dei metodi migrati in MpSpecRepository (33 metodi originali ancora attivi).
|
||||
- [ ] **Passo 3.2**: Verifica compilazione (dotnet build MP.Data\MP.Data.csproj).
|
||||
- [ ] **Passo 3.3**: Aggiornamento MpDataService per iniettare i 5 nuovi repository invece di MpSpecRepository.
|
||||
- [ ] **Passo 3.4**: Refactoring MpSpecRepository (solo metodi residui non migrati).
|
||||
|
||||
+9
-1
@@ -1,3 +1,9 @@
|
||||
# build_all_par.ps1
|
||||
# script per compilazione (parallela) progetti MAPO-CORE
|
||||
# nb: prerequisito powershell >= 7, install con
|
||||
# winget install Microsoft.PowerShell
|
||||
|
||||
|
||||
# --- CONFIGURAZIONE ---
|
||||
$pattern = "MP-*.sln"
|
||||
$sharedProjectPath = ".\MP.Data\MP.Data.csproj"
|
||||
@@ -9,7 +15,9 @@ $agentMode = $args -contains "--agent"
|
||||
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
|
||||
|
||||
# 1. Trova l'MSBuild ufficiale di Visual Studio 2022
|
||||
$vsPaths = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -version "[17.0,18.0)" -products * -requires Microsoft.Component.MSBuild -property installationPath
|
||||
$vsPaths = @(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -version "[17.0,19.0)" -products * -requires Microsoft.Component.MSBuild -property installationPath)
|
||||
# versione WKS-R9-SAM
|
||||
# $vsPaths = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -version "[17.0,18.0)" -products * -requires Microsoft.Component.MSBuild -property installationPath
|
||||
if (-not $vsPaths) {
|
||||
if ($agentMode) { exit 1 }
|
||||
Write-Host "❌ Impossibile trovare Visual Studio 2022!" -ForegroundColor Red
|
||||
|
||||
Reference in New Issue
Block a user