Show contents 

Ui > Ui Assembly Interfaces > IUiCommandTarget > IUiCommandTarget.Execute > Ms Plugin > CopyModelSpace

CopyModelSpace Command

Purpose

It copies modeling container.

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
IMetabaseObjectCopyInfo Object with parameters of copying the Modeling Container repository object.

Application Features

The command can be applied only to modeling container.

Example

Executing the example requires a form containing a button with the Button1 identifier.

It is required that the repository contains a modeling container with the MS_PLUGIN identifier.

Add links to the Fore, 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
    Mb: IMetabase;
    CInfo: IMetabaseObjectCopyInfo;
    Target: IUiCommandTarget;
    Context: IUiCommandExecutionContext;
Begin
    
// Get current repository
    Mb := MetabaseClass.Active;
    
// Create an object to copy and set parameters
    CInfo := MB.CreateCopyInfo;
    CInfo.Id := MB.GenerateId(
"MS_PLUGIN_COPY");
    CInfo.Name := 
"Container copy";
    CInfo.WithData := 
True;
    CInfo.Source := MB.ItemById(
"MS_PLUGIN");
    CInfo.Destination := MB.Root;
    
// Get Ms plugin
    Target := WinApplication.Instance.GetPluginTarget("Ms");
    
// Create a context to execute a command
    Context := Target.CreateExecutionContext;
    
// Send command parameter
    Context.Data := CInfo;
    
// Execute the command
    Target.Execute("CopyModelSpace", Context);
End Sub Button1OnClick;

Imports Prognoz.Platform.Interop.Fore;
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
    Mb: IMetabase;
    CInfo: IMetabaseObjectCopyInfo;
    Target: IUiCommandTarget;
    WinApp: WinApplicationClassClass = 
New WinApplicationClassClass();
    RunContext: ForeRuntimeContext;
    Context: IUiCommandExecutionContext;
Begin
    
// Get current repository
    Mb := Self.Metabase;
    
// Create an object to copy and set parameters
    CInfo := MB.CreateCopyInfo();
    CInfo.Id := MB.GenerateId(
"MS_PLUGIN_COPY"0);
    CInfo.Name := 
"Container copy";
    CInfo.WithData := 
True;
    CInfo.Source := MB.ItemById[
"MS_PLUGIN"];
    CInfo.Destination := MB.Root;
    
// 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 := CInfo;
    
// Execute the command
    Target.Execute("CopyModelSpace", Context, RunContext);
End Sub;

After executing the example, clicking the Button1 copies the modeling container with data.

See also:

IUiCommandTarget.Execute