Modifica x gestione errore in caricamento doppio se cache inganna il check orario
This commit is contained in:
@@ -227,13 +227,17 @@ namespace GWMS.Data.Controllers
|
||||
|
||||
public List<PlantDTO> GetPlantsDTO(int maxRecords)
|
||||
{
|
||||
var plantList = dbCtx
|
||||
.DbSetPlant
|
||||
.ToList();
|
||||
List<PlantDTO> dbResult = new List<PlantDTO>();
|
||||
using (GWMSContext dbCtxMult = new GWMSContext(_configuration))
|
||||
{
|
||||
var plantList = dbCtxMult
|
||||
.DbSetPlant
|
||||
.ToList();
|
||||
|
||||
var dbResult = plantList
|
||||
dbResult = plantList
|
||||
.Select(x => PlantDTO(x.PlantId, maxRecords))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return dbResult;
|
||||
}
|
||||
@@ -353,7 +357,7 @@ namespace GWMS.Data.Controllers
|
||||
public PlantDTO PlantDTO(int PlantId, int maxRecords)
|
||||
{
|
||||
var currPlant = GetPlant(PlantId);
|
||||
|
||||
PlantDTO answ = new PlantDTO();
|
||||
List<TSData> LevelTS = new List<TSData>();
|
||||
Dictionary<string, double> PressAct = new Dictionary<string, double>();
|
||||
Dictionary<string, List<TSData>> PressTS = new Dictionary<string, List<TSData>>();
|
||||
@@ -361,82 +365,87 @@ namespace GWMS.Data.Controllers
|
||||
List<TSData> PressBHTS = new List<TSData>();
|
||||
List<TSData> PressBLTS = new List<TSData>();
|
||||
List<TSData> OrderTS = new List<TSData>();
|
||||
// recupero dal DB
|
||||
var rawLevelData = dbCtx
|
||||
|
||||
using (GWMSContext dbCtxMult = new GWMSContext(_configuration))
|
||||
{
|
||||
// recupero dal DB
|
||||
var rawLevelData = dbCtxMult
|
||||
.DbSetPlantLog
|
||||
.Where(x => x.FluxType == "Level" && x.PlantId == PlantId)
|
||||
.OrderBy(x => x.DtEvent)
|
||||
.Take(maxRecords)
|
||||
.ToList();
|
||||
|
||||
var rawMainPressData = dbCtx
|
||||
.DbSetPlantLog
|
||||
.Where(x => x.FluxType == "MainPress" && x.PlantId == PlantId)
|
||||
.OrderBy(x => x.DtEvent)
|
||||
.Take(maxRecords)
|
||||
.ToList();
|
||||
var rawMainPressData = dbCtxMult
|
||||
.DbSetPlantLog
|
||||
.Where(x => x.FluxType == "MainPress" && x.PlantId == PlantId)
|
||||
.OrderBy(x => x.DtEvent)
|
||||
.Take(maxRecords)
|
||||
.ToList();
|
||||
|
||||
var rawBHPressData = dbCtx
|
||||
.DbSetPlantLog
|
||||
.Where(x => x.FluxType == "PressBH" && x.PlantId == PlantId)
|
||||
.OrderBy(x => x.DtEvent)
|
||||
.Take(maxRecords)
|
||||
.ToList();
|
||||
var rawBHPressData = dbCtxMult
|
||||
.DbSetPlantLog
|
||||
.Where(x => x.FluxType == "PressBH" && x.PlantId == PlantId)
|
||||
.OrderBy(x => x.DtEvent)
|
||||
.Take(maxRecords)
|
||||
.ToList();
|
||||
|
||||
var rawBLPressData = dbCtx
|
||||
.DbSetPlantLog
|
||||
.Where(x => x.FluxType == "PressBL" && x.PlantId == PlantId)
|
||||
.OrderBy(x => x.DtEvent)
|
||||
.Take(maxRecords)
|
||||
.ToList();
|
||||
var rawBLPressData = dbCtxMult
|
||||
.DbSetPlantLog
|
||||
.Where(x => x.FluxType == "PressBL" && x.PlantId == PlantId)
|
||||
.OrderBy(x => x.DtEvent)
|
||||
.Take(maxRecords)
|
||||
.ToList();
|
||||
|
||||
var rawOrderData = dbCtx
|
||||
.DbSetOrders
|
||||
.Where(x => x.PlantId == PlantId)
|
||||
.OrderBy(x => x.DtOrder)
|
||||
.Take(maxRecords)
|
||||
.ToList();
|
||||
var rawOrderData = dbCtxMult
|
||||
.DbSetOrders
|
||||
.Where(x => x.PlantId == PlantId)
|
||||
.OrderBy(x => x.DtOrder)
|
||||
.Take(maxRecords)
|
||||
.ToList();
|
||||
|
||||
LevelTS = rawLevelData
|
||||
.Select(x => new TSData() { DtEvent = x.DtEvent, ValDouble = x.ValNumber }).ToList();
|
||||
LevelTS = rawLevelData
|
||||
.Select(x => new TSData() { DtEvent = x.DtEvent, ValDouble = x.ValNumber }).ToList();
|
||||
|
||||
OrderTS = rawOrderData
|
||||
.Select(x => new TSData() { DtEvent = x.DtOrder, ValDouble = x.OrderQty }).ToList();
|
||||
OrderTS = rawOrderData
|
||||
.Select(x => new TSData() { DtEvent = x.DtOrder, ValDouble = x.OrderQty }).ToList();
|
||||
|
||||
PressMainTS = rawMainPressData
|
||||
.Select(x => new TSData() { DtEvent = x.DtEvent, ValDouble = x.ValNumber }).ToList();
|
||||
PressMainTS = rawMainPressData
|
||||
.Select(x => new TSData() { DtEvent = x.DtEvent, ValDouble = x.ValNumber }).ToList();
|
||||
|
||||
PressBHTS = rawBHPressData
|
||||
.Select(x => new TSData() { DtEvent = x.DtEvent, ValDouble = x.ValNumber }).ToList();
|
||||
PressBHTS = rawBHPressData
|
||||
.Select(x => new TSData() { DtEvent = x.DtEvent, ValDouble = x.ValNumber }).ToList();
|
||||
|
||||
PressBLTS = rawBLPressData
|
||||
.Select(x => new TSData() { DtEvent = x.DtEvent, ValDouble = x.ValNumber }).ToList();
|
||||
PressBLTS = rawBLPressData
|
||||
.Select(x => new TSData() { DtEvent = x.DtEvent, ValDouble = x.ValNumber }).ToList();
|
||||
|
||||
PressTS.Add("Main", PressMainTS);
|
||||
PressTS.Add("BH", PressBHTS);
|
||||
PressTS.Add("BL", PressBLTS);
|
||||
PressTS.Add("Main", PressMainTS);
|
||||
PressTS.Add("BH", PressBHTS);
|
||||
PressTS.Add("BL", PressBLTS);
|
||||
|
||||
double actLevel = LevelTS.Count > 0 ? LevelTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble : 0;
|
||||
double valMain = PressMainTS.Count > 0 ? PressMainTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble : 0;
|
||||
double valBH = PressBHTS.Count > 0 ? PressBHTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble : 0;
|
||||
double valBL = PressBLTS.Count > 0 ? PressBLTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble : 0;
|
||||
double actLevel = LevelTS.Count > 0 ? LevelTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble : 0;
|
||||
double valMain = PressMainTS.Count > 0 ? PressMainTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble : 0;
|
||||
double valBH = PressBHTS.Count > 0 ? PressBHTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble : 0;
|
||||
double valBL = PressBLTS.Count > 0 ? PressBLTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble : 0;
|
||||
|
||||
PressAct.Add("Main", valMain);
|
||||
PressAct.Add("BH", valBH);
|
||||
PressAct.Add("BL", valBL);
|
||||
PressAct.Add("Main", valMain);
|
||||
PressAct.Add("BH", valBH);
|
||||
PressAct.Add("BL", valBL);
|
||||
|
||||
PlantDTO answ = new PlantDTO()
|
||||
{
|
||||
PlantId = PlantId,
|
||||
PlantCode = currPlant.PlantCode,
|
||||
PlantDesc = currPlant.PlantDesc,
|
||||
LevelAct = actLevel,
|
||||
LevelMax = currPlant.LevelMax,
|
||||
PressAct = PressAct,
|
||||
LevelTS = LevelTS,
|
||||
PressTS = PressTS,
|
||||
OrderTS = OrderTS
|
||||
};
|
||||
// popolo valolri
|
||||
answ = new PlantDTO()
|
||||
{
|
||||
PlantId = PlantId,
|
||||
PlantCode = currPlant.PlantCode,
|
||||
PlantDesc = currPlant.PlantDesc,
|
||||
LevelAct = actLevel,
|
||||
LevelMax = currPlant.LevelMax,
|
||||
PressAct = PressAct,
|
||||
LevelTS = LevelTS,
|
||||
PressTS = PressTS,
|
||||
OrderTS = OrderTS
|
||||
};
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user