Пример #1
0
        private void listBoxBalanceServer_DrawItem(object sender, DrawItemEventArgs e)
        {
            ListBox listBox = sender as ListBox;

            e.DrawBackground();
            Graphics g = e.Graphics;

            int index = e.Index;

            if (index >= 0)
            {
                bool selected = ((e.State & DrawItemState.Selected) == DrawItemState.Selected);

                Hubble.Core.BigTable.ServerInfo serverinfo = listBox.Items[index] as Hubble.Core.BigTable.ServerInfo;

                if (selected)
                {
                    g.FillRectangle(new SolidBrush(Color.FromKnownColor(KnownColor.Highlight)), e.Bounds);
                }
                else
                {
                    if (!serverinfo.Enabled)
                    {
                        g.FillRectangle(new SolidBrush(Color.Gray), e.Bounds);
                    }
                    else
                    {
                        g.FillRectangle(new SolidBrush(Color.White), e.Bounds);
                    }
                }

                g.DrawString(serverinfo.ServerName, listBox.Font, new SolidBrush(Color.Black), e.Bounds);
                e.DrawFocusRectangle();
            }
        }
Пример #2
0
        private void buttonAddFailoverServers_Click(object sender, EventArgs e)
        {
            TabletInfo tablet = listBoxTablets.SelectedItem as TabletInfo;

            if (tablet == null)
            {
                QAMessageBox.ShowErrorMessage("Please choose a tablet");
                return;
            }

            ServerInfomation serverInfo = comboBoxFailoverServers.SelectedItem as ServerInfomation;

            if (serverInfo == null)
            {
                QAMessageBox.ShowErrorMessage("Please choose a server name");
                return;
            }

            if (listBoxFailoverServers.Items.Contains(serverInfo))
            {
                QAMessageBox.ShowErrorMessage("Can't input reduplicate server name!");
                return;
            }

            listBoxFailoverServers.Items.Add(serverInfo);
            tablet.FailoverServers.Add(serverInfo);

            buttonEnableFS.Enabled = listBoxFailoverServers.Items.Count > 0;
        }
Пример #3
0
            private void ListTable(Hubble.Core.BigTable.ServerInfo serverInfo)
            {
                Tables = new List <string>();

                using (HubbleAsyncConnection conn = new HubbleAsyncConnection(serverInfo.ConnectionString))
                {
                    conn.Open();

                    HubbleCommand command = new HubbleCommand("exec sp_tablelist", conn);
                    DataSet       ds      = command.Query();

                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        if (!bool.Parse(row["IsBigTable"].ToString()))
                        {
                            string fullName = row["TableName"].ToString();
                            int    index    = fullName.IndexOf(conn.Database, 0, StringComparison.CurrentCultureIgnoreCase);
                            if (index == 0)
                            {
                                index += conn.Database.Length;
                                Tables.Add(fullName.Substring(index + 1, fullName.Length - index - 1));
                            }
                        }
                    }
                }
            }
Пример #4
0
        private void listBoxFailoverServers_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = listBoxFailoverServers.SelectedIndex;

            if (index >= 0)
            {
                Hubble.Core.BigTable.ServerInfo serverInfo = listBoxFailoverServers.Items[index] as
                                                             Hubble.Core.BigTable.ServerInfo;

                labelFailoverEnabled.Text  = serverInfo.ServerName + " ";
                labelFailoverEnabled.Text += serverInfo.Enabled ? "Enabled" : "Disabled";
                buttonEnableFS.Text        = !serverInfo.Enabled ? "Enable" : "Disable";
            }
        }
Пример #5
0
        private void buttonAddServer_Click(object sender, EventArgs e)
        {
            string serverName       = "";
            string connectionString = "";

            if (QAMessageBox.ShowInputBox("Server name", "Please input server name", ref serverName) == DialogResult.OK)
            {
                if (string.IsNullOrEmpty(serverName))
                {
                    QAMessageBox.ShowErrorMessage("server name can't be empty!");
                    return;
                }

                if (QAMessageBox.ShowInputBox("Server name", "Please input connection string", ref connectionString) == DialogResult.OK)
                {
                    if (string.IsNullOrEmpty(connectionString))
                    {
                        QAMessageBox.ShowErrorMessage("connection string can't be empty!");
                        return;
                    }

                    Hubble.Core.BigTable.ServerInfo serverInfo =
                        new Hubble.Core.BigTable.ServerInfo(serverName,
                                                            connectionString);

                    if (BigTableInfo.ServerList.Contains(serverInfo))
                    {
                        QAMessageBox.ShowErrorMessage("Can't input reduplicate server name!");
                        return;
                    }

                    BigTableInfo.ServerList.Add(new Hubble.Core.BigTable.ServerInfo(serverName,
                                                                                    connectionString));

                    ListViewItem item = new ListViewItem(new string[] { "True", serverName, connectionString });

                    listViewServers.Items.Add(item);

                    InitListViewItem(item);

                    RefreshDatabaseTableEnumerate();
                }
            }
        }
