public static async Task DefaultNetworkLicenseServiceValidationHandlerAsync(object sender, NetworkValidatedEventArgs e)
        {
            if (_isInErrorHandling)
            {
                Log.Warning("Already handling the invalid license usage");
                return;
            }

            var validationResult = e.ValidationResult;
            if (!validationResult.IsValid)
            {
                if (validationResult.IsCurrentUserLatestUser())
                {
                    _isInErrorHandling = true;

                    var serviceLocator = ServiceLocator.Default;

                    var dispatcherService = serviceLocator.ResolveType<IDispatcherService>();
                    await dispatcherService.InvokeAsync(async () =>
                    {
                        var uiVisualizerService = serviceLocator.ResolveType<IUIVisualizerService>();
                        await uiVisualizerService.ShowDialogAsync<NetworkLicenseUsageViewModel>(validationResult);
                    });

                    _isInErrorHandling = false;

                    // Force check
                    var networkLicenseService = serviceLocator.ResolveType<INetworkLicenseService>();
                    networkLicenseService.ValidateLicense();
                }
            }
        }
        private async void OnNetworkLicenseValidated(object sender, NetworkValidatedEventArgs e)
        {
            var validationResult = e.ValidationResult;

            if (!validationResult.IsValid)
            {
                var latestUsage = validationResult.GetLatestUser();

                if (validationResult.IsCurrentUserLatestUser())
                {
                    await _messageService.ShowAsync(string.Format("License is invalid, using '{0}' of '{1}' licenses. You are the latest user, your software will be shut down", validationResult.CurrentUsers.Count, validationResult.MaximumConcurrentUsers));
                }
                else
                {
                    await _messageService.ShowAsync(string.Format("License is invalid, using '{0}' of '{1}' licenses. The latest user is '{2}' with ip '{3}', you can continue working", validationResult.CurrentUsers.Count, validationResult.MaximumConcurrentUsers, latestUsage.UserName, latestUsage.Ip));
                }
            }
        }
        public static void DefaultNetworkLicenseServiceValidationHandler(object sender, NetworkValidatedEventArgs e)
        {
            if (_isInErrorHandling)
            {
                Log.Warning("Already handling the invalid license usage");
                return;
            }

            var validationResult = e.ValidationResult;
            if (!validationResult.IsValid)
            {
                if (validationResult.IsCurrentUserLatestUser())
                {
                    _isInErrorHandling = true;

                    var entryAssembly = AssemblyHelper.GetEntryAssembly();

                    var message = string.Format("The current number of usages for {0} is higher than the maximum number of concurrent users allowed based on the current license. Since this computer is the last one using the license, the software has to shut down.\n\nIf you feel that you have not reached the maximum number of usages, please contact support.\n\nThe maximum allowed is {1}, the current usage is {2}.", entryAssembly.Title(), validationResult.MaximumConcurrentUsers, validationResult.CurrentUsers.Count);

                    Log.Error(message);

                    Log.Error("Listing all the usages of the license:");
                    Log.Indent();

                    foreach (var licenseUsage in validationResult.CurrentUsers)
                    {
                        Log.Error("* {0}", licenseUsage);
                    }

                    Log.Unindent();

                    Log.Info("Shutting down application");

                    var process = Process.GetCurrentProcess();
                    process.Kill();
                }
            }
        }
Beispiel #4
0
 private void OnNetworkLicenseValidated(object sender, NetworkValidatedEventArgs e)
 {
     UpdateValidationResult(e.ValidationResult);
 }
        private async void OnNetworkLicenseValidated(object sender, NetworkValidatedEventArgs e)
        {
            var validationResult = e.ValidationResult;
            if (!validationResult.IsValid)
            {
                var latestUsage = validationResult.GetLatestUser();

                if (validationResult.IsCurrentUserLatestUser())
                {
                    await _messageService.ShowAsync(string.Format("License is invalid, using '{0}' of '{1}' licenses. You are the latest user, your software will be shut down", validationResult.CurrentUsers.Count, validationResult.MaximumConcurrentUsers));
                }
                else
                {
                    await _messageService.ShowAsync(string.Format("License is invalid, using '{0}' of '{1}' licenses. The latest user is '{2}' with ip '{3}', you can continue working", validationResult.CurrentUsers.Count, validationResult.MaximumConcurrentUsers, latestUsage.UserName, latestUsage.Ip));
                }
            }
        }
 private void OnNetworkLicenseValidated(object sender, NetworkValidatedEventArgs e)
 {
     UpdateValidationResult(e.ValidationResult);
 }