diff --git a/src/com/fr/data/MobileTableWsdlDataDemo.java b/src/com/fr/data/MobileTableWsdlDataDemo.java index 938f2c0..bd0535a 100644 --- a/src/com/fr/data/MobileTableWsdlDataDemo.java +++ b/src/com/fr/data/MobileTableWsdlDataDemo.java @@ -20,7 +20,7 @@ public class MobileTableWsdlDataDemo extends AbstractTableData { private String[][] data; public MobileTableWsdlDataDemo() { - this.data = this.getData(); + this.data = this.getMobileTableWsdlData(); } @Override @@ -82,7 +82,7 @@ public class MobileTableWsdlDataDemo extends AbstractTableData { } - public String[][] getData() { + public String[][] getMobileTableWsdlData() { try { String url = "http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl"; EndpointReference targetEPR = new EndpointReference(url); diff --git a/src/com/fr/data/MobileWsdlTableDataDemo.java b/src/com/fr/data/MobileWsdlTableDataDemo.java index d6bc4ee..44eca53 100644 --- a/src/com/fr/data/MobileWsdlTableDataDemo.java +++ b/src/com/fr/data/MobileWsdlTableDataDemo.java @@ -23,7 +23,7 @@ public class MobileWsdlTableDataDemo extends AbstractTableData { private String[][] data; public MobileWsdlTableDataDemo() { - this.data = this.getData(); + this.data = this.getMobileWsdlTableData(); } public int getColumnCount() throws TableDataException { @@ -78,7 +78,7 @@ public class MobileWsdlTableDataDemo extends AbstractTableData { } - public String[][] getData() { + public String[][] getMobileWsdlTableData() { try { String url = "http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl"; EndpointReference targetEPR = new EndpointReference(url); @@ -102,8 +102,6 @@ public class MobileWsdlTableDataDemo extends AbstractTableData { OMElement result1 = sender.sendReceive(method); String[][] result = getResults(result1); return result; - } catch (org.apache.axis2.AxisFault e) { - e.printStackTrace(); } catch (java.rmi.RemoteException e) { e.printStackTrace(); } diff --git a/src/com/fr/data/MobileWsdlTableDataDemo1.java b/src/com/fr/data/MobileWsdlTableDataDemo1.java index a84f159..c46fc03 100644 --- a/src/com/fr/data/MobileWsdlTableDataDemo1.java +++ b/src/com/fr/data/MobileWsdlTableDataDemo1.java @@ -17,7 +17,7 @@ public class MobileWsdlTableDataDemo1 extends AbstractTableData { private String[][] data; public MobileWsdlTableDataDemo1() { - this.data = this.getData(); + this.data = this.getMobileWsdlTableData(); } public int getColumnCount() throws TableDataException { @@ -72,7 +72,7 @@ public class MobileWsdlTableDataDemo1 extends AbstractTableData { } - public String[][] getData() { + public String[][] getMobileWsdlTableData() { try { String url = "http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl"; EndpointReference targetEPR = new EndpointReference(url); @@ -98,8 +98,6 @@ public class MobileWsdlTableDataDemo1 extends AbstractTableData { return result; } catch (org.apache.axis2.AxisFault e) { e.printStackTrace(); - } catch (java.rmi.RemoteException e) { - e.printStackTrace(); } return new String[][]{{}}; } diff --git a/src/com/fr/data/MobileWsdlTableDataDemoPara.java b/src/com/fr/data/MobileWsdlTableDataDemoPara.java index c31c775..fb12108 100644 --- a/src/com/fr/data/MobileWsdlTableDataDemoPara.java +++ b/src/com/fr/data/MobileWsdlTableDataDemoPara.java @@ -18,7 +18,7 @@ public class MobileWsdlTableDataDemoPara extends AbstractTableData { private String[][] data; public MobileWsdlTableDataDemoPara() { - this.data = this.getData(); + this.data = this.getMobileWsdlTableData(); } public int getColumnCount() throws TableDataException { @@ -69,7 +69,7 @@ public class MobileWsdlTableDataDemoPara extends AbstractTableData { } - public String[][] getData() { + public String[][] getMobileWsdlTableData() { try { FRLogger.getLogger().error("进入了"); String url = "http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl"; @@ -99,8 +99,6 @@ public class MobileWsdlTableDataDemoPara extends AbstractTableData { OMElement result1 = sender.sendReceive(method); String[][] result = getResults(result1); return result; - } catch (org.apache.axis2.AxisFault e) { - e.printStackTrace(); } catch (java.rmi.RemoteException e) { e.printStackTrace(); } diff --git a/src/com/fr/data/ParamSAPDataTest.java b/src/com/fr/data/ParamSAPDataTest.java index 25e1df8..973ed22 100644 --- a/src/com/fr/data/ParamSAPDataTest.java +++ b/src/com/fr/data/ParamSAPDataTest.java @@ -1,13 +1,16 @@ package com.fr.data; import com.fr.base.FRContext; -import com.fr.base.Parameter; +import com.fr.config.holder.impl.xml.XmlColConf; import com.fr.function.ConnectSAPServer; +import com.fr.stable.ParameterProvider; import com.sap.conn.jco.JCoDestination; import com.sap.conn.jco.JCoException; import com.sap.conn.jco.JCoFunction; import com.sap.conn.jco.JCoTable; +import java.util.ArrayList; + public class ParamSAPDataTest extends AbstractTableData { private String[] columnNames = null; @@ -18,8 +21,12 @@ public class ParamSAPDataTest extends AbstractTableData { private static JCoDestination jCoDestination; public ParamSAPDataTest() { - this.parameters = new Parameter[]{new Parameter("LIFNR"), - new Parameter("NAME1")}; + ArrayList arrayList = new ArrayList<>(); + arrayList.add("LIFNR"); + arrayList.add("NAME1"); + + + this.parameters = new XmlColConf<>(arrayList, ParameterProvider.class); this.columnNames = new String[this.columnNum]; this.columnNames[0] = "供应商编码"; @@ -69,8 +76,10 @@ public class ParamSAPDataTest extends AbstractTableData { if (function == null) throw new RuntimeException( "Function not found in SAP."); - function.getImportParameterList().setValue("LIFNR", "%" + this.parameters[0].getValue().toString().toUpperCase().trim() + "%"); - function.getImportParameterList().setValue("NAME1", "%" + this.parameters[1].getValue().toString().toUpperCase().trim() + "%"); + function.getImportParameterList().setValue("LIFNR", "%" + + ((ParameterProvider) (parameters.get().toArray()[0])).getValue().toString().toUpperCase().trim() + "%"); + function.getImportParameterList().setValue("NAME1", "%" + ((ParameterProvider) (parameters.get().toArray()[1])) + .getValue().toString().toUpperCase().trim() + "%"); function.execute(jCoDestination); JCoTable returnTable = function.getTableParameterList().getTable( "ZLFA1S3"); diff --git a/src/com/fr/data/ParamTableDataDemo.java b/src/com/fr/data/ParamTableDataDemo.java index 551c58f..8024cfa 100644 --- a/src/com/fr/data/ParamTableDataDemo.java +++ b/src/com/fr/data/ParamTableDataDemo.java @@ -2,6 +2,7 @@ package com.fr.data; import com.fr.base.FRContext; import com.fr.file.DatasourceManager; +import com.fr.stable.ParameterProvider; import java.sql.Connection; import java.sql.DriverManager; @@ -82,8 +83,7 @@ public class ParamTableDataDemo extends AbstractTableData { return; } // 保存得到的数据库表名 - String tableName = parameters[0].getValue().toString(); - + String tableName = ((ParameterProvider) (parameters.get().toArray())[0]).getValue().toString(); // 构造SQL语句,并打印出来 String sql = "select * from " + tableName; diff --git a/src/com/fr/data/WebServiceTableData.java b/src/com/fr/data/WebServiceTableData.java index 60173d7..127f658 100644 --- a/src/com/fr/data/WebServiceTableData.java +++ b/src/com/fr/data/WebServiceTableData.java @@ -10,7 +10,7 @@ public class WebServiceTableData extends AbstractTableData { private String[][] data; public WebServiceTableData() { - this.data = this.getData(); + this.data = this.getWebServiceTableData(); } //获取列数 @@ -41,7 +41,7 @@ public class WebServiceTableData extends AbstractTableData { return data[rowIndex + 1][columnIndex]; } - public String[][] getData() { + public String[][] getWebServiceTableData() { try { String endpoint = "http://localhost:8080/axis/TestWS2TDClient.jws"; Service service = new Service(); diff --git a/src/com/fr/data/WebServiceWsdlTableDataDemo2.java b/src/com/fr/data/WebServiceWsdlTableDataDemo2.java index 48662fb..a4f16e8 100644 --- a/src/com/fr/data/WebServiceWsdlTableDataDemo2.java +++ b/src/com/fr/data/WebServiceWsdlTableDataDemo2.java @@ -11,7 +11,7 @@ public class WebServiceWsdlTableDataDemo2 extends AbstractTableData { private String[][] data; public WebServiceWsdlTableDataDemo2() { - this.data = this.getData(); + this.data = this.getWebServiceWsdlTableData(); } public int getColumnCount() throws TableDataException { @@ -33,7 +33,7 @@ public class WebServiceWsdlTableDataDemo2 extends AbstractTableData { return data[rowIndex + 1][columnIndex]; } - public String[][] getData() { + public String[][] getWebServiceWsdlTableData() { try { String url = "http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl"; MobileCodeWSStub stub = new MobileCodeWSStub(url); @@ -55,8 +55,6 @@ public class WebServiceWsdlTableDataDemo2 extends AbstractTableData { } } return result; - } catch (org.apache.axis2.AxisFault e) { - e.printStackTrace(); } catch (java.rmi.RemoteException e) { e.printStackTrace(); } @@ -64,8 +62,8 @@ public class WebServiceWsdlTableDataDemo2 extends AbstractTableData { } public static void main(String[] args) { - for (int i = 0; i < new WebServiceWsdlTableDataDemo2().getData().length; i++) { - System.out.println(new WebServiceWsdlTableDataDemo2().getData()[i]); + for (int i = 0; i < new WebServiceWsdlTableDataDemo2().getWebServiceWsdlTableData().length; i++) { + System.out.println(new WebServiceWsdlTableDataDemo2().getWebServiceWsdlTableData()[i]); } } } \ No newline at end of file diff --git a/src/com/fr/data/XMLDemoTableData.java b/src/com/fr/data/XMLDemoTableData.java index 419e4ac..8d5c80d 100644 --- a/src/com/fr/data/XMLDemoTableData.java +++ b/src/com/fr/data/XMLDemoTableData.java @@ -1,6 +1,7 @@ package com.fr.data; import com.fr.base.Parameter; +import com.fr.config.holder.impl.xml.XmlColConf; import com.fr.general.data.DataModel; import com.fr.script.Calculator; import com.fr.stable.ParameterProvider; @@ -29,8 +30,8 @@ public class XMLDemoTableData extends AbstractParameterTableData { // 构造函数 public XMLDemoTableData() { // 定义需要的参数,这里定义一个参数,参数名为filename,给其一个默认值"Northwind.xml" - this.parameters = new Parameter[1]; - this.parameters[0] = new Parameter("filename", "Northwind"); + this.parameters = new XmlColConf<>(new ArrayList(), ParameterProvider.class); + parameters.add(new Parameter("filename", "Northwind")); } /** diff --git a/src/com/fr/demo/ChangeRowAndCol.java b/src/com/fr/demo/ChangeRowAndCol.java index bdbbf8d..61afa9b 100644 --- a/src/com/fr/demo/ChangeRowAndCol.java +++ b/src/com/fr/demo/ChangeRowAndCol.java @@ -1,8 +1,6 @@ //遍历单元格 package com.fr.demo; -import com.fr.base.Env; -import com.fr.base.FRContext; import com.fr.io.TemplateWorkBookIO; import com.fr.main.TemplateWorkBook; import com.fr.report.cell.TemplateCellElement; @@ -10,6 +8,7 @@ import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.worksheet.WorkSheet; import com.fr.web.core.Reportlet; import com.fr.web.request.ReportletRequest; +import com.fr.workspace.simple.SimpleWork; import java.util.Map; @@ -18,12 +17,13 @@ public class ChangeRowAndCol extends Reportlet { public TemplateWorkBook createReport(ReportletRequest reportletrequest) { // 定义最终需要返回的WorkBook对象 TemplateWorkBook workbook = null; - Env oldEnv = FRContext.getCurrentEnv(); + String envPath = "D:\\FineReport_8.0\\WebReport\\WEB-INF"; + SimpleWork.checkIn(envPath); WorkSheet newworksheet = new WorkSheet(); String change = "0"; try { // 读取模板保存为WorkBook对象 - workbook = TemplateWorkBookIO.readTemplateWorkBook(oldEnv, + workbook = TemplateWorkBookIO.readTemplateWorkBook( "\\doc\\Primary\\GroupReport\\Group.cpt"); // 读取请求中的参数判断是否需要切换行列显示,0表示不切换,1表示切换 if (reportletrequest.getParameter("change") != null) { @@ -59,6 +59,8 @@ public class ChangeRowAndCol extends Reportlet { } } catch (Exception e) { e.printStackTrace(); + } finally { + SimpleWork.checkOut(); } return workbook; } diff --git a/src/com/fr/demo/NewDateDemo.java b/src/com/fr/demo/NewDateDemo.java index 4fae5c3..b38d639 100644 --- a/src/com/fr/demo/NewDateDemo.java +++ b/src/com/fr/demo/NewDateDemo.java @@ -1,8 +1,6 @@ //��̬�޸����� package com.fr.demo; -import com.fr.base.Env; -import com.fr.base.FRContext; import com.fr.data.ArrayTableDataDemo; import com.fr.general.ModuleContext; import com.fr.io.TemplateWorkBookIO; @@ -16,11 +14,10 @@ import java.util.Map; public class NewDateDemo extends Reportlet { public TemplateWorkBook createReport(ReportletRequest reportletrequest) { TemplateWorkBook workbook = null; - Env oldEnv = FRContext.getCurrentEnv(); ModuleContext.startModule(EngineModule.class.getName()); try { // ����workbook���󣬽�ģ�屣��Ϊworkbook���󲢷��� - workbook = TemplateWorkBookIO.readTemplateWorkBook(oldEnv, "1.cpt"); + workbook = TemplateWorkBookIO.readTemplateWorkBook("1.cpt"); ArrayTableDataDemo a = new ArrayTableDataDemo(); // ���ö���ij������ݼ����� workbook.putTableData("ds2", a); // ��ģ�帳�µ����ݼ� } catch (Exception e) { diff --git a/src/com/fr/demo/ReadFromDatabase.java b/src/com/fr/demo/ReadFromDatabase.java index d983cad..be146dc 100644 --- a/src/com/fr/demo/ReadFromDatabase.java +++ b/src/com/fr/demo/ReadFromDatabase.java @@ -1,11 +1,11 @@ package com.fr.demo; import com.fr.base.FRContext; -import com.fr.dav.LocalEnv; import com.fr.main.TemplateWorkBook; import com.fr.main.impl.WorkBook; import com.fr.web.core.Reportlet; import com.fr.web.request.ReportletRequest; +import com.fr.workspace.simple.SimpleWork; import java.io.InputStream; import java.sql.Blob; @@ -20,7 +20,7 @@ public class ReadFromDatabase extends Reportlet { public TemplateWorkBook createReport(ReportletRequest reportletRequest) { // 定义报表运行环境,才能执行报表 String envpath = "D:\\FineReport_8.0\\WebReport\\WEB-INF"; - FRContext.setCurrentEnv(new LocalEnv(envpath)); + SimpleWork.checkIn(envpath); WorkBook workbook = new WorkBook(); String name = reportletRequest.getParameter("cptname").toString(); @@ -45,6 +45,8 @@ public class ReadFromDatabase extends Reportlet { } } catch (Exception e) { e.printStackTrace(); + } finally { + SimpleWork.checkOut(); } return workbook; } diff --git a/src/com/fr/demo/SaveReportToDatabase.java b/src/com/fr/demo/SaveReportToDatabase.java index 2bbcd66..0f04f30 100644 --- a/src/com/fr/demo/SaveReportToDatabase.java +++ b/src/com/fr/demo/SaveReportToDatabase.java @@ -1,7 +1,6 @@ package com.fr.demo; -import com.fr.base.FRContext; -import com.fr.dav.LocalEnv; +import com.fr.workspace.simple.SimpleWork; import java.io.File; import java.io.FileInputStream; @@ -19,7 +18,7 @@ public class SaveReportToDatabase { try { // 定义报表运行环境,才能执行报表 String envpath = "D:\\FineReport_8.0\\WebReport\\WEB-INF"; - FRContext.setCurrentEnv(new LocalEnv(envpath)); + SimpleWork.checkIn(envpath); // 连接数据库 String driver = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://112.124.109.239:3306/yourdatabase"; @@ -44,6 +43,8 @@ public class SaveReportToDatabase { conn.close(); } catch (Exception e) { e.printStackTrace(); + } finally { + SimpleWork.checkOut(); } } } \ No newline at end of file diff --git a/src/com/fr/demo/SimpleReportletDemo.java b/src/com/fr/demo/SimpleReportletDemo.java index 20df0fc..b051b1a 100644 --- a/src/com/fr/demo/SimpleReportletDemo.java +++ b/src/com/fr/demo/SimpleReportletDemo.java @@ -1,27 +1,29 @@ //程序网络报表 package com.fr.demo; -import com.fr.base.Env; -import com.fr.base.FRContext; import com.fr.io.TemplateWorkBookIO; import com.fr.main.TemplateWorkBook; import com.fr.web.core.Reportlet; import com.fr.web.request.ReportletRequest; +import com.fr.workspace.simple.SimpleWork; import java.util.Map; public class SimpleReportletDemo extends Reportlet { public TemplateWorkBook createReport(ReportletRequest reportletrequest) { + String envPath = "D:\\FineReport_8.0\\WebReport\\WEB-INF"; + SimpleWork.checkIn(envPath); // 新建一个WorkBook对象,用于保存最终返回的报表 - Env oldEnv = FRContext.getCurrentEnv(); TemplateWorkBook WorkBook = null; try { // 读取模板,将模板保存为workbook对象并返回 - WorkBook = TemplateWorkBookIO.readTemplateWorkBook(oldEnv, + WorkBook = TemplateWorkBookIO.readTemplateWorkBook( "\\doc\\Primary\\Parameter\\Parameter.cpt"); } catch (Exception e) { e.getStackTrace(); + } finally { + SimpleWork.checkOut(); } return WorkBook; } diff --git a/src/com/fr/demo/URLParameterDemo.java b/src/com/fr/demo/URLParameterDemo.java index 5d71da2..c4dac4f 100644 --- a/src/com/fr/demo/URLParameterDemo.java +++ b/src/com/fr/demo/URLParameterDemo.java @@ -1,15 +1,14 @@ // 程序网络报表中获取request中的值 package com.fr.demo; -import com.fr.base.FRContext; import com.fr.base.Parameter; -import com.fr.dav.LocalEnv; import com.fr.general.ModuleContext; import com.fr.io.TemplateWorkBookIO; import com.fr.main.TemplateWorkBook; import com.fr.report.module.EngineModule; import com.fr.web.core.Reportlet; import com.fr.web.request.ReportletRequest; +import com.fr.workspace.simple.SimpleWork; import java.util.Map; @@ -18,14 +17,13 @@ public class URLParameterDemo extends Reportlet { public TemplateWorkBook createReport(ReportletRequest reportletRequest) { String envPath = "D:\\FineReport_8.0\\WebReport\\WEB-INF"; - FRContext.setCurrentEnv(new LocalEnv(envPath)); + SimpleWork.checkIn(envPath); ModuleContext.startModule(EngineModule.class.getName()); // 获取外部传来的参数 TemplateWorkBook wbTpl = null; String countryValue = reportletRequest.getParameter("地区").toString(); try { - wbTpl = TemplateWorkBookIO.readTemplateWorkBook( - FRContext.getCurrentEnv(), "\\doc\\Primary\\Parameter\\Parameter.cpt"); + wbTpl = TemplateWorkBookIO.readTemplateWorkBook("\\doc\\Primary\\Parameter\\Parameter.cpt"); // 提取报表参数组,由于原模板只有country一个参数,因此直接取index为0的参数,并将外部传入的值赋给该参数 Parameter[] ps = wbTpl.getParameters(); ps[0].setValue(countryValue); @@ -34,7 +32,8 @@ public class URLParameterDemo extends Reportlet { wbTpl.getReportParameterAttr().setParameterUI(null); } catch (Exception e) { e.printStackTrace(); - return null; + } finally { + SimpleWork.checkOut(); } return wbTpl; } diff --git a/src/com/fr/function/ReportCheck.java b/src/com/fr/function/ReportCheck.java index ee0948b..5ea8448 100644 --- a/src/com/fr/function/ReportCheck.java +++ b/src/com/fr/function/ReportCheck.java @@ -1,8 +1,6 @@ // 自定义函数实现表间校验 package com.fr.function; -import com.fr.base.Env; -import com.fr.base.FRContext; import com.fr.base.ResultFormula; import com.fr.io.TemplateWorkBookIO; import com.fr.json.JSONArray; @@ -28,12 +26,11 @@ public class ReportCheck extends AbstractFunction { // 定义返回的值 Object returnValue = null; // 定义报表运行环境,才能运行读取的报表 - Env oldEnv = FRContext.getCurrentEnv(); try { ResultWorkBook rworkbook = null; // 读取模板 WorkBook workbook = (WorkBook) TemplateWorkBookIO - .readTemplateWorkBook(oldEnv, cptname); + .readTemplateWorkBook(cptname); // 获取需要传递给报表的参数名与参数值,格式如[{"name":para1name,"value":para1value},{"name":para2name,"value":para2value},......] JSONArray parasArray = new JSONArray(args[1].toString()); // 需要判断是否是5秒内执行过的 diff --git a/src/com/fr/io/ExcuteDemo.java b/src/com/fr/io/ExcuteDemo.java index 0d382dd..6861181 100644 --- a/src/com/fr/io/ExcuteDemo.java +++ b/src/com/fr/io/ExcuteDemo.java @@ -1,13 +1,14 @@ package com.fr.io; -import com.fr.base.FRContext; -import com.fr.dav.LocalEnv; +import com.fr.base.operator.common.CommonOperator; +import com.fr.env.operator.CommonOperatorImpl; import com.fr.general.ModuleContext; import com.fr.io.exporter.ExcelExporter; import com.fr.main.TemplateWorkBook; import com.fr.main.workbook.ResultWorkBook; import com.fr.report.module.EngineModule; import com.fr.stable.WriteActor; +import com.fr.workspace.simple.SimpleWork; import java.io.File; import java.io.FileOutputStream; @@ -18,10 +19,12 @@ public class ExcuteDemo { try { // 首先需要定义执行所在的环境,这样才能正确读取数据库信息 String envPath = "D:\\FineReport_8.0\\WebReport\\WEB-INF"; - FRContext.setCurrentEnv(new LocalEnv(envPath)); + + SimpleWork.checkIn(envPath); + ModuleContext.startModule(EngineModule.class.getName()); // 读取模板 - TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), "\\doc\\Primary\\Parameter\\Parameter.cpt"); + TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook("\\doc\\Primary\\Parameter\\Parameter.cpt"); /* * 生成参数map,注入参数与对应的值,用于执行报表 该模板中只有一个参数地区,给其赋值华北 * 若参数在发送请求时传过来,可以通过req.getParameter(name)获得 @@ -38,6 +41,8 @@ public class ExcuteDemo { excelExporter.export(outputStream, result); } catch (Exception e) { e.printStackTrace(); + } finally { + SimpleWork.checkOut(); } } } \ No newline at end of file diff --git a/src/com/fr/io/ExportApi.java b/src/com/fr/io/ExportApi.java index 01f352f..c2a44b4 100644 --- a/src/com/fr/io/ExportApi.java +++ b/src/com/fr/io/ExportApi.java @@ -1,8 +1,6 @@ package com.fr.io; -import com.fr.base.FRContext; import com.fr.base.Parameter; -import com.fr.dav.LocalEnv; import com.fr.general.ModuleContext; import com.fr.io.exporter.CSVExporter; import com.fr.io.exporter.EmbeddedTableDataExporter; @@ -17,6 +15,7 @@ import com.fr.main.impl.WorkBook; import com.fr.main.workbook.ResultWorkBook; import com.fr.report.module.EngineModule; import com.fr.stable.WriteActor; +import com.fr.workspace.simple.SimpleWork; import java.io.File; import java.io.FileOutputStream; @@ -26,14 +25,13 @@ public class ExportApi { public static void main(String[] args) { // 定义报表运行环境,才能执行报表 String envpath = "D:\\FineReport_8.0\\WebReport\\WEB-INF"; - FRContext.setCurrentEnv(new LocalEnv(envpath)); + SimpleWork.checkIn(envpath); ModuleContext.startModule(EngineModule.class.getName()); ResultWorkBook rworkbook = null; try { // 未执行模板工作薄 WorkBook workbook = (WorkBook) TemplateWorkBookIO - .readTemplateWorkBook(FRContext.getCurrentEnv(), - "\\doc\\Primary\\Parameter\\Parameter.cpt"); + .readTemplateWorkBook("\\doc\\Primary\\Parameter\\Parameter.cpt"); // 获取报表参数并设置值,导出内置数据集时数据集会根据参数值查询出结果从而转为内置数据集 Parameter[] parameters = workbook.getParameters(); parameters[0].setValue("华东"); @@ -88,6 +86,8 @@ public class ExportApi { ModuleContext.stopModules(); } catch (Exception e) { e.printStackTrace(); + } finally { + SimpleWork.checkOut(); } } } \ No newline at end of file diff --git a/src/com/fr/io/ExportBatch.java b/src/com/fr/io/ExportBatch.java index 99f9dcc..31d27f2 100644 --- a/src/com/fr/io/ExportBatch.java +++ b/src/com/fr/io/ExportBatch.java @@ -1,7 +1,5 @@ package com.fr.io; -import com.fr.base.FRContext; -import com.fr.dav.LocalEnv; import com.fr.general.ModuleContext; import com.fr.io.exporter.ExcelExporter; import com.fr.main.TemplateWorkBook; @@ -9,6 +7,7 @@ import com.fr.main.workbook.ResultWorkBook; import com.fr.report.module.EngineModule; import com.fr.stable.StableUtils; import com.fr.stable.WriteActor; +import com.fr.workspace.simple.SimpleWork; import java.io.BufferedReader; import java.io.File; @@ -24,10 +23,10 @@ public class ExportBatch { try { // ���屨�����л���,����ִ�б��� String envpath = "D:\\FineReport_7.1\\WebReport\\WEB-INF"; - FRContext.setCurrentEnv(new LocalEnv(envpath)); + SimpleWork.checkIn(envpath); ModuleContext.startModule(EngineModule.class.getName()); // ��ȡ�����µ�ģ���ļ� - TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), + TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook( "doc\\Primary\\DetailReport\\Details.cpt"); // ��ȡ���ڱ���IJ���ֵ��txt�ļ� File parafile = new File(envpath + "\\para.txt"); @@ -65,6 +64,8 @@ public class ExportBatch { ModuleContext.stopModules(); } catch (Exception e) { e.printStackTrace(); + } finally { + SimpleWork.checkOut(); } } } \ No newline at end of file diff --git a/src/com/fr/io/ExportExcel.java b/src/com/fr/io/ExportExcel.java index ffd8466..a7a1d83 100644 --- a/src/com/fr/io/ExportExcel.java +++ b/src/com/fr/io/ExportExcel.java @@ -1,8 +1,6 @@ package com.fr.io; -import com.fr.base.FRContext; import com.fr.base.Parameter; -import com.fr.dav.LocalEnv; import com.fr.general.ModuleContext; import com.fr.io.exporter.ExcelExporter; import com.fr.io.exporter.LargeDataPageExcelExporter; @@ -16,6 +14,7 @@ import com.fr.main.workbook.ResultWorkBook; import com.fr.report.core.ReportUtils; import com.fr.report.module.EngineModule; import com.fr.stable.WriteActor; +import com.fr.workspace.simple.SimpleWork; import java.io.File; import java.io.FileOutputStream; @@ -25,14 +24,13 @@ public class ExportExcel { public static void main(String[] args) { // 定义报表运行环境,才能执行报表 String envpath = "D:\\FineReport_8.0\\WebReport\\WEB-INF"; - FRContext.setCurrentEnv(new LocalEnv(envpath)); + SimpleWork.checkIn(envpath); ModuleContext.startModule(EngineModule.class.getName()); ResultWorkBook rworkbook = null; try { // 未执行模板工作薄 WorkBook workbook = (WorkBook) TemplateWorkBookIO - .readTemplateWorkBook(FRContext.getCurrentEnv(), - "\\doc\\Primary\\Parameter\\Parameter.cpt"); + .readTemplateWorkBook("\\doc\\Primary\\Parameter\\Parameter.cpt"); // 获取报表参数并设置值,导出内置数据集时数据集会根据参数值查询出结果从而转为内置数据集 Parameter[] parameters = workbook.getParameters(); parameters[0].setValue("华东"); diff --git a/src/com/fr/io/ExportReports.java b/src/com/fr/io/ExportReports.java index 9e01ce9..96a20cc 100644 --- a/src/com/fr/io/ExportReports.java +++ b/src/com/fr/io/ExportReports.java @@ -1,8 +1,6 @@ package com.fr.io; -import com.fr.base.FRContext; import com.fr.base.Parameter; -import com.fr.dav.LocalEnv; import com.fr.general.ModuleContext; import com.fr.io.exporter.PageExcelExporter; import com.fr.main.TemplateWorkBook; @@ -11,6 +9,7 @@ import com.fr.report.core.ReportUtils; import com.fr.report.module.EngineModule; import com.fr.report.report.PageReport; import com.fr.stable.PageActor; +import com.fr.workspace.simple.SimpleWork; import java.io.File; import java.io.FileOutputStream; @@ -20,12 +19,12 @@ public class ExportReports { public static void main(String[] args) { // ���屨�����л���,����ִ�б��� String envpath = "D:\\FineReport\\develop\\code\\build\\package\\WebReport\\WEB-INF"; - FRContext.setCurrentEnv(new LocalEnv(envpath)); + SimpleWork.checkIn(envpath); ModuleContext.startModule(EngineModule.class.getName()); // ���г����һЩ��Ҫ��ʼ�� try { // δִ��ģ�幤���� - TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), + TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook( "Gettingstarted.cpt"); // ����ֵΪChina�������������������rworkbook Parameter[] parameters = workbook.getParameters(); @@ -52,6 +51,8 @@ public class ExportReports { } catch (Exception e) { e.printStackTrace(); + } finally { + SimpleWork.checkOut(); } } } \ No newline at end of file diff --git a/src/com/fr/io/JavaPrint.java b/src/com/fr/io/JavaPrint.java index f0ab95b..7a7cad8 100644 --- a/src/com/fr/io/JavaPrint.java +++ b/src/com/fr/io/JavaPrint.java @@ -1,10 +1,9 @@ package com.fr.io; -import com.fr.base.FRContext; import com.fr.base.Parameter; -import com.fr.dav.LocalEnv; import com.fr.main.TemplateWorkBook; import com.fr.print.PrintUtils; +import com.fr.workspace.simple.SimpleWork; import java.util.HashMap; @@ -13,9 +12,9 @@ public class JavaPrint { public static void main(String[] args) { // 定义报表运行环境,才能执行报表 String envPath = "D:\\FineReport\\develop\\code\\build\\package\\WebReport\\WEB-INF"; - FRContext.setCurrentEnv(new LocalEnv(envPath)); + SimpleWork.checkIn(envPath); try { - TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), "GettingStarted.cpt"); + TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook("GettingStarted.cpt"); // 参数传值 Parameter[] parameters = workbook.getParameters(); HashMap paraMap = new HashMap(); @@ -30,6 +29,8 @@ public class JavaPrint { } } catch (Exception e) { e.printStackTrace(); + } finally { + SimpleWork.checkOut(); } } } \ No newline at end of file diff --git a/src/com/fr/io/SetParameterWindow.java b/src/com/fr/io/SetParameterWindow.java index ce9c908..9792465 100644 --- a/src/com/fr/io/SetParameterWindow.java +++ b/src/com/fr/io/SetParameterWindow.java @@ -1,15 +1,14 @@ // �����������API package com.fr.io; -import com.fr.base.FRContext; import com.fr.base.background.ColorBackground; -import com.fr.dav.LocalEnv; import com.fr.general.Background; import com.fr.general.ModuleContext; import com.fr.io.exporter.EmbeddedTableDataExporter; import com.fr.main.impl.WorkBook; import com.fr.main.parameter.ReportParameterAttr; import com.fr.report.module.EngineModule; +import com.fr.workspace.simple.SimpleWork; import java.awt.Color; import java.io.File; @@ -20,11 +19,11 @@ public class SetParameterWindow { try { // ���屨�����л���,����ִ�б��� String envPath = "D:\\FineReport\\develop\\code\\build\\package\\WebReport\\WEB-INF"; - FRContext.setCurrentEnv(new LocalEnv(envPath)); + SimpleWork.checkIn(envPath); ModuleContext.startModule(EngineModule.class.getName()); // ��ȡģ�屣��ΪWorkBook���� WorkBook workbook = (WorkBook) TemplateWorkBookIO - .readTemplateWorkBook(FRContext.getCurrentEnv(), + .readTemplateWorkBook( "\\doc\\Primary\\Parameter\\Parameter.cpt"); // ��ȡWorkBook�������IJ�������ReportParameterAttr ReportParameterAttr paraAttr = workbook.getReportParameterAttr(); @@ -52,6 +51,8 @@ public class SetParameterWindow { templateExporter.export(outputStream, workbook); } catch (Exception e) { e.printStackTrace(); + } finally { + SimpleWork.checkOut(); } } } \ No newline at end of file diff --git a/src/com/fr/io/SimpleDemo.java b/src/com/fr/io/SimpleDemo.java index 5631d89..c966cde 100644 --- a/src/com/fr/io/SimpleDemo.java +++ b/src/com/fr/io/SimpleDemo.java @@ -1,15 +1,14 @@ //��ȡ�޸ı��� package com.fr.io; -import com.fr.base.FRContext; import com.fr.base.Style; -import com.fr.dav.LocalEnv; import com.fr.general.FRFont; import com.fr.general.ModuleContext; import com.fr.main.impl.WorkBook; import com.fr.report.cell.CellElement; import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.module.EngineModule; +import com.fr.workspace.simple.SimpleWork; import java.awt.Color; import java.io.File; @@ -19,12 +18,12 @@ public class SimpleDemo { public static void main(String[] args) { // ���屨�����л���,����ִ�б��� String envPath = "D:\\FineReport_7.0\\WebReport\\WEB-INF"; - FRContext.setCurrentEnv(new LocalEnv(envPath)); + SimpleWork.checkIn(envPath); ModuleContext.startModule(EngineModule.class.getName()); try { // ��ȡģ�� WorkBook workbook = (WorkBook) TemplateWorkBookIO - .readTemplateWorkBook(FRContext.getCurrentEnv(), + .readTemplateWorkBook( "\\doc\\Primary\\Parameter\\Parameter.cpt"); // ���WorkBook�е�WorkSheet�������޸�A1��Ԫ���ǰ��ɫΪ��ɫ @@ -44,6 +43,8 @@ public class SimpleDemo { ((WorkBook) workbook).export(outputStream); } catch (Exception e) { e.printStackTrace(); + } finally { + SimpleWork.checkOut(); } } } \ No newline at end of file