/**
  * 识别缺省的JDBC驱动类型(g4Dao)
  *
  * @throws SQLException
  */
 private void initDbType() throws SQLException {
   Dao g4Dao = (Dao) SpringBeanLoader.getSpringBean("g4Dao");
   Connection connection = g4Dao.getConnection();
   String dbString = connection.getMetaData().getDatabaseProductName().toLowerCase();
   try {
     connection.close();
   } catch (Exception e) {
     log.error(G4Constants.Exception_Head + "未正常关闭数据库连接");
     e.printStackTrace();
   }
   if (dbString.indexOf("ora") > -1) {
     System.setProperty("g4Dao.db", "oracle");
   } else if (dbString.indexOf("mysql") > -1) {
     System.setProperty("g4Dao.db", "mysql");
   } else if (dbString.indexOf("microsoft") > -1) {
     System.setProperty("g4Dao.db", "sqlserver");
   } else {
     if (log.isErrorEnabled()) {
       log.error(G4Constants.Exception_Head + "G4Studio平台目前还不支持你使用的数据库产品.如需获得支持,请和我们联系!");
     }
     System.exit(0);
   }
 }
/**
 * 首页Action
 *
 * @author XiongChun
 * @since 2010-01-13
 * @see BizAction
 */
public class IndexAction extends BizAction {

  private OrganizationService organizationService =
      (OrganizationService) SpringBeanLoader.getSpringBean("organizationService");

  /**
   * 首页初始化
   *
   * @param
   * @return
   */
  public ActionForward indexInit(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    request.setAttribute("sysTitle", getParamValue("SYS_TITLE", request));
    request.setAttribute("westTitle", getParamValue("WEST_NAVIGATE_TITLE", request));
    String viewString = "indexView";
    String appLayout = getParamValue("APP_LAYOUT", request);
    if (appLayout.equals(G4Constants.APP_LAYOUT_DESKTOP)) {
      viewString = "desktopView";
    }
    String userLayout = getSessionContainer(request).getUserInfo().getLayout();
    if (G4Utils.isNotEmpty(userLayout)) {
      if (userLayout.equals(G4Constants.APP_LAYOUT_DESKTOP)) {
        viewString = "desktopView";
      } else {
        viewString = "indexView";
      }
    }

    List list = g4Reader.queryForList("Bus.querySiteName");
    Dto sites = new BaseDto();
    for (int i = 0; i < list.size(); i++) {
      Dto t = (Dto) list.get(i);
      sites.put(t.getAsString("id"), t.getAsString("name"));
    }
    getServlet().getServletContext().setAttribute("siteNameList", sites);

    Dto timesection = new BaseDto();
    //		for(int i=4;i<40;i++){
    //			if(i%2==0){
    //				timesection.put((i-3), i+":30-"+(i+1)+":00");
    //			}
    //			else{
    //
    //				timesection.put((i-3), i+":00-"+(i)+":30");
    //			}
    //
    //
    //		}
    //
    timesection.put("3T", "4:30-5:00");
    timesection.put("4T", "5:00-5:30");
    timesection.put("5T", "5:30-6:00");
    timesection.put("6T", "6:00-6:30");
    timesection.put("7T", "6:30-7:00");
    timesection.put("8T", "7:00-7:30");
    timesection.put("9T", "7:30-8:00");
    timesection.put("10T", "8:00-8:30");
    timesection.put("11T", "8:30-9:00");
    timesection.put("12T", "9:00-9:30");
    timesection.put("13T", "9:30-10:00");
    timesection.put("14T", "10:00-10:30");
    timesection.put("15T", "10:30-11:00");
    timesection.put("16T", "11:00-11:30");
    timesection.put("17T", "11:30-12:00");
    timesection.put("18T", "12:00-12:30");
    timesection.put("19T", "12:30-13:00");
    timesection.put("20T", "13:00-13:30");
    timesection.put("21T", "13:30-14:00");
    timesection.put("22T", "14:00-14:30");
    timesection.put("23T", "14:30-15:00");
    timesection.put("24T", "15:00-15:30");
    timesection.put("25T", "16:30-17:00");
    timesection.put("26T", "17:00-17:30");
    timesection.put("27T", "17:30-18:00");
    timesection.put("28T", "18:00-18:30");
    timesection.put("29T", "18:30-19:00");
    timesection.put("30T", "19:00-19:30");
    timesection.put("31T", "19:30-20:00");
    timesection.put("32T", "20:00-20:30");
    timesection.put("33T", "20:30-21:00");
    timesection.put("34T", "21:00-21:30");
    timesection.put("35T", "21:30-22:00");
    timesection.put("36T", "22:00-22:30");
    timesection.put("37T", "22:30-23:00");
    timesection.put("38T", "23:00-23:30");
    timesection.put("39T", "23:30-00:00");
    timesection.put("40T", "00:00-00:30");
    timesection.put("41T", "00:30-01:00");
    timesection.put("42T", "01:00-01:30");
    getServlet().getServletContext().setAttribute("timesection", timesection);
    return mapping.findForward(viewString);
  }

