前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >如何实时监控是否有待发送的文件?

如何实时监控是否有待发送的文件?

原创
作者头像
知行软件EDI
发布2022-11-25 17:13:57
4250
发布2022-11-25 17:13:57
举报
文章被收录于专栏:EDI技术知识EDI技术知识

客户在使用知行EDI系统发送文件时,有时候交易伙伴对文件的时效性要求非常严格,如果没有及时发出报文,有可能会影响供应商评级扣分,甚至被交易伙伴开具罚单。

因此客户常常会有这样的担心:端口下是否有堆积的文件没有及时发送,该如何监控呢?

手动监控

如果您安装了知行之桥.net版本,可以将如下代码复制到一个.rst文件中,例如getMessageCopunt.rst,放置在知行之桥安装路径/www文件夹下

<arc:script xmlns:arc="http://www.arcesb.com/ns/arcscript/2">

<arc:info title="GetMessageCount" description="Download files for this port.">

<input  name="Workspace" desc="The id of the workspace."/>

<input  name="ConnectorId" desc="The id of the conector."/>

<output name="Workspace" desc="The message id of the file." />

<output name="ConnectorId" desc="The subfolder of the file." />

<output name="Count" desc="The name of the file." />

</arc:info>

<table id="tbMessageCount" class="table table-hover table-bordered table-striped table-condensed dataTable no-footer">

<thead>

<tr>

<th>Workspace</th>

<th>Connector ID</th>

<th>Unsent Files</th>

</tr>

</thead>

<tbody>

<rsb:set attr="port.workspace" value="[Workspace | def | trim]" />

<rsb:set attr="port.connectorId" value="[ConnectorId | def | trim]" />

<rsb:set attr="global.datadir" value="[AppDataDirectory()]" />

<rsb:if exp="![global.datadir | direxists]">

<rsb:throw code="-1"/>

</rsb:if>

<!--Default workspace-->

<rsb:set attr="fileIn.path" value="[global.datadir | pathcombine('data')]" />

<rsb:set attr="fileIn.fileordir" value="dirs" />

<rsb:call op="fileListDir" in="fileIn" out="fileOut">

<rsb:set attr="fileIn2.path" value="[fileOut.file:fullname | pathcombine('Send')]" />

<rsb:if exp="[fileIn2.path | direxists]">

<rsb:set attr="fileIn2.recurse" value="true" />

<rsb:set attr="fileIn2.fileordir" value="files" />

<rsb:set attr="tmp.count" value="0" />

<rsb:call op="fileListDir" in="fileIn2">

<rsb:set attr="tmp.count" value="[_index]" />

</rsb:call>

<rsb:set attr="output.Workspace" value="DEFAULT" />

<rsb:set attr="output.ConnectorId" value="[fileOut.file:name]" />

<rsb:set attr="output.Count" value="[tmp.count]" />

<rsb:push item="output" />

<tr>

<td>[output.Workspace]</td>

<td>[output.ConnectorId]</td>

<td>[output.Count]</td>

</tr>

</rsb:if>

</rsb:call>

<!--Other workspaces-->

<rsb:set attr="fileIn3.path" value="[global.datadir | pathcombine('workspaces')]" />

<rsb:set attr="fileIn3.fileordir" value="dirs" />

<rsb:if exp="[fileIn3.path | direxists]">

<rsb:call op="fileListDir" in="fileIn3" out="fileOut2">

<rsb:set attr="fileIn4.path" value="[fileOut2.file:fullname]" />

<rsb:set attr="fileIn4.fileordir" value="dirs" />

<rsb:call op="fileListDir" in="fileIn4" out="fileOut3">

<rsb:set attr="fileIn5.path" value="[fileOut3.file:fullname | pathcombine('Send')]" />

<rsb:if exp="[fileIn5.path | direxists]">

<rsb:set attr="fileIn5.recurse" value="true" />

<rsb:set attr="fileIn5.fileordir" value="files" />

<rsb:set attr="tmp.count" value="0" />

<rsb:call op="fileListDir" in="fileIn5">

<rsb:set attr="tmp.count" value="[_index]" />

</rsb:call>

<rsb:set attr="output1.Workspace" value="[fileOut2.file:name]" />

