IUiLicenseManager.LicenseRequest

Fore Syntax

LicenseRequest(

FeatureName: String;

Var License: IUiLicense;

[ShowActivationWizard: Boolean = False]): UiLicenseStatusCode;

Fore.NET Syntax

LicenseRequest(

FeatureName: string,

var License: Prognoz.Platform.Interop.Ui.IUiLicense,

ShowActivationWizard: boolean,

pContext: Prognoz.Platform.Interop.Fore.ForeRuntimeContext): Prognoz.Platform.Interop.ForeSystem.UiLicenseStatusCode;

Parameters

FeatureName. Feature name.

License. License.

ShowActivationWizard. Parameter is used to open the Activation of Unit dialog box when the requested feature is not available. The parameter is set to False by default, and activation dialog box does not open.

NOTE. Value of the True parameter is used only to check stand-alone license, on checking the network license and if the the requested feature is absent, the error message is displayed.

Context. Context. It is relevant only for Fore.NET.

Description

The LicenseRequest method checks if the specified feature is included into the license and returns check result.

Comments

A feature can be checked both for network and stand-alone license.

After checking out a license, update IUiLicense.LicenseUpdate.

After the work with licensing block is finished, the license should be checked in using LicenseRelease, that is, to remove the object with license.

When application features are used, it is required to create a specific lsinit.exe containing information about them. See below the Application System Licensing article.

If a valid activation code is specified in the unit activation dialog box, the feature code is saved to file. A stand-alone license file is stored at: %PROGRAMDATA%\Foresight\Foresight Analytics Platform\lservrc.

On using the method, the license type is checked:

Fore Example

To execute the example, add a link to the Ui system assembly. Place the Button component with the Button1 identifier on the form. The example is a handler of the OnClick event for the Button1 component.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    LicManager: IUiLicenseManager;
    Feature: String;
    Lic: IUiLicense;
    StatusCode: UiLicenseStatusCode;
Begin
    LicManager := WinApplication.Instance.LicenseManager;
    Feature := "ApplicationFeature";
    StatusCode := LicManager.LicenseRequest(Feature, Lic, True);
    If StatusCode = UiLicenseStatusCode.Success Then
        Lic.LicenseUpdate;
    Else
        /// Handle licensing errors
        ///...
    End If;
    ///Work with licensing block
    ///...
    ///After work is finished, the license is checked in
    If Lic <> Null  Then
       Lic.LicenseRelease;
    End If;

End Sub Button1OnClick;

On clicking the button the ApplicationFeature feature will be requested. If it is unavailable, the Activation of Unit dialog box opens.

Fore.NET Example

To execute the example, add links to the Ui, Fore, ForeSystem system assemblies. Place the Button component with the Button1 identifier on the form. The example is a handler of the OnClick event for the Button1 component. The example of the Fore.NET example execution matches with that in the Fore example.

Imports Prognoz.Platform.Interop.Fore;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Ui;

Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
    WinApp: WinApplicationClassClass = New WinApplicationClassClass();
    Svc: IForeServices;
    RunContext: ForeRuntimeContext;
    LicManager: IUiLicenseManager;
    Feature: String;
    Lic: IUiLicense;
    StatusCode: UiLicenseStatusCode;
Begin
    Svc := Self.Metabase As IForeServices;
    RunContext := Svc.GetRuntime().Context;
    LicManager := WinApp.Instance[RunContext].LicenseManager;
    Feature := "ApplicationFeature";
    StatusCode := LicManager.LicenseRequest(Feature, Var Lic, True,RunContext);
    If StatusCode = UiLicenseStatusCode.lscSuccess Then
        Lic.LicenseUpdate();
    Else
        /// Handle licensing errors
        ///...
    End If;
    ///Work with licensing block
    ///...
    ///After work is finished, the license is checked in
    If Lic <> Null Then
            Lic.LicenseRelease();
    End If;
End Sub;

See also:

IUiLicenseManager