sunyj 8 лет назад
Родитель
Сommit
5032ac858d

+ 6 - 5
crystal-replace-view/src/main/java/com/uas/report/crystal/CrystalReplaceView.java

@@ -96,6 +96,7 @@ public class CrystalReplaceView {
         FileUtils.initDir(destDir);
         ReportClientDocument client = new ReportClientDocument();
         try {
+            // 打开报表
             client.setReportAppServer(ReportClientDocument.inprocConnectionString);
             client.open(reportFile.getAbsolutePath(), OpenReportOptions._retrieveNoReportDefinition);
             DatabaseController databaseController = client.getDatabaseController();
@@ -104,10 +105,15 @@ public class CrystalReplaceView {
             for (int j = 0; j < tables.size(); j++) {
                 ITable iTable = tables.get(j);
                 logger.info("replacing table: name=" + iTable.getName() + ", alias=" + iTable.getAlias());
+                // 修改视图名称
                 databaseController.modifyTableAlias(iTable, prefix + iTable.getAlias());
             }
 
             client.saveAs(reportFile.getName(), destDir.getAbsolutePath(), ReportSaveAsOptions._overwriteExisting);
+            // 转换成功之后,将文件移至其他路径下
+            FileUtils.initDir(successDir);
+            FileUtils.move(reportFile, new File(successDir, reportFile.getName()));
+            System.out.println();
         } catch (ReportSDKException e) {
             logger.error("报表读取失败", e);
         } catch (IOException e) {
@@ -119,10 +125,5 @@ public class CrystalReplaceView {
                 throw new IllegalStateException("报表关闭失败:", e);
             }
         }
-
-        // 转换成功之后,将文件移至其他路径下
-        FileUtils.initDir(successDir);
-        FileUtils.move(reportFile, new File(successDir, reportFile.getName()));
-        System.out.println();
     }
 }