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


C# GroupMemberService.Where方法代码示例

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


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

示例1: GetExpression

        /// <summary>
        /// Creates a Linq Expression that can be applied to an IQueryable to filter the result set.
        /// </summary>
        /// <param name="entityType">The type of entity in the result set.</param>
        /// <param name="serviceInstance">A service instance that can be queried to obtain the result set.</param>
        /// <param name="parameterExpression">The input parameter that will be injected into the filter expression.</param>
        /// <param name="selection">A formatted string representing the filter settings.</param>
        /// <returns>
        /// A Linq Expression that can be used to filter an IQueryable.
        /// </returns>
        public override Expression GetExpression( Type entityType, IService serviceInstance, ParameterExpression parameterExpression, string selection )
        {
            var settings = new SelectSettings( selection );

            var context = (RockContext)serviceInstance.Context;

            //
            // Evaluate the Data View that defines the candidate Groups.
            //
            var dataView = DataComponentSettingsHelper.GetDataViewForFilterComponent( settings.DataViewGuid, context );

            var groupService = new GroupService( context );

            var groupQuery = groupService.Queryable();

            if (dataView != null)
            {
                groupQuery = DataComponentSettingsHelper.FilterByDataView( groupQuery, dataView, groupService );
            }
            else
            {
                // Apply a default Group filter to only show Groups that would be visible in a Group List.
                groupQuery = groupQuery.Where( x => x.GroupType.ShowInGroupList );
            }

            var groupKeys = groupQuery.Select( x => x.Id );

            //
            // Construct the Query to return the list of Group Members matching the filter conditions.
            //
            var groupMemberQuery = new GroupMemberService( context ).Queryable();

            // Filter By Group.
            groupMemberQuery = groupMemberQuery.Where( x => groupKeys.Contains( x.GroupId ) );

            // Filter By Group Role Type.
            switch ( settings.RoleType )
            {
                case RoleTypeSpecifier.Member:
                    groupMemberQuery = groupMemberQuery.Where( x => !x.GroupRole.IsLeader );
                    break;

                case RoleTypeSpecifier.Leader:
                    groupMemberQuery = groupMemberQuery.Where( x => x.GroupRole.IsLeader );
                    break;
            }

            // Filter by Group Member Status.
            if ( settings.MemberStatus.HasValue )
            {
                groupMemberQuery = groupMemberQuery.Where( x => x.GroupMemberStatus == settings.MemberStatus.Value );
            }

            //
            // Create a Select Expression to return the Person records referenced by the Group Members.
            //
            var personGroupsQuery = new PersonService( context ).Queryable()
                                                                .Where( p => groupMemberQuery.Select( gm => gm.PersonId ).Contains( p.Id ) );

            var selectExpression = FilterExpressionExtractor.Extract<Model.Person>( personGroupsQuery, parameterExpression, "p" );

            return selectExpression;
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:73,代码来源:GroupDataViewFilter.cs

示例2: MapFamilyAddress

        /// <summary>
        /// Maps the family address.
        /// </summary>
        /// <param name="tableData">The table data.</param>
        /// <returns></returns>
        private void MapFamilyAddress( IQueryable<Row> tableData )
        {
            var lookupContext = new RockContext();
            var locationService = new LocationService( lookupContext );

            List<GroupMember> familyGroupMemberList = new GroupMemberService( lookupContext ).Queryable().AsNoTracking()
                .Where( gm => gm.Group.GroupType.Guid == new Guid( Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY ) ).ToList();

            var groupLocationDefinedType = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.GROUP_LOCATION_TYPE ), lookupContext );
            int homeGroupLocationTypeId = groupLocationDefinedType.DefinedValues
                .FirstOrDefault( dv => dv.Guid == new Guid( Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME ) ).Id;
            int workGroupLocationTypeId = groupLocationDefinedType.DefinedValues
                .FirstOrDefault( dv => dv.Guid == new Guid( Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_WORK ) ).Id;
            int previousGroupLocationTypeId = groupLocationDefinedType.DefinedValues
                .FirstOrDefault( dv => dv.Guid == new Guid( Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_PREVIOUS ) ).Id;

            string otherGroupLocationName = "Other (Imported)";
            int? otherGroupLocationTypeId = groupLocationDefinedType.DefinedValues
                .Where( dv => dv.TypeName == otherGroupLocationName )
                .Select( dv => (int?)dv.Id ).FirstOrDefault();
            if ( otherGroupLocationTypeId == null )
            {
                var otherGroupLocationType = new DefinedValue();
                otherGroupLocationType.Value = otherGroupLocationName;
                otherGroupLocationType.DefinedTypeId = groupLocationDefinedType.Id;
                otherGroupLocationType.IsSystem = false;
                otherGroupLocationType.Order = 0;

                lookupContext.DefinedValues.Add( otherGroupLocationType );
                lookupContext.SaveChanges( DisableAuditing );

                otherGroupLocationTypeId = otherGroupLocationType.Id;
            }

            var newGroupLocations = new List<GroupLocation>();

            int completed = 0;
            int totalRows = tableData.Count();
            int percentage = ( totalRows - 1 ) / 100 + 1;
            ReportProgress( 0, string.Format( "Verifying address import ({0:N0} found).", totalRows ) );

            foreach ( var row in tableData.Where( r => r != null ) )
            {
                int? individualId = row["Individual_ID"] as int?;
                int? householdId = row["Household_ID"] as int?;
                var personKeys = GetPersonKeys( individualId, householdId, includeVisitors: false );
                if ( personKeys != null )
                {
                    var familyGroup = familyGroupMemberList.Where( gm => gm.PersonId == personKeys.PersonId )
                        .Select( gm => gm.Group ).FirstOrDefault();

                    if ( familyGroup != null )
                    {
                        var groupLocation = new GroupLocation();

                        string street1 = row["Address_1"] as string;
                        string street2 = row["Address_2"] as string;
                        string city = row["City"] as string;
                        string state = row["State"] as string;
                        string country = row["country"] as string; // NOT A TYPO: F1 has property in lower-case
                        string zip = row["Postal_Code"] as string ?? string.Empty;

                        // restrict zip to 5 places to prevent duplicates
                        Location familyAddress = locationService.Get( street1, street2, city, state, zip.Left( 5 ), country, verifyLocation: false );

                        if ( familyAddress != null )
                        {
                            familyAddress.CreatedByPersonAliasId = ImportPersonAliasId;
                            familyAddress.Name = familyGroup.Name;
                            familyAddress.IsActive = true;

                            groupLocation.GroupId = familyGroup.Id;
                            groupLocation.LocationId = familyAddress.Id;
                            groupLocation.IsMailingLocation = true;
                            groupLocation.IsMappedLocation = true;

                            string addressType = row["Address_Type"].ToString().ToLower();
                            if ( addressType.Equals( "primary" ) )
                            {
                                groupLocation.GroupLocationTypeValueId = homeGroupLocationTypeId;
                            }
                            else if ( addressType.Equals( "business" ) || addressType.ToLower().Equals( "org" ) )
                            {
                                groupLocation.GroupLocationTypeValueId = workGroupLocationTypeId;
                            }
                            else if ( addressType.Equals( "previous" ) )
                            {
                                groupLocation.GroupLocationTypeValueId = previousGroupLocationTypeId;
                            }
                            else if ( !string.IsNullOrEmpty( addressType ) )
                            {
                                // look for existing group location types, otherwise mark as imported
                                var customTypeId = groupLocationDefinedType.DefinedValues.Where( dv => dv.Value.ToLower().Equals( addressType ) )
                                    .Select( dv => (int?)dv.Id ).FirstOrDefault();
                                groupLocation.GroupLocationTypeValueId = customTypeId ?? otherGroupLocationTypeId;
//.........这里部分代码省略.........
开发者ID:NewSpring,项目名称:Excavator,代码行数:101,代码来源:Locations.cs

示例3: btnConfirm_Click

        /// <summary>
        /// Handles the Click event of the btnConfirm control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnConfirm_Click( object sender, EventArgs e )
        {
            if ( Page.IsValid )
            {
                var rockContext = new RockContext();
                var personService = new PersonService( rockContext );
                var ids = Individuals.Select( i => i.PersonId ).ToList();

                #region Individual Details Updates

                int? newTitleId = ddlTitle.SelectedValueAsInt();
                int? newSuffixId = ddlSuffix.SelectedValueAsInt();
                int? newConnectionStatusId = ddlStatus.SelectedValueAsInt();
                int? newRecordStatusId = ddlRecordStatus.SelectedValueAsInt();
                int? newInactiveReasonId = ddlInactiveReason.SelectedValueAsInt();
                string newInactiveReasonNote = tbInactiveReasonNote.Text;
                Gender newGender = ddlGender.SelectedValue.ConvertToEnum<Gender>();
                int? newMaritalStatusId = ddlMaritalStatus.SelectedValueAsInt();

                int? newGraduationYear = null;
                if ( ypGraduation.SelectedYear.HasValue )
                {
                    newGraduationYear = ypGraduation.SelectedYear.Value;
                }

                int? newCampusId = cpCampus.SelectedCampusId;

                bool? newEmailActive = null;
                if ( !string.IsNullOrWhiteSpace( ddlIsEmailActive.SelectedValue ) )
                {
                    newEmailActive = ddlIsEmailActive.SelectedValue == "Active";
                }

                EmailPreference? newEmailPreference = ddlEmailPreference.SelectedValue.ConvertToEnumOrNull<EmailPreference>();

                string newEmailNote = tbEmailNote.Text;

                int? newReviewReason = ddlReviewReason.SelectedValueAsInt();
                string newSystemNote = tbSystemNote.Text;
                string newReviewReasonNote = tbReviewReasonNote.Text;

                int inactiveStatusId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_INACTIVE ).Id;

                var allChanges = new Dictionary<int, List<string>>();

                var people = personService.Queryable().Where( p => ids.Contains( p.Id ) ).ToList();
                foreach ( var person in people )
                {
                    var changes = new List<string>();
                    allChanges.Add( person.Id, changes );

                    if ( SelectedFields.Contains( ddlTitle.ClientID ) )
                    {
                        History.EvaluateChange( changes, "Title", DefinedValueCache.GetName( person.TitleValueId ), DefinedValueCache.GetName( newTitleId ) );
                        person.TitleValueId = newTitleId;
                    }

                    if ( SelectedFields.Contains( ddlSuffix.ClientID ) )
                    {
                        History.EvaluateChange( changes, "Suffix", DefinedValueCache.GetName( person.SuffixValueId ), DefinedValueCache.GetName( newSuffixId ) );
                        person.SuffixValueId = newSuffixId;
                    }

                    if ( SelectedFields.Contains( ddlStatus.ClientID ) )
                    {
                        History.EvaluateChange( changes, "Connection Status", DefinedValueCache.GetName( person.ConnectionStatusValueId ), DefinedValueCache.GetName( newConnectionStatusId ) );
                        person.ConnectionStatusValueId = newConnectionStatusId;
                    }

                    if ( SelectedFields.Contains( ddlRecordStatus.ClientID ) )
                    {
                        History.EvaluateChange( changes, "Record Status", DefinedValueCache.GetName( person.RecordStatusValueId ), DefinedValueCache.GetName( newRecordStatusId ) );
                        person.RecordStatusValueId = newRecordStatusId;

                        if ( newRecordStatusId.HasValue && newRecordStatusId.Value == inactiveStatusId )
                        {
                            History.EvaluateChange( changes, "Inactive Reason", DefinedValueCache.GetName( person.RecordStatusReasonValueId ), DefinedValueCache.GetName( newInactiveReasonId ) );
                            person.RecordStatusReasonValueId = newInactiveReasonId;

                            if ( !string.IsNullOrWhiteSpace( newInactiveReasonNote ) )
                            {
                                History.EvaluateChange( changes, "Inactive Reason Note", person.InactiveReasonNote, newInactiveReasonNote );
                                person.InactiveReasonNote = newInactiveReasonNote;
                            }
                        }
                    }

                    if ( SelectedFields.Contains( ddlGender.ClientID ) )
                    {
                        History.EvaluateChange( changes, "Gender", person.Gender, newGender );
                        person.Gender = newGender;
                    }

                    if ( SelectedFields.Contains( ddlMaritalStatus.ClientID ) )
                    {
//.........这里部分代码省略.........
开发者ID:Higherbound,项目名称:Higherbound-2016-website-upgrades,代码行数:101,代码来源:BulkUpdate.ascx.cs

示例4: GetRelatedPeopleQuery

        private IQueryable<RelatedPersonInfo> GetRelatedPeopleQuery( RockContext context, IEnumerable<int> groupTypeIds, IEnumerable<Guid> principalRoleGuids, IEnumerable<Guid> targetRoleGuids,
                                                                     string relationshipName = "*" )
        {
            var relationshipGroupMembersQuery = new GroupMemberService( context ).Queryable();

            relationshipGroupMembersQuery = relationshipGroupMembersQuery.Where( x => groupTypeIds.Contains( x.Group.GroupTypeId ) );

            var relatedPeopleQuery = new PersonService( context ).Queryable()
                                                                 .SelectMany( p => relationshipGroupMembersQuery.Where( gm => gm.PersonId == p.Id && principalRoleGuids.Contains( gm.GroupRole.Guid ) )
                                                                                                                .SelectMany( gm => gm.Group.Members )
                                                                                                                .Where( gm => targetRoleGuids.Contains( gm.GroupRole.Guid ) && gm.PersonId != p.Id )
                                                                                                                .OrderBy( gm => gm.GroupRole.Order )
                                                                                                                .ThenBy( gm => gm.Person.BirthDate )
                                                                                                                .ThenBy( gm => gm.Person.Gender )
                                                                                                                .Select(
                                                                                                                        gm =>
                                                                                                                        new RelatedPersonInfo
                                                                                                                        {
                                                                                                                            RelatedToPersonId = p.Id,
                                                                                                                            PersonId = gm.Person.Id,
                                                                                                                            FirstName = gm.Person.FirstName,
                                                                                                                            LastName = gm.Person.LastName,
                                                                                                                            Suffix = gm.Person.SuffixValue.Value,
                                                                                                                            RelationshipName =
                                                                                                                                ( relationshipName == "*"
                                                                                                                                      ? gm.GroupRole.Name
                                                                                                                                      : relationshipName )
                                                                                                                        } ) );

            return relatedPeopleQuery;
        }
开发者ID:,项目名称:,代码行数:31,代码来源:

示例5: bindGrid

        protected void bindGrid()
        {
            if ( String.IsNullOrWhiteSpace( CheckinCode ) )
            {
                ShowPanel( 0 );
            }
            else
            {
                rlCheckinCode.Text = CheckinCode + " <a href='?'><i class='fa fa-times'></i></a>";

                if ( !SelectedAttendanceGuid.IsEmpty() )
                {
                    ShowPanel( 2 );
                    var SelectedAttendance = new AttendanceService( rockContext ).Get( SelectedAttendanceGuid );
                    SelectedAttendance.LoadAttributes();
                    var attSearch = SelectedAttendance.GetAttributeValue( "SearchValue" );
                    var hasSearch = !String.IsNullOrWhiteSpace( attSearch );
                    if ( hasSearch )
                        attSearch = attSearch.AsNumeric();

                    var SelectedPerson = SelectedAttendance.PersonAlias.Person;
                    rlSelectedPerson.Text = SelectedPerson.FullName + " <a href='?CheckinCode=" + CheckinCode + "'><i class='fa fa-times'></i></a>";

                    var groupRoleServ = new GroupTypeRoleService( rockContext );

                    var knownRelationship_GroupMemberships = new GroupMemberService( rockContext ).Queryable()
                        .Where( gm => gm.Group.GroupTypeId == 11 && gm.PersonId == SelectedPerson.Id );

                    var shownRelationships = GetAttributeValue( "IncludedRelationships" ).Split( ',' ).Select( g => g.AsGuid() );

                    gReleventPeople.DataSource = SelectedPerson.GetFamilyMembers( false, rockContext )
                        .Select( m => new
                        {
                            Person = m.Person,
                            Role = m.GroupRole,
                            Priority = 100
                        } )
                        .ToList()
                        .Union(
                            knownRelationship_GroupMemberships
                            .Where( gm => gm.GroupRole.Guid == GUID_OwnerRole )
                            .SelectMany( gm => gm.Group.Members.Where( gm2 => gm2.PersonId != SelectedPerson.Id ) )
                            .ToList()
                            .Select( gm => new
                            {
                                Person = gm.Person,
                                Role = GetInverseRole( gm.GroupRole, groupRoleServ ),
                                Priority = 50
                            } )
                        )
                        .Union(
                             knownRelationship_GroupMemberships
                            .Where( gm => gm.GroupRole.Guid != GUID_OwnerRole )
                            .Select( gm => new
                            {
                                Person = gm.Group.Members.Where( gm2 => gm2.GroupRole.Guid == GUID_OwnerRole ).FirstOrDefault().Person,
                                Role = gm.GroupRole,
                                Priority = 40
                            } ).ToList()
                        )
                        .Where( r => shownRelationships.Contains( r.Role.Guid ) )
                        .GroupBy( x => x.Person )
                        .Select( x => new PersonRelationship
                        {
                            PersonAliasGuid = x.Key.PrimaryAlias.Guid,
                            FullName = x.Key.FullName,
                            Roles = String.Join( " ,", x.Select( y => y.Role.Name ) ),
                            Priority = x.Select( y => y.Priority ).Max(),
                            HomePhone = GetFormatedNumber( x.Key, GUID_HomePhone ),
                            MobilePhone = GetFormatedNumber( x.Key, GUID_MobilePhone ),
                            Highlight = hasSearch && x.Key.PhoneNumbers.Any( y => y.Number.Contains( attSearch ) )
                        } )
                        .OrderByDescending( r => r.Priority + ( r.Highlight ? 100 : 0) );

                    gReleventPeople.DataKeyNames = new string[] { "PersonAliasGuid" };
                    gReleventPeople.DataBind();
                }
                else
                {
                    ShowPanel( 1 );

                    int daysBacktoSearch = GetAttributeValue( "DaysBacktoSearch" ).AsInteger();
                    var searchDate = DateTime.Now.Date.AddDays( -daysBacktoSearch );

                    gSearchResults.SetLinqDataSource( new AttendanceCodeService( rockContext )
                        .Queryable()
                        .Where( c => c.Code == CheckinCode && c.IssueDateTime > searchDate )
                        .SelectMany( c => c.Attendances )
                        .OrderByDescending( "StartDateTime" ) );

                    gSearchResults.DataKeyNames = new string[] { "Guid" };
                    gSearchResults.DataBind();
                }
            }
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:95,代码来源:CheckinCodeLookup.ascx.cs

示例6: GetExpression

        /// <summary>
        /// Gets the expression.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="entityIdProperty">The entity identifier property.</param>
        /// <param name="selection">The selection.</param>
        /// <returns></returns>
        public override Expression GetExpression( RockContext context, MemberExpression entityIdProperty, string selection )
        {
            string[] selectionValues = selection.Split( '|' );

            Location selectedLocation = null;
            Guid? locationTypeValidGuid = null;
            if ( selectionValues.Count() >= 2 )
            {
                // the selected Location
                selectedLocation = new LocationService( context ).Get( selectionValues[0].AsGuid() );

                // which address type (home, work, previous) to use as the person's location
                locationTypeValidGuid = selectionValues[1].AsGuidOrNull();
            }

            Guid familyGuid = Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY.AsGuid();
            int familyGroupTypeId = new GroupTypeService( context ).Get( familyGuid ).Id;

            var groupMemberQuery = new GroupMemberService( context ).Queryable();

            const double milesPerMeter = 1 / 1609.344;

            IQueryable<double?> personLocationDistanceQuery;

            if ( selectedLocation != null )
            {
                personLocationDistanceQuery = new PersonService( context ).Queryable()
                    .Select( p =>
                        groupMemberQuery
                        .Where( m => m.Group.GroupTypeId == familyGroupTypeId && m.PersonId == p.Id )
                        .SelectMany( m => m.Group.GroupLocations )
                        .Where( gl => gl.GroupLocationTypeValue.Guid == locationTypeValidGuid )
                        .Where( gl => gl.Location.GeoPoint != null )
                        .Select( s => DbFunctions.Truncate(s.Location.GeoPoint.Distance( selectedLocation.GeoPoint ) * milesPerMeter, 2) )
                        .FirstOrDefault() );
            }
            else
            {
                personLocationDistanceQuery = new PersonService( context ).Queryable()
                    .Select( p => (double?)null );
            }

            var selectExpression = SelectExpressionExtractor.Extract<Rock.Model.Person>( personLocationDistanceQuery, entityIdProperty, "p" );

            return selectExpression;
        }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:53,代码来源:DistanceFromSelect.cs

示例7: Execute

        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        public override bool Execute( RockContext rockContext, WorkflowAction action, Object entity, out List<string> errorMessages )
        {
            errorMessages = new List<string>();

            Guid? groupGuid = null;
            Person person = null;
            string attributeValue = string.Empty;
            Guid groupRoleGuid = Guid.Empty;
            string attributeKey = string.Empty;

            // get the group attribute
            Guid groupAttributeGuid = GetAttributeValue(action, "Group").AsGuid();

            if ( !groupAttributeGuid.IsEmpty() )
            {
                groupGuid = action.GetWorklowAttributeValue(groupAttributeGuid).AsGuidOrNull();

                if ( !groupGuid.HasValue )
                {
                    errorMessages.Add("The group could not be found!");
                }
            }

            // get person alias guid
            Guid personAliasGuid = Guid.Empty;
            string personAttribute = GetAttributeValue( action, "Person" );

            Guid guid = personAttribute.AsGuid();
            if (!guid.IsEmpty())
            {
                var attribute = AttributeCache.Read( guid, rockContext );
                if ( attribute != null )
                {
                    string value = action.GetWorklowAttributeValue(guid);
                    personAliasGuid = value.AsGuid();
                }

                if ( personAliasGuid != Guid.Empty )
                {
                    person = new PersonAliasService(rockContext).Queryable().AsNoTracking()
                                    .Where(p => p.Guid.Equals(personAliasGuid))
                                    .Select(p => p.Person)
                                    .FirstOrDefault();
                }
                else {
                    errorMessages.Add("The person could not be found in the attribute!");
                }
            }

            // get group member attribute value
            attributeValue = GetAttributeValue(action, "AttributeValue");
            guid = attributeValue.AsGuid();
            if ( guid.IsEmpty() )
            {
                attributeValue = attributeValue.ResolveMergeFields(GetMergeFields(action));
            }
            else
            {
                var workflowAttributeValue = action.GetWorklowAttributeValue(guid);

                if ( workflowAttributeValue != null )
                {
                    attributeValue = workflowAttributeValue;
                }
            }

            // get optional role filter
            groupRoleGuid = GetAttributeValue(action, "GroupRoleFilter").AsGuid();

            // get attribute key
            attributeKey = GetAttributeValue(action, "GroupMemberAttributeKey").Replace(" ", "");

            // set attribute
            if ( groupGuid.HasValue && person != null )
            {
                var qry = new GroupMemberService(rockContext).Queryable()
                                .Where(m => m.Group.Guid == groupGuid && m.PersonId == person.Id);

                if ( groupRoleGuid != Guid.Empty )
                {
                    qry = qry.Where(m => m.GroupRole.Guid == groupRoleGuid);
                }

                foreach ( var groupMember in qry.ToList() )
                {
                    groupMember.LoadAttributes(rockContext);
                    if ( groupMember.Attributes.ContainsKey(attributeKey) )
                    {
                        var attribute = groupMember.Attributes[attributeKey];
                        Rock.Attribute.Helper.SaveAttributeValue(groupMember, attribute, attributeValue, rockContext);
                    }
                    else
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例8: GetExpression

        /// <summary>
        /// Gets the expression.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="entityIdProperty">The entity identifier property.</param>
        /// <param name="selection">The selection.</param>
        /// <returns></returns>
        public override Expression GetExpression( RockContext context, MemberExpression entityIdProperty, string selection )
        {
            var adultGuid = SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid();
            var childGuid = SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_CHILD.AsGuid();
            var familyGuid = SystemGuid.GroupType.GROUPTYPE_FAMILY.AsGuid();

            //Contains an array of the int representation of EmailPreferences selected
            int[] selectedPreferences = null;
            if (!string.IsNullOrEmpty(selection))
            {
                selectedPreferences = Array.ConvertAll(selection.Split(','), s => int.Parse(s));
            }

            var familyGroupMembers = new GroupMemberService(context).Queryable()
                .Where(m => m.Group.GroupType.Guid == familyGuid);

            IQueryable<IEnumerable<string>> personParentsEmailQuery;
            //Done as an if statement because:
            // 1) If you try and check selectedPreferences for null in LINQ it throws an exception
            // 2) If all preferences are selected it's quicker to disregard the preference entirely
            if (selectedPreferences == null || selectedPreferences.Length == 3)
            {
                // this returns Enumerable of Email addresses for Parents per row. The Grid then uses ListDelimiterField to convert the list into Parent's Phone Numbers
                personParentsEmailQuery = new PersonService(context).Queryable()
                    .Select(p => familyGroupMembers.Where(s => s.PersonId == p.Id && s.GroupRole.Guid == childGuid)
                        .SelectMany(gm => gm.Group.Members)
                        .Where(m => m.GroupRole.Guid == adultGuid)
                        .Where(m => !string.IsNullOrEmpty(m.Person.Email) && m.Person.IsEmailActive)
                    .Select(q => q.Person.Email).AsEnumerable());
            }
            else
            {
                // this returns Enumerable of Email addresses for Parents per row. The Grid then uses ListDelimiterField to convert the list into Parent's Phone Numbers
                personParentsEmailQuery = new PersonService(context).Queryable()
                    .Select(p => familyGroupMembers.Where(s => s.PersonId == p.Id && s.GroupRole.Guid == childGuid)
                        .SelectMany(gm => gm.Group.Members)
                        .Where(m => m.GroupRole.Guid == adultGuid )
                        .Where(m => selectedPreferences.Contains((int)m.Person.EmailPreference))
                        .Where(m => !string.IsNullOrEmpty(m.Person.Email) && m.Person.IsEmailActive)
                    .Select(q => q.Person.Email).AsEnumerable());
            }

            var selectEmail = SelectExpressionExtractor.Extract( personParentsEmailQuery, entityIdProperty, "p" );

            return selectEmail;
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:53,代码来源:ParentEmailSelect.cs

示例9: rptrGroups_ItemDataBound

        /// <summary>
        /// Handles the ItemDataBound event of the rptrGroups control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterItemEventArgs"/> instance containing the event data.</param>
        protected void rptrGroups_ItemDataBound( object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e )
        {
            if ( e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem )
            {
                var group = e.Item.DataItem as Group;
                if ( group != null )
                {
                    HyperLink hlEditGroup = e.Item.FindControl( "hlEditGroup" ) as HyperLink;
                    if ( hlEditGroup != null )
                    {
                        hlEditGroup.Visible = _allowEdit;
                        var pageParams = new Dictionary<string, string>();
                        pageParams.Add( "PersonId", Person.Id.ToString() );
                        pageParams.Add( "GroupId", group.Id.ToString() );
                        hlEditGroup.NavigateUrl = LinkedPageUrl( "GroupEditPage", pageParams );
                    }

                    Repeater rptrMembers = e.Item.FindControl( "rptrMembers" ) as Repeater;
                    if ( rptrMembers != null )
                    {
                        // use the _bindGroupsRockContext that is created/disposed in BindFamilies()
                        var members = new GroupMemberService( _bindGroupsRockContext ).Queryable( "GroupRole,Person", true )
                            .Where( m =>
                                m.GroupId == group.Id &&
                                m.PersonId != Person.Id )
                            .OrderBy( m => m.GroupRole.Order )
                            .ToList();

                        var orderedMembers = new List<GroupMember>();

                        if ( _IsFamilyGroupType )
                        {
                            // Add adult males
                            orderedMembers.AddRange( members
                                .Where( m => m.GroupRole.Guid.Equals( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT ) ) &&
                                    m.Person.Gender == Gender.Male )
                                .OrderByDescending( m => m.Person.Age ) );

                            // Add adult females
                            orderedMembers.AddRange( members
                                .Where( m => m.GroupRole.Guid.Equals( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT ) ) &&
                                    m.Person.Gender != Gender.Male )
                                .OrderByDescending( m => m.Person.Age ) );

                            // Add non-adults
                            orderedMembers.AddRange( members
                                .Where( m => !m.GroupRole.Guid.Equals( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT ) ) )
                                .OrderByDescending( m => m.Person.Age ) );
                        }
                        else
                        {
                            orderedMembers = members
                                .OrderBy( m => m.GroupRole.Order )
                                .ThenBy( m => m.Person.LastName )
                                .ThenBy( m => m.Person.NickName )
                                .ToList();
                        }
                        rptrMembers.ItemDataBound += rptrMembers_ItemDataBound;
                        rptrMembers.DataSource = orderedMembers;
                        rptrMembers.DataBind();
                    }

                    Repeater rptrAddresses = e.Item.FindControl( "rptrAddresses" ) as Repeater;
                    if ( rptrAddresses != null )
                    {
                        rptrAddresses.ItemDataBound += rptrAddresses_ItemDataBound;
                        rptrAddresses.ItemCommand += rptrAddresses_ItemCommand;
                        rptrAddresses.DataSource = new GroupLocationService( _bindGroupsRockContext ).Queryable( "Location,GroupLocationTypeValue" )
                            .Where( l => l.GroupId == group.Id )
                            .OrderBy( l => l.GroupLocationTypeValue.Order )
                            .ToList();
                        rptrAddresses.DataBind();
                    }

                    Panel pnlGroupAttributes = e.Item.FindControl( "pnlGroupAttributes" ) as Panel;
                    HyperLink hlShowMoreAttributes = e.Item.FindControl( "hlShowMoreAttributes" ) as HyperLink;
                    PlaceHolder phGroupAttributes = e.Item.FindControl( "phGroupAttributes" ) as PlaceHolder;
                    PlaceHolder phMoreGroupAttributes = e.Item.FindControl( "phMoreGroupAttributes" ) as PlaceHolder;

                    if ( pnlGroupAttributes  != null && hlShowMoreAttributes != null && phGroupAttributes != null && phMoreGroupAttributes != null )
                    {
                        hlShowMoreAttributes.Visible = false;
                        phGroupAttributes.Controls.Clear();
                        phMoreGroupAttributes.Controls.Clear();

                        group.LoadAttributes();
                        var attributes = group.Attributes
                            .Select( a => a.Value )
                            .OrderBy( a => a.Order )
                            .ToList();

                        foreach( var attribute in attributes )
                        {
                            if ( attribute.IsAuthorized( Authorization.VIEW, CurrentPerson ) )
                            {
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例10: Groups

        /// <summary>
        /// Gets the groups of selected type that person is a member of
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="input">The input.</param>
        /// <param name="groupTypeId">The group type identifier.</param>
        /// <param name="status">The status.</param>
        /// <returns></returns>
        public static List<Rock.Model.GroupMember> Groups( DotLiquid.Context context, object input, string groupTypeId, string status = "Active" )
        {
            var person = GetPerson( input );
            int? numericalGroupTypeId = groupTypeId.AsIntegerOrNull();

            if ( person != null && numericalGroupTypeId.HasValue )
            {
                var groupQuery =  new GroupMemberService( GetRockContext( context ) )
                    .Queryable("Group, GroupRole").AsNoTracking()
                    .Where( m =>
                        m.PersonId == person.Id &&
                        m.Group.GroupTypeId == numericalGroupTypeId.Value &&
                        m.Group.IsActive );

                if ( status != "All" )
                {
                    GroupMemberStatus queryStatus = GroupMemberStatus.Active;
                    queryStatus = (GroupMemberStatus)Enum.Parse( typeof( GroupMemberStatus ), status, true );

                    groupQuery = groupQuery.Where( m => m.GroupMemberStatus == queryStatus );
                }

                return groupQuery.ToList();
            }

            return new List<Model.GroupMember>();
        }
开发者ID:azturner,项目名称:Rock,代码行数:35,代码来源:RockFilters.cs

示例11: rptrGroups_ItemDataBound

        /// <summary>
        /// Handles the ItemDataBound event of the rptrGroups control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterItemEventArgs"/> instance containing the event data.</param>
        protected void rptrGroups_ItemDataBound( object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e )
        {
            if ( e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem )
            {
                var group = e.Item.DataItem as Group;
                if ( group != null )
                {
                    HyperLink hlEditGroup = e.Item.FindControl( "hlEditGroup" ) as HyperLink;
                    if ( hlEditGroup != null )
                    {
                        hlEditGroup.Visible = _allowEdit;
                        var pageParams = new Dictionary<string, string>();
                        pageParams.Add( "PersonId", Person.Id.ToString() );
                        pageParams.Add( "GroupId", group.Id.ToString() );
                        hlEditGroup.NavigateUrl = LinkedPageUrl( "GroupEditPage", pageParams );
                    }

                    Literal lEditGroup = e.Item.FindControl( "lEditGroup" ) as Literal;
                    if ( lEditGroup != null )
                    {
                        lEditGroup.Text = "Edit " + _groupType.Name;
                    }

                    Repeater rptrMembers = e.Item.FindControl( "rptrMembers" ) as Repeater;
                    if ( rptrMembers != null )
                    {
                        // use the _bindGroupsRockContext that is created/disposed in BindFamilies()
                        var members = new GroupMemberService( _bindGroupsRockContext ).Queryable( "GroupRole,Person", true )
                            .Where( m =>
                                m.GroupId == group.Id &&
                                m.PersonId != Person.Id )
                            .OrderBy( m => m.GroupRole.Order )
                            .ToList();

                        var orderedMembers = new List<GroupMember>();

                        if ( _IsFamilyGroupType )
                        {
                            // Add adult males
                            orderedMembers.AddRange( members
                                .Where( m => m.GroupRole.Guid.Equals( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT ) ) &&
                                    m.Person.Gender == Gender.Male )
                                .OrderByDescending( m => m.Person.Age ) );

                            // Add adult females
                            orderedMembers.AddRange( members
                                .Where( m => m.GroupRole.Guid.Equals( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT ) ) &&
                                    m.Person.Gender != Gender.Male )
                                .OrderByDescending( m => m.Person.Age ) );

                            // Add non-adults
                            orderedMembers.AddRange( members
                                .Where( m => !m.GroupRole.Guid.Equals( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT ) ) )
                                .OrderByDescending( m => m.Person.Age ) );
                        }
                        else
                        {
                            orderedMembers = members
                                .OrderBy( m => m.GroupRole.Order )
                                .ThenBy( m => m.Person.LastName )
                                .ThenBy( m => m.Person.NickName )
                                .ToList();
                        }
                        rptrMembers.ItemDataBound += rptrMembers_ItemDataBound;
                        rptrMembers.DataSource = orderedMembers;
                        rptrMembers.DataBind();
                    }

                    Repeater rptrAddresses = e.Item.FindControl( "rptrAddresses" ) as Repeater;
                    {
                        rptrAddresses.ItemDataBound += rptrAddresses_ItemDataBound;
                        rptrAddresses.ItemCommand += rptrAddresses_ItemCommand;
                        rptrAddresses.DataSource = new GroupLocationService( _bindGroupsRockContext ).Queryable( "Location,GroupLocationTypeValue" )
                            .Where( l => l.GroupId == group.Id )
                            .OrderBy( l => l.GroupLocationTypeValue.Order )
                            .ToList();
                        rptrAddresses.DataBind();
                    }
                }
            }
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:86,代码来源:GroupMembers.ascx.cs

示例12: BindGrid

        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            // Find all the Group Types
            var groupTypeIds = GetAvailableGroupTypes();

            if ( GetAttributeValue( "DisplayFilter" ).AsBooleanOrNull() ?? false )
            {
                int? groupTypeFilter = gfSettings.GetUserPreference( "Group Type" ).AsIntegerOrNull();
                if ( groupTypeFilter.HasValue )
                {
                    groupTypeIds = groupTypeIds.Where( g => g == groupTypeFilter.Value ).ToList();
                }
            }

            var rockContext = new RockContext();

            SortProperty sortProperty = gGroups.SortProperty;
            if ( sortProperty == null )
            {
                sortProperty = new SortProperty( new GridViewSortEventArgs( "IsActiveOrder, GroupTypeOrder, GroupTypeName, GroupOrder, Name", SortDirection.Ascending ) );
            }

            bool onlySecurityGroups = GetAttributeValue( "LimittoSecurityRoleGroups" ).AsBoolean();

            var qryGroups = new GroupService( rockContext ).Queryable().Where( g => groupTypeIds.Contains( g.GroupTypeId ) && ( !onlySecurityGroups || g.IsSecurityRole ) );

            string limitToActiveStatus = GetAttributeValue( "LimittoActiveStatus" );

            bool showActive = true;
            bool showInactive = true;

            if ( limitToActiveStatus == "all" && gfSettings.Visible )
            {
                // Filter by active/inactive unless the block settings restrict it
                if ( ddlActiveFilter.SelectedIndex > -1 )
                {
                    switch ( ddlActiveFilter.SelectedValue )
                    {
                        case "active":
                            showInactive = false;
                            break;
                        case "inactive":
                            showActive = false;
                            break;
                    }
                }
            }
            else if ( limitToActiveStatus != "all" )
            {
                // filter by the block setting for Active Status
                if ( limitToActiveStatus == "active" )
                {
                    showInactive = false;
                }
            }

            // Person context will exist if used on a person detail page
            int personEntityTypeId = EntityTypeCache.Read( "Rock.Model.Person" ).Id;
            if ( ContextTypesRequired.Any( e => e.Id == personEntityTypeId ) )
            {
                var personContext = ContextEntity<Person>();
                if ( personContext != null )
                {
                    // limit to Groups that the person is a member of
                    var qry = new GroupMemberService( rockContext ).Queryable( true )
                        .Where( m => m.PersonId == personContext.Id )
                        .Join( qryGroups, gm => gm.GroupId, g => g.Id, ( gm, g ) => new { Group = g, GroupMember = gm } );

                    // Filter by Active Status of Group and Group Membership.
                    if ( showActive && !showInactive )
                    {
                        // Show only active Groups and active Memberships.
                        qry = qry.Where( gmg => gmg.Group.IsActive && gmg.GroupMember.GroupMemberStatus == GroupMemberStatus.Active );
                    }
                    else if ( !showActive )
                    {
                        // Show only inactive Groups or inactive Memberships.
                        qry = qry.Where( gmg => !gmg.Group.IsActive || gmg.GroupMember.GroupMemberStatus == GroupMemberStatus.Inactive );
                    }

                    gGroups.DataSource = qry
                        .Select( m => new GroupListRowInfo {
                            Id = m.Group.Id,
                            Name = m.Group.Name,
                            GroupTypeName = m.Group.GroupType.Name,
                            GroupOrder = m.Group.Order,
                            GroupTypeOrder = m.Group.GroupType.Order,
                            Description = m.Group.Description,
                            IsSystem = m.Group.IsSystem,
                            GroupRole = m.GroupMember.GroupRole.Name,
                            DateAdded = m.GroupMember.CreatedDateTime,
                            IsActive = m.Group.IsActive && ( m.GroupMember.GroupMemberStatus == GroupMemberStatus.Active ),
                            IsActiveOrder = ( m.Group.IsActive && ( m.GroupMember.GroupMemberStatus == GroupMemberStatus.Active ) ? 1 : 2 ),
                            MemberCount = 0
                        } )
                        .Sort( sortProperty )
                        .ToList();
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例13: GetExpression

        /// <summary>
        /// Gets the expression.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="entityIdProperty">The entity identifier property.</param>
        /// <param name="selection">The selection.</param>
        /// <returns></returns>
        public override Expression GetExpression( RockContext context, MemberExpression entityIdProperty, string selection )
        {
            var settings = new GroupParticipationSelectSettings( selection );

            //
            // Define Candidate Groups.
            //

            // Get the Group Data View that defines the set of candidates from which matching Groups can be selected.
            var dataView = DataComponentSettingsHelper.GetDataViewForFilterComponent( settings.DataViewGuid, context );

            // Evaluate the Data View that defines the candidate Groups.
            var groupService = new GroupService( context );

            var groupQuery = groupService.Queryable();

            if (dataView != null)
            {
                groupQuery = DataComponentSettingsHelper.FilterByDataView( groupQuery, dataView, groupService );
            }
            else
            {
                // Apply a default Group filter to only show Groups that would be visible in a Group List.
                groupQuery = groupQuery.Where( x => x.GroupType.ShowInGroupList );
            }

            var groupKeys = groupQuery.Select( x => x.Id );

            //
            // Construct the Query to return the list of Group Members matching the filter conditions.
            //
            var groupMemberQuery = new GroupMemberService( context ).Queryable();

            // Filter By Group.
            groupMemberQuery = groupMemberQuery.Where( x => groupKeys.Contains( x.GroupId ) );

            // Filter By Group Role Type.
            switch ( settings.RoleType )
            {
                case RoleTypeSpecifier.Member:
                    groupMemberQuery = groupMemberQuery.Where( x => !x.GroupRole.IsLeader );
                    break;

                case RoleTypeSpecifier.Leader:
                    groupMemberQuery = groupMemberQuery.Where( x => x.GroupRole.IsLeader );
                    break;
            }

            // Filter by Group Member Status.
            if ( settings.MemberStatus.HasValue )
            {
                groupMemberQuery = groupMemberQuery.Where( x => x.GroupMemberStatus == settings.MemberStatus.Value );
            }

            //
            // Create a Select Expression to return the requested values.
            //

            // Set the Output Format of the field.
            Expression selectExpression;

            if (settings.ListFormat == ListFormatSpecifier.YesNo)
            {
                // Define a Query to return True/False text indicating if the Person participates in any of the filtered Groups.
                // Note that the text must be returned as an Enumerable to satisfy the expected output of this field.
                var personGroupsQuery = new PersonService( context ).Queryable()
                                                                    .Select( p => new List<string> { groupMemberQuery.Any( s => s.PersonId == p.Id ) ? "Yes" : "No" } );

                selectExpression = SelectExpressionExtractor.Extract( personGroupsQuery, entityIdProperty, "p" );
            }
            else
            {
                // Define a Query to return the collection of filtered Groups for each Person.
                Expression<Func<Rock.Model.GroupMember, string>> outputExpression;

                if (settings.ListFormat == ListFormatSpecifier.GroupOnly)
                {
                    outputExpression = ( ( m => m.Group.Name ) );
                }
                else
                {
                    outputExpression = ( ( m => m.Group.Name + " [" + m.GroupRole.Name + "]" ) );
                }

                // Define a Query to return the collection of filtered Groups for each Person.
                var personGroupsQuery = new PersonService( context ).Queryable()
                                                                    .Select( p => groupMemberQuery.Where( s => s.PersonId == p.Id )
                                                                                                  .OrderBy( x => x.Group.Name )
                                                                                                  .ThenBy( x => x.GroupRole.Name )
                                                                                                  .Select( outputExpression ).AsEnumerable() );

                selectExpression = SelectExpressionExtractor.Extract( personGroupsQuery, entityIdProperty, "p" );
            }
//.........这里部分代码省略.........
开发者ID:NewSpring,项目名称:Rock,代码行数:101,代码来源:GroupParticipationSelect.cs

示例14: Execute

        /// <summary>
        /// Job that will sync groups.
        /// 
        /// Called by the <see cref="IScheduler" /> when a
        /// <see cref="ITrigger" /> fires that is associated with
        /// the <see cref="IJob" />.
        /// </summary>
        public virtual void Execute( IJobExecutionContext context )
        {
            JobDataMap dataMap = context.JobDetail.JobDataMap;

            try
            {
                int notificationsSent = 0;
                int pendingMembersCount = 0;

                // get groups set to sync
                RockContext rockContext = new RockContext();

                Guid? groupTypeGuid = dataMap.GetString( "GroupType" ).AsGuidOrNull();
                Guid? systemEmailGuid = dataMap.GetString( "NotificationEmail" ).AsGuidOrNull();
                Guid? groupRoleFilterGuid = dataMap.GetString( "GroupRoleFilter" ).AsGuidOrNull();
                int? pendingAge = dataMap.GetString( "PendingAge" ).AsIntegerOrNull();

                bool includePreviouslyNotificed = dataMap.GetString( "IncludePreviouslyNotified" ).AsBoolean();

                // get system email
                SystemEmailService emailService = new SystemEmailService( rockContext );

                SystemEmail systemEmail = null;
                if ( systemEmailGuid.HasValue )
                {
                    systemEmail = emailService.Get( systemEmailGuid.Value );
                }

                if ( systemEmail == null )
                {
                    // no email specified, so nothing to do
                    return;
                }

                // get group members
                if ( groupTypeGuid.HasValue && groupTypeGuid != Guid.Empty )
                {
                    var qry = new GroupMemberService( rockContext ).Queryable( "Person, Group, Group.Members.GroupRole" )
                                            .Where( m => m.Group.GroupType.Guid == groupTypeGuid.Value
                                                && m.GroupMemberStatus == GroupMemberStatus.Pending );

                    if ( !includePreviouslyNotificed )
                    {
                        qry = qry.Where( m => m.IsNotified == false );
                    }

                    if ( groupRoleFilterGuid.HasValue )
                    {
                        qry = qry.Where( m => m.GroupRole.Guid == groupRoleFilterGuid.Value );
                    }

                    if ( pendingAge.HasValue )
                    {
                        var ageDate = RockDateTime.Now.AddDays( pendingAge.Value * -1 );
                        qry = qry.Where( m => m.ModifiedDateTime > ageDate );
                    }

                    var pendingGroupMembers = qry.ToList();

                    var groups = pendingGroupMembers.GroupBy( m => m.Group );

                    foreach ( var groupKey in groups )
                    {
                        var group = groupKey.Key;

                        // get list of pending people
                        var qryPendingIndividuals = group.Members.Where( m => m.GroupMemberStatus == GroupMemberStatus.Pending );

                        if ( !includePreviouslyNotificed )
                        {
                            qryPendingIndividuals = qryPendingIndividuals.Where( m => m.IsNotified == false );
                        }

                        if ( groupRoleFilterGuid.HasValue )
                        {
                            qryPendingIndividuals = qryPendingIndividuals.Where( m => m.GroupRole.Guid == groupRoleFilterGuid.Value );
                        }

                        var pendingIndividuals = qryPendingIndividuals.Select( m => m.Person ).ToList();

                        // get list of leaders
                        var groupLeaders = group.Members.Where( m => m.GroupRole.IsLeader == true );

                        var appRoot = Rock.Web.Cache.GlobalAttributesCache.Read( rockContext ).GetValue( "PublicApplicationRoot" );

                        var recipients = new List<RecipientData>();
                        foreach ( var leader in groupLeaders )
                        {
                            // create merge object
                            var mergeFields = new Dictionary<string, object>();
                            mergeFields.Add( "PendingIndividuals", pendingIndividuals );
                            mergeFields.Add( "Group", group );
                            mergeFields.Add( "ParentGroup", group.ParentGroup );
//.........这里部分代码省略.........
开发者ID:NewSpring,项目名称:Rock,代码行数:101,代码来源:GroupLeaderPendingNotifications.cs

示例15: GetExpression

        /// <summary>
        /// Gets the expression.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="entityIdProperty">The entity identifier property.</param>
        /// <param name="selection">The selection.</param>
        /// <returns></returns>
        public override Expression GetExpression( RockContext context, MemberExpression entityIdProperty, string selection )
        {
            //// Spouse is determined if all these conditions are met
            //// 1) Adult in the same family as Person (GroupType = Family, GroupRole = Adult, and in same Group)
            //// 2) Opposite Gender as Person
            //// 3) Both Persons are Married

            Guid adultGuid = Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid();
            Guid marriedGuid = Rock.SystemGuid.DefinedValue.PERSON_MARITAL_STATUS_MARRIED.AsGuid();
            int marriedDefinedValueId = DefinedValueCache.Read( marriedGuid ).Id;
            Guid familyGuid = Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY.AsGuid();

            var familyGroupMembers = new GroupMemberService( context ).Queryable()
                .Where( m => m.Group.GroupType.Guid == familyGuid );

            var personSpouseQuery = new PersonService( context ).Queryable()
                .Select( p => familyGroupMembers.Where( s => s.PersonId == p.Id && s.Person.MaritalStatusValueId == marriedDefinedValueId && s.GroupRole.Guid == adultGuid )
                    .SelectMany( m => m.Group.Members )
                    .Where( m =>
                        m.PersonId != p.Id &&
                        m.GroupRole.Guid == adultGuid &&
                        m.Person.Gender != p.Gender &&
                        m.Person.MaritalStatusValueId == marriedDefinedValueId &&
                        !m.Person.IsDeceased )
                    .Select( m => m.Person.NickName ).FirstOrDefault() );

            var selectSpouseExpression = SelectExpressionExtractor.Extract( personSpouseQuery, entityIdProperty, "p" );

            return selectSpouseExpression;
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:37,代码来源:SpouseNameSelect.cs


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