Auf Englisch lesen

Freigeben über


Activity.Execute(ActivityExecutionContext) Methode

Definition

Wird von der Workflowlaufzeit zum Ausführen einer Aktivität aufgerufen.

C#
protected internal virtual System.Workflow.ComponentModel.ActivityExecutionStatus Execute(System.Workflow.ComponentModel.ActivityExecutionContext executionContext);

Parameter

executionContext
ActivityExecutionContext

Der ActivityExecutionContext, der Activity und der Ausführung zuzuordnen ist.

Gibt zurück

Der ActivityExecutionStatus der Ausführungsaufgabe, die bestimmt, ob die Aktivität im Ausführzustand verbleibt oder in den Zustand Geschlossen wechselt.

Beispiele

Im folgenden Codebeispiel wird eine Implementierung der Execute-Methode veranschaulicht. In diesem Beispiel wird eine Outlook-E-Mail-Nachricht erstellt und gesendet. Dieses Beispiel stammt aus dem Outlook Workflow Wizard SDK-Beispiel. Weitere Informationen finden Sie unter Beispiel für den Outlook-Workflow-Assistenten.

C#
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;
}

Hinweise

Mit ActivityExecutionContext werden Informationen zur derzeit ausgeführten Aktivität und zum Workflow sowie Dienste aus der Laufzeitumgebung abgerufen.

Die Ausführung vollzieht sich synchron, wobei die Steuerung bei Beenden der Aktivität oder bei Erreichen eines temporären Zustands wieder dem Aufrufenden übergeben wird.

Gilt für:

Produkt Versionen
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1