public IRequest Marshall(DescribeWorkflowExecutionRequest describeWorkflowExecutionRequest)
        {
            IRequest request = new DefaultRequest(describeWorkflowExecutionRequest, "AmazonSimpleWorkflow");
            string   target  = "SimpleWorkflowService.DescribeWorkflowExecution";

            request.Headers["X-Amz-Target"] = target;

            request.Headers["Content-Type"] = "application/x-amz-json-1.0";

            string uriResourcePath = "";

            request.ResourcePath = uriResourcePath;


            using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture))
            {
                JsonWriter writer = new JsonWriter(stringWriter);
                writer.WriteObjectStart();

                if (describeWorkflowExecutionRequest != null && describeWorkflowExecutionRequest.IsSetDomain())
                {
                    writer.WritePropertyName("domain");
                    writer.Write(describeWorkflowExecutionRequest.Domain);
                }

                if (describeWorkflowExecutionRequest != null)
                {
                    WorkflowExecution execution = describeWorkflowExecutionRequest.Execution;
                    if (execution != null)
                    {
                        writer.WritePropertyName("execution");
                        writer.WriteObjectStart();
                        if (execution != null && execution.IsSetWorkflowId())
                        {
                            writer.WritePropertyName("workflowId");
                            writer.Write(execution.WorkflowId);
                        }
                        if (execution != null && execution.IsSetRunId())
                        {
                            writer.WritePropertyName("runId");
                            writer.Write(execution.RunId);
                        }
                        writer.WriteObjectEnd();
                    }
                }

                writer.WriteObjectEnd();

                string snippet = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(snippet);
            }


            return(request);
        }
Example #2
0
        public void CanTrigger_InitialStateIsOff_CanTriggerToStateOn()
        {
            // Arrange
            Switcher switcher = new Switcher
            {
                Type = OnOffWorkflow.TYPE
            };

            WorkflowExecution execution = new WorkflowExecution(new OnOffWorkflow());

            // Act
            TriggerResult result = execution.CanTrigger(new TriggerParam("SwitchOn", switcher));

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(true, result.CanTrigger);
        }
Example #3
0
        public void GetTriggers_InitialStateIsOff_TriggerNameIsSwitchOn()
        {
            // Arrange
            Switcher switcher = new Switcher
            {
                Type = OnOffWorkflow.TYPE
            };

            WorkflowExecution execution = new WorkflowExecution(new OnOffWorkflow());

            // Act
            IEnumerable <TriggerResult> result = execution.GetTriggers(switcher);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count());
            Assert.AreEqual("SwitchOn", result.First().TriggerName);
        }
Example #4
0
        public void Trigger_InitialStateIsOff_StateIsOn()
        {
            // Arrange
            Switcher switcher = new Switcher
            {
                Type = OnOffWorkflow.TYPE
            };
            WorkflowExecution execution = new WorkflowExecution(new OnOffWorkflow());

            // Act
            TriggerResult result = execution.Trigger(new TriggerParam("SwitchOn", switcher));

            // Assert
            Assert.IsNotNull(switcher);
            Assert.AreEqual("On", result.CurrentState);

            Assert.IsNotNull(result);
            Assert.AreEqual("SwitchOn", result.TriggerName);
        }
Example #5
0
        public void Trigger_InitialStateIsOn_StateIsOff()
        {
            // Arrange
            Switcher switcher = new Switcher
            {
                Type  = OnOffWorkflow.TYPE,
                State = "On"
            };
            WorkflowExecution execution = new WorkflowExecution(new OnOffWorkflow());

            // Act
            TriggerResult result = execution.Trigger(new TriggerParam("SwitchOff", switcher));

            // Assert
            Assert.NotNull(switcher);
            Assert.Equal("Off", result.CurrentState);

            Assert.NotNull(result);
            Assert.Equal("SwitchOff", result.TriggerName);
            Assert.False(result.HasAutoTrigger);
        }
Example #6
0
        public void CanTrigger_InitialStateIsOff_CanNotTriggerToStateOn()
        {
            // Arrange
            Switcher switcher = new Switcher
            {
                Type = OnOffWorkflow.TYPE
            };

            WorkflowExecution execution = new WorkflowExecution(new OnOffWorkflow());

            var variables = new Dictionary <string, WorkflowVariableBase>();
            var variable  = new SwitcherWorkflowVariable(false);

            variables.Add(SwitcherWorkflowVariable.KEY, variable);
            var triggerParam = new TriggerParam("SwitchOn", switcher, variables);

            // Act
            TriggerResult result = execution.CanTrigger(triggerParam);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(false, result.CanTrigger);
        }
