当前位置: 首页>>代码示例>>C#>>正文


C# MongoServer.Ping方法代码示例

本文整理汇总了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;
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:13,代码来源:MongoDbRepositoryManager.cs

示例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;
     }
 }
开发者ID:phillco,项目名称:MongoWebShell,代码行数:17,代码来源:Program.cs

示例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();
 }
开发者ID:neismit,项目名称:emds,代码行数:16,代码来源:SearchHashForm.cs

示例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;
     }
 }
开发者ID:opcheese,项目名称:DlyaCrawlerov,代码行数:18,代码来源:MongoRepository.cs

示例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");
     }
 }
开发者ID:neismit,项目名称:emds,代码行数:18,代码来源:TrainLogRepository.cs

示例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");
     }
 }
开发者ID:neismit,项目名称:emds,代码行数:20,代码来源:TrainLogger.cs


注:本文中的MongoServer.Ping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。