public override async void Execute(object?parameter)
        {
            try
            {
                if (_ncaItem == null)
                {
                    return;
                }

                var filePath = _promptService.PromptSaveFile(_ncaItem.FileName);
                if (filePath == null)
                {
                    return;
                }

                var openDecryptedNca    = _ncaItem.Nca.OpenDecryptedNca();
                var saveStorageRunnable = _serviceProvider.GetRequiredService <ISaveStorageRunnable>();
                saveStorageRunnable.Setup(openDecryptedNca, filePath);

                await _backgroundTaskService.RunAsync(saveStorageRunnable);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, LocalizationManager.Instance.Current.Keys.SaveFile_Error, ex.Message);
            }
        }
Beispiel #2
0
        public override async void Execute(object?parameter)
        {
            if (_partitionFileItem == null)
            {
                return;
            }

            try
            {
                var file = _partitionFileItem.File;

                var filePath = _promptService.PromptSaveFile(_partitionFileItem.Name);
                if (filePath == null)
                {
                    return;
                }
                var runnable = _serviceProvider.GetRequiredService <ISaveFileRunnable>();
                runnable.Setup(file, filePath);

                await _backgroundTaskService.RunAsync(runnable);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, LocalizationManager.Instance.Current.Keys.SaveFile_Error.SafeFormat(ex.Message));
            }
        }
        public override async void Execute(object?parameter)
        {
            if (_directoryEntryItem == null)
            {
                return;
            }

            try
            {
                IRunnable runnable;
                if (_directoryEntryItem.DirectoryEntryType == DirectoryEntryType.File)
                {
                    var file     = _directoryEntryItem.GetFile();
                    var filePath = _promptService.PromptSaveFile(_directoryEntryItem.Name);
                    if (filePath == null)
                    {
                        return;
                    }

                    var saveFileRunnable = _serviceProvider.GetRequiredService <ISaveFileRunnable>();
                    saveFileRunnable.Setup(file, filePath);
                    runnable = saveFileRunnable;
                }
                else
                {
                    var dirPath = _promptService.PromptSaveDir();
                    if (dirPath == null)
                    {
                        return;
                    }
                    var saveDirectoryRunnable = _serviceProvider.GetRequiredService <ISaveDirectoryRunnable>();
                    saveDirectoryRunnable.Setup(new[] { _directoryEntryItem }, dirPath);
                    runnable = saveDirectoryRunnable;
                }

                await _backgroundTaskService.RunAsync(runnable);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, LocalizationManager.Instance.Current.Keys.SaveFile_Error.SafeFormat(ex.Message));
            }
        }