示例#1
0
        /// <summary>
        /// Processes the specified <see cref="Rock.Model.Workflow" />
        /// </summary>
        /// <param name="workflow">The <see cref="Rock.Model.Workflow" /> instance to process.</param>
        /// <param name="errorMessages">A <see cref="System.Collections.Generic.List{String}" /> that contains any error messages that were returned while processing the <see cref="Rock.Model.Workflow" />.</param>
        public void Process(Workflow workflow, out List <string> errorMessages)
        {
            workflow.IsProcessing = true;
            this.Context.SaveChanges();

            var rockContext = (RockContext)this.Context;

            workflow.LoadAttributes(rockContext);

            workflow.Process(rockContext, out errorMessages);

            if (workflow.IsPersisted)
            {
                this.Context.WrapTransaction(() =>
                {
                    this.Context.SaveChanges();
                    workflow.SaveAttributeValues(rockContext);
                    foreach (var activity in workflow.Activities)
                    {
                        activity.SaveAttributeValues(rockContext);
                    }
                });

                workflow.IsProcessing = false;
                this.Context.SaveChanges();
            }
        }
        /// <summary>
        /// Processes the specified <see cref="Rock.Model.Workflow"/>
        /// </summary>
        /// <param name="workflow">The <see cref="Rock.Model.Workflow"/> instance to process.</param>
        /// <param name="CurrentPersonId">A <see cref="System.String"/> representing the PersonId of the <see cref="Rock.Model.Person"/> who is processing the <see cref="Rock.Model.Workflow"/>.</param>
        /// <param name="errorMessages">A <see cref="System.Collections.Generic.List{String}"/> that contains any error messages that were returned while processing the <see cref="Rock.Model.Workflow"/>.</param>
        public void Process(Workflow workflow, int?CurrentPersonId, out List <string> errorMessages)
        {
            workflow.IsProcessing = true;
            this.Save(workflow, null);

            workflow.Process(out errorMessages);

            workflow.IsProcessing = false;
            this.Save(workflow, null);
        }
示例#3
0
        /// <summary>
        /// Activates and processes a workflow activity.  If the workflow has not yet been activated, it will
        /// also be activated
        /// </summary>
        /// <param name="activityName">Name of the activity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception"></exception>
        protected bool ProcessActivity(string activityName, out List <string> errorMessages)
        {
            errorMessages = new List <string>();

            Guid?guid = GetAttributeValue("WorkflowType").AsGuidOrNull();

            if (guid.HasValue)
            {
                using (var rockContext = new RockContext())
                {
                    var workflowTypeService = new WorkflowTypeService(rockContext);
                    var workflowType        = workflowTypeService.Queryable("ActivityTypes")
                                              .Where(w => w.Guid.Equals(guid.Value))
                                              .FirstOrDefault();

                    if (workflowType != null)
                    {
                        if (CurrentWorkflow == null)
                        {
                            CurrentWorkflow = Rock.Model.Workflow.Activate(workflowType, CurrentCheckInState.Kiosk.Device.Name, rockContext);
                        }

                        var activityType = workflowType.ActivityTypes.Where(a => a.Name == activityName).FirstOrDefault();
                        if (activityType != null)
                        {
                            WorkflowActivity.Activate(activityType, CurrentWorkflow, rockContext);
                            if (CurrentWorkflow.Process(rockContext, CurrentCheckInState, out errorMessages))
                            {
                                // Keep workflow active for continued processing
                                CurrentWorkflow.CompletedDateTime = null;

                                return(true);
                            }
                        }
                        else
                        {
                            errorMessages.Add(string.Format("Workflow type does not have a '{0}' activity type", activityName));
                        }
                    }
                    else
                    {
                        errorMessages.Add("Invalid Workflow Type");
                    }
                }
            }

            return(false);
        }
示例#4
0
        /// <summary>
        /// Activates and processes a workflow activity.  If the workflow has not yet been activated, it will
        /// also be activated
        /// </summary>
        /// <param name="activityName">Name of the activity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception"></exception>
        protected bool ProcessActivity(string activityName, out List <string> errorMessages)
        {
            errorMessages = new List <string>();

            int workflowTypeId = 0;

            if (Int32.TryParse(GetAttributeValue("WorkflowTypeId"), out workflowTypeId))
            {
                var workflowTypeService = new WorkflowTypeService();
                var workflowType        = workflowTypeService.Get(workflowTypeId);
                if (workflowType != null)
                {
                    if (CurrentWorkflow == null)
                    {
                        CurrentWorkflow = Rock.Model.Workflow.Activate(workflowType, CurrentCheckInState.Kiosk.Device.Name);
                    }

                    var activityType = workflowType.ActivityTypes.Where(a => a.Name == activityName).FirstOrDefault();
                    if (activityType != null)
                    {
                        WorkflowActivity.Activate(activityType, CurrentWorkflow);
                        if (CurrentWorkflow.Process(CurrentCheckInState, out errorMessages))
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        errorMessages.Add(string.Format("Workflow type does not have a '{0}' activity type", activityName));
                    }
                }
                else
                {
                    errorMessages.Add(string.Format("Invalid Workflow type Id", activityName));
                }
            }

            return(false);
        }