Delen via


Voorbeeld: Azure-bewuste aangepaste werkstroomactiviteit

 

Gepubliceerd: januari 2017

Is van toepassing op: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online

Dit voorbeeld verkrijgt de gegevenscontext uit de huidige Microsoft Dynamics 365-bewerking en stuurt deze naar de Microsoft Azure Service Bus.

Deze voorbeeldcode is voor Microsoft Dynamics 365 (online en on-premises). Download het Microsoft Dynamics CRM SDK-pakket. U vindt deze code op de volgende locatie in het downloadpakket:

SampleCode\CS\Azure\AzureAwareWorkflowActivity\Activity.cs

Vereisten

U moet Microsoft Dynamics 365 configureren om verbinding te maken met Microsoft Azure voordat u dit voorbeeld van aangepaste werkstroomactiviteit registreert en uitvoert.Meer informatie:Azure-integratie met Microsoft Dynamics 365 configureren.

U ziet het vereiste argument “Input id” in de code. Als u deze activiteit aan een werkstroom toevoegt, moet u de GUID verschaffen van een Microsoft Azure-service-eindpunt.Meer informatie:Maak een service-eindpuntconfiguratie.

Wanneer u zich voor deze aangepaste werkstroomactiviteit registreert met Microsoft Dynamics 365 (online), moet u deze in de sandbox (gedeeltelijk vertrouwd) registreren.

Voor meer informatie over de vereisten voor het uitvoeren van de voorbeeldcode in deze SDK, zie Het voorbeeld en de helpercode gebruiken.

Demonstreert

Dit voorbeeld toont hoe u een aangepaste werkstroomactiviteit schrijft die de gegevenscontext van de huidige Microsoft Dynamics 365-bewerking naar de Microsoft Azure Service Bus kan sturen. Het versturen van de gegevenscontext wordt uitgevoerd door de methode Execute.

Voorbeeld


// 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; }
    }
}

Zie ook

IServiceEndpointNotificationService
Voorbeeldcode voor integratie van Microsoft Dynamics 365 en Microsoft Azure
Voorbeeld: persistente wachtrijlistener
Aangepaste workflowactiviteiten (workflowassemblies)

Microsoft Dynamics 365

© 2017 Microsoft. Alle rechten voorbehouden. Auteursrecht