コード例 #1
0
 /// <summary>
 /// Adds the metrics to the report request.
 /// </summary>
 /// <param name="metrics">An IList object containing the metric names that shall be requested.</param>
 public void AddMetrics(IList <string> metrics)
 {
     foreach (string s in metrics)
     {
         Metrics.Add(new Metric(s.Trim(' ')));
     }
 }
コード例 #2
0
 private void AddMetrics(string queryParam, int startIndex)
 {
     foreach (string metric in queryParam.Substring(startIndex).Split(','))
     {
         Metrics.Add(GetFriendlySizeName(metric), metric);
     }
 }
コード例 #3
0
 /// <summary>
 /// Adds the metrics to the report request.
 /// </summary>
 /// <param name="metrics">A string containing all metric names that shall be requested - separated by comma.</param>
 public void AddMetrics(string metrics)
 {
     foreach (string s in metrics.Split(','))
     {
         Metrics.Add(new Metric(s.Trim(' ')));
     }
 }
コード例 #4
0
        public async void SelectResource(SelectionChangedEventArgs args)
        {
            if (args.AddedItems.Count == 1)
            {
                LoadGraphEnabled.Value = false;
                var resource = args.AddedItems[0] as Resource;
                Metrics.Clear();
                var metrics = await _client.Metrics(resource);

                foreach (var metric in metrics)
                {
                    Metrics.Add(metric);
                }
                if (metrics.Count() > 0)
                {
                    SelectedMetric.Value = metrics.First();
                }
                else
                {
                    var m = new Metric {
                        Name = new Name {
                            LocalizedValue = "No metrics supported"
                        }
                    };
                    Metrics.Add(m);
                    SelectedMetric.Value = m;
                }
                MetricsSelectorEnabled.Value = metrics.Count() > 1;
            }
        }
コード例 #5
0
 /// <summary>
 /// Adds the specified metric.
 /// </summary>
 /// <param name="metric">The metric to add.</param>
 public AnalyticsDataOptions AddMetric(AnalyticsMetric metric)
 {
     if (Metrics == null)
     {
         Metrics = new AnalyticsMetricCollection();
     }
     Metrics.Add(metric);
     return(this);
 }
コード例 #6
0
        public CloudWatchMetric(IConfiguration configuration)
        {
            Namespace = configuration["Namespace"];
            if (string.IsNullOrWhiteSpace(Namespace))
            {
                throw new Exception("Property 'Namespace' is mandatory in the 'MetricDefinition' section.");
            }

            // The Metrics section is required, so throw an exception if it is missing.
            var metricsSections = configuration.GetSection("Metrics");

            // GetSection never returns null
            if (!metricsSections.Exists())
            {
                throw new Exception("Property 'Metrics' is mandatory in the 'MetricDefinition' section.");
            }

            foreach (var dim in metricsSections.GetChildren())
            {
                var mv = new MetricValue
                {
                    Name = dim["Name"],
                    Unit = dim["Unit"] ?? "None"
                };

                if (dim["Value"] != null && long.TryParse(dim["Value"], out long defaultValue))
                {
                    mv.Value = defaultValue;
                }

                Metrics.Add(mv);
            }

            var dimensionSection = configuration.GetSection("Dimensions");

            if (!dimensionSection.Exists())
            {
                // Add an empty dimensions array if no dimensions are specified.
                Dimensions.Add(new string[0]);
            }
            else
            {
                var dimArray = dimensionSection.GetChildren().ToArray();

                // When the first item's path ends with 1, that means the first element in the array was empty.
                if (dimArray.First().Path.EndsWith("1"))
                {
                    Dimensions.Add(new string[0]);
                }

                foreach (var dim in dimArray)
                {
                    var dimItems = dim.GetChildren();
                    Dimensions.Add(dimItems.Select(i => i.Value).Distinct().OrderBy(i => i).ToArray());
                }
            }
        }
