Fix TelemetryDataCache<TDto>.InitializeCacheFromDBAsync

This commit is contained in:
ngfrolov 2023-10-26 09:13:56 +05:00
parent 26f01eb236
commit 8d17a88f3d
Signed by: ng.frolov
GPG Key ID: E99907A0357B29A7

View File

@ -163,15 +163,16 @@ namespace AsbCloudInfrastructure.Services.SAUB
private async Task InitializeCacheFromDBAsync<TEntity>(IAsbCloudDbContext db, Action<string, double?> onProgress, CancellationToken token)
where TEntity : class, AsbCloudDb.Model.ITelemetryData
{
try
{
if (isLoading)
throw new Exception("Multiple cache loading detected.");
var defaultTimeout = db.Database.GetCommandTimeout();
db.Database.SetCommandTimeout(TimeSpan.FromMinutes(5));
if (isLoading)
throw new Exception("Multiple cache loading detected.");
try
{
isLoading = true;
db.Database.SetCommandTimeout(TimeSpan.FromMinutes(5));
Well[] wells = await db.Set<Well>()
.Include(well => well.Telemetry)
.Include(well => well.Cluster)
@ -198,7 +199,6 @@ namespace AsbCloudInfrastructure.Services.SAUB
finally
{
isLoading = false;
var defaultTimeout = db.Database.GetCommandTimeout();
db.Database.SetCommandTimeout(defaultTimeout);
}
}