forked from ddrilling/AsbCloudServer
44 lines
1.6 KiB
C#
44 lines
1.6 KiB
C#
using AsbCloudApp.Data.SAUB;
|
|
using AsbCloudApp.Services;
|
|
using AsbCloudDb.Model;
|
|
using AsbCloudInfrastructure.Services.Cache;
|
|
using DocumentFormat.OpenXml.Drawing.Charts;
|
|
using Mapster;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AsbCloudInfrastructure.Services.SAUB
|
|
{
|
|
public class TelemetryDataSaubService : TelemetryDataBaseService<TelemetryDataSaubDto, TelemetryDataSaub>
|
|
{
|
|
public TelemetryDataSaubService(
|
|
IAsbCloudDbContext db,
|
|
ITelemetryService telemetryService,
|
|
CacheDb cacheDb)
|
|
: base(db, telemetryService, cacheDb)
|
|
{ }
|
|
|
|
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;
|
|
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();
|
|
dto.DateTime = src.DateTime.ToRemoteDateTime(timezoneOffset);
|
|
return dto;
|
|
}
|
|
}
|
|
}
|