【问题标题】:How to compress files in Siebel?如何在 Siebel 中压缩文件?
【发布时间】:2015-12-19 17:07:23
【问题描述】:

我需要从我们的 Siebel 服务器读取几个文本文件并将它们附加到电子邮件中。但是,其中一些文件可能太大而无法邮寄。压缩它们肯定会解决问题,因为它们是纯文本文件。

这引出了我的问题:如何在 Siebel 中压缩文件? Siebel 7.8 中是否有任何内置的业务服务/工作流程/提供压缩功能的任何东西?我不关心文件格式:zip、tar.gz、7z...,只要我可以在没有 Siebel 的情况下提取文件(请不要使用 .SAF 格式)。

我们的存储库中有 1.041 个普通业务服务。有人可能会想,这么大的数字,应该有一个来压缩文件吧?我希望如此……不过,我还没有找到它。

我知道我可以编写一个非常简单的 Java 类来执行压缩,然后作为 Java BS 从 Siebel 使用它...但如果有替代方案,我宁愿避免使用此选项。

【问题讨论】:

    标签: compression siebel


    【解决方案1】:

    我还没有找到任何内置的业务服务来压缩文件。但是,我已经设法构建了自己的,使用Clib.system 调用Solaris 命令targzip。这很简单,你只需要把它包装在一个业务服务中:

    // Input:
    // - files: array of files to compress (each element should contain the full path)
    // - target: full path to the file to be created, without the .tar.gz extension
    
    function compress (files, target)
    {
      // Build the tar file. We add the files one each time because passing long command lines
      // to Clib.system crashes the server
      for (var i = 0; i < files.length; i++) {
        var mode = (i == 0 ? "c" : "r");
        var command = "tar -" + mode + "f " + target + ".tar " + files[i].replace(/\s/g, "?");
        if (Clib.system(command) != 0) {
          throw "Error creating tar file";
        }
      }
    
      // Build the tar.gz file 
      var command = "gzip -c " + target + ".tar > " + target + ".tar.gz";
      if (Clib.system(command) != 0) {
        throw "Error creating tar.gz file";
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2021-09-12
      • 2011-10-30
      • 1970-01-01
      • 2011-11-15
      • 1970-01-01
      • 2019-04-06
      • 2016-07-17
      • 2022-10-25
      • 1970-01-01
      相关资源
      最近更新 更多