Пример #1
0
        static void ConfigureNServiceBusToRunInTrialMode()
        {
            if (UserSidChecker.IsNotSystemSid())
            {
                var trialExpirationDate = TrialLicenseReader.GetTrialExpirationFromRegistry();
                //Check trial is still valid
                if (ExpiryChecker.IsExpired(trialExpirationDate))
                {
                    Logger.WarnFormat("Trial for NServiceBus v{0} has expired. Falling back to run in Basic1 license mode.", GitFlowVersion.MajorMinor);

                    license = LicenseDeserializer.GetBasicLicense();
                }
                else
                {
                    var message = string.Format("Trial for NServiceBus v{0} is still active, trial expires on {1}. Configuring NServiceBus to run in trial mode.", GitFlowVersion.MajorMinor, trialExpirationDate.ToLocalTime().ToShortDateString());
                    Logger.Info(message);

                    //Run in unlimited mode during trial period
                    license = LicenseDeserializer.GetTrialLicense(trialExpirationDate);
                }
                return;
            }

            Logger.Warn("Could not access registry for the current user sid. Falling back to run in Basic license mode.");

            license = LicenseDeserializer.GetBasicLicense();
        }
Пример #2
0
        internal static void PromptUserForLicenseIfTrialHasExpired()
        {
            if (!(Debugger.IsAttached && SystemInformation.UserInteractive))
            {
                //We only prompt user if user is in debugging mode and we are running in interactive mode
                return;
            }

            bool createdNew;

            using (new Mutex(true, string.Format("NServiceBus-{0}", GitFlowVersion.MajorMinor), out createdNew))
            {
                if (!createdNew)
                {
                    //Dialog already displaying for this software version by another process, so we just use the already assigned license.
                    return;
                }

                //TODO: should we display dialog if UpgradeProtection is not valid?
                if (ExpiryChecker.IsExpired(License.ExpirationDate))
                {
                    license = LicenseExpiredFormDisplayer.PromptUserForLicense();
                }
            }
        }