Exemplo n.º 1
0
        public static DetectedLicense FindLicense()
        {
            var sources = LicenseSource.GetStandardLicenseSources().ToArray();
            var result  = ActiveLicense.Find("ServiceControl", sources);

            return(new DetectedLicense("HKEY_LOCAL_MACHINE", LicenseDetails.FromLicense(result.License)));
        }
Exemplo n.º 2
0
        internal static LicenseDetails FromLicense(License license)
        {
            var details = new LicenseDetails
            {
                UpgradeProtectionExpiration = license.UpgradeProtectionExpiration,
                //If expiration date is greater that 50 years treat is as no expiration date
                ExpirationDate = license.ExpirationDate.HasValue
                    ? (license.ExpirationDate.Value > DateTime.Now.AddYears(50) ? null : license.ExpirationDate)
                    : license.ExpirationDate,
                RegisteredTo                      = license.RegisteredTo,
                IsCommercialLicense               = license.IsCommercialLicense,
                IsExtendedTrial                   = license.IsExtendedTrial,
                IsTrialLicense                    = license.IsTrialLicense,
                LicenseType                       = license.LicenseType,
                Edition                           = license.Edition,
                ValidForServiceControl            = license.ValidForApplication("ServiceControl"),
                DaysUntilSubscriptionExpires      = license.GetDaysUntilLicenseExpires(),
                DaysUntilUpgradeProtectionExpires = license.GetDaysUntilUpgradeProtectionExpires()
            };

            switch (license.GetLicenseStatus())
            {
            case LicenseStatus.Valid:
                break;

            case LicenseStatus.ValidWithExpiredUpgradeProtection:
                details.WarnUserUpgradeProtectionHasExpired = true;
                break;

            case LicenseStatus.ValidWithExpiringTrial:
                details.WarnUserTrialIsExpiring = true;
                break;

            case LicenseStatus.ValidWithExpiringSubscription:
                details.WarnUserSubscriptionIsExpiring = true;
                break;

            case LicenseStatus.ValidWithExpiringUpgradeProtection:
                details.WarnUserUpgradeProtectionIsExpiring = true;
                break;

            case LicenseStatus.InvalidDueToExpiredTrial:
                details.WarnUserTrialHasExpired = true;
                break;

            case LicenseStatus.InvalidDueToExpiredSubscription:
                details.WarnUserSubscriptionHasExpired = true;
                break;

            case LicenseStatus.InvalidDueToExpiredUpgradeProtection:
                details.WarnUserUpgradeProtectionHasExpired = true;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }


            return(details);
        }
Exemplo n.º 3
0
        public static DetectedLicense FindLicense()
        {
            var sources = LicenseSource.GetStandardLicenseSources().ToArray();
            var result  = ActiveLicense.Find("ServiceControl", sources);

            var detectedLicense = new DetectedLicense("HKEY_LOCAL_MACHINE", LicenseDetails.FromLicense(result.License));

            detectedLicense.IsEvaluationLicense = string.Equals(result.Location, "Trial License", StringComparison.OrdinalIgnoreCase);

            return(detectedLicense);
        }
        public static DetectedLicense FindLicense()
        {
            var sources = new LicenseSource[]
            {
                new LicenseSourceFilePath(GetMachineLevelLicenseLocation())
            };

            var result = ActiveLicense.Find("ServiceControl", sources);

            var detectedLicense = new DetectedLicense(result.Location, LicenseDetails.FromLicense(result.License));

            detectedLicense.IsEvaluationLicense = string.Equals(result.Location, "Trial License", StringComparison.OrdinalIgnoreCase);

            return(detectedLicense);
        }
Exemplo n.º 5
0
        public static DetectedLicense FindLicense()
        {
            var result = ActiveLicense.Find("ServiceControl", new LicenseSourceHKLMRegKey());

            return(new DetectedLicense("HKEY_LOCAL_MACHINE", LicenseDetails.FromLicense(result.License)));
        }