我正在使用Visual Studio 2010的Beta 2版本来获得一些使用WF4的高级学习。我一直在使用WF_WCF_Samples SDK中的SqlTracking示例,并且已经很好地理解如何在SQL数据库中发送和存储跟踪数据,但是在需要时没有看到如何查询数据。有没有人知道是否有任何.Net类用于查询跟踪数据,如果有的话,是否有任何已知的示例,教程或文章描述了如何查询跟踪数据?Windows Workflow Foundation 4.0和跟踪
2
A
回答
1
根据马特·温克勒,从Microsoft WF4团队,没有任何内置的API进行查询跟踪数据,开发者必须写他/她自己的。
0
0
老问题,我知道,但实际上是有或多或少的官方API中的AppFabric:当然Windows Server AppFabric Class Library
你必须找到实际的DLL文件位于%SystemRoot%\的AppFabric(安装后的AppFabric, )。很奇怪的地方放它。
要查看的关键类是SqlInstanceQueryProvider,InstanceQueryExecuteArgs。查询API是异步的,可以使用像这样(C#):
public InstanceInfo GetWorkflowInstanceInformation(Guid workflowInstanceId, string connectionString)
{
var instanceQueryProvider = new SqlInstanceQueryProvider();
// Connection string to the instance store needs to be set like this:
var parameters = new NameValueCollection()
{
{"connectionString", connectionString}
};
instanceQueryProvider.Initialize("Provider", parameters);
var queryArgs = new InstanceQueryExecuteArgs()
{
InstanceId = new List<Guid>() { workflowInstanceId }
};
// Total ruin the asynchronous advantages and use a Mutex to lock on.
var waitEvent = new ManualResetEvent(false);
IEnumerable<InstanceInfo> retrievedInstanceInfos = null;
var query = instanceQueryProvider.CreateInstanceQuery();
query.BeginExecuteQuery(
queryArgs,
TimeSpan.FromSeconds(10),
ar =>
{
lock (synchronizer)
{
retrievedInstanceInfos = query.EndExecuteQuery(ar).ToList();
}
waitEvent.Set();
},
null);
var waitResult = waitEvent.WaitOne(5000);
if (waitResult)
{
List<InstanceInfo> instances = null;
lock (synchronizer)
{
if (retrievedInstanceInfos != null)
{
instances = retrievedInstanceInfos.ToList();
}
}
if (instances != null)
{
if (instances.Count() == 1)
{
return instances.Single();
}
if (!instances.Any())
{
Log.Warning("Request for non-existing WorkflowInstanceInfo: {0}.", workflowInstanceId);
return null;
}
Log.Error("More than one(!) WorkflowInstanceInfo for id: {0}.", workflowInstanceId);
}
}
Log.Error("Time out retrieving information for id: {0}.", workflowInstanceId);
return null;
}
而只是为了澄清 - 这不给你访问到的跟踪数据,它们存储在监控数据库中。该API仅用于持久性数据库。
相关问题
- 1. Windows Workflow Foundation 4.0和跟踪
- 2. Windows Workflow Foundation 4.0和Persistence
- 3. Windows Workflow Foundation 4.0和Persistence
- 4. Workflow Foundation 4.0 - 事务服务和SQL跟踪服务?
- 5. Windows Workflow Foundation 4.0连接器
- 6. Silverlight和Windows Workflow Foundation
- 7. Silverlight和Windows Workflow Foundation
- 8. Windows Workflow Foundation 4.0中的附加属性?
- 9. Windows Workflow Foundation NullReferenceException
- 10. 如何跟踪自定义Windows Workflow Foundation活动属性?
- 11. Windows Workflow Foundation InvokeMethod类
- 12. 替代Windows Workflow Foundation
- 13. Windows服务与Windows Workflow Foundation?
- 14. Windows Workflow Foundation 4.0和WCF Web服务故障(soap故障)
- 15. Drools.NET与Windows Workflow Foundation(WF)
- 16. Windows Workflow Foundation 4(WF4)延迟
- 17. Windows Workflow Foundation 4(WF4)参数
- 18. Windows Workflow Foundation,异常和重试?
- 19. Workflow Foundation的4.0请求 - 响应
- 20. 让Microsoft在.NET 4.0中重写了Windows Workflow Foundation?
- 21. Windows Workflow Foundation 4.0选择包含延迟活动的活动
- 22. Windows Workflow Foundation 4.0突破ForEach <T>活动
- 23. Workflow Foundation独立模式
- 24. Windows Workflow 4.0 FlowSwitch不工作
- 25. Windows Workflow Foundation 4.0中的协议和命名书签有什么区别?
- 26. Extend Workflow Foundation FlowChart
- 27. Workflow Foundation线程和WCF OperationContext
- 28. Windows Workflow Foundation的Java替代方案
- 29. Windows Workflow Foundation 4(WF4)持久性
- 30. Windows Workflow Foundation 4创建基本活动
感谢您的帖子,但我想我很困惑。它在我看来,上面的链接都是如何发出跟踪数据的样本,然后将其存储在某处(如数据库或事件日志)。我正在寻找一种机制来查询存储后的数据。在.Net 3.5中,我们使用了SqlTrackingQuery,并且它是TryGetWorkflow()方法来完成此操作。这就是我试图找到的那种东西 - 一种查询存储数据的机制。也许这不包括在WF4中,我可能不得不编写自己的查询。 – 2010-01-15 16:20:56
与WorkflowInstanceQuery没有关系吗?我没有深入研究wf4 ... – 2010-01-15 16:35:07
这可能是我无法确定的,因为文档数量有限,但至少在跟踪配置文件中使用该类来发射跟踪记录,然后由TrackingParticipant使用它将其存储在某处。它可能,也可能不会被用来查询跟踪记录,一旦它们被存储 - 就像我说的,由于缺乏文档,很难说。 – 2010-01-15 17:36:14