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


C# GroupMemberService.Select方法代码示例

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


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

示例1: modalAddPerson_SaveClick

        /// <summary>
        /// Handles the SaveClick event of the modalAddPerson control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        void modalAddPerson_SaveClick( object sender, EventArgs e )
        {
            if ( hfActiveTab.Value == "Existing" )
            {
                if ( ppPerson.PersonId.HasValue && !FamilyMembers.Any( m => m.Id == ppPerson.PersonId.Value ) )
                {
                    var rockContext = new RockContext();
                    var person = new PersonService( rockContext ).Get( ppPerson.PersonId.Value );
                    if ( person != null )
                    {
                        var familyMember = new FamilyMember();
                        familyMember.SetValuesFromPerson( person );

                        var familyRoleIds = familyRoles.Select( r => r.Id ).ToList();

                        var existingFamilyRoles = new GroupMemberService( rockContext ).Queryable( "GroupRole" )
                            .Where( m => m.PersonId == person.Id && familyRoleIds.Contains( m.GroupRoleId ) )
                            .OrderBy( m => m.GroupRole.Order )
                            .ToList();

                        var existingRole = existingFamilyRoles.Select( m => m.GroupRole ).FirstOrDefault();
                        if ( existingRole != null )
                        {
                            familyMember.RoleGuid = existingRole.Guid;
                            familyMember.RoleName = existingRole.Name;
                        }

                        familyMember.ExistingFamilyMember = existingFamilyRoles.Any( r => r.GroupId == _family.Id );
                        familyMember.RemoveFromOtherFamilies = cbRemoveOtherFamilies.Checked;

                        FamilyMembers.Add( familyMember );
                    }

                }
            }
            else
            {
                var familyMember = new FamilyMember();
                familyMember.FirstName = tbNewPersonFirstName.Text;
                familyMember.NickName = tbNewPersonFirstName.Text;
                familyMember.LastName = tbNewPersonLastName.Text;
                familyMember.Gender = ddlNewPersonGender.SelectedValueAsEnum<Gender>();
                familyMember.BirthDate = dpNewPersonBirthDate.SelectedDate;
                var role = familyRoles.Where( r => r.Id == ( rblNewPersonRole.SelectedValueAsInt() ?? 0 ) ).FirstOrDefault();
                if ( role != null )
                {
                    familyMember.RoleGuid = role.Guid;
                    familyMember.RoleName = role.Name;
                }

                FamilyMembers.Add( familyMember );
            }

            ppPerson.Required = false;
            tbNewPersonFirstName.Required = false;
            tbNewPersonLastName.Required = false;

            confirmExit.Enabled = true;

            hfActiveTab.Value = string.Empty;

            modalAddPerson.Hide();

            BindMembers();
        }
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:70,代码来源:EditFamily.ascx.cs

