Completata priam versione editing pag taskList
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DatabaseModels;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -28,9 +29,9 @@ namespace MP.Data.Controllers
|
||||
/// Elenco Azioni (decodifica)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.AzioniUL> ActionsGetAll()
|
||||
public List<AzioniUL> ActionsGetAll()
|
||||
{
|
||||
List<DatabaseModels.AzioniUL> dbResult = new List<DatabaseModels.AzioniUL>();
|
||||
List<AzioniUL> dbResult = new List<AzioniUL>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
@@ -46,9 +47,9 @@ namespace MP.Data.Controllers
|
||||
/// <param name="numRecord"></param>
|
||||
/// <param name="searchVal"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.StatsAnagArticoli> ArticoliGetSearch(int numRecord, string searchVal = "")
|
||||
public List<StatsAnagArticoli> ArticoliGetSearch(int numRecord, string searchVal = "")
|
||||
{
|
||||
List<DatabaseModels.StatsAnagArticoli> dbResult = new List<DatabaseModels.StatsAnagArticoli>();
|
||||
List<StatsAnagArticoli> dbResult = new List<StatsAnagArticoli>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
@@ -67,9 +68,9 @@ namespace MP.Data.Controllers
|
||||
/// <param name="numRecord"></param>
|
||||
/// <param name="searchVal"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.StatsODL> CommesseGetSearch(int numRecord, string searchVal = "")
|
||||
public List<StatsODL> CommesseGetSearch(int numRecord, string searchVal = "")
|
||||
{
|
||||
List<DatabaseModels.StatsODL> dbResult = new List<DatabaseModels.StatsODL>();
|
||||
List<StatsODL> dbResult = new List<StatsODL>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
@@ -90,9 +91,9 @@ namespace MP.Data.Controllers
|
||||
/// Elenco da tabella Macchine
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.Macchine> MacchineGetAll()
|
||||
public List<Macchine> MacchineGetAll()
|
||||
{
|
||||
List<DatabaseModels.Macchine> dbResult = new List<DatabaseModels.Macchine>();
|
||||
List<Macchine> dbResult = new List<Macchine>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
@@ -134,9 +135,9 @@ namespace MP.Data.Controllers
|
||||
/// <param name="numRecord"></param>
|
||||
/// <param name="searchVal"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.ResControlli> StatControlliGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
public List<ResControlli> StatControlliGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
{
|
||||
List<DatabaseModels.ResControlli> dbResult = new List<DatabaseModels.ResControlli>();
|
||||
List<ResControlli> dbResult = new List<ResControlli>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
var dataFrom = new SqlParameter("@dataFrom", DataStart);
|
||||
@@ -166,9 +167,9 @@ namespace MP.Data.Controllers
|
||||
/// <param name="FirstRecord"></param>
|
||||
/// <param name="NumRecord"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.DdbTurni> StatDdbGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo, int FirstRecord, int NumRecord)
|
||||
public List<DdbTurni> StatDdbGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo, int FirstRecord, int NumRecord)
|
||||
{
|
||||
List<DatabaseModels.DdbTurni> dbResult = new List<DatabaseModels.DdbTurni>();
|
||||
List<DdbTurni> dbResult = new List<DdbTurni>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
var dataFrom = new SqlParameter("@dataFrom", DataStart);
|
||||
@@ -221,9 +222,9 @@ namespace MP.Data.Controllers
|
||||
/// <param name="KeyRichiesta">Key Richiesta, se "*" = tutti</param>
|
||||
/// <param name="CodArticolo">Cod Articolo, se "*" = tutti</param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.OdlEnergyModel> StatOdlEnergyGetFilt(string IdxMacchina, DateTime DtStart, DateTime DtEnd, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
public List<OdlEnergyModel> StatOdlEnergyGetFilt(string IdxMacchina, DateTime DtStart, DateTime DtEnd, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
{
|
||||
List<DatabaseModels.OdlEnergyModel> dbResult = new List<DatabaseModels.OdlEnergyModel>();
|
||||
List<OdlEnergyModel> dbResult = new List<OdlEnergyModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
var dataFrom = new SqlParameter("@dataFrom", DtStart);
|
||||
@@ -241,57 +242,15 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ricerca task dato tipo e
|
||||
/// </summary>
|
||||
/// <param name="TType"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.TaskListModel> TaskListGetAll(Task2ExeType TType)
|
||||
{
|
||||
List<DatabaseModels.TaskListModel> dbResult = new List<DatabaseModels.TaskListModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbSetTaskList
|
||||
.Where(x => (TType == Task2ExeType.ND || x.TType == TType))
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Ricerca task dato tipo + num max (desc)
|
||||
/// </summary>
|
||||
/// <param name="TaskId">TaskId da cui deriva</param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.TaskExecModel> TaskExeGetFilt(int TaskId, int maxRec)
|
||||
{
|
||||
List<DatabaseModels.TaskExecModel> dbResult = new List<DatabaseModels.TaskExecModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbSetTaskExe
|
||||
.Include(x => x.TaskListNav)
|
||||
.Where(x => (x.TaskId == TaskId))
|
||||
.OrderByDescending(x => x.DtStart)
|
||||
.Take(maxRec)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella ODL da filtro
|
||||
/// </summary>
|
||||
/// <param name="numRecord"></param>
|
||||
/// <param name="searchVal"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.StatsODL> StatOdlGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
public List<StatsODL> StatOdlGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
{
|
||||
List<DatabaseModels.StatsODL> dbResult = new List<DatabaseModels.StatsODL>();
|
||||
List<StatsODL> dbResult = new List<StatsODL>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
var dataFrom = new SqlParameter("@dataFrom", DataStart);
|
||||
@@ -317,9 +276,9 @@ namespace MP.Data.Controllers
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <param name="DataEnd"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.ResScarti> StatScartiGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
public List<ResScarti> StatScartiGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
{
|
||||
List<DatabaseModels.ResScarti> dbResult = new List<DatabaseModels.ResScarti>();
|
||||
List<ResScarti> dbResult = new List<ResScarti>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
var dataFrom = new SqlParameter("@dataFrom", DataStart);
|
||||
@@ -345,9 +304,9 @@ namespace MP.Data.Controllers
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <param name="DataEnd"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.TurniOee> StatTurniOeeGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
public List<TurniOee> StatTurniOeeGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
{
|
||||
List<DatabaseModels.TurniOee> dbResult = new List<DatabaseModels.TurniOee>();
|
||||
List<TurniOee> dbResult = new List<TurniOee>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
var dataFrom = new SqlParameter("@dataFrom", DataStart);
|
||||
@@ -371,9 +330,9 @@ namespace MP.Data.Controllers
|
||||
/// <param name="numRecord"></param>
|
||||
/// <param name="searchVal"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.UserActionLog> StatUserLogGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
public List<UserActionLog> StatUserLogGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
{
|
||||
List<DatabaseModels.UserActionLog> dbResult = new List<DatabaseModels.UserActionLog>();
|
||||
List<UserActionLog> dbResult = new List<UserActionLog>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
var dataFrom = new SqlParameter("@dataFrom", DataStart);
|
||||
@@ -391,6 +350,134 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ricerca task dato tipo + num max (desc)
|
||||
/// </summary>
|
||||
/// <param name="TaskId">TaskId da cui deriva</param>
|
||||
/// <returns></returns>
|
||||
public List<TaskExecModel> TaskExecGetFilt(int TaskId, int maxRec)
|
||||
{
|
||||
List<TaskExecModel> dbResult = new List<TaskExecModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetTaskExe
|
||||
.Include(x => x.TaskListNav)
|
||||
.Where(x => (x.TaskId == TaskId))
|
||||
.OrderByDescending(x => x.DtStart)
|
||||
.Take(maxRec)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upsert record TaskExec
|
||||
/// </summary>
|
||||
/// <param name="rec2upd">Record da aggiornare/inserire</param>
|
||||
/// <returns></returns>
|
||||
public bool TaskExecUpsert(TaskExecModel rec2upd)
|
||||
{
|
||||
bool done = false;
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
var currData = dbCtx
|
||||
.DbSetTaskExe
|
||||
.Where(x => x.TaskExecId == rec2upd.TaskExecId)
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
currData.TaskId = rec2upd.TaskId;
|
||||
currData.DtStart = rec2upd.DtStart;
|
||||
currData.DtEnd = rec2upd.DtEnd;
|
||||
currData.IsError = rec2upd.IsError;
|
||||
currData.Result = rec2upd.Result;
|
||||
dbCtx.Entry(currData).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbCtx
|
||||
.DbSetTaskExe
|
||||
.Add(rec2upd);
|
||||
}
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in TaskExecUpsert{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ricerca task dato tipo e
|
||||
/// </summary>
|
||||
/// <param name="TType"></param>
|
||||
/// <returns></returns>
|
||||
public List<TaskListModel> TaskListGetAll(Task2ExeType TType)
|
||||
{
|
||||
List<TaskListModel> dbResult = new List<TaskListModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetTaskList
|
||||
.Where(x => (TType == Task2ExeType.ND || x.TType == TType))
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upsert record TaskList
|
||||
/// </summary>
|
||||
/// <param name="rec2upd">Record da aggiornare/inserire</param>
|
||||
/// <returns></returns>
|
||||
public bool TaskListUpsert(TaskListModel rec2upd)
|
||||
{
|
||||
bool done = false;
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
var currData = dbCtx
|
||||
.DbSetTaskList
|
||||
.Where(x => x.TaskId == rec2upd.TaskId)
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
currData.Name = rec2upd.Name;
|
||||
currData.Descript = rec2upd.Descript;
|
||||
currData.Command = rec2upd.Command;
|
||||
currData.Args = rec2upd.Args;
|
||||
currData.Freq = rec2upd.Freq;
|
||||
currData.Cad = rec2upd.Cad;
|
||||
currData.DtLastExec = rec2upd.DtLastExec;
|
||||
currData.DtNextExec = rec2upd.DtNextExec;
|
||||
currData.LastDuration = rec2upd.LastDuration;
|
||||
currData.LastResult = rec2upd.LastResult;
|
||||
dbCtx.Entry(currData).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbCtx
|
||||
.DbSetTaskList
|
||||
.Add(rec2upd);
|
||||
}
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in TaskListUpsert{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
Reference in New Issue
Block a user