56 lines
1.8 KiB
C#
56 lines
1.8 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using DD.Persistence.Client.Clients.Base;
|
|
using DD.Persistence.Client.Clients.Interfaces;
|
|
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
|
using DD.Persistence.Models;
|
|
|
|
namespace DD.Persistence.Client.Clients;
|
|
public class WitsDataClient : BaseClient, IWitsDataClient
|
|
{
|
|
private readonly IRefitWitsDataClient refitWitsDataClient;
|
|
|
|
public WitsDataClient(IRefitWitsDataClient refitWitsDataClient, ILogger<WitsDataClient> logger) : base(logger)
|
|
{
|
|
this.refitWitsDataClient = refitWitsDataClient;
|
|
}
|
|
|
|
public async Task<int> AddRange(IEnumerable<WitsDataDto> dtos, CancellationToken token)
|
|
{
|
|
var result = await ExecutePostResponse(
|
|
async () => await refitWitsDataClient.AddRange(dtos, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<DatesRangeDto> GetDatesRangeAsync(Guid discriminatorId, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitWitsDataClient.GetDatesRangeAsync(discriminatorId, token), token);
|
|
|
|
return result!;
|
|
}
|
|
|
|
public async Task<IEnumerable<WitsDataDto>> GetPart(Guid discriminatorId, DateTimeOffset dateBegin, int take = 86400, CancellationToken token = default)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitWitsDataClient.GetPart(discriminatorId, dateBegin, take, token), token);
|
|
|
|
return result!;
|
|
}
|
|
|
|
public async Task<IEnumerable<WitsDataDto>> GetValuesForGraph(Guid discriminatorId, DateTimeOffset dateFrom, DateTimeOffset dateTo, int approxPointsCount, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitWitsDataClient.GetValuesForGraph(discriminatorId, dateFrom, dateTo, approxPointsCount, token), token);
|
|
|
|
return result!;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
refitWitsDataClient.Dispose();
|
|
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
}
|