Пример #1
0
        public static IEnumerable<string> GetGroupFieldSystemNames(MetricParameters parameters)
        {
            if(parameters == null)
                return null;

            var groupFieldNames = new List<string>();

            if (!string.IsNullOrEmpty(parameters.groupFieldOneSystemName))
                groupFieldNames.Add(parameters.groupFieldOneSystemName);
            if (!string.IsNullOrEmpty(parameters.groupFieldTwoSystemName))
                groupFieldNames.Add(parameters.groupFieldTwoSystemName);
            if (!string.IsNullOrEmpty(parameters.groupFieldThreeSystemName))
                groupFieldNames.Add(parameters.groupFieldThreeSystemName);
            if (!string.IsNullOrEmpty(parameters.groupFieldFourSystemName))
                groupFieldNames.Add(parameters.groupFieldFourSystemName);

            return groupFieldNames;
        }
Пример #2
0
        public IList<MetricItem> GetMetricData(string processName, MetricParameters parameters, string filter)
        {
            if (string.IsNullOrWhiteSpace(processName)) return null;
            if (parameters == null) return null;


            var guid = Guid.NewGuid();

            ResultFormat = null;
            var itemsToShow = new List<MetricItem>();
            var editableRoot = DynamicTypeManager.GetEditableRootType(processName);
            if (editableRoot != null)
            {
                var property = editableRoot.GetPropertyByName(parameters.MetricFieldSystemName);
                if (property != null)
                {
                    ResultFormat = ReferenceFieldsHelper.GetNumericFormat(property);
                }
            }


            var metriclist = DynamicTypeManager.GetMetricAggregateInfo<IMetricAggregateInfoList>(
                processName,
                parameters.MetricGuid,
                guid,
                filter);

            if (metriclist == null) return null;

            var groups = GetGroupFieldSystemNames(parameters).Where(@group => metriclist.Count == 0 || metriclist[0].GetType().GetProperty(@group) != null).ToList();

            foreach (var item in metriclist)
            {
                var item1 = item;
                var rnd = new Random();
                var metricItem = new MetricItem
                {
                    Result = SafeTypeConverter.Convert<double>(((dynamic)item).Result),
                    Category = string.Join(",", groups.Select(x => item1.GetType().GetProperty(x).GetValue(item1, null))),
                    Color = new SolidColorBrush(Color.FromArgb(255, (byte)rnd.Next(0, 256), (byte)rnd.Next(0, 256), (byte)rnd.Next(0, 256))),
                    Index = metriclist.IndexOf(item)
                };

                itemsToShow.Add(metricItem);
            }

            return itemsToShow;
        }