private void OfflineActivationCommandExecute(object obj) { var interaction = new OfflineActivationInteraction(_lastActivationKey); _interactionInvoker.Invoke(interaction); if (interaction.Success) { _lastActivationKey = interaction.LicenseKey; Activation activation; try { activation = _activationHelper.ActivateOfflineActivationStringFromLicenseServer(interaction.LicenseServerAnswer); } catch (FormatException) { activation = new Activation(); activation.Key = interaction.LicenseKey; } UpdateActivation(activation); IsCheckingLicense = false; LicenseCheckFinishedEvent.Set(); } }
protected virtual void OfflineActivationCommandExecute(object obj) { if (_offlineActivator == null) { return; } var lastActivationKey = LicenseKey; if (string.IsNullOrWhiteSpace(lastActivationKey)) { lastActivationKey = _licenseChecker.GetSavedLicenseKey().ValueOr(""); } var interaction = new OfflineActivationInteraction(lastActivationKey); _interactionRequest.Raise(interaction, activationInteraction => { if (activationInteraction.Success) { var activation = _offlineActivator.ValidateOfflineActivationString(interaction.LicenseServerAnswer); activation.MatchSome(a => _offlineActivator.SaveActivation(a)); //Just to show in UI //LicenseChecker in UpdateActivation can't save activation UpdateActivation(activation); } IsCheckingLicense = false; LicenseCheckFinishedEvent.Set(); }); }
private void Activate(string key) { IsCheckingLicense = true; try { var activation = _licenseChecker.ActivateWithoutSaving(key.Replace("-", "")); _dispatcher.BeginInvoke(() => UpdateActivation(activation)); } finally { IsCheckingLicense = false; LicenseCheckFinishedEvent.Set(); } }
private void ActivateWithKeyAsync(string key) { Task.Factory.StartNew(() => { IsCheckingLicense = true; try { var licenseChecker = _licenseServerHelper.BuildLicenseChecker(Edition.Activation.Product, RegistryHive.CurrentUser); var activation = licenseChecker.ActivateWithoutSavingActivation(key.Replace("-", "")); UpdateActivation(licenseChecker, activation, key); } catch { } finally { IsCheckingLicense = false; LicenseCheckFinishedEvent.Set(); } }); }