public static async Task MoveToAsync(OneDriveStorageItem item, OneDriveStorageFolder rootFolder) { Shell.Current.DisplayWaitRing = true; try { var folder = await OneDriveSampleHelpers.OpenFolderPicker("Move to", rootFolder); if (folder != null) { await item.MoveAsync(folder); } } catch (ServiceException exService) { await OneDriveSampleHelpers.DisplayOneDriveServiceExceptionAsync(exService); } catch (Exception ex) { await OneDriveSampleHelpers.DisplayMessageAsync(ex.Message); TrackingManager.TrackException(ex); } finally { Shell.Current.DisplayWaitRing = false; } }
public static async Task RenameAsync(OneDriveStorageItem itemToRename) { try { Shell.Current.DisplayWaitRing = true; string newName = await OneDriveSampleHelpers.InputTextDialogAsync("New Name"); if (!string.IsNullOrEmpty(newName)) { await itemToRename.RenameAsync(newName); } } catch (ServiceException graphEx) { await OneDriveSampleHelpers.DisplayOneDriveServiceExceptionAsync(graphEx); } catch (Exception ex) { await OneDriveSampleHelpers.DisplayMessageAsync(ex.Message); TrackingManager.TrackException(ex); } finally { Shell.Current.DisplayWaitRing = false; } }
private async Task DeleteAsync(OneDriveStorageItem itemToDelete) { MessageDialog messageDialog = new MessageDialog($"Are you sure you want to delete '{itemToDelete.Name}'", "Delete"); messageDialog.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(async(cmd) => { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Shell.Current.DisplayWaitRing = true; }); try { await itemToDelete.DeleteAsync(); await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { OneDriveItemsList.ItemsSource = _currentFolder.GetItemsAsync(); }); } catch (ServiceException ex) { await OneDriveSampleHelpers.DisplayOneDriveServiceExceptionAsync(ex); } finally { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Shell.Current.DisplayWaitRing = false; }); } }))); messageDialog.Commands.Add(new UICommand("No", new UICommandInvokedHandler((cmd) => { return; }))); messageDialog.DefaultCommandIndex = 0; messageDialog.CancelCommandIndex = 1; var command = await messageDialog.ShowAsync(); }
/// <summary> /// Download a file /// </summary> /// <param name="item">File to download from OneDrive</param> /// <returns>Task to support await of async call.</returns> public static async Task DownloadAsync(OneDriveStorageItem item) { try { Shell.Current.DisplayWaitRing = true; var oneDriveFile = (OneDriveStorageFile)item; using (var remoteStream = (await oneDriveFile.StorageFilePlatformService.OpenAsync()) as IRandomAccessStream) { await SaveToLocalFolder(remoteStream, oneDriveFile.Name); } } catch (Exception ex) { await OneDriveSampleHelpers.DisplayMessageAsync(ex.Message); TrackingManager.TrackException(ex); } finally { Shell.Current.DisplayWaitRing = false; } }
private async Task NavigateToFolderAsync(OneDriveStorageItem item) { if (item.IsFolder()) { Shell.Current.DisplayWaitRing = true; try { var currentFolder = await _currentFolder.GetFolderAsync(item.Name); OneDriveItemsList.ItemsSource = currentFolder.GetItemsAsync(); _currentFolder = currentFolder; } catch (ServiceException ex) { await OneDriveSampleHelpers.DisplayOneDriveServiceExceptionAsync(ex); } finally { Shell.Current.DisplayWaitRing = false; } } }
private async Task NavigateToFolderAsync(OneDriveStorageItem item) { progressRing.IsActive = true; try { var currentFolder = await _graphCurrentFolder.GetFolderAsync(item.Name); var items = await currentFolder.GetFoldersAsync(100); if (items.Count > 0) { LstFolder.ItemsSource = items; _graphCurrentFolder = currentFolder; } } catch (ServiceException ex) { await OneDriveSampleHelpers.DisplayOneDriveServiceExceptionAsync(ex); } finally { progressRing.IsActive = false; } }