75 lines
2.3 KiB
C#
75 lines
2.3 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;
|
|
using DD.Persistence.Models.Requests;
|
|
using DD.Persistence.Models.Common;
|
|
|
|
namespace DD.Persistence.Client.Clients;
|
|
|
|
public class TechMessagesClient : BaseClient, ITechMessagesClient
|
|
{
|
|
private readonly IRefitTechMessagesClient refitTechMessagesClient;
|
|
|
|
public TechMessagesClient(IRefitClientFactory<IRefitTechMessagesClient> refitTechMessagesClientFactory, ILogger<TechMessagesClient> logger) : base(logger)
|
|
{
|
|
this.refitTechMessagesClient = refitTechMessagesClientFactory.Create();
|
|
}
|
|
|
|
public async Task<PaginationContainer<TechMessageDto>> GetPage(PaginationRequest request, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitTechMessagesClient.GetPage(request, token), token);
|
|
|
|
return result!;
|
|
}
|
|
|
|
public async Task<int> AddRange(Guid systemId, IEnumerable<TechMessageDto> dtos, CancellationToken token)
|
|
{
|
|
var result = await ExecutePostResponse(
|
|
async () => await refitTechMessagesClient.AddRange(systemId, dtos, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<IEnumerable<DataSourceSystemDto>> GetSystems(CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitTechMessagesClient.GetSystems(token), token);
|
|
|
|
return result!;
|
|
}
|
|
|
|
public async Task<DatesRangeDto?> GetDatesRangeAsync(CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitTechMessagesClient.GetDatesRangeAsync(token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<IEnumerable<TechMessageDto>> GetPart(DateTimeOffset dateBegin, int take, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitTechMessagesClient.GetPart(dateBegin, take, token), token);
|
|
|
|
return result!;
|
|
}
|
|
|
|
public async Task<IEnumerable<MessagesStatisticDto>> GetStatistics(IEnumerable<Guid> systemIds, IEnumerable<int> categoryIds, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitTechMessagesClient.GetStatistics(systemIds, categoryIds, token), token);
|
|
|
|
return result!;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
refitTechMessagesClient.Dispose();
|
|
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
}
|