0

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

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

1 回答 1

-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

于 2012-06-04T06:20:35.863 回答