コード例 #7
0
ファイル: MetricGroup.cs プロジェクト: danMateer/platform
        public Metric AddMetric(Metric metric)
        {
            metric.Order          = GetMaxMetricOrder() + 1;
            metric.MetricGroup    = this;
            metric.MetricGroupId  = this.Id;
            metric.FormTemplateId = this.FormTemplateId;
            Metrics.Add(metric);

            return(metric);
        }
コード例 #8
0
ファイル: Skill.cs プロジェクト: agrum/Progress
        public Skill(JSONNode jNode_)
        {
            _Id         = jNode_["_id"].ToString();
            Category    = Serializer.ReadEnum <ECategory>(jNode_["category"]);
            Name        = jNode_["name"];
            Description = jNode_["description"];
            Details     = jNode_["details"];

            foreach (var condition in jNode_["metrics"].AsArray)
            {
                Metrics.Add(condition.Value);
            }
        }
コード例 #9
0
        /// <summary>
        /// Sets the metric in the Asset.
        /// </summary>
        /// <param name="metric"></param>
        /// <remarks>If a metric with the same name exists in the asset, then it will be replaced with metric supplied as argument.</remarks>
        internal void SetMetric(Metric metric)
        {
            int count = Metrics.Count;

            int index = Metrics.FindIndex((Metric setting) => { return(setting.name == metric.name); });

            if (index >= 0)
            {
                Metrics[index] = metric;
            }
            else
            {
                Metrics.Add(metric);
            }
        }
コード例 #10
0
        internal bool AddMetric(Metric metric)
        {
            foreach (var setting in Metrics)
            {
                if (metric.name == setting.name)
                {
                    metric.name = ObjectNames.GetUniqueName(Metrics.Select(m => m.name).ToArray(), metric.name);
                }
            }

            Metrics.Add(metric);
            MetricsModified?.Invoke();

            MarkDirty();

            return(true);
        }
コード例 #11
0
        public CloudWatchMetric AddMetric(string name, double value, string unit)
        {
            // If scope was not set in constructor, this method should do nothing.
            if (_scope == null)
            {
                return(this);
            }

            if (!_scope.MetricValues.ContainsKey(name))
            {
                _scope.MetricValues[name] = value;
            }

            Metrics.Add(new MetricValue {
                Name = name, Unit = unit
            });
            return(this);
        }
コード例 #12
0
        public CloudWatchMetric AddMetrics(HashSet <MetricValue> metrics)
        {
            // If scope was not set in constructor, this method should do nothing.
            if (_scope == null)
            {
                return(this);
            }

            foreach (var metric in metrics)
            {
                if (!_scope.MetricValues.ContainsKey(metric.Name))
                {
                    _scope.MetricValues[metric.Name] = metric.Value ?? 1;
                }

                Metrics.Add(metric);
            }

            return(this);
        }
コード例 #13
0
        /// <summary>
        /// Добавляет метрики в список
        /// </summary>
        /// <param name="metrics">Набор метрик для добавления</param>
        public void AddMetrics(List <RamMetric> metrics)
        {
            _logger.LogDebug("Adding metrics ");

            //Убираем дубликат последней метрике если он есть
            if (metrics.Count != 0)
            {
                if (metrics[0].Time == Metrics.Last().Time)
                {
                    metrics.RemoveAt(0);
                }
            }

            //Если еще остались новые метрики, то заносим их в список, удаля старые в начале
            foreach (var metric in metrics)
            {
                Metrics.Add(metric);
                Metrics.RemoveAt(0);
            }

            //Отправляем сообщение о том, что список метрик изменился
            OnMetricsChange(this, new EventArgs());
            _logger.LogDebug($"Added {metrics.Count} metrics");
        }
