Esempio n. 1
0
        protected override void Execute(NativeActivityContext context)
        {
            Log.Debug("FinalActivity -> Start");

            // TODO. update any workflow Out properties
            var workflowStatus = context.GetExtension <WorkflowStateData>();

            using (var proxy = new Proxy.FlowTasksService())
            {
                proxy.CompleteWorkflow(new CompleteWorkflowRequest
                {
                    WorkflowId         = context.WorkflowInstanceId.ToString(),
                    WorkflowStatusType = WorkflowStatusType.Completed,
                    Result             = workflowStatus.Result
                });

                if (!string.IsNullOrWhiteSpace(CurrentRequest.Get(context).ParentWorkflowId) &&
                    CurrentRequest.Get(context).WaitForChild)
                {
                    proxy.WorkflowEvent(new WorkflowEventRequest
                    {
                        WorkflowId    = CurrentRequest.Get(context).ParentWorkflowId,
                        CurrentId     = context.WorkflowInstanceId.ToString(),
                        CorrelationId = CurrentRequest.Get(context).CorrelationId,
                        Result        = workflowStatus.Result,
                        Event         = "Completed"
                    });
                }
            }


            Log.Debug("FinalActivity -> End");
        }
Esempio n. 2
0
        protected override void Execute(NativeActivityContext context)
        {
            Log.Debug("CreateResponseForTerminateWorkflow -> Start");

            var workflowStatus = context.GetExtension <WorkflowStateData>();

            workflowStatus.Result = WorkflowStatusType.Terminated.ToString();

            using (var proxy = new Proxy.FlowTasksService())
            {
                proxy.CompleteWorkflow(new CompleteWorkflowRequest
                {
                    WorkflowId         = context.WorkflowInstanceId.ToString(),
                    WorkflowStatusType = WorkflowStatusType.Terminated,
                    Result             = workflowStatus.Result,
                    Message            = Request.Get(context).Message
                });
            }

            Log.Debug("CreateResponseForTerminateWorkflow -> End");

            Result.Set(context, new TerminateWorkflowResponse
            {
                Ack = Library.Properties.Resources.SUCCESS_RESULT
            });
        }
Esempio n. 3
0
        protected override void Execute(NativeActivityContext context)
        {
            Log.Debug("CatchActivity -> Start");

            var er = new StringBuilder();

            er.AppendLine(string.Format("Message: {0}", Request.Get(context).Message));
            er.AppendLine(string.Format("InnerException: {0}", Request.Get(context).InnerException));
            er.AppendLine(string.Format("StackTrace: {0}", Request.Get(context).StackTrace));

            var workflowStatus = context.GetExtension <WorkflowStateData>();

            workflowStatus.Result = WorkflowStatusType.Aborted.ToString();

            using (var proxy = new Proxy.FlowTasksService())
            {
                proxy.CompleteWorkflow(new CompleteWorkflowRequest
                {
                    WorkflowId         = context.WorkflowInstanceId.ToString(),
                    WorkflowStatusType = WorkflowStatusType.Aborted,
                    Result             = workflowStatus.Result,
                    Message            = er.ToString()
                });
            }

            Log.Debug(er);

            Log.Debug("CatchActivity -> End");
        }
Esempio n. 4
0
        /// <summary>
        /// Create task
        /// </summary>
        /// <param name="context">NativeActivityContext</param>
        /// <param name="taskInfo">TaskInfo</param>
        /// <param name="properties">Properties</param>
        private void CreateTask(NativeActivityContext context, TaskInfo taskInfo, Dictionary <string, string> properties)
        {
            Log.Debug("InitializeApprove -> Assigned users: " + taskInfo.AssignedToUsers);

            var taskOid = Guid.NewGuid();

            taskInfo.TaskOid = taskOid;

            var props = new List <Contract.Message.PropertyInfo>();

            if (properties != null)
            {
                foreach (var p in properties)
                {
                    props.Add(new Contract.Message.PropertyInfo {
                        Name = p.Key, Value = p.Value
                    });
                }
            }

            using (var proxy = new Proxy.FlowTasksService())
            {
                proxy.CreateTask(new CreateTaskRequest
                {
                    WorkflowId = context.WorkflowInstanceId.ToString(),
                    TaskInfo   = taskInfo,
                    Properties = new PropertyInfos(props)
                });
            }
        }
Esempio n. 5
0
        /// <summary>
        /// OnChildWorkflowComplete Callback
        /// </summary>
        /// <remarks>
        /// Runs after Child workflow complete. Only for synchronous
        /// </remarks>
        /// <param name="context">NativeActivityContext</param>
        /// <param name="completedInstance">ActivityInstance</param>
        private void OnChildWorkflowCompleteCallback(NativeActivityContext context, ActivityInstance completedInstance)
        {
            Logger.Debug("OnChildWorkflowCompleteCallback -> Start");

            GetWorkflowResultResponse res;

            using (var proxy = new Proxy.FlowTasksService())
            {
                res = proxy.GetWorkflowResult(new GetWorkflowResultRequest
                {
                    WorkflowId = WorkflowId.Get(context)
                });
            }

            WorkflowResult.Set(context, res.WorkflowResultInfo.Result);

            Logger.Debug("OnChildWorkflowCompleteCallback -> End");
        }
Esempio n. 6
0
        /// <summary>
        /// Create Workflow From Request
        /// </summary>
        /// <param name="context">NativeActivityContext</param>
        /// <returns>Workflow Id</returns>
        private Guid CreateWorkflowFromRequest(NativeActivityContext context)
        {
            var parentId  = Request.Get(context).ParentWorkflowId;
            var parentOid = string.IsNullOrWhiteSpace(parentId) ? Guid.Empty : Guid.Parse(parentId);

            using (var proxy = new Proxy.FlowTasksService())
            {
                proxy.CreateWorkflow(new CreateWorkflowRequest
                {
                    WorkflowId       = context.WorkflowInstanceId.ToString(),
                    ParentWorkflowId = parentOid.ToString(),
                    WorkflowCode     = Request.Get(context).WorkflowCode,
                    Domain           = Request.Get(context).Domain,
                    PropertyInfos    = new PropertyInfos(GetParametersFromRequest(Request.Get(context)))
                });
            }

            return(context.WorkflowInstanceId);
        }
Esempio n. 7
0
        /// <summary>
        /// Invoke Workflow
        /// </summary>
        /// <remarks>
        /// Start a new WorkflowCode workflow.
        /// </remarks>
        /// <param name="parentWorkflowId">Parent Workflow Id</param>
        /// <param name="workflowCode">Workflow Code</param>
        /// <param name="domain">Domain</param>
        /// <param name="properties">Properties</param>
        /// <param name="async">async</param>
        /// <returns>Workflow Id</returns>
        private string InvokeWorkflow(Guid parentWorkflowId, string workflowCode, string domain, Dictionary <string, string> properties, bool async)
        {
            var startWorkflowRequest = new StartWorkflowRequest
            {
                ParentWorkflowId = parentWorkflowId.ToString(),
                Domain           = domain,
                WorkflowCode     = workflowCode,
                WfRuntimeValues  = CreatePropertiesFromDictionary(properties),
                CorrelationId    = CorrelationId,
                WaitForChild     = !async
            };

            StartWorkflowResponse startWorkflowResponse;

            using (var proxy = new Proxy.FlowTasksService())
            {
                startWorkflowResponse = proxy.StartWorkflow(startWorkflowRequest);
            }

            string workflowId = startWorkflowResponse.WorkflowId;

            return(workflowId);
        }