Ejemplo n.º 1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            try
            {
                Hubble.Core.BigTable.ServerInfo serverInfo = comboBoxBalanceServers.SelectedItem as
                                                             Hubble.Core.BigTable.ServerInfo;

                if (serverInfo != null)
                {
                    Hubble.Core.BigTable.ServerType serverType = radioButtonBalance.Checked ? Hubble.Core.BigTable.ServerType.Balance :
                                                                 Hubble.Core.BigTable.ServerType.Failover;


                    foreach (string tableName in listBoxTable.SelectedItems)
                    {
                        _TempBigTableInfo.Add(tableName, serverType, serverInfo);
                    }
                }

                _BigTableInfo.Tablets = _TempBigTableInfo.Tablets;
                _Result = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                QAMessageBox.ShowErrorMessage(ex);
                _TempBigTableInfo = _BigTableInfo.Clone();
            }
        }
Ejemplo n.º 2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            try
            {
#if HubblePro
                FormBigTableBatchInsert frmBigtableBatchInsert = new FormBigTableBatchInsert();
                frmBigtableBatchInsert.BigTableInfo = this.BigTableInfo;
                if (frmBigtableBatchInsert.ShowDialog() == DialogResult.OK)
                {
                    RefreshTabletGUI();
                }
#else
                string tableName        = null;
                string connectionString = "";

                if (QAMessageBox.ShowInputBox("Add tablet", "Input table name", ref tableName) == DialogResult.OK)
                {
                    if (string.IsNullOrEmpty(tableName))
                    {
                        QAMessageBox.ShowErrorMessage("table name can't be empty!");
                        return;
                    }

                    TabletInfo tablet = new TabletInfo(tableName, new Hubble.Core.BigTable.ServerInfo("", connectionString));
                    BigTableInfo.Add(tablet);
                    listBoxTablets.Items.Add(tablet);
                    listBoxTablets.SelectedItem = tablet;
                }
#endif
            }
            catch (Exception ex)
            {
                QAMessageBox.ShowErrorMessage(ex.Message);
            }
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
0
 private void FormBigTable_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (_BigTableGenerate.SettingChanged)
     {
         if (QAMessageBox.ShowQuestionMessage("Setting changed, do you want to save the setting?") == DialogResult.Yes)
         {
             if (!_BigTableGenerate.Save())
             {
                 e.Cancel = true;
             }
         }
     }
 }
Ejemplo n.º 5
0
        internal bool Save()
        {
            IndexFolder = IndexFolder.Trim();
            TableName   = TableName.Trim();
            if (IndexFolder == "")
            {
                QAMessageBox.ShowErrorMessage("Index folder can't be empty.");
                return(false);
            }

            if (TableName == "")
            {
                QAMessageBox.ShowErrorMessage("Table name can't be empty.");
                return(false);
            }

            if (BigTableInfo.Tablets.Count <= 0)
            {
                QAMessageBox.ShowErrorMessage("BigTable must have at least one tablet!");
                return(false);
            }

            foreach (TabletInfo tableInfo in BigTableInfo.Tablets)
            {
                if (tableInfo.BalanceServers.Count <= 0)
                {
                    QAMessageBox.ShowErrorMessage(string.Format("Table name:{0} must include at least one BalanceServer!",
                                                                tableInfo.TableName));
                    return(false);
                }
            }

            try
            {
                _ParentForm.TableName   = this.TableName;
                _ParentForm.IndexFolder = this.IndexFolder;
                _ParentForm.BigTable    = BigTableInfo;
                _ParentForm.BigTable.KeepDataIntegrity = checkBoxKeepDataIntegrity.Checked;
                _ParentForm.BigTable.ExecuteTimeout    = (int)numericUpDownExecuteTimeout.Value;
                _ParentForm._Result = DialogResult.OK;

                return(true);
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
Ejemplo n.º 6
0
        private void RefreshDatabaseTableEnumerate()
        {
            _DBTableEnumerate = new List <DatabaseTableEnumerate>();

            foreach (var serverInfo in _BigTableInfo.ServerList)
            {
                try
                {
                    _DBTableEnumerate.Add(new DatabaseTableEnumerate(serverInfo));
                }
                catch (Exception e)
                {
                    QAMessageBox.ShowInformationMessage(string.Format("Try to connect server:{0} fail. Err:{1}",
                                                                      serverInfo.ServerName, e.Message));
                }
            }
        }
Ejemplo n.º 7
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();
                }
            }
        }
Ejemplo n.º 8
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            TabletInfo tablet = listBoxTablets.SelectedItem as TabletInfo;

            if (tablet != null)
            {
                if (QAMessageBox.ShowQuestionMessage(string.Format("Are you sure you want to remove tablet: {0} ?",
                                                                   tablet.TableName)) == DialogResult.Yes)
                {
                    listBoxTablets.Items.Remove(tablet);
                    BigTableInfo.Tablets.Remove(tablet);

                    if (listBoxTablets.Items.Count > 0)
                    {
                        listBoxTablets.SelectedIndex = 0;
                    }
                }
            }
        }
Ejemplo n.º 9
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;
        }
Ejemplo n.º 10
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();
                }
            }
        }
Ejemplo n.º 11
0
        private bool ListTable(Hubble.Core.BigTable.ServerInfo serverInfo)
        {
            try
            {
                listBoxTable.Items.Clear();

                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;
                                listBoxTable.Items.Add(fullName.Substring(index + 1, fullName.Length - index - 1));
                            }
                        }
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                QAMessageBox.ShowErrorMessage(e);
                return(false);
            }
        }
Ejemplo n.º 12
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);
            }
        }