示例2: ShowResults

        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void ShowResults()
        {
            // Get the group types that we're interested in
            Guid? groupTypeGuid = GetAttributeValue( "GroupType" ).AsGuidOrNull();
            if ( !groupTypeGuid.HasValue )
            {
                ShowError( "A valid Group Type is required." );
                return;
            }

            gGroups.Columns[1].Visible = GetAttributeValue( "ShowDescription" ).AsBoolean();
            gGroups.Columns[2].Visible = GetAttributeValue( "ShowSchedule" ).AsBoolean();
            gGroups.Columns[3].Visible = GetAttributeValue( "ShowCount" ).AsBoolean();
            gGroups.Columns[4].Visible = GetAttributeValue( "ShowAge" ).AsBoolean();

            bool showProximity = GetAttributeValue( "ShowProximity" ).AsBoolean();
            gGroups.Columns[5].Visible = showProximity;  // Distance

            // Get query of groups of the selected group type
            var rockContext = new RockContext();
            var groupService = new GroupService( rockContext );
            var groupQry = groupService
                .Queryable( "GroupLocations.Location" )
                .Where( g => g.IsActive && g.GroupType.Guid.Equals( groupTypeGuid.Value ) && g.IsPublic );

            var groupParameterExpression = groupService.ParameterExpression;
            var schedulePropertyExpression = Expression.Property( groupParameterExpression, "Schedule" );

            var dowFilterControl = phFilterControls.FindControl( "filter_dow" );
            if ( dowFilterControl != null )
            {
                var field = FieldTypeCache.Read( Rock.SystemGuid.FieldType.DAY_OF_WEEK ).Field;

                var filterValues = field.GetFilterValues( dowFilterControl, null, Rock.Reporting.FilterMode.SimpleFilter );
                var expression = field.PropertyFilterExpression( null, filterValues, schedulePropertyExpression, "WeeklyDayOfWeek", typeof( DayOfWeek? ) );
                groupQry = groupQry.Where( groupParameterExpression, expression, null );
            }

            var timeFilterControl = phFilterControls.FindControl( "filter_time" );
            if ( timeFilterControl != null )
            {
                var field = FieldTypeCache.Read( Rock.SystemGuid.FieldType.TIME ).Field;

                var filterValues = field.GetFilterValues( timeFilterControl, null, Rock.Reporting.FilterMode.SimpleFilter );
                var expression = field.PropertyFilterExpression( null, filterValues, schedulePropertyExpression, "WeeklyTimeOfDay", typeof( TimeSpan? ) );
                groupQry = groupQry.Where( groupParameterExpression, expression, null );
            }

            // Filter query by any configured attribute filters
            if ( AttributeFilters != null && AttributeFilters.Any() )
            {
                var attributeValueService = new AttributeValueService( rockContext );
                var parameterExpression = attributeValueService.ParameterExpression;

                foreach ( var attribute in AttributeFilters )
                {
                    var filterControl = phFilterControls.FindControl( "filter_" + attribute.Id.ToString() );
                    if ( filterControl != null )
                    {
                        var filterValues = attribute.FieldType.Field.GetFilterValues( filterControl, attribute.QualifierValues, Rock.Reporting.FilterMode.SimpleFilter );
                        var expression = attribute.FieldType.Field.AttributeFilterExpression( attribute.QualifierValues, filterValues, parameterExpression );
                        if ( expression != null )
                        {
                            var attributeValues = attributeValueService
                                .Queryable()
                                .Where( v => v.Attribute.Id == attribute.Id );

                            attributeValues = attributeValues.Where( parameterExpression, expression, null );

                            groupQry = groupQry.Where( w => attributeValues.Select( v => v.EntityId ).Contains( w.Id ) );
                        }
                    }
                }
            }

            List<GroupLocation> fences = null;
            List<Group> groups = null;

            // Run query to get list of matching groups
            SortProperty sortProperty = gGroups.SortProperty;
            if ( sortProperty != null )
            {
                groups = groupQry.Sort( sortProperty ).ToList();
            }
            else
            {
                groups = groupQry.OrderBy( g => g.Name ).ToList();
            }

            int? fenceGroupTypeId = GetGroupTypeId( GetAttributeValue( "GeofencedGroupType" ).AsGuidOrNull() );
            bool showMap = GetAttributeValue( "ShowMap" ).AsBoolean();
            bool showFences = showMap && GetAttributeValue( "ShowFence" ).AsBoolean();

            var distances = new Dictionary<int, double>();

            // If we care where these groups are located...
            if ( fenceGroupTypeId.HasValue || showMap || showProximity )
//.........这里部分代码省略.........
开发者ID:NewPointe,项目名称:Rockit,代码行数:101,代码来源:GroupFinder.ascx.cs

示例3: 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 System.Linq.Expressions.Expression GetExpression( Data.RockContext context, System.Linq.Expressions.MemberExpression entityIdProperty, string selection )
        {
            var memberQuery = new GroupMemberService( context ).Queryable();

            IQueryable<string> groupLinkQuery;

            groupLinkQuery = memberQuery.Select( gm => gm.Group.Campus.Name );

            var exp = SelectExpressionExtractor.Extract( groupLinkQuery, entityIdProperty, "gm" );

            return exp;
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:19,代码来源:GroupCampus.cs

示例4: 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

示例5: LoadDropDowns

        /// <summary>
        /// Loads the drop downs.
        /// </summary>
        private void LoadDropDowns( BenevolenceRequest benevolenceRequest )
        {
            ddlRequestStatus.BindToDefinedType( DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.BENEVOLENCE_REQUEST_STATUS ) ), false );
            ddlConnectionStatus.BindToDefinedType( DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_CONNECTION_STATUS ) ), true );

            Guid groupGuid = GetAttributeValue( "CaseWorkerRole" ).AsGuid();
            var personList = new GroupMemberService( new RockContext() )
                .Queryable( "Person, Group" )
                .Where( gm => gm.Group.Guid == groupGuid )
                .Select( gm => gm.Person )
                .ToList();

            string caseWorkerPersonAliasValue = benevolenceRequest.CaseWorkerPersonAliasId.ToString();
            if ( benevolenceRequest.CaseWorkerPersonAlias != null &&
                benevolenceRequest.CaseWorkerPersonAlias.Person != null &&
                !personList.Select( p => p.Id ).ToList().Contains( benevolenceRequest.CaseWorkerPersonAlias.Person.Id ) )
            {
                personList.Add( benevolenceRequest.CaseWorkerPersonAlias.Person );
            }

            ddlCaseWorker.DataSource = personList.OrderBy( p => p.NickName ).ThenBy( p => p.LastName ).ToList();
            ddlCaseWorker.DataTextField = "FullName";
            ddlCaseWorker.DataValueField = "PrimaryAliasId";
            ddlCaseWorker.DataBind();
            ddlCaseWorker.Items.Insert( 0, new ListItem() );
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:29,代码来源:BenevolenceRequestDetail.ascx.cs

