DD.WellWorkover.Cloud/AsbCloudInfrastructure/Services/SaubDataCache.cs

33 lines
941 B
C#
Raw Normal View History

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