Пример #1
0
        private async Task <Models.Shared.LicenseKeyInstallResult> Activate(string email, string key)
        {
            var licensingManager = _pluginManager.LicensingManager;

            if (licensingManager != null)
            {
                var activated = await licensingManager.IsInstallActive(ProductTypeID, Certify.Management.Util.GetAppDataFolder());

                if (!activated)
                {
                    var validationResult = await licensingManager.Validate(ProductTypeID, email, key);

                    if (validationResult.IsValid)
                    {
                        var instance = new Models.Shared.RegisteredInstance
                        {
                            InstanceId = _prefs.InstanceId,
                            AppVersion = Management.Util.GetAppVersion().ToString()
                        };

                        // activate install
                        var result = await licensingManager.RegisterInstall(ProductTypeID, email, key, instance);

                        return(result);
                    }
                    else
                    {
                        return(new Models.Shared.LicenseKeyInstallResult {
                            IsSuccess = false, Message = validationResult.ValidationMessage
                        });
                    }
                }
                else
                {
                    return(new Models.Shared.LicenseKeyInstallResult {
                        IsSuccess = true, Message = "Instance already activated"
                    });
                }
            }
            else
            {
                return(new Models.Shared.LicenseKeyInstallResult {
                    IsSuccess = false, Message = "Licensing plugin unavailable"
                });
            }
        }
Пример #2
0
        private async void Deactivate_Click(object sender, RoutedEventArgs e)
        {
            var productTypeId = ViewModel.AppViewModel.ProductTypeId;

            var email = DeactivateEmail.Text?.Trim().ToLower();


            if (string.IsNullOrEmpty(email))
            {
                MessageBox.Show(Certify.Locales.SR.Registration_NeedEmail);
                return;
            }


            Mouse.OverrideCursor = Cursors.Wait;

            var licensingManager = ViewModel.AppViewModel.Current.PluginManager?.LicensingManager;

            if (licensingManager != null)
            {
                var instance = new Models.Shared.RegisteredInstance
                {
                    InstanceId = ViewModel.AppViewModel.Current.Preferences.InstanceId,
                    AppVersion = Management.Util.GetAppVersion().ToString()
                };
                var resultOK = await licensingManager.DeactivateInstall(productTypeId, Management.Util.GetAppDataFolder(), email, instance);

                Mouse.OverrideCursor = Cursors.Arrow;

                if (resultOK)
                {
                    ViewModel.AppViewModel.Current.IsRegisteredVersion = false;
                    MessageBox.Show("This install has now been deactivated. You can enter a different license key or use your key on another install.");
                    Close();
                }
                else
                {
                    MessageBox.Show("The install could not be deactivated, check specified email address is correct for account. You can manually delete the C:\\ProgramData\\Certify\\reg_1 file and deactivate your install on https://certifytheweb.com");
                }
            }

            Mouse.OverrideCursor = Cursors.Arrow;
        }
