Exemple #1
0
            /// <summary>
            ///     Set values from a string representation of the settings.
            /// </summary>
            /// <param name="selectionString"></param>
            public void FromSelectionString(string selectionString)
            {
                var selectionValues = selectionString.Split('|');

                // If selection string is invalid, ignore.
                if (selectionValues.Length < 2)
                {
                    return;
                }

                // Group Identifier
                var groupGuid = selectionValues[0].AsGuid();

                var group = new GroupService(new RockContext()).Get(groupGuid);

                ParentGroupId = (group != null) ? group.Id : 0;

                // Included Groups
                var includedGroups = selectionValues[1].AsIntegerOrNull();

                if (includedGroups != null)
                {
                    Enum.TryParse(includedGroups.ToString(), true, out IncludedGroups);
                }
                else
                {
                    IncludedGroups = IncludedGroupsSpecifier.EntireBranch;
                }
            }
Exemple #2
0
            /// <summary>
            ///     Set values from a string representation of the settings.
            /// </summary>
            /// <param name="selectionString"></param>
            public void FromSelectionString( string selectionString )
            {
                var selectionValues = selectionString.Split( '|' );

                // If selection string is invalid, ignore.
                if ( selectionValues.Length < 2 )
                {
                    return;
                }

                // Group Identifier
                var groupGuid = selectionValues[0].AsGuid();

                var group = new GroupService( new RockContext() ).Get( groupGuid );

                ParentGroupId = ( group != null ) ? group.Id : 0;

                // Included Groups
                var includedGroups = selectionValues[1].AsIntegerOrNull();

                if ( includedGroups != null )
                {
                    Enum.TryParse( includedGroups.ToString(), true, out IncludedGroups );
                }
                else
                {
                    IncludedGroups = IncludedGroupsSpecifier.EntireBranch;
                }
            }
Exemple #3
0
        /// <summary>
        ///     Gets the set of Groups that are included in a Group Branch, either as the parent or a descendant.
        /// </summary>
        /// <param name="groupService"></param>
        /// <param name="parentGroup"></param>
        /// <param name="includedBranchItems"></param>
        /// <returns></returns>
        private HashSet<int> GetGroupBranchKeys( GroupService groupService, Model.Group parentGroup, IncludedGroupsSpecifier includedBranchItems )
        {
            var groupKeys = new HashSet<int>();

            if ( parentGroup == null )
            {
                return groupKeys;
            }

            // Include the Parent Group?
            if ( includedBranchItems == IncludedGroupsSpecifier.EntireBranch )
            {
                groupKeys.Add( parentGroup.Id );
            }

            // Include descendants of the Parent Group.
            foreach ( int childGroupId in groupService.GetAllDescendents( parentGroup.Id ).Select( x => x.Id ) )
            {
                groupKeys.Add( childGroupId );
            }

            return groupKeys;
        }
Exemple #4
0
        /// <summary>
        ///     Gets the set of Groups that are included in a Group Branch, either as the parent or a descendant.
        /// </summary>
        /// <param name="groupService"></param>
        /// <param name="parentGroup"></param>
        /// <param name="includedBranchItems"></param>
        /// <returns></returns>
        private HashSet <int> GetGroupBranchKeys(GroupService groupService, Model.Group parentGroup, IncludedGroupsSpecifier includedBranchItems)
        {
            var groupKeys = new HashSet <int>();

            if (parentGroup == null)
            {
                return(groupKeys);
            }

            // Include the Parent Group?
            if (includedBranchItems == IncludedGroupsSpecifier.EntireBranch)
            {
                groupKeys.Add(parentGroup.Id);
            }

            // Include descendants of the Parent Group.
            foreach (int childGroupId in groupService.GetAllDescendentGroupIds(parentGroup.Id, false))
            {
                groupKeys.Add(childGroupId);
            }

            return(groupKeys);
        }