Fix random crash

This commit is contained in:
Tech Garage 2024-02-08 14:23:43 +03:30
parent 393da2a352
commit 331c83d7f9

View file

@ -154,14 +154,6 @@ namespace MTWireGuard.Application
lastKnown.TX = old.TX;
lastKnown.CreationTime = DateTime.Now;
dbContext.LastKnownTraffic.Update(lastKnown);
//if (lastKnown != null)
//{
// dbContext.LastKnownTraffic.Update(lastKnown);
//}
//else
//{
// await dbContext.LastKnownTraffic.AddAsync(lastKnown);
//}
item.ResetNotes = $"System reset detected at: {DateTime.Now}";
await dbContext.DataUsages.AddAsync(item);
}
@ -181,9 +173,13 @@ namespace MTWireGuard.Application
await dbContext.SaveChangesAsync();
transaction.Commit();
}
catch (DbUpdateException ex)
{
Console.WriteLine(ex.Message);
transaction.Rollback();
}
catch (Exception ex)
{
transaction.Rollback();
Console.WriteLine(ex.Message);
}
}