Search in sources :

Example 16 with LocalService

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

the class ProcessQueue method execute.

@Override
public void execute() throws Exception {
    QueueQuery query = new QueueQuery(this);
    query.setQueueMode(QueueMode.recevie);
    query.add("select * from %s ", QueueSession.defaultQueue);
    query.open();
    if (!query.getActive())
        return;
    query.remove();
    // 建立服务执行环境
    String corpNo = query.getHead().getString("_corpNo_");
    if ("".equals(corpNo)) {
        log.error("_corpNo_ is null");
        return;
    }
    String userCode = query.getHead().getString("_userCode_");
    if ("".equals(userCode)) {
        log.error("_userCode_ is null");
        return;
    }
    String service = query.getHead().getString("_service_");
    if ("".equals(service)) {
        log.error("_service_ is null");
        return;
    }
    // 调用队列内容中指定的服务
    BookHandle bh = new BookHandle(this, corpNo);
    bh.setUserCode(userCode);
    LocalService svr = new LocalService(bh);
    svr.setService(service);
    svr.getDataIn().appendDataSet(query, true);
    String msgId = query.getHead().getString("_queueId_");
    JSONObject content = JSONObject.fromObject(query.getHead().getString("_content_"));
    LocalService app = new LocalService(bh, "SvrUserMessages.updateAsyncService");
    if (svr.exec()) {
        content.element("processTime", TDateTime.Now());
        content.element("dataOut", svr.getDataOut().getJSON());
        if (!app.exec("msgId", msgId, "process", MessageProcess.ok.ordinal(), "content", content.toString()))
            log.error(app.getMessage());
    } else {
        content.element("processTime", TDateTime.Now());
        content.element("dataOut", svr.getDataOut().getJSON());
        if (!app.exec("msgId", msgId, "process", MessageProcess.error.ordinal(), "content", content.toString()))
            log.error(app.getMessage());
    }
}
Also used : JSONObject(net.sf.json.JSONObject) LocalService(cn.cerc.jbean.client.LocalService) BookHandle(cn.cerc.jbean.core.BookHandle) QueueQuery(cn.cerc.jdb.queue.QueueQuery)

Example 17 with LocalService

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

the class ResourceBuffer method getValue.

private String getValue(IHandle handle, String text) {
    LocalService svr = new LocalService(handle, "SvrLanguage.download");
    Record headIn = svr.getDataIn().getHead();
    headIn.setField("key_", text);
    headIn.setField("lang_", lang);
    if (!svr.exec()) {
        log.error(svr.getMessage());
        return text;
    }
    return svr.getDataOut().getHead().getString("value");
}
Also used : Record(cn.cerc.jdb.core.Record) LocalService(cn.cerc.jbean.client.LocalService)

Example 18 with LocalService

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

the class ResourceBuffer method get.

public String get(IHandle handle, String text) {
    if (items.size() == 0) {
        LocalService svr = new LocalService(handle, "SvrLanguage.downloadAll");
        Record headIn = svr.getDataIn().getHead();
        headIn.setField("lang_", lang);
        if (!svr.exec()) {
            log.error(svr.getMessage());
            return text;
        }
        for (Record item : svr.getDataOut()) {
            items.put(item.getString("key_"), item.getString("value_"));
        }
        if (items.size() == 0) {
            log.error("没有找到相应的语言字典数据!!!");
        }
    }
    if (items.containsKey(text)) {
        return items.get(text);
    }
    String result = getValue(handle, text);
    items.put(text, result);
    return result;
}
Also used : Record(cn.cerc.jdb.core.Record) LocalService(cn.cerc.jbean.client.LocalService)

Example 19 with LocalService

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

the class ExportService method export.

public void export() throws WriteException, IOException, AccreditException {
    if (service == null || "".equals(service))
        throw new RuntimeException("错误的调用:service is null");
    if (exportKey == null || "".equals(exportKey))
        throw new RuntimeException("错误的调用:exportKey is null");
    IHandle handle = (IHandle) this.getHandle();
    LocalService app = new LocalService(handle);
    app.setService(service);
    try (MemoryBuffer buff = new MemoryBuffer(BufferType.getExportKey, handle.getUserCode(), exportKey)) {
        app.getDataIn().close();
        app.getDataIn().setJSON(buff.getString("data"));
    }
    if (!app.exec()) {
        this.export(app.getMessage());
        return;
    }
    DataSet dataOut = app.getDataOut();
    // 对分类进行处理
    dataOut.first();
    while (dataOut.fetch()) {
        if (dataOut.getBoolean("IsType_"))
            dataOut.delete();
    }
    this.getTemplate().setDataSet(dataOut);
    super.export();
}
Also used : MemoryBuffer(cn.cerc.jbean.other.MemoryBuffer) DataSet(cn.cerc.jdb.core.DataSet) LocalService(cn.cerc.jbean.client.LocalService) IHandle(cn.cerc.jdb.core.IHandle)

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