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;
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». 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.
The LicenseRequest method checks if the set feature exists, and returns check result.
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:
If the network license is used and the requested feature is absent, the error message is displayed instead of the activation dialog box. License activation in the network mode is not supported.
If the server contains the requested license, license search settings will be changed to stand-alone license for the current user.
If a stand-alone license is used and the requested feature is absent, the activation dialog box opens.
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: