Search in sources :

Example 1 with AutoService

use of cn.cerc.jbean.client.AutoService in project summer-mis by cn-cerc.

the class ProcessService method processService.

/**
 * 处理一个服务
 */
private void processService(String msgId) {
    LocalService svr1 = new LocalService(this, "SvrUserMessages.readAsyncService");
    if (// 此任务可能被其它主机抢占
    !svr1.exec("msgId", msgId))
        return;
    Record ds = svr1.getDataOut().getHead();
    String corpNo = ds.getString("corpNo");
    String userCode = ds.getString("userCode");
    String content = ds.getString("content");
    String subject = ds.getString("subject");
    // 读取并标识为工作中,以防被其它用户抢占
    AsyncService svr2 = new AsyncService(null);
    svr2.read(content);
    svr2.setProcess(MessageProcess.working.ordinal());
    updateMessage(svr2, msgId, subject);
    try {
        try (AutoService svr3 = new AutoService(corpNo, userCode, svr2.getService())) {
            svr3.getDataIn().appendDataSet(svr2.getDataIn(), true);
            if (svr3.exec()) {
                svr2.getDataOut().appendDataSet(svr3.getDataOut(), true);
                svr2.setProcess(MessageProcess.ok.ordinal());
            } else {
                svr2.getDataOut().appendDataSet(svr3.getDataOut(), true);
                svr2.setProcess(MessageProcess.error.ordinal());
            }
            svr2.getDataOut().getHead().setField("_message_", svr3.getMessage());
            updateMessage(svr2, msgId, subject);
        }
    } catch (Throwable e) {
        e.printStackTrace();
        svr2.setProcess(MessageProcess.error.ordinal());
        svr2.getDataOut().getHead().setField("_message_", e.getMessage());
        updateMessage(svr2, msgId, subject);
    }
}
Also used : AutoService(cn.cerc.jbean.client.AutoService) Record(cn.cerc.jdb.core.Record) LocalService(cn.cerc.jbean.client.LocalService)

Aggregations

AutoService (cn.cerc.jbean.client.AutoService)1 LocalService (cn.cerc.jbean.client.LocalService)1 Record (cn.cerc.jdb.core.Record)1