コード例 #1
0
        private void LoadCategories(string machineName)
        {
            Collection <PerformanceCounterCategory> categories = null;

            try
            {
                categories = PerfMonController.GetCategories(machineName);

                category_ListBox.DataSource    = categories;
                category_ListBox.DisplayMember = "CategoryName";
                category_ListBox.SelectedIndex = -1;
            }
            catch (Win32Exception w32Exception)
            {
                TraceFactory.Logger.Error(w32Exception);
                DialogResult dialogResult = MessageBox.Show("Could not load categories for {0}. \nLoad from local machine?".FormatWith(machineName),
                                                            "Unreachable Host", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (dialogResult == DialogResult.Yes)
                {
                    //This will cause the SelectedIndex value to change which will indirectly call LoadCategories again.
                    LoadLocalHost();
                }
            }
            catch (UnauthorizedAccessException unauthException)
            {
                TraceFactory.Logger.Error(unauthException);
                MessageBox.Show("Failed to login to {0}. \nPlease check the user credentials being used.".FormatWith(machineName), "Authorization Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #2
0
        private void LoadCategoriesImpl(string machineName)
        {
            Collection <PerformanceCounterCategory> categories = PerfMonController.GetCategories(machineName);

            category_ListBox.DataSource            = categories;
            category_ListBox.DisplayMember         = "CategoryName";
            category_ListBox.SelectedIndex         = -1;
            category_ListBox.SelectedIndexChanged += category_ListBox_SelectedIndexChanged;
        }
コード例 #3
0
        private void LoadCounters()
        {
            PerformanceCounterCategory      category = category_ListBox.SelectedItem as PerformanceCounterCategory;
            Collection <PerformanceCounter> counters = PerfMonController.GetCounters(category, SelectedInstance);

            counter_ListBox.DataSource    = counters;
            counter_ListBox.DisplayMember = "CounterName";
            counter_ListBox.SelectedIndex = -1;
        }
コード例 #4
0
        private void LoadInstances(PerformanceCounterCategory category)
        {
            Collection <string> instances = PerfMonController.GetInstances(category);

            instance_ListBox.DataSource    = instances;
            instance_ListBox.SelectedIndex = -1;

            counter_ListBox.DataSource         = null;
            addCounter_ToolStripButton.Enabled = false;
        }
コード例 #5
0
        private void LoadInstances(PerformanceCounterCategory category)
        {
            Collection <string> instances = PerfMonController.GetInstances(category);

            instance_ListBox.DataSource = instances;

            //If there's only one instance, automatically select it and load the counters
            if (instances.Count == 1)
            {
                instance_ListBox.SelectedIndex = 0;
                instance_ListBox_SelectedIndexChanged(null, EventArgs.Empty);
            }
            else
            {
                instance_ListBox.SelectedIndex = -1;
            }
        }
コード例 #6
0
        private void LoadCounters(string machineName)
        {
            if (_loadFromMachine)
            {
                string instanceName = SelectedInstance;
                PerformanceCounterCategory      category = SelectedCategory as PerformanceCounterCategory;
                Collection <PerformanceCounter> counters = PerfMonController.GetCounters(category, instanceName);
                counter_ListBox.DataSource = counters;
            }
            else
            {
                ResourceWindowsCategory instance = null;
                using (EnterpriseTestContext context = new EnterpriseTestContext())
                {
                    instance = ResourceWindowsCategory.Select(context, ResourceWindowsCategoryType.PerfMon.ToString()).Where(c => c.Name == machineName).FirstOrDefault();
                }
                counter_ListBox.DataSource = instance.Children;
            }

            counter_ListBox.DisplayMember = "Name";
            counter_ListBox.SelectedIndex = -1;
        }