Search in sources :

Example 1 with IHandle

use of cn.cerc.jdb.core.IHandle in project summer-mis by cn-cerc.

the class ResourceJstl method getString.

private String getString(HttpServletRequest request, JspFragment jf) throws JspException, IOException {
    IHandle handle = (IHandle) request.getAttribute("myappHandle");
    if (handle == null) {
        log.error("handle is null");
        return "handle is null";
    }
    String text = "";
    StringWriter sw = new StringWriter();
    jf.invoke(sw);
    text = sw.toString();
    Object temp = handle.getProperty(Application.deviceLanguage);
    String lang = (temp == null || "".equals(temp)) ? Application.getLangage() : (String) temp;
    if ("cn".equals(lang)) {
        return text;
    }
    // 取其它语言的字符
    ResourceBuffer rb = items.get(lang);
    if (rb == null) {
        rb = new ResourceBuffer(lang);
        items.put(lang, rb);
    }
    // 取得到值,则直接返回
    String result = rb.get(handle, text);
    if (result != null) {
        if (!"".equals(result)) {
            return result;
        }
    }
    // 取不到值,但当前是英文时,则原样返回
    if ("en".equals(lang)) {
        if (ServerConfig.getInstance().isDebug()) {
            return lang + ":" + text;
        } else {
            return text;
        }
    }
    // 如果是其它语言,则取英文的默认值
    ResourceBuffer en = items.get("en");
    result = en.get(handle, text);
    if (result != null && !"".equals(result)) {
        return result;
    }
    if (ServerConfig.getInstance().isDebug()) {
        return lang + ":" + text;
    } else {
        return text;
    }
}
Also used : StringWriter(java.io.StringWriter) IHandle(cn.cerc.jdb.core.IHandle)

Example 2 with IHandle

use of cn.cerc.jdb.core.IHandle in project summer-mis by cn-cerc.

the class ExportHistoryWriter method finish.

@Override
public void finish(Object handle, Template template) {
    IHandle appHandle = (IHandle) handle;
    String log = String.format("系统已经为您导出: %s.xls", template.getFileName());
    new HistoryRecord(log).setLevel(HistoryLevel.General).save(appHandle);
}
Also used : HistoryRecord(cn.cerc.jbean.other.HistoryRecord) IHandle(cn.cerc.jdb.core.IHandle)

Example 3 with IHandle

use of cn.cerc.jdb.core.IHandle in project summer-bean by cn-cerc.

the class BookHandleTest method test.

@Test
@Ignore
public void test() {
    IHandle app = new BookHandle(handle, "144001");
    assertEquals(app.getCorpNo(), "144001");
}
Also used : IHandle(cn.cerc.jdb.core.IHandle) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with IHandle

use of cn.cerc.jdb.core.IHandle in project summer-mis by cn-cerc.

the class AppLoginPage method checkSecurity.

@Override
public boolean checkSecurity(String token) throws IOException, ServletException {
    IForm form = this.getForm();
    String password = null;
    String userCode = null;
    try {
        // TODO 需要统一 login_user login_pwd 与 userCode password 的名称
        if (form.getRequest().getParameter("login_usr") != null) {
            userCode = getRequest().getParameter("login_usr");
            password = getRequest().getParameter("login_pwd");
            return checkLogin(userCode, password);
        }
        log.debug(String.format("根据 token(%s) 创建 Session", token));
        IHandle sess = (IHandle) form.getHandle().getProperty(null);
        if (sess.init(token))
            return true;
        if (form.logon())
            return true;
    } catch (Exception e) {
        this.add("loginMsg", e.getMessage());
    }
    this.execute();
    return false;
}
Also used : IForm(cn.cerc.jbean.form.IForm) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) IHandle(cn.cerc.jdb.core.IHandle)

Example 5 with IHandle

use of cn.cerc.jdb.core.IHandle 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

IHandle (cn.cerc.jdb.core.IHandle)5 LocalService (cn.cerc.jbean.client.LocalService)1 IForm (cn.cerc.jbean.form.IForm)1 HistoryRecord (cn.cerc.jbean.other.HistoryRecord)1 MemoryBuffer (cn.cerc.jbean.other.MemoryBuffer)1 DataSet (cn.cerc.jdb.core.DataSet)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 ServletException (javax.servlet.ServletException)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1