Udostępnij przez


Zdarzenie AdomdConnection.CubeOpened

Występuje, gdy moduł jest otwierany.

Przestrzeń nazw:  Microsoft.AnalysisServices.AdomdServer
Zestaw:  msmgdsrv (w msmgdsrv.dll)

Składnia

'Deklaracja
Public Event CubeOpened As EventHandler
'Użycie
Dim instance As AdomdConnection
Dim handler As EventHandler

AddHandler instance.CubeOpened, handler
public event EventHandler CubeOpened
public:
 event EventHandler^ CubeOpened {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
member CubeOpened : IEvent<EventHandler,
    EventArgs>
Język JScript obsługuje używanie zdarzeń, ale nie obsługuje deklarowania nowych.

Uwagi

Poniższy kod jest częścią Analysis Services personalizacji rozszerzenia (ASPE) i przedstawiono sposób użycia CubeClosing i CubeOpened zdarzenia.

Ostrzeżenie

Następujący przykładowy kod może być również pobrany z Microsoft SQL Server Samples and Community Projects witryna sieci Web.Aby uzyskać więcej informacji dotyczących sposobu pobierania i instalowania próbek, zobacz Instalowanie SQL Server próbki i przykładowe bazy danych w SQL Server Books Online.

Przykłady

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.AnalysisServices.AdomdServer;

namespace ISV_1.ASClientExtensions

{

public class SessionMgr

{

public SessionMgr()

{

Context.CurrentConnection.CubeOpened += new EventHandler(CubeOpened);

Context.CurrentConnection.CubeClosing += new EventHandler(CubeClosing);

}

~SessionMgr()

{

}

public void CubeOpened(object sender, EventArgs e)

{

String username = Context.CurrentConnection.User.Name;

username = username.Substring(username.IndexOf('\\')+1).ToLowerInvariant();

//Verify and set user experience for opened cube

// that is define calculated members according to user profile.

AuthoringAndManagement.DefineMembers(Context.CurrentDatabaseName, Context.CurrentCube.Name, username);

// that is define KPIs according to user profile

AuthoringAndManagement.DefineKPIs(Context.CurrentDatabaseName, Context.CurrentCube.Name, username);

// that is define sets according to user profile.

AuthoringAndManagement.DefineSets(Context.CurrentDatabaseName, Context.CurrentCube.Name, username);

}

public void CubeClosing(object sender, EventArgs e)

{

//Close and discard any object that requires clean-up

}

}

}