Share via


Beispiel: Azure-fähige benutzerdefinierte Workflowaktivität

 

Veröffentlicht: Januar 2017

Gilt für: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online

Dieses Beispiel erhält den Datenkontext aus dem aktuellen Microsoft Dynamics 365-Prozess und veröffentlicht sie in Microsoft Azure Service Bus.

Dieser Beispielcode ist für Microsoft Dynamics 365 (online und lokal). Laden Sie das Microsoft Dynamics CRM SDK-Paket herunter. Dieser Code ist an folgender Position im Downloadpaket verfügbar:

SampleCode\CS\Azure\AzureAwareWorkflowActivity\Activity.cs

Anforderungen

Sie müssen die Microsoft Dynamics 365 für die Verbindung mit Microsoft Azure konfigurieren, bevor Sie sich anmelden und diese benutzerdefinierte Beispiel-Workflowaktivität ausführen.Weitere Informationen:Konfigurieren der Azure-Integration in Microsoft Dynamics 365.

Beachten Sie das erforderliche “Input id”-Argument im Code. Wenn Sie diese Aktivität zu einem Workflow hinzufügen, müssen Sie die GUID des Microsoft Azure Dienstendpunkts zur Verfügung stellen.Weitere Informationen:Erstellen Sie eine Dienstendpunkt-Konfiguration.

Wenn Sie diese benutzerdefinierte Workflowaktivität bei Microsoft Dynamics 365 (online) registrieren, müssen Sie es im Sandkasten (mit teilweiser Vertrauenswürdigkeit) registrieren.

Weitere Informationen zu den Anforderungen zum Ausführen des in diesem SDK enthaltenen Beispielcodes finden Sie unter Verwenden des Beispiel- und Hilfscode.

Demonstriert

Dieses Beispiel zeigt, wie Sie eine benutzerdefinierte Workflowaktivität schreiben, die den Datenkontext vom aktuellen Microsoft Azure Service Bus-Vorgang im Microsoft Dynamics 365 veröffentlichen kann. Das Veröffentlichen des Datenkontexts wird durch die Execute-Methode ausgeführt.

Beispiel


// This namespace is found in the System.Activities.dll assembly.
using System.Activities;

// This namespace is found in the Microsoft.Xrm.Sdk.dll assembly
// located in the SDK\bin folder of the SDK download.
using Microsoft.Xrm.Sdk;

// This namespace is found in the Microsoft.Xrm.Sdk.Workflow.dll assembly
// located in the SDK\bin folder of the SDK download.
using Microsoft.Xrm.Sdk.Workflow;

namespace Microsoft.Crm.Sdk.Samples
{
    /// <summary>
    /// This class is able to post the execution context to the Windows Azure 
    /// Service Bus.
    /// </summary>
    public class AzureAwareWorkflowActivity : CodeActivity
    {
        /// <summary>
        /// This method is called when the workflow executes.
        /// </summary>
        /// <param name="executionContext">The data for the event triggering
        /// the workflow.</param>
        protected override void Execute(CodeActivityContext executionContext)
        {
            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();

            IServiceEndpointNotificationService endpointService =
                     executionContext.GetExtension<IServiceEndpointNotificationService>();
            endpointService.Execute(ServiceEndpoint.Get(executionContext), context);
        }

        /// <summary>
        /// Enables the service endpoint to be provided when this activity is added as a 
        /// step in a workflow.
        /// </summary>
        [RequiredArgument]
        [ReferenceTarget("serviceendpoint")]
        [Input("Input id")]
        public InArgument<EntityReference> ServiceEndpoint { get; set; }
    }
}

Siehe auch

IServiceEndpointNotificationService
Beispielcode für Microsoft Dynamics 365- und Microsoft Azure-Integration
Beispiel: Persistenter Warteschlangenlistener
Benutzerdefinierte Workflowaktivitäten (Workflowassemblys)

Microsoft Dynamics 365

© 2017 Microsoft. Alle Rechte vorbehalten. Copyright