How to send content of a file in a tSendMail - java

i try since some days to send one mail with different informations from child job and father job.
see my jobs below:
and my tRunJob_3
at the end of this job, i can put informations from tAggregateRow in the email, but it send several email (one mail by condition "if" approved DeinitJob --- if --- tRunJob_3)
my file generated by tFileOutputDelimited_1 in the father job contains all the information i need to put in the final mail.
1: how to display these informations in one email (no attachement) ?
2: i have this error in my console:
For input string: "7.91'7.91"
multiple points
what it means ?
EDIT:
with the modification below, it send me 1 email with the informations collected
in my tjavaflex:
code initial
// start part of your Java code
boolean loop ;
System.out.println("## START\n#");
code principal
// here is the main part of the component,
// a piece of code executed in the row
// loop
// code sample:
System.out.println("## LOAD...\n#");
if ((String)globalMap.get("message") != null) {
globalMap.put("message", (String)globalMap.get("message") + row5.mag + " qt: " + row5.qt + " p1: " + row5.p1 + "\n" ) ;
}
code final:
// end of the component, outside/closing the loop
loop = true ;
System.out.println("## END\n#");
with a if loop between tjava and tsendmail
but still have my error:
For input string: "7.91'7.91"
multiple points

Related

tJava fetch string from print output in talend

