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


C# Driver.CommandDocument类代码示例

本文整理汇总了C#中MongoDB.Driver.CommandDocument的典型用法代码示例。如果您正苦于以下问题:C# CommandDocument类的具体用法?C# CommandDocument怎么用?C# CommandDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CommandDocument类属于MongoDB.Driver命名空间,在下文中一共展示了CommandDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EnableSharding

 /// <summary>
 /// 数据库分片
 /// </summary>
 /// <param name="routeSvr"></param>
 /// <param name="shardingDB"></param>
 /// <returns></returns>
 public static CommandResult EnableSharding(MongoServer routeSvr, String shardingDB)
 {
     CommandDocument mongoCmd = new CommandDocument();
     mongoCmd = new CommandDocument();
     mongoCmd.Add("enablesharding", shardingDB);
     return ExecuteMongoCommand(mongoCmd, routeSvr);
 }
开发者ID:kklik,项目名称:MagicMongoDBTool,代码行数:13,代码来源:MongoDBHelper_Replset.cs

示例2: FillClientStatusToList

        /// <summary>
        /// </summary>
        /// <param name="trvSvrStatus"></param>
        /// <param name="mongoConnClientLst"></param>
        public static void FillClientStatusToList(CtlTreeViewColumns trvSvrStatus,
            Dictionary<string, MongoClient> mongoConnClientLst)
        {
            var srvDocList = new List<BsonDocument>();
            foreach (var mongoSvrKey in mongoConnClientLst.Keys)
            {
                try
                {
                    var mongoClient = mongoConnClientLst[mongoSvrKey];
                    //flydreamer提供的代码
                    // 感谢 魏琼东 的Bug信息,一些命令必须以Admin执行
                    if (RuntimeMongoDbContext.GetServerConfigBySvrPath(mongoSvrKey).LoginAsAdmin)
                    {
                        var adminDb = mongoClient.GetDatabase(ConstMgr.DatabaseNameAdmin);
                        //Can't Convert IMongoDB To MongoDB
                        var command = new CommandDocument {{CommandHelper.ServerStatusCommand.CommandString, 1}};

                        var serverStatusDoc =
                            CommandHelper.ExecuteMongoDBCommand(command, adminDb).Response;
                        srvDocList.Add(serverStatusDoc);
                    }
                }
                catch (Exception ex)
                {
                    Utility.ExceptionDeal(ex);
                }
            }
            UiHelper.FillDataToTreeView("Server Status", trvSvrStatus, srvDocList, 0);
            //打开第一层
            foreach (TreeNode item in trvSvrStatus.DatatreeView.Nodes)
            {
                item.Expand();
            }
        }
开发者ID:lizhi5753186,项目名称:MongoCola,代码行数:38,代码来源:FillMongoDB.cs

示例3: TestCodeMissing

        public void TestCodeMissing()
        {
            var command = new CommandDocument("invalid", 1);
            var document = new BsonDocument();
            var result = new CommandResult(command, document);

            Assert.IsFalse(result.Code.HasValue);
        }
开发者ID:wireclub,项目名称:mongo-csharp-driver,代码行数:8,代码来源:CommandResultTests.cs

示例4: ExecuteJsShell

 /// 注意:有些命令可能只能用在mongos上面,例如addshard
 /// <summary>
 ///     使用Shell Helper命令
 /// </summary>
 /// <param name="JsShell"></param>
 /// <param name="mongoSvr"></param>
 /// <returns></returns>
 public static CommandResult ExecuteJsShell(String JsShell, MongoServer mongoSvr)
 {
     var ShellCmd = new BsonDocument {{"$eval", new BsonJavaScript(JsShell)}, {"nolock", true}};
     //必须nolock
     var mongoCmd = new CommandDocument();
     mongoCmd.AddRange(ShellCmd);
     return ExecuteMongoSvrCommand(mongoCmd, mongoSvr);
 }
开发者ID:EricBlack,项目名称:MagicMongoDBTool,代码行数:15,代码来源:MongoDBHelper_Command_Run.cs

