コード例 #1
0
        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);
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
            }
        }
コード例 #4
0
        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)));
        }
コード例 #5
0
        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)));
        }
コード例 #6
0
 public Option <string, LicenseError> GetSavedLicenseKey()
 {
     return(_licenseChecker.GetSavedLicenseKey());
 }