public string CheckLicense() { try { //check if license MP exists. _emg.ManagementPacks.GetManagementPack(new Guid("d3818ae4-e8e0-5f64-9411-d142cdd84dc9")); //var license = validator.ValidateLicense(getProductKey(), _productName, getLicenseKey()); //var fakelicense = new Mock<ILicenseValidator>(); //fakelicense.Setup(f => f.ValidateLicense(getProductKey(), _productName, getLicenseKey())).Returns(() => new License("TESTKEY", DateTime.Now, _productName)); //validator = fakelicense.Object; var version = _emoSettings.GetLeastDerivedNonAbstractClass().GetManagementPack().Version.ToString(); var productKey = GetProductKey(); var licenseKey = GetLicenseKey(); var license = _validator.ValidateLicense(productKey, _productName, licenseKey, version); return(license.LicenseKeyExpirationDate.ToString(CultureInfo.CurrentUICulture)); } catch (ObjectNotFoundException ex) { throw new LicenseNotFoundException( "Cireson Licensing Management Pack is not installed on the management group. " + ex.Message, ex); } catch (LicenseNotFoundException ex) { throw new LicenseNotFoundException( "An error occured while retrieving license for " + _productName + ". " + ex.Message, ex); } }
public bool ValidateLicense(string productKey, string applicationName, string licenseKey, string version) { _validator = new LicenseValidator(); try { return(_validator.ValidateLicense(productKey, applicationName, licenseKey, version) != null); } catch (Exception) { return(false); } }
public bool ValidateLicense(string productKey, string applicationName, string licenseKey, string version, out DateTime?expirationDate) { _validator = new LicenseValidator(); try { var license = _validator.ValidateLicense(productKey, applicationName, licenseKey, version); if (license == null) { expirationDate = null; return(false); } expirationDate = license.LicenseKeyExpirationDate; return(true); } catch (Exception) { expirationDate = null; return(false); } }