public async Task BackupWorkspace(IJSRuntime js, string fileName) { var localStorageManager = new LocalStorageManager(LocalStorageRepository); var backup = await localStorageManager.ExportToZip(); await js.SaveAs(fileName, backup); }
public async Task ResetWorkspace(IJSRuntime js) { var localStorageManager = new LocalStorageManager(LocalStorageRepository); await localStorageManager.Clear(); await js.ReloadApplication(); }
public async Task HandleFileSelected(IFileListEntry[] files) { SetProgress(); await Task.Delay(10); try { var reader = new FileListEntryReader() { DataValidation = data => { if (!LocalStorageManager.ValidateZip(data)) { throw new InvalidOperationException("Invalid archive format"); } } }; var file = files?.FirstOrDefault(); Data = await reader.HandleFile(file); SetInfo(file.Name); } catch (Exception ex) { SetError(ex.Message); Data = null; } }
public async Task RestoreWorkspace(IJSRuntime js, byte[] data) { var localStorageManager = new LocalStorageManager(LocalStorageRepository); await localStorageManager.Clear(); await localStorageManager.ImportFromZip(data); await js.ReloadApplication(); }