forked from ddrilling/AsbCloudServer
fix telemetry user id mapping
This commit is contained in:
parent
187c83a7b1
commit
16bd6749fd
@ -18,6 +18,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
private readonly ITelemetryService telemetryService;
|
||||
private readonly ITelemetryAnalyticsService analyticsService;
|
||||
private readonly CacheTable<Telemetry> cacheTelemetry;
|
||||
private readonly CacheTable<TelemetryUser> cacheTelemetryUsers;
|
||||
private readonly CacheTable<Well> cacheWells;
|
||||
|
||||
public DataService(IAsbCloudDbContext db, ITelemetryService telemetryService,
|
||||
@ -27,6 +28,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
this.telemetryService = telemetryService;
|
||||
this.analyticsService = analyticsService;
|
||||
cacheTelemetry = cacheDb.GetCachedTable<Telemetry>((AsbCloudDbContext)db);
|
||||
cacheTelemetryUsers = cacheDb.GetCachedTable<TelemetryUser>((AsbCloudDbContext)db);
|
||||
cacheWells = cacheDb.GetCachedTable<Well>((AsbCloudDbContext)db);
|
||||
}
|
||||
|
||||
@ -94,10 +96,13 @@ namespace AsbCloudInfrastructure.Services
|
||||
if (oldDataSaubBase.Any())
|
||||
db.DataSaubBases.RemoveRange(oldDataSaubBase);
|
||||
|
||||
|
||||
foreach (var dto in dtos)
|
||||
{
|
||||
var dataSaub = dto.Adapt<DataSaubBase>();
|
||||
var telemetryUser = await cacheTelemetryUsers
|
||||
.FirstOrDefaultAsync(u => u.IdTelemetry == telemetryId && (u.Name == dto.User || u.Surname == dto.User), token)
|
||||
.ConfigureAwait(false);
|
||||
dataSaub.IdUser = telemetryUser?.IdUser;
|
||||
dataSaub.IdTelemetry = telemetryId;
|
||||
db.DataSaubBases.Add(dataSaub);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user