TrackingService.TryGetProfile(Type, TrackingProfile) 方法

定义

必须在派生类中重写,并且在实现后为指定的工作流类型(如果有)检索跟踪配置文件。

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

要为其获取跟踪配置文件的工作流的 Type

profile
TrackingProfile

此方法返回时,将包含要加载的 TrackingProfile。 此参数未经初始化即被传递。

返回

如果指定工作流 trueTrackingProfile 可用,则为 Type;否则为 false。 如果为 true,则会在 TrackingProfile 中返回 profile

示例

下面的示例演示 TryGetProfile 方法的实现,该方法调用私有 GetProfile 方法。 此示例摘自“终止跟踪服务”SDK 示例。 有关详细信息,请参阅 终止跟踪服务示例

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

注解

跟踪服务负责管理可用于特定工作流类型和特定工作流实例的跟踪配置文件。 可以采用您选择的任何方式实现此管理。 例如,您可以为每个工作流 TrackingProfile 和工作流实例返回相同的 Type;或者,您可以管理工作流实例、工作流 TypeVersion 引用的跟踪配置文件的复杂存储。

适用于