How to allow specific customers to work offline indefinitely
Overview
Implementation
Create a feature
Application level changes
// Add this code to your application's startup code
if (ValidateLicense () == false)
{
DisplayLicenseForm();
if (ValidateLicense() == false)
{
Environment.Exit(0);
}
}
////////////////////////////////////////////////////
// New function to perform license validation instead
// of the typical ValidateLicenseAtStartup
////////////////////////////////////////////////////
private bool ValidateLicense()
{
bool ret = false;
bool validateOnServer = lv.QlmLicenseObject.ValidateOnServer;
// Disable server-side validation
lv.QlmLicenseObject.ValidateOnServer = false;
// Update the license binding as needed
bool needsActivation = false;
string errorMsg = string.Empty;
// Perform a local license validation to check if a specific feature is enabled.
if (lv.ValidateLicenseAtStartup(licenseBinding, ref needsActivation,
ref errorMsg) == true)
{
// assuming that you created a feature to allow a customer to always
// run offline with feature Set = 0 and Feature ID = 4.
bool offlineFeature = lv.QlmLicenseObject.IsFeatureEnabledEx(0, 4);
if (offlineFeature == true)
{
lv.QlmLicenseObject.MaxDaysOffline = -1;
lv.QlmLicenseObject.OfflinePeriodExceededAction =
EOfflinePeriodExceededAction.DoNothing;
ret = true;
}
else if (validateOnServer == true)
{
lv.QlmLicenseObject.ValidateOnServer = validateOnServer;
ret = lv.ValidateLicenseAtStartup(licenseBinding, ref needsActivation,
ref errorMsg);
}
}
else
{
// restore the original setting
lv.QlmLicenseObject.ValidateOnServer = validateOnServer;
}
return ret;
}PreviousHow to add license file validationNextHow to use GetDataSetEx to retrieve customer information
Last updated