public override async void Execute(object?parameter) { if (_sectionItem == null) { return; } var selectedDir = _promptService.PromptSaveDir(); if (selectedDir == null) { return; } try { var targetDirPath = Path.Combine(selectedDir, $"Section_{_sectionItem.SectionIndex}"); var runnable = _serviceProvider.GetRequiredService <ISaveDirectoryRunnable>(); runnable.Setup(_sectionItem.ChildItems, targetDirPath); 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)); } }