示例#1
0
        private void DiscoveryHostOnClientDiscovered(object sender, DiscoveryHost.ClientDiscoveredEventArgs clientDiscoveredEventArgs)
        {
            if (senderId == clientDiscoveredEventArgs.SenderId) // we got our own notification, ignore it
            {
                return;
            }

            if (UserId != clientDiscoveredEventArgs.UserId) // another license, we don't care
            {
                return;
            }

            // same user id, different senders
            switch (MultipleLicenseUsageBehavior)
            {
            case MultipleLicenseUsage.AllowForSameUser:
                if (Environment.UserName == clientDiscoveredEventArgs.UserName)
                {
                    return;
                }
                break;
            }

            RaiseLicenseInvalidated();
            RaiseMultipleLicenseDiscovered(clientDiscoveredEventArgs);
        }
示例#2
0
        private void DiscoveryHostOnClientDiscovered(object sender, DiscoveryHost.ClientDiscoveredEventArgs clientDiscoveredEventArgs)
        {
            if (senderId == clientDiscoveredEventArgs.SenderId)             // we got our own notification, ignore it
            {
                return;
            }
            if (UserId != clientDiscoveredEventArgs.UserId)             // another license, we don't care
            {
                return;
            }

            // same user id, different senders
            switch (MultipleLicenseUsageBehavior)
            {
            case MultipleLicenseUsage.AllowForSameUser:
                if (Environment.UserName == clientDiscoveredEventArgs.UserName)
                {
                    return;
                }
                break;
            }
            var client = discoveryClient;

            if (client != null)
            {
                client.PublishMyPresence();
            }
            RaiseLicenseInvalidated();
            var onMultipleLicensesWereDiscovered = MultipleLicensesWereDiscovered;

            if (onMultipleLicensesWereDiscovered != null)
            {
                onMultipleLicensesWereDiscovered(this, clientDiscoveredEventArgs);
            }
        }
示例#3
0
        private void RaiseMultipleLicenseDiscovered(DiscoveryHost.ClientDiscoveredEventArgs args)
        {
            var onMultipleLicensesWereDiscovered = MultipleLicensesWereDiscovered;

            if (onMultipleLicensesWereDiscovered != null)
            {
                onMultipleLicensesWereDiscovered(this, args);
            }
        }
示例#4
0
        private void DiscoveryHostOnClientDiscovered(object sender, DiscoveryHost.ClientDiscoveredEventArgs clientDiscoveredEventArgs)
        {
            if (senderId == clientDiscoveredEventArgs.SenderId) // we got our own notification, ignore it
            {
                return;
            }
            if (UserId != clientDiscoveredEventArgs.UserId) // another license, we don't care
            {
                return;
            }

            // same user id, different senders
            switch (MultipleLicenseUsageBehavior)
            {
            case MultipleLicenseUsage.AllowSameLicense:
                return;

            case MultipleLicenseUsage.AllowForSameUser:
                if (Environment.UserName == clientDiscoveredEventArgs.UserName)
                {
                    return;
                }
                break;

            case MultipleLicenseUsage.Deny:
                if (Environment.UserName == clientDiscoveredEventArgs.UserName &&
                    Environment.MachineName == clientDiscoveredEventArgs.MachineName)
                {
                    return;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException("invalid MultipleLicenseUsageBehavior: " + MultipleLicenseUsageBehavior);
            }
            var client = discoveryClient;

            if (client != null)
            {
                client.PublishMyPresence();
            }
            RaiseLicenseInvalidated();
            var onMultipleLicensesWereDiscovered = MultipleLicensesWereDiscovered;

            if (onMultipleLicensesWereDiscovered != null)
            {
                onMultipleLicensesWereDiscovered(this, clientDiscoveredEventArgs);
            }
            else
            {
                throw new InvalidOperationException("Multiple licenses were discovered, but no one is handling the MultipleLicensesWereDiscovered event");
            }
        }
示例#5
0
        private void OnMultipleLicensesWereDiscovered(object sender, DiscoveryHost.ClientDiscoveredEventArgs clientDiscoveredEventArgs)
        {
            logger.Error("A duplicate license was found at {0} for user {1}. User Id: {2}. Both licenses were disabled!",
                         clientDiscoveredEventArgs.MachineName,
                         clientDiscoveredEventArgs.UserName,
                         clientDiscoveredEventArgs.UserId);

            CurrentLicense = new LicensingStatus
            {
                Status  = "AGPL - Open Source",
                Error   = true,
                Message =
                    string.Format("A duplicate license was found at {0} for user {1}. User Id: {2}.", clientDiscoveredEventArgs.MachineName,
                                  clientDiscoveredEventArgs.UserName,
                                  clientDiscoveredEventArgs.UserId)
            };
        }