Test riscrittura flushredis + ottimizzazione insert remoteRebootLog
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user