当前位置: 首页>>代码示例>>C#>>正文


C# Workflow.Process方法代码示例

本文整理汇总了C#中Workflow.Process方法的典型用法代码示例。如果您正苦于以下问题:C# Workflow.Process方法的具体用法?C# Workflow.Process怎么用?C# Workflow.Process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Workflow的用法示例。


在下文中一共展示了Workflow.Process方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Process

        /// <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();
            }
        }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:31,代码来源:WorkflowService.Partial.cs

示例2: Process

        /// <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 );
        }
开发者ID:pkdevbox,项目名称:Rock,代码行数:16,代码来源:WorkflowService.Partial.cs

示例3: HydrateObjects

        private bool HydrateObjects()
        {
            LoadWorkflowType();

            if ( _workflowType == null )
            {
                ShowMessage( NotificationBoxType.Danger, "Configuration Error", "Workflow type was not configured or specified correctly." );
                return false;
            }

            if ( !_workflowType.IsAuthorized( Authorization.VIEW, CurrentPerson ) )
            {
                ShowMessage( NotificationBoxType.Warning, "Sorry", "You are not authorized to view this type of workflow." );
                return false;
            }

            // If operating against an existing workflow, get the workflow and load attributes
            if ( !WorkflowId.HasValue )
            {
                WorkflowId = PageParameter( "WorkflowId" ).AsIntegerOrNull();
                if ( !WorkflowId.HasValue )
                {
                    Guid guid = PageParameter( "WorkflowGuid" ).AsGuid();
                    if ( !guid.IsEmpty() )
                    {
                        _workflow = _workflowService.Queryable()
                            .Where( w => w.Guid.Equals( guid ) && w.WorkflowTypeId == _workflowType.Id )
                            .FirstOrDefault();
                        if ( _workflow != null )
                        {
                            WorkflowId = _workflow.Id;
                        }
                    }
                }
            }

            if ( WorkflowId.HasValue )
            {
                if ( _workflow == null )
                {
                    _workflow = _workflowService.Queryable()
                        .Where( w => w.Id == WorkflowId.Value && w.WorkflowTypeId == _workflowType.Id )
                        .FirstOrDefault();
                }
                if ( _workflow != null )
                {
                    _workflow.LoadAttributes();
                    foreach ( var activity in _workflow.Activities )
                    {
                        activity.LoadAttributes();
                    }
                }

            }

            // If an existing workflow was not specified, activate a new instance of workflow and start processing
            if ( _workflow == null )
            {
                _workflow = Rock.Model.Workflow.Activate( _workflowType, "Workflow" );

                List<string> errorMessages;
                if ( _workflow.Process( _rockContext, out errorMessages ) )
                {
                    // If the workflow type is persisted, save the workflow
                    if ( _workflow.IsPersisted || _workflowType.IsPersisted )
                    {
                        _workflowService.Add( _workflow );

                        RockTransactionScope.WrapTransaction( () =>
                        {
                            _rockContext.SaveChanges();
                            _workflow.SaveAttributeValues( _rockContext );
                            foreach ( var activity in _workflow.Activities )
                            {
                                activity.SaveAttributeValues( _rockContext );
                            }
                        } );

                        WorkflowId = _workflow.Id;
                    }
                }
            }

            if ( _workflow == null )
            {
                ShowMessage( NotificationBoxType.Danger, "Workflow Activation Error", "Workflow could not be activated." );
                return false;
            }

            if ( _workflow.IsActive )
            {
                if ( ActionTypeId.HasValue )
                {
                    foreach ( var activity in _workflow.ActiveActivities )
                    {
                        _action = activity.Actions.Where( a => a.ActionTypeId == ActionTypeId.Value ).FirstOrDefault();
                        if ( _action != null )
                        {
                            _activity = activity;
                            _activity.LoadAttributes();
//.........这里部分代码省略.........
开发者ID:jondhinkle,项目名称:Rock,代码行数:101,代码来源:WorkflowEntry.ascx.cs

示例4: HydrateObjects

        private bool HydrateObjects()
        {
            LoadWorkflowType();

            // Set the note type if this is first request
            if ( !Page.IsPostBack )
            {
                var noteType = new NoteTypeService( _rockContext ).Get( Rock.SystemGuid.NoteType.WORKFLOW_NOTE.AsGuid() );
                ncWorkflowNotes.NoteTypeId = noteType.Id;
            }

            if ( _workflowType == null )
            {
                ShowMessage( NotificationBoxType.Danger, "Configuration Error", "Workflow type was not configured or specified correctly." );
                return false;
            }

            if ( !_workflowType.IsAuthorized( Authorization.VIEW, CurrentPerson ) )
            {
                ShowMessage( NotificationBoxType.Warning, "Sorry", "You are not authorized to view this type of workflow." );
                return false;
            }

            // If operating against an existing workflow, get the workflow and load attributes
            if ( !WorkflowId.HasValue )
            {
                WorkflowId = PageParameter( "WorkflowId" ).AsIntegerOrNull();
                if ( !WorkflowId.HasValue )
                {
                    Guid guid = PageParameter( "WorkflowGuid" ).AsGuid();
                    if ( !guid.IsEmpty() )
                    {
                        _workflow = _workflowService.Queryable()
                            .Where( w => w.Guid.Equals( guid ) && w.WorkflowTypeId == _workflowType.Id )
                            .FirstOrDefault();
                        if ( _workflow != null )
                        {
                            WorkflowId = _workflow.Id;
                        }
                    }
                }
            }

            if ( WorkflowId.HasValue )
            {
                if ( _workflow == null )
                {
                    _workflow = _workflowService.Queryable()
                        .Where( w => w.Id == WorkflowId.Value && w.WorkflowTypeId == _workflowType.Id )
                        .FirstOrDefault();
                }
                if ( _workflow != null )
                {
                    _workflow.LoadAttributes();
                    foreach ( var activity in _workflow.Activities )
                    {
                        activity.LoadAttributes();
                    }
                }

            }

            // If an existing workflow was not specified, activate a new instance of workflow and start processing
            if ( _workflow == null )
            {
                string workflowName = PageParameter( "WorkflowName" );
                if ( string.IsNullOrWhiteSpace(workflowName))
                {
                    workflowName = "New " + _workflowType.WorkTerm;
                }

                _workflow = Rock.Model.Workflow.Activate( _workflowType, workflowName);
                if ( _workflow != null )
                {
                    // If a PersonId or GroupId parameter was included, load the corresponding
                    // object and pass that to the actions for processing
                    object entity = null;
                    int? personId = PageParameter( "PersonId" ).AsIntegerOrNull();
                    if ( personId.HasValue )
                    {
                        entity = new PersonService( _rockContext ).Get( personId.Value );
                    }
                    else
                    {
                        int? groupId = PageParameter( "GroupId" ).AsIntegerOrNull();
                        if ( groupId.HasValue )
                        {
                            entity = new GroupService( _rockContext ).Get( groupId.Value );
                        }
                    }

                    // Loop through all the query string parameters and try to set any workflow
                    // attributes that might have the same key
                    foreach ( string key in Request.QueryString.AllKeys )
                    {
                        _workflow.SetAttributeValue( key, Request.QueryString[key] );
                    }

                    List<string> errorMessages;
                    if ( _workflow.Process( _rockContext, entity, out errorMessages ) )
//.........这里部分代码省略.........
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:101,代码来源:WorkflowEntry.ascx.cs


注:本文中的Workflow.Process方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。