Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
Hi,
I am trying to write a program that will check WTUsers to see when they last logged into Windchill. I have code that worked against our LDAP, but ran outside of Windchill. We need to move this inside Windchill in order to keep WTUser and LDAP User in sync. I've written Listeners before that will listen for an event, but I haven't written any scheduled services yet. Is there any examples that can help me? I can get the functionality working based on my previous code, but I'm not sure how to make it "scheduled" in Windchill.
It's pretty simple create a custom schedule job. The below link will be helpful and also refer the customizer guide, it is very well explained there too.
Never thought to look under Visualization for this info. I'll take a look and see if it helps. Thanks.
You can create your own Scheduling queue which can appear in Queue Management. Below is the example to create scheduling queue.
public static void processPublishingQueueEntry(WTObject wtobj, String objno, String objrev, WTObject wtobj2, String objno2, String objrev2) {
SessionContext prev = SessionContext.newContext();
try {
SessionHelper.manager.setAdministrator();
ReferenceFactory referencefactory = new ReferenceFactory();
String sobj = referencefactory.getReferenceString(wtobj);
String sobj2 = referencefactory.getReferenceString(wtobj2);
QuerySpec spec = new QuerySpec(wt.queue.ScheduleQueue.class);
spec.appendWhere(new SearchCondition(wt.queue.ScheduleQueue.class, "name", SearchCondition.EQUAL, "yourqueuename"));
QueryResult result = PersistenceHelper.manager.find(spec);
ScheduleQueue queue;
if (result == null || result.size() < 1) {
//Create the Queue.
logger.debug("Creating a New Queue, as its not present.");
queue = QueueHelper.manager.createScheduleQueue("yourqueuename");
} else {
logger.debug("Using the existing queue.");
queue = (ScheduleQueue) result.nextElement();
}
WTUser adminUser = (WTUser) wt.session.SessionHelper.manager.getPrincipal();
Class[] argTypes = {String.class, String.class, String.class, String.class, String.class, String.class};
Object[] argValues = {sobj, objno, objrev, sobj2, objno2, objrev2};
Timestamp timestamp = new Timestamp(System.currentTimeMillis() + 5000L);
queue.addEntry(adminUser, "createViewable", "com.xxxx.services.xxxxService", argTypes, argValues, timestamp);
} catch (Exception e) {
e.printStackTrace();
} finally {
SessionContext.setContext(prev);
}
}
Hope this will help in creating job with in Windchill
It did. Thanks.
Hi,
I have same requirement. right now i have one class which extarct data like WTPart from Windchill once in a day and place in to staging area out side Windchill,i am using cron job on daily basis to extract the Windchill data.
Can you please guide me to how i can use Schedulers instead of Cron job ?
Regards,
Vivek