TrackingService.TryGetProfile(Type, TrackingProfile) 方法

定义

必须在派生类中重写,并且在实现后为指定的工作流类型(如果有)检索跟踪配置文件。Must be overridden in the derived class, and when implemented, retrieves the tracking profile for the specified workflow type if one is available.

protected public:
 abstract bool TryGetProfile(Type ^ workflowType, [Runtime::InteropServices::Out] System::Workflow::Runtime::Tracking::TrackingProfile ^ % profile);
protected internal abstract bool TryGetProfile (Type workflowType, out System.Workflow.Runtime.Tracking.TrackingProfile profile);
abstract member TryGetProfile : Type * TrackingProfile -> bool
Protected Friend MustOverride Function TryGetProfile (workflowType As Type, ByRef profile As TrackingProfile) As Boolean

参数

workflowType
Type

要为其获取跟踪配置文件的工作流的 TypeThe Type of the workflow for which to get the tracking profile.

profile
TrackingProfile

此方法返回时,将包含要加载的 TrackingProfileWhen this method returns, contains the TrackingProfile to load. 此参数未经初始化即被传递。This parameter is passed uninitialized.

返回

Boolean

如果指定工作流 trueTrackingProfile 可用,则为 Type;否则为 falsetrue if a TrackingProfile for the specified workflow Type is available; otherwise, false. 如果为 true,则会在 TrackingProfile 中返回 profileIf true, the TrackingProfile is returned in profile.

示例

下面的示例演示 TryGetProfile 方法的实现,该方法调用私有 GetProfile 方法。The following example demonstrates an implementation of the TryGetProfile method, which calls a private GetProfile method. 此示例摘自“终止跟踪服务”SDK 示例。This example is from the Termination Tracking Service SDK sample. 有关详细信息,请参阅 终止跟踪服务示例For more information, see Termination Tracking Service Sample.

class OrderServiceImpl : IOrderService
{
    string orderId;
    public WorkflowInstance instanceId;

    // Called by the workflow to pass an order id
    public void CreateOrder(string Id)
    {
        Console.WriteLine("\nPurchase Order Created in System");
        orderId = Id;
    }

    // Called by the host to approve an order
    public void ApproveOrder()
    {
        EventHandler<OrderEventArgs> orderApproved = this.OrderApproved;
        if (orderApproved != null)
            orderApproved(null, new OrderEventArgs(instanceId.InstanceId, orderId));
    }

    // Called by the host to reject an order
    public void RejectOrder()
    {
        EventHandler<OrderEventArgs> orderRejected = this.OrderRejected;
        if (orderRejected != null)
            orderRejected(null, new OrderEventArgs(instanceId.InstanceId, orderId));
    }

    // Events that handled within a workflow by HandleExternalEventActivity activities
    public event EventHandler<OrderEventArgs> OrderApproved;
    public event EventHandler<OrderEventArgs> OrderRejected;
}
Class OrderServiceImpl
    Implements IOrderService

    Dim orderId As String
    Public instanceId As WorkflowInstance

    ' Called by the workflow to pass an order id
    Public Sub CreateOrder(ByVal Id As String)

        Console.WriteLine("\nPurchase Order Created in System")
        orderId = Id
    End Sub

    ' Called by the host to approve an order
    Public Sub ApproveOrder()
        RaiseEvent OrderApproved(Nothing, New OrderEventArgs(instanceId.InstanceId, orderId))
    End Sub

    ' Called by the host to reject an order
    Public Sub RejectOrder()
        RaiseEvent OrderRejected(Nothing, New OrderEventArgs(instanceId.InstanceId, orderId))
    End Sub

    ' Events that handled within a workflow by HandleExternalEventActivity activities
    Public Event OrderApproved(ByVal sender As Object, ByVal e As OrderEventArgs) Implements IOrderService.OrderApproved
    Public Event OrderRejected(ByVal sender As Object, ByVal e As OrderEventArgs) Implements IOrderService.OrderRejected
End Class

注解

跟踪服务负责管理可用于特定工作流类型和特定工作流实例的跟踪配置文件。A tracking service is responsible for managing the tracking profiles available for specific workflow types and specific workflow instances. 可以采用您选择的任何方式实现此管理。You can implement this management in whatever manner you choose. 例如,您可以为每个工作流 TrackingProfile 和工作流实例返回相同的 Type;或者,您可以管理工作流实例、工作流 TypeVersion 引用的跟踪配置文件的复杂存储。For example, you can return the same TrackingProfile for every workflow Type and workflow instance; or you can manage a sophisticated store of tracking profiles referenced by workflow instance, workflow Type, and Version.

适用于