Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Hi,
does anyone know how I can hook into a file transfer job complete event. I have a mash up which can kick start a file transfer from the edge to a file repository thing. Is there a way that I can hook into a notification that the transfer was completed successfully?
I am using the FileTransferSubsystem Copy service to do the actual transfer. I can see that one of the parameters for the service is async which is currently set to false.
async
- Should the service wait for the copy to complete - BOOLEAN
I would prefer not to wait for the transfer complete in the service if possible as files might be quite large.
I notice that the copy service returns a result - INFOTABLE - Aspects {dataShape:FileTransferJob} . Is there some way I can use this. I thought maybe I could use the transferId parameter and a timer to check if the job was done by using FileTransferSubsystem IsTransferJobActive service? Likewise it would also be good to know if it failed.
Thanks,
K
Solved! Go to Solution.
On the file repository thing, there is an event called FileTransfer. You just need to subscribe to this, and then there are different statuses which will be returned into the subscription, e.g. "VALIDATED" if it completed successfully, "ERROR" if it did not complete, or "ACTIVE" if the file transfer is started and ongoing. There is a similar approach which checks other event data instead of status in KCS here. Hope this helps!
On the file repository thing, there is an event called FileTransfer. You just need to subscribe to this, and then there are different statuses which will be returned into the subscription, e.g. "VALIDATED" if it completed successfully, "ERROR" if it did not complete, or "ACTIVE" if the file transfer is started and ongoing. There is a similar approach which checks other event data instead of status in KCS here. Hope this helps!
Hi Tori,
thanks for that, extremely helpful. I can see how I can get the file repository to subscribe to the events now. I do have one further question, do you have any idea how can get my mashup to respond to a 'file transfer complete' event? The only way I can think of, is to poll the file repository on a timer but ideally I'd like to respond to the event directly rather than have to keep polling. Is there any way at all to get a mashup to subscribe to events?
K
I am a bit confused; what exactly do you want the mashup to do with the event information?
Sorry, didn't explain myself very well.
In my mash up I kick off a process on the edge device which results in a file being created then uploaded to the server. Due to the time this might take (c.30 seconds) I don't want to wait for the process to complete.
What I would like to achieve is to subscribe to the file transfer event so that I can have a status message appear in my mash up when the file transfer is complete.
hope that is a bit clearer?
K
Hey Kieron, I think what Carles is describing involves the GetProperties service in newer versions of ThingWorx. All you have to do is check the box called "Automatically update..." which appears in the right-hand data pane when the service is selected, and then bind the property to the display field, whatever is used. When the FileTransfer Event occurs, in the subscription, update this property, and you are good to go.
Hi Tori,
again thank you, very helpful. I think we might need to update our TW version as I hadn't seen/noticed this feature.
Appreciate your help.
K
Hi Kieron,
Push mashup updates are available starting at TW 7.2
Best Regards,
Carles.
Thank you. Yes we do have it, I just never noticed it before
Hi Kieron,
The only way to get a Mashup notified (push rather than poll) by a server side "event change" it's through property update changes . Then, for instance, you will have to add a property on the FileRepository, let's call it nUploads as INTEGER, and on the event that you subscribed before just add up +1 to the nUploads property, then from the mashup you can push "subscribe" to this nUploads property in order to refresh the Mashup.
Best Regards,
Carles.
Hi Carles,
thanks for the help. Not sure what you mean by 'push subscribe'. do you mean using a timer to poll the 'nUploads' parameter, or is there a way in a mash up to subscribe to this property's data change event?
K
Hi Kieron, yes there's a method to "subscribe to property's data change event" please follow the link referenced on my previous post
Thanks Carles, as usual you have been very helpful.
K