Example #7
0
        public IRequest Marshall(GetWorkflowExecutionHistoryRequest getWorkflowExecutionHistoryRequest)
        {
            IRequest request = new DefaultRequest(getWorkflowExecutionHistoryRequest, "AmazonSimpleWorkflow");
            string   target  = "SimpleWorkflowService.GetWorkflowExecutionHistory";

            request.Headers["X-Amz-Target"] = target;
            request.Headers["Content-Type"] = "application/x-amz-json-1.0";

            using (StringWriter stringWriter = new StringWriter())
            {
                JsonWriter writer = new JsonWriter(stringWriter);
                writer.WriteObjectStart();

                if (getWorkflowExecutionHistoryRequest != null && getWorkflowExecutionHistoryRequest.IsSetDomain())
                {
                    writer.WritePropertyName("domain");
                    writer.Write(getWorkflowExecutionHistoryRequest.Domain);
                }

                if (getWorkflowExecutionHistoryRequest != null)
                {
                    WorkflowExecution execution = getWorkflowExecutionHistoryRequest.Execution;
                    if (execution != null)
                    {
                        writer.WritePropertyName("execution");
                        writer.WriteObjectStart();
                        if (execution != null && execution.IsSetWorkflowId())
                        {
                            writer.WritePropertyName("workflowId");
                            writer.Write(execution.WorkflowId);
                        }
                        if (execution != null && execution.IsSetRunId())
                        {
                            writer.WritePropertyName("runId");
                            writer.Write(execution.RunId);
                        }
                        writer.WriteObjectEnd();
                    }
                }
                if (getWorkflowExecutionHistoryRequest != null && getWorkflowExecutionHistoryRequest.IsSetNextPageToken())
                {
                    writer.WritePropertyName("nextPageToken");
                    writer.Write(getWorkflowExecutionHistoryRequest.NextPageToken);
                }
                if (getWorkflowExecutionHistoryRequest != null && getWorkflowExecutionHistoryRequest.IsSetMaximumPageSize())
                {
                    writer.WritePropertyName("maximumPageSize");
                    writer.Write(getWorkflowExecutionHistoryRequest.MaximumPageSize);
                }
                if (getWorkflowExecutionHistoryRequest != null && getWorkflowExecutionHistoryRequest.IsSetReverseOrder())
                {
                    writer.WritePropertyName("reverseOrder");
                    writer.Write(getWorkflowExecutionHistoryRequest.ReverseOrder);
                }

                writer.WriteObjectEnd();

                string snippet = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(snippet);
                return(request);
            }
        }
 public int CompleteWorkFlowExecution(WorkflowExecution execution)
 {
     return(dataAccess.CompleteWorkFlowExecution(execution));
 }
 public int StartWorkFlowExecution(WorkflowExecution execution)
 {
     return(dataAccess.StartWorkFlowExecution(execution));
 }
Example #10
0
 /// <summary>
 /// Internal constructor.
 /// </summary>
 /// <param name="execution">The workflow's execution information.</param>
 internal InternalWorkflowExecution(WorkflowExecution execution)
 {
     this.WorkflowId = execution.WorkflowId;
     this.RunId      = execution.RunId;
 }
Example #11
0
        /// <summary>
        /// Creates a stub for an existing child workflow specified by a <see cref="WorkflowExecution"/>.
        /// </summary>
        /// <param name="client">The associated <see cref="CadenceClient"/>.</param>
        /// <param name="dataConverter">The data converter.</param>
        /// <param name="parentWorkflow">The parent workflow.</param>
        /// <param name="execution">The <see cref="WorkflowExecution"/>.</param>
        /// <returns>The workflow stub as an <see cref="object"/>.</returns>
        public object Create(CadenceClient client, IDataConverter dataConverter, Workflow parentWorkflow, WorkflowExecution execution)
        {
            Covenant.Requires <ArgumentNullException>(client != null, nameof(client));
            Covenant.Requires <ArgumentNullException>(dataConverter != null, nameof(dataConverter));
            Covenant.Requires <ArgumentNullException>(parentWorkflow != null, nameof(parentWorkflow));
            Covenant.Requires <ArgumentNullException>(execution != null, nameof(execution));

            return(childExternalConstructor.Invoke(new object[] { client, dataConverter, parentWorkflow, execution }));
        }
Example #12
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="execution">The child workflow's execution information.</param>
 /// <param name="childId">
 /// The child workflow's local ID.  This is used to identify the
 /// child when communicating with <b>cadence-proxy</b>.
 /// </param>
 internal ChildExecution(WorkflowExecution execution, long childId)
 {
     this.Execution = execution;
     this.ChildId   = childId;
 }
Example #13
0
 public int StartWorkFlowExecution([FromBody] WorkflowExecution value)
 {
     return(workFloor.StartWorkFlowExecution(value));
 }
