いくつかの txt ファイルを含む xxx.GZ ファイルを送信ポートに展開できるカスタム BizTalk 2013 R2 (受信または送信) パイプラインを作成しようとしました。
これが私が今まで試したことです:
PS。.Net の IO GZip クラスを使用しました。
BTS アプリケーションを作成し、受信場所と送信ポートを構成しました。
受信場所は、私が作成したカスタム パイプラインを使用します。ここに、私が試したカスタム パイプラインのコードを示します。
public void Disassemble(IPipelineContext pc, IBaseMessage inmsg) { IBaseMessagePart bodyPart = inmsg.BodyPart; if (bodyPart != null) { Stream originalStream = bodyPart.GetOriginalDataStream(); if (originalStream != null) { using (GZipStream gZipInputStream = new GZipStream(new MemoryStream(originalStream.ReadByte()), CompressionMode.Decompress)) { MemoryStream memStream = new MemoryStream(); byte[] buffer = new Byte[1024]; int bytesRead = 1024; while (bytesRead != 0) { bytesRead = gZipInputStream.Read(buffer, 0, buffer.Length); gZipInputStream.CopyTo(buffer, 0); memStream.Write(buffer, 0, bytesRead); } IBaseMessage outMessage; outMessage = pc.GetMessageFactory().CreateMessage(); outMessage.AddPart("Body", pc.GetMessageFactory().CreateMessagePart(), true); memStream.Position = 0; outMessage.BodyPart.Data = memStream; outMessage.Context = PipelineUtil.CloneMessageContext(inmsg.Context); _msgs.Enqueue(outMessage); } } } }
このコードは、私が望むようには機能しないようです。GZ ファイルを送信ポートに解凍せずに送信するだけです。実装されたパイプラインを受信場所ポートで使用します。BizTalk が受信場所で GZ パック ファイルを受信すると、この受信場所でサブスクライブする送信ポートにファイルを送信するだけです。パイプラインは GZ ストリームに対して何もしていないようです。すべきことは、GZ ファイルをアンパックし、アンパックされたすべてのファイルを送信ポートに送信することです。これは、アンパック ファイルを配置する必要があるフォルダーを指します。
うまくいかずにグーグルで検索しようとしましたが、存在するサンプルはうまくいかないようです。
誰でも私を助けたり、コードで何が間違っているかを教えてくれます。いくつかの txt ファイルを含む受信した GZ ファイルを送信ポート (フォルダーを指す) に解凍できる C# カスタム BizTalk 2013 R2 (受信または送信) パイプラインを実装したいだけですか?
アップデート:
Dissambler バージョンが機能しなかったので、デコード バージョンを作成しました。
パイプラインのデコード コードは次のとおりです。
#region IComponent members
/// <summary>
/// Implements IComponent.Execute method.
/// </summary>
/// <param name="pc">Pipeline context</param>
/// <param name="inmsg">Input message</param>
/// <returns>Original input message</returns>
/// <remarks>
/// IComponent.Execute method is used to initiate
/// the processing of the message in this pipeline component.
/// </remarks>
public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(Microsoft.BizTalk.Component.Interop.IPipelineContext pc, Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg)
{
if (null == pc) throw new ArgumentNullException("pContext", "Pipeline context can not be null");
if (null == inmsg) throw new ArgumentNullException("pInMsg", "Input message can not be null");
IBaseMessagePart bodyPart = inmsg.BodyPart;
if (bodyPart != null)
{
GZipStream strm = new GZipStream(bodyPart.GetOriginalDataStream(), CompressionMode.Decompress);
bodyPart.Data = strm;
pc.ResourceTracker.AddResource(strm);
}
return inmsg;
}
#endregion
GZip ファイル内の各ファイルの正しいファイル名を取得するにはどうすればよいですか? したがって、メッセージが送信ポートに送信されると、正しいファイル名でファイルが書き込まれます。