TrackingService.TryGetProfile(Type, TrackingProfile) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
必須在衍生類別中覆寫,在實作之後會擷取指定之工作流程類型的追蹤設定檔 (如果有的話)。
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
參數
- profile
- TrackingProfile
這個方法傳回時,包含要載入的 TrackingProfile。 這個參數會以未初始化的狀態傳遞。
傳回
如果有指定之工作流程 true
的 TrackingProfile 則為 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,或者您也可以管理由工作流程執行個體、工作流程 Type 和 Version 所參考之追蹤設定檔的複雜存放區。