Ejemplo n.º 1
0
 public static IniFile getIniFile(String fileName) throws Exception {
   IniFile iniFile = new IniFile(fileName);
   try {
     iniFile.load();
   } catch (Exception e) {
     e.printStackTrace();
   }
   return iniFile;
 }
Ejemplo n.º 2
0
  /*
   * 批量删除日志
   */
  public void onClick$btnBatchDeleteGen(Event event) throws Exception {
    if (topNGenerateTime.getSelectedCount() == 0) {

      try {
        Messagebox.show("请选择报告!", "提示", Messagebox.OK, Messagebox.INFORMATION);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      return;
    }
    try {
      int ret =
          Messagebox.show(
              "你确认要删除选中的记录吗?", "提示", Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION);

      if (ret == Messagebox.CANCEL) return;
    } catch (Exception e) {
      e.printStackTrace();
    }
    Listitem topNlist = topNList.getSelectedItem();
    Iterator it = topNGenerateTime.getSelectedItems().iterator();
    try {
      while (it.hasNext()) {
        Listitem item = (Listitem) it.next();
        TopNLogBean logbean = (TopNLogBean) item.getValue();
        String section = logbean.getTitle();
        String filetype = logbean.getFiletype();
        String finame = TopNLogListmodel.getfilename(section, filetype);
        String reportid = topNlist.getId();
        IniFile inifile = new IniFile("reportTopN." + reportid + ".ini");
        inifile.load();
        for (String key : inifile.getSectionList()) {
          if (key.equals(section)) {
            inifile.deleteSection(section);
            inifile.saveChange();
            File file = new File(finame);
            File folder = new File(finame + "_files");
            if (file.exists()) {
              file.delete();
            }
            if (folder.exists()) {
              Toolkit.getToolkit().deleteFolder(finame + "_files");
            }
          }
        }
      }
    } catch (Exception e) {
      throw e;
    }
    // 刷新数据
    onSelecttopNList(event);
  }
Ejemplo n.º 3
0
  /** 批量删除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();
  }
Ejemplo n.º 4
0
  /**
   * 批量允许按钮功能
   *
   * @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();
  }
Ejemplo n.º 5
0
 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();
   }
 }
Ejemplo n.º 6
0
 /**
  * 报告列表点击事件,显示自动生成的TOPN报告
  *
  * @param event
  */
 public void onSelecttopNList(Event event) {
   Listitem item = topNList.getSelectedItem();
   if (topNGenerateTime.getItemCount() > 0) {
     topNGenerateTime.getItems().clear();
   }
   if (item == null) {
     return;
   }
   String reportid = item.getId();
   IniFile iniGen = new IniFile("reportTopN." + reportid + ".ini");
   try {
     iniGen.load();
   } catch (Exception e) {
     return;
   }
   topn_time.setVisible(true);
   TopNLogListmodel model = new TopNLogListmodel(iniGen, this);
   topNGenerateTime.setModel(model);
   topNGenerateTime.setItemRenderer(model);
 }