none
Setting FileName without using Orchestration RRS feed

  • Question

  • 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 Tuesday, February 24, 2015 3:56 PM
    Tuesday, February 24, 2015 3:54 PM

Answers

  • 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 Tuesday, February 24, 2015 5:50 PM
    Tuesday, February 24, 2015 4:07 PM
    Moderator
  • 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


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    • Marked as answer by vdha Tuesday, February 24, 2015 5:50 PM
    Tuesday, February 24, 2015 4:23 PM

All replies

  • 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 Tuesday, February 24, 2015 5:50 PM
    Tuesday, February 24, 2015 4:07 PM
    Moderator
  • Have you tried %datetime% macro. Something like ABC_%datetime%.xml

    Regards,

    M.R.Ashwin Prabhu


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    Tuesday, February 24, 2015 4:08 PM
  • 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.

    Tuesday, February 24, 2015 4:16 PM
  • 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


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    • Marked as answer by vdha Tuesday, February 24, 2015 5:50 PM
    Tuesday, February 24, 2015 4:23 PM
  • 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


    Please mark as answer or vote as helpful if my reply does

    Tuesday, February 24, 2015 4:25 PM
    Moderator