public static NetworkLicenseUsage GetLatestUser(this NetworkValidationResult validationResult) { Argument.IsNotNull(() => validationResult); var latestUsage = (from usage in validationResult.CurrentUsers orderby usage.StartDateTime descending select usage).FirstOrDefault(); return(latestUsage); }
public static bool IsCurrentUserLatestUser(this NetworkValidationResult validationResult) { Argument.IsNotNull(() => validationResult); var serviceLocator = ServiceLocator.Default; var networkLicenseService = serviceLocator.ResolveType <INetworkLicenseService>(); var latestUser = validationResult.GetLatestUser(); if (latestUser != null) { return(string.Equals(networkLicenseService.ComputerId, latestUser.ComputerId)); } return(false); }
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?.Invoke(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; }