public static async Task MoveToAsync(Toolkit.Services.OneDrive.OneDriveStorageItem item, Toolkit.Services.OneDrive.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; } }
/// <summary> /// Initializes a new instance of the <see cref="OneDriveStorageItemPlatform"/> class. /// </summary> /// <param name="service">Instance of OneDriveService</param> /// <param name="oneDriveStorageItem">Instance of OneDriveStorageItem</param> public OneDriveStorageItemPlatform( Toolkit.Services.OneDrive.OneDriveService service, Toolkit.Services.OneDrive.OneDriveStorageItem oneDriveStorageItem) { _service = service; _oneDriveStorageItem = oneDriveStorageItem; }
public static async Task RenameAsync(Toolkit.Services.OneDrive.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(Toolkit.Services.OneDrive.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, async() => { OneDriveItemsList.ItemsSource = await _graphCurrentFolder.GetItemsAsync(20); }); } 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(Toolkit.Services.OneDrive.OneDriveStorageItem item) { try { Shell.Current.DisplayWaitRing = true; var oneDriveFile = (Toolkit.Services.OneDrive.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(Toolkit.Services.OneDrive.OneDriveStorageItem item) { if (item.IsFolder()) { Shell.Current.DisplayWaitRing = true; try { var currentFolder = await _graphCurrentFolder.GetFolderAsync(item.Name); OneDriveItemsList.ItemsSource = await currentFolder.GetItemsAsync(20); _graphCurrentFolder = currentFolder; } catch (ServiceException ex) { await OneDriveSampleHelpers.DisplayOneDriveServiceExceptionAsync(ex); } finally { Shell.Current.DisplayWaitRing = false; } } }
private async Task NavigateToFolderAsync(Toolkit.Services.OneDrive.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; } }
/// <summary> /// Creates an instance of platform-specific implementation. /// </summary> /// <param name="oneDriveService">Instance of the service.</param> /// <param name="oneDriveStorageItem">Instance of the storage item.</param> /// <returns>Returns concrete type.</returns> public IOneDriveStorageItemPlatform CreateOneDriveStorageItemPlatformInstance(Toolkit.Services.OneDrive.OneDriveService oneDriveService, Toolkit.Services.OneDrive.OneDriveStorageItem oneDriveStorageItem) { return(new OneDriveStorageItemPlatform(oneDriveService, oneDriveStorageItem)); }