示例6: ListGroups

        private void ListGroups()
        {
            RockContext rockContext = new RockContext();

            var qry = new GroupMemberService(rockContext)
                        .Queryable("Group")
                        .Where( m => m.PersonId == CurrentPersonId
                                && m.GroupMemberStatus == GroupMemberStatus.Active
                                && m.Group.IsActive == true);

            List<Guid> includeGroupTypeGuids = GetAttributeValue( "IncludeGroupTypes" ).SplitDelimitedValues().Select( a => Guid.Parse( a ) ).ToList();
            if ( includeGroupTypeGuids.Count > 0 )
            {
                qry = qry.Where( t => includeGroupTypeGuids.Contains( t.Group.GroupType.Guid ) );
            }

            List<Guid> excludeGroupTypeGuids = GetAttributeValue( "ExcludeGroupTypes" ).SplitDelimitedValues().Select( a => Guid.Parse( a ) ).ToList();
            if ( excludeGroupTypeGuids.Count > 0 )
            {
                qry = qry.Where( t => !excludeGroupTypeGuids.Contains( t.Group.GroupType.Guid ) );
            }

            var groups = qry.Select( m => new GroupInvolvementSummary  { Group = m.Group, Role = m.GroupRole.Name, IsLeader = m.GroupRole.IsLeader, GroupType = m.Group.GroupType.Name } ).ToList();

            var mergeFields = new Dictionary<string, object>();
            mergeFields.Add( "Groups", groups );
            mergeFields.Add( "CurrentPerson", CurrentPerson );
            var globalAttributeFields = Rock.Web.Cache.GlobalAttributesCache.GetMergeFields( CurrentPerson );
            globalAttributeFields.ToList().ForEach( d => mergeFields.Add( d.Key, d.Value ) );

            Dictionary<string, object> linkedPages = new Dictionary<string, object>();
            linkedPages.Add( "DetailPage", LinkedPageUrl( "DetailPage", null ) );
            mergeFields.Add( "LinkedPages", linkedPages );

            string template = GetAttributeValue( "LavaTemplate" );

            // show debug info
            bool enableDebug = GetAttributeValue( "EnableDebug" ).AsBoolean();
            if ( enableDebug && IsUserAuthorized( Authorization.EDIT ) )
            {
                lDebug.Visible = true;
                lDebug.Text = mergeFields.lavaDebugInfo();
            }

            lContent.Text = template.ResolveMergeFields( mergeFields );
        }
开发者ID:RMRDevelopment,项目名称:Rockit,代码行数:46,代码来源:GroupListPersonalizedLava.ascx.cs