  /**
   * 欢迎页面初始化
   *
   * @param
   * @return
   */
  public ActionForward preferencesInit(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    return mapping.findForward("welcomeView");
  }

  /**
   * 保存用户自定义皮肤
   *
   * @param
   * @return
   */
  public ActionForward saveUserTheme(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    Dto dto = new BaseDto();
    String theme = request.getParameter("theme");
    dto.put("userid", super.getSessionContainer(request).getUserInfo().getUserid());
    dto.put("theme", theme);
    Dto outDto = organizationService.saveUserTheme(dto);
    String jsonString = JsonHelper.encodeObject2Json(outDto);
    write(jsonString, response);
    return mapping.findForward(null);
  }

  /**
   * 保存用户自定义布局
   *
   * @param
   * @return
   */
  public ActionForward saveUserLayout(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    Dto dto = new BaseDto();
    String layout = request.getParameter("layout");
    dto.put("userid", super.getSessionContainer(request).getUserInfo().getUserid());
    dto.put("layout", layout);
    Dto outDto = organizationService.saveUserLayout(dto);
    UserInfoVo userInfoVo = getSessionContainer(request).getUserInfo();
    userInfoVo.setLayout(layout);
    getSessionContainer(request).setUserInfo(userInfoVo);
    String jsonString = JsonHelper.encodeObject2Json(outDto);
    write(jsonString, response);
    return mapping.findForward(null);
  }

  /**
   * 保存用户自定义桌面背景
   *
   * @param
   * @return
   */
  public ActionForward saveUserBackground(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    Dto dto = new BaseDto();
    String background = request.getParameter("background");
    dto.put("userid", super.getSessionContainer(request).getUserInfo().getUserid());
    dto.put("background", background);
    Dto outDto = organizationService.saveUserBackground(dto);
    String jsonString = JsonHelper.encodeObject2Json(outDto);
    write(jsonString, response);
    return mapping.findForward(null);
  }

  /**
   * 加载当前登录用户信息
   *
   * @param
   * @return
   */
  public ActionForward loadUserInfo(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    UserInfoVo userInfoVo = getSessionContainer(request).getUserInfo();
    Dto inDto = new BaseDto();
    G4Utils.copyPropFromBean2Dto(userInfoVo, inDto);
    Dto outDto = (BaseDto) g4Reader.queryForObject("User.getUserInfoByKey", inDto);
    outDto.remove("password");
    String jsonString = JsonHelper.encodeDto2FormLoadJson(outDto, null);
    write(jsonString, response);
    return mapping.findForward(null);
  }

