private void SetSuperSolutions(IOrganizationService service, List <Setting> settings) { //TODO: set array of valid types = [1, 2, 3, 4, 5, 20, 21, etc...] List <string> solutionUniqueNames = new List <string>(); List <Solution> solutions = new List <Solution>(); this.ComponentTypesSolutionMapping = new Dictionary <string, string>(); for (int i = 1; i < 999; i++) { if (i != WebResourceType) { var settingForThisComponent = settings.FirstOrDefault(k => k.Key == string.Format(FormatSuperSolutionSettingKeyName, i)); if (settingForThisComponent != null) { var value = settingForThisComponent.Value; if (!this.ComponentTypesSolutionMapping.ContainsKey(i.ToString())) { this.ComponentTypesSolutionMapping.Add(i.ToString(), value); } if (solutionUniqueNames.IndexOf(value) < 0) { solutionUniqueNames.Add(settingForThisComponent.Value); } } } else { for (int j = 1; j < 12; j++) //Different types of webresources { var settingForThisComponent = settings.FirstOrDefault(k => k.Key == string.Format(FormatWebResourceSuperSolutionSettingKeyName, i, j)); if (settingForThisComponent != null) { var value = settingForThisComponent.Value; if (!this.ComponentTypesSolutionMapping.ContainsKey($"{i}_{j}")) { this.ComponentTypesSolutionMapping.Add($"{i}_{j}", value); } if (solutionUniqueNames.IndexOf(value) < 0) { solutionUniqueNames.Add(settingForThisComponent.Value); } } } } } foreach (var solutionUniqueName in solutionUniqueNames) { solutions.Add(CurrentSolutionManager.GetSolution(solutionUniqueName)); } this.SuperSolutions = solutions; if (this.SuperSolutions.Count > 0) { SelectedSuperSolution = this.SuperSolutions[0]; } }
private void CleanAndMergeSourceSolutions(List <Solution> affectedSuperSolutions, Dictionary <string, string> mappings) { foreach (var item in affectedSuperSolutions) { UpdateDialogMessage($"Cleaning source solution {item.UniqueName}..."); CurrentSolutionManager.CleanSolution(item.Id); UpdateDialogMessage($"Merging new result in source solution {item.UniqueName}..."); var sourceKey = item.UniqueName; var backupKey = mappings[sourceKey]; var backupSolution = CurrentSolutionManager.GetSolution(backupKey); var componentsInBackupSolution = CurrentSolutionManager.GetSolutionComponents(backupSolution.Id, false); UpdateDialogMessage($"Calculating new components for {item.UniqueName}..."); var componentsForThisSolution = GetSolutionComponentsForSolution(item).Cast <SolutionComponentBase>().ToList(); var allComponents = new List <SolutionComponentBase>(); allComponents.AddRange(componentsInBackupSolution); allComponents.AddRange(componentsForThisSolution); var newSuperSolutionComponents = CurrentSolutionManager .GetMergedSolutionComponents(allComponents); UpdateDialogMessage($"Adding components to supersolution {item.UniqueName}..."); CurrentSolutionManager.CreateMergedSolution(item.Id, newSuperSolutionComponents); UpdateDialogMessage($"Increasing revision version of {item.UniqueName}..."); CurrentSolutionManager.IncreaseSolutionRevisionVersion(item.Id); item.Version = CurrentSolutionManager.GetSolutionVersion(item.Id); } }
private void CheckDependencies() { SetDialog("Checking dependencies..."); ThreadManager.Instance.ScheduleTask(() => { var isError = false; var errorMessage = string.Empty; //var clonedSolutionId = Guid.Empty; try { SetDialog("Connecting to destination environment..."); var stringConnection = DestinationCrmConnection.GetStringConnetion(); var solution = CurrentSolutionManager.GetSolution(WorkSolution.SolutionId); DestinationService = CrmDataProvider.GetService(stringConnection); DestinationSolutionManager = new SolutionManager(DestinationService); var path = Path.GetTempPath(); SetDialog("Downloading solution..."); var filePath = $@"{path}{solution.UniqueName}.zip"; CurrentSolutionManager.ExportSolution(solution.UniqueName, filePath, true); SetDialog("Importing solution in destionation environment..."); DestinationSolutionManager.ImportSolution(filePath, false, false, false); SetDialog("Removing solution from destination environment..."); DestinationSolutionManager.RemoveSolution(solution.UniqueName); CurrentSolutionManager.SetDependenciesOKForWorkSolution(WorkSolution.Id); } catch (Exception ex) { isError = true; errorMessage = ex.Message; } System.Windows.Application.Current.Dispatcher.Invoke(() => { if (isError) { CurrentSolutionManager.SetDependenciesKOForWorkSolution(WorkSolution.Id, errorMessage); MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { //this.ClonedSolutionId = clonedSolutionId; _window.Close(); } UnsetDialog(); }); }, "Cloning solution...", _checkDependenciesTaskId); }