Search in sources :

Example 1 with IAppLogin

use of cn.cerc.jbean.tools.IAppLogin in project summer-bean by cn-cerc.

the class Application method getAppLogin.

public static IAppLogin getAppLogin(IForm form) {
    init();
    if (!app.containsBean("AppLogin"))
        throw new RuntimeException(String.format("%s 中没有找到 bean: AppLogin", xmlFile));
    IAppLogin result = app.getBean("AppLogin", IAppLogin.class);
    result.init(form);
    return result;
}
Also used : IAppLogin(cn.cerc.jbean.tools.IAppLogin)

Example 2 with IAppLogin

use of cn.cerc.jbean.tools.IAppLogin in project summer-mis by cn-cerc.

the class StartForms method doFilter.

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    HttpServletRequest req = (HttpServletRequest) request;
    HttpServletResponse resp = (HttpServletResponse) response;
    String uri = req.getRequestURI();
    // 遇到静太文件直接输出
    if (isStatic(uri)) {
        chain.doFilter(req, resp);
        return;
    }
    log.info(uri);
    String childCode = getRequestCode(req);
    if (childCode == null) {
        req.setAttribute("message", "无效的请求:" + childCode);
        req.getRequestDispatcher(Application.getAppConfig().getJspErrorFile()).forward(req, resp);
        return;
    }
    String[] params = childCode.split("\\.");
    String formId = params[0];
    String funcCode = params.length == 1 ? "execute" : params[1];
    req.setAttribute("logon", false);
    // 验证菜单是否启停
    if (Application.containsBean("AppFormFilter")) {
        IFormFilter formFilter = Application.getBean("AppFormFilter", IFormFilter.class);
        if (formFilter != null) {
            if (formFilter.doFilter(resp, formId, funcCode)) {
                return;
            }
        }
    }
    IForm form = null;
    try {
        form = createForm(req, resp, formId);
        if (form == null) {
            req.setAttribute("message", "error servlet:" + req.getServletPath());
            AppConfig conf = createConfig();
            req.getRequestDispatcher(conf.getJspErrorFile()).forward(req, resp);
            return;
        }
        // 设备讯息
        ClientDevice info = new ClientDevice(form);
        info.setRequest(req);
        req.setAttribute("_showMenu_", !ClientDevice.device_ee.equals(info.getDevice()));
        form.setClient(info);
        // 建立数据库资源
        try (AppHandle handle = createHandle(req)) {
            try {
                handle.setProperty(Application.sessionId, req.getSession().getId());
                handle.setProperty(Application.deviceLanguage, info.getLanguage());
                req.setAttribute("myappHandle", handle);
                form.setHandle(handle);
                log.debug("进行安全检查,若未登录则显示登录对话框");
                IAppLogin page = createLogin(form);
                if (page.checkSecurity(info.getSid())) {
                    String corpNo = handle.getCorpNo();
                    if (null != corpNo && !"".equals(corpNo)) {
                        String tempStr = String.format("调用菜单: %s(%s), 用户:%s", form.getTitle(), formId, handle.getUserName());
                        log.info(tempStr);
                    }
                    // 进行维护检查,在每月的最后一天晚上11点到下个月的第一天早上5点,不允许使用系统
                    if (checkEnableTime())
                        callForm(form, funcCode);
                }
            } catch (Exception e) {
                Throwable err = e.getCause();
                if (err == null)
                    err = e;
                req.setAttribute("msg", err.getMessage());
                ErrorPage opera = new ErrorPage(form, err);
                opera.execute();
            }
        }
    } catch (Exception e) {
        log.error(childCode + ":" + e.getMessage());
        req.setAttribute("message", e.getMessage());
        AppConfig conf = Application.getAppConfig();
        req.getRequestDispatcher(conf.getJspErrorFile()).forward(req, resp);
        return;
    }
}
Also used : AppConfig(cn.cerc.jbean.core.AppConfig) ErrorPage(cn.cerc.jmis.page.ErrorPage) HttpServletResponse(javax.servlet.http.HttpServletResponse) IForm(cn.cerc.jbean.form.IForm) AppHandle(cn.cerc.jbean.core.AppHandle) PageException(cn.cerc.jbean.core.PageException) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) HttpServletRequest(javax.servlet.http.HttpServletRequest) IAppLogin(cn.cerc.jbean.tools.IAppLogin)

Aggregations

IAppLogin (cn.cerc.jbean.tools.IAppLogin)2 AppConfig (cn.cerc.jbean.core.AppConfig)1 AppHandle (cn.cerc.jbean.core.AppHandle)1 PageException (cn.cerc.jbean.core.PageException)1 IForm (cn.cerc.jbean.form.IForm)1 ErrorPage (cn.cerc.jmis.page.ErrorPage)1 IOException (java.io.IOException)1 ServletException (javax.servlet.ServletException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1