本文整理汇总了C#中ILog.IndentScope方法的典型用法代码示例。如果您正苦于以下问题:C# ILog.IndentScope方法的具体用法?C# ILog.IndentScope怎么用?C# ILog.IndentScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILog
的用法示例。
在下文中一共展示了ILog.IndentScope方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RestoreDatabase
private void RestoreDatabase(DatabaseBackupInfo db, bool dryRun, ILog log)
{
var sb = new StringBuilder();
var dbName = SqlUtils.ToBracketedIdentifier(db.Name);
var sqlParams = new SqlParamCollection();
sb.AppendFormat(
"USE [master]\n" +
"IF db_id(@dbName) IS NOT NULL\n" +
" ALTER DATABASE {0} SET SINGLE_USER WITH ROLLBACK IMMEDIATE\n" +
"RESTORE DATABASE {0} FROM DISK = @backupFile WITH FILE = 1, NOUNLOAD, STATS = 5",
dbName);
sqlParams.Add("@dbName", SqlDbType.NVarChar).Value = db.Name;
sqlParams.Add("@backupFile", SqlDbType.NVarChar).Value = db.BackupFilePath;
if (mDatabaseConnection.Relocate)
{
var names = SqlUtils.GetLogicalAndPhysicalNamesFromBackupFile(mDatabaseConnection, db.BackupFilePath);
var i = 0;
foreach (var tuple in names)
{
var logical = string.Format("@l{0}", i);
var physical = string.Format("@p{0}", i);
sb.AppendFormat(",\n MOVE {0} TO {1}", logical, physical);
var destPath = GetRelocation(db.Name, mDatabaseConnection.RelocatePath, tuple.Item2);
sqlParams.Add(logical, SqlDbType.NVarChar).Value = tuple.Item1;
sqlParams.Add(physical, SqlDbType.NVarChar).Value = destPath;
++i;
}
}
sb.AppendFormat(
"\nALTER DATABASE {0} SET MULTI_USER\n", dbName);
log.LogFormat("Restoring {0} from {1}", db.Name, db.BackupFilePath);
if (!dryRun)
{
using (var process = SqlUtils.Exec(mDatabaseConnection, db.Name, sb.ToString(), sqlParams))
using (log.IndentScope())
{
foreach (var processOutputLine in process.GetOutput())
{
log.Log(processOutputLine.Line);
}
}
}
log.Log("Database restore completed.");
}