示例#1
0
        public static bool Check()
        {
            if (DateTime.Now - LastLicenseCheck < LicenseCheckInterval)
            {
                return(true);
            }

            LicenseCheck.License license = LicenseCheck.License.FromRegistry(LicenseRegistryKey, LicensedAppName);
            if (license.Status == LicenseCheck.License.LicenseStatus.Valid)
            {
                LastLicenseCheck = DateTime.Now;
                return(true);
            }

            using (LicenseCheck.RequestLicenseForm form = new LicenseCheck.RequestLicenseForm())
            {
                form.ActivationCode = LicenseCheck.License.FormatActivationCode(LicenseCheck.License.GetActivationCode(LicensedAppName));
                if (Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(null, form, false) != System.Windows.Forms.DialogResult.OK)
                {
                    return(false);
                }

                license = LicenseCheck.License.FromFile(form.LicenseFile, LicensedAppName);
                if (license.Status != LicenseCheck.License.LicenseStatus.Valid)
                {
                    return(false);
                }

                license.SaveToRegistry(LicenseRegistryKey);

                LastLicenseCheck = DateTime.Now;
                return(true);
            }
        }
示例#2
0
        public static bool Check()
        {
            if (DateTime.Now - LastLicenseCheck < LicenseCheckInterval)
            {
                return(true);
            }

            LicenseCheck.License license = LicenseCheck.License.FromRegistry(LicenseRegistryKey, LicensedAppName);
            if (license.Status == LicenseCheck.License.LicenseStatus.Valid)
            {
                license.SaveToRegistry(LicenseRegistryKey);

                LastLicenseCheck = DateTime.Now;
                return(true);
            }
            else
            {
                return(Request());
            }
        }