Exemplo n.º 1
0
        public XElement Serialize()
        {
            var duplicates = GetDuplicateChannels();

            if (duplicates.Any())
            {
                var joinedDuplicates = string.Join(", ", duplicates);

                return(PrtgReport
                       .Failed(new PrtgText($"Duplicate channels: {joinedDuplicates}"))
                       .Serialize());
            }

            return(new XElement("prtg",
                                Results.Select(result => result.Serialize()),
                                Text.Serialize()
                                ));
        }
Exemplo n.º 2
0
        private static IPrtgReport GenerateReport(Func <IPrtgReport> probe)
        {
            try
            {
                return(probe());
            }
            catch (AggregateException exception)
            {
                var innerExceptionsMessages = ExtractInnerExceptionsMessages(exception);

                return(PrtgReport.Failed($"Sensor has failed - an aggregate exception '{exception.Message}' " +
                                         $"with following inner exceptions was thrown: {innerExceptionsMessages}"));
            }
            catch (Exception exception)
            {
                return(PrtgReport.Failed($"Sensor has failed - an exception was thrown: {exception.Message}"));
            }
        }