Я пишу модуль, который может обрабатывать и выполнять другие действия на SSAS с VB.NET. Я добавляю эту информацию в Treelist. Я могу получить показатели, измерения и атрибуты DimensionAttributes, но не могу получить все элементы DimensionAttributes и вычисляемые элементы мер.
For Each objMdxScript As MdxScript In cubeDef.MdxScripts
For i As Integer = 0 To a.CalculationProperties.Count - 1
Dim MeasureName As String = objMdxScript.CalculationProperties(i).CalculationReference.Replace("[MEASURES].[", "")
Next
Next
Я использую Microsoft.AnalysisService.dll. Я не мог найти рассчитанные члены. Я пробовал это, но это не сработало. Потому что он возвращает ноль рассчитанного свойства.
Private Sub GetCubeInfo()
Dim impersonator As Tools.Network.Impersonator
Dim cubeList As New List(Of Cube)
Dim server As New Server()
impersonator = New Impersonator(fmCubeConnect.userName, Settings.OLAPNTDomainName, fmCubeConnect.password, LogonType.LOGON32_LOGON_NEW_CREDENTIALS, LogonProvider.LOGON32_PROVIDER_WINNT50)
Try
If server.Connected Then
server.Disconnect()
End If
server.Connect(String.Format("Provider={0};Data source={1};", fmCubeConnect.provider, fmCubeConnect.serverAddress))
Catch ex As Exception
MessageBox.Show(ex.Message, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
Exit Sub
End Try
Try
If QueryObject.GetType Is GetType(Database) Then
Dim database = server.Databases.FindByName(QueryObject.ToString)
For Each cube In database.Cubes.Cast(Of Cube)
cubeList.Add(cube)
Next
ElseIf QueryObject.GetType Is GetType(Cube) Then
Dim convertedObject As Cube = Convert.ChangeType(QueryObject, GetType(Cube))
cubeList.Add(convertedObject)
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
Exit Sub
End Try
Dim MeasTitleAdded As Boolean = False
Dim DimTitleAdded As Boolean = False
Dim KpisTitleAdded As Boolean = False
For Each cubeDef As Cube In cubeList
Dim parentForRootNodes As TreeListNode = Nothing
Dim rootCubeNode As TreeListNode = MetadataTree.AppendNode(New Object() {cubeDef.Name}, parentForRootNodes, cubeDef)
' Measures and submeasures
For Each m As MeasureGroup In cubeDef.MeasureGroups
Dim measTitleNode As TreeListNode
If Not MeasTitleAdded Then
measTitleNode = MetadataTree.AppendNode(New Object() {"Measures"}, rootCubeNode, "measureTitle")
MeasTitleAdded = True
End If
' Adding MeasureGroups
Dim measNode As TreeListNode = MetadataTree.AppendNode(New Object() {m.Name}, measTitleNode, m)
' Adding Measures
For i As Integer = 0 To m.Measures.Count - 1
Dim subMeasNode As TreeListNode = MetadataTree.AppendNode(New Object() {m.Measures(i).Name}, measNode, m.Measures(i))
Next
Next
Dim kpiTitleNode As TreeListNode
If Not KpisTitleAdded Then
kpiTitleNode = MetadataTree.AppendNode(New Object() {"KPIs"}, rootCubeNode, "kpiTitle")
KpisTitleAdded = True
End If
'Adding KPIs
For Each k As Kpi In cubeDef.Kpis
Dim KPINode As TreeListNode = MetadataTree.AppendNode(New Object() {k.Name}, kpiTitleNode, k)
Next
'Adding Dimensions and DimensionAttributes
For Each d As CubeDimension In cubeDef.Dimensions
'Adding Dimensions
Dim dimNode As TreeListNode = MetadataTree.AppendNode(New Object() {d.Name}, rootCubeNode, d)
'Adding DimensionAttributes
For i As Integer = 0 To d.Attributes.Count - 1
Dim subDimNode As TreeListNode = MetadataTree.AppendNode(New Object() {d.Attributes(i).AttributeID}, dimNode, d.Attributes(i))
Next
Next
Next
End Sub
Я хочу получить все члены DimensionAttributes и вычисляемые элементы мер.