Hello all,
in the function TriggerEmailAlarmMessage() there is a log message at the end of that function, why is that messages showing up before the logic that is before that function call?
if (newAlarms = true) {
string machineName := new string;
string deviceId := new string;
boolean deviceFound := false;
integer i := 0;
// Searching x the machine name that is used x representing the object in user interfaces.
FindManagedObject request := new FindManagedObject;
request.reqId := Util.generateReqId();
request.deviceId := "1523844618";
monitor.subscribe(FindManagedObjectResponse.SUBSCRIBE_CHANNEL);
on FindManagedObjectResponse(reqId=request.reqId) as response
and not FindManagedObjectResponseAck(request.reqId)
{
// Extract information from the document
AnyExtractor ex := AnyExtractor.create(response.managedObject.params["emailConfiguration"]);
// Loop trough all the machines
while (true) {
sequence<any> deviceIds := ex.getSequenceOr([i].toString() + ".childDevicesIds", new sequence<any>);
if (deviceIds = (new sequence <any>)) {
break;
}
integer j := 0;
while (j < deviceIds.size()) {
if (ex.getString([i].toString() + ".childDevicesIds" + [j].toString()) = second32Bit.source) {
integer tempCounter := 0;
// Get list of email
sequence<any> emailList := ex.getSequence([i].toString() + ".email");
while tempCounter < emailList.size() {
string emailRead := ex.getString([i].toString() + ".email" + [tempCounter].toString());
emailReceivers.append(emailRead);
tempCounter := tempCounter + 1;
}
// Get list of emailCC
sequence<any> emailListCC := ex.getSequence([i].toString() + ".emailCC");
tempCounter := 0;
while tempCounter < emailListCC.size() {
string emailReadCC := ex.getString([i].toString() + ".emailCC" + [tempCounter].toString());
emailCC.append(emailReadCC);
tempCounter := tempCounter + 1;
}
// Get machine name
machineName := ex.getString([i].toString() + ".name");
// Set flag because we found the device in the list
deviceFound := true;
// Exit the j while loop;
break;
}
j := j + 1;
}
if deviceFound = true {
// Exit for the while 1 loop
break;
}
i := i + 1;
}
TriggerEmailAlarmMessage(second32Bit.source, machineName,INDEX_ERROR_FOUND);
}
on FindManagedObjectResponseAck(request.reqId)
as requestCompleted
{
// Request is completed and we can unsubscribe from this channel
monitor.unsubscribe(FindManagedObjectResponse.SUBSCRIBE_CHANNEL);
}
send request to FindManagedObject.SEND_CHANNEL;
TriggerEmailAlarmMessage(second32Bit.source, machineName,INDEX_ERROR_FOUND);
}