示例7: modalAddPerson_SaveClick

        /// <summary>
        /// Handles the SaveClick event of the modalAddPerson control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        void modalAddPerson_SaveClick( object sender, EventArgs e )
        {
            if ( hfActiveTab.Value == "Existing" )
            {
                if ( ppPerson.PersonId.HasValue )
                {
                    var existingfamilyMember = FamilyMembers.Where( m => m.Id == ppPerson.PersonId.Value ).FirstOrDefault();
                    if ( existingfamilyMember != null )
                    {
                        existingfamilyMember.Removed = false;
                    }
                    else
                    {
                        var rockContext = new RockContext();
                        var person = new PersonService( rockContext ).Get( ppPerson.PersonId.Value );
                        if ( person != null )
                        {
                            var familyMember = new FamilyMember();
                            familyMember.SetValuesFromPerson( person );

                            var familyRoleIds = familyRoles.Select( r => r.Id ).ToList();

                            var existingFamilyRoles = new GroupMemberService( rockContext ).Queryable( "GroupRole" )
                                .Where( m => m.PersonId == person.Id && familyRoleIds.Contains( m.GroupRoleId ) )
                                .OrderBy( m => m.GroupRole.Order )
                                .ToList();

                            var existingRole = existingFamilyRoles.Select( m => m.GroupRole ).FirstOrDefault();
                            if ( existingRole != null )
                            {
                                familyMember.RoleGuid = existingRole.Guid;
                                familyMember.RoleName = existingRole.Name;
                            }

                            familyMember.ExistingFamilyMember = existingFamilyRoles.Any( r => r.GroupId == _family.Id );
                            familyMember.RemoveFromOtherFamilies = cbRemoveOtherFamilies.Checked;

                            FamilyMembers.Add( familyMember );
                        }
                    }
                }
            }
            else
            {
                var familyMember = new FamilyMember();
                familyMember.TitleValueId = ddlNewPersonTitle.SelectedValueAsId();
                familyMember.FirstName = tbNewPersonFirstName.Text;
                familyMember.NickName = tbNewPersonFirstName.Text;
                familyMember.LastName = tbNewPersonLastName.Text;
                familyMember.SuffixValueId = ddlNewPersonSuffix.SelectedValueAsId();
                familyMember.Gender = rblNewPersonGender.SelectedValueAsEnum<Gender>();
                familyMember.MaritalStatusValueId = ddlNewPersonMaritalStatus.SelectedValueAsInt();
                DateTime? birthdate = dpNewPersonBirthDate.SelectedDate;
                if ( birthdate.HasValue )
                {
                    // If setting a future birthdate, subtract a century until birthdate is not greater than today.
                    var today = RockDateTime.Today;
                    while ( birthdate.Value.CompareTo( today ) > 0 )
                    {
                        birthdate = birthdate.Value.AddYears( -100 );
                    }
                }
                familyMember.BirthDate = birthdate;
                familyMember.GradeOffset = ddlGradePicker.SelectedValueAsInt();
                familyMember.ConnectionStatusValueId = ddlNewPersonConnectionStatus.SelectedValueAsId();
                var role = familyRoles.Where( r => r.Id == ( rblNewPersonRole.SelectedValueAsInt() ?? 0 ) ).FirstOrDefault();
                if ( role != null )
                {
                    familyMember.RoleGuid = role.Guid;
                    familyMember.RoleName = role.Name;
                }

                FamilyMembers.Add( familyMember );
            }

            ppPerson.Required = false;
            tbNewPersonFirstName.Required = false;
            tbNewPersonLastName.Required = false;
            rblNewPersonRole.Required = false;
            rblNewPersonGender.Required = false;
            ddlNewPersonConnectionStatus.Required = false;

            confirmExit.Enabled = true;

            hfActiveTab.Value = string.Empty;

            modalAddPerson.Hide();

            BindMembers();
        }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:95,代码来源:EditFamily.ascx.cs

