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