Certain combinations of time limitations are not permitted when creating a license e.g. it does not make sense to set an Expiration Date and an Expiration Period at the same time. The former is set explicitly irrespective of when the license is actually activated, whereas the latter is used to calculate the Expiration Date based on an offset from the actual date of activation.
The Software Potential Portal guards against users setting incorrect combinations but when creating licenses using the Web Services API, the Software Potential service will throw an exception if invalid combinations are submitted in a license management CreateLicense or UpdateLicense request.
ExpirationDate and ExpirationPeriod Settings
The following table indicates how to set the different combinations of the License.LicenseInfo.Limitations.ExpirationDate
and License.LicenseInfo.Limitations.ExpirationPeriod
properties when creating different types of time-limited licenses as well as perpetual/unlimited licenses.
All date times should be UTC. ExpirationPeriod is expressed as TimeSpan e.g. TimeSpam.FromDays(30), TimeSpan.MaxValue
ExpirationDate | ExpirationPeriod | Result |
---|---|---|
Max Value / A Date | NULL (+) | Error (*) |
Null (+) | Max Value /Number Of Days | Error (*) |
A Date | Max Value /Number Of Days | Error (*) |
A Date | -1 | OK (Expiration Date Set) |
Max Value | Number Of Days (e.g. 30) | OK (Expiration Days Set) |
Max Value | Max Value | Unlimited Expiration |
(+) Null: if don’t populate the field with a value.
(*) Error: “LicenseInfo.Limitations.ExpirationDate and LicenseInfo.Limitations.ExpirationPeriod cannot both be set” will be returned as an error in Exception
Set an Expiration Date on a License
To programmatically set an expiration date on a license, set the following properties on the LicenseInfo.Limitations
:
LicenseInfo.Limitations.ExpirationDate = expirationDateTime.ToUniversalTime();
LicenseInfo.Limitations.ExpirationPeriod = TimeSpan.FromDays(-1);
To expire a license with immediate effect set the ExpirationDate to
DateTime.UtcNow.Date;
Set ExpirationPeriod on a time-limited License
To issue a time-limited license with an ExpirationPeriod, such that the license will expire a defined number of days (e.g. 30 days) after the license is activated, set the following properties on the license:
LicenseInfo.Limitations.ExpirationDate = DateTime.MaxValue;
LicenseInfo.Limitations.ExpirationPeriod = TimeSpan.FromDays(30);
If you retrieve this license after it is activated using GetLicenseById
or GetLicenseByActivationKey
, the ExpirationDate and ExpirationPeriod are both set. To reissue such a license you will need to reset the ExpirationPeriod to -1 i.e. LicenseInfo.Limitations.ExpirationPeriod = TimeSpan.FromDays(-1);
Comments
0 comments
Article is closed for comments.