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


C# PersonService.OrderBy方法代码示例

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


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

示例1: lbPrintAttendanceRoster_Click

        /// <summary>
        /// Handles the Click event of the lbPrintAttendanceRoster 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 lbPrintAttendanceRoster_Click( object sender, EventArgs e )
        {
            // NOTE: lbPrintAttendanceRoster is a full postback since we are returning a download of the roster

            nbPrintRosterWarning.Visible = false;
            var rockContext = new RockContext();

            Dictionary<int, object> mergeObjectsDictionary = new Dictionary<int, object>();
            if ( _attendees != null )
            {
                var personIdList = _attendees.Select( a => a.PersonId ).ToList();
                var personList = new PersonService( rockContext ).GetByIds( personIdList );
                foreach ( var person in personList.OrderBy( a => a.LastName ).ThenBy( a => a.NickName ) )
                {
                    mergeObjectsDictionary.AddOrIgnore( person.Id, person );
                }
            }

            var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields( this.RockPage, this.CurrentPerson );
            mergeFields.Add( "Group", this._group );

            var mergeTemplate = new MergeTemplateService( rockContext ).Get( this.GetAttributeValue( "AttendanceRosterTemplate" ).AsGuid() );

            if ( mergeTemplate == null )
            {
                this.LogException( new Exception( "No Merge Template specified in block settings" ) );
                nbPrintRosterWarning.Visible = true;
                nbPrintRosterWarning.Text = "Unable to print Attendance Roster";
                return;
            }

            MergeTemplateType mergeTemplateType = mergeTemplate.GetMergeTemplateType();
            if ( mergeTemplateType == null )
            {
                this.LogException( new Exception( "Unable to determine Merge Template Type" ) );
                nbPrintRosterWarning.Visible = true;
                nbPrintRosterWarning.Text = "Error printing Attendance Roster";
                return;
            }

            BinaryFile outputBinaryFileDoc = null;

            var mergeObjectList = mergeObjectsDictionary.Select( a => a.Value ).ToList();

            outputBinaryFileDoc = mergeTemplateType.CreateDocument( mergeTemplate, mergeObjectList, mergeFields );

            // set the name of the output doc
            outputBinaryFileDoc = new BinaryFileService( rockContext ).Get( outputBinaryFileDoc.Id );
            outputBinaryFileDoc.FileName = _group.Name + " Attendance Roster" + Path.GetExtension( outputBinaryFileDoc.FileName ?? "" ) ?? ".docx";
            rockContext.SaveChanges();

            if ( mergeTemplateType.Exceptions != null && mergeTemplateType.Exceptions.Any() )
            {
                if ( mergeTemplateType.Exceptions.Count == 1 )
                {
                    this.LogException( mergeTemplateType.Exceptions[0] );
                }
                else if ( mergeTemplateType.Exceptions.Count > 50 )
                {
                    this.LogException( new AggregateException( string.Format( "Exceptions merging template {0}. See InnerExceptions for top 50.", mergeTemplate.Name ), mergeTemplateType.Exceptions.Take( 50 ).ToList() ) );
                }
                else
                {
                    this.LogException( new AggregateException( string.Format( "Exceptions merging template {0}. See InnerExceptions", mergeTemplate.Name ), mergeTemplateType.Exceptions.ToList() ) );
                }
            }

            var uri = new UriBuilder( outputBinaryFileDoc.Url );
            var qry = System.Web.HttpUtility.ParseQueryString( uri.Query );
            qry["attachment"] = true.ToTrueFalse();
            uri.Query = qry.ToString();
            Response.Redirect( uri.ToString(), false );
            Context.ApplicationInstance.CompleteRequest();
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:79,代码来源:GroupAttendanceDetail.ascx.cs

示例2: BindGrid

        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            var rockContext = new RockContext();
            var restUserRecordTypeId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_RESTUSER.AsGuid() ).Id;
            var activeRecordStatusValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE.AsGuid() ).Id;
            var queryable = new PersonService( rockContext ).Queryable()
                .Where( q => q.RecordTypeValueId == restUserRecordTypeId && q.RecordStatusValueId == activeRecordStatusValueId );

            SortProperty sortProperty = gRestKeyList.SortProperty;
            if ( sortProperty != null )
            {
                gRestKeyList.DataSource = queryable.Sort( sortProperty ).ToList();
            }
            else
            {
                gRestKeyList.DataSource = queryable.OrderBy( q => q.LastName ).ToList();
            }

            gRestKeyList.DataBind();
        }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:23,代码来源:RestKeyList.ascx.cs

示例3: BindGrid

        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            var rockContext = new RockContext();
            var recordTypeValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_BUSINESS.AsGuid() ).Id;

            var queryable = new PersonService( rockContext ).Queryable()
                .Where( q => q.RecordTypeValueId == recordTypeValueId );

            // Business Name Filter
            var businessName = gfBusinessFilter.GetUserPreference( "Business Name" );
            if ( !string.IsNullOrWhiteSpace( businessName ) )
            {
                queryable = queryable.Where( a => a.FirstName.Contains( businessName ) );
            }

            var activeRecordStatusValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE.AsGuid() ).Id;
            string activeFilterValue = gfBusinessFilter.GetUserPreference( "Active Status" );
            if (activeFilterValue == "inactive")
            {
                queryable = queryable.Where( b => b.RecordStatusValueId != activeRecordStatusValueId );
            }
            else if (activeFilterValue == "active")
            {
                queryable = queryable.Where( b => b.RecordStatusValueId == activeRecordStatusValueId );
            }

            SortProperty sortProperty = gBusinessList.SortProperty;
            if ( sortProperty != null )
            {
                gBusinessList.DataSource = queryable.Sort( sortProperty ).ToList();
            }
            else
            {
                gBusinessList.DataSource = queryable.OrderBy( q => q.FirstName ).ToList();
            }

            gBusinessList.DataBind();
        }
