Пример #1
0
        //######################################
        // WaitForSensorTargetResolution
        //######################################

        private string WaitForSensorTargetResolution(int deviceId, int tmpId, Func <int, bool> progressCallback)
        {
            var parameters = new SensorTargetProgressParameters(deviceId, tmpId);

            SensorTargetProgress p;
            bool continueQuery = true;

            var stopwatch = new Stopwatch();
            var timeout   = TimeSpan.FromSeconds(60);

            stopwatch.Start();

            do
            {
                p = ObjectEngine.GetObject <SensorTargetProgress>(parameters);

                if (progressCallback != null)
                {
                    continueQuery = progressCallback(p.Percent);
                }

                if (p.Percent < 100)
                {
                    if (!continueQuery)
                    {
                        break;
                    }

                    if (stopwatch.Elapsed > timeout)
                    {
                        throw new TimeoutException("Failed to retrieve sensor information within a reasonable period of time. Check target device is accessible and that valid credentials have been supplied");
                    }

#if !DEBUG
                    Thread.Sleep(1000);
#endif
                }
            } while (p.Percent < 100);

            if (!continueQuery)
            {
                return(null);
            }

            ResponseParser.ValidateSensorTargetProgressResult(p);

            var page = RequestEngine.ExecuteRequest(new SensorTargetCompletedParameters(deviceId, tmpId));

            return(page);
        }
Пример #2
0
 private NotificationTriggerData GetNotificationTriggerData(int objectId, CancellationToken token) =>
 ObjectEngine.GetObject <NotificationTriggerData>(
     new NotificationTriggerDataParameters(objectId),
     ParseNotificationTriggerTypes,
     token
     );
Пример #3
0
 private NotificationTriggerData GetNotificationTriggerData(Either <IPrtgObject, int> objectOrId, CancellationToken token) =>
 ObjectEngine.GetObject <NotificationTriggerData>(
     new NotificationTriggerDataParameters(objectOrId),
     ParseNotificationTriggerTypes,
     token
     );
Пример #4
0
        //todo: check all arguments we can in this file and make sure we validate input. when theres a chain of methods, validate on the inner most one except if we pass a parameter object, in which case validate both

        /// <summary>
        /// Resolves an address to its latitudinal and longitudinal coordinates. May spuriously return no results.
        /// </summary>
        /// <param name="address">The address to resolve.</param>
        /// <returns></returns>
        internal List <Location> ResolveAddress(string address) =>
        ObjectEngine.GetObject <GeoResult>(new ResolveAddressParameters(address), ResponseParser.ResolveParser).Results.ToList();