Activity.Execute(ActivityExecutionContext) 메서드

정의

활동을 실행하기 위해 워크플로 런타임에서 호출됩니다.Called by the workflow runtime to execute an activity.

protected public:
 virtual System::Workflow::ComponentModel::ActivityExecutionStatus Execute(System::Workflow::ComponentModel::ActivityExecutionContext ^ executionContext);
protected internal virtual System.Workflow.ComponentModel.ActivityExecutionStatus Execute (System.Workflow.ComponentModel.ActivityExecutionContext executionContext);
abstract member Execute : System.Workflow.ComponentModel.ActivityExecutionContext -> System.Workflow.ComponentModel.ActivityExecutionStatus
override this.Execute : System.Workflow.ComponentModel.ActivityExecutionContext -> System.Workflow.ComponentModel.ActivityExecutionStatus
Protected Friend Overridable Function Execute (executionContext As ActivityExecutionContext) As ActivityExecutionStatus

매개 변수

executionContext
ActivityExecutionContext

ActivityExecutionContext 및 실행과 연결할 Activity입니다.The ActivityExecutionContext to associate with this Activity and execution.

반환

ActivityExecutionStatus

활동이 Executing 상태로 남아 있을지, Closed 상태로 전환될지 결정하는 실행 작업의 ActivityExecutionStatus입니다.The ActivityExecutionStatus of the run task, which determines whether the activity remains in the executing state, or transitions to the closed state.

예제

다음 코드 예제에서는 Execute 메서드를 구현하는 방법을 보여 줍니다.The following code example shows an implementation of the Execute method. 이 예제에서는 Outlook 전자 메일 메시지가 생성 되 고 전송 합니다.In this example, an Outlook email message is constructed and sent. 이 예제는 Outlook Workflow Wizard SDK 샘플의 일부입니다.This example is from the Outlook Workflow Wizard SDK sample. 자세한 내용은 Outlook Workflow Wizard 샘플합니다.For more information, see Outlook Workflow Wizard Sample.

protected override ActivityExecutionStatus Execute(ActivityExecutionContext context)
{
    // Create an Outlook Application object.
    Outlook.Application outlookApp = new Outlook.Application();

    Outlook._MailItem oMailItem = (Outlook._MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
    oMailItem.To = outlookApp.Session.CurrentUser.Address;
    oMailItem.Subject = "Auto-Reply";
    oMailItem.Body = "Out of Office";

    //adds it to the outbox
    if (this.Parent.Parent is ParallelActivity)
    {
        if ((this.Parent.Parent.Parent.Activities[1] as DummyActivity).TitleProperty != "")
        {
            MessageBox.Show("Process Auto-Reply for Email");
            oMailItem.Send();
        }
    }
    else if (this.Parent.Parent is SequentialWorkflowActivity)
    {
        if ((this.Parent.Parent.Activities[1] as DummyActivity).TitleProperty != "")
        {
            MessageBox.Show("Process Auto-Reply for Email");
            oMailItem.Send();
        }
    }
    return ActivityExecutionStatus.Closed;
}
Protected Overrides Function Execute(ByVal executionContext As System.Workflow.ComponentModel.ActivityExecutionContext) As System.Workflow.ComponentModel.ActivityExecutionStatus
    ' Create an Outlook Application object. 
    Dim outlookApp As Outlook.Application = New Outlook.Application()

    Dim oMailItem As Outlook._MailItem = CType(outlookApp.CreateItem(Outlook.OlItemType.olMailItem), Outlook._MailItem)
    oMailItem.MailTo = outlookApp.Session.CurrentUser.Address
    oMailItem.Subject = "Auto-Reply"
    oMailItem.Body = "Out of Office"

    Dim dummy As Activity

    If TypeOf Me.Parent.Parent Is ParallelActivity Then
        dummy = Me.Parent.Parent.Parent.Activities.Item(1)
        If Not (CType(dummy, DummyActivity).Title = "") Then
            MessageBox.Show("Process Auto-Reply for Email")
            oMailItem.Send()
        End If
    End If
    If TypeOf Me.Parent.Parent Is SequentialWorkflowActivity Then
        dummy = Me.Parent.Parent.Activities.Item(1)
        If Not (CType(dummy, DummyActivity).Title = "") Then
            MessageBox.Show("Process Auto-Reply for Email")
            oMailItem.Send()
        End If
    End If

    Return ActivityExecutionStatus.Closed
End Function

설명

ActivityExecutionContext는 현재 실행 중인 작업과 워크플로에 대 한 정보를 가져오는 데 사용 되며, 런타임 환경에서 서비스를 가져오는 데에도 사용 됩니다.The ActivityExecutionContext is used to get information about the currently running activity and workflow, and is also used to obtain services from the runtime environment.

동기적으로 실행되며, 활동이 완료되거나 중간 상태에 도달하면 호출자에게 제어가 반환됩니다.The running occurs synchronously, returning control to the caller when the activity is completed or reaches an intermediate state.

적용 대상