aggunta transazione
This commit is contained in:
@@ -135,6 +135,7 @@ namespace MP.Data.Controllers
|
||||
public async Task<bool> CheckCambiaStatoBatchAsync(tipoInputEvento tipoInput, string IdxMacchina, DateTime InizioStato, int IdxTipo, string CodArt, string Value, int MatrOpr, string pallet)
|
||||
{
|
||||
await using var dbCtx = new MoonProContext(_configuration);
|
||||
await using var tx = await dbCtx.Database.BeginTransactionAsync();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -195,10 +196,12 @@ namespace MP.Data.Controllers
|
||||
}
|
||||
|
||||
// Nessuna eccezione = successo
|
||||
await tx.CommitAsync();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await tx.RollbackAsync();
|
||||
// Log dettagliato errore
|
||||
Log.Error(ex, $"Errore in CheckCambiaStatoBatchAsync: {IdxMacchina} | {tipoInput}");
|
||||
throw; // O return false; se il chiamante gestisce fallimenti
|
||||
|
||||
Reference in New Issue
Block a user