public async Task RunAction(
            [ActivityTrigger] IDurableActivityContext context,
            ILogger logger)
        {
            WorkflowMessageEnvelope envelope =
                context.GetInputWithCustomSerializationSettings <WorkflowMessageEnvelope>(this.serializerSettingsProvider.Instance);

            var    workflowTrigger = (HostedWorkflowTrigger)envelope.Trigger;
            string instanceId      = envelope.GetWorkflowInstanceId();

            logger.LogInformation(
                $"Making function call to process trigger {workflowTrigger.Id} for instance {instanceId}");

            var subjects = new ObservableCollection <string>();

            workflowTrigger.Subjects?.ForEach(subjects.Add);

            var body = new Trigger
            {
                Id          = workflowTrigger.Id,
                Subjects    = subjects,
                TriggerName = workflowTrigger.TriggerName,
                Parameters  = workflowTrigger.Parameters,
            };

            await this.client.SendTriggerAsync(envelope.TenantId, instanceId, body);
        }
        public async Task <int> RunAction(
            [ActivityTrigger] IDurableActivityContext context)
        {
            WorkflowMessageEnvelope envelope =
                context.GetInputWithCustomSerializationSettings <WorkflowMessageEnvelope>(this.serializerSettingsProvider.Instance);

            ITenant tenant = await this.tenantProvider.GetTenantAsync(envelope.TenantId);

            IWorkflowInstanceStore instanceStore = await this.workflowInstanceStoreFactory.GetWorkflowInstanceStoreForTenantAsync(tenant);

            return(await instanceStore.GetMatchingWorkflowInstanceCountForSubjectsAsync(envelope.Trigger.GetSubjects()));
        }
        public async Task <string[]> RunAction(
            [ActivityTrigger] IDurableActivityContext context)
        {
            WorkflowMessageEnvelope envelope =
                context.GetInputWithCustomSerializationSettings <WorkflowMessageEnvelope>(this.serializerSettingsProvider.Instance);

            ITenant tenant = await this.tenantProvider.GetTenantAsync(envelope.TenantId);

            IWorkflowInstanceStore instanceStore =
                await this.workflowInstanceStoreFactory.GetWorkflowInstanceStoreForTenantAsync(tenant);

            IEnumerable <string> instanceIds = await instanceStore.GetMatchingWorkflowInstanceIdsForSubjectsAsync(
                envelope.Trigger.GetSubjects(),
                500,
                envelope.GetWorkflowInstancesPageNumber());

            return(instanceIds.ToArray());
        }
Пример #4
0
        public async Task RunAction(
            [ActivityTrigger] IDurableActivityContext context,
            ILogger logger)
        {
            WorkflowMessageEnvelope envelope =
                context.GetInputWithCustomSerializationSettings <WorkflowMessageEnvelope>(this.serializerSettingsProvider.Instance);

            logger.LogInformation(
                $"Making function call for StartWorkflowInstanceRequest {envelope.StartWorkflowInstanceRequest.RequestId}");

            var body = new StartWorkflowRequest
            {
                Context            = envelope.StartWorkflowInstanceRequest.Context,
                WorkflowId         = envelope.StartWorkflowInstanceRequest.WorkflowId,
                WorkflowInstanceId = envelope.StartWorkflowInstanceRequest.WorkflowInstanceId,
                RequestId          = envelope.StartWorkflowInstanceRequest.RequestId,
            };

            await this.engineClient.StartWorkflowInstanceAsync(envelope.TenantId, body);
        }