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


C# PersonService.Take方法代码示例

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


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

示例1: Search

        public IQueryable<PersonSearchResult> Search( string name, bool includeHtml)
        {
            int count = 20;
            bool reversed;
            IOrderedQueryable<Person> sortedPersonQry = new PersonService().Queryable().QueryByName( name, out reversed );

            var topQry = sortedPersonQry.Take( count );
            List<Person> sortedPersonList = topQry.ToList();

            var appPath = System.Web.VirtualPathUtility.ToAbsolute( "~" );
            string itemDetailFormat = @"
<div class='picker-select-item-details clearfix' style='display: none;'>
	{0}
	<div class='contents'>
        {1}
	</div>
</div>
";

            Guid activeRecord = new Guid( SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE );
 
            // figure out Family, Address, Spouse
            GroupMemberService groupMemberService = new GroupMemberService();

            List<PersonSearchResult> searchResult = new List<PersonSearchResult>();
            foreach ( var person in sortedPersonList)
            {
                PersonSearchResult personSearchResult = new PersonSearchResult();
                personSearchResult.Name = reversed ? person.FullNameReversed : person.FullName;
                personSearchResult.ImageHtmlTag = Person.GetPhotoImageTag( person.PhotoId, person.Gender, 50, 50 );
                personSearchResult.Age = person.Age.HasValue ? person.Age.Value : -1;
                personSearchResult.ConnectionStatus = person.ConnectionStatusValue != null ? person.ConnectionStatusValue.Name : string.Empty;
                personSearchResult.Gender = person.Gender.ConvertToString();

                if ( person.RecordStatusValue != null )
                {
                    personSearchResult.RecordStatus = person.RecordStatusValue.Name;
                    personSearchResult.IsActive = person.RecordStatusValue.Guid.Equals( activeRecord );
                }
                else
                {
                    personSearchResult.RecordStatus = string.Empty;
                    personSearchResult.IsActive = false;
                }

                personSearchResult.Id = person.Id;

                if ( includeHtml )
                {
                    string imageHtml = null;

                    imageHtml = Person.GetPhotoImageTag(person.PhotoId, person.Gender, 65, 65);

                    string personInfo = string.Empty;

                    var groupMemberQry = groupMemberService.Queryable().Where( a => a.PersonId.Equals( person.Id ) );
                    List<GroupMember> personGroupMember = groupMemberQry.ToList();

                    Guid familyGuid = new Guid( Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY );
                    Guid adultGuid = new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT );

                    GroupMember familyGroupMember = personGroupMember.Where( a => a.Group.GroupType.Guid.Equals( familyGuid ) ).FirstOrDefault();
                    if ( familyGroupMember != null )
                    {
                        personInfo += familyGroupMember.GroupRole.Name;
                        if ( person.Age != null )
                        {
                            personInfo += " <em>(" + person.Age.ToString() + " yrs old)</em>";
                        }

                        // Figure out spouse (Implied by "the other GROUPROLE_FAMILY_MEMBER_ADULT that is of the opposite gender")
                        if ( familyGroupMember.GroupRole.Guid.Equals( adultGuid ) )
                        {
                            person.GetSpouse();
                            GroupMember spouseMember = familyGroupMember.Group.Members.Where( a => !a.PersonId.Equals( person.Id ) && a.GroupRole.Guid.Equals( adultGuid ) ).FirstOrDefault();
                            if ( spouseMember != null )
                            {
                                if ( !familyGroupMember.Person.Gender.Equals( spouseMember.Person.Gender ) )
                                {
                                    personInfo += "<p><strong>Spouse:</strong> " + spouseMember.Person.FullName + "</p>";
                                }
                            }
                        }
                    }
                    else
                    {
                        if ( person.Age != null )
                        {
                            personInfo += person.Age.ToString() + " yrs old";
                        }
                    }

                    if ( familyGroupMember != null )
                    {
                        var groupLocation = familyGroupMember.Group.GroupLocations.FirstOrDefault();
                        if ( groupLocation != null )
                        {
                            var location = groupLocation.Location;
                            if ( location != null )
                            {
//.........这里部分代码省略.........
开发者ID:pkdevbox,项目名称:Rock,代码行数:101,代码来源:PeopleController.Partial.cs

示例2: Search

        public IQueryable<PersonSearchResult> Search( string name, bool includeHtml )
        {
            int count = 20;
            bool reversed;
            bool allowFirstNameOnly = false;

            var searchComponent = Rock.Search.SearchContainer.GetComponent( typeof( Rock.Search.Person.Name ) );
            if ( searchComponent != null )
            {
                allowFirstNameOnly = searchComponent.GetAttributeValue( "FirstNameSearch" ).AsBoolean();
            }

            var rockContext = new Rock.Data.RockContext();
            IOrderedQueryable<Person> sortedPersonQry = new PersonService( rockContext )
                .GetByFullNameOrdered( name, true, false, allowFirstNameOnly, out reversed );

            var topQry = sortedPersonQry.Take( count );
            List<Person> sortedPersonList = topQry.ToList();

            var appPath = System.Web.VirtualPathUtility.ToAbsolute( "~" );
            string itemDetailFormat = @"
<div class='picker-select-item-details clearfix' style='display: none;'>
	{0}
	<div class='contents'>
        {1}
	</div>
</div>
";
            Guid activeRecord = new Guid( SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE );

            // figure out Family, Address, Spouse
            GroupMemberService groupMemberService = new GroupMemberService( rockContext );

            List<PersonSearchResult> searchResult = new List<PersonSearchResult>();
            foreach ( var person in sortedPersonList )
            {
                PersonSearchResult personSearchResult = new PersonSearchResult();
                personSearchResult.Name = reversed ? person.FullNameReversed : person.FullName;
                personSearchResult.ImageHtmlTag = Person.GetPhotoImageTag( person.PhotoId, person.Gender, 50, 50 );
                personSearchResult.Age = person.Age.HasValue ? person.Age.Value : -1;
                personSearchResult.ConnectionStatus = person.ConnectionStatusValueId.HasValue ? DefinedValueCache.Read( person.ConnectionStatusValueId.Value ).Name : string.Empty;
                personSearchResult.Gender = person.Gender.ConvertToString();
                personSearchResult.Email = person.Email;

                if ( person.RecordStatusValueId.HasValue )
                {
                    var recordStatus = DefinedValueCache.Read( person.RecordStatusValueId.Value );
                    personSearchResult.RecordStatus = recordStatus.Name;
                    personSearchResult.IsActive = recordStatus.Guid.Equals( activeRecord );
                }
                else
                {
                    personSearchResult.RecordStatus = string.Empty;
                    personSearchResult.IsActive = false;
                }

                personSearchResult.Id = person.Id;

                string imageHtml = string.Format(
                    "<div class='person-image' style='background-image:url({0}&width=65);background-size:cover;background-position:50%'></div>",
                    Person.GetPhotoUrl( person.PhotoId, person.Gender ) );

                string personInfo = string.Empty;

                Guid adultGuid = new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT );

                Guid familyGuid = new Guid( Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY );
                var familyGroupMember = groupMemberService.Queryable()
                    .Where( a => a.PersonId == person.Id )
                    .Where( a => a.Group.GroupType.Guid.Equals( familyGuid ) )
                    .Select( s => new
                    {
                        s.GroupRole,
                        GroupLocation = s.Group.GroupLocations.Select( a => a.Location ).FirstOrDefault()
                    } ).FirstOrDefault();

                if ( familyGroupMember != null )
                {
                    personInfo += familyGroupMember.GroupRole.Name;
                    if ( person.Age != null )
                    {
                        personInfo += " <em>(" + person.Age.ToString() + " yrs old)</em>";
                    }

                    if ( familyGroupMember.GroupRole.Guid.Equals( adultGuid ) )
                    {
                        var spouse = person.GetSpouse();
                        if ( spouse != null )
                        {
                            personInfo += "<p><strong>Spouse:</strong> " + spouse.FullName + "</p>";
                            personSearchResult.SpouseName = spouse.FullName;
                        }
                    }
                }
                else
                {
                    if ( person.Age != null )
                    {
                        personInfo += person.Age.ToString() + " yrs old";
                    }
//.........这里部分代码省略.........
开发者ID:jondhinkle,项目名称:Rock,代码行数:101,代码来源:PeopleController.Partial.cs


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