Exemplo n.º 1
0
        private static void Collapse(UIHierarchyItem item, ref UIHierarchy solutionExplorer)
        {
            foreach (UIHierarchyItem innerItem in item.UIHierarchyItems)
            {
                if (innerItem.UIHierarchyItems.Count > 0)
                {

                    // Re-cursive call
                    Collapse(innerItem, ref solutionExplorer);

                    // Collapse
                    if (innerItem.UIHierarchyItems.Expanded)
                    {
                        innerItem.UIHierarchyItems.Expanded = false;
                        if (innerItem.UIHierarchyItems.Expanded == true)
                        {
                            // Bug in VS 2005
                            innerItem.Select(vsUISelectionType.vsUISelectionTypeSelect);
                            solutionExplorer.DoDefaultAction();
                        }

                    }
                }

            }
        }
 public static void SelectProject(UIHierarchy tree, Project CoreRecipes)
 {
   foreach (UIHierarchyItem subnode in tree.UIHierarchyItems)
   {
     SelectProject(subnode, CoreRecipes);
   }
 }
 public void SelectProject(UIHierarchy tree, Project CoreRecipes)
 {
   foreach (UIHierarchyItem subnode in tree.UIHierarchyItems)
   {
     subnode.UIHierarchyItems.Expanded = true;
     SelectProject(subnode, CoreRecipes);
   }
 }
Exemplo n.º 4
0
 public void CanFindHierarchyTest()
 {
     ConfigurationDesignHost host = new ConfigurationDesignHost();
     UIHierarchyService hierarchyService = host.GetService(typeof(IUIHierarchyService)) as UIHierarchyService;
     Assert.IsNotNull(hierarchyService);
     ApplicationConfigurationNode appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
     UIHierarchy hierarchy = new UIHierarchy(appNode, host, new ConfigurationContext(appNode.ConfigurationFile));
     ConfigurationSectionCollectionNode node = new ConfigurationSectionCollectionNode();
     appNode.Nodes.Add(node);
     node.Nodes.Add(new ConfigurationSectionNode());
     hierarchyService.AddHierarchy(hierarchy);
     IUIHierarchy foundHierarchy = hierarchyService.GetHierarchy(appNode.Id);
     Assert.AreSame(hierarchy, foundHierarchy);
 }
        private void ExpandCollapseNodes(UIHierarchyItem node, bool expanded, UIHierarchy tree)
        {
            foreach(UIHierarchyItem subNode in node.UIHierarchyItems)
              {
            ExpandCollapseNodes(subNode, expanded, tree);
              }

              if (node.Object is SolutionFolder)
              {
            node.UIHierarchyItems.Expanded = true;
              }
              else if (node.Object is Solution)
              {
            node.UIHierarchyItems.Expanded = true;
              }
              else if (node.Object is Project)
              {
            if (((Project)node.Object).Object is SolutionFolder)
            {
              //are there projects in the solution folder
              SolutionFolder f = ((Project)node.Object).Object as SolutionFolder;
              bool expandit = false;
              foreach (ProjectItem pi in f.Parent.ProjectItems)
              {
                if (pi.Object is Project)
                {
                  //solutionfolder contains a child project, dont close
                  expandit = true;
                }
              }
              node.UIHierarchyItems.Expanded = expandit;
            }
            else
            {
              node.UIHierarchyItems.Expanded = false;
            }
              }
              else
              {
            node.UIHierarchyItems.Expanded = false;
            //bug in VS
            //if still expanded
            if (node.UIHierarchyItems.Expanded == true)
            {
              node.Select(vsUISelectionType.vsUISelectionTypeSelect);
              tree.DoDefaultAction();
            }
              }
        }
        private CopyAsPathCommand(CopyAsPathCommandPackage package, UIHierarchy solutionExplorer)
        {
            Requires.NotNull(package, nameof(package));
            Requires.NotNull(solutionExplorer, nameof(solutionExplorer));
            this.package = package;
            this.solutionExplorer = solutionExplorer;

            OleMenuCommandService commandService = package.QueryService<IMenuCommandService>() as OleMenuCommandService;
            if (commandService != null)
            {
                var menuCommandID = new CommandID(CommandSet, CommandId);
                var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandID);
                commandService.AddCommand(menuItem);
            }
        }
Exemplo n.º 7
0
 public void AddHierarchyAndEventFiredTest()
 {
     ConfigurationDesignHost host = new ConfigurationDesignHost();
     UIHierarchyService hierarchyService = host.GetService(typeof(IUIHierarchyService)) as UIHierarchyService;
     hierarchyService.HierarchyAdded += new HierarchyAddedEventHandler(OnHierarchyAdded);
     Assert.IsNotNull(hierarchyService);
     ApplicationConfigurationNode appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
     IUIHierarchy hierarchy = new UIHierarchy(appNode, host, new ConfigurationContext(appNode.ConfigurationFile));
     hierarchyService.AddHierarchy(hierarchy);
     Assert.IsTrue(addEventCalled);
     Assert.AreEqual(1, addEventCount);
     Assert.AreSame(hierarchy, eventHierarchy);
     ConfigurationSectionCollectionNode node = new ConfigurationSectionCollectionNode();
     appNode.Nodes.Add(node);
     node.Nodes.Add(new ConfigurationSectionNode());
     Assert.AreEqual(1, hierarchyService.hierarchies.Count);
 }
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            try
            {
                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                if (((System.Array)solExplorer.SelectedItems).Length != 1)
                {
                    return(false);
                }

                UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                Project         p        = GetSelectedProjectReference();

                SolutionClass solution = hierItem.Object as SolutionClass;
                if (p != null)
                {
                    Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)p;
                    return(projExt.Kind == BIDSProjectKinds.SSRS);
                }
                else if (solution != null)
                {
                    foreach (Project pp in solution.Projects)
                    {
                        Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)p;
                        if (projExt.Kind == BIDSProjectKinds.SSRS)
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            }
            catch
            {
                return(false);
            }
        }
        /// <summary>
        /// 折叠全部项目
        /// </summary>
        /// <param name="sln">解决方案COM</param>
        public static void CollapseAllProject(this Solution sln)
        {
            UIHierarchy rootNode = (sln.DTE as DTE2).ToolWindows.SolutionExplorer;

            List <UIHierarchyItem> itemNodes = GetProjectNodes(sln);

            if (itemNodes != null && itemNodes.Count > 0)
            {
                for (int i = 0; i < itemNodes.Count; i++)
                {
                    Project proj = itemNodes[i].Object as Project;
                    //项目为非顶级项目
                    if (proj == null)
                    {
                        ProjectItem projItem = itemNodes[i].Object as ProjectItem;
                        if (projItem != null && itemNodes[i].UIHierarchyItems.Expanded)
                        {
                            itemNodes[i].Select(vsUISelectionType.vsUISelectionTypeSelect);
                            rootNode.DoDefaultAction();
                        }
                    }
                    else
                    {
                        //项目为顶级项目
                        itemNodes[i].UIHierarchyItems.Expanded = false;
                    }
                }
            }
            //折叠顶级项目
            string           solutionName = sln.Properties.Item("Name").Value.ToString();
            UIHierarchyItems items        = rootNode.GetItem(solutionName).UIHierarchyItems;

            foreach (UIHierarchyItem topItem in items)
            {
                topItem.UIHierarchyItems.Expanded = false;
            }
        }
Exemplo n.º 10
0
        public static IEnumerable <string> SelectedItemPaths(this UIHierarchy solutionExplorer)
        {
            var items = (Array)solutionExplorer.SelectedItems;

            foreach (UIHierarchyItem selItem in items)
            {
                var item     = selItem.Object as ProjectItem;
                var project  = selItem.Object as Project;
                var solution = selItem.Object as Solution;

                if (item != null && item.Properties != null)
                {
                    yield return(item.Properties.Item("FullPath").Value.ToString());
                }
                else if (project != null && project.Kind != ProjectKinds.vsProjectKindSolutionFolder)
                {
                    yield return(project.RootFolderName());
                }
                else if (solution != null && !string.IsNullOrEmpty(solution.FullName))
                {
                    yield return(Path.GetDirectoryName(solution.FullName));
                }
            }
        }
Exemplo n.º 11
0
        private string GetFileNameWithOutExt()
        {
            UIHierarchy uiHierarchy = (UIHierarchy)_applicationObject.Windows.Item(Constants.vsWindowKindSolutionExplorer).Object;

            foreach (UIHierarchyItem item in (Array)uiHierarchy.SelectedItems)
            {
                if (item.Object is ProjectItem)
                {
                    ProjectItem File    = item.Object as ProjectItem;
                    string      FileExt = File.Name.Substring(File.Name.LastIndexOf('.'));
                    if (FileExt.Equals(".feature"))
                    {
                        string[] FileName = File.Name.Split('.');
                        return(FileName[0]);
                    }
                    else
                    {
                        return(string.Empty);
                    }
                }
                return(string.Empty);
            }
            return(string.Empty);
        }
