forked from ddrilling/AsbCloudServer
Fix TelemetryTracker dbContext disposing.
This commit is contained in:
parent
6412c24a3e
commit
a74032eed5
@ -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());
|
||||
@ -65,7 +65,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
db.Database.SetCommandTimeout(2 * 60);
|
||||
db.Database.SetCommandTimeout(2 * 60);
|
||||
var dates = await db.TelemetryDataSaub
|
||||
.GroupBy(d => d.IdTelemetry)
|
||||
.Select(g => new
|
||||
@ -77,9 +77,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
.AsNoTracking()
|
||||
.ToListAsync()
|
||||
.ConfigureAwait(false);
|
||||
|
||||
db.Dispose();
|
||||
|
||||
|
||||
var oldReqs = dates.Select(t => new
|
||||
{
|
||||
Uid = cacheTelemetry.FirstOrDefault(c => c.Id == t.IdTelemetry)?.RemoteUid,
|
||||
@ -91,9 +89,13 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
var telemetryStat = telemetriesStats.GetOrAdd(oldReq.Uid, (uid) => new TrackerStat { RemoteUid = uid });
|
||||
telemetryStat.TelemetryDateMin = oldReq.DateMin;
|
||||
telemetryStat.TelemetryDateMax = oldReq.DateMax;
|
||||
telemetryStat.TelemetryDateMax = oldReq.DateMax;
|
||||
telemetryStat.LastTimeServer = oldReq.DateMax;
|
||||
}
|
||||
}).ContinueWith((t) =>
|
||||
{
|
||||
db.Dispose();
|
||||
return t;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user