/**
  * 判断该任务是否存在
  *
  * @throws IOException
  */
 public String checkUnique() throws IOException {
   HttpServletRequest request = ServletActionContext.getRequest();
   String vcTaskName = request.getParameter("vcTaskName").trim();
   int i = keywordsTacticsImpl.isVcTaskName(vcTaskName);
   if (i == -1) { // -1表示不存在该任务名称
     Struts2Utils.renderText("true");
   } else {
     Struts2Utils.renderText("false");
   }
   return null;
 }
 /** 支持使用Jquery.validate Ajax检验用户名是否重复. */
 public String checkUnique() {
   HttpServletRequest request = Struts2Utils.getRequest();
   String loginName = request.getParameter("entity.vcLoginName");
   String oldLoginName = request.getParameter("oldLoginName");
   if (baseUserInfoManager.isPropertyUnique("vcLoginName", loginName, oldLoginName)) {
     Struts2Utils.renderText("true");
   } else {
     Struts2Utils.renderText("false");
   }
   return null;
 }
 /** 获取角色对应菜单ID */
 public void getAjaxRoleMenuIds() throws Exception {
   String menuIds = "";
   HttpServletRequest request = ServletActionContext.getRequest();
   String roleId = request.getParameter("role_id");
   List list = basePermissionsManager.getAllPermis(false);
   List permisList = baseRoleManager.getRolePermis(roleId);
   if (list != null && !list.isEmpty()) {
     for (Iterator it = list.iterator(); it.hasNext(); ) {
       VBasePermissions basePermisView = (VBasePermissions) it.next();
       String permis_id = basePermisView.getId();
       // 循环得到角色标识对应菜单
       if (permisList != null && !permisList.isEmpty()) {
         for (Iterator it2 = permisList.iterator(); it2.hasNext(); ) {
           TbBaseRolePermis tbBaseRolePermis = (TbBaseRolePermis) it2.next();
           if (permis_id.equals(tbBaseRolePermis.getVcPermId())) {
             menuIds = menuIds + permis_id + ":";
           }
         }
       }
     }
   }
   if (!"".equals(menuIds)) {
     menuIds = menuIds.substring(0, menuIds.lastIndexOf(":"));
   }
   Struts2Utils.renderText(menuIds);
 }
  /** 获取图形数据 */
  public void getAjaxChartXmlData() throws Exception {
    // int pageSize = 20;
    /*
     * 图表不包含‘其他’的数据,因此为了去除其他,必须多查一条数据
     */

    int pageSize = 21;
    String totalXml =
        this.packTotalData(
            dataType_search,
            spaceLevel_search,
            businessName,
            timeLevel_search,
            time_search,
            pageSize);
    String imsisXml =
        this.packImsisData(
            dataType_search,
            spaceLevel_search,
            businessName,
            timeLevel_search,
            time_search,
            pageSize);
    String countXml =
        this.packCountData(
            dataType_search,
            spaceLevel_search,
            businessName,
            timeLevel_search,
            time_search,
            pageSize);
    Struts2Utils.renderText(totalXml + "&&&" + imsisXml + "&&&" + countXml);
  }
 /** 核查旧密码合法性 */
 public String checkPwd() throws ServiceStartupException {
   HttpServletRequest request = Struts2Utils.getRequest();
   String oldPwd = request.getParameter("oldPwd");
   LoginListener loginListener =
       (LoginListener)
           ServletActionContext.getRequest()
               .getSession()
               .getAttribute(VarConstants.LOGIN_LISTENER_KEY);
   String userid = loginListener.getSessionContainer().getUserInfo().getId();
   TbBaseUserInfo userInfo = baseUserInfoManager.get(userid);
   if (Utils.getMD5String(oldPwd).equals(userInfo.getVcPassword())) {
     Struts2Utils.renderText("true");
   } else {
     Struts2Utils.renderText("false");
   }
   return null;
 }
 /** 停止策略 */
 public void stopTactics() throws Exception {
   HttpServletRequest request = ServletActionContext.getRequest();
   String msg = "";
   ServletActionContext.getResponse().setCharacterEncoding("UTF-8");
   ServletActionContext.getRequest().setCharacterEncoding("UTF-8");
   int nmDataGetterTaskId = ReqUtils.getReqInt(request, "ids");
   keywordsTacticsImpl.stopTatctics(nmDataGetterTaskId);
   msg = "停止策略成功!";
   Struts2Utils.renderText(msg);
 }
 /** 同步统一网管平台用户信息 */
 public void getAllUnmpUserInfo() {
   String msg = "";
   try {
     boolean b = unmpUserManager.getAllUnmpUserInfo();
     if (b) {
       msg = "同步用户成功!";
     } else {
       msg = "同步用户失败!";
     }
   } catch (Exception e) {
     logger.error(e.getMessage());
     msg = "同步用户失败!";
   }
   Struts2Utils.renderText(msg);
 }
 /** 删除用户 */
 public void deleteUsers() throws Exception {
   HttpServletRequest request = ServletActionContext.getRequest();
   String ids = request.getParameter("ids");
   String[] sids = ids.split(",");
   String msg = "";
   try { // 删除成功
     baseUserInfoManager.deleteByKeys(sids);
     msg = "删除用户成功!";
     commonManagerImpl.log(request, "删除用户[主键:" + ids + "]成功!");
   } catch (Exception e) { // 删除失败
     msg = "删除用户成功\\!";
     commonManagerImpl.log(request, "删除用户[主键:" + ids + "]失败!");
   }
   Struts2Utils.renderText(msg);
 }
 /** 删除策略 */
 public void deleteTactics() throws Exception {
   HttpServletRequest request = ServletActionContext.getRequest();
   String msg = "";
   ServletActionContext.getResponse().setCharacterEncoding("UTF-8");
   ServletActionContext.getRequest().setCharacterEncoding("UTF-8");
   String nmDataGetterTaskId = ReqUtils.getReqString(request, "ids");
   List dlist = keywordsTacticsImpl.findDataGetterFilterId(nmDataGetterTaskId);
   if (dlist != null && dlist.size() > 0) {
     String nmDataGetterFilterId = "";
     for (int i = 0; i < dlist.size(); i++) {
       nmDataGetterFilterId = nmDataGetterFilterId + dlist.get(i).toString() + ",";
     }
     nmDataGetterFilterId = nmDataGetterFilterId.substring(0, nmDataGetterFilterId.length() - 1);
     keywordsTacticsImpl.deleteKeyValueSoTypeIdFilter(nmDataGetterFilterId);
   }
   keywordsTacticsImpl.deleteTactics(nmDataGetterTaskId);
   msg = "删除策略成功!";
   Struts2Utils.renderText(msg);
 }
  /**
   * 获取部门和角色信息
   *
   * @throws Exception
   */
  public void getAjaxXmlData() throws Exception {
    deptsList = baseDepartmentManager.getAll(); // 获取所有部门
    rolesList = baseRoleManager.getAll(); // 获取所有角色
    String deptXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    if (deptsList != null && !deptsList.isEmpty()) {
      deptXml = deptXml + "<root>";
      for (TbBaseDepartment dept : deptsList) {
        deptXml =
            deptXml
                + "<data>"
                + "<id>"
                + dept.getId()
                + "</id>"
                + "<name>"
                + dept.getVcDeptName()
                + "</name>"
                + "</data>";
      }
      deptXml = deptXml + "</root>";
    }

    String roleXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    if (rolesList != null && !rolesList.isEmpty()) {
      roleXml = roleXml + "<root>";
      for (TbBaseRoles role : rolesList) {
        roleXml =
            roleXml
                + "<data>"
                + "<id>"
                + role.getId()
                + "</id>"
                + "<name>"
                + role.getVcRolesName()
                + "</name>"
                + "</data>";
      }
      roleXml = roleXml + "</root>";
    }
    Struts2Utils.renderText(deptXml + "&&&" + roleXml);
  }