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);
        }
Пример #2
0
 /// <summary>
 /// Called when the object is validated.
 /// </summary>
 protected virtual void OnValidated()
 {
     Validated.SafeInvoke(this);
 }