示例8: BindGrid

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

            if ( ( GetAttributeValue( "DisplayFilter" ) ?? "false" ).AsBoolean() )
            {
                int? groupTypeFilter = gfSettings.GetUserPreference( "Group Type" ).AsInteger( false );
                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( "GroupTypeOrder, GroupTypeName, GroupOrder, Name", SortDirection.Ascending ) );
            }

            bool onlySecurityGroups = GetAttributeValue( "LimittoSecurityRoleGroups" ).AsBoolean();
            bool showDescriptionColumn = GetAttributeValue( "DisplayDescriptionColumn" ).AsBoolean();
            bool showActiveStatusColumn = GetAttributeValue( "DisplayActiveStatusColumn" ).AsBoolean();
            bool showSystemColumn = GetAttributeValue( "DisplaySystemColumn" ).AsBoolean();

            if ( !showDescriptionColumn )
            {
                gGroups.TooltipField = "Description";
            }

            Dictionary<string, BoundField> boundFields = gGroups.Columns.OfType<BoundField>().ToDictionary( a => a.DataField );
            boundFields["GroupTypeName"].Visible = GetAttributeValue( "DisplayGroupTypeColumn" ).AsBoolean();
            boundFields["Description"].Visible = showDescriptionColumn;

            Dictionary<string, BoolField> boolFields = gGroups.Columns.OfType<BoolField>().ToDictionary( a => a.DataField );
            boolFields["IsActive"].Visible = showActiveStatusColumn;
            boolFields["IsSystem"].Visible = showSystemColumn;

            // Person context will exist if used on a person detail page
            var personContext = ContextEntity<Person>();
            if ( personContext != null )
            {
                boundFields["GroupRole"].Visible = true;
                boundFields["DateAdded"].Visible = true;
                boundFields["MemberCount"].Visible = false;

                gGroups.Actions.ShowAdd = false;
                gGroups.IsDeleteEnabled = false;
                gGroups.Columns.OfType<DeleteField>().ToList().ForEach( f => f.Visible = false );

                var qry = new GroupMemberService( rockContext ).Queryable()
                    .Where( m =>
                        m.PersonId == personContext.Id &&
                        groupTypeIds.Contains( m.Group.GroupTypeId ) &&
                        ( !onlySecurityGroups || m.Group.IsSecurityRole ) );

                // Filter by active/inactive
                if ( ddlActiveFilter.SelectedIndex > -1 )
                {
                    if ( ddlActiveFilter.SelectedValue == "inactive" )
                    {
                        qry = qry.Where( a => a.Group.IsActive == false );
                    }
                    else if ( ddlActiveFilter.SelectedValue == "active" )
                    {
                        qry = qry.Where( a => a.Group.IsActive == true );
                    }
                }

                gGroups.DataSource = qry
                    .Select( m => new
                        {
                            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.GroupRole.Name,
                            DateAdded = m.CreatedDateTime,
                            IsActive = m.Group.IsActive,
                            MemberCount = 0
                        } )
                    .Sort( sortProperty )
                    .ToList();
            }
            else
            {
                bool canEdit = IsUserAuthorized( Authorization.EDIT );
                gGroups.Actions.ShowAdd = canEdit;
                gGroups.IsDeleteEnabled = canEdit;

                boundFields["GroupRole"].Visible = false;
                boundFields["DateAdded"].Visible = false;
//.........这里部分代码省略.........
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:101,代码来源:GroupList.ascx.cs

示例9: 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 System.Linq.Expressions.Expression GetExpression( Data.RockContext context, System.Linq.Expressions.MemberExpression entityIdProperty, string selection )
        {
            bool showAsLink = this.GetAttributeValueFromSelection( "ShowAsLink", selection ).AsBooleanOrNull() ?? false;
            int displayOrder = this.GetAttributeValueFromSelection( "DisplayOrder", selection ).AsIntegerOrNull() ?? 0;

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

            IQueryable<string> personLinkQuery;

            if ( showAsLink )
            {
                // Return a string in the format: <a href='/person/{personId}'>LastName, NickName</a>
                if ( displayOrder == 0 )
                {
                    personLinkQuery = memberQuery.Select( gm => "<a href='/person/" + gm.PersonId.ToString() + "'>" + gm.Person.NickName + " " + gm.Person.LastName + "</a>" );
                }
                else
                {
                    personLinkQuery = memberQuery.Select( gm => "<a href='/person/" + gm.PersonId.ToString() + "'>" + gm.Person.LastName + ", " + gm.Person.NickName + "</a>" );
                }
            }
            else
            {
                if ( displayOrder == 0 )
                {
                    personLinkQuery = memberQuery.Select( gm => gm.Person.NickName + " " + gm.Person.LastName );
                }
                else
                {
                    personLinkQuery = memberQuery.Select( gm => gm.Person.LastName + ", " + gm.Person.NickName );
                }
            }

            var exp = SelectExpressionExtractor.Extract( personLinkQuery, entityIdProperty, "gm" );

            return exp;
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:44,代码来源:PersonLinkSelect.cs

示例10: 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 System.Linq.Expressions.Expression GetExpression( Data.RockContext context, System.Linq.Expressions.MemberExpression entityIdProperty, string selection )
        {
            bool showAsLink = this.GetAttributeValueFromSelection( "ShowAsLink", selection ).AsBooleanOrNull() ?? false;

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

            IQueryable<string> groupLinkQuery;

            if ( showAsLink )
            {
                // Return a string in the format: <a href='/group/{groupId}'>Group Name</a>
                groupLinkQuery = memberQuery.Select( gm => "<a href='/group/" + gm.GroupId.ToString() + "'>" + gm.Group.Name + "</a>" );
            }
            else
            {
                groupLinkQuery = memberQuery.Select( gm => gm.Group.Name );
            }

            var exp = SelectExpressionExtractor.Extract( groupLinkQuery, entityIdProperty, "gm" );

            return exp;
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:29,代码来源:GroupLinkSelect.cs

示例11: 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( "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" );

            if ( limitToActiveStatus == "all" && gfSettings.Visible )
            {
                // Filter by active/inactive unless the block settings restrict it
                if ( ddlActiveFilter.SelectedIndex > -1 )
                {
                    if ( ddlActiveFilter.SelectedValue == "inactive" )
                    {
                        qryGroups = qryGroups.Where( a => a.IsActive == false );
                    }
                    else if ( ddlActiveFilter.SelectedValue == "active" )
                    {
                        qryGroups = qryGroups.Where( a => a.IsActive == true );
                    }
                }
            }
            else if ( limitToActiveStatus != "all")
            {
                // filter by the block settinf for Active Status
                if ( limitToActiveStatus == "inactive")
                {
                    qryGroups = qryGroups.Where( a => a.IsActive == false );
                }
                else if ( limitToActiveStatus == "active" )
                {
                    qryGroups = qryGroups.Where( a => a.IsActive == true );
                }
            }

            // 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 } );

                    gGroups.DataSource = qry
                        .Select( m => new
                            {
                                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,
                                MemberCount = 0
                            } )
                        .Sort( sortProperty )
                        .ToList();
                }
            }
            else
            {
                var roleGroupType = GroupTypeCache.Read( Rock.SystemGuid.GroupType.GROUPTYPE_SECURITY_ROLE.AsGuid() );
                int roleGroupTypeId = roleGroupType != null ? roleGroupType.Id : 0;
                bool useRolePrefix = onlySecurityGroups || groupTypeIds.Contains( roleGroupTypeId );

                gGroups.DataSource = qryGroups.Select( g => new
                        {
                            Id = g.Id,
                            Name = (( useRolePrefix && g.GroupType.Id != roleGroupTypeId ) ? "GROUP - " : "" ) + g.Name,
//.........这里部分代码省略.........
开发者ID:Higherbound,项目名称:Higherbound-2016-website-upgrades,代码行数:101,代码来源:GroupList.ascx.cs

示例12: 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;
            string filterValue = string.Empty;
            string filterKey = string.Empty;

            // get the group attribute
            groupGuid = GetAttributeValue( action, "SelectionGroup" ).AsGuid();

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

            // get filter key
            filterKey = GetAttributeValue( action, "GroupMemberAttributeKey" );

            // get the filter value
            filterValue = GetAttributeValue( action, "FilterValue" );
            Guid? filterValueGuid = filterValue.AsGuidOrNull();
            if ( filterValueGuid.HasValue )
            {
                filterValue = action.GetWorklowAttributeValue( filterValueGuid.Value );
            }
            else
            {
                filterValue = filterValue.ResolveMergeFields( GetMergeFields( action ) );
            }

            // get group members
            var qry = new GroupMemberService( rockContext ).Queryable().AsNoTracking()
                                    .Where( g => g.Group.Guid == groupGuid );

            if (!string.IsNullOrWhiteSpace(filterKey)){
                qry = qry.WhereAttributeValue( rockContext, filterKey, filterValue );
            }

            var groupMembers = qry.Select( g => new {
                                        g.Person.NickName,
                                        g.Person.LastName,
                                        g.Person.SuffixValueId,
                                        PrimaryAliasGuid = g.Person.Aliases.FirstOrDefault().Guid } )
                                   .ToList();

            if ( groupMembers.Count() > 0 )
            {
                // get random group member from options
                Random rnd = new Random();
                int r = rnd.Next( groupMembers.Count );

                var selectedGroupMember = groupMembers[r];

                // set value
                Guid selectPersonGuid = GetAttributeValue( action, "SelectedPerson" ).AsGuid();
                if ( !selectPersonGuid.IsEmpty() )
                {
                    var selectedPersonAttribute = AttributeCache.Read( selectPersonGuid, rockContext );
                    if ( selectedPersonAttribute != null )
                    {
                        // If this is a person type attribute
                        if ( selectedPersonAttribute.FieldTypeId == FieldTypeCache.Read( Rock.SystemGuid.FieldType.PERSON.AsGuid(), rockContext ).Id )
                        {
                            SetWorkflowAttributeValue( action, selectPersonGuid, selectedGroupMember.PrimaryAliasGuid.ToString() );
                        }
                        else if ( selectedPersonAttribute.FieldTypeId == FieldTypeCache.Read( Rock.SystemGuid.FieldType.TEXT.AsGuid(), rockContext ).Id )
                        {
                            SetWorkflowAttributeValue( action, selectPersonGuid, Person.FormatFullName(selectedGroupMember.NickName, selectedGroupMember.LastName, selectedGroupMember.SuffixValueId)  );
                        }
                    }
                }
            }
            else
            {
                errorMessages.Add( "No group member for the selected campus could be found." );
            }

            errorMessages.ForEach( m => action.AddLogEntry( m, true ) );

            return true;
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:90,代码来源:SetAttributeToRandomGroupMember.cs

示例13: BindFamilies

        private void BindFamilies( RockContext rockContext, IQueryable<Person> personQry, IQueryable<int> dataviewPersonIdQry )
        {
            var familyGroupType = GroupTypeCache.Read( Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY.AsGuid() );

            var personIds = personQry.Select( p => p.Id );

            var groupMemberQry = new GroupMemberService( rockContext )
                .Queryable().AsNoTracking()
                .Where( m =>
                    m.Group.GroupTypeId == familyGroupType.Id &&
                    personIds.Contains( m.PersonId ) );

            var familyIdQry = groupMemberQry.Select( m => m.GroupId ).Distinct();

            _familyMembers = new GroupService( rockContext )
                .Queryable().AsNoTracking()
                .Where( g => familyIdQry.Contains( g.Id ) )
                .Select( g => new
                {
                    GroupId = g.Id,
                    People = g.Members
                        .Where( m => dataviewPersonIdQry.Contains( m.PersonId ) )
                        .OrderBy( m => m.GroupRole.Order )
                        .ThenBy( m => m.Person.BirthDate )
                        .Select( m => m.Person )
                        .Select( p => new PersonDirectoryItem
                        {
                            Id = p.Id,
                            RecordTypeValueId = p.RecordTypeValueId,
                            NickName = p.NickName,
                            LastName = p.LastName,
                            Email = p.Email,
                            BirthMonth = p.BirthMonth,
                            BirthDay = p.BirthDay,
                            BirthDate = p.BirthDate,
                            Gender = p.Gender,
                            PhotoId = p.PhotoId,
                            GraduationYear = p.GraduationYear
                        } )
                        .ToList()
                } )
                .ToDictionary( k => k.GroupId, v => v.People );

            if ( _showAddress )
            {
                var homeLoc = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME.AsGuid() );
                if ( familyGroupType != null && homeLoc != null )
                {
                    _addresses = new GroupService( rockContext )
                        .Queryable().AsNoTracking()
                        .Where( g => familyIdQry.Contains( g.Id ) )
                        .Select( g => new
                        {
                            g.Id,
                            HomeLocations = g.GroupLocations
                                .Where( gl =>
                                    gl.GroupLocationTypeValueId.HasValue &&
                                    gl.GroupLocationTypeValueId == homeLoc.Id )
                                .Select( gl => gl.Location )
                                .ToList()
                        } )
                        .ToDictionary( k => k.Id, v => v.HomeLocations );
                }
            }

            if ( _phoneNumberCaptions.Any() )
            {
                var familyPersonIds = _familyMembers
                    .SelectMany( m => m.Value )
                    .Select( p => p.Id )
                    .Distinct()
                    .ToList();
                LoadPhoneNumbers( rockContext, familyPersonIds );
            }

            var families = groupMemberQry.Select( m => new FamilyDirectoryItem
            {
                Id = m.GroupId,
                Name = m.Group.Name
            } )
            .Distinct()
            .Take( GetAttributeValue( "MaxResults" ).AsInteger() )
            .ToList();

            rptFamilies.DataSource = families;
            rptFamilies.DataBind();
            rptFamilies.Visible = true;

            rptPeople.Visible = false;
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:90,代码来源:PersonDirectory.ascx.cs


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