134 lines
4.5 KiB
C#
134 lines
4.5 KiB
C#
using Microsoft.Data.SqlClient;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using MP.Data.DatabaseModels;
|
|
using NLog;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MP.Data.Controllers
|
|
{
|
|
public class MpInveController : IDisposable
|
|
{
|
|
#region Public Constructors
|
|
|
|
public MpInveController(IConfiguration configuration)
|
|
{
|
|
_configuration = configuration;
|
|
Log.Info("Avviata classe MpInveController");
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Elenco Inventari CORRENTI (=aperti, senza data fine)
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<InventorySessionModel> InventSessCurrList()
|
|
{
|
|
List<InventorySessionModel> dbResult = new List<InventorySessionModel>();
|
|
using (var dbCtx = new MoonPro_InveContext(_configuration))
|
|
{
|
|
dbResult = dbCtx
|
|
.DbInveSess
|
|
.Where(x => x.DtEnd == null)
|
|
.AsNoTracking()
|
|
.OrderByDescending(x => x.DtStart)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco Inventari tipo Azienda (TUTTI, chiusi e paerti) filtrati x data
|
|
/// </summary>
|
|
/// <param name="FromDate"></param>
|
|
/// <param name="ToDate"></param>
|
|
/// <returns></returns>
|
|
public List<InventorySessionModel> InventSessHistList(DateTime FromDate, DateTime ToDate)
|
|
{
|
|
List<InventorySessionModel> dbResult = new List<InventorySessionModel>();
|
|
using (var dbCtx = new MoonPro_InveContext(_configuration))
|
|
{
|
|
dbResult = dbCtx
|
|
.DbInveSess
|
|
.Where(x => x.DtStart >= FromDate && x.DtStart <= ToDate)
|
|
.AsNoTracking()
|
|
.OrderByDescending(x => x.DtStart)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_configuration = null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco Scansioni dato Id sessione inventario
|
|
/// </summary>
|
|
/// <param name="InveSessId"></param>
|
|
/// <returns></returns>
|
|
public List<ScanDataModel> ScanBySession(int InveSessId)
|
|
{
|
|
List<ScanDataModel> dbResult = new List<ScanDataModel>();
|
|
using (var dbCtx = new MoonPro_InveContext(_configuration))
|
|
{
|
|
dbResult = dbCtx
|
|
.DbScanData
|
|
.Where(x => x.InveSessID == InveSessId)
|
|
.AsNoTracking()
|
|
.OrderByDescending(x => x.DtScan)
|
|
.ToList();
|
|
}
|
|
return dbResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco operatori
|
|
/// </summary>
|
|
/// /// <param name="MatrOpr"></param>
|
|
/// /// <param name="authKey"></param>
|
|
/// <returns></returns>
|
|
public List<AnagOperatoriModel> ElencoOperatori(int matrOpr, string authKey)
|
|
{
|
|
List<AnagOperatoriModel> dbResult = new List<AnagOperatoriModel>();
|
|
using (var dbCtx = new MoonProContext(_configuration))
|
|
{
|
|
if ((matrOpr == 0) && (authKey == ""))
|
|
{
|
|
dbResult = dbCtx
|
|
.DbOperatori
|
|
.Where(s => s.MatrOpr > 0)
|
|
.AsNoTracking()
|
|
.OrderBy(x => x.MatrOpr)
|
|
.ToList();
|
|
}
|
|
else
|
|
{
|
|
dbResult = dbCtx
|
|
.DbOperatori
|
|
.Where(s => (s.MatrOpr > 0) && (s.MatrOpr == matrOpr) && (s.authKey==authKey))
|
|
.AsNoTracking()
|
|
.OrderBy(x => x.MatrOpr)
|
|
.ToList();
|
|
}
|
|
}
|
|
return dbResult;
|
|
}
|
|
#endregion Public Methods
|
|
|
|
#region Private Fields
|
|
|
|
private static IConfiguration _configuration;
|
|
|
|
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
#endregion Private Fields
|
|
}
|
|
} |