private async void DiscoverResourcesAsync() { _discoverResourcesCommand.SetCanExecute(false); try { var serverResources = await _serverSettingsViewModel.GetServerResources(_networkSettingsViewModel, _generalOptions); var calendars = serverResources.Calendars.Select(c => new CalendarDataViewModel(c)).ToArray(); var addressBooks = serverResources.AddressBooks.Select(a => new AddressBookDataViewModel(a)).ToArray(); var taskLists = serverResources.TaskLists.Select(d => new TaskListDataViewModel(d)).ToArray(); using (var selectResourcesForm = new SelectResourceForm(ConnectionTests.ResourceType.Calendar, _session, calendars, addressBooks, taskLists)) { if (selectResourcesForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { List <Contracts.Options> optionList = new List <Contracts.Options>(); foreach (var resource in calendars.Where(c => c.SelectedFolder != null)) { var options = CreateOptions(resource); _serverSettingsViewModel.FillOptions(options, resource.Model); optionList.Add(options); } foreach (var resource in addressBooks.Where(c => c.SelectedFolder != null)) { var options = CreateOptions(resource); _serverSettingsViewModel.FillOptions(options, resource.Model); optionList.Add(options); } foreach (var resource in taskLists.Where(c => c.SelectedFolder != null)) { var options = CreateOptions(resource); _serverSettingsViewModel.FillOptions(options, resource.Model); optionList.Add(options); } _parent.RequestAdd(optionList); _parent.RequestRemoval(this); } } } catch (Exception x) { s_logger.Error("Exception while DiscoverResourcesAsync.", x); string message = null; for (Exception ex = x; ex != null; ex = ex.InnerException) { message += ex.Message + Environment.NewLine; } MessageBox.Show(message, OptionTasks.ConnectionTestCaption); } finally { _discoverResourcesCommand.SetCanExecute(true); } }
private async void MergeResourcesAsync() { _mergeResourcesCommand.SetCanExecute(false); try { var serverResources = await _serverSettingsViewModel.GetServerResources(); var calendars = serverResources.Calendars.Select(c => new CalendarDataViewModel(c)).ToArray(); var optionList = new List <OptionsModel>(); foreach (var resource in calendars) { resource.SelectedFolder = _selectedFolder; var options = CreateOptionsWithCategory(resource); _serverSettingsViewModel.SetResourceUrl(options, resource.Model); optionList.Add(options); } _parent.RequestAdd(optionList); _parent.RequestRemoval(this); } catch (Exception x) { s_logger.Error("Exception while MergeResourcesAsync.", x); string message = null; for (Exception ex = x; ex != null; ex = ex.InnerException) { message += ex.Message + Environment.NewLine; } MessageBox.Show(message, OptionTasks.ConnectionTestCaption); } finally { _mergeResourcesCommand.SetCanExecute(true); } }