Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Hello ALL,
I hate to be lazy, but my search to date, hasn't produced much.
I am not much on windchill listeners, but my current need is for a listener that checks a server/shared folder, for a file with a specific name.
Maybe every 5 minutes or such. Then as soon as it finds that file, it starts/initiates/initializes/? a workflow.
I hope the listener area isn't as limited as the business rules are...4 ootb or lots of coding....lol
Thanks
Larry Jett
datajett@aol.com
Larry,
As I understand Windchill listeners they can listen for and get triggered on events on Windchill objects like WTDoc checkin etc. What you want is probably to set up a service that listen for file system events as you will find examples of if you google for 'java file listener' then use that to kick off your workflow.
There are multiple ways you can accomplish this. It depends upon what kind of system you are watching the folders on and you can create a trigger to initiate the workflow. Here are the options that I can think of:
Here is the workflow expression code, I have been working on. With timer.
java.io.File folder = new File("D:\\SHAREFILE_SYNC\\DOCS\\");
java.io.File[] listOfFiles = folder.listFiles();
for (java.io.File file : listOfFiles) {
if (file.isFile()) {
String fileName = "";
fileName = file.getName();
if (filename.endsWith(".pdf") {
System.out.println("WorkFlow Start");
wt.workflow.engine.WfEngineHelper.service.startProcess(proc, data, 0);
break;
}
}
}
I have been pulled off this task, but I will see how this goes, when I get back to it.
But I might need to adjust this to look in subfolders also. Because the pdf's will be in sub folders of the above top folder.
I have not thought this code out, but its a good start, till I check workflow syntax check
for (java.io.File file : listOfFiles) {
if (file.isFile()) {
String fileName = "";
fileName = file.getName();
if (filename.endsWith(".pdf") {
System.out.println("WorkFlow Start");
wt.workflow.engine.WfEngineHelper.service.startProcess(proc, data, 0);
break;
}
}
else if(file.isDirectory()){
java.io.File[] listOfFilesSub = file.listFiles();
for (java.io.File fileSub : listOfFilesSub) {
if (fileSub.isFile()) {
String fileNameSub = "";
fileNameSub = file.getName();
if (filename.endsWith(".pdf") {
System.out.println("WorkFlow Start");
wt.workflow.engine.WfEngineHelper.service.startProcess(proc, data, 0);
break;
}
}
}
}
}
Larry Jett