  /**
   * 修改当前登录用户信息
   *
   * @param
   * @return
   */
  public ActionForward updateUserInfo(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    CommonActionForm cForm = (CommonActionForm) form;
    UserInfoVo userInfoVo = getSessionContainer(request).getUserInfo();
    UserService service = (UserService) getService("userService");
    Dto indDto = cForm.getParamAsDto(request);
    Dto outDto = new BaseDto(G4Constants.TRUE);
    outDto.put("flag", G4Constants.SUCCESS);
    String password = G4Utils.encryptBasedDes(indDto.getAsString("password2"));
    if (password.equals(userInfoVo.getPassword())) {
      service.updateUserItem4IndexPage(indDto);
      outDto.put("flag", G4Constants.SUCCESS);
      userInfoVo.setPassword(G4Utils.encryptBasedDes(indDto.getAsString("password1")));
      getSessionContainer(request).setUserInfo(userInfoVo);
    } else {
      outDto.setSuccess(G4Constants.FALSE);
      outDto.put("flag", G4Constants.FAILURE);
    }
    write(outDto.toJson(), response);
    return mapping.findForward(null);
  }

  /**
   * 解锁系统
   *
   * @param
   * @return
   */
  public ActionForward unlockSystem(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    CommonActionForm cForm = (CommonActionForm) form;
    UserInfoVo userInfoVo = getSessionContainer(request).getUserInfo();
    Dto indDto = cForm.getParamAsDto(request);
    String password = G4Utils.encryptBasedDes(indDto.getAsString("password"));
    Dto outDto = new BaseDto(G4Constants.TRUE);
    if (password.equals(userInfoVo.getPassword())) {
      outDto.put("flag", G4Constants.SUCCESS);
    } else {
      outDto.put("flag", G4Constants.FAILURE);
    }
    write(outDto.toJson(), response);
    return mapping.findForward(null);
  }
}
 /**
  * 演示事务控制
  *
  * @author XiongChun
  * @since 2011-2-30
  * @see BizAction
  */
 public static void main(String[] args) {
   DemoService demoService = (DemoService) SpringBeanLoader.getSpringBean("demoService");
   Dto outDto = demoService.doTransactionTest();
   System.out.println("返回值:\n" + outDto);
 }
Beispiel #4
0
/**
 * HTML标签
 *
 * @author XiongChun
 * @since 2010-01-30
 */
public class HtmlTag extends TagSupport {

  private TagSupportService armTagSupportService =
      (TagSupportService) SpringBeanLoader.getSpringBean("armTagSupportService");

  private static Log log = LogFactory.getLog(HtmlTag.class);
  private String extDisabled;
  private String title;
  private String jqueryEnabled;
  private String showLoading;
  private String uxEnabled = "true";
  private String fcfEnabled = "false";
  private String doctypeEnable = "false"; // 带有时分秒选择的控件的页面需要设置为:true
  private String exportParams = "false";
  private String exportUserinfo = "false";
  private String isSubPage = "true";
  private String urlSecurity2 = "true";
  private String exportExceptionWindow = "false";

