Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        public List <CodeStatement <TSqlStatement> > GetStatements(Project project = null)
        {
            if (project != null)
            {
                return(GetCodeTSqlStatements(project));
            }

            var statements = new List <CodeStatement <TSqlStatement> >();
            var enumerator = new ProjectEnumerator();

            foreach (var p in enumerator.Get(ProjectType.SSDT))
            {
                statements.AddRange(GetCodeTSqlStatements(p));
            }

            return(statements);
        }
        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);
            }
        }