// 保存工作组
  public String saveGroupRule() {
    String name = getParaValue("name");
    String desciption = getParaValue("description");
    String[] id = getParaArrayValue("checkbox");
    String ids = "";
    if (ids != null) {
      for (int i = 0; i < id.length; i++) {
        ids = ids + id[i] + ",";
      }
    }
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date date = new Date();
    User user = (User) session.getAttribute(SessionConstant.CURRENT_USER);
    CompGroupRule vo = new CompGroupRule();
    vo.setName(name);

    vo.setDescription(desciption);
    vo.setRuleId(ids);
    vo.setCreatedBy(user.getName());
    vo.setCreatedTime(sdf.format(date));
    vo.setLastModifiedBy(user.getName());
    vo.setLastModifiedTime(sdf.format(date));
    CompGroupRuleDao dao = new CompGroupRuleDao();
    dao.save(vo);
    return null;
  }
  // 保存修改策略
  public String updateStrategy() {
    int id = getParaIntValue("id");
    String name = getParaValue("name");
    String description = getParaValue("description");
    int type = getParaIntValue("type");
    int violateType = getParaIntValue("violateType");
    String[] temp = getParaArrayValue("checkbox");
    StringBuffer ids = new StringBuffer();
    if (temp != null) {
      for (int i = 0; i < temp.length; i++) {
        ids.append(temp[i] + ",");
      }
    }

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date date = new Date();
    User user = (User) session.getAttribute(SessionConstant.CURRENT_USER);
    CompStrategy vo = new CompStrategy();
    vo.setId(id);
    vo.setName(name);
    vo.setDescription(description);
    vo.setType(type);
    vo.setViolateType(violateType);
    vo.setGroupId(ids.toString());
    vo.setLastModifiedBy(user.getName());
    vo.setLastModifiedTime(sdf.format(date));
    CompStrategyDao dao = new CompStrategyDao();
    dao.update(vo);
    return null;
  }
  public String reportDayList() {
    StringBuffer s = new StringBuffer();
    User current_user = (User) session.getAttribute(SessionConstant.CURRENT_USER);
    if (current_user.getBusinessids() != null) {
      if (current_user.getBusinessids() != "-1") {
        String[] bids = current_user.getBusinessids().split(",");
        if (bids.length > 0) {
          for (int ii = 0; ii < bids.length; ii++) {
            if (bids[ii].trim().length() > 0) {
              s.append(" bid like '%").append(bids[ii]).append("%' ");
              if (ii != bids.length - 1) s.append(" or ");
            }
          }
        }
      }
    }
    // InterfaceTempDao interfaceDao = new InterfaceTempDao();
    List list = new ArrayList();
    HostNodeDao dao = new HostNodeDao();
    list = dao.loadNetworkByBid(4, current_user.getBusinessids());

    List interfaceList = new ArrayList();
    PortconfigDao portconfigDao = new PortconfigDao();
    try {
      interfaceList = portconfigDao.getAllBySms();
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      portconfigDao.close();
    }

    request.setAttribute("list", list);
    request.setAttribute("interfaceList", interfaceList);
    return "/capreport/comprehensive/compreReportDay.jsp";
  }
Пример #4
0
 private String changeskins() {
   String skin = getParaValue("skin");
   CommonAppUtil.setSkin(skin);
   UserDao dao = new UserDao();
   User user = (User) session.getAttribute(SessionConstant.CURRENT_USER);
   user.setSkins(skin);
   dao.update(user);
   return "/user.do?action=home";
 }
