DD.WellWorkover.Cloud/AsbCloudInfrastructure/Services/SAUB/TelemetryDataSaubService.cs

45 lines
1.7 KiB
C#
Raw Normal View History

2022-04-08 13:10:06 +05:00
using AsbCloudApp.Data.SAUB;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using AsbCloudInfrastructure.Services.Cache;
2022-10-06 13:49:20 +05:00
using DocumentFormat.OpenXml.Drawing.Charts;
using Mapster;
2022-10-06 13:49:20 +05:00
using Microsoft.EntityFrameworkCore;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
2022-04-11 18:00:34 +05:00
namespace AsbCloudInfrastructure.Services.SAUB
{
2022-04-11 18:00:34 +05:00
public class TelemetryDataSaubService : TelemetryDataBaseService<TelemetryDataSaubDto, TelemetryDataSaub>
{
public TelemetryDataSaubService(
IAsbCloudDbContext db,
ITelemetryService telemetryService,
2022-11-15 17:44:48 +05:00
TelemetryDataCache<TelemetryDataSaubDto> telemetryDataCache,
CacheDb cacheDb)
2022-11-15 17:44:48 +05:00
: base(db, telemetryService, telemetryDataCache, cacheDb)
2022-04-11 18:00:34 +05:00
{ }
public override TelemetryDataSaub Convert(TelemetryDataSaubDto src, double timezoneOffset)
{
var entity = src.Adapt<TelemetryDataSaub>();
var telemetryUser = cacheTelemetryUsers?
.FirstOrDefault(u => u.IdTelemetry == src.IdTelemetry && (u.Name == src.User || u.Surname == src.User));
entity.IdUser = telemetryUser?.IdUser;
2022-04-08 13:10:06 +05:00
entity.DateTime = src.DateTime.ToUtcDateTimeOffset(timezoneOffset);
return entity;
}
public override TelemetryDataSaubDto Convert(TelemetryDataSaub src, double timezoneOffset)
{
var dto = src.Adapt<TelemetryDataSaubDto>();
var telemetryUser = cacheTelemetryUsers?
.FirstOrDefault(u => u.IdTelemetry == src.IdTelemetry && u.IdUser == src.IdUser);
dto.User = telemetryUser?.MakeDisplayName();
2022-04-08 13:10:06 +05:00
dto.DateTime = src.DateTime.ToRemoteDateTime(timezoneOffset);
return dto;
}
}
}