GetCubeModelDesc Command

Purpose

Determines a time series database or a cube that contain a modeling object.

Parameters of Use

Command parameters are passed in the IUiCommandExecutionContext.Data property. Executing the command requires to specify the following value in this property:

Value type Description
IMetabaseObjectDescriptor Repository object.

Application Features

The command returns both any types of cubes and time series databases.

Example

Executing the example requires a form containing a button named Button1 and the UiModel component named UiModel1.

It is required that the repository contains a time series database that includes a modeling container with a model. This model is specified as an object for the UiModel component.

Add links to the Fore, KeFore, Metabase, Ms, UI system assemblies.

The example is a handler of the OnClick event for the Button1 button.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    Result: IMetabaseObjectDescriptor;
    Key: Integer;
Begin
    Key := UiModel1.Object.Key;
    
// Execute function
    Result := GetSmhDesc(Key, "GetCubeModelDesc");
    
// Display value
    WinApplication.InformationBox(Result.Name + " (" + Result.Id + ")");
End Sub Button1OnClick;

Function GetSmhDesc(Key: Integer; Plugin: String): IMetabaseObjectDescriptor;
Var
    Desc, Result: IMetabaseObjectDescriptor;
    Target: IUiCommandTarget;
    Context: IUiCommandExecutionContext;
Begin
    Desc := MetabaseClass.Active.Item(Key);
    
// Get Ms plugin
    Target := WinApplication.Instance.GetPluginTarget("Ms");
    
// Create a context to execute a command
    Context := Target.CreateExecutionContext;
    
// Send command parameter
    Context.Data := Desc;
    
// Execute the command
    Result := Target.Execute(Plugin, Context) As IMetabaseObjectDescriptor;
    
Return Result;
End Function GetSmhDesc;

Imports Prognoz.Platform.Interop.Fore;
Imports Prognoz.Platform.Interop.KeFore;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Ui;

Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
    WinApp: WinApplicationClassClass = 
New WinApplicationClassClass();
    Result: IMetabaseObjectDescriptor;
    Key: uinteger;
Begin
    Key := uiModelNet1.Object.Key;
    
// Execute function
    Result := GetSmhDesc(Key, "GetCubeModelDesc");
    
// Display value
    WinApp.InformationBox(Result.Name + " (" + Result.Id + ")"New IWin32WindowForeAdapter(Self));
End Sub;

Function GetSmhDesc(Key: uinteger; Plugin: String): IMetabaseObjectDescriptor;
Var
    Mb: IMetabase;
    Desc, Result: IMetabaseObjectDescriptor;
    Target: IUiCommandTarget;
    Context: IUiCommandExecutionContext;
    WinApp: WinApplicationClassClass = 
New WinApplicationClassClass();
    RunContext: ForeRuntimeContext;
Begin
    
// Get current repository
    Mb := Self.Metabase;
    Desc := Mb.Item[Key];
    
// Get Ms plugin
    RunContext := (Mb As IForeServices).GetRuntime().Context;
    Target := WinApp.Instance[RunContext].GetPluginTarget(
"Ms");
    
// Create a context to execute a command
    Context := Target.CreateExecutionContext();
    
// Send command parameter
    Context.Data := Desc;
    
// Execute the command
    Result := Target.Execute(Plugin, Context, RunContext) As IMetabaseObjectDescriptor;
    
Return Result;
End Function GetSmhDesc;

After executing the example, clicking the Button1 button displays a message with information about name and identifier of the time series database that contains a modeling container with the specified model.

See also:

IUiCommandTarget.Execute