/// <summary>Defines the method to be called when the command is invoked.</summary> /// <param name="parameter">Data used by the command. If the command does not require data to be passed, this object can be set to null.</param> public void Execute(object parameter) { var oldBuildAdapters = mainWindowViewModel.BuildAdapters.ToList(); MonitorSettingsContainer.BuildServers.Clear(); mainWindowViewModel.BuildAdapters.Clear(); foreach (var buildServerAdapter in settingsViewModel.BuildServers) { var buildServer = new BuildServer { ServerName = buildServerAdapter.ServerName, DomainName = buildServerAdapter.Domain, Login = buildServerAdapter.Login, PasswordBytes = buildServerAdapter.CryptedPassword, Url = buildServerAdapter.TfsUrl, DetailBuildUrl = buildServerAdapter.DetailBuildUrl, TfsVersion = buildServerAdapter.TfsVersion }; MonitorSettingsContainer.BuildServers.Add(buildServer); foreach (var buildDefinitionResult in buildServerAdapter.BuildDefinitionResults.Where(x => x.Selected)) { var buildDefinition = new BuildDefinition { Id = buildDefinitionResult.Id, Name = buildDefinitionResult.Name, Uri = buildDefinitionResult.Uri, Url = buildDefinitionResult.Url, ProjectId = buildDefinitionResult.ProjectId }; var existingAdapter = oldBuildAdapters.FirstOrDefault(x => x.BuildInformation.BuildDefinitionId == buildDefinition.Id); if (existingAdapter != null) { buildDefinition.Tags = existingAdapter.Tags.ToArray(); } buildServer.BuildDefinitions.Add(buildDefinition); } foreach (var build in buildServer.GetBuilds()) { mainWindowViewModel.BuildAdapters.Add(new BuildAdapter(mainWindowViewModel, build, false)); } } mainWindowViewModel.Refresh(); MonitorSettingsContainer.SaveBuildServers(); settingsView.Close(); }