开发者ID:Ganon11,项目名称:Rock,代码行数:41,代码来源:BusinessList.ascx.cs

示例4: BindGrid

        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            var rockContext = new RockContext();
            var recordTypeValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_BUSINESS.AsGuid() ).Id;

            var queryable = new PersonService( rockContext ).Queryable()
                .Where( q => q.RecordTypeValueId == recordTypeValueId );

            var businessName = string.Empty;
            bool viaSearch = false;

            // Use the name passed in the page parameter if given
            if ( !string.IsNullOrWhiteSpace( PageParameter( "SearchTerm" ) ) )
            {
                viaSearch = true;
                gfBusinessFilter.Visible = false;
                businessName = PageParameter( "SearchTerm" );
            }
            else
            {
                // Business Name Filter
                businessName = gfBusinessFilter.GetUserPreference( "Business Name" );
            }

            if ( !string.IsNullOrWhiteSpace( businessName ) )
            {
                queryable = queryable.Where( a => a.LastName.Contains( businessName ) );
            }

            if ( ! viaSearch )
            {
                var activeRecordStatusValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE.AsGuid() ).Id;
                string activeFilterValue = gfBusinessFilter.GetUserPreference( "Active Status" );
                if ( activeFilterValue == "inactive" )
                {
                    queryable = queryable.Where( b => b.RecordStatusValueId != activeRecordStatusValueId );
                }
                else if ( activeFilterValue == "active" )
                {
                    queryable = queryable.Where( b => b.RecordStatusValueId == activeRecordStatusValueId );
                }

                SortProperty sortProperty = gBusinessList.SortProperty;
                if ( sortProperty != null )
                {
                    queryable = queryable.Sort( sortProperty );
                }
                else
                {
                    queryable = queryable.OrderBy( q => q.LastName );
                }
            }

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

            var businessList = queryable.Select( b => new
            {
                Id = b.Id,
                b.LastName,
                BusinessName = b.LastName,
                PhoneNumber = b.PhoneNumbers.FirstOrDefault().NumberFormatted,
                Email = b.Email,
                Address = b.Members
                                .Where( m => m.Group.GroupType.Guid.ToString() == Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY )
                                .SelectMany( m => m.Group.GroupLocations )
                                .FirstOrDefault()
                                .Location,
                Contacts = b.Members
                                .Where( m => m.Group.GroupType.Guid.ToString() == Rock.SystemGuid.GroupType.GROUPTYPE_KNOWN_RELATIONSHIPS )
                                .SelectMany( m => m.Group.Members)
                                .Where( p => p.GroupRole.Guid.ToString() == Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_OWNER && p.PersonId != b.Id)
                                .Select( p => p.Person.LastName + ", " + p.Person.NickName)
            } );

            if ( viaSearch && businessList.ToList().Count == 1 )
            {
                ShowDetailForm( businessList.ToList()[0].Id );
            }
            else
            {
                gBusinessList.EntityTypeId = EntityTypeCache.Read<Person>().Id;
                gBusinessList.DataSource = businessList.ToList();
                gBusinessList.DataBind();
            }
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:88,代码来源:BusinessList.ascx.cs

示例5: BindGrid

        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            var rockContext = new RockContext();
            var recordTypeValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_BUSINESS.AsGuid() ).Id;
            var activeRecordStatusValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE.AsGuid() ).Id;
            int? businessRoleId = new GroupTypeRoleService( rockContext ).Queryable()
                .Where( r =>
                    r.Guid.Equals( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_BUSINESS ) ) )
                .Select( r => r.Id )
                .FirstOrDefault();
            var queryable = new PersonService( rockContext ).Queryable()
                .Where( q => q.RecordTypeValueId == recordTypeValueId && q.RecordStatusValueId == activeRecordStatusValueId );

            // Business Name Filter
            var businessName = gfBusinessFilter.GetUserPreference( "Business Name" );
            if ( !string.IsNullOrWhiteSpace( businessName ) )
            {
                queryable = queryable.Where( a => a.FirstName.Contains( businessName ) );
            }

            // Owner Filter
            int ownerId = 0;
            if ( int.TryParse( gfBusinessFilter.GetUserPreference( "Owner" ), out ownerId ) && ownerId != 0 )
            {
                var members = queryable.SelectMany( a => a.Members ).ToList();
                foreach ( var member in members )
                {
                    if ( member.GroupRoleId == businessRoleId )
                    {
                        var groupMemberService = new GroupMemberService( rockContext );
                        var owner = groupMemberService.GetInverseRelationship( member, false, CurrentPersonAlias );
                        if ( owner.PersonId != ownerId )
                        {
                            queryable = queryable.Where( a => a.Id != member.PersonId );
                        }
                    }
                }
            }

            SortProperty sortProperty = gBusinessList.SortProperty;
            if ( sortProperty != null )
            {
                gBusinessList.DataSource = queryable.Sort( sortProperty ).ToList();
            }
            else
            {
                gBusinessList.DataSource = queryable.OrderBy( q => q.FirstName ).ToList();
            }

            gBusinessList.DataBind();
        }
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:54,代码来源:BusinessList.ascx.cs


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