Ejemplo n.º 1
0
            public override ViewModelActionResult Do(IViewModelActionInstance actionInstance)
            {
                try
                {
                    Microsoft.AnalysisServices.BackEnd.DataModelingSandbox sandbox = TabularHelpers.GetTabularSandboxFromActiveWindow(_plugin.package);
                    if (sandbox == null)
                    {
                        throw new Exception("Can't get Sandbox!");
                    }
                    IServiceProvider provider = TabularHelpers.GetTabularServiceProviderFromActiveWindow(_plugin.package);

                    foreach (IViewModelNode node in actionInstance.Targets.OfType <IViewModelNode>())
                    {
                        _plugin.ExecuteSyncDescriptions(sandbox, provider, node.Text);
                    }
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
                }
                return(new ViewModelActionResult(null, (IViewModelObject)null));
            }
Ejemplo n.º 2
0
 public override void Consider(IViewModelActionInstance actionInstance)
 {
 }
Ejemplo n.º 3
0
 public override void Cancel(IViewModelActionInstance actionInstance)
 {
 }
Ejemplo n.º 4
0
 public override IShowMessageRequest Confirm(IViewModelActionInstance actionInstance)
 {
     return(null);
 }
Ejemplo n.º 5
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
            }