Search in sources :

Example 11 with LocalService

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

the class StartForms method checkTimeout.

protected void checkTimeout(IForm form, String funcCode, long startTime, long timeout) {
    long totalTime = System.currentTimeMillis() - startTime;
    if (totalTime > timeout) {
        String[] tmp = form.getClass().getName().split("\\.");
        String pageCode = tmp[tmp.length - 1] + "." + funcCode;
        String dataIn = new Gson().toJson(form.getRequest().getParameterMap());
        if (dataIn.length() > 60000)
            dataIn = dataIn.substring(0, 60000);
        LocalService ser = new LocalService(form.getHandle(), "SvrFormTimeout.save");
        Record head = ser.getDataIn().getHead();
        head.setField("pageCode", pageCode);
        head.setField("dataIn", dataIn);
        head.setField("tickCount", totalTime);
        ser.exec();
    }
}
Also used : Gson(com.google.gson.Gson) Record(cn.cerc.jdb.core.Record) LocalService(cn.cerc.jbean.client.LocalService)

Example 12 with LocalService

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

the class JPushRecord method send.

public void send(IHandle handle) {
    LocalService svr = new LocalService(handle, "SvrUserLogin.getMachInfo");
    if (!svr.exec("CorpNo_", corpNo, "UserCode_", userCode)) {
        throw new RuntimeException(svr.getMessage());
    }
    // 设置极光推送平台
    JiguangPush push = new JiguangPush(handle);
    push.setMessage(alert);
    push.setMsgId("" + msgId);
    push.setTitle(title);
    // 将消息推送到极光平台
    DataSet dataOut = svr.getDataOut();
    while (dataOut.fetch()) {
        String machineCode = dataOut.getString("MachineCode_");
        int machineType = dataOut.getInt("MachineType_");
        switch(machineType) {
            case 6:
                push.send(ClientType.IOS, machineCode);
                break;
            case 7:
                // 过滤掉没有注册IMEI码的移动设备
                if (!"n_null".equals(machineCode) && !"n_000000000000000".equals(machineCode)) {
                    push.send(ClientType.Android, machineCode);
                }
                break;
            default:
                break;
        }
    }
}
Also used : DataSet(cn.cerc.jdb.core.DataSet) JiguangPush(cn.cerc.jdb.jiguang.JiguangPush) LocalService(cn.cerc.jbean.client.LocalService)

Example 13 with LocalService

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

the class MessageRecord method send.

public String send(IHandle handle) {
    if (subject == null || "".equals(subject)) {
        throw new RuntimeException("消息标题不允许为空");
    }
    if (userCode == null || "".equals(userCode)) {
        throw new RuntimeException("用户代码不允许为空");
    }
    String sendCorpNo = corpNo != null ? corpNo : handle.getCorpNo();
    if ("".equals(sendCorpNo)) {
        throw new RuntimeException("公司别不允许为空");
    }
    LocalService svr = new LocalService(handle, "SvrUserMessages.appendRecord");
    Record headIn = svr.getDataIn().getHead();
    headIn.setField("corpNo", sendCorpNo);
    headIn.setField("userCode", userCode);
    headIn.setField("level", level.ordinal());
    headIn.setField("subject", subject);
    headIn.setField("content", content.toString());
    headIn.setField("process", process);
    if (!svr.exec()) {
        throw new RuntimeException(svr.getMessage());
    }
    // 返回消息的编号
    return svr.getDataOut().getHead().getString("msgId");
}
Also used : Record(cn.cerc.jdb.core.Record) LocalService(cn.cerc.jbean.client.LocalService)

Example 14 with LocalService

use of cn.cerc.jbean.client.LocalService 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)

Example 15 with LocalService

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

the class ProcessService method execute.

@Override
public void execute() {
    LocalService svr = new LocalService(this, "SvrUserMessages.getWaitList");
    if (!svr.exec())
        throw new RuntimeException(svr.getMessage());
    DataSet ds = svr.getDataOut();
    while (ds.fetch()) {
        log.info("开始处理异步任务,UID=" + ds.getString("UID_"));
        processService(ds.getString("UID_"));
    }
}
Also used : DataSet(cn.cerc.jdb.core.DataSet) LocalService(cn.cerc.jbean.client.LocalService)

Aggregations

LocalService (cn.cerc.jbean.client.LocalService)19 Record (cn.cerc.jdb.core.Record)9 MemoryBuffer (cn.cerc.jbean.other.MemoryBuffer)4 DataSet (cn.cerc.jdb.core.DataSet)3 Gson (com.google.gson.Gson)2 AutoService (cn.cerc.jbean.client.AutoService)1 BookHandle (cn.cerc.jbean.core.BookHandle)1 Webfunc (cn.cerc.jbean.core.Webfunc)1 IForm (cn.cerc.jbean.form.IForm)1 UserNotFindException (cn.cerc.jbean.other.UserNotFindException)1 IMemcache (cn.cerc.jdb.cache.IMemcache)1 IHandle (cn.cerc.jdb.core.IHandle)1 JiguangPush (cn.cerc.jdb.jiguang.JiguangPush)1 SqlQuery (cn.cerc.jdb.mysql.SqlQuery)1 QueueQuery (cn.cerc.jdb.queue.QueueQuery)1 ClientDevice (cn.cerc.jmis.core.ClientDevice)1 AbstractForm (cn.cerc.jmis.form.AbstractForm)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 JSONObject (net.sf.json.JSONObject)1 Ignore (org.junit.Ignore)1