Add metering device import
This commit is contained in:
@ -118,6 +118,18 @@ namespace Hcs.Client.Api
|
|||||||
return await request.ExecuteAsync(payload, token);
|
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>
|
||||||
/// Импорт новости для информирования граждан
|
/// Импорт новости для информирования граждан
|
||||||
/// </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\ImportLivingHouseUODataPayload.cs" />
|
||||||
<Compile Include="Client\Api\Payload\HouseManagement\ImportNotificationDataPayload.cs" />
|
<Compile Include="Client\Api\Payload\HouseManagement\ImportNotificationDataPayload.cs" />
|
||||||
<Compile Include="Client\Api\Payload\HouseManagement\ImportSupplyResourceContractDataPayload.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\Registry239.cs" />
|
||||||
<Compile Include="Client\Api\Registry\Registry24.cs" />
|
<Compile Include="Client\Api\Registry\Registry24.cs" />
|
||||||
<Compile Include="Client\Api\Registry\Registry276.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\ImportAccountDataRequest.cs" />
|
||||||
<Compile Include="Client\Api\Request\HouseManagement\ImportContractDataRequest.cs" />
|
<Compile Include="Client\Api\Request\HouseManagement\ImportContractDataRequest.cs" />
|
||||||
<Compile Include="Client\Api\Request\HouseManagement\ImportHouseUODataRequest.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\ImportNotificationDataRequest.cs" />
|
||||||
<Compile Include="Client\Api\Request\HouseManagement\ImportSupplyResourceContractDataRequest.cs" />
|
<Compile Include="Client\Api\Request\HouseManagement\ImportSupplyResourceContractDataRequest.cs" />
|
||||||
<Compile Include="Client\Api\Request\NsiCommon\ExportNsiItemRequest.cs" />
|
<Compile Include="Client\Api\Request\NsiCommon\ExportNsiItemRequest.cs" />
|
||||||
|
|||||||
@ -183,6 +183,41 @@ namespace Hcs.TestApp.Scenario
|
|||||||
Console.WriteLine("Scenario execution " + (result ? "succeeded" : "failed"));
|
Console.WriteLine("Scenario execution " + (result ? "succeeded" : "failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void ImportMeteringDeviceData()
|
||||||
|
{
|
||||||
|
var result = client.HouseManagement.ImportMeteringDeviceDataAsync(new MeteringDeviceFullInformationType()
|
||||||
|
{
|
||||||
|
BasicChatacteristicts = new MeteringDeviceBasicCharacteristicsType()
|
||||||
|
{
|
||||||
|
MeteringDeviceNumber = "Н43733003",
|
||||||
|
MeteringDeviceStamp = "-",
|
||||||
|
MeteringDeviceModel = "-",
|
||||||
|
CommissioningDate = new DateTime(2021, 1, 1),
|
||||||
|
CommissioningDateSpecified = true,
|
||||||
|
RemoteMeteringMode = false,
|
||||||
|
FirstVerificationDate = new DateTime(2021, 1, 1),
|
||||||
|
FirstVerificationDateSpecified = true,
|
||||||
|
VerificationInterval = Registry16.Element4,
|
||||||
|
FactorySealDate = new DateTime(2021, 1, 1),
|
||||||
|
FactorySealDateSpecified = true,
|
||||||
|
TemperatureSensor = false,
|
||||||
|
PressureSensor = false,
|
||||||
|
Item = new MeteringDeviceBasicCharacteristicsTypeResidentialPremiseDevice()
|
||||||
|
{
|
||||||
|
PremiseGUID = ["6e011824-3d8a-48d7-b0ee-7b36be7096bf"],
|
||||||
|
AccountGUID = ["019917a8-6eb6-74cc-99b7-58350127ac50"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Item = true,
|
||||||
|
Items = [new MunicipalResourceNotElectricBaseType()
|
||||||
|
{
|
||||||
|
MunicipalResource = Registry239.Element4,
|
||||||
|
MeteringValue = "0"
|
||||||
|
}]
|
||||||
|
}).Result;
|
||||||
|
Console.WriteLine("Scenario execution " + (result ? "succeeded" : "failed"));
|
||||||
|
}
|
||||||
|
|
||||||
internal void ImportNotificationData()
|
internal void ImportNotificationData()
|
||||||
{
|
{
|
||||||
var payload = new ImportNotificationDataPayload()
|
var payload = new ImportNotificationDataPayload()
|
||||||
|
|||||||
Reference in New Issue
Block a user