Example #14
0
        public IRequest Marshall(GetWorkflowExecutionHistoryRequest getWorkflowExecutionHistoryRequest)
        {
            IRequest request = new DefaultRequest(getWorkflowExecutionHistoryRequest, "AmazonSimpleWorkflow");
            string   target  = "SimpleWorkflowService.GetWorkflowExecutionHistory";

            request.Headers["X-Amz-Target"] = target;

            request.Headers["Content-Type"] = "application/x-amz-json-1.0";


            string uriResourcePath = "";

            if (uriResourcePath.Contains("?"))
            {
                int    queryPosition = uriResourcePath.IndexOf("?", StringComparison.OrdinalIgnoreCase);
                string queryString   = uriResourcePath.Substring(queryPosition + 1);
                uriResourcePath = uriResourcePath.Substring(0, queryPosition);

                foreach (string s in queryString.Split('&', ';'))
                {
                    string[] nameValuePair = s.Split('=');
                    if (nameValuePair.Length == 2 && nameValuePair[1].Length > 0)
                    {
                        request.Parameters.Add(nameValuePair[0], nameValuePair[1]);
                    }
                    else
                    {
                        request.Parameters.Add(nameValuePair[0], null);
                    }
                }
            }

            request.ResourcePath = uriResourcePath;


            using (StringWriter stringWriter = new StringWriter(System.Globalization.CultureInfo.InvariantCulture))
            {
                JsonWriter writer = new JsonWriter(stringWriter);
                writer.WriteObjectStart();

                if (getWorkflowExecutionHistoryRequest != null && getWorkflowExecutionHistoryRequest.IsSetDomain())
                {
                    writer.WritePropertyName("domain");
                    writer.Write(getWorkflowExecutionHistoryRequest.Domain);
                }

                if (getWorkflowExecutionHistoryRequest != null)
                {
                    WorkflowExecution execution = getWorkflowExecutionHistoryRequest.Execution;
                    if (execution != null)
                    {
                        writer.WritePropertyName("execution");
                        writer.WriteObjectStart();
                        if (execution != null && execution.IsSetWorkflowId())
                        {
                            writer.WritePropertyName("workflowId");
                            writer.Write(execution.WorkflowId);
                        }
                        if (execution != null && execution.IsSetRunId())
                        {
                            writer.WritePropertyName("runId");
                            writer.Write(execution.RunId);
                        }
                        writer.WriteObjectEnd();
                    }
                }
                if (getWorkflowExecutionHistoryRequest != null && getWorkflowExecutionHistoryRequest.IsSetNextPageToken())
                {
                    writer.WritePropertyName("nextPageToken");
                    writer.Write(getWorkflowExecutionHistoryRequest.NextPageToken);
                }
                if (getWorkflowExecutionHistoryRequest != null && getWorkflowExecutionHistoryRequest.IsSetMaximumPageSize())
                {
                    writer.WritePropertyName("maximumPageSize");
                    writer.Write(getWorkflowExecutionHistoryRequest.MaximumPageSize);
                }
                if (getWorkflowExecutionHistoryRequest != null && getWorkflowExecutionHistoryRequest.IsSetReverseOrder())
                {
                    writer.WritePropertyName("reverseOrder");
                    writer.Write(getWorkflowExecutionHistoryRequest.ReverseOrder);
                }

                writer.WriteObjectEnd();

                string snippet = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(snippet);
            }


            return(request);
        }
        public IRequest Marshall(DescribeWorkflowExecutionRequest describeWorkflowExecutionRequest)
        {
            IRequest request = new DefaultRequest(describeWorkflowExecutionRequest, "AmazonSimpleWorkflow");
            string   target  = "SimpleWorkflowService.DescribeWorkflowExecution";

            request.Headers["X-Amz-Target"] = target;
            request.Headers["Content-Type"] = "application/x-amz-json-1.0";



            string uriResourcePath = "";

            if (uriResourcePath.Contains("?"))
            {
                string queryString = uriResourcePath.Substring(uriResourcePath.IndexOf("?") + 1);
                uriResourcePath = uriResourcePath.Substring(0, uriResourcePath.IndexOf("?"));

                foreach (string s in queryString.Split('&', ';'))
                {
                    string[] nameValuePair = s.Split('=');
                    if (nameValuePair.Length == 2 && nameValuePair[1].Length > 0)
                    {
                        request.Parameters.Add(nameValuePair[0], nameValuePair[1]);
                    }
                    else
                    {
                        request.Parameters.Add(nameValuePair[0], null);
                    }
                }
            }

            request.ResourcePath = uriResourcePath;


            using (StringWriter stringWriter = new StringWriter())
            {
                JsonWriter writer = new JsonWriter(stringWriter);
                writer.WriteObjectStart();

                if (describeWorkflowExecutionRequest != null && describeWorkflowExecutionRequest.IsSetDomain())
                {
                    writer.WritePropertyName("domain");
                    writer.Write(describeWorkflowExecutionRequest.Domain);
                }

                if (describeWorkflowExecutionRequest != null)
                {
                    WorkflowExecution execution = describeWorkflowExecutionRequest.Execution;
                    if (execution != null)
                    {
                        writer.WritePropertyName("execution");
                        writer.WriteObjectStart();
                        if (execution != null && execution.IsSetWorkflowId())
                        {
                            writer.WritePropertyName("workflowId");
                            writer.Write(execution.WorkflowId);
                        }
                        if (execution != null && execution.IsSetRunId())
                        {
                            writer.WritePropertyName("runId");
                            writer.Write(execution.RunId);
                        }
                        writer.WriteObjectEnd();
                    }
                }

                writer.WriteObjectEnd();

                string snippet = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(snippet);
            }


            return(request);
        }