/// <summary> /// 建立数据库 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CreateMongoDBToolStripMenuItem_Click(object sender, EventArgs e) { string strDbName; if (GuiConfig.IsUseDefaultLanguage) { strDbName = MyMessageBox.ShowInput("Please Input DataBaseName:", "Create Database"); } else { strDbName = MyMessageBox.ShowInput( GuiConfig.GetText(TextType.CreateNewDataBaseInput), GuiConfig.GetText(TextType.CreateNewDataBase)); } string errMessage; if (Operater.IsDatabaseNameValid(strDbName, out errMessage)) { try { var strRusult = Operater.DataBaseOpration(RuntimeMongoDbContext.SelectObjectTag, strDbName, Operater.Oprcode.Create); if (string.IsNullOrEmpty(strRusult)) { RefreshToolStripMenuItem_Click(sender, e); } else { MyMessageBox.ShowMessage("Error", "Create MongoDatabase", strRusult, true); } } catch (ArgumentException ex) { Utility.ExceptionDeal(ex, "Create MongoDatabase", "Argument Exception"); } } else { MyMessageBox.ShowMessage("Create MongoDatabase", "Argument Exception", errMessage, true); } }
/// <summary> /// Drop MongoDB /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DelMongoDBToolStripMenuItem_Click(object sender, EventArgs e) { var strTitle = "Drop Database"; var strMessage = "Are you really want to Drop current Database?"; if (!GuiConfig.IsUseDefaultLanguage) { strTitle = GuiConfig.GetText(TextType.DropDataBase); strMessage = GuiConfig.GetText(TextType.DropDataBaseConfirm); } if (!MyMessageBox.ShowConfirm(strTitle, strMessage)) { return; } var strTagPrefix = TagInfo.GetTagPath(ConstMgr.CollectionTag + ":" + RuntimeMongoDbContext.SelectTagData); var strDbName = strTagPrefix.Split("/".ToCharArray())[(int)EnumMgr.PathLevel.Database]; if (trvsrvlst.SelectedNode == null) { trvsrvlst.SelectedNode = null; } var rtnResult = Operater.DataBaseOpration(RuntimeMongoDbContext.SelectObjectTag, strDbName, Operater.Oprcode.Drop); if (string.IsNullOrEmpty(rtnResult)) { RefreshToolStripMenuItem_Click(sender, e); //关闭所有的相关视图 MultiTabManger.SelectObjectTagPrefixDeleted(strTagPrefix); } else { MyMessageBox.ShowMessage("Error", "Error", rtnResult, true); } }