Startup. Initialize cache loading.

This commit is contained in:
ngfrolov 2023-05-19 16:27:24 +05:00
parent e9af9f7ddf
commit 9106658ebf
Signed by: ng.frolov
GPG Key ID: E99907A0357B29A7

View File

@ -10,6 +10,8 @@ using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Threading; using System.Threading;
using AsbCloudInfrastructure.Background; using AsbCloudInfrastructure.Background;
using AsbCloudApp.Data.SAUB;
using AsbCloudInfrastructure.Services.SAUB;
namespace AsbCloudInfrastructure namespace AsbCloudInfrastructure
{ {
@ -28,6 +30,9 @@ namespace AsbCloudInfrastructure
var wellService = provider.GetRequiredService<IWellService>(); var wellService = provider.GetRequiredService<IWellService>();
wellService.EnshureTimezonesIsSetAsync(CancellationToken.None).Wait();// TODO: make this background work wellService.EnshureTimezonesIsSetAsync(CancellationToken.None).Wait();// TODO: make this background work
_ = provider.GetRequiredService<TelemetryDataCache<TelemetryDataSaubDto>>();
_ = provider.GetRequiredService<TelemetryDataCache<TelemetryDataSpinDto>>();
var backgroundWorker = provider.GetRequiredService<BackgroundWorker>(); var backgroundWorker = provider.GetRequiredService<BackgroundWorker>();
backgroundWorker.Push(WellInfoService.MakeWork()); backgroundWorker.Push(WellInfoService.MakeWork());
backgroundWorker.Push(OperationDetectionWorkFactory.MakeWork()); backgroundWorker.Push(OperationDetectionWorkFactory.MakeWork());
@ -45,7 +50,7 @@ namespace AsbCloudInfrastructure
var workAction = (string _, IServiceProvider _, CancellationToken _) => { var workAction = (string _, IServiceProvider _, CancellationToken _) => {
var bytes = GC.GetTotalMemory(false); var bytes = GC.GetTotalMemory(false);
var bytesString = FromatBytes(bytes); var bytesString = FromatBytes(bytes);
System.Diagnostics.Trace.TraceInformation($"Total memory allocated is {bytesString} bytes. DbContext count is:{AsbCloudDb.Model.AsbCloudDbContext.ReferenceCount}"); System.Diagnostics.Trace.TraceInformation($"Total memory allocated is {bytesString} bytes. DbContext count is:{AsbCloudDbContext.ReferenceCount}");
return Task.CompletedTask; return Task.CompletedTask;
}; };
var workPeriod = TimeSpan.FromMinutes(1); var workPeriod = TimeSpan.FromMinutes(1);