コード例 #1
0
        private async Task <DataMeasurementDto[]> GetMeasurementValuesSplitByMeasurement(PathInformationDto partPath, MeasurementValueFilterAttributesDto filter, CancellationToken cancellationToken)
        {
            var newFilter = filter.Clone();

            newFilter.MeasurementUuids = null;

            var parameter = CreateParameterDefinitions(partPath, newFilter);

            parameter.Add(ParameterDefinition.Create(AbstractMeasurementFilterAttributesDto.MeasurementUuidsParamName, ""));

            var requestRestriction = RequestBuilder.AppendParameters("values", parameter);
            var targetSize         = RestClientHelper.GetUriTargetSize(ServiceLocation, requestRestriction, MaxUriLength);

            var result = new List <DataMeasurementDto>(filter.MeasurementUuids.Length);

            foreach (var uuids in ArrayHelper.Split(filter.MeasurementUuids, targetSize, RestClientHelper.LengthOfListElementInUri))
            {
                newFilter.MeasurementUuids = uuids;
                if (newFilter.CharacteristicsUuidList?.Length > 0)
                {
                    result.AddRange(await GetMeasurementValuesSplitByCharacteristics(partPath, newFilter, cancellationToken).ConfigureAwait(false));
                }
                else
                {
                    result.AddRange(await _RestClient.Request <DataMeasurementDto[]>(RequestBuilder.CreateGet("values", CreateParameterDefinitions(partPath, newFilter).ToArray()), cancellationToken).ConfigureAwait(false));
                }
            }

            return(result.ToArray());
        }
コード例 #2
0
        /// <inheritdoc />
        public async Task DeleteMeasurementsByUuid(Guid[] measurementUuids, CancellationToken cancellationToken = default)
        {
            if (measurementUuids.Any())
            {
                var emptyParameter     = new[] { ParameterDefinition.Create("measurementUuids", "") };
                var requestRestriction = RequestBuilder.AppendParameters("measurements", emptyParameter);

                var targetSize = RestClientHelper.GetUriTargetSize(ServiceLocation, requestRestriction, MaxUriLength);

                foreach (var uuids in ArrayHelper.Split(measurementUuids, targetSize, RestClientHelper.LengthOfListElementInUri))
                {
                    var parameter = ParameterDefinition.Create("measurementUuids", RestClientHelper.ConvertGuidListToString(uuids));
                    await _RestClient.Request(RequestBuilder.CreateDelete("measurements", parameter), cancellationToken).ConfigureAwait(false);
                }
            }
        }
コード例 #3
0
        /// <inheritdoc />
        public async Task <string[]> GetDistinctMeasurementAttributeValues(ushort key, PathInformationDto partPath = null, DistinctMeasurementFilterAttributesDto filter = null, CancellationToken cancellationToken = default)
        {
            var featureMatrix = await GetFeatureMatrixInternal(FetchBehavior.FetchIfNotCached, cancellationToken).ConfigureAwait(false);

            if (!featureMatrix.SupportsDistinctMeasurementAttributeValuesSearch)
            {
                throw new OperationNotSupportedOnServerException(
                          "Fetching distinct measurement values is not supported by this server.",
                          DataServiceFeatureMatrix.DistinctMeasurementAttributsValuesSearchMinVersion,
                          featureMatrix.CurrentInterfaceVersion);
            }

            if (filter?.MeasurementUuids?.Length > 0)
            {
                var newFilter = filter.Clone();
                newFilter.MeasurementUuids = null;

                var parameter = CreateParameterDefinitions(partPath, newFilter, key);
                parameter.Add(ParameterDefinition.Create(AbstractMeasurementFilterAttributesDto.MeasurementUuidsParamName, ""));

                var requestRestriction = RequestBuilder.AppendParameters("values", parameter);
                var targetSize         = RestClientHelper.GetUriTargetSize(ServiceLocation, requestRestriction, MaxUriLength);

                var result = new List <string>(filter.MeasurementUuids.Length);
                foreach (var uuids in ArrayHelper.Split(filter.MeasurementUuids, targetSize, RestClientHelper.LengthOfListElementInUri))
                {
                    newFilter.MeasurementUuids = uuids;

                    var attributes = await _RestClient.Request <string[]>(RequestBuilder.CreateGet("distinctMeasurementAttributeValues", CreateParameterDefinitions(partPath, newFilter, key).ToArray()), cancellationToken).ConfigureAwait(false);

                    result.AddRange(attributes);
                }

                return(result.ToArray());
            }

            return(await _RestClient.Request <string[]>(RequestBuilder.CreateGet("distinctMeasurementAttributeValues", CreateParameterDefinitions(partPath, filter, key).ToArray()), cancellationToken).ConfigureAwait(false));
        }
コード例 #4
0
        private async Task <DataMeasurementDto[]> GetMeasurementValuesSplitByCharacteristics(PathInformationDto partPath, MeasurementValueFilterAttributesDto filter, CancellationToken cancellationToken)
        {
            var newFilter = filter.Clone();

            newFilter.CharacteristicsUuidList = null;

            var parameter = CreateParameterDefinitions(partPath, newFilter);

            parameter.Add(ParameterDefinition.Create(MeasurementValueFilterAttributesDto.CharacteristicsUuidListParamName, ""));

            var requestRestriction = RequestBuilder.AppendParameters("values", parameter);
            var targetSize         = RestClientHelper.GetUriTargetSize(ServiceLocation, requestRestriction, MaxUriLength);

            var result          = new List <DataMeasurementDto>(filter.MeasurementUuids?.Length ?? 0);
            var allMeasurements = new Dictionary <Guid, DataMeasurementDto>();

            foreach (var uuids in ArrayHelper.Split(filter.CharacteristicsUuidList, targetSize, RestClientHelper.LengthOfListElementInUri))
            {
                newFilter.CharacteristicsUuidList = uuids;

                var measurements = await _RestClient.Request <DataMeasurementDto[]>(RequestBuilder.CreateGet("values", CreateParameterDefinitions(partPath, newFilter).ToArray()), cancellationToken).ConfigureAwait(false);

                foreach (var measurement in measurements)
                {
                    if (allMeasurements.TryGetValue(measurement.Uuid, out var existingMeasurement))
                    {
                        existingMeasurement.Characteristics = Combine(existingMeasurement.Characteristics, measurement.Characteristics);
                    }
                    else
                    {
                        result.Add(measurement);
                        allMeasurements.Add(measurement.Uuid, measurement);
                    }
                }
            }

            return(result.ToArray());
        }