LPT Alert Operation Procedure

Available in:

LPT 2.36.6.0 version 

Objective: Scheduling server-side code execution using the alert mechanism in j-guar. 

Procedure: To run alerts in j-guar application, an operation definition is needed since alert mechanism only works with workflow operations. 
So we can define alert operation using LPT operation definitions editor (batchOperations.lod). When we click “Add Alert Operation” there are fields to be filled which are:  

Code: Code of the Alert operation which must be unique among operations.

Name, Description: User-friendly and resource bind name and description of the operation.

Performer: Workflow performer which is executed when the alarm is on.
This class is implemented from IWPOperationPerformer and must implement perform a function.


Server Side: 
If the operation will work server side without the interference of the user.

This selection must be done If operation is successful it must return:

TaskManagerConstants.EXEC_STATUS_SUCCESS_COMPLETE, to return

TaskManagerConstants.EXEC_STATUS_CANCEL ,to cancel the operation and return

TaskManagerConstants.EXEC_STATUS_SUCCESS_NOTCOMPLETE ,for unsuccessful operations.


IOperationContext inside the perform parameters contain ClientContext or ServerClientContext, 
which can be used inside performer class.  
Any method call from server or client can be done inside
the perform function.

import com.lbs.data.factory.FactoryParams;
import com.lbs.data.factory.IObjectFactory;
import com.lbs.remoteclient.IClientContext;
import com.lbs.services.exception.TaskManagerException;
import com.lbs.tm.client.IOperationContext;
import com.lbs.tm.client.ITaskOperationInstance;
import com.lbs.tm.tools.TaskManagerConstants;
import com.lbs.unity.mm.bo.MMBOItem;
import com.lbs.wf.workproduct.IWPOperationPerformer;
import com.lbs.wf.workproduct.IWorkProductOperation;
 
public class TestAlert implements IWPOperationPerformer {
public boolean preProcessData(IClientContext context, Object source,
            Object data, Object typeInfo, int mode) {
        return true;
    }
 
    public int perform(IOperationContext arg0, ITaskOperationInstance arg1)
            throws TaskManagerException {
         IWorkProductOperation op = null;
        //gets operation definition
        op = arg1.getOperationDef();
        System.out.println("Alert Operation Perform");
        //gets client context, and gets objectFactory
        IClientContext context = arg0.getClientContext();
        IObjectFactory factory = context.getObjectFactory();
        switch (op.getCategory()) {
            case IWorkProductOperation.CATEGORY_CUSTOM: {
            //do some work here
            selectResult(factory, "2", "serverdeneme");
            return TaskManagerConstants.EXEC_STATUS_SUCCESS_COMPLETE;
            }
        }
        return TaskManagerConstants.EXEC_STATUS_CANCEL;
    }
     
       
 
    /**
    * work function example
    */
    public Object selectResult(IObjectFactory factory , String param1, String param2) {
    Object[] params = new Object[2];
    try {
        //create item
        MMBOItem item = new MMBOItem();
        //fill parameters
        FactoryParams fparams = new FactoryParams();
        fparams.setActiveFilter("LOGICALREF > " + param1);
        System.out.println("Param1: " + param1);
        //read item with given parameters
        boolean ok = factory.first(item, fparams);
        if (ok == true) {
            param1 = item.getCode();
            System.out.println("Param11: " + param1);
        }
        params[0] = param1;
        params[1] = param2;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return params;
    }
}

How to Set the Alarm

Open jguar Client. Under Workflow Management/Task Definitions menu item Alert list can be seen. Add new Alert. Give Kod, schedule the time.

  

 















Under “Task Definitions” tab, give a name for the task and under the “Operations” grid insert new operation.

Open lookup of “Name” column and select the alarm operation defined in LPT (i.e Test Alert) and save the operation.

 


Telif HakkıKullanım KoşullarıGizlilik
Copyright © 2018 Logo Yazılım