public PrioritySupportUrlOpenCommand(IProcessStarter processStarter, IVersionHelper versionHelper, ILicenseChecker licenseChecker, LicenseKeySyntaxChecker licenseKeySyntaxChecker, Configuration config) : base(processStarter) { _versionHelper = versionHelper; var edition = LicenseValidator.Interface.Tools.StringValueAttribute.GetStringValue(config.Product); var key = licenseChecker.GetSavedLicenseKey().ValueOr(""); var normKey = licenseKeySyntaxChecker.NormalizeLicenseKey(key); Url = BuildUrl(edition, normKey); }
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); _interactionInvoker.Invoke(interaction); if (interaction.Success) { var activation = _offlineActivator.ValidateOfflineActivationString(interaction.LicenseServerAnswer); try { activation.MatchSome(a => _offlineActivator.SaveActivation(a)); } catch (SecurityException) { } //Just to show in UI //LicenseChecker in UpdateActivation can't save activation UpdateActivation(activation); } IsCheckingLicense = false; LicenseCheckFinishedEvent.Set(); }
protected virtual async Task OfflineActivationCommandExecute(object obj) { if (_offlineActivator == null) { return; } var lastActivationKey = LicenseKey; if (string.IsNullOrWhiteSpace(lastActivationKey)) { lastActivationKey = _licenseChecker.GetSavedLicenseKey().ValueOr(""); } var interaction = new OfflineActivationInteraction(lastActivationKey); await _interactionRequest.RaiseAsync(interaction); if (interaction.Success) { var activation = _offlineActivator.ValidateOfflineActivationString(interaction.LicenseServerAnswer); try { activation.MatchSome(a => _offlineActivator.SaveActivation(a)); } catch (SecurityException) { _logger.Info("Can't save activation. Please share the license for all users."); } //Just to show in UI //LicenseChecker in UpdateActivation can't save activation await UpdateActivation(activation); RaiseLicensePropertyChangedEvents(); } }
private Option <Activation, LicenseError> RenewActivation() { var activation = _licenseChecker.GetSavedActivation(); if (activation.Exists(a => a.ActivationMethod == ActivationMethod.Offline)) { return(activation); } if (activation.Exists(IsActivationPeriodStillValid)) { return(activation); } var licenseKey = activation.Match( some: a => a.Key.Some <string, LicenseError>(), none: e => _licenseChecker.GetSavedLicenseKey()); return(licenseKey.Match( some: key => _licenseChecker.ActivateWithKey(key), none: e => Option.None <Activation, LicenseError>(LicenseError.NoLicenseKey))); }
private Option <Activation, LicenseError> RenewActivation() { var activation = _licenseChecker.GetSavedActivation(); if (activation.Exists(a => a.ActivationMethod == ActivationMethod.Offline)) { return(activation); } if (activation.Exists(IsActivationPeriodStillValid)) { return(activation); } var licenseKey = activation.Match( some: a => a.Key.Some <string, LicenseError>(), none: e => _licenseChecker.GetSavedLicenseKey()); return(licenseKey.Match( some: key => { var newActivation = _licenseChecker.ActivateWithoutSaving(key); // Only save if we receive a valid license or the license was blocked newActivation .Filter(a => a.IsActivationStillValid() || a.Result == Result.BLOCKED, LicenseError.NoActivation) .MatchSome(a => _licenseChecker.SaveActivation(a)); // If the online activation failed and the old activation is still valid, return the current activation if (!newActivation.HasValue && activation.Exists(a => a.IsActivationStillValid())) { return activation; } return newActivation; }, none: e => Option.None <Activation, LicenseError>(LicenseError.NoLicenseKey))); }
public Option <string, LicenseError> GetSavedLicenseKey() { return(_licenseChecker.GetSavedLicenseKey()); }