示例#1
0
 private Map<String, String> getServerByNodeId(String id) {
   Map<String, String> map = new LinkedHashMap<String, String>();
   INode node = view.getNode(id);
   if (node == null) return map;
   if (INode.MONITOR.equals(node.getType())) {
     return map;
   }
   if (INode.ENTITY.equals(node.getType())) {
     EntityInfo entityinfo = view.getEntityInfo(node);
     if (entityinfo.getDeviceType() != null) {
       if ("_win".equals(entityinfo.getDeviceType())
           || "_unix".equals(entityinfo.getDeviceType())) {
         map.put(
             entityinfo.getSvId(), entityinfo.getName() + "(" + entityinfo.getDeviceType() + ")");
         return map;
       }
     }
   }
   IForkNode f = (IForkNode) node;
   List<String> ids = f.getSonList();
   for (String newid : ids) {
     map.putAll(this.getServerByNodeId(newid));
   }
   return map;
 }
 public void onInit() throws Exception {
   try {
     View view = Toolkit.getToolkit().getSvdbView(Executions.getCurrent().getDesktop());
     if (!view.isAdmin()) { // 非管理员用户
       IniFile userIniFile = view.getUserIni();
       String addTopN_str =
           userIniFile.getValue(userIniFile.getSections(), UserRightId.DoTopNReportlistAdd);
       String deleteTopN_str =
           userIniFile.getValue(userIniFile.getSections(), UserRightId.DoTopNReportlistDel);
       String editTopN_str =
           userIniFile.getValue(userIniFile.getSections(), UserRightId.DoStatisticReportlistEdit);
       if (!"1".equals(addTopN_str)) {
         addTopN.setDisabled(true);
       }
       if (!"1".equals(deleteTopN_str)) {
         delete.setDisabled(true);
       }
       if (!"1".equals(editTopN_str)) {
         editFlag = false;
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  /** 批量删除topN报告 */
  public void onClick$delete(Event event) {
    if (topNList.getSelectedCount() <= 0) {
      try {
        Messagebox.show("请选择报告!", "提示", Messagebox.OK, Messagebox.INFORMATION);
      } catch (InterruptedException e) {
      }
      return;
    }
    try {
      int ret =
          Messagebox.show(
              "你确认要删除选中的记录吗?", "询问", Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION);
      if (ret == Messagebox.CANCEL) return;
      Set<Listitem> items = topNList.getSelectedItems();
      if (items == null || items.size() == 0) return;
      Iterator itr = items.iterator();
      this.iniFile = new IniFile(INI_FILE);
      if (iniFile == null) return;
      for (; itr.hasNext(); ) {
        Listitem item = (Listitem) itr.next();
        iniFile.deleteSection(item.getId());
        IniFile iniGen = new IniFile("reportTopN." + item.getId() + ".ini");
        try {
          iniGen.load();
        } catch (Exception e) {

        }
        List<String> sections = iniGen.getSectionList();
        for (String section : sections) {
          if (section.equalsIgnoreCase("TempSection(Please_modify_it)")) continue;
          Map<String, String> value = iniGen.getFmap().get(section);
          String fileType = value.get("fileType");
          String filePath = TopNLogListmodel.getfilename(section, fileType);
          File f = new File(filePath);
          if (!f.exists()) continue;
          f.delete();
          if (fileType.equals("html")) {
            f.delete();
            Toolkit.getToolkit().deleteFolder(filePath + "_files");
          }
          iniGen.deleteSection(section);
        }
        iniGen.saveChange();
      }

      iniFile.saveChange(); // 1252396986281
    } catch (Exception e) {
      e.printStackTrace();
    }
    View view = Toolkit.getToolkit().getSvdbView(Executions.getCurrent().getDesktop());
    String loginname = view.getLoginName();
    String minfo =
        loginname + " " + "在" + OpObjectId.topn_report.name + "中进行了  " + OpTypeId.del.name + "操作。";
    AppendOperateLog.addOneLog(loginname, minfo, OpTypeId.del, OpObjectId.topn_report);
    // 刷新页面
    refreshInifile();
    refreshiControl();
    this.topNGenerateTime.getItems().clear();
  }
  /**
   * 生成报告按钮事件
   *
   * @param event
   * @throws Exception
   */
  public void onClick$CreateReportBtn(Event event) throws Exception {

    if (topNList.getSelectedItem() == null) {
      try {
        Messagebox.show("请选择报告!", "提示", Messagebox.OK, Messagebox.INFORMATION);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      return;
    }

    View view = Toolkit.getToolkit().getSvdbView(event.getTarget().getDesktop());
    String loginname = view.getLoginName();
    Listitem item = topNList.getSelectedItem();
    String section = item.getId();
    this.iniFile = new IniFile(INI_FILE);
    try {
      this.iniFile.load();
    } catch (Exception e) {
    }
    Map<String, String> reportDefine = this.iniFile.getSectionData(section);
    String Period = reportDefine.get("Period");
    String filetype = reportDefine.get("fileType");
    if (filetype == null) {
      filetype = "html";
    }
    Date tmStart = null;
    Date tmEnd = new Date();

    if (Period.equals("Month")) tmStart = Toolkit.getToolkit().delDay(new Date(), 30);
    else if (Period.equals("Week")) tmStart = Toolkit.getToolkit().delDay(new Date(), 7);
    else if (Period.equals("Day")) tmStart = Toolkit.getToolkit().delDay(new Date(), 1);
    else {
      Toolkit.getToolkit().showError("报告区间不支持:");
      return;
    }

    TopNReport tmpTopNReport = new TopNReport(section, reportDefine, tmStart, tmEnd, view, false);

    //	    tmpTopNReport.createReport();
    Thread thread = new Thread(tmpTopNReport);
    thread.setName("TopNReport -- TopNReport.java");
    thread.start();
    final Window win =
        (Window) Executions.createComponents("/main/progress/topnprogress.zul", null, null);
    win.setAttribute("topnreport", tmpTopNReport);
    win.setAttribute("filetype", filetype);
    win.setAttribute("reportname", tmpTopNReport.strReportName);
    win.doModal();
    // AMedia(String name, String format, String ctype, URL url, String charset)
    // 刷新日志数据

    // addlog
    //		View view = Toolkit.getToolkit().getSvdbView(event.getTarget().getDesktop());
    String minfo = loginname + " " + "在" + OpObjectId.topn_report.name + "中进行了手动生成报告操作.";
    AppendOperateLog.addOneLog(loginname, minfo, OpTypeId.add, OpObjectId.topn_report);
    onSelecttopNList(event);
  }
 private String getInitFrequecy(INode node) {
   View view = Toolkit.getToolkit().getSvdbView(getDesktop());
   MonitorInfo info = view.getMonitorInfo(node);
   MonitorTemplate tmplate = info.getMonitorTemplate();
   String initFreq = "";
   for (Map<String, String> keyMap : tmplate.get_Parameter_Items()) {
     if ("监测频率".equals(keyMap.get("sv_label"))) {
       initFreq = keyMap.get("sv_value") + "分钟";
       break;
     }
   }
   return initFreq;
 }
  /**
   * 批量允许按钮功能
   *
   * @param event
   */
  public void onClick$batchAllow(Event event) {
    if (topNList.getSelectedCount() <= 0) {
      try {
        Messagebox.show("请选择报告!", "提示", Messagebox.OK, Messagebox.INFORMATION);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      return;
    }

    Set<Listitem> items = topNList.getSelectedItems();
    if (items == null || items.size() == 0) return;
    Iterator itr = items.iterator();
    this.iniFile = new IniFile(INI_FILE);
    if (iniFile == null) return;
    try {
      iniFile.load();
    } catch (Exception e1) {
      e1.printStackTrace();
    }
    for (; itr.hasNext(); ) {
      Listitem item = (Listitem) itr.next();
      try {
        iniFile.setKeyValue(item.getId(), "Deny", "No"); // 允许
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    try {
      iniFile.saveChange();
    } catch (Exception e) {
      e.printStackTrace();
    }

    View view = Toolkit.getToolkit().getSvdbView(event.getTarget().getDesktop());
    String loginname = view.getLoginName();
    String minfo =
        loginname
            + " "
            + "在"
            + OpObjectId.topn_report.name
            + "中进行了  "
            + OpTypeId.enable.name
            + "操作。";
    AppendOperateLog.addOneLog(loginname, minfo, OpTypeId.enable, OpObjectId.topn_report);
    // 刷新页面
    refreshiControl();
  }
示例#7
0
  @Override
  public Map<String, String> getSelectArray() {
    Map<String, String> map = new LinkedHashMap<String, String>();
    if (view == null) view = Toolkit.getToolkit().getSvdbView(this.getDesktop());
    map.put("127.0.0.1", "127.0.0.1");

    INode[] ses = view.getSe();
    for (INode se : ses) {
      map.putAll(this.getServerByNodeId(se.getSvId()));
    }
    //		return map;

    // ÅÅÐò
    ArrayList keylist = new ArrayList();
    for (String key : map.keySet()) {
      keylist.add(key);
    }
    Object[] strKeylist = keylist.toArray();
    Arrays.sort(strKeylist); // ÅÅÐò
    Map<String, String> changedMap = new LinkedHashMap<String, String>();
    for (Object key : strKeylist) {
      String value = map.get(key);
      changedMap.put(key.toString(), value);
    }
    return changedMap;
  }
 /**
  * 编辑TOP_N报告
  *
  * @param section
  * @throws Exception
  */
 public void onTpenEditTop_NReport(Event section) throws Exception {
   View view = Toolkit.getToolkit().getSvdbView(Executions.getCurrent().getDesktop());
   if (this.editFlag) {
     final Window win = (Window) Executions.createComponents(EditTOPN, null, null);
     win.setAttribute("isedit", true);
     win.setAttribute("tTopNReportComposer", this);
     win.setAttribute("iniFile", iniFile);
     win.setAttribute("currsection", section.getData());
     try {
       win.doModal();
     } catch (Exception e) {
       return;
     }
     refreshInifile();
     String loginname = view.getLoginName();
     String minfo =
         loginname
             + " "
             + "在"
             + OpObjectId.topn_report.name
             + "中进行了  "
             + OpTypeId.edit.name
             + "操作。";
     AppendOperateLog.addOneLog(loginname, minfo, OpTypeId.edit, OpObjectId.topn_report);
   } else {
     try {
       Messagebox.show(
           "用户:" + view.getLoginName() + " 没有  编辑TopN报告  的权限!",
           "提示",
           Messagebox.OK,
           Messagebox.INFORMATION);
       return;
     } catch (Exception e) {
     }
   }
 }