Пример #3
0
        private async Task <bool> Deactivate(string email)
        {
            var licensingManager = _pluginManager.LicensingManager;

            if (licensingManager != null)
            {
                var instance = new Models.Shared.RegisteredInstance
                {
                    InstanceId = _prefs.InstanceId,
                    AppVersion = Management.Util.GetAppVersion().ToString()
                };

                var deactivated = await licensingManager.DeactivateInstall(ProductTypeID, Certify.Management.Util.GetAppDataFolder(), email, instance);

                return(deactivated);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        private async void ValidateKey_Click(object sender, RoutedEventArgs e)
        {
            var email = EmailAddress.Text?.Trim().ToLower();
            var pwd   = Password.Password.Trim();

            if (String.IsNullOrEmpty(email))
            {
                MessageBox.Show(Certify.Locales.SR.Registration_NeedEmail);
                return;
            }

            if (String.IsNullOrEmpty(pwd))
            {
                // MessageBox.Show(Certify.Locales.SR.Registration_NeedKey);
                return;
            }

            ValidateKey.IsEnabled = false;
            Mouse.OverrideCursor  = Cursors.Wait;

            var dashboardClient = ViewModel.AppViewModel.Current.PluginManager?.DashboardClient;

            if (dashboardClient != null)
            {
                try
                {
                    var instance = new Models.Shared.RegisteredInstance
                    {
                        InstanceId  = ViewModel.AppViewModel.Current.Preferences.InstanceId,
                        AppVersion  = new Management.Util().GetAppVersion().ToString(),
                        OS          = Environment.OSVersion.ToString(),
                        MachineName = Environment.MachineName
                    };

                    var resultOK = await dashboardClient.RegisterInstance(instance, email, pwd, (bool)CreateNewAccount.IsChecked);

                    Mouse.OverrideCursor = Cursors.Arrow;

                    if (resultOK)
                    {
                        await ViewModel.AppViewModel.Current.SetInstanceRegistered();

                        MessageBox.Show("Server registration completed.");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Server registration could not complete.");
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show(Certify.Locales.SR.Registration_KeyValidationError);
                }
            }
            else
            {
                MessageBox.Show(Certify.Locales.SR.Registration_UnableToVerify);
            }

            ValidateKey.IsEnabled = true;
            Mouse.OverrideCursor  = Cursors.Arrow;
        }
Пример #5
0
        private async void ValidateKey_Click(object sender, RoutedEventArgs e)
        {
            var productTypeId = ViewModel.AppViewModel.ProductTypeId;

            var email = EmailAddress.Text?.Trim().ToLower();
            var key   = LicenseKey.Text?.Trim().ToLower();

            if (string.IsNullOrEmpty(email))
            {
                MessageBox.Show(Certify.Locales.SR.Registration_NeedEmail);
                return;
            }

            if (string.IsNullOrEmpty(key))
            {
                MessageBox.Show(Certify.Locales.SR.Registration_NeedKey);
                return;
            }

            ValidateKey.IsEnabled = false;
            Mouse.OverrideCursor  = Cursors.Wait;

            var licensingManager = ViewModel.AppViewModel.Current.PluginManager?.LicensingManager;

            if (licensingManager != null)
            {
                try
                {
                    var validationResult = await licensingManager.Validate(productTypeId, email, key);

                    if (validationResult.IsValid)
                    {
                        var instance = new Models.Shared.RegisteredInstance
                        {
                            InstanceId = ViewModel.AppViewModel.Current.Preferences.InstanceId,
                            AppVersion = Management.Util.GetAppVersion().ToString()
                        };

                        var installRegistration = await licensingManager.RegisterInstall(productTypeId, email, key, instance);

                        Mouse.OverrideCursor = Cursors.Arrow;
                        if (installRegistration.IsSuccess)
                        {
                            var settingsPath = Management.Util.GetAppDataFolder();
                            if (licensingManager.FinaliseInstall(productTypeId, installRegistration, settingsPath))
                            {
                                ViewModel.AppViewModel.Current.IsRegisteredVersion = true;
                                MessageBox.Show(installRegistration.Message);

                                Close();
                            }
                        }
                        else
                        {
                            ValidateKey.IsEnabled = true;
                            MessageBox.Show(installRegistration.Message);
                        }
                    }
                    else
                    {
                        MessageBox.Show(validationResult.ValidationMessage);
                    }
                }
                catch (Exception exp)
                {
                    Log?.Information("ValidateKey:" + exp.ToString());

                    MessageBox.Show(Certify.Locales.SR.Registration_KeyValidationError);
                    MessageBox.Show(exp.ToString());
                }
            }
            else
            {
                MessageBox.Show("Could not load the licensing validation plugin. The app may need to be re-installed.");
            }

            ValidateKey.IsEnabled = true;
            Mouse.OverrideCursor  = Cursors.Arrow;
        }