/// <summary> /// Runs on a thread pool thread periodically. /// </summary> /// <param name="o"></param> private void Verify(object o) { lock (singleThreadedVerify) { try { //No verification of license store needed; they can be replaced by user ILicenseStore s = c.Plugins.GetOrInstall <ILicenseStore>(new LicenseStore(this.LicenseCacheFilePattern)); //Get all encrypted licenses and // Decrypt them, grouping by normalized domain name var licenses = RemovedExpired(DecryptAll(s.GetLicenses())); //Fix all possible pendingFeatures using existing license data. UpdateFeatureStatus(licenses); if (pendingFeatures.Count > 0) { //Send off https request based on appId and pendingFeatures pairs. //Get List<byte> in return. var newLicenses = DecryptAll(RequestLicenses(pendingFeatures)); if (newLicenses.Count > 0) { //Update cached feature statuses UpdateFeatureStatus(newLicenses); s.SetLicenses(ExportLicenses(Merge(licenses, newLicenses))); } } } finally { lastEndedVerification = DateTime.UtcNow; } } }
protected override void PerformBackgroundAction() { var licenses = RemovedExpired(DecryptAll(licenseStore.GetLicenses())); // Fix all possible pendingFeatures using existing license data. UpdateFeatureStatus(licenses, true); // If we still have pending features, retrieve license info from KeyHub if (pendingFeatures.Count > 0) { var newLicenses = DecryptAll(RequestLicenses()); if (newLicenses.Count > 0) { UpdateFeatureStatus(newLicenses, false); licenseStore.SetLicenses(ExportLicenses(Merge(licenses, newLicenses))); } } }