How to retrieve activation information from the License Server
string ipAddress;
// lv is an instance of the LicenseValidator class
// the code below assumes that you have already called lv.ValidateLicenseAtStartup
GetLicenseInformation (Environment.MachineName, out ipAddress);private void GetLicenseInformation (string computerID, out string ipAddress)
{
ipAddress = string.Empty;
lv.QlmLicenseObject.GetLicenseInfo(string.Empty, lv.ActivationKey, false, out string dataSet, out string response);
ILicenseInfo licenseInfo = new LicenseInfo();
string message = string.Empty;
if (lv.QlmLicenseObject.ParseResults(response, ref licenseInfo, ref message))
{
DataSet ds = new DataSet("NewDataSet");
XmlReader reader = new XmlTextReader(dataSet, XmlNodeType.Document, null);
if (!String.IsNullOrEmpty(dataSet))
{
ds.ReadXml(reader);
if ((ds.Tables.Count > 0) && (ds.Tables[0].Rows.Count > 0))
{
DataRowCollection drc = ds.Tables[0].Rows;
if ((drc != null) && (drc.Count > 0))
{
DataRow dr = drc[0];
int numLicenses = (int)dr["NumLicenses"];
if (numLicenses <= 1)
{
ipAddress = dr["IP_Address"].ToString();
}
else
{
GetLicenseInfoFromActivationLog(computerID, out ipAddress);
}
}
}
}
}
else
{
throw new Exception(message);
}
}
private void GetLicenseInfoFromActivationLog(string computerID, out string ipAddress)
{
string dataSet = string.Empty;
ipAddress = string.Empty;
lv.QlmLicenseObject.GetActivationLog(string.Empty, lv.ActivationKey, ref dataSet, out string response);
if (!String.IsNullOrEmpty (dataSet))
{
DataSet ds = new DataSet("NewDataSet");
XmlReader reader = new XmlTextReader(dataSet, XmlNodeType.Document, null);
if (!String.IsNullOrEmpty(dataSet))
{
ds.ReadXml(reader);
if ((ds.Tables.Count > 0) && (ds.Tables[0].Rows.Count > 0))
{
DataRowCollection drc = ds.Tables[0].Rows;
if (drc != null)
{
foreach (DataRow dr in drc)
{
string dbComputerID = (string) dr["ComputerID"];
if (String.Compare (computerID, dbComputerID) == 0)
{
ipAddress = dr["IP_Address"].ToString();
break;
}
}
}
}
}
else
{
throw new Exception("Failed to get the activation log");
}
}
}PreviousHow to fire an event when MaxDaysOffline is reachedNextQLM strict authentication for HTTP Methods
Last updated