コード例 #1
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);
            }
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
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);

            _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();
            });
        }
        public DesignTimeOfflineActivationWindow()
            : base(new ProcessStarter(), new DesignTimeUserGuideHelper(), new DesignTimeActivationHelper(), new TranslationProxy())
        {
            var interaction = new OfflineActivationInteraction("SomeLicenseKey");

            interaction.LicenseServerAnswer = "SomeLSA";
            SetInteraction(interaction);
        }
コード例 #5
0
        public void SetUp()
        {
            _process         = Substitute.For <IProcessStarter>();
            _userGuideHelper = Substitute.For <IUserGuideHelper>();
            var product = Product.PdfCreator;

            _offlineActivator = Substitute.For <IOfflineActivator>();
            var activation = new Activation(acceptExpiredActivation: true)
            {
                Product = product
            };

            _viewModel = new OfflineActivationViewModel(_process, _userGuideHelper, _offlineActivator, new OfflineActivationViewModelTranslation());
            _viewModel.FinishInteraction = () => { _finishInteractionWasCalled = true; };
            _propertiesChangedList       = new List <string>();

            _interaction = new OfflineActivationInteraction(ValidLicenseKey);
            _viewModel.SetInteraction(_interaction);
        }
コード例 #6
0
        public void SetUp()
        {
            _process = Substitute.For <IProcessStarter>();
            var product = Product.PdfCreator;

            _offlineActivator = Substitute.For <IOfflineActivator>();
            var activation = new Activation(acceptExpiredActivation: true)
            {
                Product = product
            };

            _translationUpdater = new TranslationUpdater(new TranslationFactory(), new ThreadManager());
            _viewModel          = new OfflineActivationUserControlViewModel(_process, _offlineActivator, _translationUpdater);

            _viewModel.FinishInteraction = () => { _finishInteractionWasCalled = true; };
            _propertiesChangedList       = new List <string>();

            _interaction = new OfflineActivationInteraction(ValidLicenseKey);
            _viewModel.SetInteraction(_interaction);
        }
コード例 #7
0
        public void SetUp()
        {
            _process         = Substitute.For <IProcessStarter>();
            _userGuideHelper = Substitute.For <IUserGuideHelper>();
            var product = Product.PdfCreator;

            _activationHelper = Substitute.For <IActivationHelper>();
            _activationHelper.Activation.Returns(new Activation()
            {
                Product = product
            });
            _translator = Substitute.For <ITranslator>();
            _translator.GetTranslation("OfflineActivationViewModel", "InvalidLicenseKeySyntax")
            .Returns(InvalidLicenseKeySyntaxMessage);
            _viewModel = new OfflineActivationViewModel(_process, _userGuideHelper, _activationHelper, _translator);
            _viewModel.FinishInteraction = () => { _finishInteractionWasCalled = true; };
            _propertiesChangedList       = new List <string>();

            _interaction = new OfflineActivationInteraction(ValidLicenseKey);
            _viewModel.SetInteraction(_interaction);
        }