private List <ConnectionGroup> Load() { var newRepo = new NewRepositoryReader(_knownConnections); try { newRepo.LoadProfiles("profiles.json"); } catch (Exception ex) { MessageBox.Show($"Ошибка загрузки {ProfilesFile}: {ex.Message}", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } var groups = TryLoadOldRepo(); if (groups != null) { newRepo.SaveProfiles(ProfilesFile, _knownConnections._knownConnectionProfiles); newRepo.Save(ConnectionsFile, groups); } else { try { groups = newRepo.Load(ConnectionsFile); } catch (Exception ex) { MessageBox.Show($"Ошибка загрузки {ConnectionsFile}: {ex.Message}", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } } return(groups); }
private void SaveProject() { var groups = ConnectionGroupViewModels.Select(vm => vm.Source).ToList(); var repoReader = new NewRepositoryReader(_knownConnections); repoReader.Save(ConnectionsFile, groups); repoReader.SaveProfiles(ProfilesFile, _knownConnections._knownConnectionProfiles); }