コード例 #14
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                if (_update)
                {
                    bool aggregatePoll = _aggregatePolling;
                    bool serverPoll    = _serverPolling;
                    if (aggregatePoll || serverPoll)
                    {
                        using (var scope = _scopeFactory.CreateScope()) {
                            Metrics        m;
                            MonitoringJson monitor;
                            var            dbContext = scope.ServiceProvider.GetRequiredService <ServersContext>();

                            if (aggregatePoll)
                            {
                                bool    firstMetric = true;
                                Metrics total       = new Metrics();
                                foreach (Server s in dbContext.Servers)
                                {
                                    _activeServers.TryAdd(s.Name, s);

                                    try {
                                        monitor = RequestMetrics(s);
                                    }
                                    catch (Exception) {
                                        continue;
                                    }

                                    m           = new Metrics();
                                    m.ServerId  = s.ServerId;
                                    m.Timestamp = DateTime.UtcNow;
                                    m.Date      = DateHelper.DateToInt(m.Timestamp);
                                    m.Time      = DateHelper.TimeToInt(m.Timestamp);
                                    m.DayOfWeek = (int)m.Timestamp.DayOfWeek;
                                    monitor.CopyTo(ref m);

                                    if (firstMetric == true)
                                    {
                                        firstMetric = false;
                                        total       = m;
                                    }
                                    else
                                    {
                                        total.Add(ref m);
                                    }

                                    if (serverPoll)
                                    {
                                        if (_serverNamesToClientIds[s.Name].Count > 0)
                                        {
                                            await _hubContext.Clients.Group(s.Name).SendAsync("ReceiveMessage", $"{JsonConvert.SerializeObject(monitor)}");
                                        }
                                    }
                                }

                                await _hubContext.Clients.Group(PollHub.GROUP_MAIN).SendAsync("ReceiveMessage", $"{JsonConvert.SerializeObject(total)}");
                            }
                            else
                            {
                                foreach (string serverName in _serverNamesToClientIds.Keys)
                                {
                                    if (_serverNamesToClientIds[serverName].Count > 0)
                                    {
                                        var server = dbContext.Servers.FirstOrDefault(s => s.Name == serverName);
                                        _activeServers.TryAdd(serverName, server);

                                        try {
                                            monitor = RequestMetrics(server);
                                        }
                                        catch (Exception) {
                                            continue;
                                        }

                                        await _hubContext.Clients.Group(serverName).SendAsync("ReceiveMessage", $"{JsonConvert.SerializeObject(monitor)}");
                                    }
                                }
                            }
                        }
                    }

                    _update = false;
                }
            }
        }
コード例 #15
0
        public PieChartViewModel()
        {
            this.Data = new List <PieChartModel>();

            Data.Add(new PieChartModel()
            {
                Country = "Uruguay", Count = 2807
            });
            Data.Add(new PieChartModel()
            {
                Country = "Argentina", Count = 2577
            });
            Data.Add(new PieChartModel()
            {
                Country = "USA", Count = 2473
            });
            Data.Add(new PieChartModel()
            {
                Country = "Germany", Count = 2120
            });
            Data.Add(new PieChartModel()
            {
                Country = "Netherlands", Count = 2071
            });
            Data.Add(new PieChartModel()
            {
                Country = "Malta", Count = 960
            });
            Data.Add(new PieChartModel()
            {
                Country = "Maldives", Count = 941
            });
            Data.Add(new PieChartModel()
            {
                Country = "Monaco", Count = 908
            });

            this.Population = new List <Population>();
            Population.Add(new Population()
            {
                Continent = "Asia", Countries = "China", States = "Taiwan", PopulationinContinents = 50.02, PopulationinCountries = 26.02, PopulationinStates = 18.02
            });
            Population.Add(new Population()
            {
                Continent = "Africa", Countries = "India", States = "Shandong", PopulationinContinents = 20.81, PopulationinCountries = 24, PopulationinStates = 8
            });
            Population.Add(new Population()
            {
                Continent = "Europe", Countries = "Nigeria", States = "Uttar Pradesh", PopulationinContinents = 15.37, PopulationinCountries = 12.81, PopulationinStates = 14.5
            });
            Population.Add(new Population()
            {
                Countries = "Ethiopia", States = "Maharashtra", PopulationinCountries = 8, PopulationinStates = 9.5
            });
            Population.Add(new Population()
            {
                Countries = "Germany", States = "Kano", PopulationinCountries = 8.37, PopulationinStates = 7.81
            });
            Population.Add(new Population()
            {
                Countries = "Turkey", States = "Lagos", PopulationinCountries = 7, PopulationinStates = 5
            });
            Population.Add(new Population()
            {
                States = "Oromia", PopulationinStates = 5
            });
            Population.Add(new Population()
            {
                States = "Amhara", PopulationinStates = 3
            });
            Population.Add(new Population()
            {
                States = "Hessen", PopulationinStates = 5.37
            });
            Population.Add(new Population()
            {
                States = "Bayern", PopulationinStates = 3
            });
            Population.Add(new Population()
            {
                States = "Istanbul", PopulationinStates = 4.5
            });
            Population.Add(new Population()
            {
                States = "Ankara", PopulationinStates = 2.5
            });

            this.Metrics = new List <SemiPieAndDoughnutChartModel>();
            Metrics.Add(new SemiPieAndDoughnutChartModel(43, 32));
            Metrics.Add(new SemiPieAndDoughnutChartModel(20, 34));
            Metrics.Add(new SemiPieAndDoughnutChartModel(67, 41));
            Metrics.Add(new SemiPieAndDoughnutChartModel(52, 42));
            Metrics.Add(new SemiPieAndDoughnutChartModel(71, 48));
            Metrics.Add(new SemiPieAndDoughnutChartModel(30, 45));

            StartAngle = 180;
            EndAngle   = 360;
        }
