85 lines
3.3 KiB
OpenEdge ABL
85 lines
3.3 KiB
OpenEdge ABL
public class orgHealthCheckController {
|
|
|
|
public orgHealthCheckController() {
|
|
}
|
|
|
|
@AuraEnabled(cacheable=true)
|
|
public static List<OrgHealthCheckVO> getOrgHealthCheckList() {
|
|
List<OrgHealthCheckVO> healthCheckList = new List<OrgHealthCheckVO>();
|
|
|
|
//add values
|
|
Integer counter=1;
|
|
healthCheckList.add(new OrgHealthCheckVO(getUUID()+'','Daily Async Apex Executions',getCurrentValue('DailyAsyncApexExecutions'),getLimit('DailyAsyncApexExecutions')));
|
|
healthCheckList.add(new OrgHealthCheckVO(getUUID()+'','Data Storage (MB)',getCurrentValue('DataStorageMB'),getLimit('DataStorageMB')));
|
|
healthCheckList.add(new OrgHealthCheckVO(getUUID()+'','File Storage (MB)',getCurrentValue('FileStorageMB'),getLimit('FileStorageMB')));
|
|
healthCheckList.add(new OrgHealthCheckVO(getUUID()+'','Daily Api Requests',getCurrentValue('DailyApiRequests'),getLimit('DailyApiRequests')));
|
|
healthCheckList.add(new OrgHealthCheckVO(getUUID()+'','Daily Functions Api Call Limit',getCurrentValue('DailyFunctionsApiCallLimit'),getLimit('DailyFunctionsApiCallLimit')));
|
|
|
|
healthCheckList.sort();
|
|
return healthCheckList;
|
|
}
|
|
|
|
public static String getUUID() {
|
|
Blob b = Crypto.GenerateAESKey(128);
|
|
String h = EncodingUtil.ConvertTohex(b);
|
|
String guid = h.SubString(0,8).toUpperCase();//+ '-' + h.SubString(8,12) + '-' + h.SubString(12,16) + '-' + h.SubString(16,20) + '-' + h.substring(20);
|
|
return guid;
|
|
}
|
|
|
|
public static Integer getLimit(String name) {
|
|
Map<String,System.OrgLimit> limitsMap = OrgLimits.getMap();
|
|
System.OrgLimit asyncLimit = limitsMap.get(name);
|
|
if(asyncLimit!=null) {
|
|
return asyncLimit.getLimit();
|
|
}
|
|
else {
|
|
return 0;
|
|
}
|
|
}
|
|
public static Integer getCurrentValue(String name) {
|
|
Map<String,System.OrgLimit> limitsMap = OrgLimits.getMap();
|
|
System.OrgLimit asyncLimit = limitsMap.get(name);
|
|
if(asyncLimit!=null) {
|
|
return asyncLimit.getValue();
|
|
}else return 0;
|
|
}
|
|
|
|
public class OrgHealthCheckVO implements Comparable {
|
|
@AuraEnabled public Double scale=0;
|
|
@AuraEnabled public String color;
|
|
@AuraEnabled public Double value;
|
|
@AuraEnabled public String name;
|
|
@AuraEnabled public String id;
|
|
@AuraEnabled public Double maxlimit;
|
|
|
|
final String OK = '#34cceb';
|
|
final String CAUTION = '#ebd334';
|
|
final String BAD = '#eb5934';
|
|
|
|
public Integer compareTo(Object compareTo) {
|
|
OrgHealthCheckVO ohcvo = (OrgHealthCheckVO) compareTo;
|
|
if (this.scale == ohcvo.scale) return 0;
|
|
if (this.scale > ohcvo.scale) return 1;
|
|
return -1;
|
|
}
|
|
|
|
OrgHealthCheckVO(String id,String name,Double value,Double maxlimit) {
|
|
this.id=id;
|
|
this.name=name;
|
|
this.value=value;
|
|
this.maxlimit=maxlimit;
|
|
if(maxlimit>0) {
|
|
Decimal calc = (value/maxlimit)*100;
|
|
this.scale = calc.setScale(2);
|
|
}
|
|
|
|
if(this.scale <45) {
|
|
this.color = OK;
|
|
}else if(this.scale >45 && this.scale<65) {
|
|
this.color = CAUTION;
|
|
}else {
|
|
this.color=BAD;
|
|
}
|
|
}
|
|
}
|
|
} |