protected override IActivityExecutionResult OnResume(ActivityExecutionContext context) { var payload = context.GetInput <CallBridgedPayload>() !; var results = new List <IActivityExecutionResult>(); context.LogOutputProperty(this, "Received Payload", payload); if (payload.CallControlId == CallControlIdA) { CallBridgedPayloadA = payload; Output = payload; results.Add(Outcome(TelnyxOutcomeNames.LegABridged)); } if (payload.CallControlId == CallControlIdB) { CallBridgedPayloadB = payload; Output = payload; results.Add(Outcome(TelnyxOutcomeNames.LegBBridged)); } if (CallBridgedPayloadA != null && CallBridgedPayloadB != null) { results.Add(Outcome(TelnyxOutcomeNames.Bridged, new BridgedCallsOutput(CallBridgedPayloadA, CallBridgedPayloadB))); } else { results.Add(Suspend()); } return(Combine(results)); }
private IActivityExecutionResult ExecuteInternal(ActivityExecutionContext context) { var webhookModel = (TelnyxWebhook)context.Input !; if (webhookModel.Data.Payload is CallPayload callPayload) { context.WorkflowExecutionContext.CorrelationId = callPayload.CallSessionId; if (!context.HasCallControlId()) { context.SetCallControlId(callPayload.CallControlId); } if (callPayload is CallInitiatedPayload callInitiatedPayload) { if (!context.HasFromNumber()) { context.SetFromNumber(callInitiatedPayload.To); } context.SetCallerNumber(callInitiatedPayload.From); } } Model = webhookModel; Output = webhookModel.Data.Payload; context.LogOutputProperty(this, "Webhook Payload", webhookModel); return(Done()); }
protected override IActivityExecutionResult OnResume(ActivityExecutionContext context) { var triggeredSignal = context.GetInput <Signal>() !; SignalInput = triggeredSignal.Input; Output = triggeredSignal.Input; context.LogOutputProperty(this, nameof(Output), Output); return(Done()); }
private IActivityExecutionResult ExecuteInternal(ActivityExecutionContext context) { var message = (MessageModel)context.Input !; Output = message.ReadBody(MessageType, _serializer); context.LogOutputProperty(this, nameof(Output), Output); context.JournalData.Add("Headers", message.ExtractHeaders()); return(Done()); }
protected override async ValueTask <IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context) { var response = await DialAsync(context); DialResponse = response; context.LogOutputProperty(this, "Dial Response", response); return(!SuspendWorkflow ? Done(response) : Suspend()); }
private IActivityExecutionResult ExecuteInternalAsync(ActivityExecutionContext context) { if (context.Input != null) { var message = (MqttApplicationMessage)context.Input; Output = System.Text.Encoding.UTF8.GetString(message.Payload); } context.LogOutputProperty(this, nameof(Output), Output); return(Done()); }
private IActivityExecutionResult ExecuteInternalAsync(ActivityExecutionContext context) { var message = (TransportMessage)context.Input !; var messageBody = System.Text.Encoding.UTF8.GetString(message.Body); Output = messageBody; context.LogOutputProperty(this, nameof(Output), Output); context.JournalData.Add("Headers", message.Headers); return(Done()); }
protected override IActivityExecutionResult OnResume(ActivityExecutionContext context) { var payload = context.GetInput <CallPayload>(); Output = payload; context.LogOutputProperty(this, "Received Payload", payload); return(payload switch { CallAnsweredPayload => Outcome(TelnyxOutcomeNames.Answered), CallHangupPayload => Outcome(TelnyxOutcomeNames.Hangup), _ => throw new ArgumentOutOfRangeException(nameof(payload)) });
protected override IActivityExecutionResult OnResume(ActivityExecutionContext context) { var payload = context.GetInput <CallPayload>(); Output = payload; context.LogOutputProperty(this, "Output", payload); return(payload switch { CallAnsweredPayload answeredPayload => AnsweredOutcome(answeredPayload), CallHangupPayload hangupPayload => HangupOutcome(hangupPayload), CallInitiatedPayload initiatedPayload => Combine(InitiatedOutcome(initiatedPayload), Suspend()), _ => throw new ArgumentOutOfRangeException(nameof(payload)) });
protected override IActivityExecutionResult OnResume(ActivityExecutionContext context) { var eventModel = context.GetInput <TaskResultModel>() !; var outcomes = eventModel.Outcomes; if (outcomes?.Any() == false) { outcomes = new[] { OutcomeNames.Done } } ; Output = eventModel.Payload; context.LogOutputProperty(this, nameof(Output), Output); return(base.Outcomes(outcomes !)); } }
protected override async ValueTask <IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context) { var parentBlueprint = context.ActivityBlueprint.Parent; var isRoot = parentBlueprint == null; // Remove any blocking activities within the scope of the composite activity. var blockingActivities = context.WorkflowExecutionContext.WorkflowInstance.BlockingActivities; var blockingActivityIds = blockingActivities.Select(x => x.ActivityId).ToList(); var containedBlockingActivityIds = parentBlueprint == null ? blockingActivityIds : parentBlueprint.Activities.Where(x => blockingActivityIds.Contains(x.Id)).Select(x => x.Id).ToList(); var containedBlockingActivities = blockingActivities.Where(x => containedBlockingActivityIds.Contains(x.ActivityId)); foreach (var blockingActivity in containedBlockingActivities) { await context.WorkflowExecutionContext.RemoveBlockingActivityAsync(blockingActivity); } // Evict & remove any scope activities within the scope of the composite activity. var scopes = context.WorkflowInstance.Scopes.Select(x => x).Reverse().ToList(); var scopeIds = scopes.Select(x => x.ActivityId).ToList(); var containedScopeActivityIds = parentBlueprint == null ? scopeIds : parentBlueprint.Activities.Where(x => scopeIds.Contains(x.Id)).Select(x => x.Id).ToList(); foreach (var scopeId in containedScopeActivityIds) { var scopeActivity = context.WorkflowExecutionContext.GetActivityBlueprintById(scopeId) !; await context.WorkflowExecutionContext.EvictScopeAsync(scopeActivity); scopes.RemoveAll(x => x.ActivityId == scopeId); } context.WorkflowInstance.Scopes = new SimpleStack <ActivityScope>(scopes.AsEnumerable().Reverse()); // Return output. Output = new FinishOutput(ActivityOutput, OutcomeNames); context.LogOutputProperty(this, nameof(Output), Output); if (isRoot) { // Clear activity scheduler to prevent other scheduled activities from adding new blocking activities, which would prevent the workflow from completing. context.WorkflowExecutionContext.ClearScheduledActivities(); } return(Noop()); }