Пример #5
0
  /**
   * 获得业务权限的 SQL 语句
   *
   * @author nielin
   * @date 2010-08-09
   * @return
   */
  public String getBidSql(String fieldName) {
    User current_user = (User) session.getAttribute(SessionConstant.CURRENT_USER);

    String sql = "";
    StringBuffer s = new StringBuffer();
    if (current_user.getRole() != 0) {
      int _flag = 0;
      if (current_user.getBusinessids() != null) {
        if (current_user.getBusinessids() != "-1") {
          String[] bids = current_user.getBusinessids().split(",");
          if (bids.length > 0) {
            for (int i = 0; i < bids.length; i++) {
              if (bids[i].trim().length() > 0) {
                if (_flag == 0) {
                  s.append(" and ( " + fieldName + " like '%," + bids[i].trim() + ",%' ");
                  _flag = 1;
                } else {
                  // flag = 1;
                  s.append(" or " + fieldName + " like '%," + bids[i].trim() + ",%' ");
                }
              }
            }
            s.append(") ");
          }
        }
      }
    }

    sql = s.toString();

    String treeBid = request.getParameter("treeBid");
    if (treeBid != null && treeBid.trim().length() > 0) {
      treeBid = treeBid.trim();
      treeBid = "," + treeBid + ",";
      String[] treeBids = treeBid.split(",");
      if (treeBids != null) {
        for (int i = 0; i < treeBids.length; i++) {
          if (treeBids[i].trim().length() > 0) {
            sql = sql + " and " + fieldName + " like '%," + treeBids[i].trim() + ",%'";
          }
        }
      }
    }
    // SysLogger.info("select * from topo_host_node where managed=1 "+sql);
    return sql;
  }
  public CompRule loadRule() {

    String rule_name = getParaValue("rule_name");
    String des = getParaValue("des");
    int standard = getParaIntValue(("standard"));
    int level = getParaIntValue("level");
    String add_des = getParaValue("add_des");

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date date = new Date();
    User user = (User) session.getAttribute(SessionConstant.CURRENT_USER);
    CompRule rule = new CompRule();
    rule.setComprule_name(rule_name);
    rule.setDescription(des);
    rule.setSelect_type(standard);
    rule.setCreate_time(sdf.format(date));
    rule.setLast_modified_time(sdf.format(date));
    rule.setCreated_by(user.getName());
    rule.setLast_modified_by(user.getName()); // 在修改时不变
    rule.setViolation_severity(level);
    rule.setRemediation_descr(add_des);
    return rule;
  }
  /**
   * 设备事件统计:01 主机设备告警统计明细:02 网络设备告警统计明细:03 事件告警趋势分析(每小时):04 主机设备TOP趋势分析:05 网络设备TOP趋势分析:06 星期日:0
   * 星期一:1 星期二:2 星期三:3 星期四:4 星期五:5 星期六:6 时间:03 模板保存
   */
  public void savePerforIndexWeek() {
    String dataStr = "保存成功!";

    String startTime = request.getParameter("startdate"); // 开始时间
    SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    if (startTime == null) {
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
      startTime = sdf.format(new Date()) + " 00:00:00";
    } else {
      startTime = startTime + " 00:00:00";
    }
    String toTime = request.getParameter("todate"); // 截至时间
    if (toTime == null) {
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
      toTime = sdf.format(new Date()) + " 23:59:59";
    } else {
      toTime = toTime + " 23:59:59";
    }
    DBManager dbManager = new DBManager();

    // 报表中内容
    String reportname = this.getParaValue("report_name"); // 报表名称 reportName,
    String username = this.getParaValue("recievers_name"); // 邮件接收人 reportUserName,
    String tile = this.getParaValue("tile"); // 邮件标题  emailTitle,
    String desc = this.getParaValue("desc"); // 邮件描述  emailContent,
    String bidtext = this.getParaValue("bidtext"); // 所属业务  attachmentBusiness,
    String reporttype = this.getParaValue("reporttype"); // 周报表   reportType,
    String exporttype = request.getParameter("exporttype"); // 报表类型  ExpReportType,
    String ids = request.getParameter("ids"); // 选择的设备  ids,
    String eventCount = this.getParaValue("eventCount"); // 设备事件统计
    //			String hostAlarmCount = this.getParaValue("hostAlarmCount");//hostAlarmCount 主机设备告警统计明细
    //			String netAlarmCount = this.getParaValue("netAlarmCount");//netAlarmCount  网络设备告警统计明细
    String eventAnalyze = this.getParaValue("eventAnalyze"); // eventAnalyze  事件告警趋势分析
    String hostTopAnalyze = this.getParaValue("hostTopAnalyze"); // hostTopAnalyze  主机设备TOP趋势分析
    String netTopAnalyze = this.getParaValue("netTopAnalyze"); // netTopAnalyze  网络设备TOP趋势分析
    String transmitfrequency = this.getParaValue("transmitfrequency"); // 周 reportContentOption,
    String sendtimeweek = this.getParaValue("sendtimeweek"); // 星期几  sendWeek,
    String sendtimehou = request.getParameter("sendtimehou"); // 发生时间  sendTime,
    String startdate = this.getParaValue("mystartdate");
    String mytodate = this.getParaValue("mytodate");

    // 报表内容
    try {
      reportname = new String(reportname.getBytes("iso8859-1"), "UTF-8");
      username = new String(username.getBytes("iso8859-1"), "UTF-8");
      tile = new String(tile.getBytes("iso8859-1"), "UTF-8");
      desc = new String(desc.getBytes("iso8859-1"), "UTF-8");
    } catch (UnsupportedEncodingException e1) {
      e1.printStackTrace();
    }

    String recieversId = this.getParaValue("recievers_id");
    UserDao userDao = new UserDao();
    List userList = new ArrayList();
    try {
      userList = userDao.findbyIDs(recieversId.substring(1));
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      userDao.close();
    }
    StringBuffer buf = new StringBuffer(); // 接收者邮件地址
    for (int i = 0; i < userList.size(); i++) {
      User vo = (User) userList.get(i);
      buf.append(vo.getEmail());
      buf.append(",");
    }
    Calendar tempCal = Calendar.getInstance();
    Date cc = tempCal.getTime();
    String time = sdFormat.format(cc);
    StringBuffer sql = new StringBuffer();
    // sql  attachmentBusiness
    sql.append(
        "insert into nms_compreReportWeek_resources"
            + "(reportName,reportUserName,emailTitle,emailContent,attachmentBusiness,"
            + "reportType,ExpReportType,ids,eventCount,"
            +
            //					"hostAlarmCount,netAlarmCount," +
            "eventAnalyze,hostTopAnalyze,netTopAnalyze,sendWeek,"
            + "sendOtherDay,sendTime,reportUserEmail) values('");
    sql.append(reportname + "','");
    sql.append(username + "','");
    sql.append(tile + "','");
    sql.append(desc + "','");
    sql.append(bidtext + "','");
    sql.append(reporttype + "','");
    sql.append(exporttype + "','");
    sql.append(ids + "','");
    sql.append(eventCount + "','");
    //			sql.append(hostAlarmCount+"','");
    //			sql.append(netAlarmCount+"','");
    sql.append(eventAnalyze + "','");
    sql.append(hostTopAnalyze + "','");
    sql.append(netTopAnalyze + "','");
    sql.append(transmitfrequency + "','");
    sql.append(sendtimeweek + "','");
    sql.append(sendtimehou + "','");
    //			sql.append(startdate+"','");
    //			sql.append(mytodate+"','");
    sql.append(buf.toString() + "')");
    try {
      dbManager.executeUpdate(sql.toString());
    } catch (Exception e) {
      e.printStackTrace();
      dataStr = "保存失败!!!";
    } finally {
      dbManager.close();
    }
    Map<String, String> map = new HashMap<String, String>();
    map.put("dataStr", dataStr);
    JSONObject json = JSONObject.fromObject(map);
    out.print(json);
    out.flush();
  }