/// <summary> /// MongoDB 서버 <paramref name="serverName"/>의 Database (<paramref name="databaseName"/>)를 삭제합니다. /// </summary> /// <param name="serverName"></param> /// <param name="databaseName"></param> /// <returns></returns> public static CommandResult DropDatabase(string serverName, string databaseName) { MongoServer server = null; try { server = CreateMongoServer(serverName); var result = server.DropDatabase(databaseName); return(result); } catch (Exception ex) { if (log.IsWarnEnabled) { log.Warn("Database[{0}] 삭제에 실패했습니다.", databaseName); log.Warn(ex); } } finally { if (server != null) { server.Disconnect(); } } return(EmptyCommandResult); }
public void Setup() { server = MongoServer.Create("mongodb://localhost/?safe=true"); server.Connect(); server.DropDatabase("onlinetests"); database = server["onlinetests"]; }
public void Setup() { server = MongoServer.Create(); server.Connect(); server.DropDatabase("onlinetests"); database = server["onlinetests"]; }
public void TestFixtureSetUp() { _server = MongoServer.Create(ConnStr); if (_server.DatabaseExists(PropSetCollectionsDb)) _server.DropDatabase(PropSetCollectionsDb); _testDb = _server.GetDatabase(PropSetCollectionsDb); }
public void Setup() { MongoServer = MongoServer.Create(ConnectionString); MongoServer.DropDatabase(DataBase); Resolver = new TestResolver(); OnSetup(); }
public void Setup() { server = MongoServer.Create("mongodb://localhost/?safe=true"); server.Connect(); server.DropDatabase("onlinetests"); database = server["onlinetests"]; }
/// <summary> /// 数据库操作 /// </summary> /// <param name="strObjTag"></param> /// <param name="dbName"></param> /// <param name="func"></param> /// <param name="tr"></param> /// <returns></returns> public static String DataBaseOpration(String strObjTag, String dbName, Oprcode func, TreeNode tr) { String rtnResult = String.Empty; MongoServer mongoSvr = GetMongoServerBySvrPath(strObjTag); String strSvrPath = SystemManager.GetTagData(strObjTag); String svrKey = strSvrPath.Split("/".ToCharArray())[(int)PathLv.InstanceLv]; var result = new CommandResult(new BsonDocument()); if (mongoSvr != null) { switch (func) { case Oprcode.Create: if (!mongoSvr.DatabaseExists(dbName)) { //从权限上看,clusterAdmin是必须的 //但是能够建立数据库,不表示能够看到里面的内容! //dbAdmin可以访问数据库。 //clusterAdmin能创建数据库但是不能访问数据库。 try { mongoSvr.GetDatabase(dbName); tr.Nodes.Add(UIHelper.FillDataBaseInfoToTreeNode(dbName, mongoSvr, svrKey + "/" + svrKey)); } catch (Exception ex) { //如果使用没有dbAdmin权限的clusterAdmin。。。。 SystemManager.ExceptionDeal(ex); } } break; case Oprcode.Drop: if (mongoSvr.DatabaseExists(dbName)) { result = mongoSvr.DropDatabase(dbName); if (tr != null) { tr.TreeView.Nodes.Remove(tr); } if (!result.Response.Contains("err")) { return(String.Empty); } return(result.Response["err"].ToString()); } break; case Oprcode.Repair: //其实Repair的入口不在这个方法里面 CommandHelper.ExecuteMongoDBCommand(CommandHelper.repairDatabase_Command, SystemManager.GetCurrentDataBase()); break; default: break; } } return(rtnResult); }
public virtual void SetUp() { MongoClient = new MongoClient(_connectionString); MongoServer = MongoClient.GetServer(); MongoServer.DropDatabase(_databaseName); MongoDatabase = MongoServer.GetDatabase(_databaseName); MongoDatabase.SetProfilingLevel(ProfilingLevel.All); }
public void FixtureTearDown() { if (_mongoServer.DatabaseExists(_testDatabaseName)) { _mongoServer.DropDatabase(_testDatabaseName); } // TODO: Cleanup RavenDB }
public void TestGetCollectionNames() { server.DropDatabase("onlinetests"); database["a"].Insert(new BsonDocument("a", 1)); database["b"].Insert(new BsonDocument("b", 1)); database["c"].Insert(new BsonDocument("c", 1)); var collectionNames = database.GetCollectionNames(); Assert.AreEqual(new[] { "a", "b", "c", "system.indexes" }, collectionNames); }
public void TestDropDatabase() { _collection.Insert(new BsonDocument()); var databaseNames = _server.GetDatabaseNames(); Assert.IsTrue(databaseNames.Contains(_database.Name)); var result = _server.DropDatabase(_database.Name); databaseNames = _server.GetDatabaseNames(); Assert.IsFalse(databaseNames.Contains(_database.Name)); }
public void TestDropDatabase() { if (!_isMasterSlavePair) { _collection.Insert(new BsonDocument()); var databaseNames = _server.GetDatabaseNames(); Assert.IsTrue(databaseNames.Contains(_database.Name)); _server.DropDatabase(_database.Name); databaseNames = _server.GetDatabaseNames(); Assert.IsFalse(databaseNames.Contains(_database.Name)); } }
protected virtual void OnTestFixtureSetUp() { if(IoC.IsNotInitialized) IoC.Initialize(); if(IsDebugEnabled) log.Debug("MongoDB 서버에 접속합니다. connectionString=[{0}]", DefaultConnectionString); Server = MongoServer.Create(DefaultConnectionString); Server.Connect(); Server.DropDatabase(DefaultDatabaseName); Database = Server[DefaultDatabaseName]; }
public void TestDropDatabase() { var databaseNamespace = CoreTestConfiguration.GetDatabaseNamespaceForTestClass(typeof(MongoServerTests)); var database = __server.GetDatabase(databaseNamespace.DatabaseName); var collection = database.GetCollection("test"); collection.Insert(new BsonDocument()); var databaseNames = __server.GetDatabaseNames(); Assert.True(databaseNames.Contains(database.Name)); __server.DropDatabase(database.Name); databaseNames = __server.GetDatabaseNames(); Assert.False(databaseNames.Contains(database.Name)); }
public void TestDropDatabase() { var databaseName = "onlinetests-temp"; var database = server[databaseName]; var test = database["test"]; test.Insert(new BsonDocument()); var databaseNames = server.GetDatabaseNames(); Assert.IsTrue(databaseNames.Contains(databaseName)); var result = server.DropDatabase(databaseName); databaseNames = server.GetDatabaseNames(); Assert.IsFalse(databaseNames.Contains(databaseName)); }
public void TestDropDatabase() { if (!_isMasterSlavePair) { var databaseNamespace = CoreTestConfiguration.GetDatabaseNamespaceForTestFixture(); var database = _server.GetDatabase(databaseNamespace.DatabaseName); var collection = database.GetCollection("test"); collection.Insert(new BsonDocument()); var databaseNames = _server.GetDatabaseNames(); Assert.IsTrue(databaseNames.Contains(database.Name)); _server.DropDatabase(database.Name); databaseNames = _server.GetDatabaseNames(); Assert.IsFalse(databaseNames.Contains(database.Name)); } }
protected virtual void OnTestFixtureSetUp() { if (IoC.IsNotInitialized) { IoC.Initialize(); } if (IsDebugEnabled) { log.Debug("MongoDB 서버에 접속합니다. connectionString=[{0}]", DefaultConnectionString); } Server = MongoServer.Create(DefaultConnectionString); Server.Connect(); Server.DropDatabase(DefaultDatabaseName); Database = Server[DefaultDatabaseName]; }
/// <summary> /// 数据库操作 /// </summary> /// <param name="strObjTag"></param> /// <param name="dbName"></param> /// <param name="func"></param> /// <param name="tr"></param> /// <returns></returns> public static Boolean DataBaseOpration(String strObjTag, String dbName, Oprcode func, TreeNode tr) { Boolean rtnResult = false; MongoServer mongoSvr = GetMongoServerBySvrPath(strObjTag); String strSvrPath = SystemManager.GetTagData(strObjTag); String svrKey = strSvrPath.Split("/".ToCharArray())[(int)PathLv.ServerLV]; if (mongoSvr != null) { switch (func) { case Oprcode.Create: if (!mongoSvr.DatabaseExists(dbName)) { mongoSvr.GetDatabase(dbName); tr.Nodes.Add(FillDataBaseInfoToTreeNode(dbName, mongoSvr, svrKey + "/" + svrKey)); rtnResult = true; } break; case Oprcode.Drop: if (mongoSvr.DatabaseExists(dbName)) { mongoSvr.DropDatabase(dbName); if (tr != null) { tr.TreeView.Nodes.Remove(tr); } rtnResult = true; } break; case Oprcode.Repair: //How To Compress?Run Command?? break; default: break; } } return(rtnResult); }
public static void DropDatabase(string dbName) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(filePath); XmlNodeList dbNodeList = xmlDoc.DocumentElement.SelectNodes("/Databases/DataBase"); foreach (XmlNode node in dbNodeList) { if (node.Attributes.GetNamedItem("dataBaseName").Value == dbName) { var currentNode = node; var parentNode = node.ParentNode; parentNode.RemoveChild(currentNode); xmlDoc.Save(filePath); MongoServer server = Utilities.CreateMongoConnection(); // var database = server.GetDatabase(dbName); server.DropDatabase(dbName); MessageBox.Show("Database " + dbName + " dropped successfully!"); break; } } }
private void CleanUp() { MongoServer.DropDatabase(DataBase); MongoServer.Disconnect(); OnCleanUp(); }
public virtual void TearDownFixture() { _server.DropDatabase("test"); }
private void CleanUp() { _server.DropDatabase(DataBase); _server.Disconnect(); }
public CommandResult DropDatabase(string databaseName) { return(_mongoServer.DropDatabase(databaseName)); }
public void dropAll() { server.DropDatabase("tickData"); }