다음을 통해 공유


Activity.Execute(ActivityExecutionContext) 메서드

정의

활동을 실행하기 위해 워크플로 런타임에서 호출됩니다.

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입니다.

반환

활동이 Executing 상태로 남아 있을지, Closed 상태로 전환될지 결정하는 실행 작업의 ActivityExecutionStatus입니다.

예제

다음 코드 예제에서는 Execute 메서드를 구현하는 방법을 보여 줍니다. 이 예제에서는 Outlook 전자 메일 메시지가 생성되고 전송됩니다. 이 예제는 Outlook Workflow Wizard SDK 샘플의 일부입니다. 자세한 내용은 Outlook Workflow Wizard 샘플합니다.

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 현재 실행 중인 작업 및 워크플로에 대한 정보를 가져오는 데 사용되며 런타임 환경에서 서비스를 가져오는 데도 사용됩니다.

실행은 동기적으로 발생하며, 작업이 완료되거나 중간 상태에 도달하면 호출자에게 컨트롤을 반환합니다.

적용 대상