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 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().ToList().ForEach(error => { throw RemoteException.CreateNew(error.ErrorCode, error.Description); }); result.Items.OfType().ToList().ForEach(commonResult => { commonResult.Items.OfType().ToList().ForEach(error => { throw RemoteException.CreateNew(error.ErrorCode, error.Description); }); }); return true; } } }