示例#1
0
		private int Run(
			DatabaseLogger logger,
			IEnumerable<DbMaintenanceSettings> databasesToBackup,
			Action<string, string> maintenanceOperation)
		{
			var databaseBackupedCount = 0;

			foreach (var database in databasesToBackup)
			{
				try
				{
					maintenanceOperation(database.Name, database.Path);

					logger.Successed(database.Name);

					databaseBackupedCount++;
				}
				catch (Exception exception)
				{
					logger.Failed(database.Name, exception);
				}
			}

			return databaseBackupedCount;
		}
示例#2
0
        public int Restore(
            DatabaseLogger logger,
            string connectionString,
            IEnumerable <DbMaintenanceSettings> databasesToRestore)
        {
            var sqlDatabase = new SqlDatabase(connectionString);

            Action <string, string> action = sqlDatabase.Restore;

            return(Run(logger, databasesToRestore, action));
        }
示例#3
0
		public int Restore(
			DatabaseLogger logger,
			string connectionString,
			IEnumerable<DbMaintenanceSettings> databasesToRestore)
		{
			var sqlDatabase = new SqlDatabase(connectionString);

			Action<string, string> action = sqlDatabase.Restore;

			return Run(logger, databasesToRestore, action);
		}
示例#4
0
        public int Restore(
            DatabaseLogger logger,
            string connectionString,
            IEnumerable <DbMaintenanceSettings> databasesToRestore,
            string restorePath)
        {
            var sqlDatabase = new SqlDatabase(connectionString);

            Action <string, string> action =
                (databaseName, backupPath) => sqlDatabase.Restore(databaseName, backupPath, restorePath);

            return(Run(logger, databasesToRestore, action));
        }
示例#5
0
		public int Restore(
			DatabaseLogger logger,
			string connectionString,
			IEnumerable<DbMaintenanceSettings> databasesToRestore,
			string restorePath)
		{
			var sqlDatabase = new SqlDatabase(connectionString);

			Action<string, string> action =
				(databaseName, backupPath) => sqlDatabase.Restore(databaseName, backupPath, restorePath);

			return Run(logger, databasesToRestore, action);
		}
示例#6
0
        public int Backup(
            DatabaseLogger logger,
            string connectionString,
            IEnumerable <DbMaintenanceSettings> databasesToBackup,
            bool appendDatabaseBackup)
        {
            var sqlDatabase = new SqlDatabase(connectionString);

            Action <string, string> action =
                (databaseName, databasePath) =>
                sqlDatabase.Backup(databaseName, databasePath, appendDatabaseBackup);

            return(Run(logger, databasesToBackup, action));
        }
示例#7
0
		public int Backup(
			DatabaseLogger logger,
			string connectionString,
			IEnumerable<DbMaintenanceSettings> databasesToBackup,
			bool appendDatabaseBackup)
		{
			var sqlDatabase = new SqlDatabase(connectionString);

			Action<string, string> action =
				(databaseName, databasePath) =>
					sqlDatabase.Backup(databaseName, databasePath, appendDatabaseBackup);

			return Run(logger, databasesToBackup, action);
		}