  /** 标签开始 */
  public int doStartTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    UserInfoVo userInfo = WebUtils.getSessionContainer(request).getUserInfo();
    String contextPath = request.getContextPath();
    request.setAttribute("webContext", contextPath);
    Dto dto = new BaseDto();
    PropertiesHelper pHelper = PropertiesFactory.getPropertiesHelper(PropertiesFile.G4);
    String micolor = pHelper.getValue("micolor", "blue");
    dto.put("micolor", micolor);
    String urlSecurity = pHelper.getValue("urlSecurity", "1");
    dto.put("urlSecurity", urlSecurity);
    dto.put("urlSecurity2", urlSecurity2);
    dto.put("userInfo", userInfo);
    dto.put("ajaxErrCode", G4Constants.Ajax_Timeout);
    dto.put("requestURL", request.getRequestURL());
    dto.put("contextPath", contextPath);
    dto.put("doctypeEnable", doctypeEnable);
    dto.put("extDisabled", G4Utils.isEmpty(extDisabled) ? "false" : extDisabled);
    dto.put("title", G4Utils.isEmpty(title) ? "G4Studio" : title);
    dto.put("jqueryEnabled", G4Utils.isEmpty(jqueryEnabled) ? "false" : jqueryEnabled);
    dto.put("showLoading", G4Utils.isEmpty(showLoading) ? "true" : showLoading);
    dto.put("uxEnabled", uxEnabled);
    dto.put("exportExceptionWindow", exportExceptionWindow);
    dto.put("fcfEnabled", fcfEnabled);
    dto.put("exportParams", exportParams);
    dto.put("exportUserinfo", exportUserinfo);
    dto.put("isSubPage", isSubPage);
    dto.put("pageLoadMsg", WebUtils.getParamValue("PAGE_LOAD_MSG", request));
    String titleIcon = WebUtils.getParamValue("TITLE_ICON", request);
    dto.put("titleIcon", G4Utils.isEmpty(titleIcon) ? "G4Studio.ico" : titleIcon);
    if (exportParams.equals("true")) {
      dto.put("paramList", WebUtils.getParamList(request));
    }
    // String agent = request.getHeader("user-agent");
    // dto.put("firefox", agent.indexOf("Firefox") == -1 ? "false" : "true");
    PropertiesHelper p = PropertiesFactory.getPropertiesHelper(PropertiesFile.G4);
    dto.put("extMode", p.getValue("extMode", TagConstant.Ext_Mode_Run));
    dto.put("runMode", p.getValue("runMode", TagConstant.RUN_MODE_NORMAL));
    Dto themeDto = new BaseDto();
    Dto resultDto = new BaseDto();
    if (G4Utils.isNotEmpty(userInfo)) {
      themeDto.put("userid", userInfo.getUserid());
      resultDto = armTagSupportService.getEauserSubInfo(themeDto);
    }
    String theme = null;
    if (G4Utils.isNotEmpty(resultDto)) theme = resultDto.getAsString("theme");
    String defaultTheme = WebUtils.getParamValue("SYS_DEFAULT_THEME", request);
    theme = G4Utils.isEmpty(theme) ? defaultTheme : theme;
    dto.put("theme", theme);
    TemplateEngine engine = TemplateEngineFactory.getTemplateEngine(TemplateType.VELOCITY);
    DefaultTemplate template = new FileTemplate();
    template.setTemplateResource(TagHelper.getTemplatePath(getClass().getName()));
    StringWriter writer = engine.mergeTemplate(template, dto);
    try {
      pageContext.getOut().write(writer.toString());
    } catch (IOException e) {
      log.error(G4Constants.Exception_Head + e.getMessage());
      e.printStackTrace();
    }
    return super.EVAL_BODY_INCLUDE;
  }

  /** 标签结束 */
  public int doEndTag() throws JspException {
    try {
      pageContext.getOut().write("</html>");
    } catch (IOException e) {
      log.error(G4Constants.Exception_Head + e.getMessage());
      e.printStackTrace();
    }
    return super.EVAL_PAGE;
  }

  /** 释放资源 */
  public void release() {
    extDisabled = null;
    title = null;
    jqueryEnabled = null;
    uxEnabled = null;
    fcfEnabled = null;
    doctypeEnable = null;
    exportParams = null;
    exportUserinfo = null;
    isSubPage = null;
    urlSecurity2 = null;
    super.release();
  }

  public void setExtDisabled(String extDisabled) {
    this.extDisabled = extDisabled;
  }

  public void setJqueryEnabled(String jqueryEnabled) {
    this.jqueryEnabled = jqueryEnabled;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  public void setShowLoading(String showLoading) {
    this.showLoading = showLoading;
  }

  public void setUxEnabled(String uxEnabled) {
    this.uxEnabled = uxEnabled;
  }

  public String getFcfEnabled() {
    return fcfEnabled;
  }

  public void setFcfEnabled(String fcfEnabled) {
    this.fcfEnabled = fcfEnabled;
  }

  public void setDoctypeEnable(String doctypeEnable) {
    this.doctypeEnable = doctypeEnable;
  }

  public void setExportParams(String exportParams) {
    this.exportParams = exportParams;
  }

  public void setExportUserinfo(String exportUserinfo) {
    this.exportUserinfo = exportUserinfo;
  }

  public void setIsSubPage(String isSubPage) {
    this.isSubPage = isSubPage;
  }

  public void setUrlSecurity2(String urlSecurity2) {
    this.urlSecurity2 = urlSecurity2;
  }

  public void setExportExceptionWindow(String exportExceptionWindow) {
    this.exportExceptionWindow = exportExceptionWindow;
  }
}
 /** 应用平台启动 */
 private void systemStartup(ServletContext servletContext) {
   PropertiesHelper pHelper = PropertiesFactory.getPropertiesHelper(PropertiesFile.G4);
   String forceLoad = pHelper.getValue("forceLoad", SystemConstants.FORCELOAD_N);
   long start = System.currentTimeMillis();
   if (forceLoad.equalsIgnoreCase(SystemConstants.FORCELOAD_N)) {
     log.info("*******************************************************");
     log.info("G4系统集成与应用开发平台[G4Studio]开始启动...");
     log.info("*******************************************************");
   }
   try {
     wac = SpringBeanLoader.getApplicationContext();
   } catch (Exception e) {
     success = false;
     e.printStackTrace();
   }
   if (success) {
     MonitorService monitorService =
         (MonitorService) SpringBeanLoader.getSpringBean("monitorService");
     monitorService.deleteHttpSession(new BaseDto());
     try {
       initDbType();
     } catch (SQLException e) {
       e.printStackTrace();
     }
   }
   if (success) {
     log.info("系统开始启动字典装载程序...");
     log.info("开始加载字典...");
     Reader g4Reader = (Reader) SpringBeanLoader.getSpringBean("g4Reader");
     List codeList = null;
     try {
       codeList = g4Reader.queryForList("Resource.getCodeViewList");
       log.info("字典加载成功!");
     } catch (Exception e) {
       success = false;
       log.error("字典加载失败!");
       e.printStackTrace();
     }
     servletContext.setAttribute("EACODELIST", codeList);
   }
   if (success) {
     log.info("系统开始启动全局参数表装载程序...");
     log.info("开始加载全局参数表...");
     List paramList = null;
     try {
       Reader g4Reader = (Reader) SpringBeanLoader.getSpringBean("g4Reader");
       paramList = g4Reader.queryForList("Resource.getParamList");
       log.info("全局参数表加载成功!");
     } catch (Exception e) {
       success = false;
       log.error("全局参数表加载失败!");
       e.printStackTrace();
     }
     servletContext.setAttribute("EAPARAMLIST", paramList);
   }
   long timeSec = (System.currentTimeMillis() - start) / 1000;
   log.info("********************************************");
   if (success) {
     log.info("G4系统集成与应用开发平台[G4Studio]启动成功[" + G4Utils.getCurrentTime() + "]");
     log.info("启动总耗时: " + timeSec / 60 + "分 " + timeSec % 60 + "秒 ");
   } else {
     log.error("G4系统集成与应用开发平台[G4Studio]启动失败[" + G4Utils.getCurrentTime() + "]");
     log.error("启动总耗时: " + timeSec / 60 + "分" + timeSec % 60 + "秒");
   }
   log.info("********************************************");
 }