コード例 #16
0
        internal MetricEvent SaveNewMetric(NewMetricMessage newMetric, string ipAddress, DateTime?overrideTime = null, bool disableSave = false)
        {
            var applicationId = this.GetApplicationId(newMetric.ApplicationId);

            if (applicationId == -1)
            {
                Trace.TraceError($"Invalid ApplicationId {newMetric.ApplicationId} from {ipAddress}");
                throw new InvalidOperationException($"Invalid ApplicationId {newMetric.ApplicationId} from {ipAddress}");
            }

            //Debug.WriteLine("Save - ApplicationId {0}ms", clock.ElapsedMilliseconds);
            //clock.Restart();

            var installId = this.GetOrCreateInstallId(newMetric.InstallId);
            //Debug.WriteLine("Save - InstallId {0}ms", clock.ElapsedMilliseconds);
            //clock.Restart();

            var metricId = this.GetMetricId(newMetric.MetricId);
            //Debug.WriteLine("Save - MetricId {0}ms", clock.ElapsedMilliseconds);
            //clock.Restart();

            var metricEvent = new MetricEvent
            {
                AppId       = applicationId,
                InstallId   = installId,
                SessionId   = newMetric.SessionId,
                MetricId    = metricId,
                IPAddress   = ipAddress,
                EventId     = newMetric.EventId,
                MetricValue = newMetric.Value ?? string.Empty
            };

            if (overrideTime.HasValue)
            {
                metricEvent.Timestamp = overrideTime.Value;
            }

            var metricAsJson = JsonConvert.SerializeObject(newMetric);

            if (!metricEvent.Validate())
            {
                Trace.TraceError($"Invalid MetricEvent, cannot save: {metricAsJson}");
                throw new InvalidOperationException($"Invalid MetricEvent {metricAsJson}");
            }

            // If element valid, use the MetricEvent for loggin from here
            metricAsJson = JsonConvert.SerializeObject(metricEvent);

            var newMetricEvent = Metrics.Add(metricEvent);

            if (!disableSave)
            {
                try
                {
                    SaveChanges();
                    return(newMetricEvent);
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Unable to save MetricEvent, cannot save: {0} {1}", ex, metricAsJson);
                    throw;
                }
            }

            return(null);
        }
