将跟踪配置文件添加到工作流

本文关键字:工作流 添加 配置文件 跟踪 | 更新日期: 2023-09-27 18:32:16

>我有我的自定义工作流程,如下例所示。如何添加工作流跟踪配置文件以监视每个步骤中发生的情况?

 static void Main(string[] args)
    {
        OuputToConsole("hello", "wf");
        Console.ReadKey();
    }
    private static void OuputToConsole(string p, string p_2)
    {
        // workflow implementation
        var s = new Sequence()
                    {
                        Activities =
                            {
                                new WriteLine() {Text = p},
                                new WriteLine() {Text = p_2}
                            }
                    };
        // running code or execute code
        WorkflowInvoker.Invoke(s);
    }

将跟踪配置文件添加到工作流

您可以参考WCf_WF_sample进行跟踪。您可以从此处下载。

http://www.microsoft.com/en-us/download/details.aspx?id=21459

下面给出了 SQL 服务器的跟踪配置文件示例。

<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright (c) Microsoft Corporation.  All rights reserved. -->
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
  </system.web>

  <connectionStrings>
    <add connectionString="Data Source=localhost'SQLEXPRESS;Initial Catalog=TrackingSample;Integrated Security=SSPI"
         name="TrackingDbConnection" providerName="System.Data.SqlClient"  />
  </connectionStrings>
  <system.serviceModel>
      <extensions>
        <behaviorExtensions>
          <add name="sqlTracking" type="Microsoft.Samples.SqlTracking.SqlTrackingExtensionElement, SqlTrackingParticipant, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
        </behaviorExtensions>
      </extensions>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <sqlTracking profileName="Troubleshooting Profile"
                                 connectionStringName="TrackingDbConnection"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
          <serviceMetadata httpGetEnabled="True"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <tracking>
      <profiles>
        <trackingProfile name="Troubleshooting Profile">
          <workflow activityDefinitionId="*">
            <workflowInstanceQueries>
              <workflowInstanceQuery>
                <states>
                  <state name="*" />
                </states>
              </workflowInstanceQuery>
            </workflowInstanceQueries>
            <activityStateQueries>
              <activityStateQuery activityName="*">
                <states>
                  <state name="*" />
                </states>
                <variables>
                  <variable name="*"/>
                </variables>
              </activityStateQuery>
            </activityStateQueries>
            <activityScheduledQueries>
              <activityScheduledQuery activityName="*" childActivityName="*" />
            </activityScheduledQueries>
            <faultPropagationQueries>
              <faultPropagationQuery faultSourceActivityName="*" faultHandlerActivityName="*" />
            </faultPropagationQueries>
            <customTrackingQueries>
              <customTrackingQuery name="*" activityName="*" />
            </customTrackingQueries>
          </workflow>
        </trackingProfile>
        <trackingProfile name="Instance_And_Custom_Records">
          <workflow activityDefinitionId="*">
            <workflowInstanceQueries>
              <workflowInstanceQuery>
                <states>
                  <state name="*" />
                </states>
              </workflowInstanceQuery>
            </workflowInstanceQueries>
            <customTrackingQueries>
              <customTrackingQuery name="*" activityName="*" />
            </customTrackingQueries>
           </workflow>
        </trackingProfile>
      </profiles>
    </tracking>
  </system.serviceModel>
</configuration>

您也可以参考这些链接以获得更多了解。http://msdn.microsoft.com/en-us/library/ee513992.aspx