Fix refresh post inserimento min spegnimento mancanti
This commit is contained in:
@@ -850,7 +850,7 @@ namespace MP.Data.Services
|
||||
public async Task<bool> FlushCache()
|
||||
{
|
||||
RedisValue pattern = new RedisValue($"{redisBaseKey}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
bool answ = await ExecFlushRedisPatternAsync(pattern);
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -861,7 +861,7 @@ namespace MP.Data.Services
|
||||
public async Task<bool> FlushCache(string KeyReq)
|
||||
{
|
||||
RedisValue pattern = new RedisValue($"{redisBaseKey}:{KeyReq}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
bool answ = await ExecFlushRedisPatternAsync(pattern);
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -921,11 +921,15 @@ namespace MP.Data.Services
|
||||
/// <summary>
|
||||
/// Elenco DTO x plotting seq stati giornaliero
|
||||
/// </summary>
|
||||
/// <param name="listDetail">Dettagli</param>
|
||||
/// <param name="listDetail">Record dettaglio giornata</param>
|
||||
/// <returns></returns>
|
||||
public List<ManualStatusDTO> SeqDayStatus(List<InsManualiModel> listDetail)
|
||||
public List<ManualStatusDTO> InsManSeqDayStatus(List<InsManualiModel> listDetail)
|
||||
{
|
||||
List<ManualStatusDTO>? result = new List<ManualStatusDTO>();
|
||||
// per sicurezza RIORDINO!
|
||||
listDetail = listDetail
|
||||
.OrderBy(x => x.InizioStato)
|
||||
.ToList();
|
||||
if (listDetail.Count > 0)
|
||||
{
|
||||
DateTime periodStart = listDetail.FirstOrDefault().InizioStato;
|
||||
@@ -1009,6 +1013,75 @@ namespace MP.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Riempie eventuali buchi con evento indicato
|
||||
/// </summary>
|
||||
/// <param name="listDetail">Record dettaglio giornata</param>
|
||||
/// <param name="idxTipoEv">IdxTipo da riempire</param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> InsManFillMissing(List<InsManualiModel> listDetail, int idxTipoEv)
|
||||
{
|
||||
List<InsManualiModel> rec2add = new List<InsManualiModel>();
|
||||
InsManualiModel newRec = new InsManualiModel();
|
||||
if (listDetail.Count > 0)
|
||||
{
|
||||
// punto come record attuale il primo
|
||||
InsManualiModel currRec = listDetail.FirstOrDefault();
|
||||
|
||||
string idxMacc = currRec.IdxMacchina;
|
||||
DateTime periodStart = currRec.InizioStato;
|
||||
DateTime periodEnd = currRec.FineStato.Value;
|
||||
|
||||
// se NON parte da mezzanotte metto un "pad iniziale"...
|
||||
if (periodStart.TimeOfDay > new TimeSpan(0))
|
||||
{
|
||||
// creo record x la durata necessaria
|
||||
newRec = new InsManualiModel()
|
||||
{
|
||||
CodArticolo = "ND",
|
||||
KeyRichiesta = "",
|
||||
IdxMacchina = idxMacc,
|
||||
InizioStato = periodStart.Date,
|
||||
FineStato = periodStart,
|
||||
IdxTipoEv = idxTipoEv,
|
||||
MatrOpr = 0,
|
||||
PzBuoni = 0,
|
||||
TCiclo = 0,
|
||||
MinProd = (decimal)periodStart.TimeOfDay.TotalMinutes
|
||||
};
|
||||
rec2add.Add(newRec);
|
||||
}
|
||||
|
||||
// cerco ultimo record...
|
||||
currRec = listDetail.LastOrDefault();
|
||||
periodStart = currRec.InizioStato;
|
||||
periodEnd = currRec.FineStato.Value;
|
||||
// se non arrivo a mezzanotte aggiungo "pad finale"
|
||||
var lastPeriod = TimeSpan.FromHours(24).Subtract(periodEnd.TimeOfDay).TotalMinutes;
|
||||
if (lastPeriod > 1)
|
||||
{
|
||||
// creo record x la durata necessaria
|
||||
newRec = new InsManualiModel()
|
||||
{
|
||||
CodArticolo = "ND",
|
||||
KeyRichiesta = "",
|
||||
IdxMacchina = idxMacc,
|
||||
InizioStato = periodEnd,
|
||||
FineStato = periodEnd.Date.AddDays(1).AddSeconds(-1),
|
||||
IdxTipoEv = idxTipoEv,
|
||||
MatrOpr = 0,
|
||||
PzBuoni = 0,
|
||||
TCiclo = 0,
|
||||
MinProd = (decimal)lastPeriod
|
||||
};
|
||||
rec2add.Add(newRec);
|
||||
}
|
||||
// eseguo upsert massivo
|
||||
await InsManUpsert(rec2add);
|
||||
}
|
||||
return rec2add.Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco insManuali macchina
|
||||
/// </summary>
|
||||
@@ -1056,8 +1129,8 @@ namespace MP.Data.Services
|
||||
// salvo
|
||||
fatto = dbTabController.InsManUpsert(currRecord);
|
||||
// svuoto cache
|
||||
RedisValue pattern = $"{redisBaseKey}:InsMan";
|
||||
await ExecFlushRedisPattern(pattern);
|
||||
RedisValue pattern = $"{redisBaseKey}:InsMan:*";
|
||||
await ExecFlushRedisPatternAsync(pattern);
|
||||
return fatto;
|
||||
}
|
||||
/// <summary>
|
||||
@@ -1070,8 +1143,8 @@ namespace MP.Data.Services
|
||||
// salvo
|
||||
fatto = dbTabController.InsManUpsert(listRecord);
|
||||
// svuoto cache
|
||||
RedisValue pattern = $"{redisBaseKey}:InsMan";
|
||||
await ExecFlushRedisPattern(pattern);
|
||||
RedisValue pattern = $"{redisBaseKey}:InsMan:*";
|
||||
await ExecFlushRedisPatternAsync(pattern);
|
||||
return fatto;
|
||||
}
|
||||
|
||||
@@ -1996,7 +2069,7 @@ namespace MP.Data.Services
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
var done = await ExecFlushRedisPattern(currKey);
|
||||
var done = await ExecFlushRedisPatternAsync(currKey);
|
||||
if (done)
|
||||
{
|
||||
answ = true;
|
||||
@@ -2830,7 +2903,7 @@ namespace MP.Data.Services
|
||||
{
|
||||
pattern = new RedisValue($"{MpIoNS}:{baseMem}:*");
|
||||
}
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
bool answ = await ExecFlushRedisPatternAsync(pattern);
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -3721,11 +3794,11 @@ namespace MP.Data.Services
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Esegue flush memoria redis dato pattern
|
||||
/// Esegue flush memoria redis dato pattern in async
|
||||
/// </summary>
|
||||
/// <param name="pattern"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> ExecFlushRedisPattern(RedisValue pattern)
|
||||
private async Task<bool> ExecFlushRedisPatternAsync(RedisValue pattern)
|
||||
{
|
||||
bool answ = false;
|
||||
var listEndpoints = redisConn.GetEndPoints();
|
||||
@@ -3748,6 +3821,34 @@ namespace MP.Data.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue flush memoria redis dato pattern, metodo sincrono
|
||||
/// </summary>
|
||||
/// <param name="pattern"></param>
|
||||
/// <returns></returns>
|
||||
private bool ExecFlushRedisPattern(RedisValue pattern)
|
||||
{
|
||||
bool answ = false;
|
||||
var listEndpoints = redisConn.GetEndPoints();
|
||||
foreach (var endPoint in listEndpoints)
|
||||
{
|
||||
//var server = redisConnAdmin.GetServer(listEndpoints[0]);
|
||||
var server = redisConn.GetServer(endPoint);
|
||||
if (server != null)
|
||||
{
|
||||
var keyList = server.Keys(redisDb.Database, pattern);
|
||||
foreach (var item in keyList)
|
||||
{
|
||||
redisDb.KeyDelete(item);
|
||||
}
|
||||
answ = true;
|
||||
}
|
||||
}
|
||||
// notifico update ai client in ascolto x reset cache
|
||||
NotifyReloadRequest($"FlushRedisCache | {pattern}");
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hash dati EXE TASK x la macchina specificata
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user