public void Fill(SolutionBrowserForm parent, string projectType, string objectName,
                         ProjectItem defaultPath = null)
        {
            ObjectName.Text = objectName;
            _parent         = parent;
            _defaultPath    = defaultPath;

            var enumerator = new ProjectEnumerator();

            foreach (var project in enumerator.Get(projectType))
            {
                var newNode = new TreeViewItem();
                newNode.Header = project.Name;
                newNode.Tag    = project;

                for (var i = 1; i <= project.ProjectItems.Count; i++)
                {
                    var expandParent = false;
                    var node         = AddChildren(project.ProjectItems.Item(i), out expandParent);

                    if (node != null)
                    {
                        newNode.Items.Add(node);
                        if (expandParent)
                        {
                            newNode.IsExpanded = true;
                            node.IsExpanded    = true;
                        }
                    }
                }

                Tree.Items.Add(newNode);
            }
        }
Ejemplo n.º 2
0
        public void PopulateTreeview()
        {
            Dispatcher.Invoke(ClearWindows);

            try
            {
                var projects = new ProjectEnumerator().Get(ProjectType.SSDT);

                var root = Dispatcher.Invoke(() => new TreeViewItem());

                foreach (var project in projects)
                {
                    var node = GetProjectNode(project);
                    Dispatcher.Invoke(() => root.Items.Add(node));
                }

                Dispatcher.Invoke(() =>
                {
                    root.Header = "Solution";
                    ProjectItems.Items.Add(root);
                });
            }
            catch (Exception e)
            {
                MessageBox.Show("Error populating tree view: " + e.Message);
            }
        }
        public static IVsHierarchy GetProject(this IVsSolution2 source, string projectName)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            SolutionWrapper   solution = new SolutionWrapper();
            ProjectEnumerator projects = new ProjectEnumerator(solution);

            return(projects.FindProject(projectName));
        }
Ejemplo n.º 4
0
        public SolutionParser(ProjectEnumerator projectEnumerator, DacParserBuilder dacParserBuilder, IStatus statusDisplay)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            statusDisplay.SetStatus("Finding Sql Projects...");
            var projects = projectEnumerator.EnumerateProjects();

            int count = 1;

            if (DebugLogging.Enable)
            {
                OutputWindowMessage.WriteMessage("Solution: Found {0} projects", projects.Count);
            }

            foreach (var project in projects)
            {
                statusDisplay.SetStatus(string.Format("Enumerating project {0} of {1} - project: {2}", count++, projects.Count, project.Name));

                if (!File.Exists(project.DacPath))
                {
                    if (DebugLogging.Enable)
                    {
                        OutputWindowMessage.WriteMessage("Solution: Did not find dacpac for project - path: {0}", project.DacPath);
                    }
                    continue;
                }

                var dac = dacParserBuilder.Build(project.DacPath);

                _projectList.Add(project.Name);
                _projects.Add(project.Name, new VsProject(project.PreDeployScriptPath, project.PostDeployScriptPath, dac.GetTableDefinitions(), project.Name, File.GetLastWriteTime(project.DacPath)));
            }

            stopwatch.Stop();
            statusDisplay.SetStatus(string.Format("Complete...Process took {0} seconds", stopwatch.ElapsedMilliseconds / 1000));

            if (DebugLogging.Enable)
            {
                OutputWindowMessage.WriteMessage("Solution: Enumerate Complete...Process took {0} seconds", stopwatch.ElapsedMilliseconds / 1000);
            }
        }
 public Enumerator(ProjectEnumerator enumerator)
 {
     _items = GetHierarchies(enumerator._solution);
     _index = -1;
 }
Ejemplo n.º 6
0
        private void ShowCodeMap(object sender, RoutedEventArgs e)
        {
            try
            {
                CodeMap.Items.Clear();

                var store = CodeCoverageStore.Get;

                var projects = new ProjectEnumerator().Get(ProjectType.SSDT);
                foreach (var p in projects)
                {
                    var newItem = new TreeViewItem();
                    //newItem.Header = p.Name;

                    var statements = new StatementEnumerator().GetStatements(p);
                    var fileMap    = new Dictionary <string, List <CodeStatement <TSqlStatement> > >();


                    foreach (var statement in statements)
                    {
                        if (!fileMap.ContainsKey(statement.FileName))
                        {
                            fileMap[statement.FileName] = new List <CodeStatement <TSqlStatement> >();
                        }

                        fileMap[statement.FileName].Add(statement);
                    }

                    double parentStatements        = 0;
                    double parentCoveredStatements = 0;

                    foreach (var file in fileMap.Keys.OrderBy(pp => pp))
                    {
                        var map = fileMap[file];

                        var    child                  = new TreeViewItem();
                        double childStatements        = 0;
                        double childCoveredStatements = 0;



                        foreach (var sqlModule in map.Where(o => o.Statement.GetType() == typeof(CreateProcedureStatement)))
                        {
                            var name = (sqlModule.Statement as CreateProcedureStatement)?.ProcedureReference.Name.ToNameString();
                            parentStatements = AddChildItems(name, sqlModule, store, parentStatements, file, child, ref parentCoveredStatements, ref childStatements, ref childCoveredStatements);
                            store.AddStatementFileMap(name, sqlModule.FileName);
                        }


                        foreach (var sqlModule in map.Where(o => o.Statement.GetType() == typeof(CreateFunctionStatement)))
                        {
                            var name = (sqlModule.Statement as CreateFunctionStatement)?.Name.ToNameString();
                            parentStatements = AddChildItems(name, sqlModule, store, parentStatements, file, child, ref parentCoveredStatements, ref childStatements, ref childCoveredStatements);
                            store.AddStatementFileMap(name, sqlModule.FileName);
                        }


                        var childCoveragePercent = ((double)childCoveredStatements / (double)childStatements) * 100;
                        var childLabel           = new LabelWithProgressIndicator(string.Format("{0} - {1}% ({2} / {3})", new FileInfo(file).Name, childCoveragePercent, childCoveredStatements, childStatements), childCoveragePercent, file);
                        childLabel.Configure();
                        child.Header = childLabel;


                        if (child.Items.Count > 0)
                        {
                            newItem.Items.Add(child);
                        }
                    }

                    var parentLabel = new LabelWithProgressIndicator(string.Format("{0} - ({1} / {2})", p.Name, parentCoveredStatements, parentStatements), (parentCoveredStatements / parentStatements) * 100.0);
                    parentLabel.Configure();
                    newItem.Header = parentLabel;

                    CodeMap.Items.Add(newItem);
                }
            }
            catch (Exception ex)
            {
                OutputPane.WriteMessageAndActivatePane("SSDTDevPack: Exception calling ShowCodeMap: {0}", ex);
            }
        }