Hi,
I need to make a custom pipeline component which deals with the content to replace \n with \r\n.
Please suggest.
Regards,
Ranjana
Technology Tips and News
Hi,
I need to make a custom pipeline component which deals with the content to replace \n with \r\n.
Please suggest.
Regards,
Ranjana
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
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.
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
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
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.
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.
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.
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
Thanks, SMSVikasK
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
Thanks, SMSVikasK
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
Thanks, SMSVikasK