private async Task RegisterFolderForSync(object parameter) { await DesktopClientHelper.ShowDekstopClientInfo(); if (parameter is DavItem) { var folderPicker = new FolderPicker(); folderPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; folderPicker.FileTypeFilter.Add("."); var folder = await folderPicker.PickSingleFolderAsync(); if (folder == null) { return; } var state = await folder.GetIndexedStateAsync(); if (state == IndexedState.NotIndexed || state == IndexedState.PartiallyIndexed) { ContentDialog dialog = new ContentDialog(); dialog.Content = state == IndexedState.NotIndexed ? App.ResourceLoader.GetString("NotIndexedError") : App.ResourceLoader.GetString("PartiallyIndexedError"); dialog.PrimaryButtonText = App.ResourceLoader.GetString("yes"); dialog.SecondaryButtonText = App.ResourceLoader.GetString("no"); var result = await dialog.ShowAsync(); if (result == ContentDialogResult.Secondary) { return; } } var fa = await _syncedFolderService.AddFolderToSyncAsync(folder, (DavItem)parameter); NavigationService.Navigate(typeof(SyncedFolderConfigurationPage), fa, new SuppressNavigationTransitionInfo()); } }
private async Task RegisterFolderForSync(object parameter) { await DesktopClientHelper.ShowDekstopClientInfo(); if (parameter is DavItem) { var folderPicker = new FolderPicker(); folderPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; folderPicker.FileTypeFilter.Add("."); var folder = await folderPicker.PickSingleFolderAsync(); if (folder == null) { return; } var state = await folder.GetIndexedStateAsync(); if (state == IndexedState.NotIndexed || state == IndexedState.PartiallyIndexed) { ContentDialog dialog = new ContentDialog(); dialog.Content = state == IndexedState.NotIndexed ? App.ResourceLoader.GetString("NotIndexedError") : App.ResourceLoader.GetString("PartiallyIndexedError"); dialog.PrimaryButtonText = App.ResourceLoader.GetString("yes"); dialog.SecondaryButtonText = App.ResourceLoader.GetString("no"); var result = await dialog.ShowAsync(); if (result == ContentDialogResult.Secondary) { return; } } foreach (var assocaition in _syncedFolderService.GetAllSyncedFolders()) { if (String.Equals(folder.Path, assocaition.LocalFolderPath, StringComparison.OrdinalIgnoreCase)) { MessageDialog dialog = new MessageDialog(string.Format(App.ResourceLoader.GetString("SelectedFolderAlreadyInUseForSync"), folder.Path)); await dialog.ShowAsync(); return; } } var fa = await _syncedFolderService.AddFolderToSyncAsync(folder, (DavItem)parameter); NavigationService.Navigate(typeof(SyncedFolderConfigurationPage), fa, new SuppressNavigationTransitionInfo()); } }
private async Task AcceptSelection() { if (_itemsToMove != null) { await Move(); } else { SyncedFoldersService service = new SyncedFoldersService(); var library = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures); foreach (var assocaition in service.GetAllSyncedFolders()) { if (WebDavNavigationService.CurrentItem.EntityId == assocaition.RemoteFolderFolderPath) { MessageDialog dialog = new MessageDialog(string.Format(App.ResourceLoader.GetString("SelectedFolderAlreadyInUseForSync"), WebDavNavigationService.CurrentItem.EntityId)); await dialog.ShowAsync(); return; } if (String.Equals(assocaition.LocalFolderPath, library.SaveFolder.Path, StringComparison.OrdinalIgnoreCase)) { MessageDialog dialog = new MessageDialog(string.Format(App.ResourceLoader.GetString("SelectedFolderAlreadyInUseForSync"), library.SaveFolder.Path)); await dialog.ShowAsync(); return; } } Configuration.IsBackgroundTaskEnabled = true; new BackgroundTaskConfiguration().Enabled = true; await service.AddFolderToSyncAsync(library.SaveFolder, WebDavNavigationService.CurrentItem, SyncDirection.UploadOnly); await NavigationService.NavigateAsync(typeof(SyncedFoldersPageView), WebDavNavigationService.CurrentItem, new SuppressNavigationTransitionInfo()); } }