public NetworkLicenseUsageViewModel(NetworkValidationResult networkValidationResult, ILicenseInfoService licenseInfoService, IProcessService processService, INetworkLicenseService networkLicenseService, IDispatcherService dispatcherService) { Argument.IsNotNull(() => networkValidationResult); Argument.IsNotNull(() => licenseInfoService); Argument.IsNotNull(() => processService); Argument.IsNotNull(() => networkLicenseService); Argument.IsNotNull(() => dispatcherService); _licenseInfoService = licenseInfoService; _processService = processService; _networkLicenseService = networkLicenseService; _dispatcherService = dispatcherService; var assembly = AssemblyHelper.GetEntryAssembly(); Title = assembly.Title() + " licence usage"; PurchaseUrl = _licenseInfoService.GetLicenseInfo().PurchaseUrl; UpdateValidationResult(networkValidationResult, false); _dispatcherTimer.Interval = TimeSpan.FromSeconds(15); CloseApplication = new Command(OnCloseApplicationExecute); BuyLicenses = new Command(OnBuyLicensesExecute); }
private async Task OnValidateLicenseOnLocalNetworkExecuteAsync() { NetworkValidationResult validationResult = null; validationResult = _networkLicenseService.ValidateLicense(); await _messageService.ShowAsync(string.Format("License is {0}valid, using '{1}' of '{2}' licenses", validationResult.IsValid ? string.Empty : "NOT ", validationResult.CurrentUsers.Count, validationResult.MaximumConcurrentUsers)); }
private void OnShowLicenseUsageExecute() { var networkValidationResult = new NetworkValidationResult(); networkValidationResult.MaximumConcurrentUsers = 2; networkValidationResult.CurrentUsers.AddRange(new[] { new NetworkLicenseUsage("12", "192.168.1.100", "Jon", "Licence signature", DateTime.Now), new NetworkLicenseUsage("13", "192.168.1.101", "Jane", "Licence signature", DateTime.Now), new NetworkLicenseUsage("14", "192.168.1.102", "Samuel", "Licence signature", DateTime.Now), new NetworkLicenseUsage("15", "192.168.1.103", "Paula", "Licence signature", DateTime.Now) }); _uiVisualizerService.ShowDialog <NetworkLicenseUsageViewModel>(networkValidationResult); }
public virtual NetworkValidationResult ValidateLicense() { var networkValidationResult = new NetworkValidationResult(); var license = _licenseService.CurrentLicense; if (license == null) { return(networkValidationResult); } networkValidationResult.MaximumConcurrentUsers = license.GetMaximumConcurrentLicenses(); Log.Info("Checking for other licenses, maximum number of concurrent users allowed is '{0}'", networkValidationResult.MaximumConcurrentUsers); try { CreateLicenseListeningSockets(); var timeout = SearchTimeout.TotalMilliseconds > 0 ? (int)SearchTimeout.TotalMilliseconds : 2000; var licenseUsages = new List <NetworkLicenseUsage>(); foreach (var ipAddress in GetIpAddresses()) { var usages = BroadcastMessage(ipAddress, license.Signature, timeout); licenseUsages.AddRange(usages); } networkValidationResult.CurrentUsers.AddRange(licenseUsages.GroupBy(x => x.ComputerId).Select(group => group.First())); Log.Debug("Found {0}", networkValidationResult); Validated.SafeInvoke(this, new NetworkValidatedEventArgs(networkValidationResult)); } catch (Exception ex) { Log.Error(ex, "Failed to check for maximum number of concurrent users"); } return(networkValidationResult); }
private void UpdateValidationResult(NetworkValidationResult networkValidationResult, bool allowToClose = true) { Argument.IsNotNull(() => networkValidationResult); var computerId = _networkLicenseService.ComputerId; MaximumNumberOfConcurrentUsages = networkValidationResult.MaximumConcurrentUsers; CurrentUsers = (from user in networkValidationResult.CurrentUsers where !string.Equals(user.ComputerId, computerId) select user).ToList(); if (allowToClose && networkValidationResult.IsValid) { Log.Info("No longer exceeding maximum concurrent users, closing network license validation"); #pragma warning disable 4014 _dispatcherService.BeginInvoke(() => this.SaveAndCloseViewModelAsync()); #pragma warning restore 4014 } }
public NetworkLicenseUsageViewModel(NetworkValidationResult networkValidationResult, ILicenseInfoService licenseInfoService, IProcessService processService) { Argument.IsNotNull(() => networkValidationResult); Argument.IsNotNull(() => licenseInfoService); Argument.IsNotNull(() => processService); _networkValidationResult = networkValidationResult; _licenseInfoService = licenseInfoService; _processService = processService; var assembly = AssemblyHelper.GetEntryAssembly(); Title = assembly.Title() + " licence usage"; PurchaseUrl = licenseInfoService.GetLicenseInfo().PurchaseUrl; CurrentUsers = networkValidationResult.CurrentUsers.ToList(); MaximumNumberOfConcurrentUsages = networkValidationResult.MaximumConcurrentUsers; CloseApplication = new Command(OnCloseApplicationExecute); BuyLicenses = new Command(OnBuyLicensesExecute); }
public virtual NetworkValidationResult ValidateLicense() { var networkValidationResult = new NetworkValidationResult(); var license = _licenseService.CurrentLicense; if (license == null) { return networkValidationResult; } networkValidationResult.MaximumConcurrentUsers = license.GetMaximumConcurrentLicenses(); Log.Info("Checking for other licenses, maximum number of concurrent users allowed is '{0}'", networkValidationResult.MaximumConcurrentUsers); try { CreateLicenseListeningSockets(); var timeout = SearchTimeout != null ? (int)SearchTimeout.TotalMilliseconds : 2000; var licenseUsages = new List<NetworkLicenseUsage>(); foreach (var ipAddress in GetIpAddresses()) { var usages = BroadcastMessage(ipAddress, license.Signature, timeout); licenseUsages.AddRange(usages); } networkValidationResult.CurrentUsers.AddRange(licenseUsages.GroupBy(x => x.ComputerId).Select(group => group.First())); Log.Debug("Found {0}", networkValidationResult); Validated.SafeInvoke(this, new NetworkValidatedEventArgs(networkValidationResult)); } catch (Exception ex) { Log.Error(ex, "Failed to check for maximum number of concurrent users"); } return networkValidationResult; }
public NetworkValidatedEventArgs(NetworkValidationResult validationResult) { ValidationResult = validationResult; }
private void OnShowLicenseUsageExecute() { var networkValidationResult = new NetworkValidationResult(); networkValidationResult.MaximumConcurrentUsers = 2; networkValidationResult.CurrentUsers.AddRange(new[] { new NetworkLicenseUsage("12", "192.168.1.100", "Jon", "Licence signature", DateTime.Now), new NetworkLicenseUsage("13", "192.168.1.101", "Jane", "Licence signature", DateTime.Now), new NetworkLicenseUsage("14", "192.168.1.102", "Samuel", "Licence signature", DateTime.Now), new NetworkLicenseUsage("15", "192.168.1.103", "Paula", "Licence signature", DateTime.Now) }); _uiVisualizerService.ShowDialog<NetworkLicenseUsageViewModel>(networkValidationResult); }