Advanced use licensing

Licensed use allows you to use all of the Advanced features of ScriptX in any way you choose. There are two use scenarios:

  • As for Basic use, the ScriptX Factory is either already present in a document displayed in a web browser control, or injected. All the advanced ScriptX properties/methods are available and are used as appropriate and the content displayed in the web browser control is printed. (See our Github repo for a complete sample - the project WpfBrowserLicensedUse).
  • The PrintHtml() method is use to print dynamically created HTML or a pre-existing document - no web browser control is required.

License types

Two types of license are available:

  1. A machine license which will license the use of ScriptX by any applications on the machines listed in the license, or
  2. An application license that will license the use of ScriptX by the process to which it is applied - a unique license is required for each application but the application may be deployed to any number of desktops.

Machine license

A machine license is to all intents and purposes the same as a server side / remote printing license but is always used by the interactive account. Installation of the license is as per for server side licenses.

Application license

The application to which the license applied must contain a version info resource with the following information:

  • The application (product) name as the resource 'ProductName'
  • Your company name as the resource 'CompanyName'
  • Your company name must appear within the resource 'LegalCopyright'.

An application license does not require separate install processes. The MeadCo license file is either delivered with the application or made available for download by the application. The license is then 'installed' when it is used.

Using (applying) the license

The following XAML code behind shows the principle of using a license within an application; the MeadCo Security Manager object is created and the Apply method called.

A suitable point for applying the license in a desktop app is during the frame load event:

private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
{
   WebBrowser.Navigate(_homeUrl);

   // license this application so that everything is possible.
   ApplyScriptXLicense();
}

A console application might apply the license during its initialisation. A service should apply the license on each use of ScriptX features.

The details of the license (its GUID, the revision and the location of the license file) are stored in app.config:

private void ApplyScriptXLicense()
{
   Guid licenseGuid = new Guid(ConfigurationManager.AppSettings["ScriptXLicenseGuid"]);

   UriBuilder uriBuilder = new UriBuilder();
   uriBuilder.Scheme = "http";
   uriBuilder.Host = ConfigurationManager.AppSettings["ScriptXLicenseHost"];
   uriBuilder.Path = $"download/{licenseGuid.ToString()}/mlf";
       
   ApplyScriptXLicense(uriBuilder.Uri,
      licenseGuid, 
      Int32.Parse(ConfigurationManager.AppSettings["ScriptXLicenseRevision"]));
}

With these details, the license can be applied to the process:

/// <summary>
/// License this application for use of ScriptX Advanced features.
/// *NOTE* When debugging, must *not* Enable the Visual Studio Hosting Process 
/// (on Project properties -> Debug page)
/// </summary>
///
/// <param name="licenseUri">The Uri of the license file, 
///                      can be null/empty if using a machine license</param>
/// <param name="licenseGuid">The unique id of the license</param>
/// <param name="licenseRevision">The license revision</param>
private void ApplyScriptXLicense(Uri licenseUri, Guid licenseGuid, int licenseRevision)
{
   var secMgr = new SecMgr.SecMgr();

   try
   {
      secMgr.Apply(licenseUri == null ? "" : licenseUri.ToString(),
         "{" + licenseGuid.ToString() + "}",
         licenseRevision);
   }
   catch (Exception e)
   {
      MessageBox.Show(string.Format("Failed to license this application using: {0}\n\n
          The error was: {1}", 
          licenseUri == null ? "the machine license" : licenseUri.ToString(),e.Message),
          this.Title);
   }
}

 

::> Applying the license