Add new Hcs.Broker to communicate with ГИС ЖКХ via CryptoPro LibCore

This commit is contained in:
2025-09-28 15:45:15 +09:00
parent 904988780a
commit 2b49320014
171 changed files with 185618 additions and 0 deletions

View File

@ -0,0 +1,43 @@
using Hcs.Broker.Api.Request.Exception;
using Hcs.Broker.Internal;
using Hcs.Service.Async.DeviceMetering;
namespace Hcs.Broker.Api.Request.DeviceMetering
{
internal class ImportMeteringDeviceValuesRequest(Client client) : DeviceMeteringRequestBase(client)
{
protected override bool CanBeRestarted => false;
internal async Task<bool> ExecuteAsync(importMeteringDeviceValuesRequestMeteringDevicesValues values, CancellationToken token)
{
// http://open-gkh.ru/DeviceMetering/importMeteringDeviceValuesRequest.html
var request = new importMeteringDeviceValuesRequest
{
Id = Constants.SIGNED_XML_ELEMENT_ID,
version = "10.0.1.1",
MeteringDevicesValues = [values]
};
var result = await SendAndWaitResultAsync(request, async asyncClient =>
{
var response = await asyncClient.importMeteringDeviceValuesAsync(CreateRequestHeader(), request);
return response.AckRequest.Ack;
}, token);
result.Items.OfType<ErrorMessageType>().ToList().ForEach(error =>
{
throw RemoteException.CreateNew(error.ErrorCode, error.Description);
});
result.Items.OfType<CommonResultType>().ToList().ForEach(commonResult =>
{
commonResult.Items.OfType<ErrorMessageType>().ToList().ForEach(error =>
{
throw RemoteException.CreateNew(error.ErrorCode, error.Description);
});
});
return true;
}
}
}