This sample doesn’t contain Manco.Licensing DLL itself in it, so don’t forget to download main archive from the 'Download - Manco .NET Licensing System' page.
The Activation Web Service is the separate part of Manco .NET Licensing System. It is designed to perform 4 main functions:
In this article we describe how the Activation Web Service can be used for online product activation.
The Activation Web Service uses licensing schema that is similar to the Windows XP licensing. When you install Windows XP you enter the License Key that is printed on the sticker. When installation is finished you follow the process of Windows activation. During this process you obtain Activation Key from the Microsoft Activation Service. After that this particular copy of the Windows can work on one PC only.
Licensing scenario with Activation Web Service can be used when you’d like to bind licensed software to particular PC. This scenario limits using of your software with one PC per one License Key/License File bought from you. This schema works as following:
We suppose that you have read section "Quick Start using ‘Unlock Key’ licensing schema" already. So we will describe only things are specific for the “Unlock Key with Activation” licensing schema.
Activation Web Service can automatically send e-Mail with Activation Key to user. If you’d like to use this functionality you should configure activation letter for product that uses activation schema.
Firstly we should create e-Mail configuration for Activation Letter. Select “e-Mail Configuration” tab in the License Manager. Click "Add new e-mail" toolbar button. New e-Mail configuration will be added. Rename it (“My Product activation e-Mail” for example). Most fields on the e-Mail configuration view are good known for most people are using e-Mails in their practice.
Following fields are required:
When all necessary fields will be filled in click "Save all" toolbar button to save changes made.
Now select “Product” tab and select version node. In the “Activation Letter” combo box select e-Mail configuration you have created:
The “Unlock Key with Activation” license type can be defined as following:
Then you should create evaluation license file using this license type. Evaluation license file shouldn’t contain any Unlock or Activation Key (correspondent fields must be empty). Correspondent evaluation sale record could look like the following:
Pay attention that both: Unlock and Activation Keys are empty. Create license file and add it to your project.
Now you should prepare your product to use Activation Web Service.
Firstly add web reference to your project that will refer to the Activation Web Service:
Add evaluation window to your project. It could looks like the following:
Add “OnClick” event handler for the “Activate” button. This handler should set Unlock Key to the license object, obtain product ID and send it to the activation server.
[C#]
private void cmdActivateAndFill_Click(object sender, EventArgs e)
{
// If "Unlock Key" has been entered
if (txtUnlockKey.Text.Trim() != string.Empty)
{
// Pass "Unlock Key" to the license object
m_oLicense.UnlockKey = txtUnlockKey.Text.Trim();
// Get instance of the Activation Service
ActivationWebService.ActivationService loActivationService =
new ActivationWebService.ActivationService();
try
{
// Get product ID from the license and try to activate it
// Ask activation service to send copy of the key
// to the customer's e-Mail
string lsActivationKey =
loActivationService.ActivateProductGetKey(
m_oLicense.ProductID,
true);
if (lsActivationKey != null)
{
// In case when product succesfully activated
// user will recieve e-Mail with activation code.
txtActivationKey.Text = lsActivationKey;
MessageBox.Show("Activation Key has been succesfully"
+ " generated and passed to the text box."
+ " Click OK to continue.");
}
}
catch (Exception exc)
{
MessageBox.Show("Exception during activation:\n"
+ exc.ToString());
}
}
else
{
MessageBox.Show("Enter Unlock Key to be able activate product");
}
}
[Visual Basic .NET]
Private Sub cmdActivateAndFill_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cmdActivateAndFill.Click
' If "Unlock Key" has been entered
If txtUnlockKey.Text.Trim() <> String.Empty Then
' Pass "Unlock Key" to the license object
m_oLicense.UnlockKey = txtUnlockKey.Text.Trim()
' Get instance of the Activation Service
Dim loActivationService As ActivationWebService.ActivationService = _
New ActivationWebService.ActivationService()
Try
' Get product ID from the license and try to activate it
' Ask activation service to send copy of the key to
' the(customer) 's e-Mail
Dim lsActivationKey As String = _
loActivationService.ActivateProductGetKey( _
m_oLicense.ProductID, _
True)
If Not lsActivationKey Is Nothing Then
' In case when product succesfully activated user
' will recieve e-Mail with activation code.
txtActivationKey.Text = lsActivationKey
MessageBox.Show("Activation Key has been succesfully " _
& " generated and passed to the correspondent text box." _
& " Click OK to continue.")
End If
Catch exc As Exception
MessageBox.Show("Exception during activation:" _
& vbCrLf _
& exc.ToString())
End Try
Else
MessageBox.Show("Enter Unlock Key to be able activate product")
End If
End Sub
The evaluation window also should provide properties to get Unlock Key entered by user and Activation Key obtained from the Activation Web Service.
Next, the program needs to check to see the status of the license. If it is evaluation, or not valid, evaluation window needs to be shown that allows the user to input an Unlock Key and activate application. It looks like the best place for this code is “OnLoad” event handler:
[C#]
private void MainForm_Load(object sender, EventArgs e)
{
// Check if the current license is evaluation license or not valid
if (license.IsEvaluation || !license.IsValid)
{
// This is evaluation or not valid license,
// so we should show evaluation dialog
// This is evaluation license, so
// we should show license dialog
LicenseForm loForm = new LicenseForm(license);
if (loForm.ShowDialog() == DialogResult.OK
&& loForm.UnlockKey.Trim() != string.Empty
&& loForm.ActivationKey.Trim() != string.Empty)
{
// License information have been entered.
// Pass it to the license object for the
// following validation.
license.UnlockKey = loForm.UnlockKey;
license.ActivationKey = loForm.ActivationKey;
}
else if (license.IsExpired)
{
// The evaluation license has been expired and
// no license information have been entered,
// so we should close application.
Application.Exit();
}
}
// Now you can use license object to validate license.
// License will be valid if it is evaluation license,
// or entered valid Unlock and Activation keys.
if (license.IsValid)
{
// Initialize application
// Make some GUI elements available only when
// Unlock Key and Activation Key have been entered
// (license is valid and is not evaluation one).
tsmiAvailableWhenActivated.Enabled = !license.IsEvaluation;
txtAvailableWhenActivated.Enabled = !license.IsEvaluation;
openToolStripButton.Enabled = !license.IsEvaluation;
saveToolStripButton.Enabled = !license.IsEvaluation;
}
else
{
// It is not an evaluation license and valid Unlock Key
// and Activation Key have not been entered.
MessageBox.Show("License Not Valid\nIllegal validator: "
+ license.InvalidValidator.ToString(),
"Sample Application",
MessageBoxButtons.OK,
MessageBoxIcon.Stop);
Application.Exit();
}
}
[Visual Basic .NET]
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
' Check if the current license is evaluation license or not valid
If license.IsEvaluation Or Not license.IsValid Then
' This is evaluation or not valid license, so
' we should show license dialog
Dim loForm As LicenseForm = New LicenseForm(license)
If loForm.ShowDialog() = DialogResult.OK _
And loForm.UnlockKey.Trim() <> String.Empty _
And loForm.ActivationKey.Trim() <> String.Empty Then
' License information have been entered.
' Pass it to the license object for the
' following validation.
license.UnlockKey = loForm.UnlockKey
license.ActivationKey = loForm.ActivationKey
ElseIf license.IsExpired Then
' The evaluation license has been expired and
' no license information have been entered,
' so we should close application.
Application.Exit()
End If
End If
' Now you can use license object to validate license.
' License will be valid if it is evaluation license,
' or entered valid Unlock and Activation keys.
If license.IsValid Then
' Initialize application
' Make some GUI elements available only when
' Unlock Key and Activation Key have been entered
' (license is valid and is not evaluation one).
tsmiAvailableWhenActivated.Enabled = Not license.IsEvaluation
txtAvailableWhenActivated.Enabled = Not license.IsEvaluation
openToolStripButton.Enabled = Not license.IsEvaluation
saveToolStripButton.Enabled = Not license.IsEvaluation
Else
' It is not an evaluation license and valid Unlock Key
' and Activation Key have not been entered.
MessageBox.Show("License Not Valid" _
+ vbCrLf _
+ "Invalid Validator: " _
+ license.InvalidValidator.ToString(), _
"Sample Application", _
MessageBoxButtons.OK, _
MessageBoxIcon.Stop)
Application.Exit()
End If
End Sub
Now you application is ready to run. First time you start it you will see evaluation window with fields to enter Unlock and Activation keys and button for product activation. If you simple close this window your application will continue execution in the evaluation mode. You can check this mode using “IsEvaluation” property of the license object. You can enable or disable some functionality or GUI controls based on this status. To get your application fully functional you have to create “Unlock Key” and then activate it.
Click
toolbar button. You will see “Add new sale” window. Enter necessary customer information. Actually it is enough enter customer name and e-Mail, but we would recommend at least First and Last name too. Activation Web Service can send activation e-Mail to customer. If you’d like use this functionality then you MUST fill in “e-Mail” field in the sale window. Click
toolbar button to perform search of the client through the database. Click
toolbar button to generate Unlock Key.
Click OK to add new sale. Save all changes made in the License Manager. To do it click
toolbar button. All records have been created in the License Manager will be saved in the database.
Your next step depends on if Activation Web Service uses own database, or share database with License Manager. In case when AWS and License Manager are using common database you now can simple use Unlock Key have been created to activate your application. If AWS and License Manager use different databases then you should synchronize data before license can be activated. See “Activation Web Service Management” section for information how to synchronize databases.