Beispiel #6
0
/**
 * Desktop桌面布局标签:G4Studio_ARM专用
 *
 * @author XiongChun
 * @since 2012-12-22
 */
public class ArmDesktopTag extends TagSupport {

  private TagSupportService armTagSupportService =
      (TagSupportService) SpringBeanLoader.getSpringBean("armTagSupportService");

  private static Log log = LogFactory.getLog(HtmlTag.class);

  /** 标签开始 */
  public int doStartTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    UserInfoVo userInfo = WebUtils.getSessionContainer(request).getUserInfo();
    String contextPath = request.getContextPath();
    request.setAttribute("webContext", contextPath);
    Dto dto = new BaseDto();
    PropertiesHelper pHelper = PropertiesFactory.getPropertiesHelper(PropertiesFile.G4);
    dto.put("title", WebUtils.getParamValue("SYS_TITLE", request));
    dto.put("contextPath", contextPath);
    String titleIcon = WebUtils.getParamValue("TITLE_ICON", request);
    dto.put("titleIcon", G4Utils.isEmpty(titleIcon) ? "G4Studio.ico" : titleIcon);
    Dto themeDto = new BaseDto();
    Dto resultDto = new BaseDto();
    if (G4Utils.isNotEmpty(userInfo)) {
      themeDto.put("userid", userInfo.getUserid());
      resultDto = armTagSupportService.getEauserSubInfo(themeDto);
    }
    String theme = null;
    if (G4Utils.isNotEmpty(resultDto)) theme = resultDto.getAsString("theme");
    String defaultTheme = WebUtils.getParamValue("SYS_DEFAULT_THEME", request);
    theme = G4Utils.isEmpty(theme) ? defaultTheme : theme;
    dto.put("theme", theme);
    String layout = null;
    if (G4Utils.isNotEmpty(resultDto)) layout = resultDto.getAsString("layout");
    String defaultLayout = WebUtils.getParamValue("APP_LAYOUT", request);
    layout = G4Utils.isEmpty(layout) ? defaultLayout : layout;
    dto.put("layout", layout);
    String background = null;
    if (G4Utils.isNotEmpty(resultDto)) background = resultDto.getAsString("background");
    String defaultBackfround = WebUtils.getParamValue("DESKTOP_BACKGROUND", request);
    background = G4Utils.isEmpty(background) ? defaultBackfround : background;
    dto.put("background", background);
    PropertiesHelper p = PropertiesFactory.getPropertiesHelper(PropertiesFile.G4);
    dto.put("extMode", p.getValue("extMode", TagConstant.Ext_Mode_Run));
    dto.put("runMode", p.getValue("runMode", TagConstant.RUN_MODE_NORMAL));
    dto.put("ajaxErrCode", G4Constants.Ajax_Timeout);
    String micolor = pHelper.getValue("micolor", "blue");
    dto.put("username", WebUtils.getSessionContainer(request).getUserInfo().getUsername());
    dto.put("account", WebUtils.getSessionContainer(request).getUserInfo().getAccount());
    Dto qDto = new BaseDto();
    qDto.put("deptid", WebUtils.getSessionContainer(request).getUserInfo().getDeptid());
    dto.put("deptname", armTagSupportService.getDepartmentInfo(qDto).getAsString("deptname"));
    dto.put("userInfo", userInfo);
    List menuList = getMenuList();
    dto.put("menuList", menuList);
    dto.put("paramList", WebUtils.getParamList(request));
    TemplateEngine engine = TemplateEngineFactory.getTemplateEngine(TemplateType.VELOCITY);
    DefaultTemplate template = new FileTemplate();
    template.setTemplateResource(TagHelper.getTemplatePath(getClass().getName()));
    StringWriter writer = engine.mergeTemplate(template, dto);
    try {
      pageContext.getOut().write(writer.toString());
    } catch (IOException e) {
      log.error(G4Constants.Exception_Head + e.getMessage());
      e.printStackTrace();
    }
    return super.SKIP_BODY;
  }

  /**
   * 获取权限内的功能菜单
   *
   * @return
   */
  private List getMenuList() {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    String account = WebUtils.getSessionContainer(request).getUserInfo().getAccount();
    account = account == null ? "" : account;
    String accountType = SystemConstants.ACCOUNTTYPE_NORMAL;
    if (account.equalsIgnoreCase(WebUtils.getParamValue("DEFAULT_ADMIN_ACCOUNT", request))) {
      accountType = SystemConstants.ACCOUNTTYPE_SUPER;
    } else if (account.equalsIgnoreCase(
        WebUtils.getParamValue("DEFAULT_DEVELOP_ACCOUNT", request))) {
      accountType = SystemConstants.ACCOUNTTYPE_DEVELOPER;
    }
    Dto qDto = new BaseDto();
    qDto.put("accountType", accountType);
    qDto.put("userid", WebUtils.getSessionContainer(request).getUserInfo().getUserid());
    List menuList = armTagSupportService.getMenuList4Desktop(qDto).getDefaultAList();
    return menuList;
  }

  /** 标签结束 */
  public int doEndTag() throws JspException {
    return super.EVAL_PAGE;
  }

  /** 释放资源 */
  public void release() {

    super.release();
  }
}