DetectedOperationService temporary fix timezone problem

This commit is contained in:
ngfrolov 2024-03-29 08:49:26 +05:00
parent dd934bb1c5
commit 38521940a6
Signed by: ng.frolov
GPG Key ID: E99907A0357B29A7
2 changed files with 10 additions and 3 deletions

View File

@ -11,6 +11,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AsbCloudInfrastructure.Services.DetectOperations.Detectors;
using AsbCloudInfrastructure.Services.SAUB;
namespace AsbCloudInfrastructure.Services.DetectOperations;
@ -142,7 +143,7 @@ public class DetectedOperationService : IDetectedOperationService
const int minOperationLength = 5;
const int maxDetectorsInterpolationFrameLength = 30;
const int gap = maxDetectorsInterpolationFrameLength + minOperationLength;
var timeIncrement = TimeSpan.FromSeconds(1);
//var timezone = telemetryService.GetTimezone(idTelemetry);
while (true)
{
@ -155,6 +156,7 @@ public class DetectedOperationService : IDetectedOperationService
var detectableTelemetries = (await telemetryDataSaubService.GetByTelemetryAsync(idTelemetry, request, token))
.Where(t => t.BlockPosition >= 0)
.Select(t => t as TelemetryNewDataSaubDto)
.Select(t => new DetectableTelemetry
{
DateTime = t.DateTime,//TODO: <-- вот тут ошибка при присвоении DateTime с kind unspecified в DateTimeOffset времени назначается локальный часовой пояс.

View File

@ -16,6 +16,11 @@ using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services.SAUB;
class TelemetryNewDataSaubDto : TelemetryDataSaubDto
{
public new DateTimeOffset DateTime { get; set; }
}
public class TelemetryDataSaubService : TelemetryDataBaseService<TelemetryDataSaubDto, TelemetryDataSaub>, ITelemetryDataSaubService
{
private readonly ITelemetryUserService telemetryUserService;
@ -124,10 +129,10 @@ public class TelemetryDataSaubService : TelemetryDataBaseService<TelemetryDataSa
protected override TelemetryDataSaubDto Convert(TelemetryDataSaub src, double timezoneOffset)
{
var dto = src.Adapt<TelemetryDataSaubDto>();
var dto = src.Adapt<TelemetryNewDataSaubDto>();
var telemetryUser = telemetryUserService.GetOrDefault(src.IdTelemetry, src.IdUser ?? int.MinValue);
dto.User = telemetryUser?.MakeDisplayName();
dto.DateTime = src.DateTime.ToRemoteDateTime(timezoneOffset);
dto.DateTime = src.DateTime.ToOffset(TimeSpan.FromHours(timezoneOffset)); // src.DateTime.ToRemoteDateTime(timezoneOffset);
dto.BitDepth = src.BitDepth <= src.WellDepth
? src.BitDepth
: src.WellDepth;