/// <summary>Default NetworkFloatingLicense constructor</summary> internal SampleLicense(LicensingGui gui) : base(LicenseConfiguration.EncryptionKey, true, true, LicenseConfiguration.ThisProductID, "", new List <SystemIdentifierAlgorithm>(new SystemIdentifierAlgorithm[] { new NetworkNameIdentifierAlgorithm(Path.GetDirectoryName(LicenseConfiguration.LicenseFilePath.ToLowerInvariant())) })) { this.ProductVersion = IOHelper.GetAssemblyFileVersion(System.Reflection.Assembly.GetEntryAssembly()); m_Settings = gui; }
/// <summary>Generates the LicenseStatusEntry objects containing network seats status, which displayed in the license management form</summary> /// <param name="validationResult">whether or not last license validation was successful</param> /// <param name="licensingGui">The LicensingGui object which will display the status</param> /// <param name="semaphore">The NetworkSemaphore object that contains total seats count and active/used seats count</param> internal void InitializeNetworkLicenseStatusEntries(bool validationResult, LicensingGui licensingGui, NetworkSemaphore semaphore) { InitializeLicenseStatusEntries(validationResult, licensingGui); if (validationResult && semaphore != null) { licensingGui.LicenseStatusEntries.Add(new LicenseStatusEntry(LicenseStatusIcon.Information, "Network Seats", "Seats Used: " + semaphore.SeatsActive.ToString() + " out of " + semaphore.SeatsTotal.ToString())); } }
/// <summary>Performs post-processing updates for actions performed through the <see cref="LicensingGui"/>.</summary> /// <remarks><para>This method is called by the <see cref="LicensingGui.LicenseManagementActionComplete"/> event handler method. In the /// sample application form source code (i.e. MainForm.cs), this method is similarly named PostProcessingUpdates. This might be named /// something like licensingGui1_LicenseManagementActionComplete in your application.</para></remarks> /// <param name="lic">The <see cref="License"/> being processed.</param> /// <param name="licGui">The <see cref="LicensingGui"/> used to process updates for the license.</param> /// <param name="e">The post-processing event arguments returned from the <see cref="LicensingGui"/> object.</param> /// <param name="newValidationSuccessful">Whether or not validation after processing updates has passed successfully.</param> internal static void PostProcessingUpdates(ref SampleLicense lic, ref LicensingGui licGui, ref LicenseManagementActionCompleteEventArgs e, out bool newValidationSuccessful) { //If an action was processed, run some post-processing actions. if (LicenseManagementActionTypes.ManualTriggerCode == e.ActionType) { //A trigger code needs to be processed... if (!lic.ProcessTriggerCode(e.LicenseID, e.Password, e.TriggerCodeNumber, e.TriggerCodeEventData)) { //If trigger code processing failed, show the error in the license management dialog. e.PostProcessingSuccessful = false; e.LastError = lic.LastError; } //Reload and revalidate the license file. if (lic.LoadFile(LicenseConfiguration.LicenseFilePath)) { newValidationSuccessful = lic.Validate(); } else { newValidationSuccessful = false; } } else if (LicenseError.ERROR_WEBSERVICE_RETURNED_FAILURE == e.LastError.ErrorNumber) { //The last action failed because the license is no longer valid in SOLO Server, so remove the license from the system. if (ShouldLicenseBeRevoked(lic.LastError.ExtendedErrorNumber)) { RevokeLicense(ref lic, ref licGui); newValidationSuccessful = false; } else { //The web service returned an error, which should be disabled to the user. e.PostProcessingSuccessful = false; e.LastError = lic.LastError; } } else if (LicenseManagementActionTypes.OnlineDeactivation == e.ActionType || LicenseManagementActionTypes.ManualDeactivation == e.ActionType) { RevokeLicense(ref lic, ref licGui); newValidationSuccessful = false; return; } else if (e.ProcessedSuccessfully && (LicenseManagementActionTypes.OnlineActivation == e.ActionType || LicenseManagementActionTypes.OnlineRefresh == e.ActionType || LicenseManagementActionTypes.ManualActivation == e.ActionType || LicenseManagementActionTypes.ManualRefresh == e.ActionType)) { //This was a successful activation or license refresh attempt, which means we have a new license to process. lic.ProcessNewLicense(ref e, out newValidationSuccessful); } newValidationSuccessful = lic.Validate(); }
//TODO: IMPORTANT: This code depends on the data from the LicenseConfiguration class. Make sure you update the members in that class if you copy it into your application! #region Constructors /// <summary>Creates a new <see cref="SampleLicense"/>.</summary> /// <param name="settings"><see cref="LicensingGui"/> object used, which can provide objects used for making web service calls.</param> internal SampleLicense(LicensingGui settings) : base(LicenseConfiguration.EncryptionKey, true, true, LicenseConfiguration.ThisProductID, LicenseConfiguration.ThisProductVersion, LicenseConfiguration.SystemIdentifierAlgorithms) { m_Settings = settings; //Initialize the alias configuration... foreach (LicenseAlias alias in LicenseConfiguration.Aliases) { AddAlias(alias); } }
/// <summary>Generates the <see cref="LicenseStatusEntry"/> objects displayed on the license management form.</summary> /// <remarks> /// <para>This method is called from the application's primary form. The call to this method is typically located in a common method /// that is used to update controls on the form based on the new license status. For example, this method is called "UpdateLicenseStatus" /// in the sample applications.</para> /// </remarks> /// <param name="lastValidationSuccessful">Whether or not the last license validation was successful.</param> /// <param name="licGui">The <see cref="LicensingGui"/> object which will display the status.</param> internal void InitializeLicenseStatusEntries(bool lastValidationSuccessful, LicensingGui licGui) { licGui.LicenseStatusEntries.Clear(); licGui.LicenseStatusEntries.Add(GenerateLicenseStatusEntry(lastValidationSuccessful)); //TODO: If you have other license parameters (such as network seats, allowed application/feature uses remaining, etc...), // or modules/features which should have a status entry displayed, add the entries here. Some rough examples are // provided in the comments immediately below. //licGui.LicenseStatusEntries.Add(new LicenseStatusEntry(LicenseStatusIcon.Ok, "Ok Test", "This is an Ok test item.")); //licGui.LicenseStatusEntries.Add(new LicenseStatusEntry(LicenseStatusIcon.Information, "Information Test", "This is an Information test item.")); //licGui.LicenseStatusEntries.Add(new LicenseStatusEntry(LicenseStatusIcon.Unavailable, "Unavailable Test", "This is an Unavailable test item.")); //licGui.LicenseStatusEntries.Add(new LicenseStatusEntry(LicenseStatusIcon.Warning, "Warning Test", "This is an Warning test item.")); }
/// <summary>Revokes the license.</summary> /// <remarks><para>This method is called from <see cref="PostProcessingUpdates"/>.</para></remarks> /// <param name="lic">The <see cref="License"/> object being revoked.</param> /// <param name="licGui">The <see cref="LicensingGui"/> which references the <see cref="License"/> object.</param> internal static void RevokeLicense(ref SampleLicense lic, ref LicensingGui licGui) { //The license has been revoked, so remove it from the system. lic.RemoveLicense(); //Create a new License to clear out any data (like the License ID and Installation ID) from memory. lic = SampleLicense.CreateNewLicense(licGui); //Now try to load the license file even though it doesn't exist. This helps ensure the correct error //message is displayed in the license status entry if the license management form is opened again. lic.LoadFile(LicenseConfiguration.LicenseFilePath); //Update the reference to the License object in case the license management form is opened again. licGui.ApplicationLicense = lic; }
/// <summary>Creates a new <see cref="SampleLicense"/></summary> /// <param name="gui">The <see cref="LicensingGui"/> object used by the main form.</param> /// <returns>Returns a new <see cref="SampleLicense"/> object.</returns> internal static SampleLicense CreateNewLicense(LicensingGui gui) { return(new SampleLicense(gui)); }
//TODO: IMPORTANT: This code depends on the data from the LicenseConfiguration class. Make sure you update the members in LicenseConfiguration if you copy it into your application! #region Constructors /// <summary>Creates a new <see cref="SampleLicense"/>.</summary> /// <param name="settings">The <see cref="LicensingGui"/> object, which may be used to obtain proxy authentication credentials from the user.</param> internal SampleLicense(LicensingGui settings) : base(LicenseConfiguration.EncryptionKey, true, true, LicenseConfiguration.ThisProductID, LicenseConfiguration.ThisProductVersion, LicenseConfiguration.SystemIdentifierAlgorithms) { m_Settings = settings; }