コード例 #17
0
        public DoughnutChartViewModel()
        {
            StartAngle = 180;
            EndAngle   = 360;

            this.Tax = new List <DoughnutChartModel>();

            Tax.Add(new DoughnutChartModel()
            {
                Category = "Total License", Percentage = 20d
            });
            Tax.Add(new DoughnutChartModel()
            {
                Category = "Other", Percentage = 23d
            });
            Tax.Add(new DoughnutChartModel()
            {
                Category = "Sales and Gross Receipt", Percentage = 12d
            });
            Tax.Add(new DoughnutChartModel()
            {
                Category = "Corporation Net Income", Percentage = 28d
            });
            Tax.Add(new DoughnutChartModel()
            {
                Category = "Individual Income", Percentage = 10d
            });
            Tax.Add(new DoughnutChartModel()
            {
                Category = "Sales", Percentage = 10d
            });

            this.Population = new List <DoughnutChartPopulations>();

            Population.Add(new DoughnutChartPopulations()
            {
                Continent = "Asia", Countries = "China", States = "Taiwan", PopulationinContinents = 50.02, PopulationinCountries = 26.02, PopulationinStates = 18.02
            });
            Population.Add(new DoughnutChartPopulations()
            {
                Continent = "Africa", Countries = "India", States = "Shandong", PopulationinContinents = 20.81, PopulationinCountries = 24, PopulationinStates = 8
            });
            Population.Add(new DoughnutChartPopulations()
            {
                Continent = "Europe", Countries = "Nigeria", States = "Uttar Pradesh", PopulationinContinents = 15.37, PopulationinCountries = 12.81, PopulationinStates = 14.5
            });
            Population.Add(new DoughnutChartPopulations()
            {
                Countries = "Ethiopia", States = "Maharashtra", PopulationinCountries = 8, PopulationinStates = 9.5
            });
            Population.Add(new DoughnutChartPopulations()
            {
                Countries = "Germany", States = "Kano", PopulationinCountries = 8.37, PopulationinStates = 7.81
            });
            Population.Add(new DoughnutChartPopulations()
            {
                Countries = "Turkey", States = "Lagos", PopulationinCountries = 7, PopulationinStates = 5
            });
            Population.Add(new DoughnutChartPopulations()
            {
                States = "Oromia", PopulationinStates = 5
            });
            Population.Add(new DoughnutChartPopulations()
            {
                States = "Amhara", PopulationinStates = 3
            });
            Population.Add(new DoughnutChartPopulations()
            {
                States = "Hessen", PopulationinStates = 5.37
            });
            Population.Add(new DoughnutChartPopulations()
            {
                States = "Bayern", PopulationinStates = 3
            });
            Population.Add(new DoughnutChartPopulations()
            {
                States = "Istanbul", PopulationinStates = 4.5
            });
            Population.Add(new DoughnutChartPopulations()
            {
                States = "Ankara", PopulationinStates = 2.5
            });

            ExpenditureData = new List <DoughnutChartPopulations>
            {
                new DoughnutChartPopulations()
                {
                    Category = "Vehicle", Expenditure = 62.7, Image = new Uri(@"/syncfusion.chartdemos.wpf;component/Assets/Chart/Car.png", UriKind.RelativeOrAbsolute)
                },
                new DoughnutChartPopulations()
                {
                    Category = "Education", Expenditure = 29.5, Image = new Uri(@"/syncfusion.chartdemos.wpf;component/Assets/Chart/Chart_Book.png", UriKind.RelativeOrAbsolute)
                },
                new DoughnutChartPopulations()
                {
                    Category = "Home", Expenditure = 85.2, Image = new Uri(@"/syncfusion.chartdemos.wpf;component/Assets/Chart/House.png", UriKind.RelativeOrAbsolute)
                },
                new DoughnutChartPopulations()
                {
                    Category = "Personal", Expenditure = 45.6, Image = new Uri(@"/syncfusion.chartdemos.wpf;component/Assets/Chart/Personal.png", UriKind.RelativeOrAbsolute)
                },
            };

            this.Metrics = new List <SemiPieAndDoughnutChartModel>();
            Metrics.Add(new SemiPieAndDoughnutChartModel(43, 32));
            Metrics.Add(new SemiPieAndDoughnutChartModel(20, 34));
            Metrics.Add(new SemiPieAndDoughnutChartModel(67, 41));
            Metrics.Add(new SemiPieAndDoughnutChartModel(52, 42));
            Metrics.Add(new SemiPieAndDoughnutChartModel(71, 48));
            Metrics.Add(new SemiPieAndDoughnutChartModel(30, 45));
        }