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