receive アクティビティを公開する xaml サービスを想像できます。これは私のワークフローの最初のアクティビティです。この受信の背後には、InitializeCorrelation"、"assign"、"delay" などの単純なアクティビティがあります。次に、アクティビティ デザイナーで作成されたカスタム アクティビティがあります。つまり、メイン ワークフローに実際にコード アクティビティがあります。は、開発者がアクティビティをカスタマイズできるようにするドラッグ アンド ドロップ ゾーンを提供します。ただし、最初はこのアクティビティに固定の受信アクティビティが必要です。この受信は、の最初の受信で得られた情報を使用して初期化された最初の 1 つの相関ハンドルを使用して相関する必要があります。サービス。
私の問題は、xaml で初期化された関連付けハンドルを使用して、コード アクティビティで受信を関連付けることができないことです。2 番目の受信 (コード受信) を呼び出すと、タイムアウト エラーが発生します。
何が悪いのか知っていますか?
これは私のコード活動のコードです
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using System.ComponentModel;
using WF4ActivityDesignerLibrary.ActivityDesigner;
using System.Xml.Linq;
using System.ServiceModel.Activities;
using System.ServiceModel;
using System.Activities.Statements;
namespace WF4ActivityDesignerLibrary.Activities
{
[Designer(typeof(ContainerWithMultipleActivitiesDesigner))]
public class ActivityWithMultipleChild : NativeActivity
{
public List<Activity> Activities { get; set; }
private Receive ReceiveCancel { get; set; }
private SendReply ReplyCancel { get; set; }
private CorrelationScope Scope { get; set; }
public InArgument<System.ServiceModel.Activities.CorrelationHandle> HandleToCorrelate { get; set; }
private Variable<CorrelationHandle> CorrelationHandle { get; set; }
private Variable<string> orderid = new Variable<string> { Name = "orderid" };
//public SendReply SendReplyCancel { get; set; }
public ActivityWithMultipleChild()
{
Activities = new List<Activity>();
InitializeReceiveAndReply();
}
private void InitializeReceiveAndReply()
{
CorrelationHandle = new Variable<CorrelationHandle>("SenseProcessCorrelationHandle");
ReceiveCancel = new Receive
{
CanCreateInstance = false,
ServiceContractName = "IOrderService",
OperationName = "StartOrder",
CorrelatesWith = HandleToCorrelate,
ProtectionLevel = System.Net.Security.ProtectionLevel.None,
SerializerOption = System.ServiceModel.Activities.SerializerOption.DataContractSerializer,
DisplayName = "Segundo Receive",
CorrelatesOn = new MessageQuerySet
{
{ "key1", new XPathMessageQuery("string('11445')") }
},
Content = new ReceiveParametersContent()
{
Parameters = { { "orderid", new OutArgument<string>(this.orderid) } }
},
CorrelationInitializers =
{
new RequestReplyCorrelationInitializer
{
CorrelationHandle = CorrelationHandle,
}
}
};
ReplyCancel = new SendReply
{
Request = ReceiveCancel,
PersistBeforeSend = true,
Content = SendParametersContent.Create(new Dictionary<string, InArgument> { { "OrderId", new InArgument<string>((env) => "asdf") } })
};
}
protected override void CacheMetadata(NativeActivityMetadata metadata)
{
base.CacheMetadata(metadata);
metadata.AddVariable(this.orderid);
metadata.AddChild(ReceiveCancel);
metadata.AddChild(ReplyCancel);
metadata.AddVariable(CorrelationHandle);
}
protected override void Execute(NativeActivityContext context)
{
ReceiveCancel.CorrelatesWith = context.GetValue<CorrelationHandle>(HandleToCorrelate);
context.ScheduleActivity(ReceiveCancel, OnReceiveCompleted);
Activities.Reverse(0, Activities.Count);
}
void OnReceiveCompleted(NativeActivityContext context, ActivityInstance inst)
{
foreach (Activity act in Activities)
{
context.ScheduleActivity(act);
}
context.ScheduleActivity(ReplyCancel);
}
}
}