getScoreAll function
Preparation Aggregate Score (Total Score) from User, Device Nodes To check current User, Device Node and Pairing Node (shared my another device score)
Implementation
Future getScoreAll() async{
///Prevent duplication
CoreValues.aggregate.clear();
CoreValues.aggregateThreatsScore = '';
///For shared threat score from another my device score
var sharedthreatsScoreList = [];
///For current device my threat scores
var currentThreatsScoreList = [];
try {
///Get current all information of device, user risk score
currentThreatsScoreList = await getCurrentScore();
logger.d('indiC getScore threatsScoreAggregate getCurrentScore $currentThreatsScoreList');
///Sum threat risk score from current device, user score
for(var i = 0; i < CoreValues.geigerThreatUUID.length; i++){
var tempDevice = currentThreatsScoreList[0][i].split(',');
var tempUser = currentThreatsScoreList[1][i].split(',');
var score = (double.parse(tempDevice[1])+double.parse(tempUser[1]))/2;
CoreValues.aggregateThreatsScore += '${tempDevice[0]},$score;';
}
try {
///Get shared risk score of another my device
///regarding sharing information to check on GEIGER wiki
var devicesPairingNode = await Storage.controller.get(':Enterprise:Users:${Storage.userUUID}:devicesPairing');
var getChildren = await devicesPairingNode.getChildren();
var devicesIterator = getChildren.entries.iterator;
///Check shared risk score of another my devices (0...*)
///Based on GEIGER wiki
while (devicesIterator.moveNext()) {
// var userNameNode = await devicesIterator.current.value.getValue('userName');
// var useruuidNode = await devicesIterator.current.value.getValue('userUUID');
// var devicenameNode = await devicesIterator.current.value.getValue('deviceName');
var sharedGEIGERScoreNode = await devicesIterator.current.value.getValue('sharedGeigesharedThreatsScorerScore');
var sharedThreatsScoreNode = await devicesIterator.current.value.getValue('');
var sharedNumberOfMetricNode = await devicesIterator.current.value.getValue('sharedNumberOfMetric');
// var sharedScoreDateNode = await devicesIterator.current.value.getValue('sharedScoreDate');
// var username = userNameNode!.getValue('en');
// var useruuid = useruuidNode!.getValue('en');
// var devicename = devicenameNode!.getValue('en');
var sharedGEIGERScore = sharedGEIGERScoreNode!.getValue('en');
var sharedThreatsScore = sharedThreatsScoreNode!.getValue('en');
var sharedNumberOfMetric = sharedNumberOfMetricNode!.getValue('en');
// var sharedScoreDate = sharedScoreDateNode!.getValue('en');
var tempSharedThreatsScore = sharedThreatsScore!.split(';');
sharedthreatsScoreList.add(tempSharedThreatsScore);
///Makes Map {Risk Score: Number of Metric}
///this store at global value 'CoreValues.aggregate'
var tempMap = {};
tempMap[sharedGEIGERScore] = sharedNumberOfMetric;
CoreValues.aggregate.add(tempMap);
}
///Sum shared risk threat score from shared devices
for(var threatsScoreAggregate in sharedthreatsScoreList ){
for(var i = 0; i < CoreValues.geigerThreatUUID.length; i++){
var tempTSA = threatsScoreAggregate[i].split(',');
var score = double.parse(tempTSA[1]);
CoreValues.aggregateThreatsScore += '${tempTSA[0]},$score;';
}
}
} on StorageException {
logger.i("Doesn't exists your Pairing devices, Please pair your devices");
}
}catch (e){
logger.i('indiA getScore ${e.toString()}');
}
}