Beispiel #1
0
        private async Task LoadSolutionDifferenceImage(string filePath)
        {
            if (!this.IsControlsEnabled)
            {
                return;
            }

            this.Dispatcher.Invoke(() =>
            {
                this._itemsSource.Clear();

                txtBFilePath.Text = string.Empty;
            });

            if (string.IsNullOrEmpty(filePath))
            {
                return;
            }

            if (!File.Exists(filePath))
            {
                return;
            }

            ToggleControls(null, false, Properties.OutputStrings.LoadingSolutionDifferenceImage);

            try
            {
                this._SolutionDifferenceImage = await SolutionDifferenceImage.LoadAsync(filePath);
            }
            catch (Exception ex)
            {
                DTEHelper.WriteExceptionToOutput(null, ex);

                this._SolutionDifferenceImage = null;
            }

            txtBFilePath.Dispatcher.Invoke(() =>
            {
                if (this._SolutionDifferenceImage != null)
                {
                    txtBFilePath.Text = filePath;
                }
                else
                {
                    txtBFilePath.Text = string.Empty;
                }
            });

            if (this._SolutionDifferenceImage == null)
            {
                ToggleControls(null, true, Properties.OutputStrings.LoadingSolutionDifferenceImageFailed);
                return;
            }

            ToggleControls(null, true, Properties.OutputStrings.LoadingSolutionDifferenceImageCompleted);

            FilteringSolutionDifferenceImageComponents();
        }
Beispiel #2
0
        private async Task CreateFileWithUniqueComponentsInSolution1(
            string filePath
            , Guid idSolution1
            , Guid idSolution2
            )
        {
            try
            {
                SolutionRepository repositorySolution = new SolutionRepository(_service);

                var solution1 = await repositorySolution.GetSolutionByIdAsync(idSolution1);

                var solution2 = await repositorySolution.GetSolutionByIdAsync(idSolution2);

                SolutionComponentRepository repository = new SolutionComponentRepository(_service);

                var components1 = await repository.GetSolutionComponentsAsync(solution1.Id, new ColumnSet(SolutionComponent.Schema.Attributes.componenttype, SolutionComponent.Schema.Attributes.objectid, SolutionComponent.Schema.Attributes.rootcomponentbehavior));

                var components2 = await repository.GetSolutionComponentsAsync(solution2.Id, new ColumnSet(SolutionComponent.Schema.Attributes.componenttype, SolutionComponent.Schema.Attributes.objectid, SolutionComponent.Schema.Attributes.rootcomponentbehavior));

                var componentsOnlyIn1 = GetComponentsInFirstNotSecond(components1, components2);
                var componentsOnlyIn2 = GetComponentsInFirstNotSecond(components2, components1);

                await CreateFileWithComponentsInSolution1(filePath, solution1.UniqueName, solution2.UniqueName, components1.Count, components2.Count, componentsOnlyIn1, componentsOnlyIn2.Count);

                var commonComponents = GetCommonComponents(components1, components2);

                List <SolutionImageComponent> imageCommonComponents = await _descriptor.GetSolutionImageComponentsListAsync(commonComponents);

                List <SolutionImageComponent> imageComponentsOnlyIn1 = await _descriptor.GetSolutionImageComponentsListAsync(componentsOnlyIn1);

                List <SolutionImageComponent> imageComponentsOnlyIn2 = await _descriptor.GetSolutionImageComponentsListAsync(componentsOnlyIn2);

                SolutionDifferenceImage image = new SolutionDifferenceImage()
                {
                    Solution1Name = solution1.UniqueName,
                    Solution2Name = solution2.UniqueName,

                    ConnectionName = _service.ConnectionData.Name,

                    ConnectionOrganizationName    = _service.ConnectionData.UniqueOrgName,
                    ConnectionDiscoveryService    = _service.ConnectionData.DiscoveryUrl,
                    ConnectionOrganizationService = _service.ConnectionData.OrganizationUrl,
                    ConnectionPublicUrl           = _service.ConnectionData.PublicUrl,

                    MachineName           = Environment.MachineName,
                    ExecuteUserDomainName = Environment.UserDomainName,
                    ExecuteUserName       = Environment.UserName,

                    ConnectionSystemUserName = _service.ConnectionData.GetUsername,

                    CreatedOn = DateTime.Now,
                };

                foreach (var item in imageCommonComponents)
                {
                    if (!image.CommonComponents.Contains(item))
                    {
                        image.CommonComponents.Add(item);
                    }
                }

                foreach (var item in imageComponentsOnlyIn1)
                {
                    if (!image.OnlySolution1Components.Contains(item))
                    {
                        image.OnlySolution1Components.Add(item);
                    }
                }

                foreach (var item in imageComponentsOnlyIn2)
                {
                    if (!image.OnlySolution2Components.Contains(item))
                    {
                        image.OnlySolution2Components.Add(item);
                    }
                }

                await image.SaveAsync(filePath + ".xml");
            }
            catch (Exception ex)
            {
                this._iWriteToOutput.WriteErrorToOutput(_service.ConnectionData, ex);
            }
        }