String result;
String orgName;
String orgCountry;
Organization orgDetails =[ select Id, Name, Country from Organization limit 1];
Id orgId = orgDetails.Id;
orgName = orgDetails.Name;
orgCountry = orgDetails.Country;
PageReference pr=new PageReference('/'+orgId);
//called screenscraping: get the data from the page
String rawData=pr.getContent().toString();
String licRow = '>Salesforce</th><td class=" dataCell ">Active</td><td class=" dataCell numericalColumn">';
Integer licLen = licRow.length();
Integer pos=rawData.indexOf(licRow);
if (-1!=pos)
{
Integer licStart = pos + licLen;
result=rawData.substring(licStart, licStart+3);
}
Decimal lic = decimal.valueOf(result);
integer u = [select count() from user where profile.UserLicense.Name = 'salesforce' and isactive = true];
Decimal userCount = decimal.valueOf(u);
Integer totalUnused = (lic.intValue() - userCount.intValue());
System.debug('************ Licenses???? ***************** ' + String.valueOf(totalUnused));
No comments:
Post a Comment