public SensorViewModel ToViewModel(PrtgSensor sensor)
        {
            var viewModel = new SensorViewModel
            {
                Value = sensor.LastValue,
                StatusMessage = sensor.StatusMessage.TrimWhiteSpaceAndQuotes(),
                StatusMessageEx = sensor.StatusMessageEx.TrimWhiteSpaceAndQuotes(),
                IsPaused = sensor.IsPaused,
                IsError = sensor.IsError,
                IsWarning = sensor.IsWarning,
                StatusSince = sensor.StatusSince,
                Host = sensor.Device.Host,
            };

            CopyBaseProperties(sensor, viewModel);

            return viewModel;
        }
Ejemplo n.º 2
0
        private PrtgSensor ReadSensor(XElement element, PrtgDevice device)
        {
            var result = new PrtgSensor(device);

            FillBasicProperties(element, result);

            result.DataMode = element.Element("datamode").TryGetString();
            result.Interval = element.Element("interval").TryGetInt();

            result.LastDown = element.Element("lastdown_raw_utc").TryGetDateTime();
            result.LastUp = element.Element("lastup_raw_utc").TryGetDateTime();
            result.LastError = element.Element("lasterror_raw_utc").TryGetDateTime();
            result.LastOk = element.Element("lastok_raw_utc").TryGetDateTime();
            result.LastTime = element.Element("lasttime_raw_utc").TryGetDateTime();

            result.LastValue = element.Element("lastvalue").TryGetString();
            result.LastValueRaw = element.Element("lastvalue_raw").TryGetString();
            result.SensorKind = element.Element("sensorkind").TryGetString();
            result.SensorType = element.Element("sensortype").TryGetString();
            result.StatusMessage = element.Element("status").TryGetString();
            result.StatusMessageEx = element.Element("statusmessage").TryGetString();

            result.StatusSince = element.Element("statussince_raw_utc").TryGetDateTime();

            return result;
        }