/// <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);
        }
        internal void ExecuteSyncDescriptions(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandbox, IServiceProvider provider, string tableName)
        {
            try
            {
                Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.AMOCode code = delegate
                {
                    int iDescriptionsSet;
                    Microsoft.AnalysisServices.BackEnd.SandboxTransactionProperties properties = new Microsoft.AnalysisServices.BackEnd.SandboxTransactionProperties();
                    properties.RecalcBehavior = Microsoft.AnalysisServices.BackEnd.TransactionRecalcBehavior.Default;
                    using (Microsoft.AnalysisServices.BackEnd.SandboxTransaction tran = sandbox.CreateTransaction(properties))
                    {
                        if (!TabularHelpers.EnsureDataSourceCredentials(sandbox))
                        {
                            MessageBox.Show("Cancelling Sync Descriptions because data source credentials were not entered.", "BIDS Helper Tabular Sync Descriptions - Cancelled!");
                            tran.RollbackAndContinue();
                            return;
                        }

                        Dimension d = sandbox.Database.Dimensions.GetByName(tableName);
                        iDescriptionsSet = SyncDescriptionsPlugin.SyncDescriptions(d, true, provider, true);
                        sandbox.Database.Update(UpdateOptions.ExpandFull);
                        tran.Commit();
                    }

                    MessageBox.Show("Set " + iDescriptionsSet + " descriptions successfully.", "BIDS Helper - Sync Descriptions");
                };
                sandbox.ExecuteAMOCode(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationType.Update, Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationCancellability.AlwaysExecute, code, true);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
            }
        }
        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);
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #4
0
        internal void SetHideMemberIf(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandbox, IEnumerable <Tuple <string, string, string> > hierarchyLevels, List <HideIfValue> newValues)
        {
            try
            {
                Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.AMOCode code = delegate
                {
                    Microsoft.AnalysisServices.BackEnd.SandboxTransactionProperties properties = new Microsoft.AnalysisServices.BackEnd.SandboxTransactionProperties();
                    properties.RecalcBehavior = Microsoft.AnalysisServices.BackEnd.TransactionRecalcBehavior.AlwaysRecalc;
                    List <Dimension> dims = new List <Dimension>();
                    using (Microsoft.AnalysisServices.BackEnd.SandboxTransaction tran = sandbox.CreateTransaction(properties))
                    {
                        if (!TabularHelpers.EnsureDataSourceCredentials(sandbox))
                        {
                            MessageBox.Show("Cancelling apply of HideMemberIf because data source credentials were not entered.", "BIDS Helper Tabular HideMemberIf - Cancelled!");
                            tran.RollbackAndContinue();
                            return;
                        }

                        SSAS.TabularHideMemberIfAnnotation annotation = GetAnnotation(sandbox);

                        foreach (Tuple <string, string, string> tuple in hierarchyLevels)
                        {
                            Dimension d = sandbox.Database.Dimensions.GetByName(tuple.Item1);
                            if (!dims.Contains(d))
                            {
                                dims.Add(d);
                            }
                            Hierarchy h = d.Hierarchies.GetByName(tuple.Item2);
                            Level     l = h.Levels.GetByName(tuple.Item3);
                            l.HideMemberIf = newValues[0];
                            newValues.RemoveAt(0);

                            annotation.Set(l);
                        }

                        TabularHelpers.SaveXmlAnnotation(sandbox.Database, HIDEMEMBERIF_ANNOTATION, annotation);

                        sandbox.Database.Update(UpdateOptions.ExpandFull);

                        //bug in AS2012 (still not working in RTM CU1) requires ProcessFull to successfully switch from HideMemberIf=Never to NoName
                        foreach (Dimension d in dims)
                        {
                            d.Process(ProcessType.ProcessFull);
                        }

                        tran.Commit();
                    }
                };
                sandbox.ExecuteAMOCode(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationType.Update, Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationCancellability.AlwaysExecute, code, true);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
            }
        }
 private SSAS.TabularTranslationsAnnotation GetAnnotation(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandbox)
 {
     SSAS.TabularTranslationsAnnotation annotation = new SSAS.TabularTranslationsAnnotation();
     if (sandbox.Database.Annotations.Contains(TRANSLATIONS_ANNOTATION))
     {
         string xml = TabularHelpers.GetAnnotationXml(sandbox.Database, TRANSLATIONS_ANNOTATION);
         System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(SSAS.TabularTranslationsAnnotation));
         annotation = (SSAS.TabularTranslationsAnnotation)serializer.Deserialize(new System.IO.StringReader(xml));
     }
     return(annotation);
 }
 public static SSAS.TabularDisplayFoldersAnnotation GetAnnotation(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandbox)
 {
     SSAS.TabularDisplayFoldersAnnotation annotation = new SSAS.TabularDisplayFoldersAnnotation();
     if (sandbox.Database.Annotations.Contains(DISPLAY_FOLDER_ANNOTATION))
     {
         string xml = TabularHelpers.GetAnnotationXml(sandbox.Database, DISPLAY_FOLDER_ANNOTATION);
         System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(SSAS.TabularDisplayFoldersAnnotation));
         annotation = (SSAS.TabularDisplayFoldersAnnotation)serializer.Deserialize(new System.IO.StringReader(xml));
     }
     return(annotation);
 }
 public static SSAS.TabularActionsAnnotation GetAnnotation(Cube cube)
 {
     SSAS.TabularActionsAnnotation annotation = new SSAS.TabularActionsAnnotation();
     if (cube.Annotations.Contains(SSAS.TabularActionsEditorForm.ACTION_ANNOTATION))
     {
         string xml = TabularHelpers.GetAnnotationXml(cube, SSAS.TabularActionsEditorForm.ACTION_ANNOTATION);
         System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(SSAS.TabularActionsAnnotation));
         annotation = (SSAS.TabularActionsAnnotation)serializer.Deserialize(new System.IO.StringReader(xml));
     }
     return(annotation);
 }
        private void ExecSandbox(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandboxParam)
        {
            try
            {
                sandbox = sandboxParam;
                if (sandbox == null)
                {
                    throw new Exception("Can't get Sandbox!");
                }
                cube = sandbox.Cube;
                if (cube == null)
                {
                    throw new Exception("The workspace database cube doesn't exist.");
                }

                SSAS.TabularActionsEditorForm form = new SSAS.TabularActionsEditorForm(cube, sandbox.AdomdConnection);
                if (form.ShowDialog() == DialogResult.OK)
                {
                    Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.AMOCode code = delegate
                    {
                        using (Microsoft.AnalysisServices.BackEnd.SandboxTransaction tran = sandbox.CreateTransaction())
                        {
                            foreach (Perspective p in cube.Perspectives)
                            {
                                p.Actions.Clear();
                            }
                            cube.Actions.Clear();
                            foreach (Microsoft.AnalysisServices.Action action in form.Actions())
                            {
                                cube.Actions.Add(action);
                                foreach (Perspective p in cube.Perspectives)
                                {
                                    if (form.ActionInPerspective(action.ID, p.ID))
                                    {
                                        p.Actions.Add(action.ID);
                                    }
                                }
                            }

                            TabularHelpers.SaveXmlAnnotation(cube, SSAS.TabularActionsEditorForm.ACTION_ANNOTATION, form.Annotation);

                            cube.Update(UpdateOptions.ExpandFull);
                            tran.Commit();
                        }
                    };
                    sandbox.ExecuteAMOCode(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationType.Update, Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationCancellability.AlwaysExecute, code, true);
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
            }
        }
Beispiel #9
0
        private void HookBimWindow(ProjectItem pi)
        {
            try
            {
                if (pi == null || pi.Name == null)
                {
                    return;
                }
                string sFileName = pi.Name.ToLower();
                if (!sFileName.EndsWith(".bim"))
                {
                    return;
                }

                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                if (((System.Array)solExplorer.SelectedItems).Length != 1)
                {
                    return;
                }

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

                SandboxEditor editor = TabularHelpers.GetTabularSandboxEditorFromProjectItem(pi, false);
                if (editor == null)
                {
                    return;
                }
#if !DENALI && !SQL2014
                // if the sandbox is in the new tabular metadata mode (JSON) then exit here
                if (editor.Sandbox.IsTabularMetadata)
                {
                    return;
                }
#endif
                Microsoft.AnalysisServices.Common.ERDiagram diagram = TabularHelpers.GetTabularERDiagramFromSandboxEditor(editor);
                if (diagram != null)
                {
                    SetupContextMenu(diagram);
                }
                else
                {
                    if (!_hookedSandboxEditors.Contains(editor))
                    {
                        editor.DiagramObjectsSelected += new EventHandler <ERDiagramSelectionChangedEventArgs>(editor_DiagramObjectsSelected);
                        _hookedSandboxEditors.Add(editor);
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
            }
        }
Beispiel #10
0
 private SSAS.TabularHideMemberIfAnnotation GetAnnotation(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandbox)
 {
     if (sandbox.Database.Annotations.Contains(HIDEMEMBERIF_ANNOTATION))
     {
         string xml = TabularHelpers.GetAnnotationXml(sandbox.Database, HIDEMEMBERIF_ANNOTATION);
         System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(BIDSHelper.SSAS.TabularHideMemberIfAnnotation));
         return((SSAS.TabularHideMemberIfAnnotation)serializer.Deserialize(new System.IO.StringReader(xml)));
     }
     else
     {
         return(new SSAS.TabularHideMemberIfAnnotation());
     }
 }
        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);
            }
        }
Beispiel #12
0
 internal HideIfValue GetHideMemberIf(IEnumerable <Tuple <string, string, string> > hierarchyLevels)
 {
     Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandbox = TabularHelpers.GetTabularSandboxFromActiveWindow();
     if (sandbox != null)
     {
         foreach (Tuple <string, string, string> tuple in hierarchyLevels)
         {
             Dimension d = sandbox.Database.Dimensions.GetByName(tuple.Item1);
             Hierarchy h = d.Hierarchies.GetByName(tuple.Item2);
             Level     l = h.Levels.GetByName(tuple.Item3);
             return(l.HideMemberIf);
         }
     }
     throw new Exception("Couldn't find HideMemberIf value.");
 }
        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);
        }
        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);
            }
        }
        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);
        }
            public override DiagramActionResult Do(IDiagramActionInstance actionInstance)
            {
                try
                {
                    Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandbox = TabularHelpers.GetTabularSandboxFromActiveWindow();
                    if (sandbox == null)
                    {
                        throw new Exception("Can't get Sandbox!");
                    }
                    IServiceProvider provider = TabularHelpers.GetTabularServiceProviderFromActiveWindow();

                    foreach (IDiagramNode node in actionInstance.Targets.OfType <IDiagramNode>())
                    {
                        _plugin.ExecuteSyncDescriptions(sandbox, provider, node.Text);
                    }
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
                }
                return(new DiagramActionResult(null, (IDiagramObject)null));
            }
