本文整理汇总了C#中MongoDB.Driver.CommandDocument.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# CommandDocument.ToString方法的具体用法?C# CommandDocument.ToString怎么用?C# CommandDocument.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoDB.Driver.CommandDocument
的用法示例。
在下文中一共展示了CommandDocument.ToString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: ExecuteMongoSvrCommand
/// <summary>
/// 执行MongoCommand
/// </summary>
/// <param name="mCommandDocument">命令Doc</param>
/// <param name="mongoSvr">目标服务器</param>
/// <returns></returns>
public static CommandResult ExecuteMongoSvrCommand(CommandDocument mCommandDocument, MongoServer mongoSvr)
{
CommandResult mCommandResult;
try
{
mCommandResult = mongoSvr.GetDatabase(DATABASE_NAME_ADMIN).RunCommand(mCommandDocument);
}
catch (MongoCommandException ex)
{
mCommandResult = ex.CommandResult;
}
RunCommandEventArgs e = new RunCommandEventArgs();
e.CommandString = mCommandDocument.ToString();
e.RunLevel = PathLv.ServerLV;
e.Result = mCommandResult;
OnCommandRunComplete(e);
return mCommandResult;
}
示例3: ExecuteMongoSvrCommand
/// <summary>
/// 执行MongoCommand
/// </summary>
/// <param name="mCommandDocument">命令Doc</param>
/// <param name="mongoSvr">目标服务器</param>
/// <returns></returns>
public static CommandResult ExecuteMongoSvrCommand(CommandDocument mCommandDocument, MongoServer mongoSvr)
{
CommandResult mCommandResult;
try
{
mCommandResult = mongoSvr.GetDatabase(MongoDbHelper.DATABASE_NAME_ADMIN).RunCommand(mCommandDocument);
}
catch (MongoCommandException ex)
{
mCommandResult = ex.CommandResult;
}
var e = new RunCommandEventArgs
{
CommandString = mCommandDocument.ToString(),
RunLevel = MongoDbHelper.PathLv.InstanceLv,
Result = mCommandResult
};
OnCommandRunComplete(e);
return mCommandResult;
}
示例4: ExecuteMongoDBCommand
/// <summary>
/// 执行数据库命令
/// </summary>
/// <param name="mongoCmd"></param>
/// <param name="mongoDB"></param>
/// <returns></returns>
public static CommandResult ExecuteMongoDBCommand(CommandDocument mongoCmd, MongoDatabase mongoDB)
{
CommandResult mCommandResult;
try
{
mCommandResult = mongoDB.RunCommand(mongoCmd);
}
catch (MongoCommandException ex)
{
mCommandResult = ex.CommandResult;
}
var e = new RunCommandEventArgs
{
CommandString = mongoCmd.ToString(),
RunLevel = MongoDbHelper.PathLv.DatabaseLv,
Result = mCommandResult
};
OnCommandRunComplete(e);
return mCommandResult;
}
示例5: 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 ExecuteCommand = new CommandDocument
{
{Command, mongoCol.Name},
};
foreach (BsonElement item in ExtendInfo.Elements)
{
ExecuteCommand.Add(item);
}
CommandResult mCommandResult = mongoCol.Database.RunCommand(ExecuteCommand);
var e = new RunCommandEventArgs
{
CommandString = ExecuteCommand.ToString(),
RunLevel = MongoDbHelper.PathLv.CollectionLv,
Result = mCommandResult
};
OnCommandRunComplete(e);
return mCommandResult;
}
示例6: ExecuteMongoSvrCommand
/// <summary>
/// 执行MongoCommand
/// </summary>
/// <param name="mCommandDocument">命令Doc</param>
/// <param name="mongoSvr">目标服务器</param>
/// <returns></returns>
public static CommandResult ExecuteMongoSvrCommand(CommandDocument mCommandDocument, MongoServer mongoSvr)
{
CommandResult mCommandResult;
try
{
mCommandResult = mongoSvr.GetDatabase(ConstMgr.DatabaseNameAdmin).RunCommand(mCommandDocument);
}
catch (MongoCommandException ex)
{
mCommandResult = new CommandResult(ex.Result);
}
var e = new RunCommandEventArgs
{
CommandString = mCommandDocument.ToString(),
RunLevel = EnumMgr.PathLevel.Instance,
Result = mCommandResult
};
OnCommandRunComplete(e);
return mCommandResult;
}
示例7: ExecuteMongoDBCommand
/// <summary>
///
/// </summary>
/// <param name="mongoCmd"></param>
/// <param name="mongoDb"></param>
/// <returns></returns>
public static CommandResult ExecuteMongoDBCommand(CommandDocument mongoCmd, IMongoDatabase mongoDb)
{
CommandResult mCommandResult = null;
try
{
var t = Task.Run(
async () => { mCommandResult = await mongoDb.RunCommandAsync<CommandResult>(mongoCmd); }
);
t.Wait();
}
catch (MongoCommandException ex)
{
mCommandResult = new CommandResult(ex.Result);
}
var e = new RunCommandEventArgs
{
CommandString = mongoCmd.ToString(),
RunLevel = EnumMgr.PathLevel.Database,
Result = mCommandResult
};
OnCommandRunComplete(e);
return mCommandResult;
}
示例8: 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 executeCommand = new CommandDocument
{
{command, mongoCol.Name}
};
foreach (var item in extendInfo.Elements)
{
executeCommand.Add(item);
}
var mCommandResult = mongoCol.Database.RunCommand(executeCommand);
var e = new RunCommandEventArgs
{
CommandString = executeCommand.ToString(),
RunLevel = EnumMgr.PathLevel.Collection,
Result = mCommandResult
};
OnCommandRunComplete(e);
return mCommandResult;
}
示例9: ExecuteMongoSvrCommand
/// <summary>
/// 执行MongoCommand
/// </summary>
/// <param name="mCommandDocument">命令Doc</param>
/// <param name="mongoSvr">目标服务器</param>
/// <returns></returns>
public static CommandResult ExecuteMongoSvrCommand(CommandDocument mCommandDocument, MongoServer mongoSvr)
{
CommandResult mCommandResult = null;
try
{
if (mongoSvr.DatabaseExists(ConstMgr.DatabaseNameAdmin))
{
//Repl的时候,会发生超时问题
mCommandResult = mongoSvr.GetDatabase(ConstMgr.DatabaseNameAdmin).RunCommand(mCommandDocument);
}
else
{
//Replset的时候,没有Admin数据库
BsonDocument AdminDatabaseNotFound = new BsonDocument();
AdminDatabaseNotFound.Add("errmsg", "Admin Database Not Found");
mCommandResult = new CommandResult(AdminDatabaseNotFound);
}
}
catch (MongoCommandException ex)
{
mCommandResult = new CommandResult(ex.Result);
}
catch (TimeoutException)
{
BsonDocument TimeOutDocument = new BsonDocument();
TimeOutDocument.Add("errmsg", "TimeoutException");
mCommandResult = new CommandResult(TimeOutDocument);
}
var e = new RunCommandEventArgs
{
CommandString = mCommandDocument.ToString(),
RunLevel = EnumMgr.PathLevel.Instance,
Result = mCommandResult
};
OnCommandRunComplete(e);
return mCommandResult;
}
示例10: 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;
}