SLPS Developer Discussion Developer level questions on Code Protection, Licensing, customisation APIs etc
InishTech Support Forums > SLPS Developer Discussion > How to I test for a enabled/disabled feature so i can remove the feature from the menu? Login to add this as a favourite.
User avatar
Member
Member
wqwalter - 11/20/2009 5:46:46 PM
   
How to I test for a enabled/disabled feature so i can remove the feature from the menu?

I have a number of optional features in my application that I want to enable/disable using SLPS. I can add a method associated with a protected feature I get a unlicensed exception but I would rather remove the button from the menu so the user does not see buttons for features they did not purchase. Do you have documentation and examples on how to do that?

Bill Walter


User avatar
InishTech Dev
InishTech Dev
josullivan - 11/25/2009 3:50:33 PM
   
RE:How to I test for a enabled/disabled feature so i can remove the feature from the menu?

Bill

You can use the Runtime API to check whether

  • firstly the feature is included within a valid license and
  • secondly, any feature usage limitations have been exceeded

Attached is a snippet from the C# tutorial which shows just such a simple check being implemented for a feature "Max # of Patients" where there is a usage limitation.  If this latter check is not applicable in your case you can remove the relevant code.

You can call this from the relevant menu handling code - just need to pass the correct values for your

  • Permutation ID short code
  • Product Name
  • Product Version
  • FeatureName (which has to correspond exactly with the Feature Name listed for the Product/SKU in SLP Online service)

 

public static System.Data.DataRow AddPatient()
{
	//*
	//Check license for the Max # of Patients feature.
	//If the feature does not exist or the number of
	//current patients is greater than the max number
	//of patients, exit this method without adding
	//a new patient.

	//Create the SLM runtime object, which is the single
	//entry point for the runtime API.
	string perumationID = "my private permutation id";
	SLMRuntime SLM = new SLMRuntime(perumationID);
	string productName = "Medical Image System";
	string productVersion = "1.0";
	SLM.OpenSession(productName, productVersion);

	//get the runtime data for the
	//Max # of Patients feature
	string featureName = "Max # of Patients";
	IFeatureRuntimeData MaxPatientsFeature = SLM.Session.GetFeatureRuntimeData("featureName,true);

	//ensure that the Max # of Patients feature
	//is in a valid license
	if (MaxPatientsFeature != null)
	{
		//Get the total usage limit for the
		//Max # of Patients feature
		uint MaxPatients =
		MaxPatientsFeature.Limit.TotalUsageCount;
		uint CurrentPatients = (uint)GetNewPatientCount();
		if (CurrentPatients >= MaxPatients)
		{
			MessageBox.Show(
			"The maximum number of patients " +
			"for this license has been reached. " +
			"Please contact Contoso, Ltd to upgrade " +
			"to an Enterprise license.");
			return null;
		}
	}
	else
	{
		MessageBox.Show("You do not have a license " +
		"for this feature. Please contact Contoso, Ltd " +
		"to upgrade to an Enterprise license.");
		return null;
	}
	//Add a new patient if license check was successful
	//*/
	PatientForm patientForm = new PatientForm();
	patientForm.Text = "Add New Patient";
}

 


User avatar
Member
Member
wqwalter - 11/25/2009 6:04:25 PM
   
RE:How to I test for a enabled/disabled feature so i can remove the feature from the menu?

Thanks for the reply. I saw that example but I thought it only would work if the feature had a count limit and ypu actually ran the feature. I was wanting to hid the ability to run the feature so it could not even be attempted to be run. I will try what is outlined and see if I can get what I am looking for.

 

Bill Walter


1

There are currently no users on-line.

  • Sticky
  • Locked sticky
  • Hot sticky
  • Hot locked sticky
  • Thread
  • Hot thread
  • Locked thread