I want to use SSAS cube to get data from Dynamics AX and Pass data to wpf Devexpress PivotGrid.
I am using following order in AX to create cube:
Perspective-->View-->Query(with arguments)
Now when I change the arguments of query everytime I have to Process the cube manually and render the data.
I want that process to be done through c# code automatically.
i had tried below code
Server server = new Server();
server.Connect(cubeConnectionString);
Database database = server.Databases.FindByName(databaseName);
Cube cube = database.Cubes.FindByName(cubeName);
cube.Process(ProcessType.ProcessFull);
but it is not working.
Can anyone help??
I am not knowing what the error you are getting. To process cube from C# the code you have used seems correct but might you have missed something in connection string. For Reference you can download sample project provided in this link to my blog:
Process Cube dynamically in C#
Code which I had used to process my cube database is like below...
Server server = new Server();
server.Connect("Data source=YourSSASServerName;Timeout=7200000;Integrated Security=SSPI");
Database database = server.Databases.FindByName("YourCubeDBName");
database.Process(ProcessType.ProcessFull);
I know this question is a few years old, but I recently developed a solution to do this. I stumbled across this question when trying to solve the problem myself.
First, check your permissions, see if you can process it via SSMS, but I assume you've already done that.
The second is using the right libraries. The two libraries you should be using are:
- Microsoft.AnalysisServices and
- Microsoft.AnalysisServices.Core
For me, I used version 14.x of both, and each dll needs to have the same version number
The Server object you create is actually Microsoft.AnalysisServices.Server and that class needs Microsoft.AnalysisServices.Core.Server see https://docs.microsoft.com/en-us/dotnet/api/microsoft.analysisservices.server?view=analysisservices-dotnet
The doco at https://docs.microsoft.com/en-us/dotnet/api/microsoft.analysisservices?view=analysisservices-dotnet also highlights the need to use both libraries.
Microsoft.AnalysisServices.Core.Server is an abstract class, so you won't be able to instantiate it, that's why you use Microsoft.AnalysisServices.Server. See https://docs.microsoft.com/en-us/dotnet/api/microsoft.analysisservices.core.server?view=analysisservices-dotnet
Today, you'll need to use dotnet 4.x, I don't think .Net Core will allow you to use these libraries (I could be wrong). Using .Net Core failed for me, complained about 'WindowsImpersonationContext'
In the end, the following code worked for me...
using Microsoft.AnalysisServices;
using Microsoft.AnalysisServices.Core;
void Main()
{
Microsoft.AnalysisServices.Server server = new Microsoft.AnalysisServices.Server();
server.Connect("servername") ;
Microsoft.AnalysisServices.Database db = server.Databases.FindByName("SSAS_DBName");
Microsoft.AnalysisServices.Cube cube = db.Cubes.FindByName("CubeName");
cube.Process( ProcessType.ProcessFull );
}