BizTalk

Implementation of macro in Pipeline Component

Below are few of the macros and implementation in .Net/BizTalk.net. This can be directly used in the archiving pipeline component

“%datetime%” -> DateTime.Now.ToString(“yyyy-MM-ddTHHmmss”);
“%datetime_bts2000%” -> DateTime.Now.ToString(“yyyyMMddHHmmsss”); 
“%datetime.tz%” -> DateTime.Now.ToString(“yyyy-MM-ddTHHmmsszzz”).Replace(“:”,“”); 
“%MessageID%” -> InMsg.MessageID.ToString();
“%SourceFileName%” -> InMsg.Context.Read(“ReceivedFileName”, http://schemas.microsoft.com/BizTalk/2003/file-properties”).ToString();
“%time%” -> DateTime.Now.ToString(“HHmmss”).Replace(“:”, “”);
“%time.tz%” -> DateTime.Now.ToString(“HHmmsszzz”).Replace(“:”, “”);

Implementaion of the searching pattern to search the pattern %<any alpha number or . >%

string pattern = @”[%][\w|.]*[%]”;
string strMatch = “”;
foreach (Match match in Regex.Matches(FileNameWithMacro, pattern))
{
ReadMacro(match.Value); //This will be method implmentation of replacing macro with actaull file content.
FileName = FileName.Replace(match.Value, strMatch);
strMatch =“”;
}