Custom pipeline component

Hi,

I need to make a custom pipeline component which deals with the content to replace \n with \r\n.

Please suggest.

Regards,

Ranjana

September 10th, 2015 10:09am

Hi,

It is best if you can go over the earlier posts, which are very helpful and most of the answers can be found 

Find below this is exactly the same question

https://social.msdn.microsoft.com/Forums/en-US/6c5f4029-d28f-42c0-bdc7-c988fd099fb0/biztalk-server-custom-pipeline-component-for-removing-the-trailer-from-the-txt-file?forum=biztalkgeneral

Regards

K


Free Windows Admin Tool Kit Click here and download it now
September 10th, 2015 10:16am

This issue happens if you're transferring a file from a U**X system to a windows system using FTP/SFTP or NFS shares. If you're receiving this file through FTP/SFTP then changing the transfer mode from "binary" to "ascii" would solve your problem (no need to write a custom component).

If however you want then look at regexp to help you with a fast replace. If however the file size is large then a stream approach would have to be adopted. The location of such a component should be the decode stage of the pipeline to ensure that the 0x0A and 0x0D delimiters in the FFDASM work fine.

Regards.

September 10th, 2015 10:29am

Hi,

It is best if you can go over the earlier posts, which are very helpful and most of the answers can be found 

Find below this is exactly the same question

https://social.msdn.microsoft.com/Forums/en-US/6c5f4029-d28f-42c0-bdc7-c988fd099fb0/biztalk-server-custom-pipeline-component-for-removing-the-trailer-from-the-txt-file?forum=biztalkgeneral

Regards

K


  • Edited by Koushik984 Thursday, September 10, 2015 2:15 PM
Free Windows Admin Tool Kit Click here and download it now
September 10th, 2015 2:14pm

Hi,

It is best if you can go over the earlier posts, which are very helpful and most of the answers can be found 

Find below this is exactly the same question

https://social.msdn.microsoft.com/Forums/en-US/6c5f4029-d28f-42c0-bdc7-c988fd099fb0/biztalk-server-custom-pipeline-component-for-removing-the-trailer-from-the-txt-file?forum=biztalkgeneral

Regards

K


  • Edited by Koushik984 Thursday, September 10, 2015 2:15 PM
September 10th, 2015 2:14pm

This issue happens if you're transferring a file from a U**X system to a windows system using FTP/SFTP or NFS shares. If you're receiving this file through FTP/SFTP then changing the transfer mode from "binary" to "ascii" would solve your problem (no need to write a custom component).

If however you want then look at regexp to help you with a fast replace. If however the file size is large then a stream approach would have to be adopted. The location of such a component should be the decode stage of the pipeline to ensure that the 0x0A and 0x0D delimiters in the FFDASM work fine.

Regards.

Free Windows Admin Tool Kit Click here and download it now
September 10th, 2015 2:26pm

This issue happens if you're transferring a file from a U**X system to a windows system using FTP/SFTP or NFS shares. If you're receiving this file through FTP/SFTP then changing the transfer mode from "binary" to "ascii" would solve your problem (no need to write a custom component).

If however you want then look at regexp to help you with a fast replace. If however the file size is large then a stream approach would have to be adopted. The location of such a component should be the decode stage of the pipeline to ensure that the 0x0A and 0x0D delimiters in the FFDASM work fine.

Regards.

  • Proposed as answer by Aaron H. Kim Friday, September 11, 2015 11:56 AM
September 10th, 2015 2:26pm

This issue happens if you're transferring a file from a U**X system to a windows system using FTP/SFTP or NFS shares. If you're receiving this file through FTP/SFTP then changing the transfer mode from "binary" to "ascii" would solve your problem (no need to write a custom component).

If however you want then look at regexp to help you with a fast replace. If however the file size is large then a stream approach would have to be adopted. The location of such a component should be the decode stage of the pipeline to ensure that the 0x0A and 0x0D delimiters in the FFDASM work fine.

Regards.

  • Proposed as answer by Aaron H. Kim Friday, September 11, 2015 11:56 AM
Free Windows Admin Tool Kit Click here and download it now
September 10th, 2015 2:26pm

Hi Ranjana,

Please find the below pipeline component code.

#region IComponent members

        public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(Microsoft.BizTalk.Component.Interop.IPipelineContext pContext, Microsoft.BizTalk.Message.Interop.IBaseMessage pInMsg)
        {
            try
            {
                StreamReader streamReader = new StreamReader(pInMsg.BodyPart.GetOriginalDataStream());
                byte[] bytesString = Encoding.Default.GetBytes(Regex.Replace(streamReader.ReadToEnd(), "(?<!\r)\n", Environment.NewLine));
                streamReader.Close();
                MemoryStream OutmemoryStream = new MemoryStream();
                OutmemoryStream.Write(bytesString, 0, bytesString.Length);
                OutmemoryStream.Seek(0, SeekOrigin.Begin);
                pInMsg.BodyPart.Data = OutmemoryStream;
                pContext.ResourceTracker.AddResource(OutmemoryStream);
                return pInMsg;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        #endregion

Output

PC_U_To_W_File

Thanks, SMSVikasK

September 11th, 2015 2:12pm

Hi Ranjana,

Please find the below pipeline component code.

#region IComponent members

        public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(Microsoft.BizTalk.Component.Interop.IPipelineContext pContext, Microsoft.BizTalk.Message.Interop.IBaseMessage pInMsg)
        {
            try
            {
                StreamReader streamReader = new StreamReader(pInMsg.BodyPart.GetOriginalDataStream());
                byte[] bytesString = Encoding.Default.GetBytes(Regex.Replace(streamReader.ReadToEnd(), "(?<!\r)\n", Environment.NewLine));
                streamReader.Close();
                MemoryStream OutmemoryStream = new MemoryStream();
                OutmemoryStream.Write(bytesString, 0, bytesString.Length);
                OutmemoryStream.Seek(0, SeekOrigin.Begin);
                pInMsg.BodyPart.Data = OutmemoryStream;
                pContext.ResourceTracker.AddResource(OutmemoryStream);
                return pInMsg;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        #endregion

Output

PC_U_To_W_File

Thanks, SMSVikasK

Free Windows Admin Tool Kit Click here and download it now
September 11th, 2015 6:10pm

Hi Ranjana,

Please find the below pipeline component code.

#region IComponent members

        public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(Microsoft.BizTalk.Component.Interop.IPipelineContext pContext, Microsoft.BizTalk.Message.Interop.IBaseMessage pInMsg)
        {
            try
            {
                StreamReader streamReader = new StreamReader(pInMsg.BodyPart.GetOriginalDataStream());
                byte[] bytesString = Encoding.Default.GetBytes(Regex.Replace(streamReader.ReadToEnd(), "(?<!\r)\n", Environment.NewLine));
                streamReader.Close();
                MemoryStream OutmemoryStream = new MemoryStream();
                OutmemoryStream.Write(bytesString, 0, bytesString.Length);
                OutmemoryStream.Seek(0, SeekOrigin.Begin);
                pInMsg.BodyPart.Data = OutmemoryStream;
                pContext.ResourceTracker.AddResource(OutmemoryStream);
                return pInMsg;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        #endregion

Output

PC_U_To_W_File

Thanks, SMSVikasK

September 11th, 2015 6:10pm

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

Other recent topics Other recent topics