Пример #6
0
        private void buttonEnableFS_Click(object sender, EventArgs e)
        {
            int index = listBoxFailoverServers.SelectedIndex;

            if (index >= 0)
            {
                Hubble.Core.BigTable.ServerInfo serverInfo = listBoxFailoverServers.Items[index] as
                                                             Hubble.Core.BigTable.ServerInfo;
                serverInfo.Enabled = buttonEnableFS.Text == "Enable";

                int tabletIndex = listBoxTablets.SelectedIndex;

                RefreshTabletGUI();

                listBoxTablets.SelectedIndex = tabletIndex;

                listBoxFailoverServers.SelectedIndex = index;
            }
        }
Пример #7
0
        private void buttonDelFailoverServers_Click(object sender, EventArgs e)
        {
            TabletInfo tablet = listBoxTablets.SelectedItem as TabletInfo;

            if (tablet == null)
            {
                QAMessageBox.ShowErrorMessage("Please choose a tablet");
                return;
            }

            Hubble.Core.BigTable.ServerInfo serverInfo = listBoxFailoverServers.SelectedItem as Hubble.Core.BigTable.ServerInfo;
            if (serverInfo != null)
            {
                if (QAMessageBox.ShowQuestionMessage(string.Format("Are you sure you want to remove server: {0} ?",
                                                                   serverInfo.ServerName)) == DialogResult.Yes)
                {
                    listBoxFailoverServers.Items.Remove(serverInfo);
                    tablet.FailoverServers.Remove(serverInfo);
                }
            }

            buttonEnableFS.Enabled = listBoxFailoverServers.Items.Count > 0;
        }
Пример #8
0
        private void buttonDeleteServer_Click(object sender, EventArgs e)
        {
            if (listViewServers.SelectedItems.Count > 0)
            {
                ListViewItem item = listViewServers.SelectedItems[0];

                if (QAMessageBox.ShowQuestionMessage(string.Format("Are you sure you want to remove server: {0} ?",
                                                                   item.SubItems["ServerName"].Text)) == DialogResult.Yes)
                {
                    listViewServers.Items.Remove(item);

                    RefreshDatabaseTableEnumerate();

                    Hubble.Core.BigTable.ServerInfo serverInfo =
                        new Hubble.Core.BigTable.ServerInfo(item.SubItems["ServerName"].Text,
                                                            item.SubItems["ConnectionString"].Text);

                    BigTableInfo.RemoveServerInfo(serverInfo);

                    CheckServerList();
                }
            }
        }
Пример #9
0
 public TabletInfo(string tableName, ServerInfo serverInfo)
 {
     this.TableName = tableName;
     BalanceServers.Add(serverInfo.Clone());
 }
Пример #10
0
        private void buttonUpdateServer_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewServers.SelectedItems.Count > 0)
                {
                    string serverName       = listViewServers.SelectedItems[0].SubItems["ServerName"].Text;
                    string connectionString = listViewServers.SelectedItems[0].SubItems["ConnectionString"].Text;

                    Hubble.Core.BigTable.ServerInfo serverInfo =
                        new Hubble.Core.BigTable.ServerInfo(serverName,
                                                            connectionString);

                    serverInfo = BigTableInfo.ServerList.SingleOrDefault(s => s.Equals(serverInfo));

                    if (serverInfo == null)
                    {
                        return;
                    }

                    FormServerInfo frmServerInfo = new FormServerInfo();

                    if (frmServerInfo.ShowDialog(serverInfo) == DialogResult.OK)
                    {
                        serverInfo = frmServerInfo.ServerInfo;

                        for (int i = 0; i < BigTableInfo.ServerList.Count; i++)
                        {
                            if (BigTableInfo.ServerList[i].Equals(serverInfo))
                            {
                                BigTableInfo.ServerList[i] = serverInfo;
                                break;
                            }
                        }

                        //Find the tablets and change the specified server info
                        for (int i = 0; i < BigTableInfo.Tablets.Count; i++)
                        {
                            for (int j = 0; j < BigTableInfo.Tablets[i].BalanceServers.Count; j++)
                            {
                                if (BigTableInfo.Tablets[i].BalanceServers[j].Equals(serverInfo))
                                {
                                    BigTableInfo.Tablets[i].BalanceServers[j] = serverInfo.Clone();
                                    break;
                                }
                            }

                            for (int j = 0; j < BigTableInfo.Tablets[i].FailoverServers.Count; j++)
                            {
                                if (BigTableInfo.Tablets[i].FailoverServers[j].Equals(serverInfo))
                                {
                                    BigTableInfo.Tablets[i].FailoverServers[j] = serverInfo.Clone();
                                    break;
                                }
                            }
                        }

                        listViewServers.SelectedItems[0].SubItems["ConnectionString"].Text = connectionString;

                        RefreshDatabaseTableEnumerate();

                        RefreshServerGUI();
                        RefreshTabletGUI();
                        _SettingChanged = true;
                    }
                }
            }
            catch (Exception ex)
            {
                QAMessageBox.ShowErrorMessage(ex);
            }
        }
Пример #11
0
 internal DatabaseTableEnumerate(Hubble.Core.BigTable.ServerInfo serverInfo)
 {
     ListTable(serverInfo);
     this.DBName = serverInfo.ServerName;
 }