/// <summary> /// Initializes a new instance of the <see cref="DbRestoreInfoAttribute"/> class. /// </summary> /// <param name="connectionString">The connection string to the database server.</param> /// <param name="databaseName">Name of the database to be restored.</param> /// <param name="backupDestination">The location of the backup file.</param> /// <param name="factoryType">The factory class derived from <see cref="IDbFactory"/> that will execute the restore</param> /// <param name="backupDevice">The <see cref="DbBackupDevice">type</see> of backup device.</param> /// <exception cref="ArgumentNullException">Thrown if either the <paramref name="connectionString"/>, /// <paramref name="databaseName"/>, <paramref name="backupDestination"/>, or <paramref name="factoryType"/> are null</exception> /// <exception cref="ArgumentException">Thrown if <paramref name="factoryType"/> does not derive from <see cref="IDbFactory"/></exception> protected DbRestoreInfoAttribute( string connectionString, string databaseName, string backupDestination, Type factoryType, DbBackupDevice backupDevice ) { if (connectionString == null) { throw new ArgumentNullException("connectionString"); } if (databaseName == null) { throw new ArgumentNullException("databaseName"); } if (backupDestination == null) { throw new ArgumentNullException("backupDestination"); } if (factoryType == null) { throw new ArgumentNullException("factoryType"); } if (!typeof(IDbFactory).IsAssignableFrom(factoryType)) { throw new ArgumentException("factorType must implement IDbFactory"); } this.connectionstring = connectionString; this.databaseName = databaseName; this.backupDestination = backupDestination; this.backupDevice = backupDevice; this.factoryType = factoryType; }
protected DbRestoreInfoAttribute( string connectionString, string databaseName, string backupDestination, Type factoryType, DbBackupDevice backupDevice ) { if (connectionString == null) throw new ArgumentNullException("connectionString"); if (databaseName == null) throw new ArgumentNullException("databaseName"); if (backupDestination == null) throw new ArgumentNullException("backupDestination"); if (factoryType == null) throw new ArgumentNullException("factoryType"); if (!typeof(IDbFactory).IsAssignableFrom(factoryType)) throw new ArgumentException("factorType must implement IDbFactory"); this.connectionstring = connectionString; this.databaseName = databaseName; this.backupDestination = backupDestination; this.backupDevice = backupDevice; this.factoryType = factoryType; }
/// <summary> /// Creates a backup of the specified database using the specified <paramref name="device"/> /// and <paramref name="destination"/>. /// </summary> /// <param name="device"> /// A <see cref="DbBackupDevice"/> defining the type of output device. /// </param> /// <param name="destination"> /// Device path. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="destination"/> is a null /// reference (Nothing in Visual Basic) /// </exception> public override void BackupDatabase(DbBackupDevice device, string destination) { if (destination == null) { throw new ArgumentNullException("destination"); } string query = null; if (device == DbBackupDevice.Dump) { query = String.Format("BACKUP DATABASE [{0}] TO {1}", this.DatabaseName, destination ); } else { query = String.Format("BACKUP DATABASE [{0}] TO {1} = '{2}'", this.DatabaseName, device.ToString().ToUpper(), destination ); } this.EnsureFileDestination(destination); this.ExecuteNonQuery(this.ConnectionString, query); }
/// <summary> /// Restores a backup of the specified database using the specified <paramref name="device"/> /// and <paramref name="destination"/>. /// </summary> /// <param name="device"> /// A <see cref="DbBackupDevice"/> defining the type of output device. /// </param> /// <param name="destination"> /// Device path. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="destination"/> is a null /// reference (Nothing in Visual Basic) /// </exception> /// <remarks> /// <para> /// If you plan to override an existing database, you must first drop this database. /// This method takes a conservative behavior and will not override an existing database. /// </para> /// <para> /// Priorly to restore the database, the method kills all the processes associeted /// to the database. /// </para> /// </remarks> public override void RestoreDatabase(DbBackupDevice device, string destination) { if (destination == null) { throw new ArgumentNullException("destination"); } // kill processes on db this.killOpenDBProcesses(this.ConnectionString, this.DatabaseName); string query = null; if (device == DbBackupDevice.Dump) { query = String.Format("RESTORE DATABASE [{0}] FROM {1}", this.DatabaseName, destination ); } else { query = String.Format("RESTORE DATABASE [{0}] FROM {1} = '{2}'", this.DatabaseName, device.ToString().ToUpper(), destination ); } this.ExecuteNonQuery(this.ConnectionString, query); }
public OracleRestoreInfoAttribute( string connectionString, string databaseName, string backupDestination, DbBackupDevice backupDevice ) : base(connectionString, databaseName, backupDestination, typeof(TestFu.Data.OracleClient.OracleFactory), backupDevice) { }
public OracleRestoreInfoAttribute( string connectionString, string databaseName, string backupDestination, DbBackupDevice backupDevice ) : base( connectionString, databaseName, backupDestination, typeof(TestFu.Data.OracleClient.OracleFactory), backupDevice ) { }
public override void RestoreDatabase(DbBackupDevice device, string destination) { throw new NotImplementedException(); }
/// <summary> /// Restores a backup of the specified database using the specified <paramref name="device"/> /// and <paramref name="destination"/>. /// </summary> /// <param name="device"> /// A <see cref="DbBackupDevice"/> defining the type of output device. /// </param> /// <param name="destination"> /// Device path. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="destination"/> is a null /// reference (Nothing in Visual Basic) /// </exception> /// <remarks> /// <para> /// If you plan to override an existing database, you must first drop this database. /// This method takes a conservative behavior and will not override an existing database. /// </para> /// </remarks> public abstract void RestoreDatabase(DbBackupDevice device, string destination);