private static void OutputResults(ChannelResults result)
 {
     // Emit the results as XML due to having multiple channels.
     var doc = new XDocument(
         new XElement("prtg",
             BuildResultElement("Number of Blobs in Container", result.TotalNumberOfBlockBlobs, "Count"),
             BuildResultElement("Total Bytes of Blobs in Container", result.TotalContainerSizeInBytes, "BytesDisk"),
             BuildResultElement("Number of Matching Blobs in Container", result.TotalNumberOfMatchedBlockBlobs, "Count"),
             BuildResultElement("Total Bytes of Matching Blobs in Container",
                 result.TotalContainerSizeOfMatchedBlobsInBytes, "BytesDisk")));
     Console.WriteLine(doc.ToString());
 }
        private static void OutputResults(ChannelResults result)
        {
            var channels = new List <IChannel>
            {
                new Channel("Number of Blobs in Container", result.TotalNumberOfBlockBlobs, new [] { ValueUnitProperty.Count }),
                new Channel("Total Bytes of Blobs in Container", result.TotalContainerSizeInBytes, new [] { ValueUnitProperty.BytesDisk }),
                new Channel("Number of Matching Blobs in Container", result.TotalNumberOfMatchedBlockBlobs, new [] { ValueUnitProperty.Count }),
                new Channel("Total Bytes of Matching Blobs in Container", result.TotalContainerSizeOfMatchedBlobsInBytes, new [] { ValueUnitProperty.BytesDisk }),
            };

            var report = new PrtgSensorSuccessResult(channels);

            Console.WriteLine(report.SerializeToXElement().ToString());
        }
        private static ChannelResults GetResults(MonitorArgs monitorArgs)
        {
            var result = new ChannelResults();

            foreach (var blob in GetContainer(monitorArgs).ListCloudBlockBlobs(monitorArgs.MatchInSubdirectories))
            {
                result.TotalNumberOfBlockBlobs++;
                result.TotalContainerSizeInBytes += blob.Properties.Length;

                // Make sure it has a name, and it matches the pattern
                if (string.IsNullOrWhiteSpace(blob.Name) ||
                    !Regex.IsMatch(blob.Name, monitorArgs.BlobNamePattern, RegexOptions.IgnoreCase | RegexOptions.Compiled))
                {
                    continue;
                }

                // If the blob as a LastModified date, then run it through the process -- if it doesn't we will
                // just include it in the results (not perfect, but edge case anyway)
                if (blob.Properties.LastModified.HasValue)
                {
                    // If ModifiedAfter is provided, make sure the file was modified after that time
                    if (!monitorArgs.ModifiedAfter.Equals(TimeSpan.Zero)
                        && blob.Properties.LastModified.Value < StartTime.Add(monitorArgs.ModifiedAfter.Negate()))
                    {
                        continue;
                    }

                    // If ModifiedBefore is provided, make sure the file was modified before that time
                    if (!monitorArgs.ModifiedBefore.Equals(TimeSpan.Zero)
                        && blob.Properties.LastModified.Value > StartTime.Add(monitorArgs.ModifiedBefore.Negate()))
                    {
                        continue;
                    }
                }

                result.TotalNumberOfMatchedBlockBlobs++;
                result.TotalContainerSizeOfMatchedBlobsInBytes += blob.Properties.Length;
            }
            return result;
        }
        private static ChannelResults GetResults(MonitorArgs monitorArgs)
        {
            var result = new ChannelResults();

            foreach (var blob in GetContainer(monitorArgs).ListCloudBlockBlobs(monitorArgs.MatchInSubdirectories))
            {
                result.TotalNumberOfBlockBlobs++;
                result.TotalContainerSizeInBytes += blob.Properties.Length;

                // Make sure it has a name, and it matches the pattern
                if (string.IsNullOrWhiteSpace(blob.Name) ||
                    !Regex.IsMatch(blob.Name, monitorArgs.BlobNamePattern, RegexOptions.IgnoreCase | RegexOptions.Compiled))
                {
                    continue;
                }

                // If the blob as a LastModified date, then run it through the process -- if it doesn't we will
                // just include it in the results (not perfect, but edge case anyway)
                if (blob.Properties.LastModified.HasValue)
                {
                    // If ModifiedAfter is provided, make sure the file was modified after that time
                    if (!monitorArgs.ModifiedAfter.Equals(TimeSpan.Zero) &&
                        blob.Properties.LastModified.Value < StartTime.Add(monitorArgs.ModifiedAfter.Negate()))
                    {
                        continue;
                    }

                    // If ModifiedBefore is provided, make sure the file was modified before that time
                    if (!monitorArgs.ModifiedBefore.Equals(TimeSpan.Zero) &&
                        blob.Properties.LastModified.Value > StartTime.Add(monitorArgs.ModifiedBefore.Negate()))
                    {
                        continue;
                    }
                }

                result.TotalNumberOfMatchedBlockBlobs++;
                result.TotalContainerSizeOfMatchedBlobsInBytes += blob.Properties.Length;
            }
            return(result);
        }