Exemplo n.º 1
0
 /// <summary>
 ///     副本管理
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ReplicaSetToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ConfigHelper.MongoConnectionConfig newConfig = SystemManager.GetCurrentServerConfig();
     SystemManager.OpenForm(new frmReplsetMgr(ref newConfig), true, true);
     SystemManager.ConfigHelperInstance.ConnectionList[newConfig.ConnectionName] = newConfig;
     SystemManager.ConfigHelperInstance.SaveToConfigFile();
     MongoDbHelper._mongoConnSvrLst.Remove(newConfig.ConnectionName);
     MongoDbHelper._mongoConnSvrLst.Add(_config.ConnectionName, MongoDbHelper.CreateMongoServer(ref newConfig));
     ServerStatusCtl.SetEnable(false);
     MyMessageBox.ShowMessage("ReplSetName", "Please refresh connection after one minute.");
     ServerStatusCtl.SetEnable(true);
 }
Exemplo n.º 2
0
        /// <summary>
        ///     Refresh
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RefreshToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UIHelper.FillConnectionToTreeView(trvsrvlst);
            ServerStatusCtl.ResetCtl();
            ServerStatusCtl.RefreshStatus(false);
            ServerStatusCtl.RefreshCurrentOpr();

            statusStripMain.Items[0].Text = !SystemManager.IsUseDefaultLanguage
                ? SystemManager.MStringResource.GetText(StringResource.TextType.Main_StatusBar_Text_Ready)
                : "Ready";
            DisableAllOpr();
        }
Exemplo n.º 3
0
        /// <summary>
        ///     初始化ReplSet
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void InitReplsetToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String ReplSetName = MyMessageBox.ShowInput("Please Fill ReplSetName :",
                                                        SystemManager.IsUseDefaultLanguage
                    ? "ReplSetName"
                    : SystemManager.MStringResource.GetText(StringResource.TextType.Replset_InitReplset));

            if (ReplSetName == String.Empty)
            {
                return;
            }
            CommandResult Result = CommandHelper.InitReplicaSet(ReplSetName,
                                                                SystemManager.GetCurrentServerConfig().ConnectionName);

            if (Result.Ok)
            {
                //修改配置
                ConfigHelper.MongoConnectionConfig newConfig = SystemManager.GetCurrentServerConfig();
                newConfig.ReplSetName = ReplSetName;
                newConfig.ReplsetList = new List <string>
                {
                    newConfig.Host +
                    (newConfig.Port != 0 ? ":" + newConfig.Port : String.Empty)
                };
                SystemManager.ConfigHelperInstance.ConnectionList[newConfig.ConnectionName] = newConfig;
                SystemManager.ConfigHelperInstance.SaveToConfigFile();
                MongoDbHelper._mongoConnSvrLst.Remove(newConfig.ConnectionName);
                MongoDbHelper._mongoConnSvrLst.Add(_config.ConnectionName,
                                                   MongoDbHelper.CreateMongoServer(ref newConfig));
                ServerStatusCtl.SetEnable(false);
                MyMessageBox.ShowMessage("ReplSetName", "Please refresh connection after one minute.");
                ServerStatusCtl.SetEnable(true);
            }
            else
            {
                MyMessageBox.ShowMessage("ReplSetName", "Failed", Result.ErrorMessage);
            }
        }