示例5: ExecuteJsShell

 /// <summary>
 /// 使用Shell Helper命令
 /// </summary>
 /// <param name="JsShell"></param>
 /// <param name="mongoSvr"></param>
 /// <returns></returns>
 public static CommandResult ExecuteJsShell(String JsShell, MongoServer mongoSvr)
 {
     BsonDocument cmd = new BsonDocument();
     cmd.Add("$eval", new BsonJavaScript(JsShell));
     //必须nolock
     cmd.Add("nolock", true);
     CommandDocument mongoCmd = new CommandDocument() { cmd };
     return ExecuteMongoCommand(mongoCmd, mongoSvr);
 }
开发者ID:kklik,项目名称:MagicMongoDBTool,代码行数:15,代码来源:MongoDBHelper_Replset.cs

示例6: TestCode

        public void TestCode()
        {
            var command = new CommandDocument("invalid", 1);
            var document = new BsonDocument("code", 18);
            var result = new CommandResult(command, document);

            Assert.IsTrue(result.Code.HasValue);
            Assert.AreEqual(18, result.Code);
        }
开发者ID:wireclub,项目名称:mongo-csharp-driver,代码行数:9,代码来源:CommandResultTests.cs

示例7: btnSearch_Click

 /// <summary>
 /// 全文检索功能
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSearch_Click(object sender, EventArgs e)
 {
     var textSearchCommand = new CommandDocument
         {
             { "text", SystemManager.GetCurrentCollection().Name },
             { "search", txtKey.Text }
         };
     CommandResult SearchResult = SystemManager.GetCurrentCollection().Database.RunCommand(textSearchCommand);
     MongoDBHelper.FillDataToTreeView("MapReduce Result", trvResult, SearchResult.Response);
 }
开发者ID:qiezi89,项目名称:MagicMongoDBTool,代码行数:15,代码来源:frmTextSearch.cs

示例8: TestOkMissing

 public void TestOkMissing() {
     var command = new CommandDocument("invalid", true);
     var document = new BsonDocument();
     var result = new CommandResult(command, document);
     try {
         var dummy = result.Ok;
     } catch (MongoCommandException ex) {
         Assert.IsTrue(ex.Message.StartsWith("Command 'invalid' failed: response has no ok element (response: "));
     }
 }
开发者ID:oskysal,项目名称:mongo-csharp-driver,代码行数:10,代码来源:CommandResultTests.cs

示例9: Count

 /// <summary>
 ///     执行Count(指定路劲)
 /// </summary>
 /// <param name="QueryDoc"></param>
 /// <param name="databaseName"></param>
 /// <param name="collectionName"></param>
 /// <returns></returns>
 public static CommandResult Count(BsonDocument QueryDoc, string databaseName, string collectionName)
 {
     //db.runCommand( { aggregate: "people", pipeline: [<pipeline>] } )
     var aggrCmd = new CommandDocument
         {
             new BsonElement("count", new BsonString(collectionName)),
             new BsonElement("query", QueryDoc)
         };
     var aggregateCommand = new MongoCommand(aggrCmd, EnumMgr.PathLevel.Database, databaseName);
     return ExecuteMongoCommand(aggregateCommand);
 }
开发者ID:magicdict,项目名称:MongoCola,代码行数:18,代码来源:DataBaseCommand.cs

示例10: Aggregate

 /// <summary>
 ///     执行聚合
 /// </summary>
 /// <param name="aggregateDoc"></param>
 /// <returns></returns>
 /// <param name="collectionName"></param>
 public static CommandResult Aggregate(BsonArray aggregateDoc, string collectionName)
 {
     //db.runCommand( { aggregate: "people", pipeline: [<pipeline>] } )
     var aggrCmd = new CommandDocument
         {
             new BsonElement("aggregate", new BsonString(collectionName)),
             new BsonElement("pipeline", aggregateDoc)
         };
     var aggregateCommand = new MongoCommand(aggrCmd, EnumMgr.PathLevel.Database);
     return ExecuteMongoCommand(aggregateCommand);
 }
开发者ID:magicdict,项目名称:MongoCola,代码行数:17,代码来源:DataBaseCommand.cs

