BizTalk 2010动态FTP发送端口输出目录和文件名称问题 [英] BizTalk 2010 Dynamic FTP Send Port Output Directory and File Name Issue

查看:183
本文介绍了BizTalk 2010动态FTP发送端口输出目录和文件名称问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当复杂的要求 - 我必须在FTP位置放置一个非常具体的命名文件,这里的诀窍是我经常不得不将它放到一个新的位置,并且每次都有一个新的文件名(目录名称和文件名取决于年份,月份,日期和时间)。显然,为此我选择使用动态发送端口,我使用MessageAssignment Shape进行配置。



每天都会生成一个文件。我需要将其放在以下格式的远程位置:
sample-servername-stage / default / file / ftp / PaymentReports / YYYY / MM_ [MonthName] / PaymentReportYYYYMMDD_HHMISS



例如,对于2016年3月2日下午6:45发布的文件,我们会有:

sample-servername-stage / default / file / ftp / PaymentReports / 2016 / 03_March / PaymentReport20160302_184500
$ b 这里是我有的代码在MessageAssignment Shape中:

  FTPSendPort1(Microsoft.XLANGs.BaseTypes.Address)=ftp:// sample-servername-stage :721\" ; 
FTPSendPort1(Microsoft.XLANGs.BaseTypes.TransportType)=FTP;

输出(FTP.CommandLogFileName)=D:\\BiztalkLogs\\FTPLog\\DynamicFTPLog.txt;
输出(FTP.UserName)=sampleUsername;
输出(FTP.Password)=samplePassword;
输出(FTP.BeforePut)=MKD+ Variable_1 +; CWD+ Variable_1;

FTPSendport1 - 动态发送端口的名称。



输出 - 输出消息的名称。

Variable_1 - 变量,我将存储要创建的目录名称。



这是最大的问题:


  1. 我需要检查一个目录是否已经存在 - 年份,然后浏览并检查月份是否已经存在。如果存在,我只需进入并放下文件。如果没有,我创建它并将文件放在那里。

  2. 除了上面显示的代码之外,我尝试了很多东西,包括设置 FILE.ReceivedFileName FTP.ReceivedFileName 属性等似乎没有任何工作。这可能是因为我无法在任何地方使用宏%SourceFileName%。正因为如此,它不断将文件放入带有GUID名称的位置,而不是我设置的位置。它的行为就像完全跳过/忽略了设置文件名的命令一样。

在此刻。我不确定如何使用FTP命令混合检查条件(如果文件夹已存在等),尤其不确定如何在编排中执行此操作。

解决方案

文件命名是在您提供FTP URL的地址属性中完成的。事实上,你甚至可以在那里使用宏。试试看:

  FTPSendPort1(Microsoft.XLANGs.BaseTypes.Address)=ftp:// sample-servername-stage:721 /SomeFolder/SomeFileName_%datetime%.xml

另一个检查文件夹是否存在的问题FTP和创建它们,我认为你必须编写一个自定义管道组件。


I have a rather complex requirement - that I have to drop a very specifically named file in an FTP location, and the trick here is that I would often have to drop it into a new location and with a new file name each time (both directory name and file name depending on the year, month, date and time). Obviously, for this purpose I chose to use a Dynamic Send Port, which I have configured using a MessageAssignment Shape.

A file will be generated each day. I need to drop it in a remote location in this form: sample-servername-stage/default/file/ftp/PaymentReports/YYYY/MM_[MonthName]/PaymentReportYYYYMMDD_HHMISS

For example, for a file posted on March, 2 2016 at 6:45pm, we would have:

sample-servername-stage/default/file/ftp/PaymentReports/2016/03_March/PaymentReport20160302_184500

Here's the code I have in the MessageAssignment Shape:

FTPSendPort1(Microsoft.XLANGs.BaseTypes.Address) = "ftp://sample-servername-stage:721";
FTPSendPort1(Microsoft.XLANGs.BaseTypes.TransportType) = "FTP";

Output(FTP.CommandLogFileName) =  "D:\\BiztalkLogs\\FTPLog\\DynamicFTPLog.txt";
Output(FTP.UserName) =  "sampleUsername";
Output(FTP.Password) =  "samplePassword";
Output(FTP.BeforePut) = "MKD " + Variable_1 + ";CWD " + Variable_1;

FTPSendport1 - name of the Dynamic Send Port.

Output - name of the Output message.

Variable_1 - variable where I will store the directory name to be created.

Here are the biggest issues:

  1. I need to check if a directory already exists - the year, then navigate in and check if the month already exists. If they exist I simply go in there and drop the file. If not, I create it and drop the file in there.

  2. I need to name the file with the date time specifics in the format shown above. In addition to the code shown above, I have tried a number of things including setting FILE.ReceivedFileName, FTP.ReceivedFileName properties etc. Nothing seems to work. This may be because I cannot use the macro %SourceFileName% anywhere. Because of this it keeps dropping the file into the location with a GUID name instead of the one I set. It behaves as though it completely skips/overlooks the command where I set the file name.

I'm thoroughly confused at this point. I'm not sure of how I can mix checking conditions (if the folders already exist etc.) with FTP commands, and especially not sure of how to do this within an orchestration.

解决方案

The file naming is done in the address property where you provide the FTP URL. In fact you can even use macros in there. Try that:

FTPSendPort1(Microsoft.XLANGs.BaseTypes.Address) = "ftp://sample-servername-stage:721/SomeFolder/SomeFileName_%datetime%.xml"

For you other problem of checking if folders exists on the FTP and creating them, I think you'll have to write a custom pipeline component.

这篇关于BizTalk 2010动态FTP发送端口输出目录和文件名称问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