<rsb:set attr="output1.ConnectorId" value="[fileOut3.file:name]" />

<rsb:set attr="output1.Count" value="[tmp.count]" />

<rsb:push item="output1" />

<tr>

<td>[output1.Workspace]</td>

<td>[output1.ConnectorId]</td>

<td>[output1.Count]</td>

</tr>

</rsb:if>

</rsb:call>

</rsb:call>

</rsb:if>

</arc:script>

</tbody>

</table>

此时,可以在浏览器直接访问地址:http://xxx.xxx.xxx.xxx:port/getMessageCount.rst即可查看知行EDI平台上所有工作区下的各端口待发送的文件数量,所涉及的属性包含Workspace(工作区名称)、Connector ID(端口名称)和Unsent Files(待发送文件数量)。

edi
edi

如果您安装了知行之桥Java版本,可将getMessageCount.rst放在arc.war中,重启Arc服务,即可在浏览器访问http://xxx.xxx.xxx.xxx:port/getMessageCount.rst。

具体操作步骤:进入知行之桥安装路径\webapp目录下,将arc.war重命名为arc.war.zip,解压缩后将getMessageCount.rst放进去(如下图),再将文件打包为arc.war。

edi
edi
edi
edi
自动监控

如果您不想每次在浏览器手动执行URL查看待发送文件数量,我们可以在知行EDI平台设置自动监控。首先,建立一个Script端口,将这段代码复制到端口的设置页面。

<!-- Time limits (Minutes) -->

<rsb:set attr="file.time" value="30" />

<!-- Files amount limits-->

<rsb:set attr="file.amount" value="1" />

<!-- Email To -->

<rsb:set attr="file.email:to" value="xxx@xx.cn" />

<!-- Email Subject -->

<rsb:set attr="file.email:subject" value="Warning: Unsent file exceeds limit!" />

<rsb:call op="getMessageCount.rst" in="file"/>

其中,file.time(文件停留在Send目录下的时间大于这个值,单位为minutes),file.amount(当Send目录下的文件数量大于这个值)和file.email:to(接收通知的邮箱)都是可以根据实际业务情况设置的。

edi
edi

同时将如下代码复制到一个命名为getMessageCount.rst的文件中,放置在知行之桥安装路径下。

<arc:script xmlns:arc="http://www.arcesb.com/ns/arcscript/2">

<arc:info title="GetMessageCount" description="Download files for this port.">

<input  name="Workspace" desc="The id of the workspace."/>

<input  name="ConnectorId" desc="The id of the conector."/>

<input  name="Time" desc="File residence time."/>

<input  name="Amount" desc="File amount."/>

<input  name="email:*" desc="Email information"/>

<output name="Workspace" desc="The message id of the file." />

<output name="ConnectorId" desc="The subfolder of the file." />

<output name="Count" desc="The name of the file." />

</arc:info>

<arc:set attr="file.warning" value="false" />

<arc:set attr="file.time" value="9" />

<arc:set attr="file.amount" value="9" />

<arc:check value="[Time | def | trim]">

<arc:set attr="file.time" value="[Time | add(0)]" />

</arc:check>

<arc:check value="[Amount | def | trim]">

<arc:set attr="file.amount" value="[Amount | add(0)]" />

</arc:check>

<arc:check value="[email:subject | def | trim]">

<arc:set attr="email.subject" value="[email:subject | trim]" />

</arc:check>

<arc:check value="[email:to | def | trim]">

<arc:set attr="email.to" value="[email:to | trim]" />

</arc:check>

<arc:set attr="email.html">

<table id="tbMessageCount" border="1" style="border-collapse: collapse;" cellpadding="5">

<colgroup>

<col width="*">

<col width="*">

<col width="140px">

</colgroup>

<thead>

<tr>

<th>Workspace</th>

<th>Connector ID</th>

<th>Unsent Files</th>

</tr>

</thead>

<tbody>

</arc:set>

<arc:set attr="port.workspace" value="[Workspace | def | trim]" />

<arc:set attr="port.connectorId" value="[ConnectorId | def | trim]" />

<!-- <arc:call op="portGetSettings" out="settings"> -->

