Exemplo n.º 1
0
        private async Task <string> GetSensorTargetsResponseAsync(int deviceId, SensorTargetParameters parameters, Func <int, bool> progressCallback)
        {
            Func <HttpResponseMessage, Task <string> > getSensorTargetTmpId = o => Task.FromResult(ResponseParser.GetSensorTargetTmpId(o));

            var tmpIdStr = await RequestEngine.ExecuteRequestAsync(parameters, getSensorTargetTmpId).ConfigureAwait(false);

            int tmpId;

            if (!int.TryParse(tmpIdStr, out tmpId))
            {
                throw new PrtgRequestException($"Failed to resolve sensor targets for sensor type '{parameters[Parameter.SensorType]}': type was not valid");
            }

            var response = await WaitForSensorTargetResolutionAsync(deviceId, tmpId, progressCallback).ConfigureAwait(false);

            return(response);
        }