Ejemplo n.º 1
0
        public async override Task ExecuteRequestAsync(bool updateGrid = true)
        {
            if (InfluxDbClient == null)
            {
                throw new Exception("No InfluxDB client available.");
            }

            // Clear current items
            listView.Items.Clear();

            // Start redraw
            listView.BeginUpdate();

            // Query and render
            var queries = await InfluxDbClient.GetRunningQueriesAsync();

            foreach (var q in queries)
            {
                listView.Items.Add(new ListViewItem(new string[]
                {
                    q.PID.ToString(),
                    q.Duration,
                    q.Database.ToString(),
                    q.Query
                })
                {
                    Tag = q
                });
            }

            // Restore selection
            if (SelectedQuery != null)
            {
                var pid = SelectedQuery.PID.ToString();

                foreach (ListViewItem li in listView.Items)
                {
                    if (li.Text == pid)
                    {
                        li.Selected   = true;
                        SelectedQuery = (InfluxDbRunningQuery)li.Tag;
                    }
                }
            }

            // Resize each column
            //if (listView.Columns.Count > 0)
            //{
            //    var columnWidth = (Width - 12) / listView.Columns.Count;
            //    if (columnWidth < 96) columnWidth = 96;
            //    foreach (ColumnHeader col in listView.Columns) col.Width = columnWidth;
            //}

            // Render
            listView.EndUpdate();

            UpdateUIState();
        }