DD.WellWorkover.Cloud/AsbCloudInfrastructure/Services/SaubDataCache.cs
Фролов 35cd538b1d Refactor DataSaubBase to TelemetryDataSaub;
Add generic TelemetryDataController;
Add TelemetryDataSpin and model;
Add migration;
2021-09-14 17:17:33 +05:00

33 lines
966 B
C#

using AsbCloudApp.Data;
using AsbCloudApp.Services;
using System.Collections.Generic;
namespace AsbCloudInfrastructure.Services
{
public class SaubDataCache : ISaubDataCache
{
public TelemetryAnalysisDto CurrentAnalysis { get; set; }
private readonly Dictionary<int, List<TelemetryDataSaubDto>> saubData =
new Dictionary<int, List<TelemetryDataSaubDto>>();
public IEnumerable<TelemetryDataSaubDto> GetOrCreateCache(int telemetryId)
{
if (!saubData.ContainsKey(telemetryId))
saubData[telemetryId] = new List<TelemetryDataSaubDto>();
return saubData[telemetryId];
}
public void AddData(TelemetryDataSaubDto data)
{
GetOrCreateCache(data.IdTelemetry);
saubData[data.IdTelemetry].Add(data);
if (saubData[data.IdTelemetry].Count > 10)
saubData[data.IdTelemetry].RemoveAt(1);
}
}
}