本文整理匯總了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;
}