<arc:set attr="global.datadir" value="[AppDataDirectory()]" />

<!-- </arc:call> -->

<arc:if exp="![global.datadir | direxists]">

<arc:throw code="-1"/>

</arc:if>

<!--Default workspace-->

<arc:set attr="fileIn.path" value="[global.datadir | pathcombine('data')]" />

<arc:set attr="fileIn.fileordir" value="dirs" />

<arc:call op="fileListDir" in="fileIn" out="fileOut">

<arc:set attr="fileIn2.path" value="[fileOut.file:fullname | pathcombine('Send')]" />

<arc:if exp="[fileIn2.path | direxists]">

<arc:set attr="fileIn2.recurse" value="true" />

<arc:set attr="fileIn2.fileordir" value="files" />

<arc:set attr="tmp.count" value="0" />

<arc:set attr="output.Workspace" value="DEFAULT" />

<arc:set attr="output.ConnectorId" value="[fileOut.file:name]" />

<arc:call op="fileListDir" in="fileIn2" out="fileOut4">

<arc:if exp="[_ | now | datediff(minute, [fileOut4.file:mtime])] > [file.time] && [fileOut4.file:name | endswith('.tmp',false,true)]">

<arc:set attr="tmp.count" value="[tmp.count | add]" />

</arc:if>

</arc:call>

<arc:if exp="[tmp.count] > [file.amount]">

<arc:set attr="file.warning" value="true" />

<arc:set attr="email.html">[email.html]

<tr>

<td style="text-align:right;">[output.Workspace]</td>

<td style="text-align:right;">[output.ConnectorId]</td>

<td style="text-align:right;">[tmp.count]</td>

</tr>

</arc:set>

</arc:if>

</arc:if>

</arc:call>

<!--Other workspaces -->

<arc:set attr="fileIn3.path" value="[global.datadir | pathcombine('workspaces')]" />

<arc:set attr="fileIn3.fileordir" value="dirs" />

<arc:if exp="[fileIn3.path | direxists]">

<arc:call op="fileListDir" in="fileIn3" out="fileOut2">

<arc:set attr="fileIn4.path" value="[fileOut2.file:fullname]" />

<arc:set attr="fileIn4.fileordir" value="dirs" />

<arc:call op="fileListDir" in="fileIn4" out="fileOut3">

<arc:set attr="fileIn5.path" value="[fileOut3.file:fullname | pathcombine('Send')]" />

<arc:if exp="[fileIn5.path | direxists]">

<arc:set attr="fileIn5.recurse" value="true" />

<arc:set attr="fileIn5.fileordir" value="files" />

<arc:set attr="tmp.count" value="0" />

<arc:set attr="output1.Workspace" value="[fileOut2.file:name]" />

<arc:set attr="output1.ConnectorId" value="[fileOut3.file:name]" />

<arc:call op="fileListDir" in="fileIn5" out="fileOut5">

<arc:if exp="[_ | now | datediff(minute, [fileOut5.file:mtime])] > [file.time] && [fileOut5.file:name | endswith('.tmp',false,true)]">

<arc:set attr="tmp.count" value="[tmp.count | add]" />

</arc:if>

</arc:call>

<arc:if exp="[tmp.count] > [file.amount]">

<arc:set attr="file.warning" value="true" />

<arc:set attr="email.html">[email.html]

<tr>

<td style="text-align:right;">[output1.Workspace]</td>

<td style="text-align:right;">[output1.ConnectorId]</td>

<td style="text-align:right;">[tmp.count]</td>

</tr>

</arc:set>

</arc:if>

</arc:if>

</arc:call>

</arc:call>

</arc:if>

</arc:script>

<arc:set attr="email.html" value="[email.html]</tbody></table>" />

<arc:equals attr="file.warning" value="true">

<arc:call op="appSendEmail" in="email" />

</arc:equals>

edi
edi

我们可以设置Script端口定时执行脚本,便在满足条件时收到如下邮件。

edi
edi

以上操作对Java版本同样适用,但注意Java版本Script端口这里需要写getMessageCount.rst文件所在的绝对路径。

edi
edi

更多 EDI 信息,请参阅: EDI 是什么?

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 手动监控
  • 自动监控
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档