示例#1
0
        private void ReloadSolutionComponentFromAggregatedSolution(AggregatedSolution aggregatedSolution)
        {
            SetDialog("Retrieving components...");
            ThreadManager.Instance.ScheduleTask(() =>
            {
                var isError      = false;
                var errorMessage = string.Empty;

                List <MergedInSolutionComponent> mergedSolutionComponents = new List <MergedInSolutionComponent>();
                var workSolutions = new List <WorkSolution>();
                try
                {
                    workSolutions            = CurrentSolutionManager.GetWorkSolutions(aggregatedSolution);
                    mergedSolutionComponents = CurrentSolutionManager.GetMergedSolutionComponents(workSolutions, true);
                }
                catch (Exception ex)
                {
                    isError      = true;
                    errorMessage = ex.Message;
                }
                System.Windows.Application.Current.Dispatcher.Invoke(() =>
                {
                    if (isError)
                    {
                        MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        WorkSolutions      = workSolutions;
                        SolutionComponents = mergedSolutionComponents;
                    }
                    UnsetDialog();
                });
            }, "Retrieving components...", _reloadComponentsTaskId);
        }
示例#2
0
        private void PrepareAggregatedSolution(List <Setting> settings, AggregatedSolution aggregatedSolution)
        {
            var aggregatedSolutionName = SettingsManager.GetSetting <string>(settings, AggregatedSolutionNameKey, AggregatedSolutionDefaultName);
            var defaultPublisherIdStr  = SettingsManager.GetSetting <string>(settings, DefaultPublisherSettingKey, string.Empty);

            if (string.IsNullOrEmpty(defaultPublisherIdStr))
            {
                throw new Exception($"Cannot find {DefaultPublisherSettingKey} as a Setting");
            }
            if (!Guid.TryParse(defaultPublisherIdStr, out Guid defaultPublisherId))
            {
                throw new Exception($"Found setting {DefaultPublisherSettingKey} is not a valid Guid");
            }
            var publisherName = GetPublisherName(defaultPublisherId);

            SelectedPublisher = new EntityReference()
            {
                Id          = defaultPublisherId,
                Name        = publisherName,
                LogicalName = PublisherLogicalName,
            };
            ReloadSolutionComponentFromAggregatedSolution(aggregatedSolution);


            var uniqueName = StringFormatter.FormatString(aggregatedSolution.Name);

            this.NewDisplayName = string.Format("AGGR - {0} - {1}", aggregatedSolution.Type.ToString(), aggregatedSolution.Name);
            this.UniqueName     = string.Format(aggregatedSolutionName, aggregatedSolution.Type.ToString(), uniqueName);
            if (this.UniqueName.Length > 50)
            {
                this.UniqueName = this.UniqueName.Substring(0, 50);
            }
        }
示例#3
0
        public void Initialize(
            Window window,
            IOrganizationService service,
            CrmConnection crmConnection,
            SolutionManager solutionManager,
            List <Setting> settings,
            List <MergedInSolutionComponent> solutionComponents,
            AggregatedSolution aggregatedSolution)
        {
            this._window                = window;
            this.SolutionComponents     = solutionComponents;
            this.Service                = service;
            this.CurrentCrmConnection   = crmConnection;
            this.CurrentSolutionManager = solutionManager;
            SetSuperSolutions(service, settings);
            this.Settings    = settings;
            IsAggregatedMode = false;
            this.BlobService = new BlobStorageService(settings);
            if (aggregatedSolution != null)
            {
                IsAggregatedMode = true;
                //PrepareAggregatedSolution(settings, aggregatedSolution);
            }

            RegisterCommands();
        }
示例#4
0
 public WorkSolutionManager(
     IOrganizationService service,
     CrmConnection currentCrmConnection,
     SolutionManager solutionManager,
     List <Setting> settings,
     AggregatedSolution aggregated)
 {
     InitializeComponent();
     this._viewModel = LayoutRoot.Resources["viewModel"] as WorkSolutionManagerViewModel;
     _viewModel.Initialize(this, service, currentCrmConnection, solutionManager, settings, aggregated);
 }
示例#5
0
 public void Initialize(
     Window window,
     IOrganizationService service,
     CrmConnection crmConnection,
     SolutionManager solutionManager,
     List <Setting> settings,
     AggregatedSolution aggregated)
 {
     this._window = window;
     this.CurrentSolutionManager = solutionManager;
     this.AggregatedSolution     = aggregated;
     this.WorkSolutions          = this.CurrentSolutionManager.GetAllWorkSolutions();
     RegisterCommands();
 }
示例#6
0
 public MergeSolutionsManager(
     IOrganizationService service,
     CrmConnection currentCrmConnection,
     SolutionManager solutionManager,
     List <Setting> settings,
     List <Solution> selectedSolutions,
     List <Solution> allSolutions,
     List <MergedInSolutionComponent> solutionComponents,
     AggregatedSolution aggregatedSolution)
 {
     InitializeComponent();
     this._viewModel = LayoutRoot.Resources["viewModel"] as MergeSolutionsManagerViewModel;
     _viewModel.Initialize(this, service, currentCrmConnection, solutionManager, settings, selectedSolutions, allSolutions, solutionComponents, aggregatedSolution);
 }