示例11: TestMaxMessageLengthWhenNotServerSuppliedUsesMaxBsonObjectSizeWhenLargerThanMongoDefaults

        public void TestMaxMessageLengthWhenNotServerSuppliedUsesMaxBsonObjectSizeWhenLargerThanMongoDefaults()
        {
            var command = new CommandDocument("ismaster", 1);
            var document = new BsonDocument
            {
                { "ok", 1 },
                { "maxBsonObjectSize", MongoDefaults.MaxMessageLength }
            };
            var result = new IsMasterResult();
            result.Initialize(command, document);

            Assert.AreEqual(MongoDefaults.MaxMessageLength + 1024, result.MaxMessageLength);
        }
开发者ID:pwelter34,项目名称:mongo-csharp-driver,代码行数:13,代码来源:IsMasterResultTests.cs

示例12: TestMaxMessageLengthWhenServerSupplied

        public void TestMaxMessageLengthWhenServerSupplied()
        {
            var command = new CommandDocument("ismaster", 1);
            var document = new BsonDocument
            {
                { "ok", 1 },
                { "maxMessageSizeBytes", 1000 },
                { "maxBsonObjectSize", 1000 }
            };
            var result = new IsMasterResult();
            result.Initialize(command, document);

            Assert.AreEqual(1000, result.MaxMessageLength);
        }
开发者ID:pwelter34,项目名称:mongo-csharp-driver,代码行数:14,代码来源:IsMasterResultTests.cs

示例13: TestOkMissing

 public void TestOkMissing()
 {
     var command = new CommandDocument("invalid", 1);
     var document = new BsonDocument();
     var result = new CommandResult(document) { Command = command };
     try
     {
         var dummy = result.Ok;
     }
     catch (MongoCommandException ex)
     {
         Assert.IsTrue(ex.Message.StartsWith("Command 'invalid' failed. Response has no ok element (response was ", StringComparison.Ordinal));
     }
 }
开发者ID:annikulin,项目名称:code-classifier,代码行数:14,代码来源:CommandResultTests.cs

示例14: AddSharding

 /// <summary>
 /// 增加数据分片
 /// </summary>
 /// <param name="routeSvr"></param>
 /// <param name="replicaSetName"></param>
 /// <param name="shardingNames"></param>
 /// <returns></returns>
 public static CommandResult AddSharding(MongoServer routeSvr, string replicaSetName, List<string> shardingNames)
 {
     BsonDocument config = new BsonDocument();
     BsonDocument cmd = new BsonDocument();
     BsonDocument host = new BsonDocument();
     string cmdPara = replicaSetName + "/";
     foreach (var item in shardingNames)
     {
         cmdPara += SystemManager.ConfigHelperInstance.ConnectionList[item].IpAddr + ":" + SystemManager.ConfigHelperInstance.ConnectionList[item].Port.ToString() + ",";
     }
     cmdPara = cmdPara.TrimEnd(",".ToCharArray());
     CommandDocument mongoCmd = new CommandDocument();
     mongoCmd.Add("addshard", cmdPara);
     return ExecuteMongoCommand(mongoCmd, routeSvr);
 }
开发者ID:kklik,项目名称:MagicMongoDBTool,代码行数:22,代码来源:MongoDBHelper_Replset.cs

示例15: Aggregate

 public static CommandResult Aggregate(BsonArray AggregateDoc)
 {
     //db.runCommand( { aggregate: "people", pipeline: [<pipeline>] } )
     try
     {
         CommandDocument agg = new CommandDocument();
         agg.Add(new BsonElement("aggregate", new BsonString(SystemManager.GetCurrentCollection().Name)));
         agg.Add(new BsonElement("pipeline", AggregateDoc));
         MongoCommand Aggregate_Command = new MongoCommand(agg, PathLv.DatabaseLV);
         return ExecuteMongoCommand(Aggregate_Command, false);
     }
     catch (Exception ex)
     {
         SystemManager.ExceptionDeal(ex);
         return new CommandResult(new BsonDocument());
     }
 }
开发者ID:qq33357486,项目名称:MagicMongoDBTool,代码行数:17,代码来源:MongoDBHelper_RunCommand.cs


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