通过工作流基础4.0中的代码注册自定义跟踪参与者
我在尝试在工作流基础 4.0 中附加自定义跟踪参与者时遇到问题。我有一个继承自 TrackingParticipant 的类,但除了通过大量混乱的 app.config 条目(如下面的 SDK 示例(在 system.servicemodel 元素中)所示)之外,我看不到将其附加到我的 WorkflowServiceHost 的任何其他方式。当我只想要一个简单的自定义跟踪参与者来监听我的 CustomTrackingRecord.Data.Add(key, value) 调用时,此选项似乎需要大量额外的开销和创建类。
public class CustomTracking : TrackingParticipant
{
protected override void Track(TrackingRecord record, TimeSpan timeout)
{
CustomTrackingRecord innerRecord = (CustomTrackingRecord)record;
var workflowInstanceId = innerRecord.InstanceId;
Console.WriteLine("Track called for workflow '{0}'", workflowInstanceId);
}
}
如何通过代码(而不是如下配置)将上述自定义跟踪参与者注册到工作流服务主机实例?
<extensions>
<behaviorExtensions>
<add name="historyFileTracking" type="Microsoft.Samples.HistoryFileTrackingExtensionElement, HiringRequestProcessDefinition, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<behaviors>
<serviceBehaviors>
<behavior>
<historyFileTracking profileName="RequestStoryTracking" path="..\..\..\Data\RequestHistory\"/>
</behavior>
</serviceBehaviors>
</behaviors>
<tracking>
<profiles>
<trackingProfile name="RequestStoryTracking">
<workflow activityDefinitionId="*">
<customTrackingQueries>
<customTrackingQuery name="*" activityName="*" />
</customTrackingQueries>
</workflow>
</trackingProfile>
</profiles>
</tracking>
I'm having trouble trying to attach a custom tracking participant in workflow foundation 4.0. I have a class that inherits from TrackingParticipant but I cannot see any other way of attaching it to my WorkflowServiceHost other than through lots of messy app.config entries like the SDK example demonstrates below (in the system.servicemodel element). This option seems to require a lot of extra overhead and classes to be created, when I just want a simple custom tracking participant to listen to my CustomTrackingRecord.Data.Add(key, value) calls.
public class CustomTracking : TrackingParticipant
{
protected override void Track(TrackingRecord record, TimeSpan timeout)
{
CustomTrackingRecord innerRecord = (CustomTrackingRecord)record;
var workflowInstanceId = innerRecord.InstanceId;
Console.WriteLine("Track called for workflow '{0}'", workflowInstanceId);
}
}
How can I register my above custom tracking participant through code (and not config like below) to a workflowServiceHost instance?
<extensions>
<behaviorExtensions>
<add name="historyFileTracking" type="Microsoft.Samples.HistoryFileTrackingExtensionElement, HiringRequestProcessDefinition, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<behaviors>
<serviceBehaviors>
<behavior>
<historyFileTracking profileName="RequestStoryTracking" path="..\..\..\Data\RequestHistory\"/>
</behavior>
</serviceBehaviors>
</behaviors>
<tracking>
<profiles>
<trackingProfile name="RequestStoryTracking">
<workflow activityDefinitionId="*">
<customTrackingQueries>
<customTrackingQuery name="*" activityName="*" />
</customTrackingQueries>
</workflow>
</trackingProfile>
</profiles>
</tracking>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将其作为工作流扩展添加到 WorkflowServiceHost 即可。
Just add it as a workflow extension to the WorkflowServiceHost.