Search code examples
c#ssas

Error Accessing LastProcessed Property in SSAS Cube


I've got an assembly which sets a roles dimension data depending on the current user. In the assembly I need to access Context.CurrentCube.LastProcessed property. The code in itself works fine. Except when the Cube has been either newly deployed or processed. Then sometimes retrieving Context.CurrentCube.LastProcessed property throws the following error:

Microsoft.AnalysisServices.AdomdServer.AdomdException: Server: The operation was cancelled by the user. at Microsoft.AnalysisServices.AdomdServer.CubeCollection..ctor(String mpCubeName) at Microsoft.AnalysisServices.AdomdServer.CubeDef.get_LastProcessed()
at Reporting.TryGetLastProcessDate() in d:\Projects\reporting\Reporting_Cube_Addons\Permissions.cs:line 181

I've wrapped that line in a try catch, with a fallback value:

    public static DateTime TryGetLastProcessDate()
    {
        DateTime last;
        try
        {
            last = Context.CurrentCube.LastProcessed;
        }
        catch (Exception ex)
        {
            log("Failed to retrieved lastProcess Date. Error:");
            log(ex.ToString());
            last = new DateTime(2015, 01, 01);
        }
        return last;
    }

But it seems that the cube stops work even though the exception has been caught..

Any ideas on what I might be doing wrong? Are there other more fail safe ways of retrieving the last processed date?


Solution

  • I would recommend either installing ASSP or using this code. Usage examples are here.

    I recall like 10 years ago there was an issue with Context.CurrentCube.LastProcessed sometimes reflecting when your started the SSAS instance rather than when you processed the cube. So we switched to this alternate approach. I have no idea if that bug has been fixed and I'm not familiar with the crash you describe. But I hope the above approach works around it for you.