Thursday, July 12, 2012

Process Cube objects using AMO

Today I am going to share code for Processing Cube objects using AMO (Analysis Management Objects) For using AMO, you need to reference the Microsoft.AnalysisServices.dll. Following is the code which you can use for processing. In following sample code, I am processing dimensions first (i.e. ProcessUpdate on dimensions) and then I am processing whole cube. Following is just a sample code, you can modify it as per your requirements


        Dim objServer As Server
        Dim objDatabase As Database

        objServer = New Server
        objServer.Connect("localhost")
        objServer.CaptureXml = True

        objDatabase = objServer.Databases.FindByName("Adventure Works DW 2008R2")

        For Each objDimension As Dimension In objDatabase.Dimensions
            objDimension.Process(ProcessType.ProcessUpdate)
        Next

        For Each objCube As Cube In objDatabase.Cubes
            objCube.Process(ProcessType.ProcessData)
            objCube.Process(ProcessType.ProcessIndexes)
        Next

        objServer.ExecuteCaptureLog(True, True)


Analysis services start processing the cube objects when you run "ExecuteCaptureLog" function.
"ExecuteCaptureLog" function accepts three overloads, first indicates whether the capture log entries will be executed in a transaction, second indicates whether the capture log entries will be executed in a parallel, third one indicates whether the affected objects will be processed.

If you just want to retrieve the generated XMLA then instead of "ExecuteCaptureLog" function, you can use the function named "ConcatenateCaptureLog" which returns XMLA string.

2 comments:

  1. I love your blog. Keep it up.Visit my site too.

    triciajoy.com

    www.triciajoy.com

    ReplyDelete
  2. I really enjoyed reading your article. I found this as an informative and interesting post, so i think it is very useful and knowledgeable. I would like to thank you for the effort you have made in writing this article.


    edupdf.org



    ReplyDelete