Test riscrittura flushredis + ottimizzazione insert remoteRebootLog

This commit is contained in:
Samuele Locatelli
2026-04-27 11:20:09 +02:00
parent 7a01793bfd
commit 1cf7a61e74
9 changed files with 136 additions and 37 deletions
+28
View File
@@ -1051,6 +1051,34 @@ namespace MP.Data.Controllers
return await dbCtx.SaveChangesAsync() > 0;
}
/// <summary>
/// Aggiunta record RemoteRebootLog
/// </summary>
/// <param name="newRec"></param>
/// <returns></returns>
public async Task<bool> RemRebootLogAddAndCleanAsync(RemoteRebootLogModel newRec, int num2keep)
{
bool fatto = false;
using var dbCtx = new MoonProContext(_configuration);
using var transaction = await dbCtx.Database.BeginTransactionAsync();
try
{
dbCtx.DbSetRemRebLog.Add(newRec);
fatto = await dbCtx.SaveChangesAsync() > 0;
var param = new SqlParameter("@num2keep", num2keep);
await dbCtx.Database.ExecuteSqlRawAsync("EXEC dbo.stp_RRL_KeepLatest @num2keep", param);
await transaction.CommitAsync();
return true;
}
catch
{
await transaction.RollbackAsync();
throw;
}
}
/// <summary>
/// Recupera tutti i record di RemoteRebootLog