Fix TelemetryTracker dbContext disposing.

This commit is contained in:
Фролов 2021-11-23 16:12:41 +05:00
parent 6412c24a3e
commit a74032eed5
2 changed files with 8 additions and 9 deletions

View File

@ -44,7 +44,7 @@ namespace AsbCloudInfrastructure.Services
var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
.UseNpgsql(configuration.GetConnectionString("DefaultConnection"))
.Options;
using var db = new AsbCloudDbContext(options);
var db = new AsbCloudDbContext(options);
var cacheTelemetry = cacheDb.GetCachedTable<Telemetry>(db);
var keyValuePairs = new Dictionary<string, TrackerStat>(cacheTelemetry.Count());
@ -78,8 +78,6 @@ namespace AsbCloudInfrastructure.Services
.ToListAsync()
.ConfigureAwait(false);
db.Dispose();
var oldReqs = dates.Select(t => new
{
Uid = cacheTelemetry.FirstOrDefault(c => c.Id == t.IdTelemetry)?.RemoteUid,
@ -94,6 +92,10 @@ namespace AsbCloudInfrastructure.Services
telemetryStat.TelemetryDateMax = oldReq.DateMax;
telemetryStat.LastTimeServer = oldReq.DateMax;
}
}).ContinueWith((t) =>
{
db.Dispose();
return t;
});
}

View File

@ -58,9 +58,6 @@ namespace AsbCloudWebApi.Controllers
public async Task<IActionResult> GetClusterRopStatByUidAsync([FromRoute] string uid,
CancellationToken token = default)
{
// if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
// return Forbid();
var result = await operationsStatService.GetRopStatByUidAsync(
uid, token).ConfigureAwait(false);