Exemplo n.º 1
0
        public void GetPartitions()
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                try
                {
                    if (serviceBusHelper == null)
                    {
                        return;
                    }

                    // ConsumerGroup Node
                    if (consumerGroupDescription == null)
                    {
                        return;
                    }

                    var partitionEnumerable      = serviceBusHelper.GetPartitions(consumerGroupDescription.EventHubPath, consumerGroupDescription.Name);
                    var partitionDescriptionList = partitionEnumerable as IList <PartitionDescription> ??
                                                   partitionEnumerable.ToList();
                    if (partitionEnumerable == null || !partitionDescriptionList.Any())
                    {
                        return;
                    }
                    partitionsBindingList = new SortableBindingList <PartitionDescription>(partitionDescriptionList)
                    {
                        AllowEdit   = false,
                        AllowNew    = false,
                        AllowRemove = false
                    };
                    partitionsBindingSource.DataSource = partitionsBindingList;
                    partitionsDataGridView.DataSource  = partitionsBindingSource;

                    var dataGridViewColumn = partitionsDataGridView.Columns["IsReadOnly"];
                    if (dataGridViewColumn != null)
                    {
                        dataGridViewColumn.Visible = false;
                    }

                    dataGridViewColumn = partitionsDataGridView.Columns["ExtensionData"];
                    if (dataGridViewColumn != null)
                    {
                        dataGridViewColumn.Visible = false;
                    }

                    dataGridViewColumn = partitionsDataGridView.Columns["EventHubPath"];
                    if (dataGridViewColumn != null)
                    {
                        dataGridViewColumn.Visible = false;
                    }

                    dataGridViewColumn = partitionsDataGridView.Columns["ConsumerGroupName"];
                    if (dataGridViewColumn != null)
                    {
                        dataGridViewColumn.Visible = false;
                    }

                    partitionsDataGridView.Refresh();

                    if (mainTabControl.TabPages[PartitionsTabPage] == null)
                    {
                        EnablePage(PartitionsTabPage);
                    }
                    if (mainTabControl.TabPages[PartitionsTabPage] != null)
                    {
                        mainTabControl.SelectTab(PartitionsTabPage);
                    }
                    CalculateLastColumnWidth();
                }
                catch (Exception ex)
                {
                    HandleException(ex);
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }