100 lines
3.5 KiB
C#
100 lines
3.5 KiB
C#
using DD.Persistence.Client.Clients.Base;
|
|
using DD.Persistence.Client.Clients.Interfaces;
|
|
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
|
using DD.Persistence.Models;
|
|
using DD.Persistence.Models.Common;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace DD.Persistence.Client.Clients;
|
|
|
|
/// <inheritdoc/>
|
|
public class TimestampedValuesClient : BaseClient, ITimestampedValuesClient
|
|
{
|
|
private readonly IRefitTimestampedValuesClient refitTimestampedSetClient;
|
|
|
|
/// <inheritdoc/>
|
|
public TimestampedValuesClient(IRefitClientFactory<IRefitTimestampedValuesClient> refitTimestampedSetClientFactory, ILogger<TimestampedValuesClient> logger) : base(logger)
|
|
{
|
|
this.refitTimestampedSetClient = refitTimestampedSetClientFactory.Create();
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public async Task<int> AddRange(Guid discriminatorId, IEnumerable<TimestampedValuesDto> sets, CancellationToken token)
|
|
{
|
|
var result = await ExecutePostResponse(
|
|
async () => await refitTimestampedSetClient.AddRange(discriminatorId, sets, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public async Task<IEnumerable<TimestampedValuesDto>> Get(Guid discriminatorId, DateTimeOffset? geTimestamp, IEnumerable<string>? columnNames, int skip, int take, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitTimestampedSetClient.Get(discriminatorId, geTimestamp, columnNames, skip, take, token), token);
|
|
return result;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public async Task<IEnumerable<TimestampedValuesDto>> GetGtDate(Guid discriminatorId, DateTimeOffset timestampBegin, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitTimestampedSetClient.GetGtDate(discriminatorId, timestampBegin, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public async Task<IEnumerable<TimestampedValuesDto>> GetFirst(Guid discriminatorId, int take, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitTimestampedSetClient.GetFirst(discriminatorId, take, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public async Task<IEnumerable<TimestampedValuesDto>> GetLast(Guid discriminatorId, int take, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitTimestampedSetClient.GetLast(discriminatorId, take, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public async Task<IEnumerable<TimestampedValuesDto>> GetResampledData(Guid discriminatorId, DateTimeOffset dateBegin, double intervalSec = 600, int approxPointsCount = 1024, CancellationToken token = default)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitTimestampedSetClient.GetResampledData(discriminatorId, dateBegin, intervalSec, approxPointsCount, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public async Task<int> Count(Guid discriminatorId, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitTimestampedSetClient.Count(discriminatorId, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public async Task<DatesRangeDto?> GetDatesRange(Guid discriminatorId, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitTimestampedSetClient.GetDatesRange(discriminatorId, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public void Dispose()
|
|
{
|
|
refitTimestampedSetClient.Dispose();
|
|
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
}
|