本文整理汇总了C#中MongoDB.Driver.CommandDocument类的典型用法代码示例。如果您正苦于以下问题:C# CommandDocument类的具体用法?C# CommandDocument怎么用?C# CommandDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandDocument类属于MongoDB.Driver命名空间,在下文中一共展示了CommandDocument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: ExecuteMongoColCommand
/// <summary>
/// 数据集命令
/// </summary>
/// <param name="Command">命令关键字</param>
/// <param name="mongoCol">数据集</param>
/// <param name="ExtendInfo">命令参数</param>
/// <returns></returns>
public static CommandResult ExecuteMongoColCommand(String Command, MongoCollection mongoCol, BsonDocument ExtendInfo)
{
var textSearchCommand = new CommandDocument
{
{ Command, mongoCol.Name },
};
foreach (var item in ExtendInfo.Elements)
{
textSearchCommand.Add(item);
}
var mCommandResult = mongoCol.Database.RunCommand(textSearchCommand);
RunCommandEventArgs e = new RunCommandEventArgs();
e.CommandString = textSearchCommand.ToString();
e.RunLevel = PathLv.CollectionLV;
e.Result = mCommandResult;
OnCommandRunComplete(e);
return mCommandResult;
}
开发者ID:huchao007,项目名称:MagicMongoDBTool,代码行数:25,代码来源:MongoDBHelper_Command_Run.cs
示例17: ExecuteMongoDBCommand
/// <summary>
/// 执行数据库命令
/// </summary>
/// <param name="mongoCmd"></param>
/// <param name="mongoDB"></param>
/// <returns></returns>
public static CommandResult ExecuteMongoDBCommand(CommandDocument mongoCmd, MongoDatabase mongoDB)
{
CommandResult rtn;
try
{
rtn = mongoDB.RunCommand(mongoCmd);
}
catch (MongoCommandException ex)
{
rtn = ex.CommandResult;
}
RunCommandEventArgs e = new RunCommandEventArgs();
e.CommandString = mongoCmd.ToString();
e.RunLevel = PathLv.DatabaseLV;
e.Result = rtn;
OnCommandRunComplete(e);
return rtn;
}
开发者ID:huohe2009,项目名称:MagicMongoDBTool,代码行数:24,代码来源:MongoDBHelper_RunCommand.cs
示例18: BeginProcessing
protected override void BeginProcessing()
{
if (_CommandDocument == null)
{
if (Value == null)
_CommandDocument = new CommandDocument(_CommandName, 1);
else
_CommandDocument = new CommandDocument(_CommandName, Actor.ToBsonValue(Value));
}
try
{
var result = Database.RunCommand(_CommandDocument);
WriteObject(new Dictionary(result.Response));
}
catch (MongoCommandException ex)
{
WriteException(ex, null);
}
}
开发者ID:nightroman,项目名称:Mdbc,代码行数:20,代码来源:InvokeCommandCommand.cs
示例19: ExecuteMongoColCommand
/// <summary>
/// 执行数据集命令
/// </summary>
/// <param name="CommandString"></param>
/// <param name="mongoCol"></param>
/// <returns></returns>
public static CommandResult ExecuteMongoColCommand(String CommandString, MongoCollection mongoCol)
{
CommandResult rtn;
BsonDocument cmd = new BsonDocument();
cmd.Add(CommandString, mongoCol.Name);
CommandDocument mongoCmd = new CommandDocument() { cmd };
try
{
rtn = mongoCol.Database.RunCommand(mongoCmd);
}
catch (MongoCommandException ex)
{
rtn = ex.CommandResult;
}
RunCommandEventArgs e = new RunCommandEventArgs();
e.CommandString = CommandString;
e.RunLevel = PathLv.DatabaseLV;
e.Result = rtn;
OnCommandRunComplete(e);
return rtn;
}
开发者ID:huohe2009,项目名称:MagicMongoDBTool,代码行数:27,代码来源:MongoDBHelper_RunCommand.cs
示例20: AddSharding
/// <summary>
/// 增加数据分片
/// </summary>
/// <param name="routeSvr"></param>
/// <param name="replicaSetName"></param>
/// <param name="lstAddress"></param>
/// <remarks>注意:有个命令可能只能用在mongos上面</remarks>
/// <returns></returns>
public static CommandResult AddSharding(MongoServer routeSvr, String replicaSetName, List<String> lstAddress, String Name, Decimal MaxSize)
{
// replset/host:port,host:port
String cmdPara = replicaSetName == String.Empty ? String.Empty : (replicaSetName + "/");
foreach (String item in lstAddress)
{
cmdPara += item + ",";
}
cmdPara = cmdPara.TrimEnd(",".ToCharArray());
CommandDocument mongoCmd = new CommandDocument();
mongoCmd.Add("addshard", cmdPara);
if (MaxSize != 0)
{
mongoCmd.Add("maxSize", (BsonValue)MaxSize);
}
if (Name != String.Empty)
{
mongoCmd.Add("name", Name);
}
return ExecuteMongoSvrCommand(mongoCmd, routeSvr);
}
开发者ID:JayZhou,项目名称:MagicMongoDBTool,代码行数:30,代码来源:MongoDBHelper_Command.cs
注:本文中的MongoDB.Driver.CommandDocument类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论