Setting FileName without using Orchestration

Hello All,

I have a requirement where, the file name should be ABC_yyyyMMddHHmmss.So I am using, Message Assignment shape in the orchestration

Message(FILE.ReceivedFileName) = "ABC_" + System.DateTime.Now.ToString("yyyyMMddHHmmss");

Is there any way of doing without orchestration. I tried using the %datetime_bts2000% but that has YYYYMMDDhhmmsss, where sss means seconds and milliseconds. I dont need milliseconds in the filename. Thanks


  • Edited by vdha 19 hours 32 minutes ago
February 24th, 2015 10:57am

Yes, but you would have to create a custom Pipeline Component.

There is nothing wrong with using an Orchestration.  Don't even think about 'performance' unless you can prove it's an issue.

The code you have will produce a time stamp with precision in seconds.  You don't have to do anything.

  • Marked as answer by vdha 17 hours 38 minutes ago
Free Windows Admin Tool Kit Click here and download it now
February 24th, 2015 11:10am

Have you tried %datetime% macro. Something like ABC_%datetime%.xml

Regards,

M.R.Ashwin Prabhu

February 24th, 2015 11:10am

Thank you guys,

@Johns, The code I used works perfectly. I was wondering if this ca be done without Orchestration, thinking about the same performance issue in future :-)

@Ashwin, %datetime% macro gives YYYY-MM-DDThhmmss format. I am just looking for yyyyMMddHHmmss.

Free Windows Admin Tool Kit Click here and download it now
February 24th, 2015 11:19am

To Add to my above reply..

ABC_%datetime%.xml macro will have output like ABC_2015-02-24T160045. But it doesn't choose your required format.

Closer to yours as you use is %datetime_bts2000%. But if you don't need milliseconds you can't use macro. You need to achieve this is in custom pipeline where you construct the name of the output file in the format as you want. Following code achieves your requirement.

public IBaseMessage Execute(IPipelineContext pc, IBaseMessage inmsg)
{
//set friendly date string
string dateString =  DateTime.Now.ToString("yyyyMMddHHmmss");


//write updated value back to context
inmsg.Context.Write("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties", "ABC_"+dateString);

//return the message with modified context
return inmsg;
}
 

NOTE: It depends on frequency of the message. If you have more frequent messages, then I would have better combination to avoid file overwritten issue.

Regards,

M.R.Ashwin Prabhu

February 24th, 2015 11:26am

Hi Vdha,

With the predefined set of macros provided, this is not possible. You need to write a custom pipeline component.

Refer: Set Dynamic Destination File Name With BizTalk Server 2006

Rachit

Free Windows Admin Tool Kit Click here and download it now
February 24th, 2015 11:27am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics