public TabularTranslatedItem(string table, IModelComponent obj, TabularTranslatedItemProperty property, TabularTranslatedItem caption, SSAS.TabularTranslationsAnnotation annotations) { _Table = table; _object = obj; _Property = property; TranslationCollection translations; string sCaption; string sDescription; string sDisplayFolder = null; if (obj is DimensionAttribute) { _ObjectType = TabularTranslatedItemType.Column; DimensionAttribute typedobj = (DimensionAttribute)obj; translations = typedobj.Translations; sDisplayFolder = typedobj.AttributeHierarchyDisplayFolder; sCaption = typedobj.Name; sDescription = typedobj.Description; } else if (obj is Hierarchy) { _ObjectType = TabularTranslatedItemType.Hierarchy; Hierarchy typedobj = (Hierarchy)obj; translations = typedobj.Translations; sDisplayFolder = typedobj.DisplayFolder; sCaption = typedobj.Name; sDescription = typedobj.Description; } else if (obj is Level) { _ObjectType = TabularTranslatedItemType.Level; Level typedobj = (Level)obj; translations = typedobj.Translations; sCaption = typedobj.Name; sDescription = typedobj.Description; } else if (obj is CalculationProperty) { _ObjectType = TabularTranslatedItemType.Measure; CalculationProperty typedobj = (CalculationProperty)obj; translations = typedobj.Translations; sDisplayFolder = typedobj.DisplayFolder; sCaption = typedobj.CalculationReference; sDescription = typedobj.Description; if (sCaption.StartsWith("[") && sCaption.EndsWith("]")) { sCaption = sCaption.Substring(1, sCaption.Length - 2); } } else if (obj is Database) { _ObjectType = TabularTranslatedItemType.Database; Database typedobj = (Database)obj; translations = typedobj.Translations; sCaption = typedobj.Name; sDescription = typedobj.Description; } else if (obj is Cube) { _ObjectType = TabularTranslatedItemType.Cube; Cube typedobj = (Cube)obj; translations = typedobj.Translations; sCaption = typedobj.Name; sDescription = typedobj.Description; } else if (obj is Perspective) { _ObjectType = TabularTranslatedItemType.Perspective; Perspective typedobj = (Perspective)obj; translations = typedobj.Translations; sCaption = typedobj.Name; sDescription = typedobj.Description; } else if (obj is Dimension) { _ObjectType = TabularTranslatedItemType.Table; Dimension typedobj = (Dimension)obj; translations = typedobj.Translations; sCaption = typedobj.Name; sDescription = typedobj.Description; } else if (obj is Microsoft.AnalysisServices.Action) { _ObjectType = TabularTranslatedItemType.Action; Microsoft.AnalysisServices.Action typedobj = (Microsoft.AnalysisServices.Action)obj; translations = typedobj.Translations; sCaption = typedobj.Name; sDescription = typedobj.Description; } else { throw new Exception("Unexpected object type: " + obj.GetType().Name); } _ObjectName = sCaption; if (property == TabularTranslatedItemProperty.Caption) { _DefaultLanguage = sCaption; SSAS.TabularTranslationObjectAnnotation annotation = annotations.Find(obj); if (annotation != null && translations.Count == 0) { foreach (SSAS.TabularTranslationAnnotation tranAnnotation in annotation.TabularTranslations) { Translation t = new Translation(tranAnnotation.Language); if (obj is DimensionAttribute) { t = new AttributeTranslation(tranAnnotation.Language); } t.Caption = tranAnnotation.Caption; t.Description = tranAnnotation.Description; t.DisplayFolder = tranAnnotation.DisplayFolder; translations.Add(t); } _restoredTranslations = true; } } else if (property == TabularTranslatedItemProperty.Description) { _DefaultLanguage = sDescription; } else if (property == TabularTranslatedItemProperty.DisplayFolder) { _DefaultLanguage = sDisplayFolder; } Languages = new Core.DirtyMonitoredDictionary <int, string>(); foreach (Translation t in translations) { if (property == TabularTranslatedItemProperty.Caption) { Languages.Add(t.Language, t.Caption); } else if (property == TabularTranslatedItemProperty.Description) { Languages.Add(t.Language, t.Description); } else if (property == TabularTranslatedItemProperty.DisplayFolder) { Languages.Add(t.Language, t.DisplayFolder); } } if (caption != null) { caption.DependentProperties.Add(this); } }
public void Save(List <SSAS.TabularTranslationObjectAnnotation> annotationsList) { if (_Property != TabularTranslatedItemProperty.Caption) { return; //every object will have a caption, so only perform the save on the caption } Dictionary <int, string> DisplayFolderLanguages = new Dictionary <int, string>(); Dictionary <int, string> DescriptionLanguages = new Dictionary <int, string>(); bool bDependentPropertyDirty = false; foreach (TabularTranslatedItem dependent in DependentProperties) { bDependentPropertyDirty = bDependentPropertyDirty || dependent.Dirty; if (dependent.Property == TabularTranslatedItemProperty.DisplayFolder) { DisplayFolderLanguages = dependent.Languages; } else if (dependent.Property == TabularTranslatedItemProperty.Description) { DescriptionLanguages = dependent.Languages; } } //if (!Dirty && !bDependentPropertyDirty) return; //would be nice if we could short-circuit here, but we need to build the annotation SSAS.TabularTranslationObjectAnnotation annotation = new TabularTranslationObjectAnnotation(); annotation.ObjectType = _ObjectType; if (_object is DimensionAttribute) { DimensionAttribute da = (DimensionAttribute)_object; annotation.ObjectID = da.ID; annotation.TableID = da.Parent.ID; SaveInternal(da.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation); } else if (_object is Hierarchy) { Hierarchy h = (Hierarchy)_object; annotation.ObjectID = h.ID; annotation.TableID = h.Parent.ID; SaveInternal(h.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation); } else if (_object is Level) { Level l = (Level)_object; annotation.ObjectID = l.ID; annotation.HierarchyID = l.Parent.ID; annotation.TableID = l.ParentDimension.ID; SaveInternal(l.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation); } else if (_object is CalculationProperty) { CalculationProperty calc = (CalculationProperty)_object; annotation.ObjectID = _ObjectName; //no need to save table SaveInternal(calc.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation); } else if (_object is Database) { Database db = (Database)_object; annotation.ObjectID = db.ID; SaveInternal(db.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation); } else if (_object is Cube) { Cube cube = (Cube)_object; annotation.ObjectID = cube.ID; SaveInternal(cube.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation); } else if (_object is Perspective) { Perspective p = (Perspective)_object; annotation.ObjectID = p.ID; SaveInternal(p.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation); } else if (_object is Dimension) { Dimension dim = (Dimension)_object; annotation.ObjectID = dim.ID; SaveInternal(dim.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation); foreach (Cube cube in dim.Parent.Cubes) { foreach (CubeDimension cd in cube.Dimensions) { if (cd.DimensionID == dim.ID) { SaveInternal(cd.Translations, DisplayFolderLanguages, DescriptionLanguages, null); } } foreach (MeasureGroup mg in cube.MeasureGroups) { if (mg.ID == dim.ID) { SaveInternal(mg.Translations, DisplayFolderLanguages, DescriptionLanguages, null); } } } } else if (_object is Microsoft.AnalysisServices.Action) { Microsoft.AnalysisServices.Action actionMaster = (Microsoft.AnalysisServices.Action)_object; foreach (Microsoft.AnalysisServices.Action action in actionMaster.Parent.Actions) { if (action.ID.StartsWith(actionMaster.ID)) { annotation.ObjectID = action.ID; SaveInternal(action.Translations, DisplayFolderLanguages, DescriptionLanguages, annotation); } } } else { throw new Exception("Unexpected object type: " + _object.GetType().Name); } if (annotation.TabularTranslations.Length > 0) { annotationsList.Add(annotation); } }
public override void OnWindowActivated(Window GotFocus, Window LostFocus) { try { package.Log.Debug("TriStatPerspectives OnWindowActivated fired"); if (GotFocus == null) { return; } IDesignerHost designer = GotFocus.Object as IDesignerHost; if (designer == null) { return; } ProjectItem pi = GotFocus.ProjectItem; if ((pi == null) || (!(pi.Object is Cube))) { return; } EditorWindow win = (EditorWindow)designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator)); VsStyleToolBar toolbar = (VsStyleToolBar)win.SelectedView.GetType().InvokeMember("ToolBar", getflags, null, win.SelectedView, null); Cube cube = (Cube)pi.Object; IntPtr ptr = win.Handle; string sHandle = ptr.ToInt64().ToString(); if (!windowHandlesFixedForPerspectives.ContainsKey(sHandle)) { windowHandlesFixedForPerspectives.Add(sHandle, win); win.ActiveViewChanged += new EventHandler(win_ActiveViewChanged); } //if (win.SelectedView.Caption == "Perspectives") if (win.SelectedView.MenuItemCommandID.ID == (int)BIDSViewMenuItemCommandID.Perspectives) { Microsoft.AnalysisServices.Design.Scripts mdxScriptCache = new Microsoft.AnalysisServices.Design.Scripts(cube); Control perspectiveBuilder = (Control)win.SelectedView.GetType().InvokeMember("ViewControl", getflags, null, win.SelectedView, null); //Microsoft.AnalysisServices.Design.PerspectivesBuilder Control grid = perspectiveBuilder.Controls[0]; //Microsoft.SqlServer.Management.UI.Grid.DlgGridControl if (!windowHandlesFixedForGridEvents.ContainsKey(sHandle)) { grid.MouseClick += new MouseEventHandler(grid_MouseClick); grid.KeyPress += new KeyPressEventHandler(grid_KeyPress); #if !(YUKON || KATMAI) _IsMetroOrGreater = VisualStudioHelpers.IsMetroOrGreater(win); HookCellPaintEvent(grid, true); #endif windowHandlesFixedForGridEvents.Add(sHandle, win); } System.Reflection.BindingFlags getpropertyflags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance; object dlgStorage = null; #if !(YUKON) dlgStorage = grid.GetType().BaseType.BaseType.InvokeMember("DlgStorage", getpropertyflags, null, grid, null); #else dlgStorage = grid.GetType().BaseType.InvokeMember("DlgStorage", getpropertyflags, null, grid, null); //Microsoft.SqlServer.Management.UI.Grid.IDlgStorage #endif object storage = dlgStorage.GetType().InvokeMember("Storage", getpropertyflags, null, dlgStorage, null); //Microsoft.SqlServer.Management.UI.Grid.MemDataStorage System.Reflection.BindingFlags getfieldflags = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance; ArrayList rows = (ArrayList)storage.GetType().BaseType.InvokeMember("m_arrRows", getfieldflags, null, storage, new object[] { }); //ArrayList columns = (ArrayList)storage.GetType().BaseType.InvokeMember("m_arrColumns", getfieldflags, null, storage, new object[] { }); object[] perspectivesColumns = (object[])rows[0]; ArrayList allGridCubeObjects = (ArrayList)perspectiveBuilder.GetType().InvokeMember("allGridCubeObjects", getfieldflags, null, perspectiveBuilder, null); for (int i = 3; i < rows.Count; i++) { object[] columns = (object[])rows[i]; object cell = columns[2]; //Microsoft.SqlServer.Management.UI.Grid.GridCell string rowObjectType = (string)cell.GetType().InvokeMember("CellData", getpropertyflags, null, cell, null); if (rowObjectType == "MeasureGroup") { cell = columns[1]; string rowObjectName = (string)cell.GetType().InvokeMember("CellData", getpropertyflags, null, cell, null); MeasureGroup mg = cube.MeasureGroups.GetByName(rowObjectName); for (int j = 3; j < columns.Length; j += 2) { cell = perspectivesColumns[j + 1]; string perspectiveName = (string)cell.GetType().InvokeMember("CellData", getpropertyflags, null, cell, null); Perspective perspective = cube.Perspectives.GetByName(perspectiveName); cell = columns[j]; bool bHighlight = false; if (perspective.MeasureGroups.Contains(mg.ID)) { PerspectiveMeasureGroup pmg = perspective.MeasureGroups[mg.ID]; foreach (Measure m in mg.Measures) { if (m.Visible && !pmg.Measures.Contains(m.ID)) { bHighlight = true; break; } } } HighlightCell(bHighlight, columns, cell, j); } } else if (rowObjectType == "CubeDimension") { cell = columns[1]; string rowObjectName = (string)cell.GetType().InvokeMember("CellData", getpropertyflags, null, cell, null); CubeDimension cd = cube.Dimensions.GetByName(rowObjectName); for (int j = 3; j < columns.Length; j += 2) { cell = perspectivesColumns[j + 1]; string perspectiveName = (string)cell.GetType().InvokeMember("CellData", getpropertyflags, null, cell, null); Perspective perspective = cube.Perspectives.GetByName(perspectiveName); cell = columns[j]; bool bHighlight = false; if (perspective.Dimensions.Contains(cd.ID)) { PerspectiveDimension pcd = perspective.Dimensions[cd.ID]; foreach (CubeHierarchy h in cd.Hierarchies) { if (h.Visible && h.Enabled && !pcd.Hierarchies.Contains(h.HierarchyID)) { bHighlight = true; break; } } if (!bHighlight) { foreach (CubeAttribute a in cd.Attributes) { if (a.AttributeHierarchyVisible && a.AttributeHierarchyEnabled && a.Attribute.AttributeHierarchyVisible && a.Attribute.AttributeHierarchyEnabled && !pcd.Attributes.Contains(a.AttributeID)) { bHighlight = true; break; } } } } HighlightCell(bHighlight, columns, cell, j); } } else if (rowObjectType == "Kpi") { cell = columns[1]; string rowObjectName = (string)cell.GetType().InvokeMember("CellData", getpropertyflags, null, cell, null); rowObjectName = rowObjectName.Trim(); Kpi kpi = cube.Kpis.GetByName(rowObjectName); for (int j = 3; j < columns.Length; j += 2) { cell = perspectivesColumns[j + 1]; string perspectiveName = (string)cell.GetType().InvokeMember("CellData", getpropertyflags, null, cell, null); Perspective perspective = cube.Perspectives.GetByName(perspectiveName); cell = columns[j]; bool bHighlight = false; if (perspective.Kpis.Contains(kpi.ID)) { PerspectiveKpi pkpi = perspective.Kpis[kpi.ID]; bHighlight = ShouldPerspectiveKpiBeHighlighted(pkpi, mdxScriptCache); } HighlightCell(bHighlight, columns, cell, j); } } else if (rowObjectType.EndsWith("Action")) { cell = columns[1]; string rowObjectName = (string)cell.GetType().InvokeMember("CellData", getpropertyflags, null, cell, null); rowObjectName = rowObjectName.Trim(); Microsoft.AnalysisServices.Action action = cube.Actions.GetByName(rowObjectName); for (int j = 3; j < columns.Length; j += 2) { cell = perspectivesColumns[j + 1]; string perspectiveName = (string)cell.GetType().InvokeMember("CellData", getpropertyflags, null, cell, null); Perspective perspective = cube.Perspectives.GetByName(perspectiveName); cell = columns[j]; bool bHighlight = false; if (perspective.Actions.Contains(action.ID)) { bHighlight = true; if (action.TargetType == ActionTargetType.DimensionMembers) { foreach (PerspectiveDimension dim in perspective.Dimensions) { if (string.Compare(action.Target, "[" + dim.CubeDimension.Name + "]", true) == 0) { bHighlight = false; break; } } } else if (action.TargetType == ActionTargetType.AttributeMembers || action.TargetType == ActionTargetType.HierarchyMembers) { foreach (PerspectiveDimension dim in perspective.Dimensions) { foreach (PerspectiveAttribute attr in dim.Attributes) { if (string.Compare(action.Target, "[" + attr.Parent.CubeDimension.Name + "].[" + attr.Attribute.Name + "]", true) == 0) { bHighlight = false; break; } } } } else if (action.TargetType == ActionTargetType.Level || action.TargetType == ActionTargetType.LevelMembers) { foreach (PerspectiveDimension dim in perspective.Dimensions) { foreach (PerspectiveHierarchy hier in dim.Hierarchies) { foreach (Level level in hier.Hierarchy.Levels) { if (string.Compare(action.Target, "[" + hier.Parent.CubeDimension.Name + "].[" + hier.Hierarchy.Name + "].[" + level.Name + "]", true) == 0) { bHighlight = false; break; } } } } } else if (action.TargetType == ActionTargetType.HierarchyMembers) { foreach (PerspectiveDimension dim in perspective.Dimensions) { foreach (PerspectiveHierarchy hier in dim.Hierarchies) { if (string.Compare(action.Target, "[" + hier.Parent.CubeDimension.Name + "].[" + hier.Hierarchy.Name + "]", true) == 0) { bHighlight = false; break; } } } } else { bHighlight = false; } } HighlightCell(bHighlight, columns, cell, j); } } else if (rowObjectType == "CalculatedMember") { cell = columns[1]; string rowObjectName = (string)cell.GetType().InvokeMember("CellData", getpropertyflags, null, cell, null); rowObjectName = rowObjectName.Trim(); for (int j = 3; j < columns.Length; j += 2) { cell = perspectivesColumns[j + 1]; string perspectiveName = (string)cell.GetType().InvokeMember("CellData", getpropertyflags, null, cell, null); Perspective perspective = cube.Perspectives.GetByName(perspectiveName); cell = columns[j]; Microsoft.AnalysisServices.Design.Script calc = (Microsoft.AnalysisServices.Design.Script)allGridCubeObjects[i].GetType().InvokeMember("Object", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetField, null, allGridCubeObjects[i], null); if (CalcIsHidden(calc)) { continue; } bool bHighlight = false; if (calc != null && calc.CalculationProperty != null && perspective.Calculations.Contains(calc.CalculationProperty.CalculationReference) && !CalcIsHidden(calc)) { if (!string.IsNullOrEmpty(calc.CalculationProperty.AssociatedMeasureGroupID)) { if (!perspective.MeasureGroups.Contains(calc.CalculationProperty.AssociatedMeasureGroupID)) { bHighlight = true; } } } HighlightCell(bHighlight, columns, cell, j); } } } grid.Refresh(); } } catch { } }
public Action(TabularModel parentTabularModel, Amo.Action Action) { _parentTabularModel = parentTabularModel; _amoAction = Action; _objectDefinition = ""; if (_amoAction.Caption != null) { _objectDefinition += "Caption: " + _amoAction.Caption + "\n"; } _objectDefinition += "Caption is MDX: " + _amoAction.CaptionIsMdx.ToString() + "\n"; if (_amoAction.Description != null) { _objectDefinition += "Description: " + _amoAction.Description + "\n"; } _objectDefinition += "Action Type: " + _amoAction.Type.ToString() + "\n"; if (_amoAction.Target != null) { _objectDefinition += "Target: " + _amoAction.Target + "\n"; } if (_amoAction.Condition != null) { _objectDefinition += "Condition: " + _amoAction.Condition + "\n"; } _objectDefinition += "Invocation: " + _amoAction.Invocation.ToString() + "\n\n"; switch (_amoAction.Type) { case ActionType.DrillThrough: if (_amoAction is DrillThroughAction) { DrillThroughAction drillThroughAction = (DrillThroughAction)_amoAction; _objectDefinition += "Drillthrough Columns:\n"; foreach (CubeAttributeBinding column in drillThroughAction.Columns) { if (drillThroughAction.Parent.Dimensions.Contains(column.CubeDimensionID) && drillThroughAction.Parent.Dimensions[column.CubeDimensionID].Attributes.Contains(column.AttributeID)) { _objectDefinition += "Table: " + drillThroughAction.Parent.Dimensions[column.CubeDimensionID].Name + ", Column: " + drillThroughAction.Parent.Dimensions[column.CubeDimensionID].Attributes[column.AttributeID].Attribute.Name + "\n"; } } if (drillThroughAction.Columns.Count > 0) { _objectDefinition += "\n"; } _objectDefinition += "Default: " + drillThroughAction.Default.ToString() + "\n"; _objectDefinition += "Maximum Rows: " + drillThroughAction.MaximumRows.ToString() + "\n"; } break; case ActionType.Report: if (_amoAction is ReportAction) { ReportAction reportAction = (ReportAction)_amoAction; _objectDefinition += "Report Parameters:\n"; foreach (ReportParameter reportParameter in reportAction.ReportParameters) { if (reportParameter.Name != null && reportParameter.Value != null) { _objectDefinition += "Name: " + reportParameter.Name + ", Value: " + reportParameter.Value + "\n"; } } if (reportAction.ReportParameters.Count > 0 || reportAction.ReportFormatParameters.Count > 0) { _objectDefinition += "\n"; } if (reportAction.ReportServer != null) { _objectDefinition += "Report Server: " + reportAction.ReportServer + "\n"; } if (reportAction.Path != null) { _objectDefinition += "Maximum Path: " + reportAction.Path + "\n"; } } break; default: if (_amoAction is StandardAction) { StandardAction standardAction = (StandardAction)_amoAction; if (standardAction.Expression != null) { _objectDefinition += "Expression:\n" + standardAction.Expression + "\n"; } } break; } //if (_parentTabularModel.ComparisonInfo.OptionsInfo.OptionTranslations) //{ // _objectDefinition += "\nFormat & Visibility:\n"; // _objectDefinition += "Action Translations: "; // if (_amoAction.Translations.Count > 0) // { // _objectDefinition += "["; // foreach (Translation actionTranslation in _amoAction.Translations) // { // _objectDefinition += CultureInfo.GetCultureInfo(actionTranslation.Language).DisplayName + ": " + actionTranslation.Caption + ", "; // } // _objectDefinition = _objectDefinition.Substring(0, _objectDefinition.Length - 2) + "]"; // } // if (_parentTabularModel.ComparisonInfo.OptionsInfo.OptionDisplayFolders) // { // _objectDefinition += ", Display Folder Translations: "; // if (_amoAction.Translations.Count > 0) // { // _objectDefinition += "["; // foreach (Translation actionDisplayFolderTranslation in _amoAction.Translations) // { // _objectDefinition += CultureInfo.GetCultureInfo(actionDisplayFolderTranslation.Language).DisplayName + ": " + actionDisplayFolderTranslation.DisplayFolder + ", "; // } // _objectDefinition = _objectDefinition.Substring(0, _objectDefinition.Length - 2) + "]"; // } // } // _objectDefinition += "\n"; //} }
private void FillScreen() { if (cmbAction.SelectedIndex >= 0) { _currentAction = _listActionClones[cmbAction.SelectedIndex]; txtName.Text = _currentAction.Name; txtCaption.Text = _currentAction.Caption; chkCaptionIsMdx.Checked = _currentAction.CaptionIsMdx; txtDescription.Text = NormalizeLineBreaks(_currentAction.Description); txtCondition.Text = NormalizeLineBreaks(_currentAction.Condition); cmbActionType.SelectedItem = _currentAction.Type.ToString(); cmbTargetType.SelectedItem = _currentAction.TargetType.ToString(); if (_currentAction.Target != null && !cmbTarget.Items.Contains(_currentAction.Target)) cmbTarget.Items.Add(_currentAction.Target); cmbTarget.SelectedItem = _currentAction.Target; cmbTarget_SelectedIndexChanged(null, null); cmbInvocation.SelectedItem = _currentAction.Invocation.ToString(); foreach (Perspective perspective in cube.Perspectives) { for (int i = 0; i < listPerspectives.Items.Count; i++) { if ((string)listPerspectives.Items[i] == perspective.Name) { bool bChecked = false; if (_dictActionPerspectives.ContainsKey(_currentAction.ID)) bChecked = (new List<string>(_dictActionPerspectives[_currentAction.ID])).Contains(perspective.Name); listPerspectives.SetItemChecked(i, bChecked); } } } if (_currentAction is StandardAction) { StandardAction action = (StandardAction)_currentAction; txtExpression.Text = NormalizeLineBreaks(action.Expression); } else { txtExpression.Text = string.Empty; } if (_currentAction is DrillThroughAction) { DrillThroughAction action = (DrillThroughAction)_currentAction; _listDrillthroughColumns = new List<TabularActionsEditorPlugin.DrillthroughColumn>(); foreach (Microsoft.AnalysisServices.Binding binding in action.Columns) { CubeAttributeBinding cubeAttributeBinding = binding as CubeAttributeBinding; if (cubeAttributeBinding == null) continue; CubeDimension cd = cube.Dimensions.Find(cubeAttributeBinding.CubeDimensionID); if (cd == null) continue; DimensionAttribute a = cd.Dimension.Attributes.Find(cubeAttributeBinding.AttributeID); if (a == null) continue; TabularActionsEditorPlugin.DrillthroughColumn col = new TabularActionsEditorPlugin.DrillthroughColumn(); col.CubeDimension = cd.Name; col.Attribute = a.Name; _listDrillthroughColumns.Add(col); } this.drillthroughColumnBindingSource.DataSource = _listDrillthroughColumns; dataGridViewDrillthroughColumns.DataSource = drillthroughColumnBindingSource; dataGridViewDrillthroughColumns.Refresh(); cmbDefault.SelectedItem = (action.Default ? "True" : "False"); txtMaxRows.Text = (action.MaximumRows <= 0 ? string.Empty : action.MaximumRows.ToString()); } else { _listDrillthroughColumns = new List<TabularActionsEditorPlugin.DrillthroughColumn>(); this.drillthroughColumnBindingSource.DataSource = _listDrillthroughColumns; dataGridViewDrillthroughColumns.DataSource = drillthroughColumnBindingSource; dataGridViewDrillthroughColumns.Refresh(); } if (_currentAction is ReportAction) { ReportAction ra = (ReportAction)_currentAction; _listReportParameters = new List<ReportParameter>(); foreach (ReportParameter rp in ra.ReportFormatParameters) { if (string.Compare(rp.Name, "rs:Command", true) != 0) //rs:Command=Render must be put in ReportFormatParameters or else the action won't work... probably a bug in SSAS... so assume it and don't show it in the UI { _listReportParameters.Add(rp); } } foreach (ReportParameter rp in ra.ReportParameters) { _listReportParameters.Add(rp); } reportParameterBindingSource.DataSource = _listReportParameters; dataGridViewReportParameters.DataSource = reportParameterBindingSource; dataGridViewReportParameters.Refresh(); txtReportServer.Text = ra.ReportServer; txtMaxRows.Text = ra.Path; //using this as ReportPath also } else { _listReportParameters = new List<ReportParameter>(); reportParameterBindingSource.DataSource = _listReportParameters; dataGridViewReportParameters.DataSource = reportParameterBindingSource; dataGridViewReportParameters.Refresh(); txtReportServer.Text = string.Empty; if (!(_currentAction is DrillThroughAction)) { txtMaxRows.Text = string.Empty; //using this as ReportPath also } } } else { txtName.Text = string.Empty; txtCaption.Text = string.Empty; chkCaptionIsMdx.Checked = false; txtDescription.Text = string.Empty; cmbActionType.SelectedItem = -1; cmbTargetType.SelectedItem = -1; cmbTarget.SelectedIndex = -1; cmbDefault.SelectedIndex = -1; txtMaxRows.Text = string.Empty; _listDrillthroughColumns = new List<TabularActionsEditorPlugin.DrillthroughColumn>(); drillthroughColumnBindingSource.DataSource = _listDrillthroughColumns; dataGridViewDrillthroughColumns.DataSource = drillthroughColumnBindingSource; dataGridViewDrillthroughColumns.Refresh(); _listReportParameters = new List<ReportParameter>(); reportParameterBindingSource.DataSource = _listReportParameters; dataGridViewReportParameters.DataSource = reportParameterBindingSource; dataGridViewReportParameters.Refresh(); } }
private void SaveAction() { if (_currentAction == null || cmbAction.SelectedIndex == -1) return; if (cmbActionType.SelectedIndex >= 0) _currentAction.Type = (ActionType)Enum.Parse(typeof(ActionType), cmbActionType.Text); if (_currentAction.Type == ActionType.DrillThrough && !(_currentAction is DrillThroughAction)) { int iIndex = _listActionClones.IndexOf(_currentAction); string sID = _currentAction.ID; _currentAction = new DrillThroughAction(); _currentAction.ID = sID; _currentAction.Type = ActionType.DrillThrough; _listActionClones[iIndex] = _currentAction; } else if (_currentAction.Type == ActionType.Report && !(_currentAction is ReportAction)) { int iIndex = _listActionClones.IndexOf(_currentAction); string sID = _currentAction.ID; _currentAction = new ReportAction(); _currentAction.ID = sID; _currentAction.Type = ActionType.Report; _listActionClones[iIndex] = _currentAction; } else if (_currentAction.Type != ActionType.Report && _currentAction.Type != ActionType.DrillThrough && !(_currentAction is StandardAction)) { int iIndex = _listActionClones.IndexOf(_currentAction); string sID = _currentAction.ID; ActionType type = _currentAction.Type; _currentAction = new StandardAction(); _currentAction.ID = sID; _currentAction.Type = type; _listActionClones[iIndex] = _currentAction; } _currentAction.Name = CleanNameOfInvalidChars(txtName.Text); _currentAction.Caption = txtCaption.Text; _currentAction.CaptionIsMdx = chkCaptionIsMdx.Checked; _currentAction.Description = txtDescription.Text; _currentAction.Condition = txtCondition.Text; if (cmbTargetType.SelectedIndex >= 0) _currentAction.TargetType = (ActionTargetType)Enum.Parse(typeof(ActionTargetType), cmbTargetType.Text); _currentAction.Target = cmbTarget.Text; if (cmbInvocation.SelectedIndex >= 0) _currentAction.Invocation = (ActionInvocation)Enum.Parse(typeof(ActionInvocation), cmbInvocation.Text); List<string> lPerspectiveIDs = new List<string>(); List<string> lPerspective = new List<string>(); foreach (string sPerspective in listPerspectives.CheckedItems) { lPerspective.Add(sPerspective); lPerspectiveIDs.Add(cube.Perspectives.GetByName(sPerspective).ID); } _dictActionPerspectives[_currentAction.ID] = lPerspective.ToArray(); if (_currentAction.Type == ActionType.DrillThrough) { DrillThroughAction action = (DrillThroughAction)_currentAction; action.Columns.Clear(); dataGridViewDrillthroughColumns.EndEdit(); foreach (TabularActionsEditorPlugin.DrillthroughColumn col in _listDrillthroughColumns) { if (!string.IsNullOrEmpty(col.CubeDimension) && !string.IsNullOrEmpty(col.Attribute)) { CubeDimension cd = cube.Dimensions.FindByName(col.CubeDimension); if (cd != null) { DimensionAttribute da = cd.Dimension.Attributes.FindByName(col.Attribute); //if a column doesn't exist anymore in the model, don't throw an error, just skip it... TODO: give some warning or red indication or error? if (da != null) { action.Columns.Add(new CubeAttributeBinding(cube.ID, cd.ID, da.ID, AttributeBindingType.Key)); //6/20/2012 - using AttributeBindingType.Key so that numbers come back as numbers in drillthrough } } } } action.Default = (cmbDefault.Text == "True"); long lngMaxRows; action.MaximumRows = (string.IsNullOrWhiteSpace(txtMaxRows.Text) || !long.TryParse(txtMaxRows.Text, out lngMaxRows) ? -1 : lngMaxRows); } else if (_currentAction.Type == ActionType.Report) { ReportAction action = (ReportAction)_currentAction; action.ReportFormatParameters.Clear(); action.ReportFormatParameters.Add("rs:Command", "Render"); action.ReportParameters.Clear(); dataGridViewReportParameters.EndEdit(); foreach (ReportParameter rp in _listReportParameters) { if (!string.IsNullOrEmpty(rp.Name) && !string.IsNullOrEmpty(rp.Value)) { action.ReportParameters.Add(rp); } } action.ReportServer = txtReportServer.Text; action.Path = txtMaxRows.Text; //multipurpose field } else { StandardAction action = (StandardAction)_currentAction; action.Expression = txtExpression.Text; } }
private void btnDelete_Click(object sender, EventArgs e) { if (cmbAction.SelectedIndex < 0) return; _listActionClones.RemoveAt(cmbAction.SelectedIndex); cmbAction.Items.RemoveAt(cmbAction.SelectedIndex); if (_listActionClones.Count > 0) cmbAction.SelectedIndex = 0; else { DisableControls(true, arrEnabledControls); _currentAction = null; } }