public async Task SafeOpenFile(string filePath) { try { _appSettings.LastOpenedFile = filePath; var runnableRelay = new RunnableRelay <NxFile>((reporter, _) => { var loadingFilePleaseWait = LocalizationManager.Instance.Current.Keys.LoadingFile_PleaseWait; reporter.SetText(loadingFilePleaseWait); return(_fileLoader.Load(filePath)); }) { SupportProgress = false, SupportsCancellation = false }; var nxFile = await _backgroundTaskService.RunAsync(runnableRelay); _openedFileService.OpenedFile = nxFile; } catch (FileNotSupportedException ex) { _logger.LogError(ex, LocalizationManager.Instance.Current.Keys.FileNotSupported_Log.SafeFormat(filePath)); } catch (Exception ex) { _logger.LogError(ex, LocalizationManager.Instance.Current.Keys.LoadingError_Failed.SafeFormat(filePath, ex.Message), ex); } }
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); } }
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 (_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)); } }
public override void Execute(object?parameter) { var openedFile = _openedFileService.OpenedFile; if (openedFile == null) { return; } var fileOverview = openedFile.Overview; if (fileOverview.NcaItems.Count <= 0) { return; } var verifyNcasHashRunnable = _serviceProvider.GetRequiredService <IVerifyNcasHashRunnable>(); verifyNcasHashRunnable.Setup(fileOverview); _backgroundTaskService.RunAsync(verifyNcasHashRunnable); }