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


C# GroupMemberService.CalculateRequirements方法代码示例

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


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

示例1: CalculateRequirements

        /// <summary>
        /// Calculates (or re-calculates) the requirements, then updates the results on the UI
        /// </summary>
        private void CalculateRequirements()
        {
            var rockContext = new RockContext();
            var groupMember = new GroupMemberService( rockContext ).Get( hfGroupMemberId.Value.AsInteger() );

            if ( groupMember != null && !groupMember.IsNewOrChangedGroupMember( rockContext ) )
            {
                groupMember.CalculateRequirements( rockContext, true );
            }

            ShowGroupRequirementsStatuses();
        }
开发者ID:,项目名称:,代码行数:15,代码来源:

示例2: Execute

        /// <summary>
        /// Execute method to check for any workflows to launch and will also recalculate group member requirements when a member is added
        /// </summary>
        public void Execute()
        {
            // if a GroupMember is getting added, call CalculateRequirements to make sure that group member requirements are calculated (if the group has requirements)
            if ( State == EntityState.Added )
            {
                if ( GroupMemberGuid.HasValue )
                {
                    using ( var rockContext = new RockContext() )
                    {
                        var groupMember = new GroupMemberService( rockContext ).Get( GroupMemberGuid.Value );
                        if ( groupMember != null )
                        {
                            groupMember.CalculateRequirements( rockContext, true );
                        }
                    }
                }
            }

            GroupMemberWorkflowTriggerType[] groupMemberWorkflowChangeTriggers = new GroupMemberWorkflowTriggerType[] { GroupMemberWorkflowTriggerType.MemberAddedToGroup, GroupMemberWorkflowTriggerType.MemberRemovedFromGroup, GroupMemberWorkflowTriggerType.MemberStatusChanged, GroupMemberWorkflowTriggerType.MemberRoleChanged };

            // Verify that valid ids were saved
            if ( GroupId.HasValue && PersonId.HasValue )
            {
                // Get all the triggers from cache
                var cachedTriggers = GroupMemberWorkflowTriggerService.GetCachedTriggers();

                // If any triggers exist
                if ( cachedTriggers != null && cachedTriggers.Any() )
                {
                    // Get the triggers associated to the group
                    var groupTriggers = cachedTriggers
                        .Where( w =>
                            groupMemberWorkflowChangeTriggers.Contains( w.TriggerType ) &&
                            w.GroupId.HasValue &&
                            w.GroupId.Value == GroupId.Value )
                        .OrderBy( w => w.Order )
                        .ToList();

                    // Get any triggers associated to a group type ( if any are found, will then filter by group type )
                    var groupTypeTriggers = cachedTriggers
                        .Where( w =>
                            groupMemberWorkflowChangeTriggers.Contains( w.TriggerType ) &&
                            w.GroupTypeId.HasValue )
                        .OrderBy( w => w.Order )
                        .ToList();

                    if ( groupTriggers.Any() || groupTypeTriggers.Any() )
                    {
                        using ( var rockContext = new RockContext() )
                        {
                            // If there were any group type triggers, will now need to read the group's group type id
                            // and then further filter these triggers by the current txn's group type
                            if ( groupTypeTriggers.Any() )
                            {
                                // Get the current txn's group type id
                                if ( !GroupTypeId.HasValue )
                                {
                                    GroupTypeId = new GroupService( rockContext )
                                        .Queryable().AsNoTracking()
                                        .Where( g => g.Id == GroupId.Value )
                                        .Select( g => g.GroupTypeId )
                                        .FirstOrDefault();
                                }

                                // Further filter the group type triggers by the group type id
                                groupTypeTriggers = groupTypeTriggers
                                    .Where( t =>
                                        t.GroupTypeId.HasValue &&
                                        t.GroupTypeId.Equals( GroupTypeId ) )
                                    .OrderBy( t => t.Order )
                                    .ToList();
                            }

                            // Combine group and grouptype trigers
                            var triggers = groupTriggers.Union( groupTypeTriggers ).ToList();

                            // If any triggers were found
                            if ( triggers.Any() )
                            {
                                // Loop through triggers and lauch appropriate workflow
                                foreach ( var trigger in triggers )
                                {
                                    switch ( trigger.TriggerType )
                                    {
                                        case GroupMemberWorkflowTriggerType.MemberAddedToGroup:
                                            {
                                                if ( State == EntityState.Added && QualifiersMatch( rockContext, trigger, GroupMemberStatus, GroupMemberStatus, GroupMemberRoleId, GroupMemberRoleId ) )
                                                {
                                                    LaunchWorkflow( rockContext, trigger.WorkflowTypeId, trigger.Name );
                                                }
                                                break;
                                            }
                                        case GroupMemberWorkflowTriggerType.MemberRemovedFromGroup:
                                            {
                                                if ( State == EntityState.Deleted && QualifiersMatch( rockContext, trigger, PreviousGroupMemberStatus, PreviousGroupMemberStatus, PreviousGroupMemberRoleId, PreviousGroupMemberRoleId ) )
                                                {
                                                    LaunchWorkflow( rockContext, trigger.WorkflowTypeId, trigger.Name );
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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