首页 > 其他分享 >如何实时监控是否有待发送的文件?

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

时间:2022-11-25 16:58:27浏览次数:57  
标签:文件 Workspace 知行 xxx 实时 发送 file rst 有待

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

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

手动监控

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

 

 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 <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>

 

edi

 

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

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。ediedi

自动监控

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

 

 
1 2 3 4 5 6 7 8 9 10 11 <!-- 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="[email protected]" /> <!-- 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

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

 

 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 <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

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

edi

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

edi

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

标签:文件,Workspace,知行,xxx,实时,发送,file,rst,有待
From: https://www.cnblogs.com/edi-ka/p/16925648.html

相关文章