---
title: "使用Biztalk Server预定义宏修改输出文件名"
author: "mapdigit"
date: "2013-03-04T16:44:00Z"
tags: []
slug: "biztalk-server"
draft: false
lastmod: "2013-03-22T14:03:19Z"
id: 1834163
url: "https://mapdigit.iteye.com/blog/1834163"
---

BizTalk Server预先定义了一些宏（Macro）可以用来定义文件输出时的文件格式，缺省使用%MessageID%.xml

[![20130304001](http://www.imobilebbs.com/wordpress/wp-content/uploads/2013/03/20130304001.png)](http://www.imobilebbs.com/wordpress/wp-content/uploads/2013/03/20130304001.png)

Biztalk Adapter (File 或 FTP） 在写文件时使用Message的ID（一般为GUID）替换%MessageID% 作为最终的文件名。

除%MessageID%之外，Biztalk还提供了如下的宏可以用来定义输出的文件名：

宏名 替换值 %datetime% UTC时间格式为 YYYY-MM-DDThhmmss (比如, 1997-07-12T103508). %datetime\_bts2000% UTC时间格式为YYYYMMDDhhmmsss, 其中 sss 为秒和微秒 (比如, 199707121035234 means 1997/07/12, 10:35:23 和 400 微秒). %datetime.tz% 本地时间加时区格式为 YYYY-MM-DDThhmmssTZD, (比如, 1997-07-12T103508+800). %DestinationParty% 目标Party的名称. 它的值来自属性BTS.DestinationParty. %DestinationPartyID% 目标Party的ID (GUID). 其值来自BTS.DestinationPartyID. %DestinationPartyQualifier% 目标Party的修饰符. 其值来自propertyBTS.DestinationPartyQualifier. %MessageID% Message的GUID，其值来自 propertyBTS.MessageID. %SourceFileName% 文件Adapter读取的源文件的文件名，包括扩展名，但不含路径名，比如foo.xml Adapter将源文件名存放到属性FILE.ReceivedFileName中， 如果无法设置该属性，该宏不会被替换 (比如,C:\\Drop\\%SourceFileName%). %SourceParty% 源Party的名称 %SourcePartyID% 源PartyID (GUID). 其值来自BTS.SourcePartyID. %SourcePartyQualifier% 源Party的修饰符. %time% UTC 时间 格式hhmmss. %time.tz% 本地时间加时区，格式 hhmmssTZD (比如 124525+530).