/// <summary> /// Create a restore data object that includes the plan to do the restore operation /// </summary> /// <param name="requestParam"></param> /// <returns></returns> private void UpdateRestorePlan(RestoreDatabaseTaskDataObject restoreDataObject) { if (!string.IsNullOrEmpty(restoreDataObject.RestoreParams.BackupFilePaths)) { restoreDataObject.AddFiles(restoreDataObject.RestoreParams.BackupFilePaths); } restoreDataObject.RestorePlanner.ReadHeaderFromMedia = !string.IsNullOrEmpty(restoreDataObject.RestoreParams.BackupFilePaths); if (string.IsNullOrWhiteSpace(restoreDataObject.RestoreParams.SourceDatabaseName)) { restoreDataObject.RestorePlanner.DatabaseName = restoreDataObject.DefaultDbName; } else { restoreDataObject.RestorePlanner.DatabaseName = restoreDataObject.RestoreParams.SourceDatabaseName; } restoreDataObject.TargetDatabase = restoreDataObject.RestoreParams.TargetDatabaseName; restoreDataObject.RestoreOptions.KeepReplication = restoreDataObject.RestoreParams.GetOptionValue <bool>(RestoreOptionsHelper.KeepReplication); restoreDataObject.RestoreOptions.ReplaceDatabase = restoreDataObject.RestoreParams.GetOptionValue <bool>(RestoreOptionsHelper.ReplaceDatabase); restoreDataObject.RestoreOptions.SetRestrictedUser = restoreDataObject.RestoreParams.GetOptionValue <bool>(RestoreOptionsHelper.SetRestrictedUser); string recoveryState = restoreDataObject.RestoreParams.GetOptionValue <string>(RestoreOptionsHelper.RecoveryState); object databaseRecoveryState; if (Enum.TryParse(typeof(DatabaseRecoveryState), recoveryState, out databaseRecoveryState)) { restoreDataObject.RestoreOptions.RecoveryState = (DatabaseRecoveryState)databaseRecoveryState; } bool isTailLogBackupPossible = restoreDataObject.IsTailLogBackupPossible(restoreDataObject.RestorePlanner.DatabaseName); if (isTailLogBackupPossible) { restoreDataObject.RestorePlanner.BackupTailLog = restoreDataObject.RestoreParams.GetOptionValue <bool>(RestoreOptionsHelper.BackupTailLog); restoreDataObject.TailLogBackupFile = restoreDataObject.RestoreParams.GetOptionValue <string>(RestoreOptionsHelper.TailLogBackupFile); restoreDataObject.TailLogWithNoRecovery = restoreDataObject.RestoreParams.GetOptionValue <bool>(RestoreOptionsHelper.TailLogWithNoRecovery); } else { restoreDataObject.RestorePlanner.BackupTailLog = false; } restoreDataObject.CloseExistingConnections = restoreDataObject.RestoreParams.GetOptionValue <bool>(RestoreOptionsHelper.CloseExistingConnections); restoreDataObject.UpdateRestorePlan(restoreDataObject.RestoreParams.RelocateDbFiles); }
/// <summary> /// Create a restore data object that includes the plan to do the restore operation /// </summary> /// <param name="requestParam"></param> /// <returns></returns> private void UpdateRestorePlan(RestoreDatabaseTaskDataObject restoreDataObject) { if (!string.IsNullOrEmpty(restoreDataObject.RestoreParams.BackupFilePath)) { restoreDataObject.AddFile(restoreDataObject.RestoreParams.BackupFilePath); } restoreDataObject.RestorePlanner.ReadHeaderFromMedia = !string.IsNullOrEmpty(restoreDataObject.RestoreParams.BackupFilePath); restoreDataObject.RestorePlanner.DatabaseName = restoreDataObject.DefaultDbName; restoreDataObject.TargetDatabase = restoreDataObject.RestoreParams.DatabaseName; //TODO: used for other types of restore /*bool isTailLogBackupPossible = restoreDataObject.RestorePlanner.IsTailLogBackupPossible(restoreDataObject.RestorePlanner.DatabaseName); * restoreDataObject.RestorePlanner.BackupTailLog = isTailLogBackupPossible; * restoreDataObject.TailLogBackupFile = restoreDataObject.Util.GetDefaultTailLogbackupFile(dbName); * restoreDataObject.RestorePlanner.TailLogBackupFile = restoreDataObject.TailLogBackupFile; */ restoreDataObject.UpdateRestorePlan(restoreDataObject.RestoreParams.RelocateDbFiles); }