internal override void Parse()
        {
            if (WebsiteMetrics == null)
            {
                WebsiteMetrics = new List <WebsiteMetric>();
            }

            XNamespace serialisationNamespace = SerialisationNamespace;
            XElement   rootElements           = Document.Element(GetSchema() + RootElement);

            foreach (var element in rootElements.Elements(GetSchema() + "MetricResponse"))
            {
                var site = new WebsiteMetric();

                var data = element.Element(GetSchema() + "Data");

                // get the compute modefrom the instance
                if (data.Element(GetSchema() + "DisplayName") != null)
                {
                    site.DisplayName = data.Element(GetSchema() + "DisplayName").Value;
                }
                // get the name of the site as in xxxx.azurewebsites.net
                if (data.Element(GetSchema() + "Name") != null)
                {
                    site.Name = data.Element(GetSchema() + "Name").Value;
                }
                // the start time of the samples collection
                if (data.Element(GetSchema() + "StartTime") != null)
                {
                    site.StartTime = DateTime.Parse(data.Element(GetSchema() + "StartTime").Value);
                }
                // the end time of the samples collection
                if (data.Element(GetSchema() + "EndTime") != null)
                {
                    site.EndTime = DateTime.Parse(data.Element(GetSchema() + "EndTime").Value);
                }
                // the end time of the samples collection
                if (data.Element(GetSchema() + "Unit") != null)
                {
                    site.Units = data.Element(GetSchema() + "Unit").Value;
                }
                // the units of the samples collection
                var total = data.Element(GetSchema() + "Values").Elements(GetSchema() + "MetricSample");

                if (total.FirstOrDefault() != null)
                {
                    // for the time being just take the first node as there isn't any need to enumerate the collection as this should contain one node
                    site.Total = int.Parse(total.FirstOrDefault().Element(GetSchema() + "Total").Value);
                }
                WebsiteMetrics.Add(site);
            }

            CommandResponse = WebsiteMetrics;
        }
Ejemplo n.º 2
0
        private List <WebsiteMetric> AddThirdMetric()
        {
            var metrics = AddSecondMetric();
            var metric  = new WebsiteMetric()
            {
                DisplayName = "bill",
                EndTime     = DateTime.UtcNow,
                Name        = "bill 1",
                StartTime   = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(5)),
                Total       = 11,
                Units       = "elastaclouds"
            };

            metrics.Add(metric);
            return(new List <WebsiteMetric>(metrics));
        }
Ejemplo n.º 3
0
        private List <WebsiteMetric> GetInitialMetric()
        {
            var list = new List <WebsiteMetric>();

            var metric = new WebsiteMetric()
            {
                DisplayName = "tom",
                EndTime     = DateTime.UtcNow,
                Name        = "tom 1",
                StartTime   = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(5)),
                Total       = 5,
                Units       = "elastaclouds"
            };

            list.Add(metric);
            return(list);
        }