Mirth:如何从文件读取器通道获取源文件目录

发布于 2024-08-08 13:21:50 字数 106 浏览 2 评论 0原文

我有一个文件读取器通道拾取 xml 文档。默认情况下,文件读取器通道会填充通道映射中的“originalFilename”,该通道仅提供文件名,而不是完整路径。有没有办法获得完整路径,而无需硬编码?

I have a file reader channel picking up an xml document. By default, a file reader channel populates the 'originalFilename' in the channel map, which ony gives me the name of the file, not the full path. Is there any way to get the full path, withouth having to hard code something?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

世态炎凉 2024-08-15 13:21:50

您可以像这样获取任何源阅读器属性:

var sourceFolder = Packages.com.mirth.connect.server.controllers.ChannelController.getInstance().getDeployedChannelById(channelId).getSourceConnector().getProperties().getProperty('host');

我将其放在 Mirth 论坛中,并列出了您可以访问的其他属性
http://www.mirthcorp.com/community/forums/showthread.php ?t=2210

You can get any of the Source reader properties like this:

var sourceFolder = Packages.com.mirth.connect.server.controllers.ChannelController.getInstance().getDeployedChannelById(channelId).getSourceConnector().getProperties().getProperty('host');

I put it up in the Mirth forums with a list of the other properties you can access
http://www.mirthcorp.com/community/forums/showthread.php?t=2210

忆梦 2024-08-15 13:21:50

您可以将该目录放入通道部署脚本中:

globalChannelMap.put("pickupDirectory", "/Mirth/inbox");

然后在源连接器

${pickupDirectory}

和另一个通道脚本中使用该映射:

function getFileLastModified(fileName) {
   var directory = globalChannelMap.get("pickupDirectory").toString();
   var fullPath = directory + "/" + fileName;
   var file = Packages.java.io.File(fullPath);
   var formatter = new Packages.java.text.SimpleDateFormat("yyyyMMddhhmmss"); 
   formatter.setTimeZone(Packages.java.util.TimeZone.getTimeZone("UTC")); 
   return formatter.format(file.lastModified()); 
};

You could put the directory in a channel deploy script:

globalChannelMap.put("pickupDirectory", "/Mirth/inbox");

then use that map in both your source connector:

${pickupDirectory}

and in another channel script:

function getFileLastModified(fileName) {
   var directory = globalChannelMap.get("pickupDirectory").toString();
   var fullPath = directory + "/" + fileName;
   var file = Packages.java.io.File(fullPath);
   var formatter = new Packages.java.text.SimpleDateFormat("yyyyMMddhhmmss"); 
   formatter.setTimeZone(Packages.java.util.TimeZone.getTimeZone("UTC")); 
   return formatter.format(file.lastModified()); 
};
征﹌骨岁月お 2024-08-15 13:21:50

不幸的是,没有用于检索文件的完整路径的变量或方法。当然,您可能已经知道路径,因为您必须在“目录”字段中提供它。我尝试使用预处理器将路径存储在通道变量中,但目录字段无法引用变量。因此,您必须在需要的地方对完整路径进行硬编码。

Unfortunately, there is no variable or method for retrieving the file's full path. Of course, you probably already know the path, since you would have had to provide it in the Directory field. I experimented with using the preprocessor to store the path in a channel variable, but the Directory field is unable to reference variables. Thus, you're stuck having to hard code the full path everywhere you need it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文