/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { string result = "Group Member"; string[] selectionValues = selection.Split('|'); if (selectionValues.Length >= 2) { var groupType = Rock.Web.Cache.GroupTypeCache.Read(selectionValues[0].AsInteger() ?? 0); var groupTypeRoleIdList = selectionValues[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(a => a.AsInteger()).ToList(); var groupTypeRoles = new GroupTypeRoleService().Queryable().Where(a => groupTypeRoleIdList.Contains(a.Id)).ToList(); if (groupType != null) { result = string.Format("In group of group type: {0}", groupType.Name); if (groupTypeRoles.Count() > 0) { result += string.Format(", with role(s): {0}", groupTypeRoles.Select(a => a.Name).ToList().AsDelimited(",")); } } } return(result); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { string result = "Group Member"; string[] selectionValues = selection.Split('|'); if (selectionValues.Length >= 2) { var rockContext = new RockContext(); var group = new GroupService(rockContext).Get(selectionValues[0].AsGuid()); var groupTypeRoleGuidList = selectionValues[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(a => a.AsGuid()).ToList(); var groupTypeRoles = new GroupTypeRoleService(rockContext).Queryable().Where(a => groupTypeRoleGuidList.Contains(a.Guid)).ToList(); if (group != null) { result = string.Format("Not in group: {0}", group.Name); if (groupTypeRoles.Count() > 0) { result += string.Format(", with role(s): {0}", groupTypeRoles.Select(a => a.Name).ToList().AsDelimited(",")); } } } return(result); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { string result = "Group Member"; string[] selectionValues = selection.Split('|'); if (selectionValues.Length >= 2) { var rockContext = new RockContext(); var group = new GroupService(rockContext).Get(selectionValues[0].AsGuid()); var groupTypeRoleGuidList = selectionValues[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(a => a.AsGuid()).ToList(); var groupTypeRoles = new GroupTypeRoleService(rockContext).Queryable().Where(a => groupTypeRoleGuidList.Contains(a.Guid)).ToList(); bool includeChildGroups = false; if (selectionValues.Length >= 3) { includeChildGroups = selectionValues[2].AsBooleanOrNull() ?? false; } GroupMemberStatus?groupMemberStatus = GroupMemberStatus.Active; if (selectionValues.Length >= 4) { groupMemberStatus = selectionValues[3].ConvertToEnumOrNull <GroupMemberStatus>(); } if (group != null) { result = string.Format("In group: {0}", group.Name); if (includeChildGroups) { result += " or child groups"; } if (groupTypeRoles.Count() > 0) { result += string.Format(", with role(s): {0}", groupTypeRoles.Select(a => string.Format("{0} ({1})", a.Name, a.GroupType.Name)).ToList().AsDelimited(",")); } if (groupMemberStatus.HasValue) { result += string.Format(", with member status: {0}", groupMemberStatus.ConvertToString()); } } } return(result); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { string result = "Group Member"; string[] selectionValues = selection.Split('|'); if (selectionValues.Length >= 2) { var groupType = GroupTypeCache.Get(selectionValues[0].AsGuid()); var groupTypeRoleGuidList = selectionValues[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(a => a.AsGuid()).ToList(); var groupTypeRoles = new GroupTypeRoleService(new RockContext()).Queryable().Where(a => groupTypeRoleGuidList.Contains(a.Guid)).ToList(); bool?groupStatus = null; if (selectionValues.Length >= 4) { groupStatus = selectionValues[3].AsBooleanOrNull(); } GroupMemberStatus?groupMemberStatus = null; if (selectionValues.Length >= 3) { groupMemberStatus = selectionValues[2].ConvertToEnumOrNull <GroupMemberStatus>(); } if (groupType != null) { result = string.Format("In group of group type: {0}", groupType.Name); if (groupTypeRoles.Count() > 0) { result += string.Format(", with role(s): {0}", groupTypeRoles.Select(a => a.Name).ToList().AsDelimited(",")); } if (groupStatus.HasValue) { result += string.Format(", with group status: {0}", groupStatus.Value ? "Active" : "Inactive"); } if (groupMemberStatus.HasValue) { result += string.Format(", with member status: {0}", groupMemberStatus.ConvertToString()); } } } return(result); }
/// <summary> /// Formats the selection for the InGroupFilter/NotInGroupFilter based on if we are in "Not" mode /// </summary> /// <param name="selection">The selection.</param> /// <param name="not">if set to <c>true</c> [not].</param> /// <returns></returns> public virtual string GroupFilterFormatSelection(string selection, bool not) { string result = "Group Member"; string[] selectionValues = selection.Split('|'); if (selectionValues.Length >= 2) { var rockContext = new RockContext(); var groupGuids = selectionValues[0].Split(',').AsGuidList(); var groups = new GroupService(rockContext).GetByGuids(groupGuids); var groupTypeRoleGuidList = selectionValues[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(a => a.AsGuid()).ToList(); var groupTypeRoles = new GroupTypeRoleService(rockContext).Queryable().Where(a => groupTypeRoleGuidList.Contains(a.Guid)).ToList(); bool includeChildGroups = false; bool includeChildGroupsPlusDescendants = false; bool includeChildGroupsIncludeSelected = false; bool includeInactiveGroups = false; if (selectionValues.Length >= 3) { includeChildGroups = selectionValues[2].AsBooleanOrNull() ?? false; if (selectionValues.Length >= 6) { includeChildGroupsIncludeSelected = selectionValues[4].AsBooleanOrNull() ?? false; includeChildGroupsPlusDescendants = selectionValues[5].AsBooleanOrNull() ?? false; } if (selectionValues.Length >= 7) { includeInactiveGroups = selectionValues[6].AsBooleanOrNull() ?? false; } } GroupMemberStatus?groupMemberStatus = null; if (selectionValues.Length >= 4) { groupMemberStatus = selectionValues[3].ConvertToEnumOrNull <GroupMemberStatus>(); } if (groups != null) { result = string.Format(not ? "Not in groups: {0}" : "In groups: {0}", groups.Select(a => a.Name).ToList().AsDelimited(", ", " or ")); if (includeChildGroups) { if (includeChildGroupsPlusDescendants) { result += " or descendant groups"; } else { result += " or child groups"; } if (includeInactiveGroups) { result += ", including inactive groups"; } if (!includeChildGroupsIncludeSelected) { result += ", not including selected groups"; } } if (groupTypeRoles.Count() > 0) { result += string.Format(", with role(s): {0}", groupTypeRoles.Select(a => string.Format("{0} ({1})", a.Name, a.GroupType.Name)).ToList().AsDelimited(",")); } if (groupMemberStatus.HasValue) { result += string.Format(", with member status: {0}", groupMemberStatus.ConvertToString()); } } } return(result); }
/// <summary> /// Formats the selection for the InGroupFilter/NotInGroupFilter based on if we are in "Not" mode /// </summary> /// <param name="selection">The selection.</param> /// <param name="not">if set to <c>true</c> [not].</param> /// <returns></returns> public virtual string GroupFilterFormatSelection( string selection, bool not ) { string result = "Group Member"; string[] selectionValues = selection.Split( '|' ); if ( selectionValues.Length >= 2 ) { var rockContext = new RockContext(); var groupGuids = selectionValues[0].Split( ',' ).AsGuidList(); var groups = new GroupService( rockContext ).GetByGuids( groupGuids ); var groupTypeRoleGuidList = selectionValues[1].Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries ).Select( a => a.AsGuid() ).ToList(); var groupTypeRoles = new GroupTypeRoleService( rockContext ).Queryable().Where( a => groupTypeRoleGuidList.Contains( a.Guid ) ).ToList(); bool includeChildGroups = false; bool includeChildGroupsPlusDescendants = false; bool includeChildGroupsIncludeSelected = false; bool includeInactiveGroups = false; string addedOnDateRangeText = null; string firstAttendanceDateRangeText = null; string lastAttendanceDateRangeText = null; if ( selectionValues.Length >= 3 ) { includeChildGroups = selectionValues[2].AsBooleanOrNull() ?? false; if ( selectionValues.Length >= 6 ) { includeChildGroupsIncludeSelected = selectionValues[4].AsBooleanOrNull() ?? false; includeChildGroupsPlusDescendants = selectionValues[5].AsBooleanOrNull() ?? false; } if ( selectionValues.Length >= 7 ) { includeInactiveGroups = selectionValues[6].AsBooleanOrNull() ?? false; } if ( selectionValues.Length >= 8 ) { // convert comma delimited to pipe then get date range text addedOnDateRangeText = SlidingDateRangePicker.FormatDelimitedValues( selectionValues[7].Replace( ',', '|' ) ); } if ( selectionValues.Length >= 10 ) { // convert comma delimited to pipe then get date range text firstAttendanceDateRangeText = SlidingDateRangePicker.FormatDelimitedValues( selectionValues[8].Replace( ',', '|' ) ); // convert comma delimited to pipe then get date range text lastAttendanceDateRangeText = SlidingDateRangePicker.FormatDelimitedValues( selectionValues[9].Replace( ',', '|' ) ); } } GroupMemberStatus? groupMemberStatus = null; if ( selectionValues.Length >= 4 ) { groupMemberStatus = selectionValues[3].ConvertToEnumOrNull<GroupMemberStatus>(); } if ( groups != null ) { result = string.Format( not ? "Not in groups: {0}" : "In groups: {0}", groups.Select( a => a.Name ).ToList().AsDelimited( ", ", " or " ) ); if ( includeChildGroups ) { if ( includeChildGroupsPlusDescendants ) { result += " or descendant groups"; } else { result += " or child groups"; } if ( includeInactiveGroups ) { result += ", including inactive groups"; } if ( !includeChildGroupsIncludeSelected ) { result += ", not including selected groups"; } } if ( groupTypeRoles.Count() > 0 ) { result += string.Format( ", with role(s): {0}", groupTypeRoles.Select( a => string.Format( "{0} ({1})", a.Name, a.GroupType.Name ) ).ToList().AsDelimited( "," ) ); } if ( groupMemberStatus.HasValue ) { result += string.Format( ", with member status: {0}", groupMemberStatus.ConvertToString() ); } if ( !string.IsNullOrEmpty( addedOnDateRangeText ) ) { result += string.Format( ", added to group in Date Range: {0}", addedOnDateRangeText ); } if ( !string.IsNullOrEmpty( firstAttendanceDateRangeText ) ) { result += string.Format( ", first attendance to group in Date Range: {0}", firstAttendanceDateRangeText ); } if ( !string.IsNullOrEmpty( lastAttendanceDateRangeText ) ) { result += string.Format( ", last attendance to group in Date Range: {0}", lastAttendanceDateRangeText ); } } } return result; }