using Dpz.Core.Public.ViewModel;
using Microsoft.Extensions.Logging;

namespace Dpz.Core.Backup;

public class RestoreService(ILoggerFactory loggerFactory) : IRestoreService
{
    public async Task RestoreAsync(string connectionString, string filePath, string filePassword)
    {
        if (string.IsNullOrEmpty(connectionString))
        {
            throw new ArgumentNullException(nameof(connectionString));
        }
        if (string.IsNullOrEmpty(filePassword))
        {
            throw new ArgumentNullException(nameof(filePath));
        }

        if (string.IsNullOrEmpty(filePath))
        {
            throw new ArgumentNullException(nameof(filePassword));
        }

        if (!File.Exists(filePath))
        {
            throw new IOException("备份文件不存在");
        }

        var restoreManager = new RestoreManager(
            connectionString,
            filePassword,
            filePath,
            loggerFactory
        );

        await restoreManager.RestoreAsync();
    }
}
评论加载中...