Exemplo n.º 12
0
        private Project GetSelectedProject()
        {
            Project         project      = null;
            UIHierarchyItem selectedItem = null;
            UIHierarchy     se           = _dte.ToolWindows.SolutionExplorer;

            object[] items = se.SelectedItems as object[];

            if (items != null || items.Length > 0)
            {
                selectedItem = items[0] as UIHierarchyItem;
            }

            Debug.Assert(selectedItem != null && selectedItem.IsSelected);
            // 获取选中项
            ProjectItem projectItem = selectedItem.Object as ProjectItem;

            // 获取选中项所在的项目
            project = projectItem.ContainingProject;

            //Debug.Write("-------------------------华丽的分割线---------------------------");
            //for (int i = 1; i <= proj.Properties.Count; i++)
            //{
            //    Property p = proj.Properties.Item(i);
            //    try
            //    {
            //        Debug.WriteLine(p.Name + ", " + p.Value);
            //    }
            //    catch (Exception ex)
            //    {
            //        //Debug.Write(ex);
            //    }
            //}

            return(project);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            try
            {
                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                if (((System.Array)solExplorer.SelectedItems).Length != 1)
                {
                    return(false);
                }

                UIHierarchyItem hierItem  = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                string          sFileName = ((ProjectItem)hierItem.Object).Name.ToLower();
                if (sFileName.EndsWith(".bim"))
                {
                    return(true);
                }

                return(((ProjectItem)hierItem.Object).Object is Cube);
            }
            catch
            {
                return(false);
            }
        }
 /// <summary>
 /// Determines if the command should be displayed or not.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public override bool DisplayCommand(UIHierarchyItem item)
 {
     try
     {
         bool        bFoundRightItem = false;
         UIHierarchy solExplorer     = this.ApplicationObject.ToolWindows.SolutionExplorer;
         foreach (UIHierarchyItem hierItem in ((System.Array)solExplorer.SelectedItems))
         {
             if (hierItem.Name.ToLower().EndsWith(".cube")) //checking the file extension is adequate because this feature is not needed for in online mode (when live connected to the server)
             {
                 bFoundRightItem = true;
             }
             else
             {
                 return(false);
             }
         }
         return(bFoundRightItem);
     }
     catch
     {
         return(false);
     }
 }
        public override void Exec()
        {
            try
            {
                UIHierarchy     solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                UIHierarchyItem hierItem    = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                ProjectItem     projItem    = (ProjectItem)hierItem.Object;
                string          sFilePath   = projItem.get_FileNames(0);
                string          sFileName   = projItem.Name + BACKUP_FILE_SUFFIX;

                SSAS.Tabular.TabularAnnotationWorkaroundForm form = new SSAS.Tabular.TabularAnnotationWorkaroundForm(sFileName);
                DialogResult res = form.ShowDialog();

                if (res == DialogResult.OK)
                {
                    FixAnnotations(sFilePath);
                    MessageBox.Show("BIDS Helper annotation format changed successfully!", "BIDS Helper Annotation Workaround");
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
            }
        }
Exemplo n.º 16
0
        public override void Execute()
        {
            try
            {
                DTE dte = GetService <DTE>(true);

                //Helpers.LogMessage(dte, this, "Collapsing project tree");

                UIHierarchy tree     = null;
                Window2     explorer = null;

                explorer = dte.Windows.Item(Constants.vsWindowKindSolutionExplorer) as Window2;
                tree     = explorer.Object as UIHierarchy;

                foreach (UIHierarchyItem node in tree.UIHierarchyItems)
                {
                    ExpandCollapseNodes(node, false, tree);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private static UIHierarchyItem FindHierarchyItem(UIHierarchy hierarchy, object item)
        {
            // This gets children of the root note in the hierarchy
            UIHierarchyItems items = hierarchy.UIHierarchyItems.Item(1).UIHierarchyItems;

            // Finds the given item in the hierarchy
            UIHierarchyItem uiItem = FindHierarchyItem(items, item);

            // uiItem would be null in most cases, however, for projects inside Solution Folders, there is a strange behavior in which the project byitself can't
            // be found in the hierarchy. Instead, in case of failure we'll search for the UIHierarchyItem
            if (uiItem == null && item is Project && ((Project)item).ParentProjectItem != null)
                uiItem = FindHierarchyItem(items, ((Project)item).ParentProjectItem);

            return uiItem;
        }
Exemplo n.º 18
0
    public static UIHierarchyItem GetSelectedUIHierarchyItem(DTE2 applicationObject)
    {
        UIHierarchy uiHierarchy = applicationObject.ToolWindows.SolutionExplorer;

        return((UIHierarchyItem)((Array)uiHierarchy.SelectedItems).GetValue(0));
    }
        private void ExecInternal(bool bPreBuildCheckOnly)
        {
            try
            {
                UIHierarchy     solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                UIHierarchyItem hierItem    = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));

                cube = sandbox.Cube;
                if (cube == null)
                {
                    throw new Exception("The workspace database cube doesn't exist.");
                }

                SSAS.TabularDisplayFoldersAnnotation annotationSavedFolders = TabularDisplayFolderPlugin.GetAnnotation(sandbox);
                SSAS.TabularTranslationsAnnotation   annotationSaved        = GetAnnotation(sandbox);

                string sTargetDatabase = null;
                string sTargetCubeName = null;
                try
                {
                    //get the deployment settings to display in the translations dialog (rather than the workspace database and cube name)
                    Microsoft.VisualStudio.Project.Automation.OAFileItem fileitem = hierItem.Object as Microsoft.VisualStudio.Project.Automation.OAFileItem;
                    DeploymentSettings deploySet = new DeploymentSettings(fileitem.ContainingProject);
                    sTargetDatabase = deploySet.TargetDatabase;
                    sTargetCubeName = deploySet.TargetCubeName;
                }
                catch { } //this seems to blow up in debug mode on my laptop... oh well


                bool bRestoredDisplayFolders = false;
                List <SSAS.TabularTranslatedItem> translationRows = new List <BIDSHelper.SSAS.TabularTranslatedItem>();

                Microsoft.AnalysisServices.AdomdClient.AdomdRestrictionCollection restrictions = new Microsoft.AnalysisServices.AdomdClient.AdomdRestrictionCollection();
                restrictions.Add(new Microsoft.AnalysisServices.AdomdClient.AdomdRestriction("CUBE_NAME", cube.Name));
                DataSet           datasetMeasures = sandbox.AdomdConnection.GetSchemaDataSet("MDSCHEMA_MEASURES", restrictions);
                DataRowCollection rowsMeasures    = datasetMeasures.Tables[0].Rows;

                Database db = cube.Parent;
                SSAS.TabularTranslatedItem captionTranslationDatabase = new SSAS.TabularTranslatedItem(null, db, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                if (!string.IsNullOrEmpty(sTargetDatabase))
                {
                    captionTranslationDatabase.OverrideCaption(sTargetDatabase);
                }
                translationRows.Add(captionTranslationDatabase);
                if (!string.IsNullOrEmpty(db.Description))
                {
                    translationRows.Add(new SSAS.TabularTranslatedItem(null, db, SSAS.TabularTranslatedItemProperty.Description, captionTranslationDatabase, null));
                }

                List <CalculationProperty> calcProperties = new List <CalculationProperty>();
                foreach (Cube c in db.Cubes)
                {
                    SSAS.TabularTranslatedItem captionTranslationCube = new SSAS.TabularTranslatedItem(null, c, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                    if (!string.IsNullOrEmpty(sTargetCubeName))
                    {
                        captionTranslationCube.OverrideCaption(sTargetCubeName);
                    }
                    translationRows.Add(captionTranslationCube);
                    if (!string.IsNullOrEmpty(c.Description))
                    {
                        translationRows.Add(new SSAS.TabularTranslatedItem(null, c, SSAS.TabularTranslatedItemProperty.Description, captionTranslationCube, null));
                    }

                    foreach (Perspective p in c.Perspectives)
                    {
                        SSAS.TabularTranslatedItem captionTranslationPerspective = new SSAS.TabularTranslatedItem(null, p, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                        translationRows.Add(captionTranslationPerspective);
                        if (!string.IsNullOrEmpty(p.Description))
                        {
                            translationRows.Add(new SSAS.TabularTranslatedItem(null, p, SSAS.TabularTranslatedItemProperty.Description, captionTranslationPerspective, null));
                        }
                    }

                    foreach (MdxScript mdx in c.MdxScripts)
                    {
                        foreach (CalculationProperty calc in mdx.CalculationProperties)
                        {
                            if (calc.Visible && !calc.CalculationReference.StartsWith("KPIs."))
                            {
                                calcProperties.Add(calc);
                            }
                        }
                    }
                }

                foreach (Dimension d in db.Dimensions)
                {
                    SSAS.TabularTranslatedItem captionTranslationDimension = new SSAS.TabularTranslatedItem(d.Name, d, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                    translationRows.Add(captionTranslationDimension);
                    if (!string.IsNullOrEmpty(d.Description))
                    {
                        translationRows.Add(new SSAS.TabularTranslatedItem(d.Name, d, SSAS.TabularTranslatedItemProperty.Description, captionTranslationDimension, null));
                    }

                    foreach (DimensionAttribute da in d.Attributes)
                    {
                        if (da.Type != AttributeType.RowNumber && da.AttributeHierarchyVisible)
                        {
                            if (string.IsNullOrEmpty(da.AttributeHierarchyDisplayFolder))
                            {
                                SSAS.TabularDisplayFolderAnnotation a = annotationSavedFolders.Find(da);
                                if (a != null)
                                {
                                    da.AttributeHierarchyDisplayFolder = a.DisplayFolder;
                                    bRestoredDisplayFolders            = true; //we have to restore the display folder or the translations on the display folder won't even be visible in the translations dialog
                                }
                            }
                            SSAS.TabularTranslatedItem captionTranslation = new SSAS.TabularTranslatedItem(d.Name, da, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                            translationRows.Add(captionTranslation);
                            if (!string.IsNullOrEmpty(da.AttributeHierarchyDisplayFolder))
                            {
                                translationRows.Add(new SSAS.TabularTranslatedItem(d.Name, da, SSAS.TabularTranslatedItemProperty.DisplayFolder, captionTranslation, null));
                            }
                            if (!string.IsNullOrEmpty(da.Description))
                            {
                                translationRows.Add(new SSAS.TabularTranslatedItem(d.Name, da, SSAS.TabularTranslatedItemProperty.Description, captionTranslation, null));
                            }
                        }
                    }
                    foreach (Hierarchy h in d.Hierarchies)
                    {
                        if (string.IsNullOrEmpty(h.DisplayFolder))
                        {
                            SSAS.TabularDisplayFolderAnnotation a = annotationSavedFolders.Find(h);
                            if (a != null)
                            {
                                h.DisplayFolder         = a.DisplayFolder;
                                bRestoredDisplayFolders = true; //we have to restore the display folder or the translations on the display folder won't even be visible in the translations dialog
                            }
                        }

                        SSAS.TabularTranslatedItem captionTranslation = new SSAS.TabularTranslatedItem(d.Name, h, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                        translationRows.Add(captionTranslation);

                        if (!string.IsNullOrEmpty(h.DisplayFolder))
                        {
                            translationRows.Add(new SSAS.TabularTranslatedItem(d.Name, h, SSAS.TabularTranslatedItemProperty.DisplayFolder, captionTranslation, null));
                        }
                        if (!string.IsNullOrEmpty(h.Description))
                        {
                            translationRows.Add(new SSAS.TabularTranslatedItem(d.Name, h, SSAS.TabularTranslatedItemProperty.Description, captionTranslation, null));
                        }

                        foreach (Level level in h.Levels)
                        {
                            SSAS.TabularTranslatedItem captionTranslationLevel = new SSAS.TabularTranslatedItem(d.Name, level, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                            translationRows.Add(captionTranslationLevel);

                            if (!string.IsNullOrEmpty(level.Description))
                            {
                                translationRows.Add(new SSAS.TabularTranslatedItem(d.Name, level, SSAS.TabularTranslatedItemProperty.Description, captionTranslationLevel, null));
                            }
                        }
                    }

                    for (int i = 0; i < rowsMeasures.Count; i++)
                    {
                        DataRow r = rowsMeasures[i];
                        if (Convert.ToString(r["MEASUREGROUP_NAME"]) == d.Name)
                        {
                            foreach (CalculationProperty calc in calcProperties)
                            {
                                if (Convert.ToString(r["MEASURE_UNIQUE_NAME"]) == "[Measures]." + calc.CalculationReference)
                                {
                                    if (string.IsNullOrEmpty(calc.DisplayFolder))
                                    {
                                        SSAS.TabularDisplayFolderAnnotation a = annotationSavedFolders.Find(calc);
                                        if (a != null)
                                        {
                                            calc.DisplayFolder      = a.DisplayFolder;
                                            bRestoredDisplayFolders = true; //we have to restore the display folder or the translations on the display folder won't even be visible in the translations dialog
                                        }
                                    }

                                    SSAS.TabularTranslatedItem captionTranslation = new SSAS.TabularTranslatedItem(d.Name, calc, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                                    translationRows.Add(captionTranslation);
                                    if (!string.IsNullOrEmpty(calc.DisplayFolder))
                                    {
                                        translationRows.Add(new SSAS.TabularTranslatedItem(d.Name, calc, SSAS.TabularTranslatedItemProperty.DisplayFolder, captionTranslation, null));
                                    }
                                    if (!string.IsNullOrEmpty(calc.Description))
                                    {
                                        translationRows.Add(new SSAS.TabularTranslatedItem(d.Name, calc, SSAS.TabularTranslatedItemProperty.Description, captionTranslation, null));
                                    }

                                    rowsMeasures.Remove(r);
                                    i--;
                                    break;
                                }
                            }
                        }
                    }
                }

                foreach (Cube c in db.Cubes)
                {
                    SSAS.TabularActionsAnnotation actionAnnotations = TabularActionsEditorPlugin.GetAnnotation(c);
                    foreach (Microsoft.AnalysisServices.Action a in c.Actions)
                    {
                        SSAS.TabularAction actionAnnotation = actionAnnotations.Find(a.ID);
                        if (actionAnnotation == null)
                        {
                            actionAnnotation = new SSAS.TabularAction();
                        }

                        if (!string.IsNullOrEmpty(actionAnnotation.OriginalTarget) &&
                            !actionAnnotation.IsMasterClone)
                        {
                            continue;
                        }

                        SSAS.TabularTranslatedItem captionTranslationAction = new SSAS.TabularTranslatedItem(null, a, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                        translationRows.Add(captionTranslationAction);
                        if (!string.IsNullOrEmpty(a.Description))
                        {
                            translationRows.Add(new SSAS.TabularTranslatedItem(null, a, SSAS.TabularTranslatedItemProperty.Description, captionTranslationAction, null));
                        }
                    }
                }

                bool bRestoredTranslations = false;

                //get a list of all the distinct languages
                List <int> listLanguages = new List <int>();
                foreach (SSAS.TabularTranslatedItem item in translationRows)
                {
                    foreach (int iLang in item.Languages.Keys)
                    {
                        if (!listLanguages.Contains(iLang))
                        {
                            listLanguages.Add(iLang);
                        }
                    }
                    if (item.RestoredTranslations)
                    {
                        bRestoredTranslations = true;
                    }
                }
                listLanguages.Sort();

                if (bRestoredTranslations)
                {
                    MessageBox.Show("Some translations have been wiped out by other editing operations. Restoring translations may be possible except when an object like a measure or a hierarchy has been renamed.\r\n\r\nBIDS Helper will attempt to restore the translations now. Be sure to click OK after you finish your edits in the Tabular Translations window.", "BIDS Helper Tabular Translations");
                }
                else if (bRestoredDisplayFolders)
                {
                    MessageBox.Show("Some display folders have been wiped out by other editing operations. Restoring display folders may be possible except when an object like a measure or a hierarchy has been renamed.\r\n\r\nBIDS Helper will attempt to restore the display folders now. Properly restored display folders are necessary for this Tabular Translations dialog to function properly. Be sure to click OK after you finish your edits in the Tabular Translations window.", "BIDS Helper Tabular Translations");
                }
                else if (bPreBuildCheckOnly)
                {
                    return; //if this is just a pre-build check and if there's nothing that needs to be restored, then just return without popping up the dialog
                }

                SSAS.TabularTranslationsEditorWindow form = new SSAS.TabularTranslationsEditorWindow(db.Language, listLanguages);
                form.WindowState           = System.Windows.WindowState.Maximized;
                form.dataGrid1.ItemsSource = translationRows;


                if (form.ShowDialog() == true)
                {
                    //count dirty changes and create annotation
                    int iNumberOfChanges = 0;
                    foreach (SSAS.TabularTranslatedItem item in translationRows)
                    {
                        if (item.Dirty)
                        {
                            iNumberOfChanges++;
                        }
                    }

                    if (iNumberOfChanges > 0 || bRestoredDisplayFolders || bRestoredTranslations)
                    {
                        AlterDatabase(translationRows);
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
            }
        }
Exemplo n.º 20
0
        private void SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            if (!this.ViewModel.SyncToSolutionExplorer)
            {
                return;
            }

            FileTreeModel selected = e.NewValue as FileTreeModel;

            if (selected != null)
            {
                UIHierarchy     solutionExplorer = (UIHierarchy)IgnorePackage.DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object;
                UIHierarchyItem rootNode         = solutionExplorer.UIHierarchyItems.Item(1);

                Stack <Tuple <UIHierarchyItems, int, bool> > parents = new Stack <Tuple <UIHierarchyItems, int, bool> >();
                ProjectItem targetItem = IgnorePackage.DTE.Solution.FindProjectItem(selected.FullPath);

                if (targetItem == null)
                {
                    return;
                }

                UIHierarchyItems collection = rootNode.UIHierarchyItems;
                int  cursor    = 1;
                bool oldExpand = collection.Expanded;

                while (cursor <= collection.Count || parents.Count > 0)
                {
                    while (cursor > collection.Count && parents.Count > 0)
                    {
                        collection.Expanded = oldExpand;
                        Tuple <UIHierarchyItems, int, bool> parent = parents.Pop();
                        collection = parent.Item1;
                        cursor     = parent.Item2;
                        oldExpand  = parent.Item3;
                    }

                    if (cursor > collection.Count)
                    {
                        break;
                    }

                    UIHierarchyItem result = collection.Item(cursor);
                    ProjectItem     item   = result.Object as ProjectItem;

                    if (item == targetItem)
                    {
                        result.Select(vsUISelectionType.vsUISelectionTypeSelect);
                        return;
                    }

                    ++cursor;

                    bool oldOldExpand = oldExpand;
                    oldExpand = result.UIHierarchyItems.Expanded;
                    result.UIHierarchyItems.Expanded = true;
                    if (result.UIHierarchyItems.Count > 0)
                    {
                        parents.Push(Tuple.Create(collection, cursor, oldOldExpand));
                        collection = result.UIHierarchyItems;
                        cursor     = 1;
                    }
                }
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            var monitorSelection = Package.GetGlobalService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection;
            var solution         = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution;

            if (monitorSelection == null || solution == null)
            {
                return;
            }

            IVsMultiItemSelect multiItemSelect       = null;
            IntPtr             hierarchyPtr          = IntPtr.Zero;
            IntPtr             selectionContainerPtr = IntPtr.Zero;
            uint itemid;
            int  hr = VSConstants.S_OK;

            try
            {
                hr = monitorSelection.GetCurrentSelection(out hierarchyPtr, out itemid, out multiItemSelect, out selectionContainerPtr);
                if (ErrorHandler.Failed(hr) || hierarchyPtr == IntPtr.Zero || itemid == VSConstants.VSITEMID_NIL)
                {
                    // there is no selection
                    return;
                }
                IVsHierarchy hierarchy = Marshal.GetObjectForIUnknown(hierarchyPtr) as IVsHierarchy;
                if (hierarchy == null)
                {
                    return;
                }

                string doc;
                ((IVsProject)hierarchy).GetMkDocument(itemid, out doc);

                object pvar;
                hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out pvar);
                var project   = (EnvDTE.Project)pvar;
                var vcproject = (VCProject)project.Object;


                string ofRoot = "..\\..\\..";
                foreach (VCConfiguration config in vcproject.Configurations)
                {
                    ofRoot = config.GetEvaluatedPropertyValue("OF_ROOT");
                    if (ofRoot != "")
                    {
                        break;
                    }
                }

                var ofDi = new DirectoryInfo(ofRoot);
                if (new DirectoryInfo(Path.Combine(vcproject.ProjectDirectory, "..\\..\\..")).Equals(ofDi))
                {
                    ofRoot = "..\\..\\..";
                }
                else
                {
                    ofRoot = Path.GetFullPath(ofRoot);
                }

                var inputForm = new FormAddons(Path.GetDirectoryName(doc), ofRoot);
                var result    = inputForm.ShowDialog();
                if (result == DialogResult.Cancel)
                {
                    return;
                }

                var addons        = inputForm.getAddons();
                var currentAddons = inputForm.getProjectCurrentAddons();

                var addonsToRemove  = currentAddons.Except(addons);
                var remainingAddons = currentAddons.Except(addonsToRemove);
                var newAddons       = addons.Except(remainingAddons);

                Wizard.removeAddons(vcproject, ofRoot, addonsToRemove);
                Wizard.addAddons(vcproject, ofRoot, newAddons);
                Wizard.saveAddonsMake(vcproject, addons);

                DTE2        application = project.DTE.Application as DTE2;
                UIHierarchy solExplorer = application.ToolWindows.SolutionExplorer;
                Wizard.CollapseAllFolders(solExplorer, project.Name);
            }
            finally
            {
                if (selectionContainerPtr != IntPtr.Zero)
                {
                    Marshal.Release(selectionContainerPtr);
                }

                if (hierarchyPtr != IntPtr.Zero)
                {
                    Marshal.Release(hierarchyPtr);
                }
            }
        }
Exemplo n.º 22
0
        public static void CollapseFilter(UIHierarchyItem item, UIHierarchy hierarchy)
        {
            UIHierarchyItems subItems = item.UIHierarchyItems;
            if (subItems != null)
            {
                foreach (UIHierarchyItem innerItem in subItems)
                {
                    if (innerItem.UIHierarchyItems.Count > 0)
                    {
                        CollapseFilter(innerItem, hierarchy);

                        if (innerItem.UIHierarchyItems.Expanded)
                        {
                            innerItem.UIHierarchyItems.Expanded = false;
                            if (innerItem.UIHierarchyItems.Expanded == true)
                            {
                                innerItem.Select(vsUISelectionType.vsUISelectionTypeSelect);
                                hierarchy.DoDefaultAction();
                            }
                        }
                    }
                }
            }
            if (item.UIHierarchyItems.Expanded)
            {
                item.UIHierarchyItems.Expanded = false;
                if (item.UIHierarchyItems.Expanded == true)
                {
                    item.Select(vsUISelectionType.vsUISelectionTypeSelect);
                    hierarchy.DoDefaultAction();
                }
            }
        }
Exemplo n.º 23
0
        private void randoopExe(DTE2 application)
        {
            {
                //////////////////////////////////////////////////////////////////////////////////
                //step 1. when load randoop_net_addin, the path of "randoop" is defined 
                //////////////////////////////////////////////////////////////////////////////////
                string installPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                var randoop_path =
                    installPath + "\\Randoop-NET-release";

                //////////////////////////////////////////////////////////////////////////////////
                // step 2. create win form (if an item is or is not selected in solution explorer)
                //////////////////////////////////////////////////////////////////////////////////

                UIHierarchy solutionExplorer = application.ToolWindows.SolutionExplorer;
                var items = solutionExplorer.SelectedItems as Array;
                var arg = new Arguments(randoop_path);

                //if (items.Length >= 1)
                if (items.Length == 1)
                {
                    /*
                    if (items.Length > 1)
                    {
                        MessageBox.Show("Select only one item.", "ERROR");
                        return;
                    }*/

                    UIHierarchyItem item1 = items.GetValue(0) as UIHierarchyItem;
                    var prJItem = item1.Object as ProjectItem;

                    if (prJItem != null)
                    {
                        string prjPath = prJItem.Properties.Item("FullPath").Value.ToString();
                        if (prjPath.EndsWith(".dll") || prjPath.EndsWith(".exe"))
                            arg.SetDllToTest(prjPath);

                    }
                }

                //////////////////////////////////////////////////////////////////////////////////
                // step 3. show the win form
                //////////////////////////////////////////////////////////////////////////////////

                arg.ShowDialog();

                if (arg.ifContinue() == false)
                {
                    //MessageBox.Show("not going to execute Randoop."); 
                    return;
                }

                //////////////////////////////////////////////////////////////////////////////////
                // step 4. run Randoop.exe while reporting progress
                //////////////////////////////////////////////////////////////////////////////////

                string exepath = randoop_path + "\\bin\\Randoop.exe";

                if (!File.Exists(exepath))
                {
                    MessageBox.Show("Can't find Randoop.exe!", "ERROR");
                    return;
                }

                var prg = new Progress();
                int totalTime = arg.GetTimeLimit();

                prg.getTotalTime(totalTime);
                prg.setRandoopExe(exepath);
                prg.setRandoopArg(arg.GetRandoopArg());

                /*
                prg.ShowDialog();

                if (prg.isNormal() == false)
                {
                    return;
                }
                */


                //////////////////////////////////////////////////////////////////////////////////
                // step 5. convert all test files to one RandoopTest.cs
                //////////////////////////////////////////////////////////////////////////////////

                //MessageBox.Show("Randoop finishes generating test cases.", "Progress"); // [progress tracking]
                string out_dir = arg.GetTestFilepath();
                int nTestPfile = arg.GetTestNoPerFile();

                prg.setOutDir(out_dir);
                prg.setTestpFile(nTestPfile);

                //toMSTest objToMsTest = new toMSTest();
                //MessageBox.Show("Converting test cases to MSTest format.", "Progress"); // [progress tracking]
                //objToMsTest.Convert(out_dir, nTestPfile);


                //////////////////////////////////////////////////////////////////////////////////
                // step 6. add/include RandoopTest.cs in a/the Test Project  
                //////////////////////////////////////////////////////////////////////////////////

                //MessageBox.Show("Creating a Test Project and add test files ...", "Progress"); // [progress tracking]
                string dllTest = arg.GetDllToTest();
                prg.setObjTested(dllTest);
                //CreateTestPrj(out_dir, dllTest);
                //MessageBox.Show("Task Completes!", "Progress"); // [progress tracking]

                //////////////////////////////////////////////////////////////////////////////////
                // final. progress traking complete with the progress bar 
                //////////////////////////////////////////////////////////////////////////////////

                prg.ShowDialog();

                if (prg.isNormal() == false)
                {
                    return;
                }

                string pathToTestPrj = CreateTestPrj(out_dir, dllTest, application);
                MessageBox.Show("Test file is created in project: " + pathToTestPrj);
                //invoke ie to open index.html generated by Randoop
                System.Diagnostics.Process.Start("IEXPLORE.EXE", pathToTestPrj + "\\index.html");
            }

            return;
        }
Exemplo n.º 24
0
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        //public override bool DisplayCommand(UIHierarchyItem item)
        //{
        //    try
        //    {
        //        UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
        //        if (((System.Array)solExplorer.SelectedItems).Length != 1)
        //            return false;

        //        UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
        //        return (((ProjectItem)hierItem.Object).Object is Dimension);
        //    }
        //    catch
        //    {
        //        return false;
        //    }
        //}


        public override void Exec()
        {
            try
            {
                UIHierarchy     solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                UIHierarchyItem hierItem    = (UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0);
                ProjectItem     projItem    = (ProjectItem)hierItem.Object;
                Dimension       d           = (Dimension)projItem.Object;

                if (d.DataSource == null)
                {
                    if (d.Source is TimeBinding)
                    {
                        MessageBox.Show("Dimension Health Check is not supported on a Server Time dimension.");
                    }
                    else
                    {
                        MessageBox.Show("The data source for this dimension is not set. Dimension Health Check cannot be run.");
                    }
                    return;
                }
                else if (d.Source is DimensionBinding)
                {
                    MessageBox.Show("Dimension Health Check is not supported on a linked dimension.");
                    return;
                }

                ApplicationObject.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationDeploy);
                ApplicationObject.StatusBar.Progress(true, "Checking Dimension Health...", 0, d.Attributes.Count * 2);

                DimensionError[] errors = Check(d);
                if (errors == null)
                {
                    return;
                }

                this.oLastDimension = d;
                this.changesvc      = (IComponentChangeService)d.Site.GetService(typeof(IComponentChangeService));

                int    iErrorCnt = 0;
                string sCaption  = d.Name + ": Dimension Health Check";

#if YUKON || KATMAI
                EnvDTE80.Windows2 toolWins;
                object            objTemp = null;
                toolWins = (Windows2)ApplicationObject.Windows;
                if (toolWin == null)
                {
                    toolWin = toolWins.CreateToolWindow2(AddInInstance, typeof(WebBrowser).Assembly.Location, typeof(WebBrowser).FullName, sCaption, "{" + typeof(WebBrowser).GUID.ToString() + "}", ref objTemp);
                }
                else
                {
                    objTemp         = toolWin.Object;
                    toolWin.Caption = sCaption;
                }

                WebBrowser browser = (WebBrowser)objTemp;
#else
                //appear to be having some problems with .NET controls inside tool windows, even though this issue says fixed: http://connect.microsoft.com/VisualStudio/feedback/details/512181/vsip-vs-2010-beta2-width-of-add-in-toolwindow-not-changed-with-activex-hosted-control#tabs
                //so just create this inside a regular WinForm
                WebBrowser browser = new WebBrowser();
#endif

                browser.AllowNavigation = true;
                if (browser.Document != null) //idea from http://geekswithblogs.net/paulwhitblog/archive/2005/12/12/62961.aspx
                {
                    browser.Document.OpenNew(true);
                }
                else
                {
                    browser.Navigate("about:blank");
                }
                Application.DoEvents();

                browser.Document.Write("<font style='font-family:Arial;font-size:10pt'>");
                browser.Document.Write("<h3>" + d.Name + ": Dimension Health Check</h3>");
                browser.Document.Write("<i>Checks whether attribute relationships hold true according to the data.<br>Also checks definition of attribute keys to determine if they are unique.<br>Also checks whether any obvious attribute relationships are missing.</i><br><br>");
                if (errors.Length > 0)
                {
                    browser.Document.Write("<b>Problems</b><br>");
                    foreach (DimensionError e in errors)
                    {
                        iErrorCnt++;
                        browser.Document.Write("<li>");
                        browser.Document.Write(e.ErrorDescription);
                        DimensionDataError           de = e as DimensionDataError;
                        DimensionRelationshipWarning rw = e as DimensionRelationshipWarning;
                        if (de != null && de.ErrorTable != null)
                        {
                            browser.Document.Write(" <a href=\"javascript:void(null)\" id=expander" + iErrorCnt + " ErrorCnt=" + iErrorCnt + " style='color:blue'>Show/hide problem rows</a><br>\r\n");
                            browser.Document.Write("<table id=error" + iErrorCnt + " cellspacing=0 style='display:none;font-family:Arial;font-size:10pt'>");
                            browser.Document.Write("<tr><td></td>");
                            for (int i = 0; i < de.ErrorTable.Columns.Count; i++)
                            {
                                browser.Document.Write("<td nowrap><b>");
                                browser.Document.Write(System.Web.HttpUtility.HtmlEncode(de.ErrorTable.Columns[i].ColumnName));
                                browser.Document.Write("</b></td><td>&nbsp;&nbsp;</td>");
                            }
                            browser.Document.Write("</tr>\r\n");
                            foreach (DataRow dr in de.ErrorTable.Rows)
                            {
                                browser.Document.Write("<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;</td>");
                                for (int i = 0; i < de.ErrorTable.Columns.Count; i++)
                                {
                                    browser.Document.Write("<td nowrap>");
                                    if (!Convert.IsDBNull(dr[i]))
                                    {
                                        browser.Document.Write(System.Web.HttpUtility.HtmlEncode(dr[i].ToString()));
                                    }
                                    else
                                    {
                                        browser.Document.Write("<font color=lightgrey>(null)</font>");
                                    }
                                    browser.Document.Write("</td><td>&nbsp;&nbsp;</td>");
                                }
                                browser.Document.Write("</tr>");
                            }
                            browser.Document.Write("</table>");
                        }
                        else if (rw != null)
                        {
                            browser.Document.Write(" <a href=\"javascript:void(null)\" id=expander" + iErrorCnt + " Attribute=\"" + rw.Attribute.ID + "\" RelatedAttribute=\"" + rw.RelatedAttribute.ID + "\" style='color:blue'>Change attribute relationship</a>\r\n");
                        }
                    }
                }
                else
                {
                    browser.Document.Write("<b>No problems found</b>");
                }
                browser.Document.Write("</font>");
                browser.IsWebBrowserContextMenuEnabled = false;
                browser.AllowWebBrowserDrop            = false;

                Application.DoEvents();

                for (int i = 1; i <= iErrorCnt; i++)
                {
                    //in some of the newer versions of Internet Explorer, javascript is not enabled
                    //so do the dynamic stuff with C# events and code
                    try
                    {
                        browser.Document.GetElementById("expander" + i).Click += new HtmlElementEventHandler(Expander_Click);
                    }
                    catch { }
                }

#if YUKON || KATMAI
                //setting IsFloating and Linkable to false makes this window tabbed
                toolWin.IsFloating = false;
                toolWin.Linkable   = false;
                toolWin.Visible    = true;
#else
                Form descForm = new Form();
                descForm.Icon          = BIDSHelper.Resources.Common.BIDSHelper;
                descForm.Text          = "BIDS Helper - " + sCaption;
                descForm.MaximizeBox   = true;
                descForm.MinimizeBox   = false;
                descForm.Width         = 600;
                descForm.Height        = 500;
                descForm.SizeGripStyle = SizeGripStyle.Show;
                descForm.MinimumSize   = new System.Drawing.Size(descForm.Width / 2, descForm.Height / 2);

                browser.Top    = 10;
                browser.Left   = 10;
                browser.Width  = descForm.Width - 30;
                browser.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
                browser.Dock   = DockStyle.Fill;
                browser.Height = descForm.Height - 60;
                descForm.Controls.Add(browser);
                descForm.Show();
#endif
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                ApplicationObject.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationDeploy);
                ApplicationObject.StatusBar.Progress(false, "Checking Dimension Health...", 2, 2);
            }
        }
Exemplo n.º 25
0
 public SelectedProjectProvider(Solution solution, UIHierarchy solutionExplorer)
 {
     _solution         = solution;
     _solutionExplorer = solutionExplorer;
 }
Exemplo n.º 26
0
        /// <summary>
        /// Execute Addin Command
        /// </summary>
        /// <param name="cmdName">
        /// Command name
        /// </param>
        /// <param name="executeOption">
        /// Execute options
        /// </param>
        /// <param name="variantIn">
        /// object variant in
        /// </param>
        /// <param name="variantOut">
        /// object variant out
        /// </param>
        /// <param name="handled">
        /// Handled true or false
        /// </param>
        public void Exec(string cmdName, vsCommandExecOption executeOption, ref object variantIn, ref object variantOut, ref bool handled)
        {
            handled = false;
            if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
            {
                if (cmdName == "Xsd2Code.Addin.Connect.Xsd2CodeAddin")
                {
                    UIHierarchy uIH  = this.applicationObjectField.ToolWindows.SolutionExplorer;
                    var         item = (UIHierarchyItem)((Array)uIH.SelectedItems).GetValue(0);

                    UIHierarchyItems items = item.UIHierarchyItems;

                    ProjectItem proitem = uIH.DTE.SelectedItems.Item(1).ProjectItem;
                    Project     proj    = proitem.ContainingProject;

                    // Try to get default nameSpace
                    string defaultNamespace = string.Empty;
                    uint?  targetFramework  = 0;
                    bool?  isSilverlightApp = false;
                    try
                    {
                        defaultNamespace = proj.Properties.Item("DefaultNamespace").Value as string;
                        targetFramework  = proj.Properties.Item("TargetFramework").Value as uint?;
                        isSilverlightApp = proj.Properties.Item("SilverlightProject.IsSilverlightApplication").Value as bool?;
                    }
                    catch
                    {
                    }

                    CodeModel codeModel = proitem.ContainingProject.CodeModel;
                    string    fileName  = proitem.FileNames[0];
                    try
                    {
                        proitem.Save(fileName);
                    }
                    catch (Exception)
                    {
                    }

                    TargetFramework framework = TargetFramework.Net20;
                    if (targetFramework.HasValue)
                    {
                        uint target = targetFramework.Value;
                        switch (target)
                        {
                        case 196608:
                            framework = TargetFramework.Net30;
                            break;

                        case 196613:
                            framework = TargetFramework.Net35;
                            break;

                        case 262144:
                            framework = TargetFramework.Net40;
                            break;
                        }
                    }
                    if (isSilverlightApp.HasValue)
                    {
                        if (isSilverlightApp.Value)
                        {
                            framework = TargetFramework.Silverlight;
                        }
                    }

                    var frm = new FormOption();
                    frm.Init(fileName, proj.CodeModel.Language, defaultNamespace, framework);

                    DialogResult result = frm.ShowDialog();

                    GeneratorParams generatorParams = frm.GeneratorParams.Clone();
                    generatorParams.InputFilePath = fileName;

                    var gen = new GeneratorFacade(generatorParams);

                    // Close file if open in IDE
                    ProjectItem projElmts;
                    bool        found = FindInProject(proj.ProjectItems, gen.GeneratorParams.OutputFilePath, out projElmts);
                    if (found)
                    {
                        Window window = projElmts.Open(Constants.vsViewKindCode);
                        window.Close(vsSaveChanges.vsSaveChangesNo);
                    }

                    if (fileName.Length > 0)
                    {
                        if (result == DialogResult.OK)
                        {
                            Result <string> generateResult = gen.Generate();
                            string          outputFileName = generateResult.Entity;

                            if (!generateResult.Success)
                            {
                                MessageBox.Show(generateResult.Messages.ToString(), "XSD2Code", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else
                            {
                                if (!found)
                                {
                                    projElmts = proitem.Collection.AddFromFile(outputFileName);
                                }

                                if (frm.OpenAfterGeneration)
                                {
                                    Window window = projElmts.Open(Constants.vsViewKindCode);
                                    window.Activate();
                                    window.SetFocus();

                                    try
                                    {
                                        // this.applicationObjectField.DTE.ExecuteCommand("Edit.RemoveAndSort", "");
                                        applicationObjectField.DTE.ExecuteCommand("Edit.FormatDocument", string.Empty);
                                    }
                                    catch (Exception)
                                    {
                                    }
                                }
                            }
                        }
                    }

                    handled = true;
                    return;
                }
            }
        }
 public static void Initialize(CopyAsPathCommandPackage package, UIHierarchy solutionExplorer)
 {
     Requires.NotNull(package, nameof(package));
     Requires.NotNull(solutionExplorer, nameof(solutionExplorer));
     Instance = new CopyAsPathCommand(package, solutionExplorer);
 }
Exemplo n.º 28
0
 public override void SetUp()
 {
     base.SetUp();
     hierarchy = new UIHierarchy(Host, CreateDefaultConfiguration());
     HierarchyService.AddHierarchy(hierarchy);
 }
Exemplo n.º 29
0
        public static void CollapseFilter(UIHierarchyItem item, UIHierarchy hierarchy, string nodeToCollapseFilter)
        {
            if (string.IsNullOrEmpty(nodeToCollapseFilter))
                return;

            foreach (UIHierarchyItem innerItem in item.UIHierarchyItems)
            {
                if (innerItem.Name == nodeToCollapseFilter)
                    CollapseFilter(innerItem, hierarchy);

                else if (innerItem.UIHierarchyItems.Count > 0)
                {
                    CollapseFilter(innerItem, hierarchy, nodeToCollapseFilter);
                }
            }
        }
Exemplo n.º 30
0
        public static void CollapseAllFolders(UIHierarchy solExplorer, string projectName)
        {
            if (solExplorer.UIHierarchyItems.Count > 0)
            {
                UIHierarchyItem rootNode = solExplorer.UIHierarchyItems.Item(1);
                rootNode.DTE.SuppressUI = true;
                foreach (UIHierarchyItem uihitem in rootNode.UIHierarchyItems)
                {
                    if (uihitem.UIHierarchyItems.Expanded)
                    {
                        collapse(uihitem, projectName);
                    }

                }
                rootNode.Select(vsUISelectionType.vsUISelectionTypeSelect);
                rootNode.DTE.SuppressUI = false;
            }
        }
 public static UIHierarchyItem[] GetAllItemsFromSolutionExplorer(UIHierarchy solExplorer)
 {
     return(RecurseUIHierarchyItems(solExplorer.UIHierarchyItems));
 }
Exemplo n.º 32
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FullMirroring"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        /// <param name="commandService">Command service to add command to, not null.</param>
        private FullMirroring(AsyncPackage package, OleMenuCommandService commandService, UIHierarchy hierarchy)
        {
            _hierarchy     = hierarchy;
            this.package   = package ?? throw new ArgumentNullException(nameof(package));
            commandService = commandService ?? throw new ArgumentNullException(nameof(commandService));

            var menuCommandID = new CommandID(CommandSet, CommandId);
            var menuItem      = new MenuCommand(this.Execute, menuCommandID);

            commandService.AddCommand(menuItem);
        }
Exemplo n.º 33
0
        private UIHierarchyItem FindProjectHierarchyItem(UIHierarchy hierarchy)
        {
            if (hierarchy.UIHierarchyItems.Count == 0)
                return null;

            UIHierarchyItem solution = hierarchy.UIHierarchyItems.Item(1);
            UIHierarchyItem projectItem = null;
            foreach (UIHierarchyItem solutionItem in solution.UIHierarchyItems)
            {
                projectItem = FindProjectHierarchyItem(solutionItem);
                if (projectItem != null)
                    break;
            }
            return projectItem;
        }
        public static void ScanReports(UIHierarchy solExplorer, bool LookForUnusedDatasets)
        {
            string sCurrentFile = string.Empty;

            try
            {
                //UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                SolutionClass   solution = hierItem.Object as SolutionClass;

                List <string> lstRdls = new List <string>();
                if (hierItem.Object is Project)
                {
                    Project p = (Project)hierItem.Object;
                    lstRdls.AddRange(GetRdlFilesInProjectItems(p.ProjectItems, true));
                }
                else if (hierItem.Object is ProjectItem)
                {
                    ProjectItem pi = hierItem.Object as ProjectItem;
                    Project     p  = pi.SubProject;
                    lstRdls.AddRange(GetRdlFilesInProjectItems(p.ProjectItems, true));
                }
                else if (solution != null)
                {
                    foreach (Project p in solution.Projects)
                    {
                        lstRdls.AddRange(GetRdlFilesInProjectItems(p.ProjectItems, true));
                    }
                }

                List <UsedRsDataSets.RsDataSetUsage> lstDataSets = new List <UsedRsDataSets.RsDataSetUsage>();
                foreach (string file in lstRdls)
                {
                    sCurrentFile = file;
                    UsedRsDataSets urds = new UsedRsDataSets(file);
                    foreach (UsedRsDataSets.RsDataSet ds in urds.DataSets)
                    {
                        if (LookForUnusedDatasets && ds.Usages.Count == 0)
                        {
                            UsedRsDataSets.RsDataSetUsage u = new UsedRsDataSets.RsDataSetUsage();
                            u.ReportName  = ds.ReportName;
                            u.DataSetName = ds.DataSetName;
                            lstDataSets.Add(u);
                        }
                        else if (!LookForUnusedDatasets && ds.Usages.Count > 0)
                        {
                            foreach (string usage in ds.Usages)
                            {
                                UsedRsDataSets.RsDataSetUsage u = new UsedRsDataSets.RsDataSetUsage();
                                u.ReportName  = ds.ReportName;
                                u.DataSetName = ds.DataSetName;
                                u.Usage       = usage;
                                lstDataSets.Add(u);
                            }
                        }
                    }
                }

                if (lstDataSets.Count == 0)
                {
                    if (LookForUnusedDatasets)
                    {
                        MessageBox.Show("All datasets are in use.", "BIDS Helper Unused Datasets Report");
                    }
                    else
                    {
                        MessageBox.Show("No datasets found.", "BIDS Helper Used Datasets Report");
                    }
                }
                else
                {
                    ReportViewerForm frm = new ReportViewerForm();
                    frm.ReportBindingSource.DataSource = lstDataSets;
                    if (LookForUnusedDatasets)
                    {
                        frm.Report  = "SSRS.UnusedDatasets.rdlc";
                        frm.Caption = "Unused Datasets Report";
                    }
                    else
                    {
                        frm.Report  = "SSRS.UsedDatasets.rdlc";
                        frm.Caption = "Used Datasets Report";
                    }
                    Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
                    reportDataSource1.Name  = "BIDSHelper_SSRS_RsDataSetUsage";
                    reportDataSource1.Value = frm.ReportBindingSource;
                    frm.ReportViewerControl.LocalReport.DataSources.Add(reportDataSource1);

                    frm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
                    frm.Show();
                }
            }
            catch (System.Exception ex)
            {
                string sError = string.Empty;
                if (!string.IsNullOrEmpty(sCurrentFile))
                {
                    sError += "Error while scanning report: " + sCurrentFile + "\r\n";
                }
                while (ex != null)
                {
                    sError += ex.Message + "\r\n" + ex.StackTrace + "\r\n\r\n";
                    ex      = ex.InnerException;
                }
                MessageBox.Show(sError);
            }
        }
Exemplo n.º 35
0
 public static UIHierarchyItem[] GetAllItemsFromSolutionExplorer(UIHierarchy solExplorer)
 {
     return RecurseUIHierarchyItems(solExplorer.UIHierarchyItems);
 }
		virtual public UIHierarchyItem GetSelectedUIHierarchy(UIHierarchy solutionExplorer)
		{
			object[] objArray = solutionExplorer.SelectedItems as object[];
			if (objArray != null && objArray.Length == 1)
				return objArray[0] as UIHierarchyItem;
			else
				return (UIHierarchyItem)null;
		}
 public SolutionExplorer(UIHierarchy solutionExplorer)
 {
     _solutionExplorer = solutionExplorer;
 }
        public void RunCustomDesignRules(Database db, Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandbox)
        {
            UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;

            if (((System.Array)solExplorer.SelectedItems).Length != 1)
            {
                return;
            }

            //UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
            // TODO - get database properties
            //ProjectItem pi = (ProjectItem)hierItem.Object;

            //Window w = pi.Open(BIDSViewKinds.Designer); //opens the designer
            //w.Activate();

            try
            {
                //ClearTaskList();
                ClearErrorList();
                ApplicationObject.StatusBar.Text = "Starting Powershell Design Rules Engine...";
                var    ps = PowerShell.Create();
                string modelType;
                if (db == null)
                {
                    modelType = "Tabular";
                    ps.Runspace.SessionStateProxy.SetVariable("WorkspaceConnection", sandbox.AdomdConnection);
                    ps.Runspace.SessionStateProxy.SetVariable("CurrentCube", sandbox.Cube);
                }
                else
                {
                    modelType = "MultiDim";
                    ps.Runspace.SessionStateProxy.SetVariable("CurrentDB", db);
                }
                ps.Runspace.SessionStateProxy.SetVariable("ModelType", modelType);
                ps.Runspace.SessionStateProxy.SetVariable("VerbosePreference", "Continue");


                ps.Streams.Debug.DataAdded   += new EventHandler <DataAddedEventArgs>(Debug_DataAdded);
                ps.Streams.Warning.DataAdded += new EventHandler <DataAddedEventArgs>(Warning_DataAdded);
                ps.Streams.Error.DataAdded   += new EventHandler <DataAddedEventArgs>(Error_DataAdded);
                ps.Streams.Verbose.DataAdded += new EventHandler <DataAddedEventArgs>(Verbose_DataAdded);

                ApplicationObject.StatusBar.Text = "Loading Custom Design Rules...";

                // TODO - look into adding a script to allow calling a copy from a central rule repository

                string dllFile = (new System.Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath;
                System.Diagnostics.Debug.WriteLine(dllFile);
                FileInfo      dll     = new FileInfo(dllFile);
                DirectoryInfo scripts = new DirectoryInfo(dll.Directory.FullName + "\\SSAS_Design_Rules");

                foreach (FileInfo f in scripts.GetFiles(modelType + "_*.ps1"))
                {
                    TextReader tr = new StreamReader(f.OpenRead());

                    string psScript = tr.ReadToEnd();
                    ps.Commands.Clear();
                    ps.AddScript(psScript);
                    ps.Invoke();
                }
                ps.Commands.Clear();
                // get a list of functions
                var pipeline = ps.Runspace.CreatePipeline();

                var cmd1 = new System.Management.Automation.Runspaces.Command("get-childitem");
                cmd1.Parameters.Add("Path", @"function:\Check*");
                pipeline.Commands.Add(cmd1);

                var cmd2 = new System.Management.Automation.Runspaces.Command("where-object");
                var sb   = ScriptBlock.Create("$_.Parameters.Count -eq 0");
                cmd2.Parameters.Add("FilterScript", sb);
                pipeline.Commands.Add(cmd2);

                var funcs    = pipeline.Invoke();
                var funcList = new List <string>();
                foreach (var f in funcs)
                {
                    funcList.Add(f.ToString());
                }
                ps.Commands.Clear();
                ApplicationObject.StatusBar.Text = "";
                // show dialog
                var dialog = new CustomDesignRulesCheckerForm();
                dialog.Functions = funcList;
                dialog.Plugin    = this;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    var iCnt = 0;
                    // run selected functions
                    foreach (var f in dialog.Functions)
                    {
                        ApplicationObject.StatusBar.Progress(true, string.Format("Running rule '{0}'", f), iCnt, dialog.Functions.Count);
                        ps.AddCommand(f);
                        ps.Invoke();
                        iCnt++;
                    }
                    ApplicationObject.StatusBar.Progress(false);
                }
            }
            catch (System.Exception ex)
            {
                AddTaskItem(PriorityType.Error, "ERROR RUNNING DESIGN CHECKS: " + ex.Message);
            }
        }
Exemplo n.º 39
0
 public SelectedFilesProvider(UIHierarchy solutionExplorer)
 {
     _solutionExplorer = solutionExplorer;
 }
Exemplo n.º 40
0
		private static void GetAndSelectSolutionExplorerHierarchy(_DTE vs, out UIHierarchy hier, out UIHierarchyItem sol)
		{
			if(vs == null)
			{
				throw new ArgumentNullException("vs");
			}
			// Select the parent folder to add the project to it.
			Window win = vs.Windows.Item(EnvDTE.Constants.vsWindowKindSolutionExplorer);
			if(win == null)
			{
				// Can't select as there's no solution explorer open.
				throw new InvalidOperationException(Properties.Resources.DteHelper_NoSolutionExplorer);
			}
			win.Activate();
			win.SetFocus();
			hier = win.Object as UIHierarchy;
			sol = hier.UIHierarchyItems.Item(1);
			if(sol == null)
			{
				// No solution is opened.
				throw new InvalidOperationException(Properties.Resources.DteHelper_NoSolutionExplorer);
			}
			sol.Select(vsUISelectionType.vsUISelectionTypeSelect);
		}
Exemplo n.º 41
0
 public static UIHierarchyItem FindHierarchyItem(this UIHierarchy hierarchy, Project item)
 {
     return(FindHierarchyItem(hierarchy, (object)item));
 }
 protected virtual IUIHierarchy CreateHierarchyAndAddToHierarchyService(ConfigurationNode node, ConfigurationContext configurationContext)
 {
     UIHierarchy hierarchy = new UIHierarchy(node, host, configurationContext);
     hierarchyService.AddHierarchy(hierarchy);
     return hierarchy;
 }
Exemplo n.º 43
0
        public override void Exec()
        {
            try
            {
                UIHierarchy       solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                UIHierarchyItem   hierItem    = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                ProjectItem       pi          = (ProjectItem)hierItem.Object;
                Window            win         = pi.Document.ActiveWindow;
                IDesignerHost     designer    = (IDesignerHost)pi.Document.ActiveWindow.Object;
                Package           package     = null;
                ConnectionManager conn        = GetSelectedConnectionManager(designer, out package);

                BIDSHelper.SSIS.FixedWidthColumnsForm form = new BIDSHelper.SSIS.FixedWidthColumnsForm();
                if (conn != null && conn.Properties["Format"].GetValue(conn).ToString() == "FixedWidth")
                {
                    //hiding properties for ragged right
                    form.dataGridView1.Height            = form.dataGridView1.Height + 50 + 26;
                    form.dataGridView1.Top              -= 50;
                    form.label1.Height                  -= 50;
                    form.cboRaggedRightDelimiter.Visible = false;
                    form.lblRaggedRight.Visible          = false;
                }

                DialogResult dialogResult = form.ShowDialog();

                if (dialogResult == DialogResult.OK)
                {
#if KATMAI || DENALI || SQL2014
                    wrap.IDTSConnectionManagerFlatFile100 ff = conn.InnerObject as wrap.IDTSConnectionManagerFlatFile100;
                    DtsConvert.GetExtendedInterface(conn);
#else
                    wrap.IDTSConnectionManagerFlatFile90 ff = conn.InnerObject as wrap.IDTSConnectionManagerFlatFile90;
                    DtsConvert.ToConnectionManager90(conn);
#endif

                    while (ff.Columns.Count > 0)
                    {
                        ff.Columns.Remove(0);
                    }

                    List <string> listUsedNames = new List <string>();

                    //JCW - Added counter to identify the last column
                    int columnCount = 1;

                    foreach (DataGridViewRow row in form.dataGridView1.Rows)
                    {
                        string sName         = row.Cells[0].Value.ToString().Trim();
                        string sOriginalName = sName;
                        int    i             = 1;
                        while (listUsedNames.Contains(sName)) //find a unique name for the column
                        {
                            sName = sOriginalName + (++i);
                        }
                        listUsedNames.Add(sName);

#if KATMAI || DENALI || SQL2014
                        wrap.IDTSConnectionManagerFlatFileColumn100 col = ff.Columns.Add();
                        wrap.IDTSName100 name = col as wrap.IDTSName100;
#else
                        wrap.IDTSConnectionManagerFlatFileColumn90 col = ff.Columns.Add();
                        wrap.IDTSName90 name = col as wrap.IDTSName90;
#endif

                        name.Name        = sName;
                        col.MaximumWidth = int.Parse(row.Cells[1].Value.ToString());
                        col.DataType     = Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType.DT_STR;

                        if (columnCount == form.dataGridView1.Rows.Count && form.cboRaggedRightDelimiter.Text != "[None]")
                        {
                            col.ColumnWidth     = 0;
                            col.ColumnType      = "Delimited";
                            col.ColumnDelimiter = DecodeDelimiter(form.cboRaggedRightDelimiter.Text);
                        }
                        else
                        {
                            col.ColumnWidth = int.Parse(row.Cells[1].Value.ToString());
                            col.ColumnType  = "FixedWidth";
                        }


                        columnCount++;
                    }

                    //mark package object as dirty
                    IComponentChangeService changesvc = (IComponentChangeService)designer.GetService(typeof(IComponentChangeService));
                    changesvc.OnComponentChanging(package, null);
                    changesvc.OnComponentChanged(package, null, null, null); //marks the package designer as dirty
                    SSISHelpers.MarkPackageDirty(package);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 /// <summary>
 ///   <see cref="FindHierarchyItem(EnvDTE.UIHierarchy,EnvDTE.Project)" />
 /// </summary>
 /// <param name="instance">The instance.</param>
 /// <param name="item">The item.</param>
 public static UIHierarchyItem FindHierarchyItem(
     this UIHierarchy instance,
     ProjectItem item)
 {
     return(FindHierarchyItem(instance, (object)item));
 }
Exemplo n.º 45
0
 internal SolutionExplorerControl(UIHierarchy solutionExplorer, ILogger logger)
 {
     this.solutionExplorer = solutionExplorer;
     this.logger           = logger;
 }
Exemplo n.º 46
0
        public override void Exec()
        {
            try
            {
                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                if (((System.Array)solExplorer.SelectedItems).Length != 1)
                {
                    return;
                }

                UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                ProjectItem     pi       = (ProjectItem)hierItem.Object;

                if (System.Windows.Forms.MessageBox.Show("Are you sure you want to reset the GUIDs for all tasks, connection managers, configurations,\r\nevent handlers, and variables in package " + pi.Name + "?", "BIDS Helper - Reset GUIDs?", System.Windows.Forms.MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }

                Window w = pi.Open(BIDSViewKinds.Designer); //opens the designer
                w.Activate();

                IDesignerHost designer = w.Object as IDesignerHost;
                if (designer == null)
                {
                    return;
                }
                EditorWindow win     = (EditorWindow)designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator));
                Package      package = win.PropertiesLinkComponent as Package;
                if (package == null)
                {
                    return;
                }


                //capture list of GUIDs to replace
                _listGuidsToReplace = new List <string>();
                AddGuid(package.ID);
                RecurseExecutablesAndCaptureGuids(package);
                foreach (DtsEventHandler h in package.EventHandlers)
                {
                    AddGuid(h.ID);
                    RecurseExecutablesAndCaptureGuids(h);
                }
                foreach (ConnectionManager cm in package.Connections)
                {
                    AddGuid(cm.ID);
                }
                foreach (Microsoft.SqlServer.Dts.Runtime.Configuration conf in package.Configurations)
                {
                    AddGuid(conf.ID);
                }

                //open package XML
                ApplicationObject.ExecuteCommand("View.ViewCode", String.Empty);

                // Loop through GUIDs captured and replace
                foreach (string sOldGuid in _listGuidsToReplace)
                {
                    ApplicationObject.Find.FindWhat          = sOldGuid;
                    ApplicationObject.Find.ReplaceWith       = "{" + System.Guid.NewGuid().ToString().ToUpper() + "}";
                    ApplicationObject.Find.Target            = vsFindTarget.vsFindTargetCurrentDocument;
                    ApplicationObject.Find.MatchCase         = false;
                    ApplicationObject.Find.MatchWholeWord    = true;
                    ApplicationObject.Find.MatchInHiddenText = false;
                    ApplicationObject.Find.Action            = vsFindAction.vsFindActionReplaceAll;
                    ApplicationObject.Find.PatternSyntax     = vsFindPatternSyntax.vsFindPatternSyntaxLiteral;

                    if (ApplicationObject.Find.Execute() == vsFindResult.vsFindResultNotFound)
                    {
                        System.Diagnostics.Debug.WriteLine("couldn't find " + sOldGuid);
                        System.Windows.Forms.MessageBox.Show("Resetting GUIDs did NOT complete successfully as the package has changed.\r\n\r\nThis may have happened if you did not have the latest version from source control before running the Reset GUIDs command.", "BIDS Helper - Problem Resetting GUIDs");
                        return;
                    }
                }

                ApplicationObject.ActiveWindow.Close(vsSaveChanges.vsSaveChangesNo); //close the package XML
                ApplicationObject.ActiveDocument.Save(null);
                w.Close(vsSaveChanges.vsSaveChangesNo);                              //close the designer

                w = pi.Open(BIDSViewKinds.Designer);                                 //opens the designer
                w.Activate();
                //that was the quick and easy way to get the expression highlighter up to date
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message + " " + ex.StackTrace);
            }
        }
Exemplo n.º 47
0
        public static string GetFolderPath(Options options, DTE2 dte)
        {
            // If option to always open at sln level is chosen, use that.
            if (options.OpenSlnLevel && dte.Solution != null && !string.IsNullOrEmpty(dte.Solution.FullName))
            {
                return(Path.GetDirectoryName(dte.Solution.FullName));
            }

            Window2 window = dte.ActiveWindow as Window2;

            if (window != null)
            {
                if (window.Type == vsWindowType.vsWindowTypeDocument)
                {
                    // if a document is active, use the document's containing folder
                    Document doc = dte.ActiveDocument;
                    if (doc != null && IsValidFileName(doc.FullName))
                    {
                        if (options.OpenProjectLevel)
                        {
                            ProjectItem item = dte.Solution.FindProjectItem(doc.FullName);

                            if (item != null && item.ContainingProject != null && !string.IsNullOrEmpty(item.ContainingProject.FullName))
                            {
                                string folder = item.ContainingProject.GetRootFolder();

                                if (!string.IsNullOrEmpty(folder))
                                {
                                    return(folder);
                                }
                            }
                        }
                        else
                        {
                            return(Path.GetDirectoryName(dte.ActiveDocument.FullName));
                        }
                    }
                }
                else if (window.Type == vsWindowType.vsWindowTypeSolutionExplorer)
                {
                    // if solution explorer is active, use the path of the first selected item
                    UIHierarchy hierarchy = window.Object as UIHierarchy;
                    if (hierarchy != null && hierarchy.SelectedItems != null)
                    {
                        UIHierarchyItem[] hierarchyItems = hierarchy.SelectedItems as UIHierarchyItem[];
                        if (hierarchyItems != null && hierarchyItems.Length > 0)
                        {
                            UIHierarchyItem hierarchyItem = hierarchyItems[0] as UIHierarchyItem;
                            if (hierarchyItem != null)
                            {
                                ProjectItem projectItem = hierarchyItem.Object as ProjectItem;
                                if (projectItem != null && projectItem.FileCount > 0)
                                {
                                    if (Directory.Exists(projectItem.FileNames[1]))
                                    {
                                        return(projectItem.FileNames[1]);
                                    }

                                    if (IsValidFileName(projectItem.FileNames[1]))
                                    {
                                        return(Path.GetDirectoryName(projectItem.FileNames[1]));
                                    }
                                }
                            }
                        }
                    }
                }
            }

            Project project = GetActiveProject(dte);

            if (project != null && !project.Kind.Equals(ProjectKinds.vsProjectKindSolutionFolder, StringComparison.OrdinalIgnoreCase))
            {
                return(project.GetRootFolder());
            }

            if (dte.Solution != null && !string.IsNullOrEmpty(dte.Solution.FullName))
            {
                return(Path.GetDirectoryName(dte.Solution.FullName));
            }

            return(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
        }
Exemplo n.º 48
0
        public override void Exec()
        {
            try
            {
                UIHierarchy     solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                UIHierarchyItem hierItem    = (UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0);
                ProjectItem     projItem    = (ProjectItem)hierItem.Object;
                Database        db          = projItem.ContainingProject.Object as Database;

                listDiscrepancies = new List <DataTypeDiscrepancy>();
                foreach (Microsoft.AnalysisServices.Dimension d in db.Dimensions)
                {
                    foreach (DimensionAttribute da in d.Attributes)
                    {
                        foreach (DataItem di in da.KeyColumns)
                        {
                            CheckDataTypeDiscrepancies(di, ColumnType.KeyColumn);
                        }
                        CheckDataTypeDiscrepancies(da.NameColumn, ColumnType.NameColumn);
                        CheckDataTypeDiscrepancies(da.CustomRollupColumn, ColumnType.CustomRollup);
                        CheckDataTypeDiscrepancies(da.CustomRollupPropertiesColumn, ColumnType.CustomRollupProperties);
                        CheckDataTypeDiscrepancies(da.UnaryOperatorColumn, ColumnType.UnaryOperator);
                        CheckDataTypeDiscrepancies(da.ValueColumn, ColumnType.ValueColumn);
                        foreach (AttributeTranslation t in da.Translations)
                        {
                            CheckDataTypeDiscrepancies(t.CaptionColumn, ColumnType.TranslationCaption);
                        }
                    }
                }

                if (listDiscrepancies.Count == 0)
                {
                    MessageBox.Show("No dimension data type discrepancies found.");
                    return;
                }

                BIDSHelper.SSAS.DataTypeDiscrepancyCheckForm form = new BIDSHelper.SSAS.DataTypeDiscrepancyCheckForm();
                form.gridBindingSource.DataSource = listDiscrepancies;
                DialogResult dialogResult = form.ShowDialog();

                if (dialogResult == DialogResult.OK)
                {
                    foreach (DataTypeDiscrepancy discrepancy in listDiscrepancies)
                    {
                        if (discrepancy.SaveChange)
                        {
                            discrepancy.AnalysisServicesColumn.DataType = discrepancy.NewDataType;
                            discrepancy.AnalysisServicesColumn.DataSize = discrepancy.NewDataTypeLength;

                            //mark dimension designer as dirty
                            IComponentChangeService changesvc = (IComponentChangeService)discrepancy.DimensionAttribute.Parent.Site.GetService(typeof(IComponentChangeService));
                            changesvc.OnComponentChanging(discrepancy.DimensionAttribute.Parent, null);
                            changesvc.OnComponentChanged(discrepancy.DimensionAttribute.Parent, null, null, null);
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }