Пример #1
0
        private void InitDataType(string dataTypeHeaderListString, string dataTypeListString)
        {
            try
            {
                var dataTypeHeaderList = JsonConvert.DeserializeObject<List<HeaderKeyValue>>(dataTypeHeaderListString);
                var dataTypeList = JsonConvert.DeserializeObject<List<DataTypeModel>>(dataTypeListString);
                var dataItemsSource = new ObservableCollection<CheckBoxTab>();
                foreach (var header in dataTypeHeaderList)
                {
                    var checkBoxTab = new CheckBoxTab
                    {
                        Header = header,
                        Items = new ObservableCollection<IItemTypeModel>()
                    };

                    foreach (var dataType in dataTypeList)
                    {
                        if (dataType.EnHeader.Contains(header.EnHeader))
                        {
                            checkBoxTab.Items.Add(dataType);
                        }
                    }

                    dataItemsSource.Add(checkBoxTab);
                }

                DataTypeItemsSource = dataItemsSource;

                WidgetView view = GetView() as WidgetView;
                if (view != null)
                {
                    view.DataTypeTabControl.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                ShowMessage.Show("初始化指标出错");
                LogHelper.LogMessage(MethodBase.GetCurrentMethod().DeclaringType, LogHelper.LogLevel, "Failed to InitMetric", ex);
            }
            finally
            {
                if (LogHelper.LogLevel == LogLevelEnum.Debug || LogHelper.LogLevel == LogLevelEnum.Info)
                {
                    LogHelper.LogMessage(MethodBase.GetCurrentMethod().DeclaringType, LogHelper.LogLevel, "InitMetric", null);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 初始化指标
        /// </summary>
        /// <param name="metricHeaderListString"></param>
        /// <param name="metricTypeListString"></param>
        private void InitMetric(string metricHeaderListString, string metricTypeListString)
        {
            try
            {
                var metricHeaderList = JsonConvert.DeserializeObject<List<HeaderKeyValue>>(metricHeaderListString);
                var metricTypeList = JsonConvert.DeserializeObject<List<MetricTypeModel>>(metricTypeListString);
                var metricItemsSource = new ObservableCollection<CheckBoxTab>();
                foreach (var header in metricHeaderList)
                {
                    var checkBoxTab = new CheckBoxTab
                    {
                        Header = header,
                        Items = new ObservableCollection<IItemTypeModel>()
                    };

                    foreach (var metricType in metricTypeList)
                    {
                        if (metricType.CnHeader.Contains(header.CnHeader))
                        {
                            if (SystemType.Id == (int)SystemTypeEnum.TrackRealtime && (metricType.EnName == "uimp" || metricType.EnName == "uclk"))
                            {
                                metricType.IsEnabled = false;
                            }
                            else
                            {
                                metricType.IsEnabled = true;
                            }
                            checkBoxTab.Items.Add(metricType);
                        }
                    }

                    metricItemsSource.Add(checkBoxTab);
                }

                MetricItemsSource = metricItemsSource;

                WidgetView view = GetView() as WidgetView;
                if (view != null)
                {
                    view.MetricTabControl.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                ShowMessage.Show("初始化指标出错");
                LogHelper.LogMessage(MethodBase.GetCurrentMethod().DeclaringType, LogHelper.LogLevel, "Failed to InitMetric", ex);
            }
            finally
            {
                if (LogHelper.LogLevel == LogLevelEnum.Debug || LogHelper.LogLevel == LogLevelEnum.Info)
                {
                    LogHelper.LogMessage(MethodBase.GetCurrentMethod().DeclaringType, LogHelper.LogLevel, "InitMetric", null);
                }
            }
        }