ForeExec

Syntax

ForeExecResult ForeExec(ForeId tFore, ForeExecArg tArg)

Parameters

tFore. Moniker of the development environment object that contains implementation of the executed method.

tArg. Operation execution parameters.

Description

The ForeExec operation executes methods implemented in Fore units.

Comments

To execute the operation, in the tFore field specify moniker of the unit, assembly that contains implementation of the executed method. The moniker can be obtained on executing the GetObjects operation. In the tArg.methodName field specify name of the method to be executed, and in the tArg.args field specify values of the method input parameters. Method implementation should be located in the global namespace.

Method signature must contain simple types parameters and return a simple type value. If the method returns a value, this value is available in the operation execution result.

If the executed method contains parameters with the Object type, string views of any object's monikers must be sent as values of these parameters. On executing the operation by the moniker the appropriate repository object is obtained and sent to the executed method. To work with this object, cast it to the interface that describes its structure. For example, on sending repository connection moniker, the parameter in method will be of the IMetabase type, on sending express report moniker it will be of the IEaxAnalyzer type, and so on.

If moniker of the binary object saved on the server using the PutBin/PutBinary operation is sent, in the executed method this object can be cast to the IBinary interface.

The ForeExec operation can send objects in the JSON format to the executed method and also receive response in the JSON format. Corresponding parameters in the method signature should have the IJsonObject type. The returned value type should be IJsonObject.

Recommendations for Use

When developing the web application, from which various methods are supposed to be run, use the following recommendations:

Disabling Execution of the ForeExec Operation

Due to possible use of the ForeExec operation for executing the code, to which the particular user must not have access, one can disable executing of the operation:

NOTE. For details about location of parameters see description of the appropriate configuration files.

<html>
<body>
    <script language="javascript" type="text/javascript">
    <!--...Previous application code...-->
    <!--...-->
    <!--Function for sending JSON request-->
    function PostRequest(url, request) {
        <!--...-->
        var xhr = new XMLHttpRequest();
        <!--...-->
        xhr.setRequestHeader('p-h', '1');
        <!--...-->
        xhr.send(JSON.stringify(request));
        <!--...-->
    }
    </script>
</body>
</html>

Working Features

When the ForeExec operation works, units/assemblies change time is not checked that is why when the method is executed for the first time, the current object version is loaded to assembly cache from repository. If method code changes afterwards, its repeated start using the ForeExec operation will result in execution of the older method version, which already exists in assembly cache. To use the actual method version, restart BI server.

Example

Various methods of using the operation are given in the following examples:

Example name
Fore Method Execution
Sending Objects as Parameter Values
Working with Objects in JSON Format

See also:

Specific Operations