共用方式為


TrackingChannel.Send(TrackingRecord) 方法

定義

在衍生類別中實作時,在 TrackingRecord 上傳送 TrackingChannel

protected public:
 abstract void Send(System::Workflow::Runtime::Tracking::TrackingRecord ^ record);
protected internal abstract void Send (System.Workflow.Runtime.Tracking.TrackingRecord record);
abstract member Send : System.Workflow.Runtime.Tracking.TrackingRecord -> unit
Protected Friend MustOverride Sub Send (record As TrackingRecord)

參數

record
TrackingRecord

要傳送的 TrackingRecord

範例

下列程式碼範例將示範 Send 方法的實作。 在此實作中,追蹤訊息會在工作流程終止時寫入事件日誌中。 這個範例來自<終止追蹤服務 SDK>範例。 如需詳細資訊,請參閱 終止追蹤服務範例

/// <summary>
/// Receives tracking events.  Instance terminated events are written to the event log.
/// </summary>
protected override void Send(TrackingRecord record)
{
    WorkflowTrackingRecord instanceTrackingRecord = record as WorkflowTrackingRecord;

    if ((null == instanceTrackingRecord) || (TrackingWorkflowEvent.Terminated != instanceTrackingRecord.TrackingWorkflowEvent))
        return;

    // Create an EventLog instance and assign its source.
    EventLog log = new EventLog();
    log.Source = sourceValue;

    // Write an informational entry to the event log.
    TrackingWorkflowTerminatedEventArgs terminatedEventArgs = instanceTrackingRecord.EventArgs as TrackingWorkflowTerminatedEventArgs;

    StringBuilder message = new StringBuilder(512);
    message.AppendLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Workflow instance {0} has been terminated.", parametersValue.InstanceId.ToString()));
    message.AppendLine();

    if (null != terminatedEventArgs.Exception)
        message.AppendLine(terminatedEventArgs.Exception.ToString());

    log.WriteEntry(message.ToString(), EventLogEntryType.Warning);
}
'/ <summary>
'/ Receives tracking events.  Instance terminated events are written to the event log.
'/ </summary>
Protected Overrides Sub Send(ByVal record As TrackingRecord)

    Dim instanceTrackingRecord As WorkflowTrackingRecord = CType(record, WorkflowTrackingRecord)

    If instanceTrackingRecord Is Nothing Or Not TrackingWorkflowEvent.Terminated = instanceTrackingRecord.TrackingWorkflowEvent Then
        Return
    End If

    ' Create an EventLog instance and assign its source.
    Dim log As New EventLog()
    log.Source = sourceValue

    ' Write an informational entry to the event log.  
    Dim terminatedEventArgs As TrackingWorkflowTerminatedEventArgs = CType(instanceTrackingRecord.EventArgs, TrackingWorkflowTerminatedEventArgs)

    Dim Message As New StringBuilder(512)
    Message.AppendLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Workflow instance 0} has been terminated.", parametersValue.InstanceId.ToString()))
    Message.AppendLine()

    If terminatedEventArgs.Exception Is Nothing Then
        Message.AppendLine(terminatedEventArgs.Exception.ToString())
    End If


    log.WriteEntry(Message.ToString(), EventLogEntryType.Warning)
End Sub

備註

執行階段追蹤基礎結構會在符合 Send 中的追蹤點時,呼叫 TrackingRecord 以在 TrackingChannel 上傳遞 TrackingProfile。 您可以使用您的應用程式要求的任何方式來處理在 TrackingChannel 上傳送的追蹤資訊。

適用於