/** 批量删除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); }
/** * 批量允许按钮功能 * * @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(); }
/** * 编辑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) { } } }