Add more variants
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
using Hcs.Client.Api.Request.HouseManagement;
|
||||
using Hcs.Service.Async.HouseManagement;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -9,6 +10,17 @@ namespace Hcs.Client.Api
|
||||
// http://open-gkh.ru/HouseManagementServiceAsync/
|
||||
public class HouseManagementApi(ClientBase client) : ApiBase(client)
|
||||
{
|
||||
/// <summary>
|
||||
/// Возвращает все договора ресурсоснабжения
|
||||
/// </summary>
|
||||
/// <param name="token">Токен отмены</param>
|
||||
/// <returns>Договора ресурсоснабжения</returns>
|
||||
public async Task<IEnumerable<exportSupplyResourceContractResultType>> ExportSupplyResourceContractDataAsync(CancellationToken token = default)
|
||||
{
|
||||
var request = new ExportSupplyResourceContractDataRequest(client);
|
||||
return await request.ExecuteAsync(token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает договор ресурсоснабжения по его идентификатору в ГИС ЖКХ
|
||||
/// </summary>
|
||||
@ -20,5 +32,17 @@ namespace Hcs.Client.Api
|
||||
var request = new ExportSupplyResourceContractDataRequest(client);
|
||||
return await request.ExecuteAsync(contractRootGuid, token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает договор ресурсоснабжения по номеру договора в ГИС ЖКХ
|
||||
/// </summary>
|
||||
/// <param name="contractNumber">Номер договора ресурсоснабжения в ГИС ЖКХ</param>
|
||||
/// <param name="token">Токен отмены</param>
|
||||
/// <returns>Договор ресурсоснабжения</returns>
|
||||
public async Task<exportSupplyResourceContractResultType> ExportSupplyResourceContractDataAsync(string contractNumber, CancellationToken token = default)
|
||||
{
|
||||
var request = new ExportSupplyResourceContractDataRequest(client);
|
||||
return await request.ExecuteAsync(contractNumber, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,13 +12,45 @@ namespace Hcs.Client.Api.Request.HouseManagement
|
||||
{
|
||||
protected override bool EnableMinimalResponseWaitDelay => false;
|
||||
|
||||
internal async Task<IEnumerable<exportSupplyResourceContractResultType>> ExecuteAsync(CancellationToken token)
|
||||
{
|
||||
var result = new List<exportSupplyResourceContractResultType>();
|
||||
|
||||
void OnResultReceived(exportSupplyResourceContractResultType[] contracts)
|
||||
{
|
||||
if (contracts?.Length > 0)
|
||||
{
|
||||
result.AddRange(contracts);
|
||||
}
|
||||
}
|
||||
|
||||
var pageNum = 0;
|
||||
Guid? exportContractRootGuid = null;
|
||||
while (true)
|
||||
{
|
||||
pageNum++;
|
||||
|
||||
client.TryLog($"Querying page #{pageNum}...");
|
||||
|
||||
var data = await QueryBatchAsync(null, null, exportContractRootGuid, OnResultReceived, token);
|
||||
if (data.IsLastPage)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
exportContractRootGuid = data.NextGuid;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal async Task<exportSupplyResourceContractResultType> ExecuteAsync(Guid contractRootGuid, CancellationToken token)
|
||||
{
|
||||
exportSupplyResourceContractResultType result = null;
|
||||
|
||||
void OnResultReceived(exportSupplyResourceContractResultType[] contracts)
|
||||
{
|
||||
result = contracts.Length > 0 ? contracts[0] : null;
|
||||
result = contracts?.Length > 0 ? contracts[0] : null;
|
||||
}
|
||||
|
||||
await QueryBatchAsync(contractRootGuid, null, null, OnResultReceived, token);
|
||||
@ -26,6 +58,20 @@ namespace Hcs.Client.Api.Request.HouseManagement
|
||||
return result;
|
||||
}
|
||||
|
||||
internal async Task<exportSupplyResourceContractResultType> ExecuteAsync(string contractNumber, CancellationToken token)
|
||||
{
|
||||
exportSupplyResourceContractResultType result = null;
|
||||
|
||||
void OnResultReceived(exportSupplyResourceContractResultType[] contracts)
|
||||
{
|
||||
result = contracts?.Length > 0 ? contracts[0] : null;
|
||||
}
|
||||
|
||||
await QueryBatchAsync(null, contractNumber, null, OnResultReceived, token);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task<PaginationData> QueryBatchAsync(
|
||||
Guid? contractRootGuid, string contractNumber, Guid? exportContractRootGuid,
|
||||
Action<exportSupplyResourceContractResultType[]> onResultReceived,
|
||||
|
||||
Reference in New Issue
Block a user