Add metering device import
This commit is contained in:
@ -118,6 +118,18 @@ namespace Hcs.Client.Api
|
||||
return await request.ExecuteAsync(payload, token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Импорт прибора учета
|
||||
/// </summary>
|
||||
/// <param name="meteringDevice">Прибор учета</param>
|
||||
/// <param name="token">Токен отмены</param>
|
||||
/// <returns>true, если операция выполнена успешно, иначе - false</returns>
|
||||
public async Task<bool> ImportMeteringDeviceDataAsync(MeteringDeviceFullInformationType meteringDevice, CancellationToken token = default)
|
||||
{
|
||||
var request = new ImportMeteringDeviceDataRequest(client);
|
||||
return await request.ExecuteAsync(meteringDevice, token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Импорт новости для информирования граждан
|
||||
/// </summary>
|
||||
|
||||
20
Hcs.Client/Client/Api/Registry/Registry16.cs
Normal file
20
Hcs.Client/Client/Api/Registry/Registry16.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using Hcs.Service.Async.HouseManagement;
|
||||
|
||||
namespace Hcs.Client.Api.Registry
|
||||
{
|
||||
/// <summary>
|
||||
/// НСИ "Межповерочный интервал" (реестровый номер 16).
|
||||
/// Взято из https://dom.gosuslugi.ru/opendataapi/nsi-16/v1.
|
||||
/// </summary>
|
||||
public static class Registry16
|
||||
{
|
||||
/// <summary>
|
||||
/// 4 года
|
||||
/// </summary>
|
||||
public static nsiRef Element4 => new()
|
||||
{
|
||||
Code = "4",
|
||||
GUID = "296aff1b-0fbe-4111-9aea-1693a6e58db0"
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
using Hcs.Client.Api.Request.Exception;
|
||||
using Hcs.Client.Internal;
|
||||
using Hcs.Service.Async.HouseManagement;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hcs.Client.Api.Request.HouseManagement
|
||||
{
|
||||
internal class ImportMeteringDeviceDataRequest(ClientBase client) : HouseManagementRequestBase(client)
|
||||
{
|
||||
protected override bool CanBeRestarted => false;
|
||||
|
||||
internal async Task<bool> ExecuteAsync(MeteringDeviceFullInformationType meteringDevice, CancellationToken token)
|
||||
{
|
||||
// http://open-gkh.ru/HouseManagement/importMeteringDeviceDataRequest.html
|
||||
var request = new importMeteringDeviceDataRequest
|
||||
{
|
||||
Id = Constants.SIGNED_XML_ELEMENT_ID,
|
||||
version = "11.1.0.8",
|
||||
MeteringDevice =
|
||||
[
|
||||
new importMeteringDeviceDataRequestMeteringDevice()
|
||||
{
|
||||
TransportGUID = Guid.NewGuid().ToString(),
|
||||
Item = meteringDevice
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var result = await SendAndWaitResultAsync(request, async asyncClient =>
|
||||
{
|
||||
var response = await asyncClient.importMeteringDeviceDataAsync(CreateRequestHeader(), request);
|
||||
return response.AckRequest.Ack;
|
||||
}, token);
|
||||
|
||||
result.Items.OfType<ErrorMessageType>().ToList().ForEach(error =>
|
||||
{
|
||||
throw RemoteException.CreateNew(error.ErrorCode, error.Description);
|
||||
});
|
||||
|
||||
var importResults = result.Items.OfType<getStateResultImportResult>();
|
||||
var commonResults = GetCommonResults(importResults);
|
||||
foreach (var commonResult in commonResults)
|
||||
{
|
||||
if (commonResult.ItemElementName == ItemChoiceType26.importMeteringDevice)
|
||||
{
|
||||
return commonResult.Item is getStateResultImportResultCommonResultImportMeteringDevice;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -74,6 +74,7 @@
|
||||
<Compile Include="Client\Api\Payload\HouseManagement\ImportLivingHouseUODataPayload.cs" />
|
||||
<Compile Include="Client\Api\Payload\HouseManagement\ImportNotificationDataPayload.cs" />
|
||||
<Compile Include="Client\Api\Payload\HouseManagement\ImportSupplyResourceContractDataPayload.cs" />
|
||||
<Compile Include="Client\Api\Registry\Registry16.cs" />
|
||||
<Compile Include="Client\Api\Registry\Registry239.cs" />
|
||||
<Compile Include="Client\Api\Registry\Registry24.cs" />
|
||||
<Compile Include="Client\Api\Registry\Registry276.cs" />
|
||||
@ -101,6 +102,7 @@
|
||||
<Compile Include="Client\Api\Request\HouseManagement\ImportAccountDataRequest.cs" />
|
||||
<Compile Include="Client\Api\Request\HouseManagement\ImportContractDataRequest.cs" />
|
||||
<Compile Include="Client\Api\Request\HouseManagement\ImportHouseUODataRequest.cs" />
|
||||
<Compile Include="Client\Api\Request\HouseManagement\ImportMeteringDeviceDataRequest.cs" />
|
||||
<Compile Include="Client\Api\Request\HouseManagement\ImportNotificationDataRequest.cs" />
|
||||
<Compile Include="Client\Api\Request\HouseManagement\ImportSupplyResourceContractDataRequest.cs" />
|
||||
<Compile Include="Client\Api\Request\NsiCommon\ExportNsiItemRequest.cs" />
|
||||
|
||||
Reference in New Issue
Block a user