示例#7
0
        public static AggregatedSolution ToAgreatedSolution(this Entity e)
        {
            if (e.LogicalName != AggregatedSolution.EntityLogicalName)
            {
                throw new InvalidCastException();
            }
            AggregatedSolution s = new AggregatedSolution();

            s.Id         = e.GetParameter <Guid>(AggregatedSolution.AttributeDefinitions.Id);
            s.CreatedOn  = e.GetParameter <DateTime>(AggregatedSolution.AttributeDefinitions.CreatedOn);
            s.ModifiedOn = e.GetParameter <DateTime>(AggregatedSolution.AttributeDefinitions.ModifiedOn);
            s.CreatedBy  = e.GetParameter <EntityReference>(AggregatedSolution.AttributeDefinitions.CreatedBy);
            s.Status     = (AggregatedSolution.AggregatedSolutionStatus)
                           e.GetParameter <OptionSetValue>(AggregatedSolution.AttributeDefinitions.Status).Value;
            s.Name = e.GetParameter <string>(AggregatedSolution.AttributeDefinitions.Name);
            s.Type = (AggregatedSolution.AggregatedSolutionType)
                     e.GetParameter <OptionSetValue>(AggregatedSolution.AttributeDefinitions.Type).Value;

            s.IsMergedWithSupersolution = e.GetParameter <bool>(AggregatedSolution.AttributeDefinitions.IsMergedWithSupersolution);
            return(s);
        }
示例#8
0
        public void Initialize(
            Window window,
            IOrganizationService service,
            CrmConnection crmConnection,
            SolutionManager solutionManager,
            List <Setting> settings,
            List <Solution> selectedSolutions,
            List <Solution> allSolutions,
            List <MergedInSolutionComponent> solutionComponents,
            AggregatedSolution aggregatedSolution)
        {
            this._window                = window;
            this.SolutionComponents     = solutionComponents;
            this.Service                = service;
            this.SourceSolutions        = allSolutions;
            this.CurrentCrmConnection   = crmConnection;
            this.CurrentSolutionManager = solutionManager;
            this.MergedSolution         = null;

            if (selectedSolutions != null && selectedSolutions.Count > 0)
            {
                this.Publishers = selectedSolutions
                                  .GroupBy(k => k.Publisher.Id)
                                  .Select(group => group.First())
                                  .Select(k => { return(k.Publisher); }).ToList();
                if (this.Publishers.Count > 0)
                {
                    this.SelectedPublisher = this.Publishers[0];
                }
            }
            IsAggregatedMode = false;
            if (aggregatedSolution != null)
            {
                IsAggregatedMode = true;
                PrepareAggregatedSolution(settings, aggregatedSolution);
                CurrentAggregatedSolution = aggregatedSolution;
            }

            RegisterCommands();
        }
示例#9
0
 public List <WorkSolution> GetWorkSolutions(AggregatedSolution aggregatedSolution)
 {
     return(GetWorkSolutions(aggregatedSolution.Id));
 }
示例#10
0
        public void CheckAggregatedSolution(AggregatedSolution aggregatedSolution)
        {
            var workSolutions     = GetWorkSolutions(aggregatedSolution);
            var openWorkSolutions = workSolutions.Where(k => k.Status != WorkSolution.WorkSolutionStatus.ReadyToInt);

            if (openWorkSolutions.ToList().Count > 0)
            {
                var openSolutions = string.Join(", ", openWorkSolutions.Select(k => { return(k.Name); }).ToList());
                throw new Exception($"Selected aggregated solution contains open work solutions:\r\n{openSolutions}");
            }


            var allOpenSolutions = GetAllOpenWorkSolutions();

            Dictionary <string, List <MergedInSolutionComponent> > componentsInWorkSolutions = new Dictionary <string, List <MergedInSolutionComponent> >();
            Dictionary <string, List <MergedInSolutionComponent> > componentsInOpenSolutions = new Dictionary <string, List <MergedInSolutionComponent> >();

            foreach (var item in workSolutions)
            {
                componentsInWorkSolutions.Add($"{item.Name} - {item.Jira}", GetMergedSolutionComponents(new List <Guid>()
                {
                    item.SolutionId
                }));
            }

            foreach (var item in allOpenSolutions)
            {
                componentsInOpenSolutions.Add($"{item.Name} - {item.Jira}", GetMergedSolutionComponents(new List <Guid>()
                {
                    item.SolutionId
                }));
            }


            var allWorkComponents = new List <MergedInSolutionComponent>();

            foreach (var item in componentsInWorkSolutions)
            {
                allWorkComponents.AddRange(item.Value);
            }

            var allOpenComponents = new List <MergedInSolutionComponent>();

            foreach (var item in componentsInOpenSolutions)
            {
                allOpenComponents.AddRange(item.Value);
            }

            var mixedComponents =
                allOpenComponents
                .Select(k => k.ObjectId)
                .Intersect(
                    allWorkComponents
                    .Select(k => k.ObjectId))
                .GroupBy(k => k)
                .ToList();



            if (mixedComponents.Count > 0)
            {
                StringBuilder st = new StringBuilder();
                foreach (var mixedComponent in mixedComponents)
                {
                    var component           = allOpenComponents.FirstOrDefault(k => k.ObjectId == mixedComponent.Key);
                    var componentDefinition = GetComponentWithDefinition(component.Id);

                    st.AppendLine($"#### Component {componentDefinition.DisplayName} ({componentDefinition.TypeString}) ####");
                    st.AppendLine($"Found in Ready2Int solutions:");
                    foreach (var item in componentsInWorkSolutions)
                    {
                        var components = item.Value;
                        if (components.Where(k => k.ObjectId == component.ObjectId).Count() > 0)
                        {
                            st.AppendLine($"\t- {item.Key}");
                        }
                    }

                    st.AppendLine($"Found in Development solutions:");
                    foreach (var item in componentsInOpenSolutions)
                    {
                        var components = item.Value;
                        if (components.Where(k => k.ObjectId == component.ObjectId).Count() > 0)
                        {
                            st.AppendLine($"\t- {item.Key}");
                        }
                    }
                    st.AppendLine();
                }

                throw new Exception(st.ToString());
            }
        }