currently I found an alternative to fetch the string output in Java using Talend Studio:
tJava code:
String output=((String)globalMap.get("tSystem_1_OUTPUT"));
System.out.println("Printing the error code 1 : "+StringUtils.substringBetween(output,"source count:", "destination count:"));
tJava output:
Printing the error code 1 : ', '1000')
('
Expected Result:
Printing the error code 1 : 1000
However, tJava takes the result exactly between string " source count:' " and " destination count: ", so that included the bracket and all. The expected result is only to get the value 1000.
How do I apply this java code to fetch the correct output?
Haven't test this within Talend itself but try this ...
String output=((String)globalMap.get("tSystem_1_OUTPUT"));
var sourceCount = output.split("\\)")[0].split(",")[1].replace("'", "").trim();
System.out.println("Printing the error code 1 : " + sourceCount);

How to fix "GetStatus Write RFID_API_UNKNOWN_ERROR data(x)- Field can Only Take Word values" Android RFID 8500 Zebra

I am trying to develop and application to read and write to RF tags. Reading is flawless, but I'm having issues with writing. Specifically the error "GetStatus Write RFID_API_UNKNOWN_ERROR data(x)- Field can Only Take Word values"
I have tried reverse-engineering the Zebra RFID API Mobile by obtaining the .apk and decoding it, but the code is obfuscated and I am not able to decypher why that application's Write works and mine doesn't.
I see the error in the https://www.ptsmobile.com/rfd8500/rfd8500-rfid-developer-guide.pdf at page 185, but I have no idea what's causing it.
I've tried forcefully changing the writeData to Hex, before I realized that the API does that on its own, I've tried changing the Length of the writeData as well, but it just gets a null value. I'm so lost.
public boolean WriteTag(String sourceEPC, long Password, MEMORY_BANK memory_bank, String targetData, int offset) {
Log.d(TAG, "WriteTag " + targetData);
try {
TagData tagData = null;
String tagId = sourceEPC;
TagAccess tagAccess = new TagAccess();
tagAccess.getClass();
TagAccess.WriteAccessParams writeAccessParams = tagAccess.new WriteAccessParams();
String writeData = targetData; //write data in string
writeAccessParams.setAccessPassword(Password);
writeAccessParams.setMemoryBank(MEMORY_BANK.MEMORY_BANK_USER);
writeAccessParams.setOffset(offset); // start writing from word offset 0
writeAccessParams.setWriteData(writeData);
// set retries in case of partial write happens
writeAccessParams.setWriteRetries(3);
// data length in words
System.out.println("length: " + writeData.length()/4);
System.out.println("length: " + writeData.length());
writeAccessParams.setWriteDataLength(writeData.length()/4);
// 5th parameter bPrefilter flag is true which means API will apply pre filter internally
// 6th parameter should be true in case of changing EPC ID it self i.e. source and target both is EPC
boolean useTIDfilter = memory_bank == MEMORY_BANK.MEMORY_BANK_EPC;
reader.Actions.TagAccess.writeWait(tagId, writeAccessParams, null, tagData, true, useTIDfilter);
} catch (InvalidUsageException e) {
System.out.println("INVALID USAGE EXCEPTION: " + e.getInfo());
e.printStackTrace();
return false;
} catch (OperationFailureException e) {
//System.out.println("OPERATION FAILURE EXCEPTION");
System.out.println("OPERATION FAILURE EXCEPTION: " + e.getResults().toString());
e.printStackTrace();
return false;
}
return true;
}
With
Password being 00
sourceEPC being the Tag ID obtained after reading
Memory Bank being MEMORY_BANK.MEMORY_BANK_USER
target data being "8426017056458"
offset being 0
It just keeps giving me "GetStatus Write RFID_API_UNKNOWN_ERROR data(x)- Field can Only Take Word values" and I have no idea why this is the case, nor I know what a "Word value" is, and i've searched for it. This is all under the "OperationFailureException", as well. Any help would be appreciated, as there's almost no resources online for this kind of thing.
Even this question is a bit older, I had the same problem so as far as I know this should be the answer.
Your target data "8426017056458" length is 13 and at writeAccessParams.setWriteDataLength(writeData.length()/4)
you are devide it with four. Now if you are trying to write the target data it is longer than the determined WriteDataLength. And this throws the Error.
One 'word' is 4 Hex => 16 Bits long. So your Data have to be filled up first and convert it to Hex.

Read TeamSpeak 3 Messages with java

im wondering if there is any other way to read out the TeamSpeak Channel Chat with java.
I know that you could use a lua plugin which opens tha java program with the messages as parameter.
The code for the Lua Plugin's event.lua file: (could be outdated)
local function onTextMessageEvent(serverConnectionHandlerID, targetMode, toID, fromID, fromName, fromUniqueIdentifier, message, ffIgnored)
print("Testmodule: onTextMessageEvent: " .. serverConnectionHandlerID .. " " .. targetMode .. " " .. toID .. " " .. fromID .. " " .. fromName .. " " .. fromUniqueIdentifier .. " " .. message .. " " .. ffIgnored)
if targetMode == 2 then
os.execute("Program.exe " .. '"' .. message .. '"')
if message == "!command#1" or message == "!command#2" or message == "!command#3" then
folder = os.getenv("APPDATA")
file = io.open(folder .. "/" .. "tmp.txt", "r")
tempfile = file:read("*all")
file:close()
os.remove(folder .. "/" .. "tmp.txt")
ts3.requestSendChannelTextMsg(serverConnectionHandlerID, tempfile, fromID)
end
end
return 0
end
Basicly the Program.exe creates the tmp.txt file and writes the specified (inside the Program.exe) answer to the file which is sent to the chat by the lua plugin.
Now i want to know if there is any way to get the messages directly with java (so that the lua plugin isn't needed anymore)
I'm thankful for any help
I found out that you can simply scan the channel & server chatlogs for new entrys.
The Logs can be found here:
%APPDATA%\Roaming\TS3Client\chats\<UniqueServerID>
Unfortunately i have no idea how the UniqueServerID is generated and where the private chatlogs can be found.

Java- how do I save data that is being read into my program by a public static void method into a String?

I am writing a Java program that will listen for PDUs that are being sent across a network, and present information about those PDUs (such as entity state & position within the simulation) to the user.
I currently have one class which is being used to listen for the PDUs being sent over the network (EspduReceiver.java), and another class that I am using to create the GUI that the user will use to interact with the program (Gui.java).
The EspduReceiver.java class currently works as intended- when I run it, it listens for any PDUs that are being sent over the network, and displays information about each individual PDU it receives in the console. The information that it displays includes the entity ID, and its position within the simulation.
However, this method literally just listens for a PDU message, and prints the relevant information about it to the console when it 'hears' one- so the information about the Entity State PDU that is being printed in the console, is not actually stored anywhere in the program at present.
Now, what I would like to do with my Gui.java class, is to create a user interface that will display what I am seeing being printed in the console to the user. I have written the foundation of a class that will do this, but I am having trouble retrieving the data that is being read into my program from the EspduReceiver.java class...
The method that I am using to retrieve the PDU information, and display it in the console currently looks like this:
public static void receivePdu(){
try{
/*Specify the socket to receive the data */
socket = new MulticastSocket(EspduSender.PORT);
address = InetAddress.getByName(EspduSender.DEFAULT_MULTICAST_GROUP);
socket.joinGroup(address);
/*Loop infinitely, receiving datagrams */
while(true){
byte buffer[] = new byte[MAX_PDU_SIZE];
packet = new DatagramPacket(buffer, buffer.length);
socket.receive(packet);
Pdu pdu = pduFactory.createPdu(packet.getData()); /* Commented on 15/04/2014 # 09:15 */
if(pdu != null){
System.out.print("Got PDU of type: " + pdu.getClass().getName());
if(pdu instanceof EntityStatePdu){
EntityID eid = ((EntityStatePdu)pdu).getEntityID();
Vector3Double position = ((EntityStatePdu)pdu).getEntityLocation();
System.out.print(" EID:[" + eid.getSite() + ", " + eid.getApplication() + ", " + eid.getEntity() + "] ");
System.out.print(" Location in DIS coordinates: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]");
} else if(!(pdu instanceof EntityStatePdu)){
System.out.println("There are no PDUs currently being received.");
}
System.out.println();
}
} /*end while */
} /*end try */
catch(Exception e){
System.out.println(e);
e.printStackTrace();
System.out.println("This is where the error is being generated");
/*09/04/2014 # 17:100
* If this exception gets called, presumably it either means that pdu is not an instance of EntityStatePdu, or
* that pdu does not actually hold a packet. */
}
}
Then, in my Gui.java class, I have a public void initGui(){...} method, which I am trying to use to call the receivePdu() method from EspduReceiver.java. I have done this by declaring a new instance of my EspduReceiver class, and creating a new String variable to hold the data generated by the receivePdu() method:
EspduReceiver receiver = new EspduReceiver();
String data = receiver.receivePdu();
However, I get an error on the String data = receiver.receivePdu(); line that says: "Type mismatch: cannot convert from void to String", and suggests that I change return type of receivePdu() to String...
I understand the reason that I get the error- because my receivePdu() method has a return type of "void", and here I am trying to state that it is String- I had originally tried to write the receivePdu method with a return type of String, but kept getting errors with that, and couldn't fix it other than by changing it to void.
Is there a way that I can access the data retrieved by the receivePdu() method, so that I can display it to the user? How would I do this? Could I possibly save the data that it retrieves to another variable, and use that to display it to the user?
You can't usefully call the receivePdu() method from your GUI, because receivePdu() never returns - it loops forever - and doesn't return anything.
Creating a new instance of EspduReceiver won't help, since the receivePdu method is static i.e. shared by all instances.
You could get receivePdu() to store data in a variable at the top level of EspduReceiver, visible to the GUI, then notify the GUI that it should collect the data and display it. Or you could push the data to the GUI from within receivePdu, though that tangles all your code up somewhat.
Either way, you will need to notify the GUI from the "Event Dispatching Thread" - see the tutorial here.

How can I get the name associated with an extension/peer without having an opened channel with the Asterisk's Java API?

I’m using FreePBX with Asterisk’s Java API.
For the moment, I’m able to display all my SIP peers with their respective states:
public void onManagerEvent(ManagerEvent event)
{
// Look if the event is a IP phone (Peer entry)
if(event instanceof PeerEntryEvent)
{
PeerEntryEvent ev = (PeerEntryEvent)event;
// Get the user extension
peer = ev.getObjectName();
// Add to the array
peersName.add(peer);
}
}
I’m able to display the phone number and name of both callers when a channel is open:
private String GetExtensionPeer(String extension)
{
for (AsteriskChannel e : channels)
if (e.number.equals(extension) && e.bridge != null )
for (AsteriskChannel channel : channels)
if (z.channel.equals(e.bridge))
return " with " + channel.number + " - " + channel.name;
return "";
}
But now, I would like to display the name of my extensions without a channel connection.
In FreePBX's panel, it's look like :
In freepbx you can get list of extensions from asterisk db. To see info, do
asterisk -rx "database show"
To get info use manager action "command" with DBGET.
Other option - got that info from freepbx's mysql db.

Categories