private async void OnActivateCommand()
        {
            try
            {
                if (IsBusy)
                {
                    return;
                }

                IsBusy = true;

                var result = await _licenseService.RegisterAsync(_key);

                if (result.Successful)
                {
                    await _ctx.SetLicenseKeyAsync(result.License.Id.ToString());

                    LicenseGlobals.Set(AppLicense.Full);
                    IsBusy = false;
                    Initialize();
                }
                else
                {
                    ShowLicenseError(result);
                }
            }
            finally
            {
                IsBusy = false;
            }
        }
Beispiel #2
0
        public Task RunAsync()
        {
            var task = Task.Run(async() =>
            {
                var result = await ValidateAsync();
                if (result.Successful)
                {
                    LicenseGlobals.Set(AppLicense.Full);
                }
            });

            return(task);
        }
        public async override void Initialize()
        {
            try
            {
                if (IsBusy)
                {
                    return;
                }

                IsBusy = true;

                _key         = Guid.Empty;
                RegisterKey  = null;
                ErrorMessage = null;
                LicenseKey   = null;
                ShowError    = false;
                LicenseGlobals.Set(AppLicense.Demo);
                Description = $"Product Name - {LicenseGlobals.Get()}"; // TODO: localize

                var result = await _licenseService.ValidateAsync(true);

                if (result.Successful)
                {
                    LicenseGlobals.Set(AppLicense.Full);
                    LicenseKey    = result.License.Id.ToString();
                    LicensedTo    = result.License.Customer.Name;
                    ShowActivated = true;
                }
                else
                {
                    ShowLicenseError(result);
                }
                Description = $"Product Name - {LicenseGlobals.Get()}"; // TODO: localize, second time???
            }
            finally
            {
                IsBusy = false;
            }
        }