本文整理汇总了C#中MongoServer.Ping方法的典型用法代码示例。如果您正苦于以下问题:C# MongoServer.Ping方法的具体用法?C# MongoServer.Ping怎么用?C# MongoServer.Ping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoServer
的用法示例。
在下文中一共展示了MongoServer.Ping方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ServerIsRunning
public static bool ServerIsRunning(MongoServer server)
{
try
{
server.Ping();
}
catch
{
return false;
}
return true;
}
示例2: ConnectToUpstream
/// <summary>
/// Connects to the upstream MongoDB server and returns if successful.
/// </summary>
private static bool ConnectToUpstream( )
{
try
{
upstream = MongoServer.Create( );
upstream.Connect( );
upstream.Ping( );
return true;
}
catch ( MongoConnectionException )
{
return false;
}
}
示例3: SearchHashForm
public SearchHashForm(string collectionName = "HashForm", string dbName = "emdsdb", string hostIP = "localhost")
{
connectionString = String.Format("mongodb://{0}/?safe=true", hostIP);
try
{
server = MongoServer.Create(connectionString);
database = server.GetDatabase(dbName);
collection = database.GetCollection<FormHash>(collectionName);
server.Ping();
}
catch
{
throw new Exception("Проблема подключением к монге");
}
log = FileLogger.GetLogger();
}
示例4: MongoRepository
public MongoRepository(string connectionString, string dbName, string collectionName)
{
ConnectionString = connectionString;
DatabaseName = dbName;
CollectionName = collectionName;
try
{
server = MongoServer.Create(connectionString);
database = server.GetDatabase(dbName, SafeMode.True);
collection = database.GetCollection(collectionName);
server.Ping();
}
catch
{
throw new Exception("Проблема с сервером БД");
//return null;
}
}
示例5: TrainLogRepository
public TrainLogRepository(string collectionName = "NeuralTrainLog", string dbName = "emdsdb", string connectionString = "mongodb://localhost/?safe=true")
{
CollectionName = collectionName;
DbName = dbName;
ConnectionString = String.Format("{0}/{1}", connectionString, dbName);
try
{
var client = new MongoClient(ConnectionString);
server = client.GetServer();
database = server.GetDatabase(dbName);
collection = database.GetCollection(collectionName);
server.Ping();
}
catch
{
throw new Exception("Не удалось подключиться к MongoDB");
}
}
示例6: TrainLogger
private TrainLogger(string collectionName = "NeuralTrainLog", string dbName = "emdsdb", string connectionStringMongo = "mongodb://localhost/?safe=true")
{
IdSession = Guid.NewGuid();
isCreate = true;
CollectionName = collectionName;
DbName = dbName;
AgeNumber = -1;
connectionString = connectionStringMongo;
try
{
server = MongoServer.Create(connectionString);
database = server.GetDatabase(dbName);
collection = database.GetCollection(collectionName);
server.Ping();
}
catch
{
throw new Exception("Не удалось подключиться к MongoDB");
}
}