Inhalte aufrufen

Profilbild

License and Store Selection for Modules

module

Best Answer Mark Wördenweber , 23 December 2022 - 14:24

 

I want to make a store selection in the modules I write.

 

Add the following line to your configuration view:

@await Component.InvokeAsync("StoreScope")

This will render the store chooser for individual settings.

Don't forget to use this in combination with the setting-editor taghelper!

 

 

How can I prevent it from working without a license code?

 

Your Module class needs the attribute LicensableModule and a CheckLicenseAsync method.

[LicensableModule]
public class Module : ModuleBase, IConfigurable
{

    // Install and Uninstall methods...

    public static Task<bool> CheckLicenseAsync()
    {
        return Throttle.CheckAsync(
            "YourPersonalUniqueKey", // This needs to change with every module you write.
            TimeSpan.FromHours(1),
            true,
            async () => await LicenseChecker.CheckStateAsync("YourModulesSystemName") > LicensingState.Unlicensed); // e.g. MyOrg.HelloWorld
    }
}

Then you can call CheckLicenseAsync anywhere in your code to confirm it is used with a valid license.

Add the using directive using static YouModuleSystemName.Module;

public IActionResult ControllerMethod(Settings settings)
{
    if (!CheckLicense())
    {
        // Invalid License.
        return new EmptyResult();
    }

    // Valid License.
}

We are currently working on new documentation. It should be released soon.

Go to the full post


  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
6 Antworten zu diesem Thema

#1 Fred Jie

Fred Jie

    Newbie

  • Members
  • Punkt
  • 8 Beiträge

Geschrieben: 22 December 2022 - 13:06

Hello,
 
I am an active developer on smartstore. I want to make a store selection in the modules I write. How can I do that? When I looked at your documents about this, I could not reach a conclusion.
 
Also, I want to license the module I wrote. How can I prevent it from working without a license code?
 
Thanks.


#2 Mark Wördenweber

Mark Wördenweber

    Smartstore Moderator

  • Administrators
  • 5 Beiträge

Geschrieben: 23 December 2022 - 09:28

What version of Smartstore are you developing for?



#3 Fred Jie

Fred Jie

    Newbie

  • Members
  • Punkt
  • 8 Beiträge

Geschrieben: 23 December 2022 - 13:49

Hello,

 

We are developing for version 5.0.1 of Smartstore. 

 

Thanks..



#4 Mark Wördenweber

Mark Wördenweber

    Smartstore Moderator

  • Administrators
  • 5 Beiträge

Geschrieben: 23 December 2022 - 14:24   Best Answer

 

I want to make a store selection in the modules I write.

 

Add the following line to your configuration view:

@await Component.InvokeAsync("StoreScope")

This will render the store chooser for individual settings.

Don't forget to use this in combination with the setting-editor taghelper!

 

 

How can I prevent it from working without a license code?

 

Your Module class needs the attribute LicensableModule and a CheckLicenseAsync method.

[LicensableModule]
public class Module : ModuleBase, IConfigurable
{

    // Install and Uninstall methods...

    public static Task<bool> CheckLicenseAsync()
    {
        return Throttle.CheckAsync(
            "YourPersonalUniqueKey", // This needs to change with every module you write.
            TimeSpan.FromHours(1),
            true,
            async () => await LicenseChecker.CheckStateAsync("YourModulesSystemName") > LicensingState.Unlicensed); // e.g. MyOrg.HelloWorld
    }
}

Then you can call CheckLicenseAsync anywhere in your code to confirm it is used with a valid license.

Add the using directive using static YouModuleSystemName.Module;

public IActionResult ControllerMethod(Settings settings)
{
    if (!CheckLicense())
    {
        // Invalid License.
        return new EmptyResult();
    }

    // Valid License.
}

We are currently working on new documentation. It should be released soon.


  • stefanmueller gefällt das

#5 Fred Jie

Fred Jie

    Newbie

  • Members
  • Punkt
  • 8 Beiträge

Geschrieben: 23 December 2022 - 14:48

Thanks for your help.



#6 Fred Jie

Fred Jie

    Newbie

  • Members
  • Punkt
  • 8 Beiträge

Geschrieben: 23 December 2022 - 15:29

Hello,

 

I did what you said but I am getting the following error.

 

"Failure, Status Unlicensed. The provided license data is invalid or incomplete."

 

Where am I doing wrong?

 

Example Code Here:

 

 

1. https://prnt.sc/CFGkP8Whba4b

2. https://prnt.sc/DdnLz4Hj6cax

 

 

Note: System Name and Site address are representations.



#7 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 27 December 2022 - 15:58

There is no counter part software that could verify your licensing. In order for this to work, your module must be offered on the SmartStore Community Marketplace. Please refer to this documentation.

  • stefanmueller gefällt das

Marcus Gesing

Smartstore AG



Auch markiert mit einem oder mehrerer dieser Schlüsselwörter: module