Beispiel #18
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");
            }
        }
        private void HookBimWindow(ProjectItem pi)
        {
            try
            {
                if (pi == null || pi.Name == null)
                {
                    return;
                }
                string sFileName = pi.Name.ToLower();
                if (!sFileName.EndsWith(".bim"))
                {
                    return;
                }

                SandboxEditor editor = TabularHelpers.GetTabularSandboxEditorFromProjectItem(pi, false);
                if (editor == null)
                {
                    return;
                }
                Microsoft.AnalysisServices.Common.ERDiagram diagram = TabularHelpers.GetTabularERDiagramFromSandboxEditor(editor);
                if (diagram != null)
                {
                    SetupContextMenu(diagram);
                }
                else
                {
                    if (!_hookedSandboxEditors.Contains(editor))
                    {
                        editor.DiagramObjectsSelected += new EventHandler <ERDiagramSelectionChangedEventArgs>(editor_DiagramObjectsSelected);
                        _hookedSandboxEditors.Add(editor);
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
            }
        }
        private void AlterDatabase(List <SSAS.TabularTranslatedItem> translatedItems)
        {
            Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.AMOCode code = delegate
            {
                using (Microsoft.AnalysisServices.BackEnd.SandboxTransaction tran = sandbox.CreateTransaction())
                {
                    SSAS.TabularTranslationsAnnotation             annotation      = new SSAS.TabularTranslationsAnnotation();
                    List <SSAS.TabularTranslationObjectAnnotation> annotationsList = new List <SSAS.TabularTranslationObjectAnnotation>();
                    foreach (SSAS.TabularTranslatedItem item in translatedItems)
                    {
                        item.Save(annotationsList);
                    }
                    annotation.TabularTranslations = annotationsList.ToArray();
                    TabularHelpers.SaveXmlAnnotation(cube.Parent, TRANSLATIONS_ANNOTATION, annotation);

                    TabularHelpers.EnsureDataSourceCredentials(sandbox);
                    cube.Parent.Update(UpdateOptions.ExpandFull);

                    tran.Commit();
                }
            };
            sandbox.ExecuteAMOCode(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationType.Update, Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationCancellability.AlwaysExecute, code, true);
        }
Beispiel #21
0
        private void ShowDiff(string oldFile, string newFile, bool bIgnoreCase, bool bIgnoreEOL, bool bIgnoreWhiteSpace, string sOldFileName, string sNewFileName)
        {
            string sCustomDiffViewer = CustomDiffViewer;

            if (!string.IsNullOrEmpty(sCustomDiffViewer))
            {
                try
                {
                    int iOldFile = sCustomDiffViewer.IndexOf('?');
                    int iNewFile = sCustomDiffViewer.LastIndexOf('?');
                    sCustomDiffViewer = sCustomDiffViewer.Substring(0, iOldFile) + '"' + oldFile + '"' + sCustomDiffViewer.Substring(iOldFile + 1, iNewFile - iOldFile - 1) + '"' + newFile + '"' + sCustomDiffViewer.Substring(iNewFile + 1);
                    Microsoft.VisualBasic.Interaction.Shell(sCustomDiffViewer, Microsoft.VisualBasic.AppWinStyle.MaximizedFocus, true, -1);
                    return;
                }
                catch (Exception ex)
                {
                    throw new Exception("There was a problem using the custom diff viewer: " + sCustomDiffViewer, ex);
                }
            }


            //try the VS2012 built-in diff viewer
            string sVS2012Error = string.Empty;

#if DENALI || SQL2014
            if (this.ApplicationObject.Version.CompareTo("11.") == 1 || this.ApplicationObject.Version.CompareTo("12.") == 1)
            {
                try
                {
                    System.Reflection.Assembly vsAssembly = System.Reflection.Assembly.Load(VS2012_SHELL_INTEROP_ASSEMBLY_FULL_NAME);

                    UIHierarchy     solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                    UIHierarchyItem hierItem    = (UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0);
                    ProjectItem     projItem    = (ProjectItem)hierItem.Object;
                    string          sTabName    = projItem.Name + " (BIDS Helper Smart Diff)";

                    System.IServiceProvider provider = null;
                    if (projItem.ContainingProject is System.IServiceProvider)
                    {
                        provider = (System.IServiceProvider)projItem.ContainingProject;
                    }
                    else
                    {
                        provider = TabularHelpers.GetTabularServiceProviderFromBimFile(hierItem, false);
                    }
                    //TODO: test .rdlc inside C# projects

                    Type   t = vsAssembly.GetType("Microsoft.VisualStudio.Shell.Interop.IVsDifferenceService");
                    object oVsDifferenceService = provider.GetService(vsAssembly.GetType("Microsoft.VisualStudio.Shell.Interop.SVsDifferenceService"));
                    Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame frame = (Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame)t.InvokeMember("OpenComparisonWindow2", System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance, null, oVsDifferenceService, new object[] { oldFile, newFile, sTabName, "BIDS Helper Smart Diff", sOldFileName, sNewFileName, "", "", (uint)0 });

                    return;
                }
                catch (Exception exVS2012)
                {
                    sVS2012Error = exVS2012.Message;
                }
            }
#endif

            int    fFlags = 0;
            string sFlags = "";
            if (bIgnoreCase)
            {
                fFlags |= 1;
                sFlags += " -ic";
            }
            if (bIgnoreEOL)
            {
                fFlags |= 4;
                sFlags += " -ie";
            }
            if (bIgnoreWhiteSpace)
            {
                fFlags |= 2;
                sFlags += " -iw";
            }

            try
            {
                MSDiff_ShowDiffUI(IntPtr.Zero, oldFile, newFile, fFlags, sOldFileName, sNewFileName);
                MSDiff_Cleanup();
            }
            catch (Exception exMSDiff)
            {
                //couldn't use MSDiff (which gets intalled with TFS2010 and below)
                //try VSS EXE
                try
                {
                    string sVSSDir = VSSInstallDir;
                    if (string.IsNullOrEmpty(sVSSDir))
                    {
                        throw new Exception("");
                    }
                    else
                    {
                        Microsoft.VisualBasic.Interaction.Shell("\"" + sVSSDir + "ssexp.exe\" /diff" + sFlags + " \"" + oldFile + "\" \"" + newFile + "\"", Microsoft.VisualBasic.AppWinStyle.MaximizedFocus, true, -1);
                    }
                }
                catch (Exception exVSS)
                {
                    if (!string.IsNullOrEmpty(sVS2012Error))
                    {
                        sVS2012Error = "\r\n\r\nCould not use the built-in Visual Studio diff viewer:\r\n" + sVS2012Error;
                    }
                    throw new Exception("Could not start Microsoft Visual SourceSafe 2005 to view diff. " + exVSS.Message + "\r\n\r\nCould not utilize Microsoft Team Foundation Server to view diff. " + exMSDiff.Message + sVS2012Error);
                }
            }
        }
        private void ExecSandbox(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandboxParam)
        {
            try
            {
                sandbox = sandboxParam;
                if (sandbox == null)
                {
                    throw new Exception("Can't get Sandbox!");
                }
                cube = sandbox.Cube;
                if (cube == null)
                {
                    throw new Exception("The workspace database cube doesn't exist.");
                }

                bool bRestoreDisplayFolders = false;
                SSAS.TabularDisplayFoldersAnnotation annotationSaved = GetAnnotation(sandbox);
                if (GetPreBuildWarning(sandbox) != null)
                {
                    if (MessageBox.Show("Some display folders have been blanked out by other editing operations. Restoring display folders may be possible except when a measures or columns have been renamed.\r\n\r\nWould you like BIDS Helper to attempt restore the display folders now?", "BIDS Helper Tabular Display Folders", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        bRestoreDisplayFolders = true;
                    }
                }

                SSAS.TabularDisplayFolderWindow form = new SSAS.TabularDisplayFolderWindow();

                List <BIDSHelper.SSAS.TabularDisplayFolder> displayFolders = new List <BIDSHelper.SSAS.TabularDisplayFolder>();

                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);

                Database db = cube.Parent;
                foreach (Dimension d in db.Dimensions)
                {
                    foreach (DimensionAttribute da in d.Attributes)
                    {
                        if (da.Type != AttributeType.RowNumber && da.AttributeHierarchyVisible)
                        {
                            if (bRestoreDisplayFolders && string.IsNullOrEmpty(da.AttributeHierarchyDisplayFolder))
                            {
                                SSAS.TabularDisplayFolderAnnotation a = annotationSaved.Find(da);
                                if (a != null)
                                {
                                    da.AttributeHierarchyDisplayFolder = a.DisplayFolder;
                                }
                            }
                            displayFolders.Add(new BIDSHelper.SSAS.TabularDisplayFolder(d.Name, da));
                        }
                    }
                    foreach (Hierarchy h in d.Hierarchies)
                    {
                        if (bRestoreDisplayFolders && string.IsNullOrEmpty(h.DisplayFolder))
                        {
                            SSAS.TabularDisplayFolderAnnotation a = annotationSaved.Find(h);
                            if (a != null)
                            {
                                h.DisplayFolder = a.DisplayFolder;
                            }
                        }
                        displayFolders.Add(new BIDSHelper.SSAS.TabularDisplayFolder(d.Name, h));
                    }
                }
                foreach (Cube c in db.Cubes)
                {
                    foreach (MdxScript mdx in c.MdxScripts)
                    {
                        foreach (CalculationProperty calc in mdx.CalculationProperties)
                        {
                            if (calc.Visible && !calc.CalculationReference.StartsWith("KPIs.")) //TODO: display folder for KPIs have to be set inline in MDX script... do this in the future
                            {
                                string sTableName = null;
                                foreach (DataRow r in datasetMeasures.Tables[0].Rows)
                                {
                                    if (Convert.ToString(r["MEASURE_UNIQUE_NAME"]) == "[Measures]." + calc.CalculationReference)
                                    {
                                        sTableName = Convert.ToString(r["MEASUREGROUP_NAME"]);
                                        break;
                                    }
                                }

                                if (bRestoreDisplayFolders && string.IsNullOrEmpty(calc.DisplayFolder))
                                {
                                    SSAS.TabularDisplayFolderAnnotation a = annotationSaved.Find(calc);
                                    if (a != null)
                                    {
                                        calc.DisplayFolder = a.DisplayFolder;
                                    }
                                }

                                displayFolders.Add(new BIDSHelper.SSAS.TabularDisplayFolder(sTableName, calc));
                            }
                        }
                    }
                }

                displayFolders.Sort();
                form.dataGrid1.ItemsSource = displayFolders;



                if (form.ShowDialog() == true)
                {
                    //count dirty changes and create annotation
                    SSAS.TabularDisplayFoldersAnnotation       annotation            = new SSAS.TabularDisplayFoldersAnnotation();
                    List <SSAS.TabularDisplayFolderAnnotation> folderAnnotationsList = new List <SSAS.TabularDisplayFolderAnnotation>();
                    int iNumberOfChanges = 0;
                    foreach (BIDSHelper.SSAS.TabularDisplayFolder folder in displayFolders)
                    {
                        if (folder.Dirty)
                        {
                            iNumberOfChanges++;
                        }
                        if (!string.IsNullOrEmpty(folder.DisplayFolder))
                        {
                            SSAS.TabularDisplayFolderAnnotation folderAnnotation = new SSAS.TabularDisplayFolderAnnotation();
                            folderAnnotation.TableID       = cube.Parent.Dimensions.GetByName(folder.Table).ID;
                            folderAnnotation.ObjectID      = folder.ObjectID;
                            folderAnnotation.ObjectType    = folder.ObjectType;
                            folderAnnotation.DisplayFolder = folder.DisplayFolder;
                            folderAnnotationsList.Add(folderAnnotation);
                        }
                    }
                    annotation.TabularDisplayFolders = folderAnnotationsList.ToArray();

                    if (iNumberOfChanges > 0 || bRestoreDisplayFolders)
                    {
                        Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.AMOCode code = delegate
                        {
                            using (Microsoft.AnalysisServices.BackEnd.SandboxTransaction tran = sandbox.CreateTransaction())
                            {
                                foreach (BIDSHelper.SSAS.TabularDisplayFolder folder in displayFolders)
                                {
                                    folder.SaveDisplayFolder();
                                }
                                TabularHelpers.SaveXmlAnnotation(cube.Parent, DISPLAY_FOLDER_ANNOTATION, annotation);

                                TabularHelpers.EnsureDataSourceCredentials(sandbox);
                                cube.Parent.Update(UpdateOptions.ExpandFull);

                                tran.Commit();
                            }
                        };
                        sandbox.ExecuteAMOCode(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationType.Update, Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationCancellability.AlwaysExecute, code, true);
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
            }
        }
        private void ExecSandbox(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandboxParam)
        {
            try
            {
#if DENALI || SQL2014
                var sb   = sandboxParam;
                var conn = sandboxParam.AdomdConnection;
#elif SQL2017
                var sb        = (Microsoft.AnalysisServices.BackEnd.DataModelingSandboxAmo)sandboxParam.Impl;
                var localConn = sandboxParam.AdomdConnection;
                var conn      = new localAdomdClient.Microsoft.AnalysisServices.AdomdClient.AdomdConnection(localConn.ConnectionString);
#else
                var sb        = (Microsoft.AnalysisServices.BackEnd.DataModelingSandboxAmo)sandboxParam.Impl;
                var localConn = sandboxParam.AdomdConnection;
                var conn      = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection(localConn.ConnectionString);
#endif

                if (sb == null)
                {
                    throw new Exception("Can't get Sandbox!");
                }
                cube = sb.Cube;
                if (cube == null)
                {
                    throw new Exception("The workspace database cube doesn't exist.");
                }


                SSAS.TabularActionsEditorForm form = new SSAS.TabularActionsEditorForm(cube, conn);
                if (form.ShowDialog() == DialogResult.OK)
                {
#if DENALI || SQL2014
                    Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.AMOCode code;
#else
                    Microsoft.AnalysisServices.BackEnd.AMOCode code;
#endif
                    code = delegate
                    {
                        using (Microsoft.AnalysisServices.BackEnd.SandboxTransaction tran = sandbox.CreateTransaction())
                        {
                            foreach (Perspective p in cube.Perspectives)
                            {
                                p.Actions.Clear();
                            }
                            cube.Actions.Clear();
                            foreach (Microsoft.AnalysisServices.Action action in form.Actions())
                            {
                                cube.Actions.Add(action);
                                foreach (Perspective p in cube.Perspectives)
                                {
                                    if (form.ActionInPerspective(action.ID, p.ID))
                                    {
                                        p.Actions.Add(action.ID);
                                    }
                                }
                            }

                            TabularHelpers.SaveXmlAnnotation(cube, SSAS.TabularActionsEditorForm.ACTION_ANNOTATION, form.Annotation);

                            cube.Update(UpdateOptions.ExpandFull);
                            tran.GetType().InvokeMember("Commit", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Public, null, tran, null);     //The .Commit() function used to return a list of strings, but in the latest set of code it is a void method which leads to "method not found" errors
                            //tran.Commit();
                        }
                    };
#if DENALI || SQL2014
                    sandbox.ExecuteAMOCode(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationType.Update, Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationCancellability.AlwaysExecute, code, true);
#else
                    sandboxParam.ExecuteEngineCode(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationType.Update, Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationCancellability.AlwaysExecute, code, true);
#endif
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
            }
        }
Beispiel #24
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);
            }
        }
Beispiel #25
0
        internal void SetHideMemberIf(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandboxParam, IEnumerable <Tuple <string, string, string> > hierarchyLevels, List <HideIfValue> newValues)
        {
            try
            {
#if DENALI || SQL2014
                Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.AMOCode code;
                var sandbox = sandboxParam;
#else
                Microsoft.AnalysisServices.BackEnd.AMOCode code;
                var sandbox = (Microsoft.AnalysisServices.BackEnd.DataModelingSandboxAmo)sandboxParam.Impl;
#endif
                code = delegate
                {
                    Microsoft.AnalysisServices.BackEnd.SandboxTransactionProperties properties = new Microsoft.AnalysisServices.BackEnd.SandboxTransactionProperties();
                    properties.RecalcBehavior = Microsoft.AnalysisServices.BackEnd.TransactionRecalcBehavior.AlwaysRecalc;
                    List <Dimension> dims = new List <Dimension>();
                    using (Microsoft.AnalysisServices.BackEnd.SandboxTransaction tran = sandboxParam.CreateTransaction(properties))
                    {
                        if (!TabularHelpers.EnsureDataSourceCredentials(sandboxParam))
                        {
                            MessageBox.Show("Cancelling apply of HideMemberIf because data source credentials were not entered.", "BIDS Helper Tabular HideMemberIf - Cancelled!");
                            tran.RollbackAndContinue();
                            return;
                        }

                        SSAS.TabularHideMemberIfAnnotation annotation = GetAnnotation(sandboxParam);

                        foreach (Tuple <string, string, string> tuple in hierarchyLevels)
                        {
                            Dimension d = sandbox.Database.Dimensions.GetByName(tuple.Item1);
                            if (!dims.Contains(d))
                            {
                                dims.Add(d);
                            }
                            Hierarchy h = d.Hierarchies.GetByName(tuple.Item2);
                            Level     l = h.Levels.GetByName(tuple.Item3);
                            l.HideMemberIf = newValues[0];
                            newValues.RemoveAt(0);

                            annotation.Set(l);
                        }

                        TabularHelpers.SaveXmlAnnotation(sandbox.Database, HIDEMEMBERIF_ANNOTATION, annotation);

                        sandbox.Database.Update(UpdateOptions.ExpandFull);

                        //bug in AS2012 (still not working in RTM CU1) requires ProcessFull to successfully switch from HideMemberIf=Never to NoName
                        foreach (Dimension d in dims)
                        {
                            d.Process(ProcessType.ProcessFull);
                        }

                        tran.GetType().InvokeMember("Commit", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Public, null, tran, null);     //The .Commit() function used to return a list of strings, but in the latest set of code it is a void method which leads to "method not found" errors
                        //tran.Commit();
                    }
                };
#if DENALI || SQL2014
                sandbox.ExecuteAMOCode(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationType.Update, Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationCancellability.AlwaysExecute, code, true);
#else
                sandboxParam.ExecuteEngineCode(Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationType.Update, Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.OperationCancellability.AlwaysExecute, code, true);
#endif
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
            }
        }
Beispiel #26
0
            public override ViewModelActionResult Do(IViewModelActionInstance actionInstance)
#endif
            {
                try
                {
#if DENALI || SQL2014
                    IEnumerable <Tuple <string, string, string> > hierarchyLevels = this.SortHierarchyLevels(actionInstance.Targets.OfType <IDiagramNode>());
#else
                    IEnumerable <Tuple <string, string, string> > hierarchyLevels = this.SortHierarchyLevels(actionInstance.Targets.OfType <IViewModelNode>());
#endif

                    Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandbox = TabularHelpers.GetTabularSandboxFromActiveWindow(_plugin.package);
                    if (sandbox == null)
                    {
                        throw new Exception("Can't get Sandbox!");
                    }

                    string sWarning = _plugin.GetPreBuildWarning(sandbox);
                    if (sWarning != null)
                    {
                        if (MessageBox.Show(sWarning, "BIDS Helper Tabular HideMemberIf", MessageBoxButtons.OKCancel) == DialogResult.OK)
                        {
                            _plugin.FixPreBuildWarning(sandbox);
                        }
                    }


                    Microsoft.AnalysisServices.HideIfValue currentValue = _plugin.GetHideMemberIf(hierarchyLevels);

                    form               = new Form();
                    form.Icon          = BIDSHelper.Resources.Common.BIDSHelper;
                    form.Text          = "BIDS Helper Tabular HideMemberIf Editor";
                    form.MaximizeBox   = true;
                    form.MinimizeBox   = false;
                    form.Width         = 400;
                    form.Height        = 150;
                    form.SizeGripStyle = SizeGripStyle.Hide;
                    form.MinimumSize   = new System.Drawing.Size(form.Width, form.Height);

                    Label labelAnnotation = new Label();
                    labelAnnotation.Text      = "HideMemberIf:";
                    labelAnnotation.Top       = 25;
                    labelAnnotation.Left      = 5;
                    labelAnnotation.Width     = 80;
                    labelAnnotation.Anchor    = AnchorStyles.Left | AnchorStyles.Top;
                    labelAnnotation.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
                    form.Controls.Add(labelAnnotation);

                    ComboBox combo = new ComboBox();
                    combo.DropDownStyle = ComboBoxStyle.DropDownList;
                    combo.Width         = form.Width - 40 - labelAnnotation.Width;
                    combo.Left          = labelAnnotation.Right + 5;
                    combo.Top           = 25;
                    combo.Anchor        = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
                    form.Controls.Add(combo);
                    combo.Items.AddRange(Enum.GetNames(typeof(HideIfValue)));
                    combo.SelectedIndex = combo.Items.IndexOf(currentValue.ToString());

                    labelAnnotation           = new Label();
                    labelAnnotation.Text      = "BIDS Helper will ProcessFull this table when you click OK.";
                    labelAnnotation.Top       = combo.Bottom + 10;
                    labelAnnotation.Left      = 5;
                    labelAnnotation.Width     = form.Width;
                    labelAnnotation.Anchor    = AnchorStyles.Left | AnchorStyles.Top;
                    labelAnnotation.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                    form.Controls.Add(labelAnnotation);

                    Button okButton = new Button();
                    okButton.Text   = "OK";
                    okButton.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
                    okButton.Left   = form.Right - okButton.Width * 2 - 40;
                    okButton.Top    = form.Bottom - okButton.Height * 2 - 20;
                    okButton.Click += new EventHandler(okButton_Click);
                    form.Controls.Add(okButton);
                    form.AcceptButton = okButton;

                    Button cancelButton = new Button();
                    cancelButton.Text   = "Cancel";
                    cancelButton.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
                    cancelButton.Left   = okButton.Right + 10;
                    cancelButton.Top    = okButton.Top;
                    form.CancelButton   = cancelButton;
                    form.Controls.Add(cancelButton);

                    DialogResult result = form.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        //build a list of HideIfValue enums the same length as the list of levels
                        HideIfValue        val  = (HideIfValue)Enum.Parse(typeof(HideIfValue), combo.SelectedItem.ToString());
                        List <HideIfValue> vals = new List <HideIfValue>();
                        foreach (Tuple <string, string, string> level in hierarchyLevels)
                        {
                            vals.Add(val);
                        }

                        //set the value
                        _plugin.SetHideMemberIf(sandbox, hierarchyLevels, vals);
                    }
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
                }
#if DENALI || SQL2014
                return(new DiagramActionResult(null, (IDiagramObject)null));
#else
                return(new ViewModelActionResult(null, (IViewModelObject)null));
#endif
            }
        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);
                                }
                            }
                        }
                    }
                }
            }
        }