Ejemplo n.º 1
0
        /// <summary>
        /// Orchestration using REST services, this orchestration signals the above orchestration which waits for an external signal.
        /// </summary>
        /// <param name="aws"></param>
        /// <returns></returns>
        static async Task RestSequence(AWS aws)
        {
            var orchestrationFactory = new AWSOrchestrationFactory(aws.AccessKeyID, aws.SecretAccessKey, aws.Region, true, aws.LambdaRole);

            var orchestration = await orchestrationFactory.CreateOrchestrationAsync("RESTSequence1");

            try
            {
                await orchestration.StartWorkflowAsync("REST Workflow Started");

                var url = "http://dummy.restapiexample.com/api/v1/";

                var a = await orchestration.CallGetAsync <DummyResponse>(url + "employees", null, null, "ServiceOperation1");

                var b = await orchestration.CallPostAsync <DummyResponse>(url + "create", null, null, null, "ServiceOperation2");

                var c = await orchestration.CallPutAsync <DummyResponse>(url + "update/21", null, null, null, "ServiceOperation3");

                var d = await orchestration.CallDeleteAsync <DummyResponse>(url + "delete/21", null, null, "ServiceOperation4");

                await orchestration.RaiseEventAsync("Approve", "Sequence3", true);

                await orchestration.CompleteWorkflowAsync(d);
            }
            catch (Exception ex)
            {
                await orchestration.FailWorkflowAsync(ex);
            }

            var currentState = await orchestration.GetCurrentState();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Orchestration using AWS Lambda functions
        /// </summary>
        /// <param name="aws"></param>
        /// <returns></returns>
        static async Task Sequence(AWS aws)
        {
            /// Initialize orchestration factory for AWS
            var orchestrationFactory = new AWSOrchestrationFactory(aws.AccessKeyID, aws.SecretAccessKey, aws.Region, true, aws.LambdaRole);

            /// Create a new orchestration
            var orchestration = await orchestrationFactory.CreateOrchestrationAsync("Sequence3");

            try {
                /// Start workflow
                await orchestration.StartWorkflowAsync("Workflow Started");

                /// Call AWS lambda task
                var a = await orchestration.CallTaskAsync <Numbers>("Number", new Numbers { Number1 = 15, Number2 = 5 }, "Operation1");

                var b = await orchestration.CallTaskAsync <OperationResult>("Sum", a, "Operation2");

                var c = await orchestration.CallTaskAsync <OperationResult>("Difference", a, "Operation3");

                var d = await orchestration.CallTaskAsync <OperationResult>("Product", a, "Operation4");

                var e = await orchestration.CallTaskAsync <OperationResult>("Quotient", a, "Operation5");

                /// Start timer
                await orchestration.StartTimerAsync("30SecTimer", new TimeSpan(0, 0, 0, 30, 0));

                /// Wait for user input
                var approved = await orchestration.WaitForEventAsync <bool>("Approve");

                /// Complete workflow
                await orchestration.CompleteWorkflowAsync(e);
            }
            catch (Exception ex)
            {
                /// Fail workflow
                await orchestration.FailWorkflowAsync(ex);
            }

            var currentState = await orchestration.GetCurrentState();
        }
Ejemplo n.º 3
0
        public async Task <Model.Workflow> ProcessAsync(Request request, ILambdaContext context)
        {
            /// Initialize orchestration factory for AWS
            var orchestrationFactory = new AWSOrchestrationFactory(true, request.LambdaRole);

            context.Logger.LogLine(JsonConvert.SerializeObject(request));
            /// Create a new .
            var orchestration = await orchestrationFactory.CreateOrchestrationAsync(request.OrchestrationId);

            context.Logger.LogLine("Created");
            try
            {
                /// Start workflow
                await orchestration.StartWorkflowAsync("Workflow Started");

                context.Logger.LogLine("Started");

                /// Call AWS lambda task
                var a = await orchestration.CallTaskAsync <Numbers>("Number", request.Numbers, "Operation1");

                context.Logger.LogLine("Operation1");

                var b = await orchestration.CallTaskAsync <OperationResult>("Sum", a, "Operation2");

                context.Logger.LogLine("Operation2");

                var c = await orchestration.CallTaskAsync <OperationResult>("Difference", a, "Operation3");

                context.Logger.LogLine("Operation3");

                var d = await orchestration.CallTaskAsync <OperationResult>("Product", a, "Operation4");

                context.Logger.LogLine("Operation4");

                var e = await orchestration.CallTaskAsync <OperationResult>("Quotient", a, "Operation5");

                context.Logger.LogLine("Operation5");
                /// Start timer
                await orchestration.StartTimerAsync("30SecTimer", new TimeSpan(0, 0, 0, 30, 0));

                context.Logger.LogLine("30SecTimer");

                /// Wait for user input
                var approved = await orchestration.WaitForEventAsync <bool>("Approve");

                context.Logger.LogLine("Approved");

                /// Complete workflow
                await orchestration.CompleteWorkflowAsync(e);

                context.Logger.LogLine("Complete");
            }
            catch (Exception ex)
            {
                /// Fail workflow
                await orchestration.FailWorkflowAsync(ex);

                context.Logger.LogLine("Fail");
                context.Logger.LogLine(ex.Message);
                context.Logger.LogLine(ex.StackTrace);
            }

            var currentState = await orchestration.GetCurrentState();

            return(currentState);
        }