Protected Overridable Function CheckProfile ( _ context As ServerRequestContext, _ limit As ActivationLimit, _ storedHash As String, _ lastActivated As DateTime, _ machineId As Integer, _ <OutAttribute> ByRef profile As ActivationProfile _ ) As Boolean
protected virtual bool CheckProfile( ServerRequestContext context, ActivationLimit limit, string storedHash, DateTime lastActivated, int machineId, out ActivationProfile profile )
The CheckProfile method is used only by license servers that persist the complete activation information in a database. The server wizard for instance will generate code that will call this method to determine if it can overwrite an existing activation.
The default rule will permit re-activation if 3 months have passed since the last activation or if the machine difference is within the tolerance of the Activation limit.
This sample demonstrates a very basic implementation of a license server's Activate method. For complete information on license servers see the License Servers in DeployLX Licensing topic.
<%@ WebService Language="VB" Class="MyLicenseServer" %>
Imports System
Imports System.IO
Imports System.Collections
Imports DeployLX.Licensing.v5
Imports DeployLX.Licensing.Management.v5
<System.Web.Services.WebService(Namespace:="http://www.xheo.com/licensing/v3_0")> _
Public Class MyLicenseServer
Inherits DeployLX.Licensing.Management.v5.LicenseServer
...
Protected Overrides Function CanActivate(ByVal context As ServerRequestContext, ByVal limit As ActivationLimit, ByRef suggestedProfile As ActivationProfile) As Boolean
Select Case context.LicensedAssemblyName
Case "DeployLX.Licensing.Management.v5"
' If already activated don't permit.
If FileContains("ActivatedSerials.dat", context.SerialNumber) Then
Return False
End If
Case "DeployLX.Licensing.v5"
Return True
End Select
Return True
End Function
Protected Overrides Sub RecordActivation(ByVal context As ServerRequestContext, ByVal limit As ActivationLimit, ByVal profile As ActivationProfile)
AddToFile("ActivatedSerials.dat", context.SerialNumber)
End Sub
...
Private Shared Sub AddToFile(ByVal path As String, ByVal serialNumber As String)
If FileContains(path, serialNumber) Then
Return
End If
Using writer As New StreamWriter(path, True)
writer.WriteLine(serialNumber)
End Using
End Sub
Private Shared Function FileContains(ByVal path As String, ByVal serialNumber As String) As Boolean
Using reader As New StreamReader(path)
Dim line As String = reader.ReadLine()
If line.Contains(serialNumber) Then
Return True
End If
End Using
Return False
End Function
End Class
<%@ WebService Language="C#" Class="MyLicenseServer" %>
using System;
using System.IO;
using System.Collections;
using DeployLX.Licensing.v5;
using DeployLX.Licensing.Management.v5;
[System.Web.Services.WebService( Namespace="http://www.xheo.com/licensing/v3_0" ) ]
public class MyLicenseServer : DeployLX.Licensing.Management.v5.LicenseServer
{
...
protected override bool CanActivate( ServerRequestContext context, ActivationLimit limit, ref ActivationProfile suggestedProfile )
{
switch( context.LicensedAssemblyName )
{
case "DeployLX.Licensing.Management.v5":
// If already activated don't permit.
if( FileContains( "ActivatedSerials.dat", context.SerialNumber ) )
return false;
break;
case "DeployLX.Licensing.v5":
return true;
}
return true;
}
protected override void RecordActivation( ServerRequestContext context, ActivationLimit limit, ActivationProfile profile )
{
AddToFile( "ActivatedSerials.dat", context.SerialNumber );
}
...
private static void AddToFile( string path, string serialNumber )
{
if( FileContains( path, serialNumber ) )
return;
using( StreamWriter writer = new StreamWriter( path, true ) )
writer.WriteLine( serialNumber );
}
private static bool FileContains( string path, string serialNumber )
{
using( StreamReader reader = new StreamReader( path ) )
{
string line = reader.ReadLine();
if( line.Contains( serialNumber ) )
return true;
}
return false;
}
}
Assembly: DeployLX.Licensing.Management.v5 (in DeployLX.Licensing.Management.v5.dll)