ILicenseManager.RequestLicense

Syntax

LicenseRequest(FeatureName: String; Var License: ILicense; [Settings: ILicenseRequestSettings = Null]): UiLicenseStatusCode;

LicenseRequest(FeatureName: String, Var License: Prognoz.Platform.Interop.Host.ILicense, Settings: Prognoz.Platform.Interop.Host.LicenseRequestSettings, Context: Prognoz.Platform.Interop.Fore.ForeRuntimeContext): Prognoz.Platform.Interop.ForeSystem.UiLicenseStatusCode;

Parameters

FeatureName. Feature name.

NOTE. Parameter's value is empty, if the Settings parameter sends feature type using the FeatureType property.

License. License.

Settings. Object to work with unit activation wizard. If required feature is unavailable, use the ShowActivationWizard property to display the Unit Activation dialog box. By default the property is set to False, the activation dialog box is not displayed.

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

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

Description

The LicenseRequest method checks if the set feature exists, and returns check result.

Comments

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

After checking out a license, update it using ILicense.LicenseUpdate.

After the work with the licensing block is finished, release the license using ILicense.LicenseRelease, that is, remove the object with the license.

If application features are used, create a specific lsinit.exe containing information about it. For details see 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.

If the method is used, the license type is checked:

Fore Example

To execute the example, place the Button component named Button1 on the form.

Add links to the Host, Forms, Ui, Fore, ForeSystem (for Fore.NET example) system assemblies.

The example is a handler of the OnClick event for the Button1 component. Execute the example without debugging.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    LicManager: ILicenseManager;
    Lic: ILicense;
    StatusCode: UiLicenseStatusCode;
    Settings: IUiLicenseRequestSettings;
Begin
    LicManager := WinApplication.Instance.LicenseManager;
    Settings := New UiLicenseRequestSettings.Create;
    
Settings.FeatureType := UiLicenseFeatureType.WordAddin;
    Settings.ShowActivationWizard := True;
    StatusCode := LicManager.RequestLicense
("", Lic, Settings);
    If StatusCode = UiLicenseStatusCode.Success Then
        Lic.LicenseUpdate;
    Else
        // handle licensing errors
        //...
    End If;
    //Work with licensed block
    //...
    //After the work is finished, release license
    If Lic <> Null Then
        Lic.LicenseRelease;
    End If;
End Sub Button1OnClick;

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

Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
    LicManager: ILicenseManager;
    Lic: ILicense;
    StatusCode: UiLicenseStatusCode;
    Settings: UiLicenseRequestSettingsClass = 
New UiLicenseRequestSettingsClass();
    WinApp: WinApplicationClassClass = 
New WinApplicationClassClass();
    Svc: IForeServices;
    RunContext: ForeRuntimeContext;
Begin
    Svc := Self.Metabase 
As IForeServices;
    RunContext := Svc.GetRuntime().Context;
    LicManager := WinApp.Instance[RunContext].LicenseManager;
    Settings.FeatureType := UiLicenseFeatureType.lftWordAddin;
    Settings.ShowActivationWizard := 
True;
    StatusCode := LicManager.RequestLicense(
""Var Lic, Settings As LicenseRequestSettings, RunContext);
    
If StatusCode = UiLicenseStatusCode.lscSuccess Then
        Lic.LicenseUpdate();
    
Else
        
// handle licensing errors
        //...
    End If;
    
//Work with licensed block
    //...
    //After the work is finished, release license
    If Lic <> Null Then
        Lic.LicenseRelease();
    
End If;
End Sub;

Clicking the button requests the PP_WordAddin feature. If it is not available, the Unit Activation dialog box opens.

See also:

ILicenseManager