Добрый день!
Можно и используя .NET, как ещё один вариант для версий, поддерживающих подключение сборок:
X++:
Microsoft.AnalysisServices.AdomdClient.AdomdConnection con;
Microsoft.AnalysisServices.AdomdClient.AdomdCommand command;
Microsoft.AnalysisServices.AdomdClient.AxisCollection axisCollection;
Microsoft.AnalysisServices.AdomdClient.Axis axis0;
Microsoft.AnalysisServices.AdomdClient.Axis axis1;
Microsoft.AnalysisServices.AdomdClient.Set set;
Microsoft.AnalysisServices.AdomdClient.TupleCollection tuplesOnRows;
Microsoft.AnalysisServices.AdomdClient.TupleCollection tuplesOnColumns;
Microsoft.AnalysisServices.AdomdClient.Tuple tupleRow;
Microsoft.AnalysisServices.AdomdClient.Tuple tupleCol;
Microsoft.AnalysisServices.AdomdClient.MemberCollection memberCollection;
Microsoft.AnalysisServices.AdomdClient.Member member;
Microsoft.AnalysisServices.AdomdClient.CellSet cellSet;
Microsoft.AnalysisServices.AdomdClient.Cell cell;
System.Collections.IEnumerator tuplesOnRowsEnumerator;
TMPOLAPData OlapData;
str value;
str mdx;
mdx = @"select {[Measures].[Продажи]} on columns,
non empty [Клиенты].[Клиенты].members on rows
from [Cube]
where условие текущего месяца" ;
try
{
con = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection();
// Set your own connection string
con.set_ConnectionString("provider=msolap;Data Source=(local);initial catalog=<YourCubeBase>;");
con.Open();
command = con.CreateCommand();
command.set_CommandText(mdx);
cellSet = command.ExecuteCellSet();
axisCollection = cellSet.get_Axes();
axis0 = axisCollection.get_Item(0);
set = axis0.get_Set();
tuplesOnColumns = set.get_Tuples();
axis1 = axisCollection.get_Item(1);
set = axis1.get_Set();
tuplesOnRows = set.get_Tuples();
// output rows
tuplesOnRowsEnumerator = tuplesOnRows.GetEnumerator();
while (tuplesOnRowsEnumerator.MoveNext())
{
OlapData.clear();
OlapData.initValue();
// fill dimension
tupleRow = tuplesOnRowsEnumerator.get_Current();
memberCollection = tupleRow.get_Members();
member = memberCollection.get_Item(0);
OlapData.nameOfelement = member.get_Caption();
// fill measure
tupleCol = tuplesOnColumns.get_Item(0);
cell = cellSet.get_Item(tupleCol.get_TupleOrdinal(), tupleRow.get_TupleOrdinal());
value = cell.get_FormattedValue();
OlapData.Value = value;
OlapData.insert();
}
if (!CLRInterop::isNull(con))
{
con.Close();
}
}
catch
{
error(AIFUtil::getClrErrorMessage());
}