Update editing insMan
This commit is contained in:
+135
-118
@@ -918,99 +918,20 @@ namespace MP.Data.Services
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco DTO x plotting seq stati giornaliero
|
||||
/// Elimina record + svuotamento cache
|
||||
/// </summary>
|
||||
/// <param name="listDetail">Record dettaglio giornata</param>
|
||||
/// <returns></returns>
|
||||
public List<ManualStatusDTO> InsManSeqDayStatus(List<InsManualiModel> listDetail)
|
||||
/// <param name="currRecord"></param>
|
||||
public async Task<bool> InsManDelete(InsManualiModel currRecord)
|
||||
{
|
||||
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;
|
||||
DateTime periodEnd = listDetail.FirstOrDefault().FineStato.Value;
|
||||
double duration = 0;
|
||||
int lastIdxTipo = -1;
|
||||
ManualStatusDTO currRec = new ManualStatusDTO();
|
||||
// se NON parte da mezzanotte metto un "pad iniziale"...
|
||||
if (periodStart.TimeOfDay > new TimeSpan(0))
|
||||
{
|
||||
lastIdxTipo = 0;
|
||||
currRec = new ManualStatusDTO
|
||||
{
|
||||
IdxTipo = lastIdxTipo,
|
||||
CssBlock = "bg-light text-dark",
|
||||
Title = "missing",
|
||||
Value = periodStart.TimeOfDay.TotalMinutes,
|
||||
ValueMax = 1440
|
||||
};
|
||||
}
|
||||
// ciclo tutti i record, verificando idxTipo...
|
||||
foreach (var item in listDetail)
|
||||
{
|
||||
if (item.IdxTipoEv != lastIdxTipo)
|
||||
{
|
||||
// aggiungo rec precedente... se > 0
|
||||
if (currRec.Value > 0)
|
||||
{
|
||||
result.Add(currRec);
|
||||
}
|
||||
lastIdxTipo = item.IdxTipoEv;
|
||||
periodStart = item.InizioStato;
|
||||
periodEnd = item.FineStato.Value;
|
||||
duration = (double)item.MinProd;
|
||||
currRec = new ManualStatusDTO
|
||||
{
|
||||
IdxTipo = lastIdxTipo,
|
||||
// fare da DB --> anagEventi
|
||||
CssBlock = item.IdxTipoEv == 1 ? "bg-success text-light" : "bg-secondary text-light",
|
||||
Title = $"{periodStart:HH:mm}-{periodEnd:HH:mm}",
|
||||
Value = duration,
|
||||
ValueMax = 1440
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
duration += (double)item.MinProd;
|
||||
periodEnd = item.FineStato.Value;
|
||||
currRec = new ManualStatusDTO
|
||||
{
|
||||
IdxTipo = lastIdxTipo,
|
||||
// fare da DB --> anagEventi
|
||||
CssBlock = item.IdxTipoEv == 1 ? "bg-success text-light" : "bg-secondary text-light",
|
||||
Title = $"{periodStart:HH:mm}-{periodEnd:HH:mm}",
|
||||
Value = duration,
|
||||
ValueMax = 1440
|
||||
};
|
||||
}
|
||||
}
|
||||
// aggiungo rec precedente... se > 0
|
||||
if (currRec.Value > 0)
|
||||
{
|
||||
result.Add(currRec);
|
||||
}
|
||||
// se non arrivo a mezzanotte aggiungo "pad finale"
|
||||
var deltaFin = TimeSpan.FromHours(24).Subtract(periodEnd.TimeOfDay);
|
||||
if (deltaFin.TotalMinutes > 1)
|
||||
{
|
||||
lastIdxTipo = 0;
|
||||
currRec = new ManualStatusDTO
|
||||
{
|
||||
IdxTipo = lastIdxTipo,
|
||||
CssBlock = "bg-light text-dark",
|
||||
Title = "missing",
|
||||
Value = deltaFin.TotalMinutes,
|
||||
ValueMax = 1440
|
||||
};
|
||||
result.Add(currRec);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
bool fatto = false;
|
||||
// salvo
|
||||
fatto = dbTabController.InsManDelete(currRecord);
|
||||
// svuoto cache
|
||||
RedisValue pattern = $"{redisBaseKey}:InsMan:*";
|
||||
await ExecFlushRedisPatternAsync(pattern);
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1120,6 +1041,101 @@ namespace MP.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco DTO x plotting seq stati giornaliero
|
||||
/// </summary>
|
||||
/// <param name="listDetail">Record dettaglio giornata</param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
DateTime periodEnd = listDetail.FirstOrDefault().FineStato.Value;
|
||||
double duration = 0;
|
||||
int lastIdxTipo = -1;
|
||||
ManualStatusDTO currRec = new ManualStatusDTO();
|
||||
// se NON parte da mezzanotte metto un "pad iniziale"...
|
||||
if (periodStart.TimeOfDay > new TimeSpan(0))
|
||||
{
|
||||
lastIdxTipo = 0;
|
||||
currRec = new ManualStatusDTO
|
||||
{
|
||||
IdxTipo = lastIdxTipo,
|
||||
CssBlock = "bg-light text-dark",
|
||||
Title = "missing",
|
||||
Value = periodStart.TimeOfDay.TotalMinutes,
|
||||
ValueMax = 1440
|
||||
};
|
||||
}
|
||||
// ciclo tutti i record, verificando idxTipo...
|
||||
foreach (var item in listDetail)
|
||||
{
|
||||
if (item.IdxTipoEv != lastIdxTipo)
|
||||
{
|
||||
// aggiungo rec precedente... se > 0
|
||||
if (currRec.Value > 0)
|
||||
{
|
||||
result.Add(currRec);
|
||||
}
|
||||
lastIdxTipo = item.IdxTipoEv;
|
||||
periodStart = item.InizioStato;
|
||||
periodEnd = item.FineStato.Value;
|
||||
duration = (double)item.MinProd;
|
||||
currRec = new ManualStatusDTO
|
||||
{
|
||||
IdxTipo = lastIdxTipo,
|
||||
// fare da DB --> anagEventi
|
||||
CssBlock = item.IdxTipoEv == 1 ? "bg-success text-light" : "bg-secondary text-light",
|
||||
Title = $"{periodStart:HH:mm}-{periodEnd:HH:mm}",
|
||||
Value = duration,
|
||||
ValueMax = 1440
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
duration += (double)item.MinProd;
|
||||
periodEnd = item.FineStato.Value;
|
||||
currRec = new ManualStatusDTO
|
||||
{
|
||||
IdxTipo = lastIdxTipo,
|
||||
// fare da DB --> anagEventi
|
||||
CssBlock = item.IdxTipoEv == 1 ? "bg-success text-light" : "bg-secondary text-light",
|
||||
Title = $"{periodStart:HH:mm}-{periodEnd:HH:mm}",
|
||||
Value = duration,
|
||||
ValueMax = 1440
|
||||
};
|
||||
}
|
||||
}
|
||||
// aggiungo rec precedente... se > 0
|
||||
if (currRec.Value > 0)
|
||||
{
|
||||
result.Add(currRec);
|
||||
}
|
||||
// se non arrivo a mezzanotte aggiungo "pad finale"
|
||||
var deltaFin = TimeSpan.FromHours(24).Subtract(periodEnd.TimeOfDay);
|
||||
if (deltaFin.TotalMinutes > 1)
|
||||
{
|
||||
lastIdxTipo = 0;
|
||||
currRec = new ManualStatusDTO
|
||||
{
|
||||
IdxTipo = lastIdxTipo,
|
||||
CssBlock = "bg-light text-dark",
|
||||
Title = "missing",
|
||||
Value = deltaFin.TotalMinutes,
|
||||
ValueMax = 1440
|
||||
};
|
||||
result.Add(currRec);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue salvataggio record + svuotamento cache
|
||||
/// </summary>
|
||||
@@ -1134,6 +1150,7 @@ namespace MP.Data.Services
|
||||
await ExecFlushRedisPatternAsync(pattern);
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue salvataggio record + svuotamento cache
|
||||
/// </summary>
|
||||
@@ -3794,34 +3811,6 @@ namespace MP.Data.Services
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Esegue flush memoria redis dato pattern in async
|
||||
/// </summary>
|
||||
/// <param name="pattern"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> ExecFlushRedisPatternAsync(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)
|
||||
{
|
||||
await redisDb.KeyDeleteAsync(item);
|
||||
}
|
||||
answ = true;
|
||||
}
|
||||
}
|
||||
// notifico update ai client in ascolto x reset cache
|
||||
NotifyReloadRequest($"FlushRedisCache | {pattern}");
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue flush memoria redis dato pattern, metodo sincrono
|
||||
/// </summary>
|
||||
@@ -3850,6 +3839,34 @@ namespace MP.Data.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue flush memoria redis dato pattern in async
|
||||
/// </summary>
|
||||
/// <param name="pattern"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> ExecFlushRedisPatternAsync(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)
|
||||
{
|
||||
await redisDb.KeyDeleteAsync(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