向工作流添加跟踪配置文件

时间:2012-04-26 14:16:33

标签: c# workflow-foundation-4

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

 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);
    }

1 个答案:

答案 0 :(得分:-1)

您可以参考WCf_WF_sample进行跟踪。你可以从这里下载。

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

下面给出了sql server的示例跟踪配置文件。

<?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