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

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

        }