public static void RegisterLicense(string licenseKeyText) { string cutomerId = null; try { var parts = licenseKeyText.SplitOnFirst('-'); cutomerId = parts[0]; LicenseKey key; using (new AccessToken(LicenseFeature.Text)) { key = PclExport.Instance.VerifyLicenseKeyText(licenseKeyText); } var releaseDate = Env.GetReleaseDate(); if (releaseDate > key.Expiry) { throw new LicenseException("This license has expired on {0} and is not valid for use with this release." .Fmt(key.Expiry.ToString("d")) + ContactDetails).Trace(); } if (key.Type == LicenseType.Trial && DateTime.UtcNow > key.Expiry) { throw new LicenseException("This trial license has expired on {0}." .Fmt(key.Expiry.ToString("d")) + ContactDetails).Trace(); } __activatedLicense = key; } catch (Exception ex) { if (ex is LicenseException) { throw; } var msg = "This license is invalid." + ContactDetails; if (!string.IsNullOrEmpty(cutomerId)) { msg += " The id for this license is '{0}'".Fmt(cutomerId); } throw new LicenseException(msg).Trace(); } }
public static string GetHashKeyToSign(this LicenseKey key) { return("{0}:{1}:{2}:{3}".Fmt(key.Ref, key.Name, key.Expiry.ToString("yyyy-MM-dd"), key.Type)); }
public static void RemoveLicense() { __activatedLicense = null; }