forked from ddrilling/AsbCloudServer
увеличил timeout для ответа БД для фоновых задач.
This commit is contained in:
parent
d99d1a27a1
commit
6c722e5478
@ -22,6 +22,7 @@ public class WorkLimitingParameterCalc : Work
|
|||||||
protected override async Task Action(string id, IServiceProvider services, Action<string, double?> onProgressCallback, CancellationToken token)
|
protected override async Task Action(string id, IServiceProvider services, Action<string, double?> onProgressCallback, CancellationToken token)
|
||||||
{
|
{
|
||||||
using var db = services.GetRequiredService<IAsbCloudDbContext>();
|
using var db = services.GetRequiredService<IAsbCloudDbContext>();
|
||||||
|
db.Database.SetCommandTimeout(TimeSpan.FromMinutes(5));
|
||||||
var lastDetectedDates = await db.LimitingParameter
|
var lastDetectedDates = await db.LimitingParameter
|
||||||
.GroupBy(o => o.IdTelemetry)
|
.GroupBy(o => o.IdTelemetry)
|
||||||
.Select(g => new
|
.Select(g => new
|
||||||
|
@ -15,7 +15,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services.Subsystems;
|
namespace AsbCloudInfrastructure.Services.Subsystems;
|
||||||
|
|
||||||
public class WorkSubsystemOperationTimeCalc: Work
|
public class WorkSubsystemOperationTimeCalc : Work
|
||||||
{
|
{
|
||||||
private const int idSubsytemTorqueMaster = 65537;
|
private const int idSubsytemTorqueMaster = 65537;
|
||||||
private const int idSubsytemSpinMaster = 65536;
|
private const int idSubsytemSpinMaster = 65536;
|
||||||
@ -32,7 +32,7 @@ public class WorkSubsystemOperationTimeCalc: Work
|
|||||||
protected override async Task Action(string id, IServiceProvider services, Action<string, double?> onProgressCallback, CancellationToken token)
|
protected override async Task Action(string id, IServiceProvider services, Action<string, double?> onProgressCallback, CancellationToken token)
|
||||||
{
|
{
|
||||||
using var db = services.GetRequiredService<IAsbCloudDbContext>();
|
using var db = services.GetRequiredService<IAsbCloudDbContext>();
|
||||||
|
db.Database.SetCommandTimeout(TimeSpan.FromMinutes(5));
|
||||||
var lastDetectedDates = await db.SubsystemOperationTimes
|
var lastDetectedDates = await db.SubsystemOperationTimes
|
||||||
.GroupBy(o => o.IdTelemetry)
|
.GroupBy(o => o.IdTelemetry)
|
||||||
.Select(g => new
|
.Select(g => new
|
||||||
@ -61,7 +61,7 @@ public class WorkSubsystemOperationTimeCalc: Work
|
|||||||
var i = 0d;
|
var i = 0d;
|
||||||
foreach (var item in telemetryLastDetectedDates)
|
foreach (var item in telemetryLastDetectedDates)
|
||||||
{
|
{
|
||||||
onProgressCallback($"Start hanling telemetry: {item.IdTelemetry} from {item.LastDate}", i++ / count);
|
onProgressCallback($"Start handling telemetry: {item.IdTelemetry} from {item.LastDate}", i++ / count);
|
||||||
var newOperationsSaub = await OperationTimeSaubAsync(item.IdTelemetry, item.LastDate ?? DateTimeOffset.MinValue, db, token);
|
var newOperationsSaub = await OperationTimeSaubAsync(item.IdTelemetry, item.LastDate ?? DateTimeOffset.MinValue, db, token);
|
||||||
if (newOperationsSaub?.Any() == true)
|
if (newOperationsSaub?.Any() == true)
|
||||||
{
|
{
|
||||||
@ -114,7 +114,7 @@ public class WorkSubsystemOperationTimeCalc: Work
|
|||||||
$" lag(mode,1) over (order by date) as mode_lag, " +
|
$" lag(mode,1) over (order by date) as mode_lag, " +
|
||||||
$" lead(mode,1) over (order by date) as mode_lead " +
|
$" lead(mode,1) over (order by date) as mode_lead " +
|
||||||
$" from t_telemetry_data_saub " +
|
$" from t_telemetry_data_saub " +
|
||||||
$" where id_telemetry = {idTelemetry} and well_depth is not null and well_depth > 0" +
|
$" where id_telemetry = {idTelemetry} and well_depth is not null and well_depth > 0 " +
|
||||||
$" order by date ) as tt " +
|
$" order by date ) as tt " +
|
||||||
$"where (tt.mode_lag is null or (tt.mode != tt.mode_lag and tt.mode_lead != tt.mode_lag)) and tt.date >= '{begin:u}' " +
|
$"where (tt.mode_lag is null or (tt.mode != tt.mode_lag and tt.mode_lead != tt.mode_lag)) and tt.date >= '{begin:u}' " +
|
||||||
$"order by tt.date;";
|
$"order by tt.date;";
|
||||||
@ -278,7 +278,8 @@ public class WorkSubsystemOperationTimeCalc: Work
|
|||||||
.Where(d => d.WellDepth != null)
|
.Where(d => d.WellDepth != null)
|
||||||
.Where(d => d.WellDepth > 0)
|
.Where(d => d.WellDepth > 0)
|
||||||
.GroupBy(d => Math.Ceiling(d.WellDepth ?? 0 * 10))
|
.GroupBy(d => Math.Ceiling(d.WellDepth ?? 0 * 10))
|
||||||
.Select(g => new {
|
.Select(g => new
|
||||||
|
{
|
||||||
DateMin = g.Min(d => d.DateTime),
|
DateMin = g.Min(d => d.DateTime),
|
||||||
DepthMin = g.Min(d => d.WellDepth) ?? 0,
|
DepthMin = g.Min(d => d.WellDepth) ?? 0,
|
||||||
})
|
})
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudInfrastructure.Services.DetectOperations;
|
using AsbCloudInfrastructure.Services.DetectOperations;
|
||||||
using AsbCloudInfrastructure.Services.Subsystems;
|
|
||||||
using AsbCloudInfrastructure.Services;
|
using AsbCloudInfrastructure.Services;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
@ -12,6 +11,7 @@ using System.Threading;
|
|||||||
using AsbCloudInfrastructure.Background;
|
using AsbCloudInfrastructure.Background;
|
||||||
using AsbCloudApp.Data.SAUB;
|
using AsbCloudApp.Data.SAUB;
|
||||||
using AsbCloudInfrastructure.Services.SAUB;
|
using AsbCloudInfrastructure.Services.SAUB;
|
||||||
|
using AsbCloudInfrastructure.Services.Subsystems;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure
|
namespace AsbCloudInfrastructure
|
||||||
{
|
{
|
||||||
@ -23,7 +23,7 @@ namespace AsbCloudInfrastructure
|
|||||||
var provider = scope.ServiceProvider;
|
var provider = scope.ServiceProvider;
|
||||||
|
|
||||||
var context = provider.GetRequiredService<IAsbCloudDbContext>();
|
var context = provider.GetRequiredService<IAsbCloudDbContext>();
|
||||||
context.Database.SetCommandTimeout(TimeSpan.FromSeconds(2 * 60));
|
context.Database.SetCommandTimeout(TimeSpan.FromMinutes(5));
|
||||||
context.Database.Migrate();
|
context.Database.Migrate();
|
||||||
|
|
||||||
// TODO: Сделать инициализацию кеша телеметрии более явной.
|
// TODO: Сделать инициализацию кеша телеметрии более явной.
|
||||||
|
Loading…
Reference in New Issue
Block a user