SPEC:
- aggiunta pagina operatori - completato fix
This commit is contained in:
@@ -1,31 +1,36 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Core.DTO;
|
||||
using MP.Core.Objects;
|
||||
using MP.Data.DbModels;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using static EgwCoreLib.Utils.DtUtils;
|
||||
|
||||
namespace MP.Data.Controllers
|
||||
{
|
||||
public class MpSpecController
|
||||
{
|
||||
protected readonly IDbContextFactory<MoonProContext> _ctxFactory;
|
||||
protected readonly IDbContextFactory<MoonPro_FluxContext> _ctxFactoryFL;
|
||||
#region Public Constructors
|
||||
|
||||
public MpSpecController(IConfiguration configuration)
|
||||
public MpSpecController(
|
||||
IConfiguration configuration,
|
||||
IDbContextFactory<MoonProContext> ctxFactory,
|
||||
IDbContextFactory<MoonPro_FluxContext> ctxFactoryFL)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_ctxFactory = ctxFactory;
|
||||
_ctxFactoryFL = ctxFactoryFL;
|
||||
#if false
|
||||
string connStr = _configuration.GetConnectionString("MP.Data");
|
||||
options = new DbContextOptionsBuilder<MoonProContext>()
|
||||
.UseSqlServer(connStr)
|
||||
.Options;
|
||||
.Options;
|
||||
#endif
|
||||
Log.Info("Avviata classe MpSpecController");
|
||||
}
|
||||
|
||||
@@ -41,7 +46,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<AnagCountersModel> AnagCountersGetNextAsync(string cntType)
|
||||
{
|
||||
AnagCountersModel answ = new AnagCountersModel();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
bool outTable = true;
|
||||
if (outTable)
|
||||
{
|
||||
@@ -102,7 +107,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<vSelEventiBCodeModel>> AnagEventiGeneralAsync(string TableName = "EvList", string FieldName = "Common")
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var pTableName = new SqlParameter("@TableName", TableName);
|
||||
var pFieldName = new SqlParameter("@FieldName", FieldName);
|
||||
var dbResult = await dbCtx
|
||||
@@ -129,7 +134,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AnagGruppiDeleteAsync(AnagGruppiModel updRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetAnagGruppi
|
||||
.AsNoTracking()
|
||||
@@ -161,7 +166,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagGruppiModel>> AnagGruppiGetTipoAsync(string tipoGruppo)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetAnagGruppi
|
||||
.Where(x => x.TipoGruppo == tipoGruppo)
|
||||
@@ -176,7 +181,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<RepartiDTO>> AnagGruppiRepartoDtoAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
// in primis recupero i reparti...
|
||||
var listReparti = await AnagGruppiGetTipoAsync("REPARTO");
|
||||
|
||||
@@ -211,7 +216,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AnagGruppiUpsertAsync(AnagGruppiModel updRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetAnagGruppi
|
||||
.AsNoTracking()
|
||||
@@ -279,7 +284,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<int> ArticoliCountAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var result = await dbCtx
|
||||
.DbSetArticoli
|
||||
.CountAsync();
|
||||
@@ -295,7 +300,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<int> ArticoliCountSearchAsync(string tipoArt = "*", string azienda = "*", string searchVal = "")
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
IQueryable<AnagArticoliModel> query = dbCtx.DbSetArticoli.AsNoTracking();
|
||||
|
||||
// filtro tipo articolo
|
||||
@@ -331,7 +336,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<int> ArticoliCountUsedAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var result = await dbCtx
|
||||
.DbSetCounter
|
||||
.FromSqlRaw("EXEC stp_ART_CountUsed")
|
||||
@@ -348,7 +353,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ArticoliDeleteRecordAsync(AnagArticoliModel currRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var currVal = dbCtx
|
||||
.DbSetArticoli
|
||||
.Where(x => x.CodArticolo == currRec.CodArticolo)
|
||||
@@ -368,7 +373,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagArticoliModel>> ArticoliGetByTipoAsync(string tipo, string azienda = "*")
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetArticoli
|
||||
.AsNoTracking()
|
||||
@@ -387,7 +392,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagArticoliModel>> ArticoliGetSearchAsync(int numRecord, string tipoArt = "*", string azienda = "*", string searchVal = "")
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
IQueryable<AnagArticoliModel> query = dbCtx.DbSetArticoli
|
||||
.AsNoTracking();
|
||||
|
||||
@@ -425,7 +430,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagArticoliModel>> ArticoliGetUnusedAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetArticoli
|
||||
.FromSqlRaw("EXEC stp_ART_getNotUsed")
|
||||
@@ -439,7 +444,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagArticoliModel>> ArticoliGetUsedAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetArticoli
|
||||
.FromSqlRaw("EXEC stp_ART_getUsed")
|
||||
@@ -454,7 +459,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<AnagArticoliModel>> ArticoliInKitAsync()
|
||||
{
|
||||
List<AnagArticoliModel> dbResult = new List<AnagArticoliModel>();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
dbResult = await dbCtx
|
||||
.DbSetArticoli
|
||||
.FromSqlRaw("EXEC stp_TempKIT_getArtChild")
|
||||
@@ -470,7 +475,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ArticoliUpdateRecord(AnagArticoliModel editRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var currRec = dbCtx
|
||||
.DbSetArticoli
|
||||
.Where(x => x.CodArticolo == editRec.CodArticolo)
|
||||
@@ -500,7 +505,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<ConfigModel>> ConfigGetAllAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetConfig
|
||||
.AsNoTracking()
|
||||
@@ -516,7 +521,7 @@ namespace MP.Data.Controllers
|
||||
{
|
||||
bool fatto = false;
|
||||
ConfigModel dbResult = new ConfigModel();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
dbResult = await dbCtx
|
||||
.DbSetConfig
|
||||
.Where(x => x.Chiave == updRec.Chiave)
|
||||
@@ -647,7 +652,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> EvListInsertAsync(EventListModel newRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var currRec = await dbCtx
|
||||
.DbSetEvList
|
||||
.AddAsync(newRec);
|
||||
@@ -874,7 +879,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> Grp2MaccDeleteAsync(Gruppi2MaccModel rec2del)
|
||||
{
|
||||
bool answ = false;
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetGrp2Macc
|
||||
.Where(x => x.CodGruppo == rec2del.CodGruppo && x.IdxMacchina == rec2del.IdxMacchina)
|
||||
@@ -896,7 +901,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> Grp2MaccInsertAsync(Gruppi2MaccModel upsRec)
|
||||
{
|
||||
bool answ = false;
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetGrp2Macc
|
||||
.Where(x => x.CodGruppo == upsRec.CodGruppo && x.IdxMacchina == upsRec.IdxMacchina)
|
||||
@@ -919,7 +924,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> Grp2OperDeleteAsync(Gruppi2OperModel rec2del)
|
||||
{
|
||||
bool answ = false;
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetGrp2Oper
|
||||
.Where(x => x.CodGruppo == rec2del.CodGruppo && x.MatrOpr == rec2del.MatrOpr)
|
||||
@@ -941,7 +946,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> Grp2OperInsertAsync(Gruppi2OperModel upsRec)
|
||||
{
|
||||
bool answ = false;
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetGrp2Oper
|
||||
.Where(x => x.CodGruppo == upsRec.CodGruppo && x.MatrOpr == upsRec.MatrOpr)
|
||||
@@ -962,7 +967,7 @@ namespace MP.Data.Controllers
|
||||
/// <param name="rec2del"></param>
|
||||
public async Task<bool> IstKitDeleteAsync(IstanzeKitModel rec2del)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetInstKit
|
||||
.Where(x => x.KeyKit == rec2del.KeyKit && x.KeyExtOrd == rec2del.KeyExtOrd)
|
||||
@@ -985,7 +990,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<IstanzeKitModel>> IstKitFiltAsync(string keyKit, string keyExtOrd)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
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)))
|
||||
@@ -1000,7 +1005,7 @@ namespace MP.Data.Controllers
|
||||
/// <param name="KeyFilt">Chiave x filtro conf su tab WKS</param>
|
||||
public async Task<bool> IstKitInsertByWKSAsync(string CodArtParent, string KeyFilt)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
|
||||
var pCodArtParent = new SqlParameter("@CodArtParent", CodArtParent);
|
||||
var pKeyFilt = new SqlParameter("@KeyFilt", KeyFilt);
|
||||
@@ -1017,7 +1022,7 @@ namespace MP.Data.Controllers
|
||||
/// <param name="editRec"></param>
|
||||
public async Task<bool> IstKitUpsertAsync(IstanzeKitModel editRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetInstKit
|
||||
.Where(x => x.KeyKit == editRec.KeyKit && x.KeyExtOrd == editRec.KeyExtOrd)
|
||||
@@ -1065,7 +1070,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<LinkMenuModel>> ListLinkAllAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetLinkMenu
|
||||
.AsNoTracking()
|
||||
@@ -1081,7 +1086,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<LinkMenuModel>> ListLinkFiltAsync(string tipoLink)
|
||||
{
|
||||
List<LinkMenuModel> dbResult = new List<LinkMenuModel>();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetLinkMenu
|
||||
.Where(x => x.TipoLink == tipoLink)
|
||||
@@ -1106,7 +1111,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<ODLExpModel>> ListODLFiltAsync(bool inCorso, string codArt, string keyRichPart, string Reparto, string IdxMacchina, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
List<ODLExpModel> dbResult = new List<ODLExpModel>();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
|
||||
var InCorso = new SqlParameter("@InCorso", inCorso);
|
||||
var CodArt = new SqlParameter("@CodArt", codArt);
|
||||
@@ -1131,7 +1136,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<PODLExpModel>> ListPODL_ByCodArtAsync(string CodArticolo, bool OnlyAvail)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var pCodArticolo = new SqlParameter("@CodArticolo", CodArticolo);
|
||||
var pOnlyAvail = new SqlParameter("@onlyAvail", OnlyAvail);
|
||||
|
||||
@@ -1149,7 +1154,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<PODLExpModel>> ListPODL_ByKitParentAsync(int IdxPodlParent)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var pIdxPodlParent = new SqlParameter("@IdxPodlParent", IdxPodlParent);
|
||||
|
||||
return await dbCtx
|
||||
@@ -1169,7 +1174,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<PODLExpModel>> ListPODL_KitFiltAsync(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var Lanc = new SqlParameter("@Lanciato", lanciato);
|
||||
var KeyRich = new SqlParameter("@KeyRich", keyRichPart);
|
||||
var CodGrp = new SqlParameter("@CodGruppo", codGruppo);
|
||||
@@ -1194,7 +1199,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<PODLExpModel>> ListPODLFiltAsync(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var Lanc = new SqlParameter("@Lanciato", lanciato);
|
||||
var KeyRich = new SqlParameter("@KeyRich", keyRichPart);
|
||||
var CodGrp = new SqlParameter("@CodGruppo", codGruppo);
|
||||
@@ -1217,7 +1222,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<ListValuesModel>> ListValuesFiltAsync(string tabName, string fieldName)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetListValues
|
||||
.Where(x => x.TableName == tabName && x.FieldName == fieldName)
|
||||
@@ -1233,7 +1238,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<MacchineModel>> MacchineByMatrOperAsync(int MatrOpr)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
if (MatrOpr == 0)
|
||||
{
|
||||
return await dbCtx
|
||||
@@ -1272,7 +1277,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<MacchineModel>> MacchineGetFiltAsync(string codGruppo)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
if (codGruppo == "*")
|
||||
{
|
||||
return await dbCtx
|
||||
@@ -1305,7 +1310,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<string>> MacchineWithFluxAsync(DateTime dtStart, DateTime dtEnd)
|
||||
{
|
||||
using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
@@ -1322,7 +1327,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<MappaStatoExplModel>> MseGetAllAsync(int maxAge = 2000)
|
||||
{
|
||||
List<MappaStatoExplModel> dbResult = new List<MappaStatoExplModel>();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
|
||||
var maxAgeSec = new SqlParameter("@maxAgeSec", maxAge);
|
||||
|
||||
@@ -1357,7 +1362,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<ODLExpModel> OdlByKeyAsync(int IdxOdl)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetODLExp
|
||||
.AsNoTracking()
|
||||
@@ -1379,7 +1384,7 @@ namespace MP.Data.Controllers
|
||||
bool fatto = false;
|
||||
if (idxOdl > 0)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
DateTime adesso = DateTime.Now;
|
||||
// preparo i parametri
|
||||
var IdxODL = new SqlParameter("@IdxODL", idxOdl);
|
||||
@@ -1441,7 +1446,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<ODLModel>> OdlGetCurrentAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetODL
|
||||
.Where(x => x.DataInizio != null && x.DataFine == null)
|
||||
@@ -1457,7 +1462,7 @@ namespace MP.Data.Controllers
|
||||
List<StatODLModel> dbResult = new List<StatODLModel>();
|
||||
if (IdxOdl > 0)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var IdxODL = new SqlParameter("@IdxODL", IdxOdl);
|
||||
|
||||
dbResult = await dbCtx
|
||||
@@ -1477,7 +1482,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<AnagOperatoriModel>> OperatoriGetFiltAsync(string codGruppo)
|
||||
{
|
||||
List<AnagOperatoriModel> dbResult = new List<AnagOperatoriModel>();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
if (codGruppo == "*")
|
||||
{
|
||||
dbResult = await dbCtx
|
||||
@@ -1510,7 +1515,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<List<string>> ParametriGetFiltAsync(string IdxMacchina)
|
||||
{
|
||||
using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
using var dbCtx = await _ctxFactoryFL.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
@@ -1529,7 +1534,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<PODLModel> PODL_getByKeyAsync(int idxPODL)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
@@ -1545,7 +1550,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<PODLModel> PODL_getByOdlAsync(int idxODL)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
@@ -1563,7 +1568,7 @@ namespace MP.Data.Controllers
|
||||
if (missingIds == null || !missingIds.Any())
|
||||
return new Dictionary<int, int>();
|
||||
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
@@ -1602,7 +1607,7 @@ namespace MP.Data.Controllers
|
||||
InsertDate = editRec.InsertDate
|
||||
};
|
||||
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var currRec = await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
@@ -1637,7 +1642,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> PODL_updateRecipe(int idxPODL, string recipeName)
|
||||
{
|
||||
bool answ = false;
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var currRec = await dbCtx
|
||||
.DbSetPODL
|
||||
.Where(x => x.IdxPromessa == idxPODL)
|
||||
@@ -1677,7 +1682,7 @@ namespace MP.Data.Controllers
|
||||
CodCli = currRec.CodCli,
|
||||
InsertDate = currRec.InsertDate
|
||||
};
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var currVal = await dbCtx
|
||||
.DbSetPODL
|
||||
.Where(x => x.IdxPromessa == recPODL.IdxPromessa)
|
||||
@@ -1694,7 +1699,7 @@ namespace MP.Data.Controllers
|
||||
/// <param name="IdxPODL">IdxPODL parent</param>
|
||||
public async Task<bool> PodlIstKitDeleteAsync(int IdxPODL)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var pIdxPODL = new SqlParameter("@IdxPODL", IdxPODL);
|
||||
|
||||
var dbResult = await dbCtx
|
||||
@@ -1710,7 +1715,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> PODLUpdateRecordAsync(PODLModel editRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var currRec = await dbCtx
|
||||
.DbSetPODL
|
||||
.Where(x => x.IdxPromessa == editRec.IdxPromessa)
|
||||
@@ -1744,7 +1749,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<StatoMacchineModel> StatoMacchinaAsync(string idxMacchina)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetStatoMacc
|
||||
.Where(x => x.IdxMacchina == idxMacchina)
|
||||
@@ -1758,7 +1763,7 @@ namespace MP.Data.Controllers
|
||||
/// <param name="rec2del"></param>
|
||||
public async Task<bool> TemplateKitDeleteAsync(TemplateKitModel rec2del)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetTempKit
|
||||
.Where(x => x.CodArtParent == rec2del.CodArtParent && x.CodArtChild == rec2del.CodArtChild)
|
||||
@@ -1782,7 +1787,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<List<TemplateKitModel>> TemplateKitFiltAsync(string KitCode, string codChild)
|
||||
{
|
||||
List<TemplateKitModel> dbResult = new List<TemplateKitModel>();
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
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)))
|
||||
@@ -1798,7 +1803,7 @@ namespace MP.Data.Controllers
|
||||
/// <param name="codAzienda"></param>
|
||||
public async Task<bool> TemplateKitUpsertAsync(TemplateKitModel editRec, string codAzienda)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
// verifico preliminarmente articolo...
|
||||
var recArt = dbCtx
|
||||
.DbSetArticoli
|
||||
@@ -1854,7 +1859,7 @@ namespace MP.Data.Controllers
|
||||
List<TksScoreModel> dbResult = new List<TksScoreModel>();
|
||||
if (!string.IsNullOrEmpty(KeyFilt))
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var pKeyFilt = new SqlParameter("@KeyFilt", KeyFilt);
|
||||
var pMaxRes = new SqlParameter("@maxResult", MaxResult);
|
||||
dbResult = await dbCtx
|
||||
@@ -1866,13 +1871,14 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Elenco Vocabolario di una lingua
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, string> VocabolarioGetLang(string lingua)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = _ctxFactory.CreateDbContext();
|
||||
var rawList = dbCtx
|
||||
.DbSetVocabolario
|
||||
.AsNoTracking()
|
||||
@@ -1892,7 +1898,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> VocabolarioUpsertAsync(VocabolarioModel upsRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetVocabolario
|
||||
.Where(x => x.Lingua == upsRec.Lingua && x.Lemma == upsRec.Lemma)
|
||||
@@ -1919,7 +1925,7 @@ namespace MP.Data.Controllers
|
||||
/// <param name="rec2del"></param>
|
||||
public async Task<bool> WipKitDeleteAsync(WipSetupKitModel rec2del)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt == rec2del.KeyFilt && x.CodOrd == rec2del.CodOrd)
|
||||
@@ -1932,7 +1938,8 @@ namespace MP.Data.Controllers
|
||||
.Remove(actRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Elimina record + vecchi della data-ora indicata
|
||||
@@ -1941,7 +1948,7 @@ namespace MP.Data.Controllers
|
||||
/// <returns></returns>
|
||||
public async Task<bool> WipKitDeleteOlderAsync(DateTime dateLimit)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.DataIns < dateLimit)
|
||||
@@ -1967,7 +1974,7 @@ namespace MP.Data.Controllers
|
||||
// solo se filtro valido...
|
||||
if (!string.IsNullOrEmpty(KeyFilt))
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
dbResult = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt.Contains(KeyFilt))
|
||||
@@ -1983,7 +1990,7 @@ namespace MP.Data.Controllers
|
||||
/// <param name="editRec"></param>
|
||||
public async Task<bool> WipKitUpsertAsync(WipSetupKitModel editRec)
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
||||
var actRec = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt == editRec.KeyFilt && x.CodOrd == editRec.CodOrd)
|
||||
@@ -2013,7 +2020,9 @@ namespace MP.Data.Controllers
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private DbContextOptions<MoonProContext> options;
|
||||
#if false
|
||||
private DbContextOptions<MoonProContext> options;
|
||||
#endif
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user