在报告中显示Cube的最后一个处理时间

时间:2011-12-19 23:52:07

标签: reporting-services ssas

有没有办法显示上次在报表中使用多维数据集或维度进行处理(我正在使用报表生成器)?

我尝试开始创建一个名为LastProcessTime的表,其中包含“Type”和“DateTimeProcessed”字段,我可以插入此表,但我不知道如何启动Insert。也许有一种完全不同的方法。感谢。

2 个答案:

答案 0 :(得分:7)

不确定是否可以将其添加到报表生成器中,但请尝试使用标准MDX报表,并使用SSAS DMV(动态管理视图):

http://dwbi1.wordpress.com/2010/01/01/ssas-dmv-dynamic-management-view/

在针对多维数据集的MDX查询窗口中运行此命令(我知道,它看起来像TSQL):

SELECT * FROM $system.mdschema_cubes

应该给你你需要的东西吗?

答案 1 :(得分:2)

我迟到了 - 但您可以在SSAS中使用自定义存储过程通过普通成员公开此信息

with 
     member [Measures].[LastProcessed] as ASSP.GetCubeLastProcessedDate()
select 
     [Measures].[LastProcessed] on 0
from [Your Cube]

可从CodePex : Analysis Services Stored Procedure Project

获取
/*============================================================================
  File:    CubeInfo.cs

  Summary: Implements a function which returns the date when the current cube
           was last processed.

  Date:    July 12, 2006

  ----------------------------------------------------------------------------
  This file is part of the Analysis Services Stored Procedure Project.
  http://www.codeplex.com/Wiki/View.aspx?ProjectName=ASStoredProcedures

  THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  PARTICULAR PURPOSE.
===========================

=================================================*/

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.AnalysisServices.AdomdServer;
using Microsoft.AnalysisServices; //reference to AMO

namespace ASStoredProcs
{
    public class CubeInfo
    {
        //the assembly must be registered with unrestricted permissions for this function to succeed
        [SafeToPrepare(true)]
        public static DateTime GetCubeLastProcessedDate()
        {
            string sServerName = Context.CurrentServerID;
            string sDatabaseName = Context.CurrentDatabaseName;
            string sCubeName = AMOHelpers.GetCurrentCubeName();

            DateTime dtTemp = DateTime.MinValue;
            Exception exDelegate = null;

            System.Threading.Thread td = new System.Threading.Thread(delegate() 
            {
                try
                {
                    Microsoft.AnalysisServices.Server oServer = new Microsoft.AnalysisServices.Server();
                    oServer.Connect("Data Source=" + sServerName);
                    Database db = oServer.Databases.GetByName(sDatabaseName);
                    Cube cube =  db.Cubes.FindByName(sCubeName);

                    dtTemp = cube.LastProcessed;
                }
                catch (Exception ex)
                {
                    exDelegate = ex;
                }
            }
            );
            td.Start(); //run the delegate code
            while (!td.Join(1000)) //wait for up to a second for the delegate to finish
            {
                Context.CheckCancelled(); //if the delegate isn't done, check whether the parent query has been cancelled. If the parent query has been cancelled (or the ForceCommitTimeout expires) then this will immediately exit
            }

            if (exDelegate != null) throw exDelegate;

            return dtTemp;
            //return Context.CurrentCube.LastProcessed; //this doesn't work because of a bug: https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=124606
        }
.
.
.