|
|
@@ -2,15 +2,13 @@ package com.uas.report.crystal;
|
|
|
|
|
|
import com.crystaldecisions.sdk.occa.report.application.OpenReportOptions;
|
|
|
import com.crystaldecisions.sdk.occa.report.application.ReportClientDocument;
|
|
|
+import com.crystaldecisions.sdk.occa.report.application.ReportSaveAsOptions;
|
|
|
import com.crystaldecisions.sdk.occa.report.data.*;
|
|
|
import com.crystaldecisions.sdk.occa.report.lib.ReportSDKException;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
-import java.io.ObjectOutputStream;
|
|
|
|
|
|
/**
|
|
|
* @author sunyj
|
|
|
@@ -24,21 +22,52 @@ public class Application {
|
|
|
try {
|
|
|
String reportName = "bjd_price.rpt";
|
|
|
client.setReportAppServer(ReportClientDocument.inprocConnectionString);
|
|
|
- client.open(reportName, OpenReportOptions._openAsReadOnly);
|
|
|
- logger.info(client.getStatusVariables().toString());
|
|
|
- IDatabase database = client.getDatabase();
|
|
|
- Connections connections = database.getConnections();
|
|
|
- for (IConnection iConnection : connections) {
|
|
|
- Tables tables = iConnection.getTables();
|
|
|
- for (ITable iTable : tables) {
|
|
|
- logger.info(iTable.getName());
|
|
|
- iTable.setName("1_QUOTATION_VIEW");
|
|
|
- }
|
|
|
+ client.open(reportName, OpenReportOptions._retrieveNoReportDefinition);
|
|
|
+// IDatabase database = client.getDatabase();
|
|
|
+// Connections connections = database.getConnections();
|
|
|
+// for(int i =0 ;i < connections.size();i++){
|
|
|
+// IConnection iConnection = connections.get(i);
|
|
|
+// IConnection newConnection= (IConnection) iConnection.clone(false);
|
|
|
+// Tables tables = (Tables) newConnection.getTables().clone(true);
|
|
|
+// for(int j = 0;j<tables.size();j++){
|
|
|
+// ITable iTable = (ITable) tables.get(j).clone(true);
|
|
|
+// logger.info(iTable.getName());
|
|
|
+// iTable.setName("1_QUOTATION_VIEW");
|
|
|
+// logger.info(iTable.getName());
|
|
|
+// tables.remove(j);
|
|
|
+// tables.add(j, iTable);
|
|
|
+// }
|
|
|
+// newConnection.setTables(tables);
|
|
|
+// connections.removeConnection(iConnection);
|
|
|
+// connections.add(i, newConnection);
|
|
|
+// }
|
|
|
+ IDataDefinition dataDefinition = client.getDataDefinition();
|
|
|
+ Fields<IField> resultFields = dataDefinition.getResultFields();
|
|
|
+ client.getDataDefinition().getResultFields().remove(0);
|
|
|
+ System.out.println(resultFields.size());
|
|
|
+ Tables tables = (Tables) client.getDatabase().getTables().clone(true);
|
|
|
+ for (int j = 0; j < tables.size(); j++) {
|
|
|
+ ITable iTable = (ITable) tables.get(j).clone(true);
|
|
|
+ logger.info(iTable.getName());
|
|
|
+ iTable.setName("1_QUOTATION_VIEW");
|
|
|
+ logger.info(iTable.getName());
|
|
|
+ client.getDatabase().getTables().remove(j);
|
|
|
+ client.getDatabase().getTables().add(j, iTable);
|
|
|
}
|
|
|
- ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(new File(reportName)));
|
|
|
- client.writeExternal(outputStream);
|
|
|
- outputStream.flush();
|
|
|
- outputStream.close();
|
|
|
+// for (IConnection iConnection : connections) {
|
|
|
+// Tables tables = iConnection.getTables();
|
|
|
+// for (ITable iTable : tables) {
|
|
|
+// logger.info(iTable.getName());
|
|
|
+// iTable.setName("1_QUOTATION_VIEW");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// database.setConnections(null);
|
|
|
+ System.out.println(client.isReadOnly());
|
|
|
+ client.refreshReportDocument();
|
|
|
+// client.save();
|
|
|
+ client.flushRequests();
|
|
|
+ client.saveAs(reportName, "C:\\sunyj\\project\\report-parent\\crystal-replace-view",
|
|
|
+ ReportSaveAsOptions._overwriteExisting);
|
|
|
} catch (ReportSDKException e) {
|
|
|
logger.error("报表读取失败", e);
|
|
|
} catch (IOException e) {
|