コード例 #1
0
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool DisplayCommand(UIHierarchyItem item)
        {
#if DENALI
            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));
                if (!(hierItem.Object is ProjectItem))
                {
                    return(false);
                }
                string sFileName = ((ProjectItem)hierItem.Object).Name.ToLower();
                if (sFileName.EndsWith(".bim"))
                {
                    if (TabularHelpers.GetTabularSandboxFromBimFile(hierItem, false) == null)
                    {
                        return(true); //.bim file is closed so show this menu item
                    }
                }
            }
            catch
            {
            }
#endif
            return(false);
        }
コード例 #2
0
        private void BuildEvents_OnBuildBegin(vsBuildScope Scope, vsBuildAction Action)
        {
            if (!this.Enabled)
            {
                return;
            }
            if (Action == vsBuildAction.vsBuildActionClean)
            {
                return;
            }

            foreach (UIHierarchyItem hierItem in VisualStudioHelpers.GetAllItemsFromSolutionExplorer(this.ApplicationObject.ToolWindows.SolutionExplorer))
            {
                if (hierItem.Name != null && hierItem.Name.ToLower().EndsWith(".bim"))
                {
                    Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandbox = TabularHelpers.GetTabularSandboxFromBimFile(hierItem, false);
                    if (sandbox != null)
                    {
                        List <BIDSHelperPluginBase> checks = new List <BIDSHelperPluginBase>();
                        foreach (BIDSHelperPluginBase plugin in Connect.Plugins.Values)
                        {
                            Type t = plugin.GetType();
                            if (plugin is ITabularOnPreBuildAnnotationCheck &&
                                !t.IsInterface &&
                                !t.IsAbstract)
                            {
                                ITabularOnPreBuildAnnotationCheck check = (ITabularOnPreBuildAnnotationCheck)plugin;
                                if (check.TabularOnPreBuildAnnotationCheckPriority == TabularOnPreBuildAnnotationCheckPriority.HighPriority)
                                {
                                    checks.Insert(0, plugin); //insert the high priority checks at the front of the list so they get run first
                                }
                                else
                                {
                                    checks.Add(plugin);
                                }
                            }
                        }

                        foreach (BIDSHelperPluginBase plugin in checks)
                        {
                            ITabularOnPreBuildAnnotationCheck check = (ITabularOnPreBuildAnnotationCheck)plugin;
                            string sWarning = check.GetPreBuildWarning(sandbox);
                            if (sWarning != null)
                            {
                                if (MessageBox.Show(sWarning, "BIDS Helper Pre-Build Warning - " + plugin.FeatureName, MessageBoxButtons.OKCancel) == DialogResult.OK)
                                {
                                    Microsoft.VisualStudio.Project.Automation.OAFileItem project = hierItem.Object as Microsoft.VisualStudio.Project.Automation.OAFileItem;
                                    Window win = project.Open(EnvDTE.Constants.vsViewKindPrimary);
                                    win.Activate();
                                    check.FixPreBuildWarning(sandbox);
                                    project.Save(hierItem.Name);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #3
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;

                string sFileName = ((ProjectItem)hierItem.Object).Name.ToLower();

                if (sFileName.EndsWith(".bim"))
                {
#if DENALI || SQL2014
                    Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandbox = TabularHelpers.GetTabularSandboxFromBimFile(hierItem, true);
                    foreach (DataSourceView o in sandbox.Database.DataSourceViews)
                    {
                        IterateDsvColumns(o);
                    }
#endif
                }
                else
                {
                    DataSourceView dsv = (DataSourceView)projItem.Object;
                    IterateDsvColumns(dsv);
                }

                if (unusedColumns.Count == 0)
                {
                    MessageBox.Show("There are no unused columns.", "BIDS Helper - Unused Columns Report");
                    return;
                }

                ReportViewerForm frm = new ReportViewerForm();
                frm.ReportBindingSource.DataSource = unusedColumns.Values;
                frm.Report = "SSAS.UnusedColumns.rdlc";
                Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
                reportDataSource1.Name  = "BIDSHelper_UnusedColumn";
                reportDataSource1.Value = frm.ReportBindingSource;
                frm.ReportViewerControl.LocalReport.DataSources.Add(reportDataSource1);
                frm.ReportViewerControl.LocalReport.ReportEmbeddedResource = "SSAS.UnusedColumns.rdlc";

                frm.Caption     = "Unused Columns Report";
                frm.WindowState = FormWindowState.Maximized;
                frm.Show();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #4
0
        public override void Exec()
        {
            try
            {
                UIHierarchy     solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                UIHierarchyItem hierItem    = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));

                sandbox = TabularHelpers.GetTabularSandboxFromBimFile(hierItem, true);
                ExecSandbox(sandbox);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
            }
        }
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool ShouldDisplayCommand()
        {
#if DENALI
            try
            {
                if (TabularHelpers.GetTabularSandboxFromBimFile(this, false) == null)
                {
                    return(true); //.bim file is closed so show this menu item
                }
            }
            catch
            {
            }
#endif
            return(false);
        }
コード例 #6
0
        public override void Exec()
        {
            try
            {
                UIHierarchy     solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                UIHierarchyItem hierItem    = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                //SolutionClass solution = hierItem.Object as SolutionClass;

                Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandbox = null;
                Database db          = null;
                bool     targetFound = false;
                if (hierItem.Object is EnvDTE.Project)
                {
                    EnvDTE.Project p = (EnvDTE.Project)hierItem.Object;
                    Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)p;
                    if (projExt.Kind == BIDSProjectKinds.SSAS)
                    {
                        db          = (Database)p.Object;
                        targetFound = true;
                    }
                }
                if (hierItem.Object is ProjectItem)
                {
                    string sFileName = ((ProjectItem)hierItem.Object).Name.ToLower();
                    if (sFileName.EndsWith(".bim"))
                    {
                        sandbox     = TabularHelpers.GetTabularSandboxFromBimFile(hierItem, true);
                        targetFound = true;
                    }
                }

                if (targetFound)
                {
                    RunCustomDesignRules(db, sandbox);
                }
                else
                {
                    MessageBox.Show("No valid design rule target found");
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #7
0
        public override bool ShouldDisplayCommand()
        {
            var selectedFile = GetSelectedFile();

            if (selectedFile != null && selectedFile.Extension == ".bim")
            {
#if !DENALI && !SQL2014
                var sb = TabularHelpers.GetTabularSandboxFromBimFile(this, false);
                if (sb == null)
                {
                    return(false);
                }
                return(!sb.IsTabularMetadata);
#else
                return(true);
#endif
            }
            return(false);
        }
コード例 #8
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));
        //        if (!(hierItem.Object is ProjectItem)) return false;
        //        string sFileName = ((ProjectItem)hierItem.Object).Name.ToLower();
        //        return (sFileName.EndsWith(".bim"));
        //    }
        //    catch
        //    {
        //    }
        //    return false;
        //}


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

                var sandbox = TabularHelpers.GetTabularSandboxFromBimFile(this, true);
                if (sandbox == null)
                {
                    throw new Exception("Can't get Sandbox!");
                }

                ProjectItem projItem = (ProjectItem)hierItem.Object;

                ExecInternal(projItem, sandbox);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
            }
        }
コード例 #9
0
        internal override void OnUpdateConfigBegin(IVsHierarchy pHierProj, VSSOLNBUILDUPDATEFLAGS dwAction, ref int pfCancel)
        {
            if (!this.Enabled)
            {
                return;
            }
            if (dwAction == VSSOLNBUILDUPDATEFLAGS.SBF_OPERATION_CLEAN)
            {
                return;
            }

            foreach (UIHierarchyItem hierItem in VisualStudioHelpers.GetAllItemsFromSolutionExplorer(this.ApplicationObject.ToolWindows.SolutionExplorer))
            {
                if (hierItem.Name != null && hierItem.Name.ToLower().EndsWith(".bim"))
                {
                    Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandbox = TabularHelpers.GetTabularSandboxFromBimFile(this, false);
                    if (sandbox == null)
                    {
                        var sandboxEditor = TabularHelpers.GetTabularSandboxEditorFromBimFile(hierItem, true);
                        if (sandboxEditor != null)
                        {
                            sandbox = sandboxEditor.Sandbox;
                        }
                    }
                    if (sandbox != null)
                    {
#if !DENALI && !SQL2014
                        if (sandbox.IsTabularMetadata)
                        {
                            return;
                        }
#endif
                        List <BIDSHelperPluginBase> checks = new List <BIDSHelperPluginBase>();
                        foreach (BIDSHelperPluginBase plugin in BIDSHelperPackage.Plugins.Values)
                        {
                            Type t = plugin.GetType();
                            if (plugin is ITabularOnPreBuildAnnotationCheck &&
                                !t.IsInterface &&
                                !t.IsAbstract)
                            {
                                ITabularOnPreBuildAnnotationCheck check = (ITabularOnPreBuildAnnotationCheck)plugin;
                                if (check.TabularOnPreBuildAnnotationCheckPriority == TabularOnPreBuildAnnotationCheckPriority.HighPriority)
                                {
                                    checks.Insert(0, plugin); //insert the high priority checks at the front of the list so they get run first
                                }
                                else
                                {
                                    checks.Add(plugin);
                                }
                            }
                        }

                        foreach (BIDSHelperPluginBase plugin in checks)
                        {
                            ITabularOnPreBuildAnnotationCheck check = (ITabularOnPreBuildAnnotationCheck)plugin;
                            string sWarning = check.GetPreBuildWarning(sandbox);
                            if (sWarning != null)
                            {
                                if (MessageBox.Show(sWarning, "BIDS Helper Pre-Build Warning - " + plugin.FeatureName, MessageBoxButtons.OKCancel) == DialogResult.OK)
                                {
                                    Microsoft.VisualStudio.Project.Automation.OAFileItem project = hierItem.Object as Microsoft.VisualStudio.Project.Automation.OAFileItem;
                                    Window win = project.Open(EnvDTE.Constants.vsViewKindPrimary);
                                    win.Activate();
                                    check.FixPreBuildWarning(sandbox);
                                    project.Save(hierItem.Name);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #10
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;

                string sFileName = ((ProjectItem)hierItem.Object).Name.ToLower();

#if DENALI || SQL2014
                Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandbox = null;
#endif


                bool bIsTabular = false;
                Cube cub        = null;
                if (projItem.Object is Cube)
                {
                    cub = (Cube)projItem.Object;
                }
                else if (sFileName.EndsWith(".bim"))
                {
#if DENALI || SQL2014
                    sandbox    = TabularHelpers.GetTabularSandboxFromBimFile(hierItem, true);
                    cub        = sandbox.Cube;
                    bIsTabular = true;
                    Microsoft.AnalysisServices.BackEnd.IDataModelingObjectCollection <Microsoft.AnalysisServices.BackEnd.DataModelingMeasure> measures = sandbox.Measures;
#endif
                }
                else
                {
                    //if you are launching this feature from the Dimension Usage tab, but some other item in Solution Explorer is highlighted, then this code works and the above doesn't
                    projItem = this.ApplicationObject.ActiveWindow.ProjectItem;
                    cub      = (Cube)projItem.Object;
                }

                DialogResult res = MessageBox.Show("Would you like a detailed report?\r\n\r\nPress Yes to see a detailed dimension usage report.\r\n\r\nPress No to see a summary level Bus Matrix dimension usage report.", "BIDS Helper - Printer Friendly Dimension Usage - Which Report Type?", MessageBoxButtons.YesNo);

                ReportViewerForm frm = new ReportViewerForm();

                if (bIsTabular)
                {
#if DENALI || SQL2014
                    bool bIsBusMatrix = (res == DialogResult.No);
                    System.Collections.Generic.List <DimensionUsage> list = PrinterFriendlyDimensionUsage.GetTabularDimensionUsage(sandbox, bIsBusMatrix);
                    DeploymentSettings _deploymentSettings = new DeploymentSettings(projItem);

                    //reset the database and cube name per the deployment settings
                    foreach (DimensionUsage du in list)
                    {
                        du.DatabaseName = _deploymentSettings.TargetDatabase;
                        du.CubeName     = _deploymentSettings.TargetCubeName;
                    }

                    frm.ReportBindingSource.DataSource = list;
#endif
                }
                else
                {
                    frm.ReportBindingSource.DataSource = PrinterFriendlyDimensionUsage.GetDimensionUsage(cub);
                }

                if (res == DialogResult.No)
                {
                    frm.Report = "SSAS.PrinterFriendlyDimensionUsageBusMatrix.rdlc";
                }
                else
                {
                    frm.Report = "SSAS.PrinterFriendlyDimensionUsage.rdlc";
                }

                Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
                reportDataSource1.Name  = "BIDSHelper_DimensionUsage";
                reportDataSource1.Value = frm.ReportBindingSource;
                frm.ReportViewerControl.LocalReport.DataSources.Add(reportDataSource1);
                if (res == DialogResult.No)
                {
                    frm.ReportViewerControl.LocalReport.ReportEmbeddedResource = "BIDSHelper.PrinterFriendlyDimensionUsageBusMatrix.rdlc";
                    frm.Caption = "Printer Friendly Dimension Usage Bus Matrix";
                }
                else
                {
                    frm.ReportViewerControl.LocalReport.ReportEmbeddedResource = "BIDSHelper.PrinterFriendlyDimensionUsage.rdlc";
                    frm.Caption = "Printer Friendly Dimension Usage";
                }
                frm.Show();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }